last_pict_type, last_non_b_pict_type and last_lambda_for are only used by the encoder's main thread.
Unified · Split
| @@ -185,10 +185,7 @@ typedef struct MpegEncContext { · 184 unmodified lines | ||
| 185 | 185 | int adaptive_quant; ///< use adaptive quantization |
| 186 | 186 | int dquant; ///< qscale difference to prev qscale |
| 187 | 187 | int pict_type; ///< AV_PICTURE_TYPE_I, AV_PICTURE_TYPE_P, AV_PICTURE_TYPE_B, ... |
| 188 | − int last_pict_type; //FIXME removes | |
| 189 | − int last_non_b_pict_type; ///< used for MPEG-4 gmc B-frames & ratecontrol | |
| 190 | 188 | int droppable; |
| 191 | − int last_lambda_for[5]; ///< last lambda for a specific pict type | |
| 192 | 189 | int skipdct; ///< skip dct and code zero residual |
| 193 | 190 | |
| 194 | 191 | /* motion compensation */ |
| @@ -1515,9 +1515,9 @@ static int estimate_best_b_count(MPVMainEncContext *const m) · 1514 unmodified lines | ||
| 1515 | 1515 | return AVERROR(ENOMEM); |
| 1516 | 1516 | |
| 1517 | 1517 | //emms_c(); |
| 1518 | − p_lambda = s->last_lambda_for[AV_PICTURE_TYPE_P]; | |
| 1518 | + p_lambda = m->last_lambda_for[AV_PICTURE_TYPE_P]; | |
| 1519 | 1519 | //p_lambda * FFABS(s->avctx->b_quant_factor) + s->avctx->b_quant_offset; |
| 1520 | − b_lambda = s->last_lambda_for[AV_PICTURE_TYPE_B]; | |
| 1520 | + b_lambda = m->last_lambda_for[AV_PICTURE_TYPE_B]; | |
| 1521 | 1521 | if (!b_lambda) // FIXME we should do this somewhere else |
| 1522 | 1522 | b_lambda = p_lambda; |
| 1523 | 1523 | lambda2 = (b_lambda * b_lambda + (1 << FF_LAMBDA_SHIFT) / 2) >> |
| @@ -1871,10 +1871,10 @@ static void frame_end(MPVMainEncContext *const m) · 347 unmodified lines | ||
| 1871 | 1871 | |
| 1872 | 1872 | emms_c(); |
| 1873 | 1873 | |
| 1874 | − s->last_pict_type = s->pict_type; | |
| 1875 | − s->last_lambda_for [s->pict_type] = s->cur_pic.ptr->f->quality; | |
| 1874 | + m->last_pict_type = s->pict_type; | |
| 1875 | + m->last_lambda_for[s->pict_type] = s->cur_pic.ptr->f->quality; | |
| 1876 | 1876 | if (s->pict_type!= AV_PICTURE_TYPE_B) |
| 1877 | − s->last_non_b_pict_type = s->pict_type; | |
| 1877 | + m->last_non_b_pict_type = s->pict_type; | |
| 1878 | 1878 | } |
| 1879 | 1879 | |
| 1880 | 1880 | static void update_noise_reduction(MPVMainEncContext *const m) |
| @@ -3702,9 +3702,9 @@ static int encode_picture(MPVMainEncContext *const m, const AVPacket *pkt) · 1821 unmodified lines | ||
| 3702 | 3702 | ff_get_2pass_fcode(m); |
| 3703 | 3703 | } else if (!(s->avctx->flags & AV_CODEC_FLAG_QSCALE)) { |
| 3704 | 3704 | if(s->pict_type==AV_PICTURE_TYPE_B) |
| 3705 | − s->lambda= s->last_lambda_for[s->pict_type]; | |
| 3705 | + s->lambda = m->last_lambda_for[s->pict_type]; | |
| 3706 | 3706 | else |
| 3707 | − s->lambda= s->last_lambda_for[s->last_non_b_pict_type]; | |
| 3707 | + s->lambda = m->last_lambda_for[m->last_non_b_pict_type]; | |
| 3708 | 3708 | update_qscale(m); |
| 3709 | 3709 | } |
| 3710 | 3710 | |
| @@ -3735,7 +3735,7 @@ static int encode_picture(MPVMainEncContext *const m, const AVPacket *pkt) · 24 unmodified lines | ||
| 3735 | 3735 | s->lambda = (s->lambda * s->me_penalty_compensation + 128) >> 8; |
| 3736 | 3736 | s->lambda2 = (s->lambda2 * (int64_t) s->me_penalty_compensation + 128) >> 8; |
| 3737 | 3737 | if (s->pict_type != AV_PICTURE_TYPE_B) { |
| 3738 | − if ((s->me_pre && s->last_non_b_pict_type == AV_PICTURE_TYPE_I) || | |
| 3738 | + if ((s->me_pre && m->last_non_b_pict_type == AV_PICTURE_TYPE_I) || | |
| 3739 | 3739 | s->me_pre == 2) { |
| 3740 | 3740 | s->avctx->execute(s->avctx, pre_estimate_motion_thread, &s->thread_context[0], NULL, context_count, sizeof(void*)); |
| 3741 | 3741 | } |
| @@ -96,6 +96,9 @@ typedef struct MPVMainEncContext { · 95 unmodified lines | ||
| 96 | 96 | int stuffing_bits; ///< bits used for stuffing |
| 97 | 97 | int next_lambda; ///< next lambda used for retrying to encode a frame |
| 98 | 98 | int fixed_qscale; ///< fixed qscale if non zero |
| 99 | + int last_lambda_for[5]; ///< last lambda for a specific pict type | |
| 100 | + int last_pict_type; //FIXME removes | |
| 101 | + int last_non_b_pict_type; ///< used for MPEG-4 gmc B-frames & ratecontrol | |
| 99 | 102 | RateControlContext rc_context; ///< contains stuff only accessed in ratecontrol.c |
| 100 | 103 | |
| 101 | 104 | int64_t mb_var_sum; ///< sum of MB variance for current frame |
| @@ -203,8 +203,8 @@ static void find_best_tables(MSMPEG4EncContext *ms) · 202 unmodified lines | ||
| 203 | 203 | ms->rl_table_index = best; |
| 204 | 204 | ms->rl_chroma_table_index = chroma_best; |
| 205 | 205 | |
| 206 | − if(s->pict_type != s->last_non_b_pict_type){ | |
| 207 | − ms->rl_table_index = 2; | |
| 206 | + if (s->pict_type != ms->m.last_non_b_pict_type) { | |
| 207 | + ms->rl_table_index= 2; | |
| 208 | 208 | if(s->pict_type==AV_PICTURE_TYPE_I) |
| 209 | 209 | ms->rl_chroma_table_index = 1; |
| 210 | 210 | else |
| @@ -940,10 +940,10 @@ float ff_rate_estimate_qscale(MPVMainEncContext *const m, int dry_run) · 939 unmodified lines | ||
| 940 | 940 | /* update predictors */ |
| 941 | 941 | if (picture_number > 2 && !dry_run) { |
| 942 | 942 | const int64_t last_var = |
| 943 | − s->last_pict_type == AV_PICTURE_TYPE_I ? rcc->last_mb_var_sum | |
| 943 | + m->last_pict_type == AV_PICTURE_TYPE_I ? rcc->last_mb_var_sum | |
| 944 | 944 | : rcc->last_mc_mb_var_sum; |
| 945 | 945 | av_assert1(m->frame_bits >= m->stuffing_bits); |
| 946 | − update_predictor(&rcc->pred[s->last_pict_type], | |
| 946 | + update_predictor(&rcc->pred[m->last_pict_type], | |
| 947 | 947 | rcc->last_qscale, |
| 948 | 948 | sqrt(last_var), |
| 949 | 949 | m->frame_bits - m->stuffing_bits); |
| @@ -2058,7 +2058,7 @@ redo_frame: · 2057 unmodified lines | ||
| 2058 | 2058 | } |
| 2059 | 2059 | if(avctx->flags&AV_CODEC_FLAG_PASS1) |
| 2060 | 2060 | ff_write_pass1_stats(&enc->m); |
| 2061 | − mpv->last_pict_type = mpv->pict_type; | |
| 2061 | + enc->m.last_pict_type = mpv->pict_type; | |
| 2062 | 2062 | |
| 2063 | 2063 | emms_c(); |
| 2064 | 2064 | |