Commit ba0c0351 authored by Fiona Glaser's avatar Fiona Glaser

Fix two bugs in QPRD

QPRD could in some cases force blocks to skip when they shouldn't be ~(+0.01db)
Force QPRD to abide by qpmin/qpmax restrictions.
parent 30a82c75
......@@ -2211,9 +2211,9 @@ static inline void x264_mb_analyse_qp_rd( x264_t *h, x264_mb_analysis_t *a )
h->mb.i_qp = orig_qp;
failures = 0;
prevcost = origcost;
while( h->mb.i_qp > 0 && h->mb.i_qp < 51 )
h->mb.i_qp += direction;
while( h->mb.i_qp >= h->param.rc.i_qp_min && h->mb.i_qp <= h->param.rc.i_qp_max )
{
h->mb.i_qp += direction;
h->mb.i_chroma_qp = h->chroma_qp_table[h->mb.i_qp];
cost = x264_rd_cost_mb( h, a->i_lambda2 );
COPY2_IF_LT( bcost, cost, bqp, h->mb.i_qp );
......@@ -2236,6 +2236,7 @@ static inline void x264_mb_analyse_qp_rd( x264_t *h, x264_mb_analysis_t *a )
break;
if( direction == 1 && !h->mb.cbp[h->mb.i_mb_xy] )
break;
h->mb.i_qp += direction;
}
}
......@@ -2243,8 +2244,8 @@ static inline void x264_mb_analyse_qp_rd( x264_t *h, x264_mb_analysis_t *a )
h->mb.i_chroma_qp = h->chroma_qp_table[h->mb.i_qp];
/* Check transform again; decision from before may no longer be optimal. */
if( h->mb.i_qp != orig_qp && x264_mb_transform_8x8_allowed( h ) &&
h->param.analyse.b_transform_8x8 )
if( h->mb.i_qp != orig_qp && h->param.analyse.b_transform_8x8 &&
x264_mb_transform_8x8_allowed( h ) )
{
h->mb.b_transform_8x8 ^= 1;
cost = x264_rd_cost_mb( h, a->i_lambda2 );
......
......@@ -140,6 +140,7 @@ static int x264_rd_cost_mb( x264_t *h, int i_lambda2 )
int b_transform_bak = h->mb.b_transform_8x8;
int i_ssd;
int i_bits;
int type_bak = h->mb.i_type;
x264_macroblock_encode( h );
......@@ -165,6 +166,7 @@ static int x264_rd_cost_mb( x264_t *h, int i_lambda2 )
}
h->mb.b_transform_8x8 = b_transform_bak;
h->mb.i_type = type_bak;
return i_ssd + i_bits;
}
......@@ -206,9 +208,7 @@ uint64_t x264_rd_cost_part( x264_t *h, int i_lambda2, int i4, int i_pixel )
if( i_pixel == PIXEL_16x16 )
{
int type_bak = h->mb.i_type;
int i_cost = x264_rd_cost_mb( h, i_lambda2 );
h->mb.i_type = type_bak;
return i_cost;
}
......
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