| 2940 | } |
| 2941 | |
| 2942 | static int encode_thread(AVCodecContext *c, void *arg){ |
| 2943 | MPVEncContext *const s = *(void**)arg; |
| 2944 | int chr_h = 16 >> s->c.chroma_y_shift; |
| 2945 | int i; |
| 2946 | MBBackup best_s = { 0 }, backup_s; |
| 2947 | uint8_t bit_buf[2][MAX_MB_BYTES]; |
| 2948 | // + 2 because ff_copy_bits() overreads |
| 2949 | uint8_t bit_buf2[2][MAX_PB2_MB_SIZE + 2]; |
| 2950 | uint8_t bit_buf_tex[2][MAX_AC_TEX_MB_SIZE + 2]; |
| 2951 | PutBitContext pb[2], pb2[2], tex_pb[2]; |
| 2952 | |
| 2953 | for(i=0; i<2; i++){ |
| 2954 | init_put_bits(&pb [i], bit_buf [i], MAX_MB_BYTES); |
| 2955 | init_put_bits(&pb2 [i], bit_buf2 [i], MAX_PB2_MB_SIZE); |
| 2956 | init_put_bits(&tex_pb[i], bit_buf_tex[i], MAX_AC_TEX_MB_SIZE); |
| 2957 | } |
| 2958 | |
| 2959 | s->last_bits= put_bits_count(&s->pb); |
| 2960 | s->mv_bits=0; |
| 2961 | s->misc_bits=0; |
| 2962 | s->i_tex_bits=0; |
| 2963 | s->p_tex_bits=0; |
| 2964 | s->i_count=0; |
| 2965 | |
| 2966 | for(i=0; i<3; i++){ |
| 2967 | /* init last dc values */ |
| 2968 | /* note: quant matrix value (8) is implied here */ |
| 2969 | s->last_dc[i] = 128 << s->c.intra_dc_precision; |
| 2970 | |
| 2971 | s->encoding_error[i] = 0; |
| 2972 | } |
| 2973 | if (s->c.codec_id == AV_CODEC_ID_AMV) { |
| 2974 | s->last_dc[0] = 128 * 8 / 13; |
| 2975 | s->last_dc[1] = 128 * 8 / 14; |
| 2976 | s->last_dc[2] = 128 * 8 / 14; |
| 2977 | #if CONFIG_MPEG4_ENCODER |
| 2978 | } else if (s->partitioned_frame) { |
| 2979 | av_assert1(s->c.codec_id == AV_CODEC_ID_MPEG4); |
| 2980 | ff_mpeg4_init_partitions(s); |
| 2981 | #endif |
| 2982 | } |
| 2983 | s->mb_skip_run = 0; |
| 2984 | memset(s->c.last_mv, 0, sizeof(s->c.last_mv)); |
| 2985 | |
| 2986 | s->last_mv_dir = 0; |
| 2987 | |
| 2988 | s->c.resync_mb_x = 0; |
| 2989 | s->c.resync_mb_y = 0; |
| 2990 | s->c.first_slice_line = 1; |
| 2991 | s->ptr_lastgob = s->pb.buf; |
| 2992 | for (int mb_y_order = s->c.start_mb_y; mb_y_order < s->c.end_mb_y; mb_y_order++) { |
| 2993 | int mb_y; |
| 2994 | if (CONFIG_SPEEDHQ_ENCODER && s->c.codec_id == AV_CODEC_ID_SPEEDHQ) { |
| 2995 | int first_in_slice; |
| 2996 | mb_y = ff_speedhq_mb_y_order_to_mb(mb_y_order, s->c.mb_height, &first_in_slice); |
| 2997 | if (first_in_slice && mb_y_order != s->c.start_mb_y) |
| 2998 | ff_speedhq_end_slice(s); |
| 2999 | s->last_dc[0] = s->last_dc[1] = s->last_dc[2] = 1024; |
nothing calls this directly
no test coverage detected