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
23 * mpeg audio declarations for both encoder and decoder.
26 /* max frame size, in samples */
27 #define MPA_FRAME_SIZE 1152
29 /* max compressed frame size */
30 #define MPA_MAX_CODED_FRAME_SIZE 1792
32 #define MPA_MAX_CHANNELS 2
34 #define SBLIMIT 32 /* number of subbands */
41 /* header + layer + bitrate + freq + lsf/mpeg25 */
42 #define SAME_HEADER_MASK \
43 (0xffe00000 | (3 << 17) | (0xf << 12) | (3 << 10) | (3 << 19))
45 /* define USE_HIGHPRECISION to have a bit exact (but slower) mpeg
48 #ifdef USE_HIGHPRECISION
49 #define FRAC_BITS 23 /* fractional bits for sb_samples and dct */
50 #define WFRAC_BITS 16 /* fractional bits for window */
52 #define FRAC_BITS 15 /* fractional bits for sb_samples and dct */
53 #define WFRAC_BITS 14 /* fractional bits for window */
56 #if defined(USE_HIGHPRECISION) && defined(CONFIG_AUDIO_NONSHORT)
57 typedef int32_t OUT_INT;
58 #define OUT_MAX INT32_MAX
59 #define OUT_MIN INT32_MIN
60 #define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 31)
62 typedef int16_t OUT_INT;
63 #define OUT_MAX INT16_MAX
64 #define OUT_MIN INT16_MIN
65 #define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15)
69 typedef int16_t MPA_INT;
71 typedef int32_t MPA_INT;
74 int l2_select_table(int bitrate, int nb_channels, int freq, int lsf);
75 int mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate);
76 void ff_mpa_synth_init(MPA_INT *window);
77 void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
78 MPA_INT *window, int *dither_state,
79 OUT_INT *samples, int incr,
80 int32_t sb_samples[SBLIMIT]);
82 /* fast header check for resync */
83 static inline int ff_mpa_check_header(uint32_t header){
85 if ((header & 0xffe00000) != 0xffe00000)
88 if ((header & (3<<17)) == 0)
91 if ((header & (0xf<<12)) == 0xf<<12)
94 if ((header & (3<<10)) == 3<<10)