1
mirror of https://git.videolan.org/git/ffmpeg.git synced 2024-09-09 09:16:59 +02:00

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).

Originally committed as revision 21516 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
Reimar Döffinger 2010-01-28 20:15:19 +00:00
parent 604b2f5276
commit 88517e9f9d

View File

@ -175,6 +175,14 @@ static inline void idx_to_quant(MPCContext *c, GetBitContext *gb, int idx, int *
} }
} }
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, static int mpc7_decode_frame(AVCodecContext * avctx,
void *data, int *data_size, void *data, int *data_size,
AVPacket *avpkt) AVPacket *avpkt)
@ -222,24 +230,19 @@ static int mpc7_decode_frame(AVCodecContext * avctx,
for(ch = 0; ch < 2; ch++){ for(ch = 0; ch < 2; ch++){
if(bands[i].res[ch]){ if(bands[i].res[ch]){
bands[i].scf_idx[ch][2] = c->oldDSCF[ch][i]; 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] = get_scale_idx(&gb, bands[i].scf_idx[ch][2]);
bands[i].scf_idx[ch][0] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][2] + t);
switch(bands[i].scfi[ch]){ switch(bands[i].scfi[ch]){
case 0: case 0:
t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7; bands[i].scf_idx[ch][1] = get_scale_idx(&gb, bands[i].scf_idx[ch][0]);
bands[i].scf_idx[ch][1] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][0] + t); bands[i].scf_idx[ch][2] = get_scale_idx(&gb, bands[i].scf_idx[ch][1]);
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);
break; break;
case 1: case 1:
t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7; bands[i].scf_idx[ch][1] = get_scale_idx(&gb, bands[i].scf_idx[ch][0]);
bands[i].scf_idx[ch][1] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][0] + t);
bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1]; bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1];
break; break;
case 2: case 2:
bands[i].scf_idx[ch][1] = bands[i].scf_idx[ch][0]; 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] = get_scale_idx(&gb, bands[i].scf_idx[ch][1]);
bands[i].scf_idx[ch][2] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][1] + t);
break; break;
case 3: case 3:
bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1] = bands[i].scf_idx[ch][0]; bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1] = bands[i].scf_idx[ch][0];