From ccac553deccf9646fdc53728f91caa988ee09176 Mon Sep 17 00:00:00 2001 From: Loren Merritt Date: Sun, 29 Oct 2006 05:48:57 +0000 Subject: [PATCH] compute chroma_qp only once per mb git-svn-id: svn://svn.videolan.org/x264/trunk@596 df754926-b1dd-0310-bc7b-ec298dee348c --- common/common.h | 1 + encoder/analyse.c | 4 ++-- encoder/macroblock.c | 7 +++---- encoder/rdo.c | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/common/common.h b/common/common.h index 8c0cf137..c823d3da 100644 --- a/common/common.h +++ b/common/common.h @@ -506,6 +506,7 @@ struct x264_t /* */ int i_qp; /* current qp */ + int i_chroma_qp; int i_last_qp; /* last qp */ int i_last_dqp; /* last delta qp */ int b_variable_qp; /* whether qp is allowed to vary per macroblock */ diff --git a/encoder/analyse.c b/encoder/analyse.c index b5d9ea01..b3ded41a 100644 --- a/encoder/analyse.c +++ b/encoder/analyse.c @@ -194,6 +194,7 @@ static void x264_mb_analyse_init( x264_t *h, x264_mb_analysis_t *a, int i_qp ) /* conduct the analysis using this lamda and QP */ a->i_qp = h->mb.i_qp = i_qp; + h->mb.i_chroma_qp = i_chroma_qp_table[x264_clip3( i_qp + h->pps->i_chroma_qp_index_offset, 0, 51 )]; a->i_lambda = i_qp0_cost_table[i_qp]; a->i_lambda2 = i_qp0_cost2_table[i_qp]; a->b_mbrd = h->param.analyse.i_subpel_refine >= 6 && @@ -864,8 +865,7 @@ static void x264_intra_rd_refine( x264_t *h, x264_mb_analysis_t *a ) if( i_max > 0 ) { - int i_qp_chroma = i_chroma_qp_table[x264_clip3( h->mb.i_qp + h->pps->i_chroma_qp_index_offset, 0, 51 )]; - int i_chroma_lambda = i_qp0_cost2_table[i_qp_chroma]; + int i_chroma_lambda = i_qp0_cost2_table[h->mb.i_chroma_qp]; /* the previous thing encoded was x264_intra_rd(), so the pixels and * coefs for the current chroma mode are still around, so we only * have to recount the bits. */ diff --git a/encoder/macroblock.c b/encoder/macroblock.c index f970983a..0b06a7f7 100644 --- a/encoder/macroblock.c +++ b/encoder/macroblock.c @@ -571,7 +571,6 @@ void x264_macroblock_encode( x264_t *h ) } /* encode chroma */ - i_qp = i_chroma_qp_table[x264_clip3( i_qp + h->pps->i_chroma_qp_index_offset, 0, 51 )]; if( IS_INTRA( h->mb.i_type ) ) { const int i_mode = h->mb.i_chroma_pred_mode; @@ -580,7 +579,7 @@ void x264_macroblock_encode( x264_t *h ) } /* encode the 8x8 blocks */ - x264_mb_encode_8x8_chroma( h, !IS_INTRA( h->mb.i_type ), i_qp ); + x264_mb_encode_8x8_chroma( h, !IS_INTRA( h->mb.i_type ), h->mb.i_chroma_qp ); /* coded block pattern and non_zero_count */ h->mb.i_cbp_luma = 0x00; @@ -707,7 +706,7 @@ int x264_macroblock_probe_skip( x264_t *h, int b_bidir ) } /* encode chroma */ - i_qp = i_chroma_qp_table[x264_clip3( i_qp + h->pps->i_chroma_qp_index_offset, 0, 51 )]; + i_qp = h->mb.i_chroma_qp; for( ch = 0; ch < 2; ch++ ) { @@ -875,7 +874,7 @@ void x264_macroblock_encode_p8x8( x264_t *h, int i8 ) } } - i_qp = i_chroma_qp_table[x264_clip3( i_qp + h->pps->i_chroma_qp_index_offset, 0, 51 )]; + i_qp = h->mb.i_chroma_qp; for( ch = 0; ch < 2; ch++ ) { diff --git a/encoder/rdo.c b/encoder/rdo.c index 36326dac..3c827cb7 100644 --- a/encoder/rdo.c +++ b/encoder/rdo.c @@ -183,7 +183,7 @@ int x264_rd_cost_i8x8_chroma( x264_t *h, int i_lambda2, int i_mode, int b_dct ) int i_ssd, i_bits; if( b_dct ) - x264_mb_encode_8x8_chroma( h, 0, h->mb.i_qp ); + x264_mb_encode_8x8_chroma( h, 0, h->mb.i_chroma_qp ); i_ssd = ssd_plane( h, PIXEL_8x8, 1, 0, 0 ) + ssd_plane( h, PIXEL_8x8, 2, 0, 0 ); -- 2.47.3