From: Jason Garrett-Glaser Date: Sun, 16 Aug 2009 10:29:49 +0000 (-0700) Subject: Fix two bugs in QPRD X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=c07d292d7b5298327d835d0c458083de29c23204;p=x264.git 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. --- diff --git a/encoder/analyse.c b/encoder/analyse.c index 7644c9d5..44a8a504 100644 --- a/encoder/analyse.c +++ b/encoder/analyse.c @@ -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 ); diff --git a/encoder/rdo.c b/encoder/rdo.c index 532ee519..7bb56d89 100644 --- a/encoder/rdo.c +++ b/encoder/rdo.c @@ -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; }