Mercurial > libavcodec.hg
annotate mpegaudio.h @ 12014:e21223172ca8 libavcodec
ARM: (mostly) whitespace cosmetics
author | mru |
---|---|
date | Tue, 29 Jun 2010 14:48:41 +0000 |
parents | ef338bd70180 |
children | 3f3d08bb5cf8 |
rev | line source |
---|---|
3699
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2979
diff
changeset
|
1 /* |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2979
diff
changeset
|
2 * copyright (c) 2001 Fabrice Bellard |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2979
diff
changeset
|
3 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3699
diff
changeset
|
4 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3699
diff
changeset
|
5 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3699
diff
changeset
|
6 * FFmpeg is free software; you can redistribute it and/or |
3699
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2979
diff
changeset
|
7 * modify it under the terms of the GNU Lesser General Public |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2979
diff
changeset
|
8 * License as published by the Free Software Foundation; either |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3699
diff
changeset
|
9 * version 2.1 of the License, or (at your option) any later version. |
3699
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2979
diff
changeset
|
10 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3699
diff
changeset
|
11 * FFmpeg is distributed in the hope that it will be useful, |
3699
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2979
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2979
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2979
diff
changeset
|
14 * Lesser General Public License for more details. |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2979
diff
changeset
|
15 * |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2979
diff
changeset
|
16 * You should have received a copy of the GNU Lesser General Public |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3699
diff
changeset
|
17 * License along with FFmpeg; if not, write to the Free Software |
3699
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2979
diff
changeset
|
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2979
diff
changeset
|
19 */ |
c537a97eec66
Add official LGPL license headers to the files that were missing them.
diego
parents:
2979
diff
changeset
|
20 |
1106 | 21 /** |
11644
7dd2a45249a9
Remove explicit filename from Doxygen @file commands.
diego
parents:
11369
diff
changeset
|
22 * @file |
1106 | 23 * mpeg audio declarations for both encoder and decoder. |
24 */ | |
84 | 25 |
7760 | 26 #ifndef AVCODEC_MPEGAUDIO_H |
27 #define AVCODEC_MPEGAUDIO_H | |
5050 | 28 |
11707 | 29 #ifndef CONFIG_FLOAT |
30 # define CONFIG_FLOAT 0 | |
31 #endif | |
32 | |
5052
d981eb275c8f
remove dependency of mpeg audio encoder over mpeg audio decoder
aurel
parents:
5051
diff
changeset
|
33 #include "avcodec.h" |
9428 | 34 #include "get_bits.h" |
5050 | 35 #include "dsputil.h" |
36 | |
8600 | 37 #define CONFIG_AUDIO_NONSHORT 0 |
38 | |
84 | 39 /* max frame size, in samples */ |
2967 | 40 #define MPA_FRAME_SIZE 1152 |
0 | 41 |
42 /* max compressed frame size */ | |
84 | 43 #define MPA_MAX_CODED_FRAME_SIZE 1792 |
0 | 44 |
45 #define MPA_MAX_CHANNELS 2 | |
46 | |
47 #define SBLIMIT 32 /* number of subbands */ | |
84 | 48 |
49 #define MPA_STEREO 0 | |
50 #define MPA_JSTEREO 1 | |
51 #define MPA_DUAL 2 | |
52 #define MPA_MONO 3 | |
53 | |
2472 | 54 /* header + layer + bitrate + freq + lsf/mpeg25 */ |
55 #define SAME_HEADER_MASK \ | |
56 (0xffe00000 | (3 << 17) | (0xf << 12) | (3 << 10) | (3 << 19)) | |
57 | |
5033
3c034e71667f
move mp3_header_decompress bitstream filter in its own file
aurel
parents:
5031
diff
changeset
|
58 #define MP3_MASK 0xFFFE0CCF |
3c034e71667f
move mp3_header_decompress bitstream filter in its own file
aurel
parents:
5031
diff
changeset
|
59 |
8594
c5349ca95c08
Replace #ifdef CONFIG_ preprocessor check by #if CONFIG_.
diego
parents:
8592
diff
changeset
|
60 #if CONFIG_MPEGAUDIO_HP |
2913 | 61 #define FRAC_BITS 23 /* fractional bits for sb_samples and dct */ |
62 #define WFRAC_BITS 16 /* fractional bits for window */ | |
63 #else | |
64 #define FRAC_BITS 15 /* fractional bits for sb_samples and dct */ | |
65 #define WFRAC_BITS 14 /* fractional bits for window */ | |
66 #endif | |
67 | |
5161 | 68 #define FRAC_ONE (1 << FRAC_BITS) |
69 | |
70 #define FIX(a) ((int)((a) * FRAC_ONE)) | |
71 | |
11707 | 72 #if CONFIG_FLOAT |
73 typedef float OUT_INT; | |
74 #define OUT_FMT SAMPLE_FMT_FLT | |
75 #elif CONFIG_MPEGAUDIO_HP && CONFIG_AUDIO_NONSHORT | |
2913 | 76 typedef int32_t OUT_INT; |
77 #define OUT_MAX INT32_MAX | |
78 #define OUT_MIN INT32_MIN | |
79 #define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 31) | |
8598
6550218be3b7
simplify: group all the AUDIO_NONSHORT parameters in the same place
aurel
parents:
8594
diff
changeset
|
80 #define OUT_FMT SAMPLE_FMT_S32 |
2913 | 81 #else |
82 typedef int16_t OUT_INT; | |
83 #define OUT_MAX INT16_MAX | |
84 #define OUT_MIN INT16_MIN | |
85 #define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15) | |
8598
6550218be3b7
simplify: group all the AUDIO_NONSHORT parameters in the same place
aurel
parents:
8594
diff
changeset
|
86 #define OUT_FMT SAMPLE_FMT_S16 |
2913 | 87 #endif |
88 | |
11707 | 89 #if CONFIG_FLOAT |
90 # define INTFLOAT float | |
91 typedef float MPA_INT; | |
92 #elif FRAC_BITS <= 15 | |
93 # define INTFLOAT int | |
2913 | 94 typedef int16_t MPA_INT; |
95 #else | |
11707 | 96 # define INTFLOAT int |
2913 | 97 typedef int32_t MPA_INT; |
98 #endif | |
99 | |
5050 | 100 #define BACKSTEP_SIZE 512 |
101 #define EXTRABYTES 24 | |
102 | |
10494 | 103 /* layer 3 "granule" */ |
104 typedef struct GranuleDef { | |
105 uint8_t scfsi; | |
106 int part2_3_length; | |
107 int big_values; | |
108 int global_gain; | |
109 int scalefac_compress; | |
110 uint8_t block_type; | |
111 uint8_t switch_point; | |
112 int table_select[3]; | |
113 int subblock_gain[3]; | |
114 uint8_t scalefac_scale; | |
115 uint8_t count1table_select; | |
116 int region_size[3]; /* number of huffman codes in each region */ | |
117 int preflag; | |
118 int short_start, long_end; /* long/short band indexes */ | |
119 uint8_t scale_factors[40]; | |
11707 | 120 INTFLOAT sb_hybrid[SBLIMIT * 18]; /* 576 samples */ |
10494 | 121 } GranuleDef; |
5050 | 122 |
8641 | 123 #define MPA_DECODE_HEADER \ |
124 int frame_size; \ | |
125 int error_protection; \ | |
126 int layer; \ | |
127 int sample_rate; \ | |
128 int sample_rate_index; /* between 0 and 8 */ \ | |
129 int bit_rate; \ | |
130 int nb_channels; \ | |
131 int mode; \ | |
132 int mode_ext; \ | |
133 int lsf; | |
134 | |
135 typedef struct MPADecodeHeader { | |
136 MPA_DECODE_HEADER | |
137 } MPADecodeHeader; | |
138 | |
5050 | 139 typedef struct MPADecodeContext { |
8641 | 140 MPA_DECODE_HEADER |
10093 | 141 uint8_t last_buf[2*BACKSTEP_SIZE + EXTRABYTES]; |
5050 | 142 int last_buf_size; |
143 /* next header (used in free format parsing) */ | |
144 uint32_t free_format_next_header; | |
145 GetBitContext gb; | |
146 GetBitContext in_gb; | |
11369 | 147 DECLARE_ALIGNED(16, MPA_INT, synth_buf)[MPA_MAX_CHANNELS][512 * 2]; |
5050 | 148 int synth_buf_offset[MPA_MAX_CHANNELS]; |
11707 | 149 DECLARE_ALIGNED(16, INTFLOAT, sb_samples)[MPA_MAX_CHANNELS][36][SBLIMIT]; |
150 INTFLOAT mdct_buf[MPA_MAX_CHANNELS][SBLIMIT * 18]; /* previous samples, for layer 3 MDCT */ | |
10494 | 151 GranuleDef granules[2][2]; /* Used in Layer 3 */ |
5050 | 152 #ifdef DEBUG |
153 int frame_count; | |
154 #endif | |
155 int adu_mode; ///< 0 for standard mp3, 1 for adu formatted mp3 | |
156 int dither_state; | |
7831 | 157 int error_recognition; |
5050 | 158 AVCodecContext* avctx; |
11885
0e777af9160a
Factorize the mpegaudio windowing code in a function and call it by a
vitor
parents:
11707
diff
changeset
|
159 void (*apply_window_mp3)(MPA_INT *synth_buf, MPA_INT *window, |
0e777af9160a
Factorize the mpegaudio windowing code in a function and call it by a
vitor
parents:
11707
diff
changeset
|
160 int *dither_state, OUT_INT *samples, int incr); |
5050 | 161 } MPADecodeContext; |
162 | |
5161 | 163 /* layer 3 huffman tables */ |
164 typedef struct HuffTable { | |
165 int xsize; | |
166 const uint8_t *bits; | |
167 const uint16_t *codes; | |
168 } HuffTable; | |
169 | |
5052
d981eb275c8f
remove dependency of mpeg audio encoder over mpeg audio decoder
aurel
parents:
5051
diff
changeset
|
170 int ff_mpa_l2_select_table(int bitrate, int nb_channels, int freq, int lsf); |
8420
2b0d01be134f
Change mpeg audio parser so it only sets frame_size, channels and bit_rate
michael
parents:
7831
diff
changeset
|
171 int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bitrate); |
10440
899237b1961f
mpegaudiodec, mpc and qdm2 all use the same mpa_synth window, so make
reimar
parents:
10093
diff
changeset
|
172 extern MPA_INT ff_mpa_synth_window[]; |
2913 | 173 void ff_mpa_synth_init(MPA_INT *window); |
174 void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset, | |
2979 | 175 MPA_INT *window, int *dither_state, |
2913 | 176 OUT_INT *samples, int incr, |
11707 | 177 INTFLOAT sb_samples[SBLIMIT]); |
178 | |
179 void ff_mpa_synth_init_float(MPA_INT *window); | |
11885
0e777af9160a
Factorize the mpegaudio windowing code in a function and call it by a
vitor
parents:
11707
diff
changeset
|
180 void ff_mpa_synth_filter_float(MPADecodeContext *s, |
0e777af9160a
Factorize the mpegaudio windowing code in a function and call it by a
vitor
parents:
11707
diff
changeset
|
181 MPA_INT *synth_buf_ptr, int *synth_buf_offset, |
11707 | 182 MPA_INT *window, int *dither_state, |
183 OUT_INT *samples, int incr, | |
184 INTFLOAT sb_samples[SBLIMIT]); | |
0 | 185 |
11939
ef338bd70180
SSE-optimized MP3 floating point windowing functions
vitor
parents:
11885
diff
changeset
|
186 void ff_mpegaudiodec_init_mmx(MPADecodeContext *s); |
ef338bd70180
SSE-optimized MP3 floating point windowing functions
vitor
parents:
11885
diff
changeset
|
187 |
2472 | 188 /* fast header check for resync */ |
189 static inline int ff_mpa_check_header(uint32_t header){ | |
190 /* header */ | |
191 if ((header & 0xffe00000) != 0xffe00000) | |
192 return -1; | |
193 /* layer check */ | |
194 if ((header & (3<<17)) == 0) | |
195 return -1; | |
196 /* bit rate */ | |
197 if ((header & (0xf<<12)) == 0xf<<12) | |
198 return -1; | |
199 /* frequency */ | |
200 if ((header & (3<<10)) == 3<<10) | |
201 return -1; | |
202 return 0; | |
203 } | |
5050 | 204 |
7760 | 205 #endif /* AVCODEC_MPEGAUDIO_H */ |