changeset 11046:15add32dd717 libavcodec

Extract duplicated code into a separate function. 5% faster on Intel Atom with gcc 4.4.1 (performance is unchanged if using av_always_inline).
author reimar
date Thu, 28 Jan 2010 20:15:19 +0000
parents 5f712d734793
children ec682347e19e
files mpc7.c
diffstat 1 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/mpc7.c	Thu Jan 28 19:44:13 2010 +0000
+++ b/mpc7.c	Thu Jan 28 20:15:19 2010 +0000
@@ -175,6 +175,14 @@
     }
 }
 
+static int get_scale_idx(GetBitContext *gb, int ref)
+{
+    int t = get_vlc2(gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7;
+    if (t == 8)
+        return get_bits(gb, 6);
+    return ref + t;
+}
+
 static int mpc7_decode_frame(AVCodecContext * avctx,
                             void *data, int *data_size,
                             AVPacket *avpkt)
@@ -222,24 +230,19 @@
         for(ch = 0; ch < 2; ch++){
             if(bands[i].res[ch]){
                 bands[i].scf_idx[ch][2] = c->oldDSCF[ch][i];
-                t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7;
-                bands[i].scf_idx[ch][0] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][2] + t);
+                bands[i].scf_idx[ch][0] = get_scale_idx(&gb, bands[i].scf_idx[ch][2]);
                 switch(bands[i].scfi[ch]){
                 case 0:
-                    t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7;
-                    bands[i].scf_idx[ch][1] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][0] + t);
-                    t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7;
-                    bands[i].scf_idx[ch][2] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][1] + t);
+                    bands[i].scf_idx[ch][1] = get_scale_idx(&gb, bands[i].scf_idx[ch][0]);
+                    bands[i].scf_idx[ch][2] = get_scale_idx(&gb, bands[i].scf_idx[ch][1]);
                     break;
                 case 1:
-                    t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7;
-                    bands[i].scf_idx[ch][1] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][0] + t);
+                    bands[i].scf_idx[ch][1] = get_scale_idx(&gb, bands[i].scf_idx[ch][0]);
                     bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1];
                     break;
                 case 2:
                     bands[i].scf_idx[ch][1] = bands[i].scf_idx[ch][0];
-                    t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7;
-                    bands[i].scf_idx[ch][2] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][1] + t);
+                    bands[i].scf_idx[ch][2] = get_scale_idx(&gb, bands[i].scf_idx[ch][1]);
                     break;
                 case 3:
                     bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1] = bands[i].scf_idx[ch][0];