Mercurial > libavcodec.hg
comparison mpc7.c @ 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 | 987373501407 |
children | 9db9a81cc220 |
comparison
equal
deleted
inserted
replaced
11045:5f712d734793 | 11046:15add32dd717 |
---|---|
173 default: // case 0 and -2..-17 | 173 default: // case 0 and -2..-17 |
174 return; | 174 return; |
175 } | 175 } |
176 } | 176 } |
177 | 177 |
178 static int get_scale_idx(GetBitContext *gb, int ref) | |
179 { | |
180 int t = get_vlc2(gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7; | |
181 if (t == 8) | |
182 return get_bits(gb, 6); | |
183 return ref + t; | |
184 } | |
185 | |
178 static int mpc7_decode_frame(AVCodecContext * avctx, | 186 static int mpc7_decode_frame(AVCodecContext * avctx, |
179 void *data, int *data_size, | 187 void *data, int *data_size, |
180 AVPacket *avpkt) | 188 AVPacket *avpkt) |
181 { | 189 { |
182 const uint8_t *buf = avpkt->data; | 190 const uint8_t *buf = avpkt->data; |
220 /* get scale indexes */ | 228 /* get scale indexes */ |
221 for(i = 0; i <= mb; i++){ | 229 for(i = 0; i <= mb; i++){ |
222 for(ch = 0; ch < 2; ch++){ | 230 for(ch = 0; ch < 2; ch++){ |
223 if(bands[i].res[ch]){ | 231 if(bands[i].res[ch]){ |
224 bands[i].scf_idx[ch][2] = c->oldDSCF[ch][i]; | 232 bands[i].scf_idx[ch][2] = c->oldDSCF[ch][i]; |
225 t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7; | 233 bands[i].scf_idx[ch][0] = get_scale_idx(&gb, bands[i].scf_idx[ch][2]); |
226 bands[i].scf_idx[ch][0] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][2] + t); | |
227 switch(bands[i].scfi[ch]){ | 234 switch(bands[i].scfi[ch]){ |
228 case 0: | 235 case 0: |
229 t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7; | 236 bands[i].scf_idx[ch][1] = get_scale_idx(&gb, bands[i].scf_idx[ch][0]); |
230 bands[i].scf_idx[ch][1] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][0] + t); | 237 bands[i].scf_idx[ch][2] = get_scale_idx(&gb, bands[i].scf_idx[ch][1]); |
231 t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7; | |
232 bands[i].scf_idx[ch][2] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][1] + t); | |
233 break; | 238 break; |
234 case 1: | 239 case 1: |
235 t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7; | 240 bands[i].scf_idx[ch][1] = get_scale_idx(&gb, bands[i].scf_idx[ch][0]); |
236 bands[i].scf_idx[ch][1] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][0] + t); | |
237 bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1]; | 241 bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1]; |
238 break; | 242 break; |
239 case 2: | 243 case 2: |
240 bands[i].scf_idx[ch][1] = bands[i].scf_idx[ch][0]; | 244 bands[i].scf_idx[ch][1] = bands[i].scf_idx[ch][0]; |
241 t = get_vlc2(&gb, dscf_vlc.table, MPC7_DSCF_BITS, 1) - 7; | 245 bands[i].scf_idx[ch][2] = get_scale_idx(&gb, bands[i].scf_idx[ch][1]); |
242 bands[i].scf_idx[ch][2] = (t == 8) ? get_bits(&gb, 6) : (bands[i].scf_idx[ch][1] + t); | |
243 break; | 246 break; |
244 case 3: | 247 case 3: |
245 bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1] = bands[i].scf_idx[ch][0]; | 248 bands[i].scf_idx[ch][2] = bands[i].scf_idx[ch][1] = bands[i].scf_idx[ch][0]; |
246 break; | 249 break; |
247 } | 250 } |