From: Loren Merritt Date: Wed, 4 Apr 2007 19:34:02 +0000 (+0000) Subject: simplify trellis X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=71c097b28e1405076f554d3b948885fd69c1774f;p=x264.git simplify trellis git-svn-id: svn://svn.videolan.org/x264/trunk@644 df754926-b1dd-0310-bc7b-ec298dee348c --- diff --git a/encoder/rdo.c b/encoder/rdo.c index d2fa78b1..e10702f5 100644 --- a/encoder/rdo.c +++ b/encoder/rdo.c @@ -252,7 +252,30 @@ static const int coeff_abs_level_transition[2][8] = { { 4, 4, 4, 4, 5, 6, 7, 7 } }; -static const int lambda2_tab[6] = { 1024, 1290, 1625, 2048, 2580, 3251 }; +// should the intra and inter lambdas be different? +// I'm just matching the behaviour of deadzone quant. +static const int lambda2_tab[2][52] = { + // inter lambda = .85 * .85 * 2**(qp/3. + 10 - LAMBDA_BITS) + { 46, 58, 73, 92, 117, 147, + 185, 233, 294, 370, 466, 587, + 740, 932, 1174, 1480, 1864, 2349, + 2959, 3728, 4697, 5918, 7457, 9395, + 11837, 14914, 18790, 23674, 29828, 37581, + 47349, 59656, 75163, 94699, 119313, 150326, + 189399, 238627, 300652, 378798, 477255, 601304, + 757596, 954511, 1202608, 1515192, 1909022, 2405217, + 3030384, 3818045, 4810435, 6060769 }, + // intra lambda = .65 * .65 * 2**(qp/3. + 10 - LAMBDA_BITS) + { 27, 34, 43, 54, 68, 86, + 108, 136, 172, 216, 273, 343, + 433, 545, 687, 865, 1090, 1374, + 1731, 2180, 2747, 3461, 4361, 5494, + 6922, 8721, 10988, 13844, 17442, 21976, + 27688, 34885, 43953, 55377, 69771, 87906, + 110755, 139543, 175813, 221511, 279087, 351627, + 443023, 558174, 703255, 886046, 1116348, 1406511, + 1772093, 2232697, 2813022, 3544186 } +}; typedef struct { uint64_t score; @@ -284,7 +307,7 @@ typedef struct { static void quant_trellis_cabac( x264_t *h, int16_t *dct, const uint16_t *quant_mf, const int *unquant_mf, const int *coef_weight, const int *zigzag, - int i_ctxBlockCat, int i_qbits, int i_lambda2, int b_ac, int i_coefs ) + int i_ctxBlockCat, int i_lambda2, int b_ac, int i_coefs ) { int abs_coefs[64], signs[64]; trellis_node_t nodes[2][8]; @@ -479,35 +502,22 @@ static void quant_trellis_cabac( x264_t *h, int16_t *dct, void x264_quant_4x4_trellis( x264_t *h, int16_t dct[4][4], int i_quant_cat, int i_qp, int i_ctxBlockCat, int b_intra ) { - const int i_qbits = i_qp / 6; - const int i_mf = i_qp % 6; - const int b_ac = (i_ctxBlockCat == DCT_LUMA_AC); - /* should the lambdas be different? I'm just matching the behaviour of deadzone quant. */ - const int i_lambda_mult = b_intra ? 65 : 85; - const int i_lambda2 = ((lambda2_tab[i_mf] * i_lambda_mult*i_lambda_mult / 10000) - << (2*i_qbits)) >> LAMBDA_BITS; - + int b_ac = (i_ctxBlockCat == DCT_LUMA_AC); quant_trellis_cabac( h, (int16_t*)dct, h->quant4_mf[i_quant_cat][i_qp], h->unquant4_mf[i_quant_cat][i_qp], x264_dct4_weight2_zigzag[h->mb.b_interlaced], x264_zigzag_scan4[h->mb.b_interlaced], - i_ctxBlockCat, 15+i_qbits, i_lambda2, b_ac, 16 ); + i_ctxBlockCat, lambda2_tab[b_intra][i_qp], b_ac, 16 ); } void x264_quant_8x8_trellis( x264_t *h, int16_t dct[8][8], int i_quant_cat, int i_qp, int b_intra ) { - const int i_qbits = i_qp / 6; - const int i_mf = i_qp % 6; - const int i_lambda_mult = b_intra ? 65 : 85; - const int i_lambda2 = ((lambda2_tab[i_mf] * i_lambda_mult*i_lambda_mult / 10000) - << (2*i_qbits)) >> LAMBDA_BITS; - quant_trellis_cabac( h, (int16_t*)dct, h->quant8_mf[i_quant_cat][i_qp], h->unquant8_mf[i_quant_cat][i_qp], x264_dct8_weight2_zigzag[h->mb.b_interlaced], x264_zigzag_scan8[h->mb.b_interlaced], - DCT_LUMA_8x8, 16+i_qbits, i_lambda2, 0, 64 ); + DCT_LUMA_8x8, lambda2_tab[b_intra][i_qp], 0, 64 ); }