QDM2 compatible decoder
[libav.git] / libavcodec / mpegaudio.h
CommitLineData
983e3246
MN
1/**
2 * @file mpegaudio.h
3 * mpeg audio declarations for both encoder and decoder.
4 */
2456e28d
FB
5
6/* max frame size, in samples */
7#define MPA_FRAME_SIZE 1152
de6d9b64
FB
8
9/* max compressed frame size */
2456e28d 10#define MPA_MAX_CODED_FRAME_SIZE 1792
de6d9b64 11
de6d9b64
FB
12#define MPA_MAX_CHANNELS 2
13
de6d9b64 14#define SBLIMIT 32 /* number of subbands */
de6d9b64 15
2456e28d
FB
16#define MPA_STEREO 0
17#define MPA_JSTEREO 1
18#define MPA_DUAL 2
19#define MPA_MONO 3
20
a7a85899
MN
21/* header + layer + bitrate + freq + lsf/mpeg25 */
22#define SAME_HEADER_MASK \
23 (0xffe00000 | (3 << 17) | (0xf << 12) | (3 << 10) | (3 << 19))
24
d9b1c197
RT
25/* define USE_HIGHPRECISION to have a bit exact (but slower) mpeg
26 audio decoder */
27
28#ifdef USE_HIGHPRECISION
29#define FRAC_BITS 23 /* fractional bits for sb_samples and dct */
30#define WFRAC_BITS 16 /* fractional bits for window */
31#else
32#define FRAC_BITS 15 /* fractional bits for sb_samples and dct */
33#define WFRAC_BITS 14 /* fractional bits for window */
34#endif
35
36#if defined(USE_HIGHPRECISION) && defined(CONFIG_AUDIO_NONSHORT)
37typedef int32_t OUT_INT;
38#define OUT_MAX INT32_MAX
39#define OUT_MIN INT32_MIN
40#define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 31)
41#else
42typedef int16_t OUT_INT;
43#define OUT_MAX INT16_MAX
44#define OUT_MIN INT16_MIN
45#define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15)
46#endif
47
48#if FRAC_BITS <= 15
49typedef int16_t MPA_INT;
50#else
51typedef int32_t MPA_INT;
52#endif
53
2456e28d 54int l2_select_table(int bitrate, int nb_channels, int freq, int lsf);
962d6ae6 55int mpa_decode_header(AVCodecContext *avctx, uint32_t head);
d9b1c197
RT
56void ff_mpa_synth_init(MPA_INT *window);
57void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
58 MPA_INT *window, int *dither_state,
59 OUT_INT *samples, int incr,
60 int32_t sb_samples[SBLIMIT]);
de6d9b64 61
0c1a9eda
ZK
62extern const uint16_t mpa_bitrate_tab[2][3][15];
63extern const uint16_t mpa_freq_tab[3];
2456e28d
FB
64extern const unsigned char *alloc_tables[5];
65extern const double enwindow[512];
66extern const int sblimit_table[5];
67extern const int quant_steps[17];
68extern const int quant_bits[17];
0c1a9eda 69extern const int32_t mpa_enwindow[257];
a7a85899
MN
70
71/* fast header check for resync */
72static inline int ff_mpa_check_header(uint32_t header){
73 /* header */
74 if ((header & 0xffe00000) != 0xffe00000)
75 return -1;
76 /* layer check */
77 if ((header & (3<<17)) == 0)
78 return -1;
79 /* bit rate */
80 if ((header & (0xf<<12)) == 0xf<<12)
81 return -1;
82 /* frequency */
83 if ((header & (3<<10)) == 3<<10)
84 return -1;
85 return 0;
86}