Revision 4d49a5a7 libavcodec/mpegaudiodec.c

View differences:

libavcodec/mpegaudiodec.c
69 69

  
70 70
static void compute_antialias_integer(MPADecodeContext *s, GranuleDef *g);
71 71
static void compute_antialias_float(MPADecodeContext *s, GranuleDef *g);
72
static void apply_window_mp3_c(MPA_INT *synth_buf, MPA_INT *window,
73
                               int *dither_state, OUT_INT *samples, int incr);
72 74

  
73 75
/* vlc structure for decoding layer 3 huffman tables */
74 76
static VLC huff_vlc[16];
......
305 307
    int i, j, k;
306 308

  
307 309
    s->avctx = avctx;
310
    s->apply_window_mp3 = apply_window_mp3_c;
308 311

  
309 312
    avctx->sample_fmt= OUT_FMT;
310 313
    s->error_recognition= avctx->error_recognition;
......
836 839
    }
837 840
}
838 841

  
839
/* 32 sub band synthesis filter. Input: 32 sub band samples, Output:
840
   32 samples. */
841
/* XXX: optimize by avoiding ring buffer usage */
842
void RENAME(ff_mpa_synth_filter)(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
843
                         MPA_INT *window, int *dither_state,
844
                         OUT_INT *samples, int incr,
845
                         INTFLOAT sb_samples[SBLIMIT])
842
static void apply_window_mp3_c(MPA_INT *synth_buf, MPA_INT *window,
843
                               int *dither_state, OUT_INT *samples, int incr)
846 844
{
847
    register MPA_INT *synth_buf;
848 845
    register const MPA_INT *w, *w2, *p;
849
    int j, offset;
846
    int j;
850 847
    OUT_INT *samples2;
851 848
#if CONFIG_FLOAT
852 849
    float sum, sum2;
853 850
#elif FRAC_BITS <= 15
854
    int32_t tmp[32];
855 851
    int sum, sum2;
856 852
#else
857 853
    int64_t sum, sum2;
858 854
#endif
859 855

  
860
    offset = *synth_buf_offset;
861
    synth_buf = synth_buf_ptr + offset;
862

  
863
#if FRAC_BITS <= 15 && !CONFIG_FLOAT
864
    dct32(tmp, sb_samples);
865
    for(j=0;j<32;j++) {
866
        /* NOTE: can cause a loss in precision if very high amplitude
867
           sound */
868
        synth_buf[j] = av_clip_int16(tmp[j]);
869
    }
870
#else
871
    dct32(synth_buf, sb_samples);
872
#endif
873

  
874 856
    /* copy to avoid wrap */
875 857
    memcpy(synth_buf + 512, synth_buf, 32 * sizeof(*synth_buf));
876 858

  
......
909 891
    SUM8(MLSS, sum, w + 32, p);
910 892
    *samples = round_sample(&sum);
911 893
    *dither_state= sum;
894
}
895

  
896

  
897
/* 32 sub band synthesis filter. Input: 32 sub band samples, Output:
898
   32 samples. */
899
/* XXX: optimize by avoiding ring buffer usage */
900
#if CONFIG_FLOAT
901
void ff_mpa_synth_filter_float(MPADecodeContext *s, float *synth_buf_ptr,
902
                               int *synth_buf_offset,
903
                               float *window, int *dither_state,
904
                               float *samples, int incr,
905
                               float sb_samples[SBLIMIT])
906
{
907
    float *synth_buf;
908
    int offset;
909

  
910
    offset = *synth_buf_offset;
911
    synth_buf = synth_buf_ptr + offset;
912

  
913
    dct32(synth_buf, sb_samples);
914
    s->apply_window_mp3(synth_buf, window, dither_state, samples, incr);
915

  
916
    offset = (offset - 32) & 511;
917
    *synth_buf_offset = offset;
918
}
919
#else
920
void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
921
                         MPA_INT *window, int *dither_state,
922
                         OUT_INT *samples, int incr,
923
                         INTFLOAT sb_samples[SBLIMIT])
924
{
925
    register MPA_INT *synth_buf;
926
    int offset;
927
#if FRAC_BITS <= 15
928
    int32_t tmp[32];
929
#endif
930

  
931
    offset = *synth_buf_offset;
932
    synth_buf = synth_buf_ptr + offset;
933

  
934
#if FRAC_BITS <= 15 && !CONFIG_FLOAT
935
    dct32(tmp, sb_samples);
936
    for(j=0;j<32;j++) {
937
        /* NOTE: can cause a loss in precision if very high amplitude
938
           sound */
939
        synth_buf[j] = av_clip_int16(tmp[j]);
940
    }
941
#else
942
    dct32(synth_buf, sb_samples);
943
#endif
944

  
945
    apply_window_mp3_c(synth_buf, window, dither_state, samples, incr);
912 946

  
913 947
    offset = (offset - 32) & 511;
914 948
    *synth_buf_offset = offset;
915 949
}
950
#endif
916 951

  
917 952
#define C3 FIXHR(0.86602540378443864676/2)
918 953

  
......
2227 2262
    for(ch=0;ch<s->nb_channels;ch++) {
2228 2263
        samples_ptr = samples + ch;
2229 2264
        for(i=0;i<nb_frames;i++) {
2230
            RENAME(ff_mpa_synth_filter)(s->synth_buf[ch], &(s->synth_buf_offset[ch]),
2265
            RENAME(ff_mpa_synth_filter)(
2266
#if CONFIG_FLOAT
2267
                         s,
2268
#endif
2269
                         s->synth_buf[ch], &(s->synth_buf_offset[ch]),
2231 2270
                         RENAME(ff_mpa_synth_window), &s->dither_state,
2232 2271
                         samples_ptr, s->nb_channels,
2233 2272
                         s->sb_samples[ch][i]);

Also available in: Unified diff