Revision bf1f4da0 libavcodec/mpegaudiodec.c

View differences:

libavcodec/mpegaudiodec.c
180 180
    FIXR(1.68179283050742908605),
181 181
};
182 182

  
183
void ff_mpa_synth_init(MPA_INT *window);
183 184
static MPA_INT window[512] __attribute__((aligned(16)));
184 185
    
185 186
/* layer 1 unscaling */
......
350 351
                    scale_factor_mult[i][2]);
351 352
        }
352 353
        
353
        /* window */
354
        /* max = 18760, max sum over all 16 coefs : 44736 */
355
        for(i=0;i<257;i++) {
356
            int v;
357
            v = mpa_enwindow[i];
358
#if WFRAC_BITS < 16
359
            v = (v + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS);
360
#endif
361
            window[i] = v;
362
            if ((i & 63) != 0)
363
                v = -v;
364
            if (i != 0)
365
                window[512 - i] = v;
366
        }
354
	ff_mpa_synth_init(window);
367 355
        
368 356
        /* huffman decode tables */
369 357
        huff_code_table[0] = NULL;
......
850 838
    sum2 op2 MULS((w2)[7 * 64], tmp);\
851 839
}
852 840

  
841
void ff_mpa_synth_init(MPA_INT *window)
842
{
843
    int i;
844

  
845
    /* max = 18760, max sum over all 16 coefs : 44736 */
846
    for(i=0;i<257;i++) {
847
        int v;
848
        v = mpa_enwindow[i];
849
#if WFRAC_BITS < 16
850
        v = (v + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS);
851
#endif
852
        window[i] = v;
853
        if ((i & 63) != 0)
854
            v = -v;
855
        if (i != 0)
856
            window[512 - i] = v;
857
    }	
858
}
853 859

  
854 860
/* 32 sub band synthesis filter. Input: 32 sub band samples, Output:
855 861
   32 samples. */
856 862
/* XXX: optimize by avoiding ring buffer usage */
857
static void synth_filter(MPADecodeContext *s1,
858
                         int ch, int16_t *samples, int incr, 
863
void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
864
			 MPA_INT *window,
865
                         int16_t *samples, int incr, 
859 866
                         int32_t sb_samples[SBLIMIT])
860 867
{
861 868
    int32_t tmp[32];
......
868 875
#else
869 876
    int64_t sum, sum2;
870 877
#endif
871
    
878

  
872 879
    dct32(tmp, sb_samples);
873 880
    
874
    offset = s1->synth_buf_offset[ch];
875
    synth_buf = s1->synth_buf[ch] + offset;
881
    offset = *synth_buf_offset;
882
    synth_buf = synth_buf_ptr + offset;
876 883

  
877 884
    for(j=0;j<32;j++) {
878 885
        v = tmp[j];
......
926 933
    *samples = round_sample(sum);
927 934

  
928 935
    offset = (offset - 32) & 511;
929
    s1->synth_buf_offset[ch] = offset;
936
    *synth_buf_offset = offset;
930 937
}
931 938

  
932 939
/* cos(pi*i/24) */
......
2505 2512
    for(ch=0;ch<s->nb_channels;ch++) {
2506 2513
        samples_ptr = samples + ch;
2507 2514
        for(i=0;i<nb_frames;i++) {
2508
            synth_filter(s, ch, samples_ptr, s->nb_channels,
2515
            ff_mpa_synth_filter(s->synth_buf[ch], &(s->synth_buf_offset[ch]),
2516
			 window,
2517
			 samples_ptr, s->nb_channels,
2509 2518
                         s->sb_samples[ch][i]);
2510 2519
            samples_ptr += 32 * s->nb_channels;
2511 2520
        }

Also available in: Unified diff