[SCM] libav/experimental: Force speed irrelevant calls to get/put_symbol() to be noinline. We need to change decode_line to always_inline because gcc decided not to inline it anymore once we force some calls to get/put_symbol() to be non inlined and this decision of gcc would lead to a 10% overall speed loss. 100k smaller object file, no speed change

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Sun Jun 30 16:44:55 UTC 2013


The following commit has been merged in the experimental branch:
commit 217d34e3070378ab55f203aad8a662238fbc902f
Author: Michael Niedermayer <michaelni at gmx.at>
Date:   Fri Apr 24 01:50:09 2009 +0000

    Force speed irrelevant calls to get/put_symbol() to be noinline.
    We need to change decode_line to always_inline because gcc decided not to inline
    it anymore once we force some calls to get/put_symbol() to be non inlined and
    this decision of gcc would lead to a 10% overall speed loss.
    100k smaller object file, no speed change
    
    Originally committed as revision 18673 to svn://svn.ffmpeg.org/ffmpeg/trunk

diff --git a/libavcodec/ffv1.c b/libavcodec/ffv1.c
index 62b12ed..8184231 100644
--- a/libavcodec/ffv1.c
+++ b/libavcodec/ffv1.c
@@ -217,7 +217,7 @@ static inline int get_context(FFV1Context *f, int_fast16_t *src, int_fast16_t *l
         return f->quant_table[0][(L-LT) & 0xFF] + f->quant_table[1][(LT-T) & 0xFF] + f->quant_table[2][(T-RT) & 0xFF];
 }
 
-static inline void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signed){
+static inline void put_symbol_inline(RangeCoder *c, uint8_t *state, int v, int is_signed){
     int i;
 
     if(v){
@@ -243,7 +243,11 @@ static inline void put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signe
     }
 }
 
-static inline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed){
+static void av_noinline put_symbol(RangeCoder *c, uint8_t *state, int v, int is_signed){
+    put_symbol_inline(c, state, v, is_signed);
+}
+
+static inline int get_symbol_inline(RangeCoder *c, uint8_t *state, int is_signed){
     if(get_rac(c, state+0))
         return 0;
     else{
@@ -263,6 +267,10 @@ static inline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed){
     }
 }
 
+static int av_noinline get_symbol(RangeCoder *c, uint8_t *state, int is_signed){
+    return get_symbol_inline(c, state, is_signed);
+}
+
 static inline void update_vlc_state(VlcState * const state, const int v){
     int drift= state->drift;
     int count= state->count;
@@ -384,7 +392,7 @@ static inline int encode_line(FFV1Context *s, int w, int_fast16_t *sample[2], in
         diff= fold(diff, bits);
 
         if(s->ac){
-            put_symbol(c, p->state[context], diff, 1);
+            put_symbol_inline(c, p->state[context], diff, 1);
         }else{
             if(context == 0) run_mode=1;
 
@@ -702,7 +710,7 @@ static av_cold int common_end(AVCodecContext *avctx){
     return 0;
 }
 
-static inline void decode_line(FFV1Context *s, int w, int_fast16_t *sample[2], int plane_index, int bits){
+static av_always_inline void decode_line(FFV1Context *s, int w, int_fast16_t *sample[2], int plane_index, int bits){
     PlaneContext * const p= &s->plane[plane_index];
     RangeCoder * const c= &s->c;
     int x;
@@ -722,7 +730,7 @@ static inline void decode_line(FFV1Context *s, int w, int_fast16_t *sample[2], i
 
 
         if(s->ac){
-            diff= get_symbol(c, p->state[context], 1);
+            diff= get_symbol_inline(c, p->state[context], 1);
         }else{
             if(context == 0 && run_mode==0) run_mode=1;
 

-- 
Libav/FFmpeg packaging



More information about the pkg-multimedia-commits mailing list