From: Loren Merritt Date: Wed, 16 Aug 2006 19:57:08 +0000 (+0000) Subject: cosmetics X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dc5d530e13e0aa38218feb7c6c1fc4b75c0b7261;p=libx264 cosmetics git-svn-id: svn://svn.videolan.org/x264/trunk@552 df754926-b1dd-0310-bc7b-ec298dee348c --- diff --git a/common/common.h b/common/common.h index 322327e1..0dbb23b5 100644 --- a/common/common.h +++ b/common/common.h @@ -447,7 +447,7 @@ struct x264_t /* pointer over mb of the frame to be compressed */ uint8_t *p_fenc[3]; - /* pointer over mb of the frame to be reconstrucated */ + /* pointer over mb of the frame to be reconstructed */ uint8_t *p_fdec[3]; /* pointer over mb of the references */ @@ -464,13 +464,13 @@ struct x264_t /* real intra4x4_pred_mode if I_4X4 or I_8X8, I_PRED_4x4_DC if mb available, -1 if not */ int intra4x4_pred_mode[X264_SCAN8_SIZE]; - /* i_non_zero_count if availble else 0x80 */ + /* i_non_zero_count if available else 0x80 */ int non_zero_count[X264_SCAN8_SIZE]; - /* -1 if unused, -2 if unavaible */ + /* -1 if unused, -2 if unavailable */ int8_t ref[2][X264_SCAN8_SIZE]; - /* 0 if non avaible */ + /* 0 if not available */ int16_t mv[2][X264_SCAN8_SIZE][2]; int16_t mvd[2][X264_SCAN8_SIZE][2]; @@ -534,7 +534,7 @@ struct x264_t int i_direct_score[2]; } frame; - /* Cummulated stats */ + /* Cumulated stats */ /* per slice info */ int i_slice_count[5]; diff --git a/common/frame.c b/common/frame.c index 260359e1..b64cbb58 100644 --- a/common/frame.c +++ b/common/frame.c @@ -652,12 +652,11 @@ void x264_deblock_v_chroma_mmxext( uint8_t *pix, int stride, int alpha, int beta void x264_deblock_h_chroma_mmxext( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 ); void x264_deblock_v_chroma_intra_mmxext( uint8_t *pix, int stride, int alpha, int beta ); void x264_deblock_h_chroma_intra_mmxext( uint8_t *pix, int stride, int alpha, int beta ); -#endif #ifdef ARCH_X86_64 void x264_deblock_v_luma_sse2( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 ); void x264_deblock_h_luma_sse2( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 ); -#elif defined( HAVE_MMXEXT ) +#else void x264_deblock_h_luma_mmxext( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 ); void x264_deblock_v8_luma_mmxext( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 ); @@ -667,6 +666,7 @@ void x264_deblock_v_luma_mmxext( uint8_t *pix, int stride, int alpha, int beta, x264_deblock_v8_luma_mmxext( pix+8, stride, alpha, beta, tc0+2 ); } #endif +#endif void x264_deblock_init( int cpu, x264_deblock_function_t *pf ) { diff --git a/common/macroblock.c b/common/macroblock.c index bb440733..1eca58cc 100644 --- a/common/macroblock.c +++ b/common/macroblock.c @@ -26,16 +26,6 @@ #include "common.h" -static const int dequant_mf[6][4][4] = -{ - { {10, 13, 10, 13}, {13, 16, 13, 16}, {10, 13, 10, 13}, {13, 16, 13, 16} }, - { {11, 14, 11, 14}, {14, 18, 14, 18}, {11, 14, 11, 14}, {14, 18, 14, 18} }, - { {13, 16, 13, 16}, {16, 20, 16, 20}, {13, 16, 13, 16}, {16, 20, 16, 20} }, - { {14, 18, 14, 18}, {18, 23, 18, 23}, {14, 18, 14, 18}, {18, 23, 18, 23} }, - { {16, 20, 16, 20}, {20, 25, 20, 25}, {16, 20, 16, 20}, {20, 25, 20, 25} }, - { {18, 23, 18, 23}, {23, 29, 23, 29}, {18, 23, 18, 23}, {23, 29, 23, 29} } -}; - int x264_mb_predict_intra4x4_mode( x264_t *h, int idx ) { const int ma = h->mb.cache.intra4x4_pred_mode[x264_scan8[idx] - 1]; diff --git a/common/macroblock.h b/common/macroblock.h index 0bdd4baf..b08f0e9d 100644 --- a/common/macroblock.h +++ b/common/macroblock.h @@ -80,15 +80,17 @@ enum mb_class_e B_BI_BI = 16, B_8x8 = 17, B_SKIP = 18, + + X264_MBTYPE_MAX = 19 }; -static const int x264_mb_type_fix[19] = +static const int x264_mb_type_fix[X264_MBTYPE_MAX] = { I_4x4, I_4x4, I_16x16, I_PCM, P_L0, P_8x8, P_SKIP, B_DIRECT, B_L0_L0, B_L0_L1, B_L0_BI, B_L1_L0, B_L1_L1, B_L1_BI, B_BI_L0, B_BI_L1, B_BI_BI, B_8x8, B_SKIP }; -static const int x264_mb_type_list0_table[19][2] = +static const int x264_mb_type_list0_table[X264_MBTYPE_MAX][2] = { {0,0}, {0,0}, {0,0}, {0,0}, /* INTRA */ {1,1}, /* P_L0 */ @@ -101,7 +103,7 @@ static const int x264_mb_type_list0_table[19][2] = {0,0}, /* B_8x8 */ {0,0} /* B_SKIP */ }; -static const int x264_mb_type_list1_table[19][2] = +static const int x264_mb_type_list1_table[X264_MBTYPE_MAX][2] = { {0,0}, {0,0}, {0,0}, {0,0}, /* INTRA */ {0,0}, /* P_L0 */ diff --git a/encoder/analyse.c b/encoder/analyse.c index 424c5da1..39ab507a 100644 --- a/encoder/analyse.c +++ b/encoder/analyse.c @@ -57,7 +57,7 @@ typedef struct /* Sub 4x8 */ int i_cost4x8[4]; /* cost per 8x8 partition */ - x264_me_t me4x8[4][4]; + x264_me_t me4x8[4][2]; /* 16x8 */ int i_cost16x8; @@ -150,7 +150,7 @@ static const int i_qp0_cost2_table[52] = { }; /* TODO: calculate CABAC costs */ -static const int i_mb_b_cost_table[19] = { +static const int i_mb_b_cost_table[X264_MBTYPE_MAX] = { 9, 9, 9, 9, 0, 0, 0, 1, 3, 7, 7, 7, 3, 7, 7, 7, 5, 9, 0 }; static const int i_mb_b16x8_cost_table[17] = { diff --git a/encoder/encoder.c b/encoder/encoder.c index 95121776..c503c2a5 100644 --- a/encoder/encoder.c +++ b/encoder/encoder.c @@ -979,7 +979,7 @@ static int x264_slice_write( x264_t *h ) x264_macroblock_analyse( h ); TIMER_STOP( i_mtime_analyse ); - /* encode this macrobock -> be carefull it can change the mb type to P_SKIP if needed */ + /* encode this macrobock -> be careful it can change the mb type to P_SKIP if needed */ TIMER_START( i_mtime_encode ); x264_macroblock_encode( h ); TIMER_STOP( i_mtime_encode ); @@ -1538,7 +1538,7 @@ do_encode: h->stat.i_slice_size[i_slice_type] += i_frame_size + NALU_OVERHEAD; h->stat.i_slice_qp[i_slice_type] += i_global_qp; - for( i = 0; i < 19; i++ ) + for( i = 0; i < X264_MBTYPE_MAX; i++ ) h->stat.i_mb_count[h->sh.i_type][i] += h->stat.frame.i_mb_count[i]; for( i = 0; i < 2; i++ ) h->stat.i_mb_count_8x8dct[i] += h->stat.frame.i_mb_count_8x8dct[i]; @@ -1613,7 +1613,7 @@ do_encode: int mb_xy; for( mb_xy = 0; mb_xy < h->sps->i_mb_width * h->sps->i_mb_height; mb_xy++ ) { - if( h->mb.type[mb_xy] < 19 && h->mb.type[mb_xy] >= 0 ) + if( h->mb.type[mb_xy] < X264_MBTYPE_MAX && h->mb.type[mb_xy] >= 0 ) fprintf( stderr, "%c ", mb_chars[ h->mb.type[mb_xy] ] ); else fprintf( stderr, "? " ); @@ -1827,4 +1827,3 @@ void x264_encoder_close ( x264_t *h ) x264_free( h->thread[i] ); x264_free( h ); } - diff --git a/encoder/macroblock.c b/encoder/macroblock.c index c42a54ff..0dab7011 100644 --- a/encoder/macroblock.c +++ b/encoder/macroblock.c @@ -120,14 +120,14 @@ static void quant_8x8( x264_t *h, int16_t dct[8][8], int quant_mf[6][8][8], int { const int i_qbits = 16 + i_qscale / 6; const int i_mf = i_qscale % 6; - const int f = ( 1 << i_qbits ) / ( b_intra ? 3 : 6 ); + const int f = ( 1 << (i_qbits + b_intra) ) / 6; h->quantf.quant_8x8_core( dct, quant_mf[i_mf], i_qbits, f ); } static void quant_4x4( x264_t *h, int16_t dct[4][4], int quant_mf[6][4][4], int i_qscale, int b_intra ) { const int i_qbits = 15 + i_qscale / 6; const int i_mf = i_qscale % 6; - const int f = ( 1 << i_qbits ) / ( b_intra ? 3 : 6 ); + const int f = ( 1 << (i_qbits + b_intra) ) / 6; h->quantf.quant_4x4_core( dct, quant_mf[i_mf], i_qbits, f ); } static void quant_4x4_dc( x264_t *h, int16_t dct[4][4], int quant_mf[6][4][4], int i_qscale ) @@ -141,7 +141,7 @@ static void quant_2x2_dc( x264_t *h, int16_t dct[2][2], int quant_mf[6][4][4], i { const int i_qbits = 16 + i_qscale / 6; const int i_mf = i_qscale % 6; - const int f = ( 1 << i_qbits ) / ( b_intra ? 3 : 6 ); + const int f = ( 1 << (i_qbits + b_intra) ) / 6; h->quantf.quant_2x2_dc_core( dct, quant_mf[i_mf][0][0], i_qbits, f ); } @@ -603,7 +603,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 ); - /* Calculate the Luma/Chroma patern and non_zero_count */ + /* Calculate the Luma/Chroma pattern and non_zero_count */ h->mb.i_cbp_luma = 0x00; if( h->mb.i_type == I_16x16 ) { @@ -640,7 +640,7 @@ void x264_macroblock_encode( x264_t *h ) } } - /* Calculate the chroma patern */ + /* Calculate the chroma pattern */ h->mb.i_cbp_chroma = 0x00; for( i = 0; i < 8; i++ ) { diff --git a/encoder/ratecontrol.c b/encoder/ratecontrol.c index c1375317..9e7d66da 100644 --- a/encoder/ratecontrol.c +++ b/encoder/ratecontrol.c @@ -35,21 +35,13 @@ #include "common/cpu.h" #include "ratecontrol.h" -#if defined(SYS_FREEBSD) || defined(SYS_BEOS) || defined(SYS_NETBSD) || defined(SYS_OPENBSD) -#define exp2f(x) powf( 2, (x) ) -#endif -#if defined(SYS_MACOSX) -#define exp2f(x) (float)pow( 2, (x) ) -#define sqrtf sqrt -#endif #if defined(SYS_OPENBSD) #define isfinite finite #endif #if defined(_MSC_VER) #define isfinite _finite #endif -#if defined(_MSC_VER) || defined(SYS_SunOS) -#define exp2f(x) pow( 2, (x) ) +#if defined(_MSC_VER) || defined(SYS_SunOS) || defined(SYS_MACOSX) #define sqrtf sqrt #endif #ifdef WIN32 // POSIX says that rename() removes the destination, but win32 doesn't. @@ -283,7 +275,7 @@ int x264_ratecontrol_new( x264_t *h ) rc->qp_constant[SLICE_TYPE_I] = x264_clip3( h->param.rc.i_qp_constant - rc->ip_offset + 0.5, 0, 51 ); rc->qp_constant[SLICE_TYPE_B] = x264_clip3( h->param.rc.i_qp_constant + rc->pb_offset + 0.5, 0, 51 ); - rc->lstep = exp2f(h->param.rc.i_qp_step / 6.0); + rc->lstep = pow( 2, h->param.rc.i_qp_step / 6.0 ); rc->last_qscale = qp2qscale(26); for( i = 0; i < 5; i++ ) {