[x264-devel] commit: Fix two bugs in QPRD (Jason Garrett-Glaser )
git version control
git at videolan.org
Mon Aug 17 20:30:36 CEST 2009
x264 | branch: master | Jason Garrett-Glaser <darkshikari at gmail.com> | Sun Aug 16 03:29:49 2009 -0700| [c07d292d7b5298327d835d0c458083de29c23204] | committer: Jason Garrett-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.
> http://git.videolan.org/gitweb.cgi/x264.git/?a=commit;h=c07d292d7b5298327d835d0c458083de29c23204
---
encoder/analyse.c | 9 +++++----
encoder/rdo.c | 4 ++--
2 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/encoder/analyse.c b/encoder/analyse.c
index 7644c9d..44a8a50 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 532ee51..7bb56d8 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;
}
More information about the x264-devel
mailing list