Remove unused types
[ffmpeg-lucabe.git] / libavcodec / mpegaudio.h
blob21de2da20d5a2669aae505ec7a2ec274c43a4366
1 /*
2 * copyright (c) 2001 Fabrice Bellard
4 * This file is part of FFmpeg.
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 /**
22 * @file mpegaudio.h
23 * mpeg audio declarations for both encoder and decoder.
26 #ifndef AVCODEC_MPEGAUDIO_H
27 #define AVCODEC_MPEGAUDIO_H
29 #include "avcodec.h"
30 #include "bitstream.h"
31 #include "dsputil.h"
33 /* max frame size, in samples */
34 #define MPA_FRAME_SIZE 1152
36 /* max compressed frame size */
37 #define MPA_MAX_CODED_FRAME_SIZE 1792
39 #define MPA_MAX_CHANNELS 2
41 #define SBLIMIT 32 /* number of subbands */
43 #define MPA_STEREO 0
44 #define MPA_JSTEREO 1
45 #define MPA_DUAL 2
46 #define MPA_MONO 3
48 /* header + layer + bitrate + freq + lsf/mpeg25 */
49 #define SAME_HEADER_MASK \
50 (0xffe00000 | (3 << 17) | (0xf << 12) | (3 << 10) | (3 << 19))
52 #define MP3_MASK 0xFFFE0CCF
54 /* define USE_HIGHPRECISION to have a bit exact (but slower) mpeg
55 audio decoder */
57 #ifdef USE_HIGHPRECISION
58 #define FRAC_BITS 23 /* fractional bits for sb_samples and dct */
59 #define WFRAC_BITS 16 /* fractional bits for window */
60 #else
61 #define FRAC_BITS 15 /* fractional bits for sb_samples and dct */
62 #define WFRAC_BITS 14 /* fractional bits for window */
63 #endif
65 #define FRAC_ONE (1 << FRAC_BITS)
67 #define FIX(a) ((int)((a) * FRAC_ONE))
69 #if defined(USE_HIGHPRECISION) && defined(CONFIG_AUDIO_NONSHORT)
70 typedef int32_t OUT_INT;
71 #define OUT_MAX INT32_MAX
72 #define OUT_MIN INT32_MIN
73 #define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 31)
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)
79 #endif
81 #if FRAC_BITS <= 15
82 typedef int16_t MPA_INT;
83 #else
84 typedef int32_t MPA_INT;
85 #endif
87 #define BACKSTEP_SIZE 512
88 #define EXTRABYTES 24
90 struct GranuleDef;
92 typedef struct MPADecodeContext {
93 DECLARE_ALIGNED_8(uint8_t, last_buf[2*BACKSTEP_SIZE + EXTRABYTES]);
94 int last_buf_size;
95 int frame_size;
96 /* next header (used in free format parsing) */
97 uint32_t free_format_next_header;
98 int error_protection;
99 int layer;
100 int sample_rate;
101 int sample_rate_index; /* between 0 and 8 */
102 int bit_rate;
103 GetBitContext gb;
104 GetBitContext in_gb;
105 int nb_channels;
106 int mode;
107 int mode_ext;
108 int lsf;
109 DECLARE_ALIGNED_16(MPA_INT, synth_buf[MPA_MAX_CHANNELS][512 * 2]);
110 int synth_buf_offset[MPA_MAX_CHANNELS];
111 DECLARE_ALIGNED_16(int32_t, sb_samples[MPA_MAX_CHANNELS][36][SBLIMIT]);
112 int32_t mdct_buf[MPA_MAX_CHANNELS][SBLIMIT * 18]; /* previous samples, for layer 3 MDCT */
113 #ifdef DEBUG
114 int frame_count;
115 #endif
116 void (*compute_antialias)(struct MPADecodeContext *s, struct GranuleDef *g);
117 int adu_mode; ///< 0 for standard mp3, 1 for adu formatted mp3
118 int dither_state;
119 int error_recognition;
120 AVCodecContext* avctx;
121 } MPADecodeContext;
123 /* layer 3 huffman tables */
124 typedef struct HuffTable {
125 int xsize;
126 const uint8_t *bits;
127 const uint16_t *codes;
128 } HuffTable;
130 int ff_mpa_l2_select_table(int bitrate, int nb_channels, int freq, int lsf);
131 int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate);
132 void ff_mpa_synth_init(MPA_INT *window);
133 void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
134 MPA_INT *window, int *dither_state,
135 OUT_INT *samples, int incr,
136 int32_t sb_samples[SBLIMIT]);
138 /* fast header check for resync */
139 static inline int ff_mpa_check_header(uint32_t header){
140 /* header */
141 if ((header & 0xffe00000) != 0xffe00000)
142 return -1;
143 /* layer check */
144 if ((header & (3<<17)) == 0)
145 return -1;
146 /* bit rate */
147 if ((header & (0xf<<12)) == 0xf<<12)
148 return -1;
149 /* frequency */
150 if ((header & (3<<10)) == 3<<10)
151 return -1;
152 return 0;
155 #endif /* AVCODEC_MPEGAUDIO_H */