Mercurial > libavcodec.hg
annotate mpegaudio.h @ 10427:1a3908177e87 libavcodec
Replace big square-root table by a call to ff_sqrt(). Based on a patch
by Reimar Dffinger.
author | vitor |
---|---|
date | Sun, 18 Oct 2009 16:29:10 +0000 |
parents | beb616cf1885 |
children | 899237b1961f |
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 /** |
8718
e9d9d946f213
Use full internal pathname in doxygen @file directives.
diego
parents:
8641
diff
changeset
|
22 * @file libavcodec/mpegaudio.h |
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 |
5052
d981eb275c8f
remove dependency of mpeg audio encoder over mpeg audio decoder
aurel
parents:
5051
diff
changeset
|
29 #include "avcodec.h" |
9428 | 30 #include "get_bits.h" |
5050 | 31 #include "dsputil.h" |
32 | |
8600 | 33 #define CONFIG_AUDIO_NONSHORT 0 |
34 | |
84 | 35 /* max frame size, in samples */ |
2967 | 36 #define MPA_FRAME_SIZE 1152 |
0 | 37 |
38 /* max compressed frame size */ | |
84 | 39 #define MPA_MAX_CODED_FRAME_SIZE 1792 |
0 | 40 |
41 #define MPA_MAX_CHANNELS 2 | |
42 | |
43 #define SBLIMIT 32 /* number of subbands */ | |
84 | 44 |
45 #define MPA_STEREO 0 | |
46 #define MPA_JSTEREO 1 | |
47 #define MPA_DUAL 2 | |
48 #define MPA_MONO 3 | |
49 | |
2472 | 50 /* header + layer + bitrate + freq + lsf/mpeg25 */ |
51 #define SAME_HEADER_MASK \ | |
52 (0xffe00000 | (3 << 17) | (0xf << 12) | (3 << 10) | (3 << 19)) | |
53 | |
5033
3c034e71667f
move mp3_header_decompress bitstream filter in its own file
aurel
parents:
5031
diff
changeset
|
54 #define MP3_MASK 0xFFFE0CCF |
3c034e71667f
move mp3_header_decompress bitstream filter in its own file
aurel
parents:
5031
diff
changeset
|
55 |
8594
c5349ca95c08
Replace #ifdef CONFIG_ preprocessor check by #if CONFIG_.
diego
parents:
8592
diff
changeset
|
56 #if CONFIG_MPEGAUDIO_HP |
2913 | 57 #define FRAC_BITS 23 /* fractional bits for sb_samples and dct */ |
58 #define WFRAC_BITS 16 /* fractional bits for window */ | |
59 #else | |
60 #define FRAC_BITS 15 /* fractional bits for sb_samples and dct */ | |
61 #define WFRAC_BITS 14 /* fractional bits for window */ | |
62 #endif | |
63 | |
5161 | 64 #define FRAC_ONE (1 << FRAC_BITS) |
65 | |
66 #define FIX(a) ((int)((a) * FRAC_ONE)) | |
67 | |
8594
c5349ca95c08
Replace #ifdef CONFIG_ preprocessor check by #if CONFIG_.
diego
parents:
8592
diff
changeset
|
68 #if CONFIG_MPEGAUDIO_HP && CONFIG_AUDIO_NONSHORT |
2913 | 69 typedef int32_t OUT_INT; |
70 #define OUT_MAX INT32_MAX | |
71 #define OUT_MIN INT32_MIN | |
72 #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
|
73 #define OUT_FMT SAMPLE_FMT_S32 |
2913 | 74 #else |
75 typedef int16_t OUT_INT; | |
76 #define OUT_MAX INT16_MAX | |
77 #define OUT_MIN INT16_MIN | |
78 #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
|
79 #define OUT_FMT SAMPLE_FMT_S16 |
2913 | 80 #endif |
81 | |
82 #if FRAC_BITS <= 15 | |
83 typedef int16_t MPA_INT; | |
84 #else | |
85 typedef int32_t MPA_INT; | |
86 #endif | |
87 | |
5050 | 88 #define BACKSTEP_SIZE 512 |
89 #define EXTRABYTES 24 | |
90 | |
91 struct GranuleDef; | |
92 | |
8641 | 93 #define MPA_DECODE_HEADER \ |
94 int frame_size; \ | |
95 int error_protection; \ | |
96 int layer; \ | |
97 int sample_rate; \ | |
98 int sample_rate_index; /* between 0 and 8 */ \ | |
99 int bit_rate; \ | |
100 int nb_channels; \ | |
101 int mode; \ | |
102 int mode_ext; \ | |
103 int lsf; | |
104 | |
105 typedef struct MPADecodeHeader { | |
106 MPA_DECODE_HEADER | |
107 } MPADecodeHeader; | |
108 | |
5050 | 109 typedef struct MPADecodeContext { |
8641 | 110 MPA_DECODE_HEADER |
10093 | 111 uint8_t last_buf[2*BACKSTEP_SIZE + EXTRABYTES]; |
5050 | 112 int last_buf_size; |
113 /* next header (used in free format parsing) */ | |
114 uint32_t free_format_next_header; | |
115 GetBitContext gb; | |
116 GetBitContext in_gb; | |
117 DECLARE_ALIGNED_16(MPA_INT, synth_buf[MPA_MAX_CHANNELS][512 * 2]); | |
118 int synth_buf_offset[MPA_MAX_CHANNELS]; | |
119 DECLARE_ALIGNED_16(int32_t, sb_samples[MPA_MAX_CHANNELS][36][SBLIMIT]); | |
120 int32_t mdct_buf[MPA_MAX_CHANNELS][SBLIMIT * 18]; /* previous samples, for layer 3 MDCT */ | |
121 #ifdef DEBUG | |
122 int frame_count; | |
123 #endif | |
124 void (*compute_antialias)(struct MPADecodeContext *s, struct GranuleDef *g); | |
125 int adu_mode; ///< 0 for standard mp3, 1 for adu formatted mp3 | |
126 int dither_state; | |
7831 | 127 int error_recognition; |
5050 | 128 AVCodecContext* avctx; |
129 } MPADecodeContext; | |
130 | |
5161 | 131 /* layer 3 huffman tables */ |
132 typedef struct HuffTable { | |
133 int xsize; | |
134 const uint8_t *bits; | |
135 const uint16_t *codes; | |
136 } HuffTable; | |
137 | |
5052
d981eb275c8f
remove dependency of mpeg audio encoder over mpeg audio decoder
aurel
parents:
5051
diff
changeset
|
138 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
|
139 int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bitrate); |
2913 | 140 void ff_mpa_synth_init(MPA_INT *window); |
141 void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset, | |
2979 | 142 MPA_INT *window, int *dither_state, |
2913 | 143 OUT_INT *samples, int incr, |
144 int32_t sb_samples[SBLIMIT]); | |
0 | 145 |
2472 | 146 /* fast header check for resync */ |
147 static inline int ff_mpa_check_header(uint32_t header){ | |
148 /* header */ | |
149 if ((header & 0xffe00000) != 0xffe00000) | |
150 return -1; | |
151 /* layer check */ | |
152 if ((header & (3<<17)) == 0) | |
153 return -1; | |
154 /* bit rate */ | |
155 if ((header & (0xf<<12)) == 0xf<<12) | |
156 return -1; | |
157 /* frequency */ | |
158 if ((header & (3<<10)) == 3<<10) | |
159 return -1; | |
160 return 0; | |
161 } | |
5050 | 162 |
7760 | 163 #endif /* AVCODEC_MPEGAUDIO_H */ |