Commit 48e8e52e authored by Anton Mitrofanov's avatar Anton Mitrofanov Committed by Fiona Glaser

Add an small per-MB cost penalty for lowres

Helps avoid VBV predictors going nuts with very low-cost MBs.
One particular case this fixes is zero-cost MBs: adaptive quantization decreases the QP a lot, but (before this patch), no cost penalty gets factored in for this, because anything times zero is zero.
parent 1b31a10c
......@@ -457,6 +457,8 @@ static void x264_slicetype_mb_cost( x264_t *h, x264_mb_analysis_t *a,
x264_me_t m[2];
int i_bcost = COST_MAX;
int list_used = 0;
/* A small, arbitrary bias to avoid VBV problems caused by zero-residual lookahead blocks. */
int lowres_penalty = 4;
h->mb.pic.p_fenc[0] = h->mb.pic.fenc_buf;
h->mc.copy[PIXEL_8x8]( h->mb.pic.p_fenc[0], FENC_STRIDE, &fenc->lowres[0][i_pel_offset], i_stride, 8 );
......@@ -653,7 +655,7 @@ lowres_intra_mb:
i_icost += intra_penalty;
i_icost += intra_penalty + lowres_penalty;
fenc->i_intra_cost[i_mb_xy] = i_icost;
int i_icost_aq = i_icost;
if( h->param.rc.i_aq_mode )
......@@ -665,6 +667,7 @@ lowres_intra_mb:
fenc->i_cost_est_aq[0][0] += i_icost_aq;
i_bcost += lowres_penalty;
/* forbid intra-mbs in B-frames, because it's rare and not worth checking */
/* FIXME: Should we still forbid them now that we cache intra scores? */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment