]> git.sesse.net Git - ffmpeg/blob - libavcodec/mpegaudiodec_float.c
Replace int_fast integer types with their sized standard posix counterparts.
[ffmpeg] / libavcodec / mpegaudiodec_float.c
1 /*
2  * Float MPEG Audio decoder
3  * Copyright (c) 2010 Michael Niedermayer
4  *
5  * This file is part of Libav.
6  *
7  * Libav is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * Libav is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with Libav; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21
22 #define CONFIG_FLOAT 1
23 #include "mpegaudiodec.c"
24
25 void ff_mpa_synth_filter_float(MPADecodeContext *s, float *synth_buf_ptr,
26                                int *synth_buf_offset,
27                                float *window, int *dither_state,
28                                float *samples, int incr,
29                                float sb_samples[SBLIMIT])
30 {
31     float *synth_buf;
32     int offset;
33
34     offset = *synth_buf_offset;
35     synth_buf = synth_buf_ptr + offset;
36
37     s->dct.dct32(synth_buf, sb_samples);
38     s->apply_window_mp3(synth_buf, window, dither_state, samples, incr);
39
40     offset = (offset - 32) & 511;
41     *synth_buf_offset = offset;
42 }
43
44 static void compute_antialias_float(MPADecodeContext *s,
45                               GranuleDef *g)
46 {
47     float *ptr;
48     int n, i;
49
50     /* we antialias only "long" bands */
51     if (g->block_type == 2) {
52         if (!g->switch_point)
53             return;
54         /* XXX: check this for 8000Hz case */
55         n = 1;
56     } else {
57         n = SBLIMIT - 1;
58     }
59
60     ptr = g->sb_hybrid + 18;
61     for(i = n;i > 0;i--) {
62         float tmp0, tmp1;
63         float *csa = &csa_table_float[0][0];
64 #define FLOAT_AA(j)\
65         tmp0= ptr[-1-j];\
66         tmp1= ptr[   j];\
67         ptr[-1-j] = tmp0 * csa[0+4*j] - tmp1 * csa[1+4*j];\
68         ptr[   j] = tmp0 * csa[1+4*j] + tmp1 * csa[0+4*j];
69
70         FLOAT_AA(0)
71         FLOAT_AA(1)
72         FLOAT_AA(2)
73         FLOAT_AA(3)
74         FLOAT_AA(4)
75         FLOAT_AA(5)
76         FLOAT_AA(6)
77         FLOAT_AA(7)
78
79         ptr += 18;
80     }
81 }
82
83 static av_cold int decode_end(AVCodecContext * avctx)
84 {
85     MPADecodeContext *s = avctx->priv_data;
86     ff_dct_end(&s->dct);
87     return 0;
88 }
89
90 #if CONFIG_MP1FLOAT_DECODER
91 AVCodec ff_mp1float_decoder =
92 {
93     "mp1float",
94     AVMEDIA_TYPE_AUDIO,
95     CODEC_ID_MP1,
96     sizeof(MPADecodeContext),
97     decode_init,
98     NULL,
99     decode_end,
100     decode_frame,
101     CODEC_CAP_PARSE_ONLY,
102     .flush= flush,
103     .long_name= NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"),
104 };
105 #endif
106 #if CONFIG_MP2FLOAT_DECODER
107 AVCodec ff_mp2float_decoder =
108 {
109     "mp2float",
110     AVMEDIA_TYPE_AUDIO,
111     CODEC_ID_MP2,
112     sizeof(MPADecodeContext),
113     decode_init,
114     NULL,
115     decode_end,
116     decode_frame,
117     CODEC_CAP_PARSE_ONLY,
118     .flush= flush,
119     .long_name= NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
120 };
121 #endif
122 #if CONFIG_MP3FLOAT_DECODER
123 AVCodec ff_mp3float_decoder =
124 {
125     "mp3float",
126     AVMEDIA_TYPE_AUDIO,
127     CODEC_ID_MP3,
128     sizeof(MPADecodeContext),
129     decode_init,
130     NULL,
131     decode_end,
132     decode_frame,
133     CODEC_CAP_PARSE_ONLY,
134     .flush= flush,
135     .long_name= NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
136 };
137 #endif
138 #if CONFIG_MP3ADUFLOAT_DECODER
139 AVCodec ff_mp3adufloat_decoder =
140 {
141     "mp3adufloat",
142     AVMEDIA_TYPE_AUDIO,
143     CODEC_ID_MP3ADU,
144     sizeof(MPADecodeContext),
145     decode_init,
146     NULL,
147     decode_end,
148     decode_frame_adu,
149     CODEC_CAP_PARSE_ONLY,
150     .flush= flush,
151     .long_name= NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"),
152 };
153 #endif
154 #if CONFIG_MP3ON4FLOAT_DECODER
155 AVCodec ff_mp3on4float_decoder =
156 {
157     "mp3on4float",
158     AVMEDIA_TYPE_AUDIO,
159     CODEC_ID_MP3ON4,
160     sizeof(MP3On4DecodeContext),
161     decode_init_mp3on4,
162     NULL,
163     decode_close_mp3on4,
164     decode_frame_mp3on4,
165     .flush= flush,
166     .long_name= NULL_IF_CONFIG_SMALL("MP3onMP4"),
167 };
168 #endif