From 4f42c3c55ff802c5b212b75317e332ce00cc4a90 Mon Sep 17 00:00:00 2001 From: Jason Garrett-Glaser Date: Sun, 14 Mar 2010 16:48:22 -0700 Subject: [PATCH] Make a bunch of small functions ALWAYS_INLINE Probably no real effect for now, but needed for the next patch. --- common/bs.h | 8 ++++---- common/cabac.h | 10 +++++----- common/common.h | 14 +++++++------- common/macroblock.h | 6 +++--- common/x86/util.h | 4 ++-- encoder/analyse.c | 6 +++--- encoder/cabac.c | 6 +++--- encoder/macroblock.h | 8 ++++---- encoder/me.h | 4 ++-- encoder/rdo.c | 4 ++-- 10 files changed, 35 insertions(+), 35 deletions(-) diff --git a/common/bs.h b/common/bs.h index 0773de6a..9e36613f 100644 --- a/common/bs.h +++ b/common/bs.h @@ -257,12 +257,12 @@ static inline void bs_rbsp_trailing( bs_t *s ) bs_write( s, s->i_left&7, 0 ); } -static inline int bs_size_ue( unsigned int val ) +static ALWAYS_INLINE int bs_size_ue( unsigned int val ) { return x264_ue_size_tab[val+1]; } -static inline int bs_size_ue_big( unsigned int val ) +static ALWAYS_INLINE int bs_size_ue_big( unsigned int val ) { if( val < 255 ) return x264_ue_size_tab[val+1]; @@ -270,7 +270,7 @@ static inline int bs_size_ue_big( unsigned int val ) return x264_ue_size_tab[(val+1)>>8] + 16; } -static inline int bs_size_se( int val ) +static ALWAYS_INLINE int bs_size_se( int val ) { int tmp = 1 - val*2; if( tmp < 0 ) tmp = val*2; @@ -280,7 +280,7 @@ static inline int bs_size_se( int val ) return x264_ue_size_tab[tmp>>8]+16; } -static inline int bs_size_te( int x, int val ) +static ALWAYS_INLINE int bs_size_te( int x, int val ) { if( x == 1 ) return 1; diff --git a/common/cabac.h b/common/cabac.h index 35871b49..ef68fe65 100644 --- a/common/cabac.h +++ b/common/cabac.h @@ -67,34 +67,34 @@ void x264_cabac_encode_flush( x264_t *h, x264_cabac_t *cb ); #endif #define x264_cabac_encode_decision_noup x264_cabac_encode_decision -static inline int x264_cabac_pos( x264_cabac_t *cb ) +static ALWAYS_INLINE int x264_cabac_pos( x264_cabac_t *cb ) { return (cb->p - cb->p_start + cb->i_bytes_outstanding) * 8 + cb->i_queue; } /* internal only. these don't write the bitstream, just calculate bit cost: */ -static inline void x264_cabac_size_decision( x264_cabac_t *cb, long i_ctx, long b ) +static ALWAYS_INLINE void x264_cabac_size_decision( x264_cabac_t *cb, long i_ctx, long b ) { int i_state = cb->state[i_ctx]; cb->state[i_ctx] = x264_cabac_transition[i_state][b]; cb->f8_bits_encoded += x264_cabac_entropy[i_state][b]; } -static inline int x264_cabac_size_decision2( uint8_t *state, long b ) +static ALWAYS_INLINE int x264_cabac_size_decision2( uint8_t *state, long b ) { int i_state = *state; *state = x264_cabac_transition[i_state][b]; return x264_cabac_entropy[i_state][b]; } -static inline void x264_cabac_size_decision_noup( x264_cabac_t *cb, long i_ctx, long b ) +static ALWAYS_INLINE void x264_cabac_size_decision_noup( x264_cabac_t *cb, long i_ctx, long b ) { int i_state = cb->state[i_ctx]; cb->f8_bits_encoded += x264_cabac_entropy[i_state][b]; } -static inline int x264_cabac_size_decision_noup2( uint8_t *state, long b ) +static ALWAYS_INLINE int x264_cabac_size_decision_noup2( uint8_t *state, long b ) { return x264_cabac_entropy[*state][b]; } diff --git a/common/common.h b/common/common.h index 798dcde5..295b27d3 100644 --- a/common/common.h +++ b/common/common.h @@ -132,22 +132,22 @@ void x264_log( x264_t *h, int i_level, const char *psz_fmt, ... ); void x264_reduce_fraction( int *n, int *d ); void x264_init_vlc_tables(); -static inline uint8_t x264_clip_uint8( int x ) +static ALWAYS_INLINE uint8_t x264_clip_uint8( int x ) { return x&(~255) ? (-x)>>31 : x; } -static inline int x264_clip3( int v, int i_min, int i_max ) +static ALWAYS_INLINE int x264_clip3( int v, int i_min, int i_max ) { return ( (v < i_min) ? i_min : (v > i_max) ? i_max : v ); } -static inline double x264_clip3f( double v, double f_min, double f_max ) +static ALWAYS_INLINE double x264_clip3f( double v, double f_min, double f_max ) { return ( (v < f_min) ? f_min : (v > f_max) ? f_max : v ); } -static inline int x264_median( int a, int b, int c ) +static ALWAYS_INLINE int x264_median( int a, int b, int c ) { int t = (a-b)&((a-b)>>31); a -= t; @@ -157,13 +157,13 @@ static inline int x264_median( int a, int b, int c ) return b; } -static inline void x264_median_mv( int16_t *dst, int16_t *a, int16_t *b, int16_t *c ) +static ALWAYS_INLINE void x264_median_mv( int16_t *dst, int16_t *a, int16_t *b, int16_t *c ) { dst[0] = x264_median( a[0], b[0], c[0] ); dst[1] = x264_median( a[1], b[1], c[1] ); } -static inline int x264_predictor_difference( int16_t (*mvc)[2], intptr_t i_mvc ) +static ALWAYS_INLINE int x264_predictor_difference( int16_t (*mvc)[2], intptr_t i_mvc ) { int sum = 0, i; for( i = 0; i < i_mvc-1; i++ ) @@ -174,7 +174,7 @@ static inline int x264_predictor_difference( int16_t (*mvc)[2], intptr_t i_mvc ) return sum; } -static inline uint16_t x264_cabac_mvd_sum( uint8_t *mvdleft, uint8_t *mvdtop ) +static ALWAYS_INLINE uint16_t x264_cabac_mvd_sum( uint8_t *mvdleft, uint8_t *mvdtop ) { int amvd0 = abs(mvdleft[0]) + abs(mvdtop[0]); int amvd1 = abs(mvdleft[1]) + abs(mvdtop[1]); diff --git a/common/macroblock.h b/common/macroblock.h index eb903d29..1cbe150d 100644 --- a/common/macroblock.h +++ b/common/macroblock.h @@ -445,7 +445,7 @@ static ALWAYS_INLINE int array_non_zero_int( int16_t *v, int i_count ) return 0; } } -static inline int x264_mb_predict_intra4x4_mode( x264_t *h, int idx ) +static ALWAYS_INLINE int x264_mb_predict_intra4x4_mode( x264_t *h, int idx ) { const int ma = h->mb.cache.intra4x4_pred_mode[x264_scan8[idx] - 1]; const int mb = h->mb.cache.intra4x4_pred_mode[x264_scan8[idx] - 8]; @@ -457,7 +457,7 @@ static inline int x264_mb_predict_intra4x4_mode( x264_t *h, int idx ) return m; } -static inline int x264_mb_predict_non_zero_code( x264_t *h, int idx ) +static ALWAYS_INLINE int x264_mb_predict_non_zero_code( x264_t *h, int idx ) { const int za = h->mb.cache.non_zero_count[x264_scan8[idx] - 1]; const int zb = h->mb.cache.non_zero_count[x264_scan8[idx] - 8]; @@ -474,7 +474,7 @@ static inline int x264_mb_predict_non_zero_code( x264_t *h, int idx ) * check whether any partition is smaller than 8x8 (or at least * might be, according to just partition type.) * doesn't check for cbp */ -static inline int x264_mb_transform_8x8_allowed( x264_t *h ) +static ALWAYS_INLINE int x264_mb_transform_8x8_allowed( x264_t *h ) { // intra and skip are disallowed // large partitions are allowed diff --git a/common/x86/util.h b/common/x86/util.h index 06743233..ccc0733d 100644 --- a/common/x86/util.h +++ b/common/x86/util.h @@ -26,7 +26,7 @@ #ifdef __GNUC__ #define x264_median_mv x264_median_mv_mmxext -static inline void x264_median_mv_mmxext( int16_t *dst, int16_t *a, int16_t *b, int16_t *c ) +static ALWAYS_INLINE void x264_median_mv_mmxext( int16_t *dst, int16_t *a, int16_t *b, int16_t *c ) { asm( "movd %1, %%mm0 \n" @@ -43,7 +43,7 @@ static inline void x264_median_mv_mmxext( int16_t *dst, int16_t *a, int16_t *b, ); } #define x264_predictor_difference x264_predictor_difference_mmxext -static inline int x264_predictor_difference_mmxext( int16_t (*mvc)[2], intptr_t i_mvc ) +static ALWAYS_INLINE int x264_predictor_difference_mmxext( int16_t (*mvc)[2], intptr_t i_mvc ) { int sum; static const uint64_t pw_1 = 0x0001000100010001ULL; diff --git a/encoder/analyse.c b/encoder/analyse.c index d58c2ad5..eef7b232 100644 --- a/encoder/analyse.c +++ b/encoder/analyse.c @@ -548,19 +548,19 @@ static const int8_t i4x4_mode_available[5][10] = {I_PRED_4x4_DC, I_PRED_4x4_H, I_PRED_4x4_V, I_PRED_4x4_DDL, I_PRED_4x4_DDR, I_PRED_4x4_VR, I_PRED_4x4_HD, I_PRED_4x4_VL, I_PRED_4x4_HU, -1}, }; -static inline const int8_t *predict_16x16_mode_available( int i_neighbour ) +static ALWAYS_INLINE const int8_t *predict_16x16_mode_available( int i_neighbour ) { int idx = i_neighbour & (MB_TOP|MB_LEFT|MB_TOPLEFT); return i16x16_mode_available[(idx&MB_TOPLEFT)?4:idx]; } -static inline const int8_t *predict_8x8chroma_mode_available( int i_neighbour ) +static ALWAYS_INLINE const int8_t *predict_8x8chroma_mode_available( int i_neighbour ) { int idx = i_neighbour & (MB_TOP|MB_LEFT|MB_TOPLEFT); return i8x8chroma_mode_available[(idx&MB_TOPLEFT)?4:idx]; } -static inline const int8_t *predict_4x4_mode_available( int i_neighbour ) +static ALWAYS_INLINE const int8_t *predict_4x4_mode_available( int i_neighbour ) { int idx = i_neighbour & (MB_TOP|MB_LEFT|MB_TOPLEFT); return i4x4_mode_available[(idx&MB_TOPLEFT)?4:idx]; diff --git a/encoder/cabac.c b/encoder/cabac.c index bb60e3b0..c6cc5dd6 100644 --- a/encoder/cabac.c +++ b/encoder/cabac.c @@ -301,7 +301,7 @@ static inline void x264_cabac_mb_sub_p_partition( x264_cabac_t *cb, int i_sub ) } } -static inline void x264_cabac_mb_sub_b_partition( x264_cabac_t *cb, int i_sub ) +static ALWAYS_INLINE void x264_cabac_mb_sub_b_partition( x264_cabac_t *cb, int i_sub ) { if( i_sub == D_DIRECT_8x8 ) { @@ -321,7 +321,7 @@ static inline void x264_cabac_mb_sub_b_partition( x264_cabac_t *cb, int i_sub ) x264_cabac_encode_decision( cb, 39, i_sub == D_L1_8x8 ); } -static inline void x264_cabac_mb_transform_size( x264_t *h, x264_cabac_t *cb ) +static ALWAYS_INLINE void x264_cabac_mb_transform_size( x264_t *h, x264_cabac_t *cb ) { int ctx = 399 + h->mb.cache.i_neighbour_transform_size; x264_cabac_encode_decision_noup( cb, ctx, h->mb.b_transform_8x8 ); @@ -349,7 +349,7 @@ static void x264_cabac_mb_ref( x264_t *h, x264_cabac_t *cb, int i_list, int idx x264_cabac_encode_decision( cb, 54 + ctx, 0 ); } -static inline int x264_cabac_mb_mvd_cpn( x264_t *h, x264_cabac_t *cb, int i_list, int idx, int l, int mvd, int ctx ) +static ALWAYS_INLINE int x264_cabac_mb_mvd_cpn( x264_t *h, x264_cabac_t *cb, int i_list, int idx, int l, int mvd, int ctx ) { const int i_abs = abs( mvd ); const int ctxbase = l ? 47 : 40; diff --git a/encoder/macroblock.h b/encoder/macroblock.h index 25beb187..d05c00b3 100644 --- a/encoder/macroblock.h +++ b/encoder/macroblock.h @@ -33,10 +33,10 @@ void x264_rdo_init( void ); int x264_macroblock_probe_skip( x264_t *h, int b_bidir ); -static inline int x264_macroblock_probe_pskip( x264_t *h ) - { return x264_macroblock_probe_skip( h, 0 ); } -static inline int x264_macroblock_probe_bskip( x264_t *h ) - { return x264_macroblock_probe_skip( h, 1 ); } +#define x264_macroblock_probe_pskip( h )\ + x264_macroblock_probe_skip( h, 0 ) +#define x264_macroblock_probe_bskip( h )\ + x264_macroblock_probe_skip( h, 1 ) void x264_predict_lossless_8x8_chroma( x264_t *h, int i_mode ); void x264_predict_lossless_4x4( x264_t *h, uint8_t *p_dst, int idx, int i_mode ); diff --git a/encoder/me.h b/encoder/me.h index 2f19e613..3fe579df 100644 --- a/encoder/me.h +++ b/encoder/me.h @@ -58,8 +58,8 @@ typedef struct { } mvsad_t; void x264_me_search_ref( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc, int *p_fullpel_thresh ); -static inline void x264_me_search( x264_t *h, x264_me_t *m, int16_t (*mvc)[2], int i_mvc ) - { x264_me_search_ref( h, m, mvc, i_mvc, NULL ); } +#define x264_me_search( h, m, mvc, i_mvc )\ + x264_me_search_ref( h, m, mvc, i_mvc, NULL ) void x264_me_refine_qpel( x264_t *h, x264_me_t *m ); void x264_me_refine_qpel_refdupe( x264_t *h, x264_me_t *m, int *p_halfpel_thresh ); diff --git a/encoder/rdo.c b/encoder/rdo.c index fed2a283..10deb9a1 100644 --- a/encoder/rdo.c +++ b/encoder/rdo.c @@ -61,7 +61,7 @@ static uint16_t cabac_size_5ones[128]; #define COPY_CABAC h->mc.memcpy_aligned( &cabac_tmp.f8_bits_encoded, &h->cabac.f8_bits_encoded, \ sizeof(x264_cabac_t) - offsetof(x264_cabac_t,f8_bits_encoded) ) -static inline uint64_t cached_hadamard( x264_t *h, int pixel, int x, int y ) +static ALWAYS_INLINE uint64_t cached_hadamard( x264_t *h, int pixel, int x, int y ) { static const uint8_t hadamard_shift_x[4] = {4, 4, 3, 3}; static const uint8_t hadamard_shift_y[4] = {4-0, 3-0, 4-1, 3-1}; @@ -80,7 +80,7 @@ static inline uint64_t cached_hadamard( x264_t *h, int pixel, int x, int y ) } } -static inline int cached_satd( x264_t *h, int pixel, int x, int y ) +static ALWAYS_INLINE int cached_satd( x264_t *h, int pixel, int x, int y ) { static const uint8_t satd_shift_x[3] = {3, 2, 2}; static const uint8_t satd_shift_y[3] = {2-1, 3-2, 2-2}; -- 2.47.3