Commit 8b4cca0e authored by Fiona Glaser's avatar Fiona Glaser

Make a bunch of small functions ALWAYS_INLINE

Probably no real effect for now, but needed for the next patch.
parent 219505af
...@@ -257,12 +257,12 @@ static inline void bs_rbsp_trailing( bs_t *s ) ...@@ -257,12 +257,12 @@ static inline void bs_rbsp_trailing( bs_t *s )
bs_write( s, s->i_left&7, 0 ); 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]; 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 ) if( val < 255 )
return x264_ue_size_tab[val+1]; return x264_ue_size_tab[val+1];
...@@ -270,7 +270,7 @@ static inline int bs_size_ue_big( unsigned int val ) ...@@ -270,7 +270,7 @@ static inline int bs_size_ue_big( unsigned int val )
return x264_ue_size_tab[(val+1)>>8] + 16; 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; int tmp = 1 - val*2;
if( tmp < 0 ) tmp = val*2; if( tmp < 0 ) tmp = val*2;
...@@ -280,7 +280,7 @@ static inline int bs_size_se( int val ) ...@@ -280,7 +280,7 @@ static inline int bs_size_se( int val )
return x264_ue_size_tab[tmp>>8]+16; 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 ) if( x == 1 )
return 1; return 1;
......
...@@ -67,34 +67,34 @@ void x264_cabac_encode_flush( x264_t *h, x264_cabac_t *cb ); ...@@ -67,34 +67,34 @@ void x264_cabac_encode_flush( x264_t *h, x264_cabac_t *cb );
#endif #endif
#define x264_cabac_encode_decision_noup x264_cabac_encode_decision #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; 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: */ /* 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]; int i_state = cb->state[i_ctx];
cb->state[i_ctx] = x264_cabac_transition[i_state][b]; cb->state[i_ctx] = x264_cabac_transition[i_state][b];
cb->f8_bits_encoded += x264_cabac_entropy[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; int i_state = *state;
*state = x264_cabac_transition[i_state][b]; *state = x264_cabac_transition[i_state][b];
return x264_cabac_entropy[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]; int i_state = cb->state[i_ctx];
cb->f8_bits_encoded += x264_cabac_entropy[i_state][b]; 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]; return x264_cabac_entropy[*state][b];
} }
......
...@@ -132,22 +132,22 @@ void x264_log( x264_t *h, int i_level, const char *psz_fmt, ... ); ...@@ -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_reduce_fraction( int *n, int *d );
void x264_init_vlc_tables(); 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; 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 ); 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 ); 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); int t = (a-b)&((a-b)>>31);
a -= t; a -= t;
...@@ -157,13 +157,13 @@ static inline int x264_median( int a, int b, int c ) ...@@ -157,13 +157,13 @@ static inline int x264_median( int a, int b, int c )
return b; 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[0] = x264_median( a[0], b[0], c[0] );
dst[1] = x264_median( a[1], b[1], c[1] ); 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; int sum = 0, i;
for( i = 0; i < i_mvc-1; 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 ) ...@@ -174,7 +174,7 @@ static inline int x264_predictor_difference( int16_t (*mvc)[2], intptr_t i_mvc )
return sum; 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 amvd0 = abs(mvdleft[0]) + abs(mvdtop[0]);
int amvd1 = abs(mvdleft[1]) + abs(mvdtop[1]); int amvd1 = abs(mvdleft[1]) + abs(mvdtop[1]);
......
...@@ -445,7 +445,7 @@ static ALWAYS_INLINE int array_non_zero_int( int16_t *v, int i_count ) ...@@ -445,7 +445,7 @@ static ALWAYS_INLINE int array_non_zero_int( int16_t *v, int i_count )
return 0; 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 ma = h->mb.cache.intra4x4_pred_mode[x264_scan8[idx] - 1];
const int mb = h->mb.cache.intra4x4_pred_mode[x264_scan8[idx] - 8]; 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 ) ...@@ -457,7 +457,7 @@ static inline int x264_mb_predict_intra4x4_mode( x264_t *h, int idx )
return m; 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 za = h->mb.cache.non_zero_count[x264_scan8[idx] - 1];
const int zb = h->mb.cache.non_zero_count[x264_scan8[idx] - 8]; 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 ) ...@@ -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 * check whether any partition is smaller than 8x8 (or at least
* might be, according to just partition type.) * might be, according to just partition type.)
* doesn't check for cbp */ * 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 // intra and skip are disallowed
// large partitions are allowed // large partitions are allowed
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#ifdef __GNUC__ #ifdef __GNUC__
#define x264_median_mv x264_median_mv_mmxext #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( asm(
"movd %1, %%mm0 \n" "movd %1, %%mm0 \n"
...@@ -43,7 +43,7 @@ static inline void x264_median_mv_mmxext( int16_t *dst, int16_t *a, int16_t *b, ...@@ -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 #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; int sum;
static const uint64_t pw_1 = 0x0001000100010001ULL; static const uint64_t pw_1 = 0x0001000100010001ULL;
......
...@@ -548,19 +548,19 @@ static const int8_t i4x4_mode_available[5][10] = ...@@ -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}, {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); int idx = i_neighbour & (MB_TOP|MB_LEFT|MB_TOPLEFT);
return i16x16_mode_available[(idx&MB_TOPLEFT)?4:idx]; 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); int idx = i_neighbour & (MB_TOP|MB_LEFT|MB_TOPLEFT);
return i8x8chroma_mode_available[(idx&MB_TOPLEFT)?4:idx]; 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); int idx = i_neighbour & (MB_TOP|MB_LEFT|MB_TOPLEFT);
return i4x4_mode_available[(idx&MB_TOPLEFT)?4:idx]; return i4x4_mode_available[(idx&MB_TOPLEFT)?4:idx];
......
...@@ -301,7 +301,7 @@ static inline void x264_cabac_mb_sub_p_partition( x264_cabac_t *cb, int i_sub ) ...@@ -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 ) 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 ) ...@@ -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 ); 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; int ctx = 399 + h->mb.cache.i_neighbour_transform_size;
x264_cabac_encode_decision_noup( cb, ctx, h->mb.b_transform_8x8 ); 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 ...@@ -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 ); 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 i_abs = abs( mvd );
const int ctxbase = l ? 47 : 40; const int ctxbase = l ? 47 : 40;
......
...@@ -33,10 +33,10 @@ void x264_rdo_init( void ); ...@@ -33,10 +33,10 @@ void x264_rdo_init( void );
int x264_macroblock_probe_skip( x264_t *h, int b_bidir ); int x264_macroblock_probe_skip( x264_t *h, int b_bidir );
static inline int x264_macroblock_probe_pskip( x264_t *h ) #define x264_macroblock_probe_pskip( h )\
{ return x264_macroblock_probe_skip( h, 0 ); } x264_macroblock_probe_skip( h, 0 )
static inline int x264_macroblock_probe_bskip( x264_t *h ) #define x264_macroblock_probe_bskip( h )\
{ return x264_macroblock_probe_skip( h, 1 ); } x264_macroblock_probe_skip( h, 1 )
void x264_predict_lossless_8x8_chroma( x264_t *h, int i_mode ); 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 ); void x264_predict_lossless_4x4( x264_t *h, uint8_t *p_dst, int idx, int i_mode );
......
...@@ -58,8 +58,8 @@ typedef struct { ...@@ -58,8 +58,8 @@ typedef struct {
} mvsad_t; } 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 ); 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 ) #define x264_me_search( h, m, mvc, i_mvc )\
{ x264_me_search_ref( h, m, mvc, i_mvc, NULL ); } 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( x264_t *h, x264_me_t *m );
void x264_me_refine_qpel_refdupe( x264_t *h, x264_me_t *m, int *p_halfpel_thresh ); void x264_me_refine_qpel_refdupe( x264_t *h, x264_me_t *m, int *p_halfpel_thresh );
......
...@@ -61,7 +61,7 @@ static uint16_t cabac_size_5ones[128]; ...@@ -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, \ #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) ) 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_x[4] = {4, 4, 3, 3};
static const uint8_t hadamard_shift_y[4] = {4-0, 3-0, 4-1, 3-1}; 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 ) ...@@ -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_x[3] = {3, 2, 2};
static const uint8_t satd_shift_y[3] = {2-1, 3-2, 2-2}; static const uint8_t satd_shift_y[3] = {2-1, 3-2, 2-2};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment