Move some mpegaudio functions to new mpegaudiodsp subsystem
[libav.git] / 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 static void compute_antialias_float(MPADecodeContext *s,
26 GranuleDef *g)
27 {
28 float *ptr;
29 int n, i;
30
31 /* we antialias only "long" bands */
32 if (g->block_type == 2) {
33 if (!g->switch_point)
34 return;
35 /* XXX: check this for 8000Hz case */
36 n = 1;
37 } else {
38 n = SBLIMIT - 1;
39 }
40
41 ptr = g->sb_hybrid + 18;
42 for(i = n;i > 0;i--) {
43 float tmp0, tmp1;
44 float *csa = &csa_table_float[0][0];
45 #define FLOAT_AA(j)\
46 tmp0= ptr[-1-j];\
47 tmp1= ptr[ j];\
48 ptr[-1-j] = tmp0 * csa[0+4*j] - tmp1 * csa[1+4*j];\
49 ptr[ j] = tmp0 * csa[1+4*j] + tmp1 * csa[0+4*j];
50
51 FLOAT_AA(0)
52 FLOAT_AA(1)
53 FLOAT_AA(2)
54 FLOAT_AA(3)
55 FLOAT_AA(4)
56 FLOAT_AA(5)
57 FLOAT_AA(6)
58 FLOAT_AA(7)
59
60 ptr += 18;
61 }
62 }
63
64 #if CONFIG_MP1FLOAT_DECODER
65 AVCodec ff_mp1float_decoder =
66 {
67 "mp1float",
68 AVMEDIA_TYPE_AUDIO,
69 CODEC_ID_MP1,
70 sizeof(MPADecodeContext),
71 decode_init,
72 NULL,
73 .close = NULL,
74 decode_frame,
75 CODEC_CAP_PARSE_ONLY,
76 .flush= flush,
77 .long_name= NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"),
78 };
79 #endif
80 #if CONFIG_MP2FLOAT_DECODER
81 AVCodec ff_mp2float_decoder =
82 {
83 "mp2float",
84 AVMEDIA_TYPE_AUDIO,
85 CODEC_ID_MP2,
86 sizeof(MPADecodeContext),
87 decode_init,
88 NULL,
89 .close = NULL,
90 decode_frame,
91 CODEC_CAP_PARSE_ONLY,
92 .flush= flush,
93 .long_name= NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
94 };
95 #endif
96 #if CONFIG_MP3FLOAT_DECODER
97 AVCodec ff_mp3float_decoder =
98 {
99 "mp3float",
100 AVMEDIA_TYPE_AUDIO,
101 CODEC_ID_MP3,
102 sizeof(MPADecodeContext),
103 decode_init,
104 NULL,
105 .close = NULL,
106 decode_frame,
107 CODEC_CAP_PARSE_ONLY,
108 .flush= flush,
109 .long_name= NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
110 };
111 #endif
112 #if CONFIG_MP3ADUFLOAT_DECODER
113 AVCodec ff_mp3adufloat_decoder =
114 {
115 "mp3adufloat",
116 AVMEDIA_TYPE_AUDIO,
117 CODEC_ID_MP3ADU,
118 sizeof(MPADecodeContext),
119 decode_init,
120 NULL,
121 .close = NULL,
122 decode_frame_adu,
123 CODEC_CAP_PARSE_ONLY,
124 .flush= flush,
125 .long_name= NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"),
126 };
127 #endif
128 #if CONFIG_MP3ON4FLOAT_DECODER
129 AVCodec ff_mp3on4float_decoder =
130 {
131 "mp3on4float",
132 AVMEDIA_TYPE_AUDIO,
133 CODEC_ID_MP3ON4,
134 sizeof(MP3On4DecodeContext),
135 decode_init_mp3on4,
136 NULL,
137 decode_close_mp3on4,
138 decode_frame_mp3on4,
139 .flush= flush,
140 .long_name= NULL_IF_CONFIG_SMALL("MP3onMP4"),
141 };
142 #endif