Mercurial > libavcodec.hg
annotate mpegaudiodec.c @ 2609:0f74a379a890 libavcodec
store the number of runs to avoid storing the last run value
about 10% lower bitrate for -qscale 32 (forman & some music video)
worst case bitrate increase <0.1% (lossless or low qscale)
and now the bad news, even though this just adds a single subtraction and an if() into the medium sized unpack_coeffs() loop and the if() will only be false once per unpac_coeff() call, gcc produces 50% slower code, i didnt look at the generated asm yet, not sure if i want to ...
author | michael |
---|---|
date | Fri, 15 Apr 2005 13:24:30 +0000 |
parents | b7511e7dabb7 |
children | ac78b35aa838 |
rev | line source |
---|---|
0 | 1 /* |
2 * MPEG Audio decoder | |
429 | 3 * Copyright (c) 2001, 2002 Fabrice Bellard. |
0 | 4 * |
429 | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Lesser General Public | |
7 * License as published by the Free Software Foundation; either | |
8 * version 2 of the License, or (at your option) any later version. | |
0 | 9 * |
429 | 10 * This library is distributed in the hope that it will be useful, |
0 | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
429 | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 * Lesser General Public License for more details. | |
0 | 14 * |
429 | 15 * You should have received a copy of the GNU Lesser General Public |
16 * License along with this library; if not, write to the Free Software | |
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
0 | 18 */ |
1106 | 19 |
20 /** | |
21 * @file mpegaudiodec.c | |
22 * MPEG Audio decoder. | |
23 */ | |
24 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
25 //#define DEBUG |
0 | 26 #include "avcodec.h" |
2398
582e635cfa08
common.c -> bitstream.c (and the single non bitstream func -> utils.c)
michael
parents:
2370
diff
changeset
|
27 #include "bitstream.h" |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
28 #include "mpegaudio.h" |
1734
8aace334bcf0
lrintf patch by ("Steven M. Schultz" <sms at 2BSD dot COM>)
michael
parents:
1733
diff
changeset
|
29 #include "dsputil.h" |
0 | 30 |
31 /* | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
32 * TODO: |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
33 * - in low precision mode, use more 16 bit multiplies in synth filter |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
34 * - test lsf / mpeg25 extensively. |
0 | 35 */ |
36 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
37 /* define USE_HIGHPRECISION to have a bit exact (but slower) mpeg |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
38 audio decoder */ |
449
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
39 #ifdef CONFIG_MPEGAUDIO_HP |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
40 #define USE_HIGHPRECISION |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
41 #endif |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
42 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
43 #ifdef USE_HIGHPRECISION |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
44 #define FRAC_BITS 23 /* fractional bits for sb_samples and dct */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
45 #define WFRAC_BITS 16 /* fractional bits for window */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
46 #else |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
47 #define FRAC_BITS 15 /* fractional bits for sb_samples and dct */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
48 #define WFRAC_BITS 14 /* fractional bits for window */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
49 #endif |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
50 |
2479 | 51 #if defined(USE_HIGHPRECISION) && defined(CONFIG_AUDIO_NONSHORT) |
52 typedef int32_t OUT_INT; | |
53 #define OUT_MAX INT32_MAX | |
54 #define OUT_MIN INT32_MIN | |
55 #define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 31) | |
56 #else | |
57 typedef int16_t OUT_INT; | |
58 #define OUT_MAX INT16_MAX | |
59 #define OUT_MIN INT16_MIN | |
60 #define OUT_SHIFT (WFRAC_BITS + FRAC_BITS - 15) | |
61 #endif | |
62 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
63 #define FRAC_ONE (1 << FRAC_BITS) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
64 |
1064 | 65 #define MULL(a,b) (((int64_t)(a) * (int64_t)(b)) >> FRAC_BITS) |
66 #define MUL64(a,b) ((int64_t)(a) * (int64_t)(b)) | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
67 #define FIX(a) ((int)((a) * FRAC_ONE)) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
68 /* WARNING: only correct for posititive numbers */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
69 #define FIXR(a) ((int)((a) * FRAC_ONE + 0.5)) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
70 #define FRAC_RND(a) (((a) + (FRAC_ONE/2)) >> FRAC_BITS) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
71 |
2489 | 72 #define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5)) |
73 //#define MULH(a,b) (((int64_t)(a) * (int64_t)(b))>>32) //gcc 3.4 creates an incredibly bloated mess out of this | |
74 static always_inline int MULH(int a, int b){ | |
75 return ((int64_t)(a) * (int64_t)(b))>>32; | |
76 } | |
77 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
78 #if FRAC_BITS <= 15 |
1064 | 79 typedef int16_t MPA_INT; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
80 #else |
1064 | 81 typedef int32_t MPA_INT; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
82 #endif |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
83 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
84 /****************/ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
85 |
0 | 86 #define HEADER_SIZE 4 |
87 #define BACKSTEP_SIZE 512 | |
88 | |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
89 struct GranuleDef; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
90 |
0 | 91 typedef struct MPADecodeContext { |
1064 | 92 uint8_t inbuf1[2][MPA_MAX_CODED_FRAME_SIZE + BACKSTEP_SIZE]; /* input buffer */ |
0 | 93 int inbuf_index; |
1064 | 94 uint8_t *inbuf_ptr, *inbuf; |
0 | 95 int frame_size; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
96 int free_format_frame_size; /* frame size in case of free format |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
97 (zero if currently unknown) */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
98 /* next header (used in free format parsing) */ |
1064 | 99 uint32_t free_format_next_header; |
0 | 100 int error_protection; |
101 int layer; | |
102 int sample_rate; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
103 int sample_rate_index; /* between 0 and 8 */ |
0 | 104 int bit_rate; |
105 int old_frame_size; | |
106 GetBitContext gb; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
107 int nb_channels; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
108 int mode; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
109 int mode_ext; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
110 int lsf; |
1142
592fb56e562f
merging a small amount of the changes from BroadQ, the rest is either not clean / doesnt apply / or is PS2 specific (someone with a PS2 should merge/send a patch for the later)
michaelni
parents:
1106
diff
changeset
|
111 MPA_INT synth_buf[MPA_MAX_CHANNELS][512 * 2] __attribute__((aligned(16))); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
112 int synth_buf_offset[MPA_MAX_CHANNELS]; |
1142
592fb56e562f
merging a small amount of the changes from BroadQ, the rest is either not clean / doesnt apply / or is PS2 specific (someone with a PS2 should merge/send a patch for the later)
michaelni
parents:
1106
diff
changeset
|
113 int32_t sb_samples[MPA_MAX_CHANNELS][36][SBLIMIT] __attribute__((aligned(16))); |
1064 | 114 int32_t mdct_buf[MPA_MAX_CHANNELS][SBLIMIT * 18]; /* previous samples, for layer 3 MDCT */ |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
115 #ifdef DEBUG |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
116 int frame_count; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
117 #endif |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
118 void (*compute_antialias)(struct MPADecodeContext *s, struct GranuleDef *g); |
2432 | 119 int adu_mode; ///< 0 for standard mp3, 1 for adu formatted mp3 |
2472 | 120 unsigned int dither_state; |
0 | 121 } MPADecodeContext; |
122 | |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
123 /** |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
124 * Context for MP3On4 decoder |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
125 */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
126 typedef struct MP3On4DecodeContext { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
127 int frames; ///< number of mp3 frames per block (number of mp3 decoder instances) |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
128 int chan_cfg; ///< channel config number |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
129 MPADecodeContext *mp3decctx[5]; ///< MPADecodeContext for every decoder instance |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
130 } MP3On4DecodeContext; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
131 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
132 /* layer 3 "granule" */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
133 typedef struct GranuleDef { |
1064 | 134 uint8_t scfsi; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
135 int part2_3_length; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
136 int big_values; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
137 int global_gain; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
138 int scalefac_compress; |
1064 | 139 uint8_t block_type; |
140 uint8_t switch_point; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
141 int table_select[3]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
142 int subblock_gain[3]; |
1064 | 143 uint8_t scalefac_scale; |
144 uint8_t count1table_select; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
145 int region_size[3]; /* number of huffman codes in each region */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
146 int preflag; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
147 int short_start, long_end; /* long/short band indexes */ |
1064 | 148 uint8_t scale_factors[40]; |
149 int32_t sb_hybrid[SBLIMIT * 18]; /* 576 samples */ | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
150 } GranuleDef; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
151 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
152 #define MODE_EXT_MS_STEREO 2 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
153 #define MODE_EXT_I_STEREO 1 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
154 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
155 /* layer 3 huffman tables */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
156 typedef struct HuffTable { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
157 int xsize; |
1064 | 158 const uint8_t *bits; |
159 const uint16_t *codes; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
160 } HuffTable; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
161 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
162 #include "mpegaudiodectab.h" |
0 | 163 |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
164 static void compute_antialias_integer(MPADecodeContext *s, GranuleDef *g); |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
165 static void compute_antialias_float(MPADecodeContext *s, GranuleDef *g); |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
166 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
167 /* vlc structure for decoding layer 3 huffman tables */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
168 static VLC huff_vlc[16]; |
1064 | 169 static uint8_t *huff_code_table[16]; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
170 static VLC huff_quad_vlc[2]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
171 /* computed from band_size_long */ |
1064 | 172 static uint16_t band_index_long[9][23]; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
173 /* XXX: free when all decoders are closed */ |
2490 | 174 #define TABLE_4_3_SIZE (8191 + 16)*4 |
1064 | 175 static int8_t *table_4_3_exp; |
176 static uint32_t *table_4_3_value; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
177 /* intensity stereo coef table */ |
1064 | 178 static int32_t is_table[2][16]; |
179 static int32_t is_table_lsf[2][2][16]; | |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
180 static int32_t csa_table[8][4]; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
181 static float csa_table_float[8][4]; |
1064 | 182 static int32_t mdct_win[8][36]; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
183 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
184 /* lower 2 bits: modulo 3, higher bits: shift */ |
1064 | 185 static uint16_t scale_factor_modshift[64]; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
186 /* [i][j]: 2^(-j/3) * FRAC_ONE * 2^(i+2) / (2^(i+2) - 1) */ |
1064 | 187 static int32_t scale_factor_mult[15][3]; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
188 /* mult table for layer 2 group quantization */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
189 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
190 #define SCALE_GEN(v) \ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
191 { FIXR(1.0 * (v)), FIXR(0.7937005259 * (v)), FIXR(0.6299605249 * (v)) } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
192 |
1064 | 193 static int32_t scale_factor_mult2[3][3] = { |
449
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
194 SCALE_GEN(4.0 / 3.0), /* 3 steps */ |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
195 SCALE_GEN(4.0 / 5.0), /* 5 steps */ |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
196 SCALE_GEN(4.0 / 9.0), /* 9 steps */ |
0 | 197 }; |
198 | |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
199 void ff_mpa_synth_init(MPA_INT *window); |
1142
592fb56e562f
merging a small amount of the changes from BroadQ, the rest is either not clean / doesnt apply / or is PS2 specific (someone with a PS2 should merge/send a patch for the later)
michaelni
parents:
1106
diff
changeset
|
200 static MPA_INT window[512] __attribute__((aligned(16))); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
201 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
202 /* layer 1 unscaling */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
203 /* n = number of bits of the mantissa minus 1 */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
204 static inline int l1_unscale(int n, int mant, int scale_factor) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
205 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
206 int shift, mod; |
1064 | 207 int64_t val; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
208 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
209 shift = scale_factor_modshift[scale_factor]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
210 mod = shift & 3; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
211 shift >>= 2; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
212 val = MUL64(mant + (-1 << n) + 1, scale_factor_mult[n-1][mod]); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
213 shift += n; |
449
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
214 /* NOTE: at this point, 1 <= shift >= 21 + 15 */ |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
215 return (int)((val + (1LL << (shift - 1))) >> shift); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
216 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
217 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
218 static inline int l2_unscale_group(int steps, int mant, int scale_factor) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
219 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
220 int shift, mod, val; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
221 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
222 shift = scale_factor_modshift[scale_factor]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
223 mod = shift & 3; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
224 shift >>= 2; |
449
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
225 |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
226 val = (mant - (steps >> 1)) * scale_factor_mult2[steps >> 2][mod]; |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
227 /* NOTE: at this point, 0 <= shift <= 21 */ |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
228 if (shift > 0) |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
229 val = (val + (1 << (shift - 1))) >> shift; |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
230 return val; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
231 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
232 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
233 /* compute value^(4/3) * 2^(exponent/4). It normalized to FRAC_BITS */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
234 static inline int l3_unscale(int value, int exponent) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
235 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
236 unsigned int m; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
237 int e; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
238 |
2490 | 239 e = table_4_3_exp [4*value + (exponent&3)]; |
240 m = table_4_3_value[4*value + (exponent&3)]; | |
241 e -= (exponent >> 2); | |
242 assert(e>=1); | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
243 if (e > 31) |
2478 | 244 return 0; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
245 m = (m + (1 << (e-1))) >> e; |
2490 | 246 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
247 return m; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
248 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
249 |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
250 /* all integer n^(4/3) computation code */ |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
251 #define DEV_ORDER 13 |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
252 |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
253 #define POW_FRAC_BITS 24 |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
254 #define POW_FRAC_ONE (1 << POW_FRAC_BITS) |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
255 #define POW_FIX(a) ((int)((a) * POW_FRAC_ONE)) |
1064 | 256 #define POW_MULL(a,b) (((int64_t)(a) * (int64_t)(b)) >> POW_FRAC_BITS) |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
257 |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
258 static int dev_4_3_coefs[DEV_ORDER]; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
259 |
2522
e25782262d7d
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
2507
diff
changeset
|
260 #if 0 /* unused */ |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
261 static int pow_mult3[3] = { |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
262 POW_FIX(1.0), |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
263 POW_FIX(1.25992104989487316476), |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
264 POW_FIX(1.58740105196819947474), |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
265 }; |
2522
e25782262d7d
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
2507
diff
changeset
|
266 #endif |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
267 |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
268 static void int_pow_init(void) |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
269 { |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
270 int i, a; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
271 |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
272 a = POW_FIX(1.0); |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
273 for(i=0;i<DEV_ORDER;i++) { |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
274 a = POW_MULL(a, POW_FIX(4.0 / 3.0) - i * POW_FIX(1.0)) / (i + 1); |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
275 dev_4_3_coefs[i] = a; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
276 } |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
277 } |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
278 |
2522
e25782262d7d
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
2507
diff
changeset
|
279 #if 0 /* unused, remove? */ |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
280 /* return the mantissa and the binary exponent */ |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
281 static int int_pow(int i, int *exp_ptr) |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
282 { |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
283 int e, er, eq, j; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
284 int a, a1; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
285 |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
286 /* renormalize */ |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
287 a = i; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
288 e = POW_FRAC_BITS; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
289 while (a < (1 << (POW_FRAC_BITS - 1))) { |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
290 a = a << 1; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
291 e--; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
292 } |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
293 a -= (1 << POW_FRAC_BITS); |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
294 a1 = 0; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
295 for(j = DEV_ORDER - 1; j >= 0; j--) |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
296 a1 = POW_MULL(a, dev_4_3_coefs[j] + a1); |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
297 a = (1 << POW_FRAC_BITS) + a1; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
298 /* exponent compute (exact) */ |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
299 e = e * 4; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
300 er = e % 3; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
301 eq = e / 3; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
302 a = POW_MULL(a, pow_mult3[er]); |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
303 while (a >= 2 * POW_FRAC_ONE) { |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
304 a = a >> 1; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
305 eq++; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
306 } |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
307 /* convert to float */ |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
308 while (a < POW_FRAC_ONE) { |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
309 a = a << 1; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
310 eq--; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
311 } |
407
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
312 /* now POW_FRAC_ONE <= a < 2 * POW_FRAC_ONE */ |
449
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
313 #if POW_FRAC_BITS > FRAC_BITS |
407
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
314 a = (a + (1 << (POW_FRAC_BITS - FRAC_BITS - 1))) >> (POW_FRAC_BITS - FRAC_BITS); |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
315 /* correct overflow */ |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
316 if (a >= 2 * (1 << FRAC_BITS)) { |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
317 a = a >> 1; |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
318 eq++; |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
319 } |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
320 #endif |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
321 *exp_ptr = eq; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
322 return a; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
323 } |
2522
e25782262d7d
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
2507
diff
changeset
|
324 #endif |
0 | 325 |
326 static int decode_init(AVCodecContext * avctx) | |
327 { | |
328 MPADecodeContext *s = avctx->priv_data; | |
836
932eb34d17c1
vc++ sucks, found by ("csharprules" <csharprules at hotmail dot com>)
michaelni
parents:
602
diff
changeset
|
329 static int init=0; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
330 int i, j, k; |
0 | 331 |
2479 | 332 #if defined(USE_HIGHPRECISION) && defined(CONFIG_AUDIO_NONSHORT) |
333 avctx->sample_fmt= SAMPLE_FMT_S32; | |
334 #else | |
335 avctx->sample_fmt= SAMPLE_FMT_S16; | |
336 #endif | |
337 | |
2491 | 338 if(avctx->antialias_algo != FF_AA_FLOAT) |
1762 | 339 s->compute_antialias= compute_antialias_integer; |
340 else | |
341 s->compute_antialias= compute_antialias_float; | |
342 | |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
343 if (!init && !avctx->parse_only) { |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
344 /* scale factors table for layer 1/2 */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
345 for(i=0;i<64;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
346 int shift, mod; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
347 /* 1.0 (i = 3) is normalized to 2 ^ FRAC_BITS */ |
449
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
348 shift = (i / 3); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
349 mod = i % 3; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
350 scale_factor_modshift[i] = mod | (shift << 2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
351 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
352 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
353 /* scale factor multiply for layer 1 */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
354 for(i=0;i<15;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
355 int n, norm; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
356 n = i + 2; |
1064 | 357 norm = ((int64_t_C(1) << n) * FRAC_ONE) / ((1 << n) - 1); |
449
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
358 scale_factor_mult[i][0] = MULL(FIXR(1.0 * 2.0), norm); |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
359 scale_factor_mult[i][1] = MULL(FIXR(0.7937005259 * 2.0), norm); |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
360 scale_factor_mult[i][2] = MULL(FIXR(0.6299605249 * 2.0), norm); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
361 dprintf("%d: norm=%x s=%x %x %x\n", |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
362 i, norm, |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
363 scale_factor_mult[i][0], |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
364 scale_factor_mult[i][1], |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
365 scale_factor_mult[i][2]); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
366 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
367 |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
368 ff_mpa_synth_init(window); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
369 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
370 /* huffman decode tables */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
371 huff_code_table[0] = NULL; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
372 for(i=1;i<16;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
373 const HuffTable *h = &mpa_huff_tables[i]; |
1057 | 374 int xsize, x, y; |
375 unsigned int n; | |
1064 | 376 uint8_t *code_table; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
377 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
378 xsize = h->xsize; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
379 n = xsize * xsize; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
380 /* XXX: fail test */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
381 init_vlc(&huff_vlc[i], 8, n, |
2370
26560d4fdb1f
Memory leak fix patch by (Burkhard Plaum <plaum >at< ipf.uni-stuttgart )dot( de>)
michael
parents:
2100
diff
changeset
|
382 h->bits, 1, 1, h->codes, 2, 2, 1); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
383 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
384 code_table = av_mallocz(n); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
385 j = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
386 for(x=0;x<xsize;x++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
387 for(y=0;y<xsize;y++) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
388 code_table[j++] = (x << 4) | y; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
389 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
390 huff_code_table[i] = code_table; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
391 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
392 for(i=0;i<2;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
393 init_vlc(&huff_quad_vlc[i], i == 0 ? 7 : 4, 16, |
2370
26560d4fdb1f
Memory leak fix patch by (Burkhard Plaum <plaum >at< ipf.uni-stuttgart )dot( de>)
michael
parents:
2100
diff
changeset
|
394 mpa_quad_bits[i], 1, 1, mpa_quad_codes[i], 1, 1, 1); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
395 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
396 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
397 for(i=0;i<9;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
398 k = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
399 for(j=0;j<22;j++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
400 band_index_long[i][j] = k; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
401 k += band_size_long[i][j]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
402 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
403 band_index_long[i][22] = k; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
404 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
405 |
902
6acc8394960d
* two functions to handle allocation of static data more simple
kabi
parents:
836
diff
changeset
|
406 /* compute n ^ (4/3) and store it in mantissa/exp format */ |
1900
5cde80c5d929
static allocation rewrite (old code was plain a broken mess)
michael
parents:
1780
diff
changeset
|
407 table_4_3_exp= av_mallocz_static(TABLE_4_3_SIZE * sizeof(table_4_3_exp[0])); |
5cde80c5d929
static allocation rewrite (old code was plain a broken mess)
michael
parents:
1780
diff
changeset
|
408 if(!table_4_3_exp) |
902
6acc8394960d
* two functions to handle allocation of static data more simple
kabi
parents:
836
diff
changeset
|
409 return -1; |
1900
5cde80c5d929
static allocation rewrite (old code was plain a broken mess)
michael
parents:
1780
diff
changeset
|
410 table_4_3_value= av_mallocz_static(TABLE_4_3_SIZE * sizeof(table_4_3_value[0])); |
5cde80c5d929
static allocation rewrite (old code was plain a broken mess)
michael
parents:
1780
diff
changeset
|
411 if(!table_4_3_value) |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
412 return -1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
413 |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
414 int_pow_init(); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
415 for(i=1;i<TABLE_4_3_SIZE;i++) { |
2490 | 416 double f, fm; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
417 int e, m; |
2490 | 418 f = pow((double)(i/4), 4.0 / 3.0) * pow(2, (i&3)*0.25); |
419 fm = frexp(f, &e); | |
2532
b7511e7dabb7
cast to uint32 as the table is uint32_t, this also worksaround a gcc or libc bug related to frexp()
michael
parents:
2522
diff
changeset
|
420 m = (uint32_t)(fm*(1LL<<31) + 0.5); |
2496
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
421 e+= FRAC_BITS - 31 + 5; |
2490 | 422 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
423 /* normalized to FRAC_BITS */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
424 table_4_3_value[i] = m; |
2490 | 425 // av_log(NULL, AV_LOG_DEBUG, "%d %d %f\n", i, m, pow((double)i, 4.0 / 3.0)); |
426 table_4_3_exp[i] = -e; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
427 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
428 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
429 for(i=0;i<7;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
430 float f; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
431 int v; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
432 if (i != 6) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
433 f = tan((double)i * M_PI / 12.0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
434 v = FIXR(f / (1.0 + f)); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
435 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
436 v = FIXR(1.0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
437 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
438 is_table[0][i] = v; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
439 is_table[1][6 - i] = v; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
440 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
441 /* invalid values */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
442 for(i=7;i<16;i++) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
443 is_table[0][i] = is_table[1][i] = 0.0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
444 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
445 for(i=0;i<16;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
446 double f; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
447 int e, k; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
448 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
449 for(j=0;j<2;j++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
450 e = -(j + 1) * ((i + 1) >> 1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
451 f = pow(2.0, e / 4.0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
452 k = i & 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
453 is_table_lsf[j][k ^ 1][i] = FIXR(f); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
454 is_table_lsf[j][k][i] = FIXR(1.0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
455 dprintf("is_table_lsf %d %d: %x %x\n", |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
456 i, j, is_table_lsf[j][0][i], is_table_lsf[j][1][i]); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
457 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
458 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
459 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
460 for(i=0;i<8;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
461 float ci, cs, ca; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
462 ci = ci_table[i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
463 cs = 1.0 / sqrt(1.0 + ci * ci); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
464 ca = cs * ci; |
2491 | 465 csa_table[i][0] = FIXHR(cs/4); |
466 csa_table[i][1] = FIXHR(ca/4); | |
467 csa_table[i][2] = FIXHR(ca/4) + FIXHR(cs/4); | |
468 csa_table[i][3] = FIXHR(ca/4) - FIXHR(cs/4); | |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
469 csa_table_float[i][0] = cs; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
470 csa_table_float[i][1] = ca; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
471 csa_table_float[i][2] = ca + cs; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
472 csa_table_float[i][3] = ca - cs; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
473 // printf("%d %d %d %d\n", FIX(cs), FIX(cs-1), FIX(ca), FIX(cs)-FIX(ca)); |
2489 | 474 // av_log(NULL, AV_LOG_DEBUG,"%f %f %f %f\n", cs, ca, ca+cs, ca-cs); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
475 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
476 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
477 /* compute mdct windows */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
478 for(i=0;i<36;i++) { |
2489 | 479 for(j=0; j<4; j++){ |
480 double d; | |
2495 | 481 |
482 if(j==2 && i%3 != 1) | |
483 continue; | |
2489 | 484 |
485 d= sin(M_PI * (i + 0.5) / 36.0); | |
486 if(j==1){ | |
487 if (i>=30) d= 0; | |
488 else if(i>=24) d= sin(M_PI * (i - 18 + 0.5) / 12.0); | |
489 else if(i>=18) d= 1; | |
490 }else if(j==3){ | |
491 if (i< 6) d= 0; | |
492 else if(i< 12) d= sin(M_PI * (i - 6 + 0.5) / 12.0); | |
493 else if(i< 18) d= 1; | |
494 } | |
495 //merge last stage of imdct into the window coefficients | |
2495 | 496 d*= 0.5 / cos(M_PI*(2*i + 19)/72); |
497 | |
498 if(j==2) | |
499 mdct_win[j][i/3] = FIXHR((d / (1<<5))); | |
500 else | |
501 mdct_win[j][i ] = FIXHR((d / (1<<5))); | |
2489 | 502 // av_log(NULL, AV_LOG_DEBUG, "%2d %d %f\n", i,j,d / (1<<5)); |
503 } | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
504 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
505 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
506 /* NOTE: we do frequency inversion adter the MDCT by changing |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
507 the sign of the right window coefs */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
508 for(j=0;j<4;j++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
509 for(i=0;i<36;i+=2) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
510 mdct_win[j + 4][i] = mdct_win[j][i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
511 mdct_win[j + 4][i + 1] = -mdct_win[j][i + 1]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
512 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
513 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
514 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
515 #if defined(DEBUG) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
516 for(j=0;j<8;j++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
517 printf("win%d=\n", j); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
518 for(i=0;i<36;i++) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
519 printf("%f, ", (double)mdct_win[j][i] / FRAC_ONE); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
520 printf("\n"); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
521 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
522 #endif |
0 | 523 init = 1; |
524 } | |
525 | |
526 s->inbuf_index = 0; | |
527 s->inbuf = &s->inbuf1[s->inbuf_index][BACKSTEP_SIZE]; | |
528 s->inbuf_ptr = s->inbuf; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
529 #ifdef DEBUG |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
530 s->frame_count = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
531 #endif |
2432 | 532 if (avctx->codec_id == CODEC_ID_MP3ADU) |
533 s->adu_mode = 1; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
534 return 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
535 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
536 |
1014
48349e11c9b2
C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M«©ns Rullg«©rd))
michaelni
parents:
902
diff
changeset
|
537 /* tab[i][j] = 1.0 / (2.0 * cos(pi*(2*k+1) / 2^(6 - j))) */ |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
538 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
539 /* cos(i*pi/64) */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
540 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
541 #define COS0_0 FIXR(0.50060299823519630134) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
542 #define COS0_1 FIXR(0.50547095989754365998) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
543 #define COS0_2 FIXR(0.51544730992262454697) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
544 #define COS0_3 FIXR(0.53104259108978417447) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
545 #define COS0_4 FIXR(0.55310389603444452782) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
546 #define COS0_5 FIXR(0.58293496820613387367) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
547 #define COS0_6 FIXR(0.62250412303566481615) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
548 #define COS0_7 FIXR(0.67480834145500574602) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
549 #define COS0_8 FIXR(0.74453627100229844977) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
550 #define COS0_9 FIXR(0.83934964541552703873) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
551 #define COS0_10 FIXR(0.97256823786196069369) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
552 #define COS0_11 FIXR(1.16943993343288495515) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
553 #define COS0_12 FIXR(1.48416461631416627724) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
554 #define COS0_13 FIXR(2.05778100995341155085) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
555 #define COS0_14 FIXR(3.40760841846871878570) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
556 #define COS0_15 FIXR(10.19000812354805681150) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
557 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
558 #define COS1_0 FIXR(0.50241928618815570551) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
559 #define COS1_1 FIXR(0.52249861493968888062) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
560 #define COS1_2 FIXR(0.56694403481635770368) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
561 #define COS1_3 FIXR(0.64682178335999012954) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
562 #define COS1_4 FIXR(0.78815462345125022473) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
563 #define COS1_5 FIXR(1.06067768599034747134) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
564 #define COS1_6 FIXR(1.72244709823833392782) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
565 #define COS1_7 FIXR(5.10114861868916385802) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
566 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
567 #define COS2_0 FIXR(0.50979557910415916894) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
568 #define COS2_1 FIXR(0.60134488693504528054) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
569 #define COS2_2 FIXR(0.89997622313641570463) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
570 #define COS2_3 FIXR(2.56291544774150617881) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
571 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
572 #define COS3_0 FIXR(0.54119610014619698439) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
573 #define COS3_1 FIXR(1.30656296487637652785) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
574 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
575 #define COS4_0 FIXR(0.70710678118654752439) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
576 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
577 /* butterfly operator */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
578 #define BF(a, b, c)\ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
579 {\ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
580 tmp0 = tab[a] + tab[b];\ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
581 tmp1 = tab[a] - tab[b];\ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
582 tab[a] = tmp0;\ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
583 tab[b] = MULL(tmp1, c);\ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
584 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
585 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
586 #define BF1(a, b, c, d)\ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
587 {\ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
588 BF(a, b, COS4_0);\ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
589 BF(c, d, -COS4_0);\ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
590 tab[c] += tab[d];\ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
591 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
592 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
593 #define BF2(a, b, c, d)\ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
594 {\ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
595 BF(a, b, COS4_0);\ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
596 BF(c, d, -COS4_0);\ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
597 tab[c] += tab[d];\ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
598 tab[a] += tab[c];\ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
599 tab[c] += tab[b];\ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
600 tab[b] += tab[d];\ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
601 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
602 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
603 #define ADD(a, b) tab[a] += tab[b] |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
604 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
605 /* DCT32 without 1/sqrt(2) coef zero scaling. */ |
1064 | 606 static void dct32(int32_t *out, int32_t *tab) |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
607 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
608 int tmp0, tmp1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
609 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
610 /* pass 1 */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
611 BF(0, 31, COS0_0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
612 BF(1, 30, COS0_1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
613 BF(2, 29, COS0_2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
614 BF(3, 28, COS0_3); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
615 BF(4, 27, COS0_4); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
616 BF(5, 26, COS0_5); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
617 BF(6, 25, COS0_6); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
618 BF(7, 24, COS0_7); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
619 BF(8, 23, COS0_8); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
620 BF(9, 22, COS0_9); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
621 BF(10, 21, COS0_10); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
622 BF(11, 20, COS0_11); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
623 BF(12, 19, COS0_12); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
624 BF(13, 18, COS0_13); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
625 BF(14, 17, COS0_14); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
626 BF(15, 16, COS0_15); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
627 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
628 /* pass 2 */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
629 BF(0, 15, COS1_0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
630 BF(1, 14, COS1_1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
631 BF(2, 13, COS1_2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
632 BF(3, 12, COS1_3); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
633 BF(4, 11, COS1_4); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
634 BF(5, 10, COS1_5); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
635 BF(6, 9, COS1_6); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
636 BF(7, 8, COS1_7); |
0 | 637 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
638 BF(16, 31, -COS1_0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
639 BF(17, 30, -COS1_1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
640 BF(18, 29, -COS1_2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
641 BF(19, 28, -COS1_3); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
642 BF(20, 27, -COS1_4); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
643 BF(21, 26, -COS1_5); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
644 BF(22, 25, -COS1_6); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
645 BF(23, 24, -COS1_7); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
646 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
647 /* pass 3 */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
648 BF(0, 7, COS2_0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
649 BF(1, 6, COS2_1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
650 BF(2, 5, COS2_2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
651 BF(3, 4, COS2_3); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
652 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
653 BF(8, 15, -COS2_0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
654 BF(9, 14, -COS2_1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
655 BF(10, 13, -COS2_2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
656 BF(11, 12, -COS2_3); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
657 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
658 BF(16, 23, COS2_0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
659 BF(17, 22, COS2_1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
660 BF(18, 21, COS2_2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
661 BF(19, 20, COS2_3); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
662 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
663 BF(24, 31, -COS2_0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
664 BF(25, 30, -COS2_1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
665 BF(26, 29, -COS2_2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
666 BF(27, 28, -COS2_3); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
667 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
668 /* pass 4 */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
669 BF(0, 3, COS3_0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
670 BF(1, 2, COS3_1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
671 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
672 BF(4, 7, -COS3_0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
673 BF(5, 6, -COS3_1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
674 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
675 BF(8, 11, COS3_0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
676 BF(9, 10, COS3_1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
677 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
678 BF(12, 15, -COS3_0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
679 BF(13, 14, -COS3_1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
680 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
681 BF(16, 19, COS3_0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
682 BF(17, 18, COS3_1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
683 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
684 BF(20, 23, -COS3_0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
685 BF(21, 22, -COS3_1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
686 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
687 BF(24, 27, COS3_0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
688 BF(25, 26, COS3_1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
689 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
690 BF(28, 31, -COS3_0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
691 BF(29, 30, -COS3_1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
692 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
693 /* pass 5 */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
694 BF1(0, 1, 2, 3); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
695 BF2(4, 5, 6, 7); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
696 BF1(8, 9, 10, 11); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
697 BF2(12, 13, 14, 15); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
698 BF1(16, 17, 18, 19); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
699 BF2(20, 21, 22, 23); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
700 BF1(24, 25, 26, 27); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
701 BF2(28, 29, 30, 31); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
702 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
703 /* pass 6 */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
704 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
705 ADD( 8, 12); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
706 ADD(12, 10); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
707 ADD(10, 14); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
708 ADD(14, 9); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
709 ADD( 9, 13); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
710 ADD(13, 11); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
711 ADD(11, 15); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
712 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
713 out[ 0] = tab[0]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
714 out[16] = tab[1]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
715 out[ 8] = tab[2]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
716 out[24] = tab[3]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
717 out[ 4] = tab[4]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
718 out[20] = tab[5]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
719 out[12] = tab[6]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
720 out[28] = tab[7]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
721 out[ 2] = tab[8]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
722 out[18] = tab[9]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
723 out[10] = tab[10]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
724 out[26] = tab[11]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
725 out[ 6] = tab[12]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
726 out[22] = tab[13]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
727 out[14] = tab[14]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
728 out[30] = tab[15]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
729 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
730 ADD(24, 28); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
731 ADD(28, 26); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
732 ADD(26, 30); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
733 ADD(30, 25); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
734 ADD(25, 29); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
735 ADD(29, 27); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
736 ADD(27, 31); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
737 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
738 out[ 1] = tab[16] + tab[24]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
739 out[17] = tab[17] + tab[25]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
740 out[ 9] = tab[18] + tab[26]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
741 out[25] = tab[19] + tab[27]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
742 out[ 5] = tab[20] + tab[28]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
743 out[21] = tab[21] + tab[29]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
744 out[13] = tab[22] + tab[30]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
745 out[29] = tab[23] + tab[31]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
746 out[ 3] = tab[24] + tab[20]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
747 out[19] = tab[25] + tab[21]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
748 out[11] = tab[26] + tab[22]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
749 out[27] = tab[27] + tab[23]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
750 out[ 7] = tab[28] + tab[18]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
751 out[23] = tab[29] + tab[19]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
752 out[15] = tab[30] + tab[17]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
753 out[31] = tab[31]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
754 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
755 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
756 #if FRAC_BITS <= 15 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
757 |
2472 | 758 static inline int round_sample(int *sum) |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
759 { |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
760 int sum1; |
2472 | 761 sum1 = (*sum) >> OUT_SHIFT; |
762 *sum &= (1<<OUT_SHIFT)-1; | |
2479 | 763 if (sum1 < OUT_MIN) |
764 sum1 = OUT_MIN; | |
765 else if (sum1 > OUT_MAX) | |
766 sum1 = OUT_MAX; | |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
767 return sum1; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
768 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
769 |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
770 #if defined(ARCH_POWERPC_405) |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
771 |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
772 /* signed 16x16 -> 32 multiply add accumulate */ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
773 #define MACS(rt, ra, rb) \ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
774 asm ("maclhw %0, %2, %3" : "=r" (rt) : "0" (rt), "r" (ra), "r" (rb)); |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
775 |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
776 /* signed 16x16 -> 32 multiply */ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
777 #define MULS(ra, rb) \ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
778 ({ int __rt; asm ("mullhw %0, %1, %2" : "=r" (__rt) : "r" (ra), "r" (rb)); __rt; }) |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
779 |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
780 #else |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
781 |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
782 /* signed 16x16 -> 32 multiply add accumulate */ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
783 #define MACS(rt, ra, rb) rt += (ra) * (rb) |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
784 |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
785 /* signed 16x16 -> 32 multiply */ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
786 #define MULS(ra, rb) ((ra) * (rb)) |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
787 |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
788 #endif |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
789 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
790 #else |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
791 |
2472 | 792 static inline int round_sample(int64_t *sum) |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
793 { |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
794 int sum1; |
2472 | 795 sum1 = (int)((*sum) >> OUT_SHIFT); |
796 *sum &= (1<<OUT_SHIFT)-1; | |
2479 | 797 if (sum1 < OUT_MIN) |
798 sum1 = OUT_MIN; | |
799 else if (sum1 > OUT_MAX) | |
800 sum1 = OUT_MAX; | |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
801 return sum1; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
802 } |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
803 |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
804 #define MULS(ra, rb) MUL64(ra, rb) |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
805 |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
806 #endif |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
807 |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
808 #define SUM8(sum, op, w, p) \ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
809 { \ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
810 sum op MULS((w)[0 * 64], p[0 * 64]);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
811 sum op MULS((w)[1 * 64], p[1 * 64]);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
812 sum op MULS((w)[2 * 64], p[2 * 64]);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
813 sum op MULS((w)[3 * 64], p[3 * 64]);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
814 sum op MULS((w)[4 * 64], p[4 * 64]);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
815 sum op MULS((w)[5 * 64], p[5 * 64]);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
816 sum op MULS((w)[6 * 64], p[6 * 64]);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
817 sum op MULS((w)[7 * 64], p[7 * 64]);\ |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
818 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
819 |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
820 #define SUM8P2(sum1, op1, sum2, op2, w1, w2, p) \ |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
821 { \ |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
822 int tmp;\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
823 tmp = p[0 * 64];\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
824 sum1 op1 MULS((w1)[0 * 64], tmp);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
825 sum2 op2 MULS((w2)[0 * 64], tmp);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
826 tmp = p[1 * 64];\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
827 sum1 op1 MULS((w1)[1 * 64], tmp);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
828 sum2 op2 MULS((w2)[1 * 64], tmp);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
829 tmp = p[2 * 64];\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
830 sum1 op1 MULS((w1)[2 * 64], tmp);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
831 sum2 op2 MULS((w2)[2 * 64], tmp);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
832 tmp = p[3 * 64];\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
833 sum1 op1 MULS((w1)[3 * 64], tmp);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
834 sum2 op2 MULS((w2)[3 * 64], tmp);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
835 tmp = p[4 * 64];\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
836 sum1 op1 MULS((w1)[4 * 64], tmp);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
837 sum2 op2 MULS((w2)[4 * 64], tmp);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
838 tmp = p[5 * 64];\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
839 sum1 op1 MULS((w1)[5 * 64], tmp);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
840 sum2 op2 MULS((w2)[5 * 64], tmp);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
841 tmp = p[6 * 64];\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
842 sum1 op1 MULS((w1)[6 * 64], tmp);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
843 sum2 op2 MULS((w2)[6 * 64], tmp);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
844 tmp = p[7 * 64];\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
845 sum1 op1 MULS((w1)[7 * 64], tmp);\ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
846 sum2 op2 MULS((w2)[7 * 64], tmp);\ |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
847 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
848 |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
849 void ff_mpa_synth_init(MPA_INT *window) |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
850 { |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
851 int i; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
852 |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
853 /* max = 18760, max sum over all 16 coefs : 44736 */ |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
854 for(i=0;i<257;i++) { |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
855 int v; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
856 v = mpa_enwindow[i]; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
857 #if WFRAC_BITS < 16 |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
858 v = (v + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS); |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
859 #endif |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
860 window[i] = v; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
861 if ((i & 63) != 0) |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
862 v = -v; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
863 if (i != 0) |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
864 window[512 - i] = v; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
865 } |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
866 } |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
867 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
868 /* 32 sub band synthesis filter. Input: 32 sub band samples, Output: |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
869 32 samples. */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
870 /* XXX: optimize by avoiding ring buffer usage */ |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
871 void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset, |
2473 | 872 MPA_INT *window, int *dither_state, |
2479 | 873 OUT_INT *samples, int incr, |
1064 | 874 int32_t sb_samples[SBLIMIT]) |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
875 { |
1064 | 876 int32_t tmp[32]; |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
877 register MPA_INT *synth_buf; |
2100 | 878 register const MPA_INT *w, *w2, *p; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
879 int j, offset, v; |
2479 | 880 OUT_INT *samples2; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
881 #if FRAC_BITS <= 15 |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
882 int sum, sum2; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
883 #else |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
884 int64_t sum, sum2; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
885 #endif |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
886 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
887 dct32(tmp, sb_samples); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
888 |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
889 offset = *synth_buf_offset; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
890 synth_buf = synth_buf_ptr + offset; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
891 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
892 for(j=0;j<32;j++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
893 v = tmp[j]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
894 #if FRAC_BITS <= 15 |
449
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
895 /* NOTE: can cause a loss in precision if very high amplitude |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
896 sound */ |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
897 if (v > 32767) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
898 v = 32767; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
899 else if (v < -32768) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
900 v = -32768; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
901 #endif |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
902 synth_buf[j] = v; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
903 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
904 /* copy to avoid wrap */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
905 memcpy(synth_buf + 512, synth_buf, 32 * sizeof(MPA_INT)); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
906 |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
907 samples2 = samples + 31 * incr; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
908 w = window; |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
909 w2 = window + 31; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
910 |
2473 | 911 sum = *dither_state; |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
912 p = synth_buf + 16; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
913 SUM8(sum, +=, w, p); |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
914 p = synth_buf + 48; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
915 SUM8(sum, -=, w + 32, p); |
2472 | 916 *samples = round_sample(&sum); |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
917 samples += incr; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
918 w++; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
919 |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
920 /* we calculate two samples at the same time to avoid one memory |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
921 access per two sample */ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
922 for(j=1;j<16;j++) { |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
923 sum2 = 0; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
924 p = synth_buf + 16 + j; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
925 SUM8P2(sum, +=, sum2, -=, w, w2, p); |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
926 p = synth_buf + 48 - j; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
927 SUM8P2(sum, -=, sum2, -=, w + 32, w2 + 32, p); |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
928 |
2472 | 929 *samples = round_sample(&sum); |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
930 samples += incr; |
2472 | 931 sum += sum2; |
932 *samples2 = round_sample(&sum); | |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
933 samples2 -= incr; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
934 w++; |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
935 w2--; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
936 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
937 |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
938 p = synth_buf + 32; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
939 SUM8(sum, -=, w + 32, p); |
2472 | 940 *samples = round_sample(&sum); |
2473 | 941 *dither_state= sum; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
942 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
943 offset = (offset - 32) & 511; |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
944 *synth_buf_offset = offset; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
945 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
946 |
2495 | 947 #define C3 FIXHR(0.86602540378443864676/2) |
948 | |
949 /* 0.5 / cos(pi*(2*i+1)/36) */ | |
950 static const int icos36[9] = { | |
951 FIXR(0.50190991877167369479), | |
952 FIXR(0.51763809020504152469), //0 | |
953 FIXR(0.55168895948124587824), | |
954 FIXR(0.61038729438072803416), | |
955 FIXR(0.70710678118654752439), //1 | |
956 FIXR(0.87172339781054900991), | |
957 FIXR(1.18310079157624925896), | |
958 FIXR(1.93185165257813657349), //2 | |
959 FIXR(5.73685662283492756461), | |
960 }; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
961 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
962 /* 12 points IMDCT. We compute it "by hand" by factorizing obvious |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
963 cases. */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
964 static void imdct12(int *out, int *in) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
965 { |
2495 | 966 int in0, in1, in2, in3, in4, in5, t1, t2; |
2496
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
967 |
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
968 in0= in[0*3]; |
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
969 in1= in[1*3] + in[0*3]; |
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
970 in2= in[2*3] + in[1*3]; |
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
971 in3= in[3*3] + in[2*3]; |
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
972 in4= in[4*3] + in[3*3]; |
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
973 in5= in[5*3] + in[4*3]; |
2495 | 974 in5 += in3; |
975 in3 += in1; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
976 |
2495 | 977 in2= MULH(2*in2, C3); |
978 in3= MULH(2*in3, C3); | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
979 |
2495 | 980 t1 = in0 - in4; |
981 t2 = MULL(in1 - in5, icos36[4]); | |
982 | |
983 out[ 7]= | |
984 out[10]= t1 + t2; | |
985 out[ 1]= | |
986 out[ 4]= t1 - t2; | |
987 | |
988 in0 += in4>>1; | |
989 in4 = in0 + in2; | |
990 in1 += in5>>1; | |
991 in5 = MULL(in1 + in3, icos36[1]); | |
992 out[ 8]= | |
993 out[ 9]= in4 + in5; | |
994 out[ 2]= | |
995 out[ 3]= in4 - in5; | |
996 | |
997 in0 -= in2; | |
998 in1 = MULL(in1 - in3, icos36[7]); | |
999 out[ 0]= | |
1000 out[ 5]= in0 - in1; | |
1001 out[ 6]= | |
1002 out[11]= in0 + in1; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1003 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1004 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1005 /* cos(pi*i/18) */ |
2489 | 1006 #define C1 FIXHR(0.98480775301220805936/2) |
1007 #define C2 FIXHR(0.93969262078590838405/2) | |
1008 #define C3 FIXHR(0.86602540378443864676/2) | |
1009 #define C4 FIXHR(0.76604444311897803520/2) | |
1010 #define C5 FIXHR(0.64278760968653932632/2) | |
1011 #define C6 FIXHR(0.5/2) | |
1012 #define C7 FIXHR(0.34202014332566873304/2) | |
1013 #define C8 FIXHR(0.17364817766693034885/2) | |
1014 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1015 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1016 /* using Lee like decomposition followed by hand coded 9 points DCT */ |
2489 | 1017 static void imdct36(int *out, int *buf, int *in, int *win) |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1018 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1019 int i, j, t0, t1, t2, t3, s0, s1, s2, s3; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1020 int tmp[18], *tmp1, *in1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1021 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1022 for(i=17;i>=1;i--) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1023 in[i] += in[i-1]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1024 for(i=17;i>=3;i-=2) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1025 in[i] += in[i-2]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1026 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1027 for(j=0;j<2;j++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1028 tmp1 = tmp + j; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1029 in1 = in + j; |
2489 | 1030 #if 0 |
1031 //more accurate but slower | |
1032 int64_t t0, t1, t2, t3; | |
1033 t2 = in1[2*4] + in1[2*8] - in1[2*2]; | |
1034 | |
1035 t3 = (in1[2*0] + (int64_t)(in1[2*6]>>1))<<32; | |
1036 t1 = in1[2*0] - in1[2*6]; | |
1037 tmp1[ 6] = t1 - (t2>>1); | |
1038 tmp1[16] = t1 + t2; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1039 |
2489 | 1040 t0 = MUL64(2*(in1[2*2] + in1[2*4]), C2); |
1041 t1 = MUL64( in1[2*4] - in1[2*8] , -2*C8); | |
1042 t2 = MUL64(2*(in1[2*2] + in1[2*8]), -C4); | |
1043 | |
1044 tmp1[10] = (t3 - t0 - t2) >> 32; | |
1045 tmp1[ 2] = (t3 + t0 + t1) >> 32; | |
1046 tmp1[14] = (t3 + t2 - t1) >> 32; | |
1047 | |
1048 tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3); | |
1049 t2 = MUL64(2*(in1[2*1] + in1[2*5]), C1); | |
1050 t3 = MUL64( in1[2*5] - in1[2*7] , -2*C7); | |
1051 t0 = MUL64(2*in1[2*3], C3); | |
1052 | |
1053 t1 = MUL64(2*(in1[2*1] + in1[2*7]), -C5); | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1054 |
2489 | 1055 tmp1[ 0] = (t2 + t3 + t0) >> 32; |
1056 tmp1[12] = (t2 + t1 - t0) >> 32; | |
1057 tmp1[ 8] = (t3 - t1 - t0) >> 32; | |
1058 #else | |
1059 t2 = in1[2*4] + in1[2*8] - in1[2*2]; | |
1060 | |
1061 t3 = in1[2*0] + (in1[2*6]>>1); | |
1062 t1 = in1[2*0] - in1[2*6]; | |
1063 tmp1[ 6] = t1 - (t2>>1); | |
1064 tmp1[16] = t1 + t2; | |
1065 | |
1066 t0 = MULH(2*(in1[2*2] + in1[2*4]), C2); | |
1067 t1 = MULH( in1[2*4] - in1[2*8] , -2*C8); | |
1068 t2 = MULH(2*(in1[2*2] + in1[2*8]), -C4); | |
1069 | |
1070 tmp1[10] = t3 - t0 - t2; | |
1071 tmp1[ 2] = t3 + t0 + t1; | |
1072 tmp1[14] = t3 + t2 - t1; | |
1073 | |
1074 tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3); | |
1075 t2 = MULH(2*(in1[2*1] + in1[2*5]), C1); | |
1076 t3 = MULH( in1[2*5] - in1[2*7] , -2*C7); | |
1077 t0 = MULH(2*in1[2*3], C3); | |
1078 | |
1079 t1 = MULH(2*(in1[2*1] + in1[2*7]), -C5); | |
1080 | |
1081 tmp1[ 0] = t2 + t3 + t0; | |
1082 tmp1[12] = t2 + t1 - t0; | |
1083 tmp1[ 8] = t3 - t1 - t0; | |
1084 #endif | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1085 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1086 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1087 i = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1088 for(j=0;j<4;j++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1089 t0 = tmp[i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1090 t1 = tmp[i + 2]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1091 s0 = t1 + t0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1092 s2 = t1 - t0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1093 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1094 t2 = tmp[i + 1]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1095 t3 = tmp[i + 3]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1096 s1 = MULL(t3 + t2, icos36[j]); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1097 s3 = MULL(t3 - t2, icos36[8 - j]); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1098 |
2496
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
1099 t0 = s0 + s1; |
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
1100 t1 = s0 - s1; |
2495 | 1101 out[(9 + j)*SBLIMIT] = MULH(t1, win[9 + j]) + buf[9 + j]; |
2489 | 1102 out[(8 - j)*SBLIMIT] = MULH(t1, win[8 - j]) + buf[8 - j]; |
1103 buf[9 + j] = MULH(t0, win[18 + 9 + j]); | |
1104 buf[8 - j] = MULH(t0, win[18 + 8 - j]); | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1105 |
2496
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
1106 t0 = s2 + s3; |
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
1107 t1 = s2 - s3; |
2495 | 1108 out[(9 + 8 - j)*SBLIMIT] = MULH(t1, win[9 + 8 - j]) + buf[9 + 8 - j]; |
2489 | 1109 out[( j)*SBLIMIT] = MULH(t1, win[ j]) + buf[ j]; |
1110 buf[9 + 8 - j] = MULH(t0, win[18 + 9 + 8 - j]); | |
1111 buf[ + j] = MULH(t0, win[18 + j]); | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1112 i += 4; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1113 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1114 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1115 s0 = tmp[16]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1116 s1 = MULL(tmp[17], icos36[4]); |
2496
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
1117 t0 = s0 + s1; |
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
1118 t1 = s0 - s1; |
2495 | 1119 out[(9 + 4)*SBLIMIT] = MULH(t1, win[9 + 4]) + buf[9 + 4]; |
2489 | 1120 out[(8 - 4)*SBLIMIT] = MULH(t1, win[8 - 4]) + buf[8 - 4]; |
1121 buf[9 + 4] = MULH(t0, win[18 + 9 + 4]); | |
1122 buf[8 - 4] = MULH(t0, win[18 + 8 - 4]); | |
0 | 1123 } |
1124 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1125 /* header decoding. MUST check the header before because no |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1126 consistency check is done there. Return 1 if free format found and |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1127 that the frame size must be computed externally */ |
1064 | 1128 static int decode_header(MPADecodeContext *s, uint32_t header) |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1129 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1130 int sample_rate, frame_size, mpeg25, padding; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1131 int sample_rate_index, bitrate_index; |
0 | 1132 if (header & (1<<20)) { |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1133 s->lsf = (header & (1<<19)) ? 0 : 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1134 mpeg25 = 0; |
0 | 1135 } else { |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1136 s->lsf = 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1137 mpeg25 = 1; |
0 | 1138 } |
1139 | |
1140 s->layer = 4 - ((header >> 17) & 3); | |
1141 /* extract frequency */ | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1142 sample_rate_index = (header >> 10) & 3; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1143 sample_rate = mpa_freq_tab[sample_rate_index] >> (s->lsf + mpeg25); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1144 sample_rate_index += 3 * (s->lsf + mpeg25); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1145 s->sample_rate_index = sample_rate_index; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1146 s->error_protection = ((header >> 16) & 1) ^ 1; |
449
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
1147 s->sample_rate = sample_rate; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1148 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1149 bitrate_index = (header >> 12) & 0xf; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1150 padding = (header >> 9) & 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1151 //extension = (header >> 8) & 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1152 s->mode = (header >> 6) & 3; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1153 s->mode_ext = (header >> 4) & 3; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1154 //copyright = (header >> 3) & 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1155 //original = (header >> 2) & 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1156 //emphasis = header & 3; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1157 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1158 if (s->mode == MPA_MONO) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1159 s->nb_channels = 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1160 else |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1161 s->nb_channels = 2; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1162 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1163 if (bitrate_index != 0) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1164 frame_size = mpa_bitrate_tab[s->lsf][s->layer - 1][bitrate_index]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1165 s->bit_rate = frame_size * 1000; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1166 switch(s->layer) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1167 case 1: |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1168 frame_size = (frame_size * 12000) / sample_rate; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1169 frame_size = (frame_size + padding) * 4; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1170 break; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1171 case 2: |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1172 frame_size = (frame_size * 144000) / sample_rate; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1173 frame_size += padding; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1174 break; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1175 default: |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1176 case 3: |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1177 frame_size = (frame_size * 144000) / (sample_rate << s->lsf); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1178 frame_size += padding; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1179 break; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1180 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1181 s->frame_size = frame_size; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1182 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1183 /* if no frame size computed, signal it */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1184 if (!s->free_format_frame_size) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1185 return 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1186 /* free format: compute bitrate and real frame size from the |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1187 frame size we extracted by reading the bitstream */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1188 s->frame_size = s->free_format_frame_size; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1189 switch(s->layer) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1190 case 1: |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1191 s->frame_size += padding * 4; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1192 s->bit_rate = (s->frame_size * sample_rate) / 48000; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1193 break; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1194 case 2: |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1195 s->frame_size += padding; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1196 s->bit_rate = (s->frame_size * sample_rate) / 144000; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1197 break; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1198 default: |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1199 case 3: |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1200 s->frame_size += padding; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1201 s->bit_rate = (s->frame_size * (sample_rate << s->lsf)) / 144000; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1202 break; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1203 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1204 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1205 |
431 | 1206 #if defined(DEBUG) |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1207 printf("layer%d, %d Hz, %d kbits/s, ", |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1208 s->layer, s->sample_rate, s->bit_rate); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1209 if (s->nb_channels == 2) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1210 if (s->layer == 3) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1211 if (s->mode_ext & MODE_EXT_MS_STEREO) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1212 printf("ms-"); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1213 if (s->mode_ext & MODE_EXT_I_STEREO) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1214 printf("i-"); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1215 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1216 printf("stereo"); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1217 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1218 printf("mono"); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1219 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1220 printf("\n"); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1221 #endif |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1222 return 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1223 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1224 |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1225 /* useful helper to get mpeg audio stream infos. Return -1 if error in |
1612 | 1226 header, otherwise the coded frame size in bytes */ |
1227 int mpa_decode_header(AVCodecContext *avctx, uint32_t head) | |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1228 { |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1229 MPADecodeContext s1, *s = &s1; |
1780 | 1230 memset( s, 0, sizeof(MPADecodeContext) ); |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1231 |
2472 | 1232 if (ff_mpa_check_header(head) != 0) |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1233 return -1; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1234 |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1235 if (decode_header(s, head) != 0) { |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1236 return -1; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1237 } |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1238 |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1239 switch(s->layer) { |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1240 case 1: |
1612 | 1241 avctx->frame_size = 384; |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1242 break; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1243 case 2: |
1612 | 1244 avctx->frame_size = 1152; |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1245 break; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1246 default: |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1247 case 3: |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1248 if (s->lsf) |
1612 | 1249 avctx->frame_size = 576; |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1250 else |
1612 | 1251 avctx->frame_size = 1152; |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1252 break; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1253 } |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1254 |
1612 | 1255 avctx->sample_rate = s->sample_rate; |
1256 avctx->channels = s->nb_channels; | |
1257 avctx->bit_rate = s->bit_rate; | |
1258 avctx->sub_id = s->layer; | |
1259 return s->frame_size; | |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1260 } |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1261 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1262 /* return the number of decoded frames */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1263 static int mp_decode_layer1(MPADecodeContext *s) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1264 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1265 int bound, i, v, n, ch, j, mant; |
1064 | 1266 uint8_t allocation[MPA_MAX_CHANNELS][SBLIMIT]; |
1267 uint8_t scale_factors[MPA_MAX_CHANNELS][SBLIMIT]; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1268 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1269 if (s->mode == MPA_JSTEREO) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1270 bound = (s->mode_ext + 1) * 4; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1271 else |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1272 bound = SBLIMIT; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1273 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1274 /* allocation bits */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1275 for(i=0;i<bound;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1276 for(ch=0;ch<s->nb_channels;ch++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1277 allocation[ch][i] = get_bits(&s->gb, 4); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1278 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1279 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1280 for(i=bound;i<SBLIMIT;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1281 allocation[0][i] = get_bits(&s->gb, 4); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1282 } |
0 | 1283 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1284 /* scale factors */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1285 for(i=0;i<bound;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1286 for(ch=0;ch<s->nb_channels;ch++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1287 if (allocation[ch][i]) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1288 scale_factors[ch][i] = get_bits(&s->gb, 6); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1289 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1290 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1291 for(i=bound;i<SBLIMIT;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1292 if (allocation[0][i]) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1293 scale_factors[0][i] = get_bits(&s->gb, 6); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1294 scale_factors[1][i] = get_bits(&s->gb, 6); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1295 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1296 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1297 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1298 /* compute samples */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1299 for(j=0;j<12;j++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1300 for(i=0;i<bound;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1301 for(ch=0;ch<s->nb_channels;ch++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1302 n = allocation[ch][i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1303 if (n) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1304 mant = get_bits(&s->gb, n + 1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1305 v = l1_unscale(n, mant, scale_factors[ch][i]); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1306 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1307 v = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1308 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1309 s->sb_samples[ch][j][i] = v; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1310 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1311 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1312 for(i=bound;i<SBLIMIT;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1313 n = allocation[0][i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1314 if (n) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1315 mant = get_bits(&s->gb, n + 1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1316 v = l1_unscale(n, mant, scale_factors[0][i]); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1317 s->sb_samples[0][j][i] = v; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1318 v = l1_unscale(n, mant, scale_factors[1][i]); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1319 s->sb_samples[1][j][i] = v; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1320 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1321 s->sb_samples[0][j][i] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1322 s->sb_samples[1][j][i] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1323 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1324 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1325 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1326 return 12; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1327 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1328 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1329 /* bitrate is in kb/s */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1330 int l2_select_table(int bitrate, int nb_channels, int freq, int lsf) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1331 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1332 int ch_bitrate, table; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1333 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1334 ch_bitrate = bitrate / nb_channels; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1335 if (!lsf) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1336 if ((freq == 48000 && ch_bitrate >= 56) || |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1337 (ch_bitrate >= 56 && ch_bitrate <= 80)) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1338 table = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1339 else if (freq != 48000 && ch_bitrate >= 96) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1340 table = 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1341 else if (freq != 32000 && ch_bitrate <= 48) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1342 table = 2; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1343 else |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1344 table = 3; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1345 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1346 table = 4; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1347 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1348 return table; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1349 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1350 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1351 static int mp_decode_layer2(MPADecodeContext *s) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1352 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1353 int sblimit; /* number of used subbands */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1354 const unsigned char *alloc_table; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1355 int table, bit_alloc_bits, i, j, ch, bound, v; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1356 unsigned char bit_alloc[MPA_MAX_CHANNELS][SBLIMIT]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1357 unsigned char scale_code[MPA_MAX_CHANNELS][SBLIMIT]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1358 unsigned char scale_factors[MPA_MAX_CHANNELS][SBLIMIT][3], *sf; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1359 int scale, qindex, bits, steps, k, l, m, b; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1360 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1361 /* select decoding table */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1362 table = l2_select_table(s->bit_rate / 1000, s->nb_channels, |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1363 s->sample_rate, s->lsf); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1364 sblimit = sblimit_table[table]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1365 alloc_table = alloc_tables[table]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1366 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1367 if (s->mode == MPA_JSTEREO) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1368 bound = (s->mode_ext + 1) * 4; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1369 else |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1370 bound = sblimit; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1371 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1372 dprintf("bound=%d sblimit=%d\n", bound, sblimit); |
1780 | 1373 |
1374 /* sanity check */ | |
1375 if( bound > sblimit ) bound = sblimit; | |
1376 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1377 /* parse bit allocation */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1378 j = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1379 for(i=0;i<bound;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1380 bit_alloc_bits = alloc_table[j]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1381 for(ch=0;ch<s->nb_channels;ch++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1382 bit_alloc[ch][i] = get_bits(&s->gb, bit_alloc_bits); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1383 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1384 j += 1 << bit_alloc_bits; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1385 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1386 for(i=bound;i<sblimit;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1387 bit_alloc_bits = alloc_table[j]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1388 v = get_bits(&s->gb, bit_alloc_bits); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1389 bit_alloc[0][i] = v; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1390 bit_alloc[1][i] = v; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1391 j += 1 << bit_alloc_bits; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1392 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1393 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1394 #ifdef DEBUG |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1395 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1396 for(ch=0;ch<s->nb_channels;ch++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1397 for(i=0;i<sblimit;i++) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1398 printf(" %d", bit_alloc[ch][i]); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1399 printf("\n"); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1400 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1401 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1402 #endif |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1403 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1404 /* scale codes */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1405 for(i=0;i<sblimit;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1406 for(ch=0;ch<s->nb_channels;ch++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1407 if (bit_alloc[ch][i]) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1408 scale_code[ch][i] = get_bits(&s->gb, 2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1409 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1410 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1411 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1412 /* scale factors */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1413 for(i=0;i<sblimit;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1414 for(ch=0;ch<s->nb_channels;ch++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1415 if (bit_alloc[ch][i]) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1416 sf = scale_factors[ch][i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1417 switch(scale_code[ch][i]) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1418 default: |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1419 case 0: |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1420 sf[0] = get_bits(&s->gb, 6); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1421 sf[1] = get_bits(&s->gb, 6); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1422 sf[2] = get_bits(&s->gb, 6); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1423 break; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1424 case 2: |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1425 sf[0] = get_bits(&s->gb, 6); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1426 sf[1] = sf[0]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1427 sf[2] = sf[0]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1428 break; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1429 case 1: |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1430 sf[0] = get_bits(&s->gb, 6); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1431 sf[2] = get_bits(&s->gb, 6); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1432 sf[1] = sf[0]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1433 break; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1434 case 3: |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1435 sf[0] = get_bits(&s->gb, 6); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1436 sf[2] = get_bits(&s->gb, 6); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1437 sf[1] = sf[2]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1438 break; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1439 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1440 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1441 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1442 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1443 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1444 #ifdef DEBUG |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1445 for(ch=0;ch<s->nb_channels;ch++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1446 for(i=0;i<sblimit;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1447 if (bit_alloc[ch][i]) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1448 sf = scale_factors[ch][i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1449 printf(" %d %d %d", sf[0], sf[1], sf[2]); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1450 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1451 printf(" -"); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1452 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1453 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1454 printf("\n"); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1455 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1456 #endif |
0 | 1457 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1458 /* samples */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1459 for(k=0;k<3;k++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1460 for(l=0;l<12;l+=3) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1461 j = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1462 for(i=0;i<bound;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1463 bit_alloc_bits = alloc_table[j]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1464 for(ch=0;ch<s->nb_channels;ch++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1465 b = bit_alloc[ch][i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1466 if (b) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1467 scale = scale_factors[ch][i][k]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1468 qindex = alloc_table[j+b]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1469 bits = quant_bits[qindex]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1470 if (bits < 0) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1471 /* 3 values at the same time */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1472 v = get_bits(&s->gb, -bits); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1473 steps = quant_steps[qindex]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1474 s->sb_samples[ch][k * 12 + l + 0][i] = |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1475 l2_unscale_group(steps, v % steps, scale); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1476 v = v / steps; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1477 s->sb_samples[ch][k * 12 + l + 1][i] = |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1478 l2_unscale_group(steps, v % steps, scale); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1479 v = v / steps; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1480 s->sb_samples[ch][k * 12 + l + 2][i] = |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1481 l2_unscale_group(steps, v, scale); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1482 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1483 for(m=0;m<3;m++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1484 v = get_bits(&s->gb, bits); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1485 v = l1_unscale(bits - 1, v, scale); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1486 s->sb_samples[ch][k * 12 + l + m][i] = v; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1487 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1488 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1489 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1490 s->sb_samples[ch][k * 12 + l + 0][i] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1491 s->sb_samples[ch][k * 12 + l + 1][i] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1492 s->sb_samples[ch][k * 12 + l + 2][i] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1493 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1494 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1495 /* next subband in alloc table */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1496 j += 1 << bit_alloc_bits; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1497 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1498 /* XXX: find a way to avoid this duplication of code */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1499 for(i=bound;i<sblimit;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1500 bit_alloc_bits = alloc_table[j]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1501 b = bit_alloc[0][i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1502 if (b) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1503 int mant, scale0, scale1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1504 scale0 = scale_factors[0][i][k]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1505 scale1 = scale_factors[1][i][k]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1506 qindex = alloc_table[j+b]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1507 bits = quant_bits[qindex]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1508 if (bits < 0) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1509 /* 3 values at the same time */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1510 v = get_bits(&s->gb, -bits); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1511 steps = quant_steps[qindex]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1512 mant = v % steps; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1513 v = v / steps; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1514 s->sb_samples[0][k * 12 + l + 0][i] = |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1515 l2_unscale_group(steps, mant, scale0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1516 s->sb_samples[1][k * 12 + l + 0][i] = |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1517 l2_unscale_group(steps, mant, scale1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1518 mant = v % steps; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1519 v = v / steps; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1520 s->sb_samples[0][k * 12 + l + 1][i] = |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1521 l2_unscale_group(steps, mant, scale0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1522 s->sb_samples[1][k * 12 + l + 1][i] = |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1523 l2_unscale_group(steps, mant, scale1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1524 s->sb_samples[0][k * 12 + l + 2][i] = |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1525 l2_unscale_group(steps, v, scale0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1526 s->sb_samples[1][k * 12 + l + 2][i] = |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1527 l2_unscale_group(steps, v, scale1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1528 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1529 for(m=0;m<3;m++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1530 mant = get_bits(&s->gb, bits); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1531 s->sb_samples[0][k * 12 + l + m][i] = |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1532 l1_unscale(bits - 1, mant, scale0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1533 s->sb_samples[1][k * 12 + l + m][i] = |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1534 l1_unscale(bits - 1, mant, scale1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1535 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1536 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1537 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1538 s->sb_samples[0][k * 12 + l + 0][i] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1539 s->sb_samples[0][k * 12 + l + 1][i] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1540 s->sb_samples[0][k * 12 + l + 2][i] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1541 s->sb_samples[1][k * 12 + l + 0][i] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1542 s->sb_samples[1][k * 12 + l + 1][i] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1543 s->sb_samples[1][k * 12 + l + 2][i] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1544 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1545 /* next subband in alloc table */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1546 j += 1 << bit_alloc_bits; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1547 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1548 /* fill remaining samples to zero */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1549 for(i=sblimit;i<SBLIMIT;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1550 for(ch=0;ch<s->nb_channels;ch++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1551 s->sb_samples[ch][k * 12 + l + 0][i] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1552 s->sb_samples[ch][k * 12 + l + 1][i] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1553 s->sb_samples[ch][k * 12 + l + 2][i] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1554 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1555 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1556 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1557 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1558 return 3 * 12; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1559 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1560 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1561 /* |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1562 * Seek back in the stream for backstep bytes (at most 511 bytes) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1563 */ |
1057 | 1564 static void seek_to_maindata(MPADecodeContext *s, unsigned int backstep) |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1565 { |
1064 | 1566 uint8_t *ptr; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1567 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1568 /* compute current position in stream */ |
1414 | 1569 ptr = (uint8_t *)(s->gb.buffer + (get_bits_count(&s->gb)>>3)); |
520
19a5e2a81e1a
new bitstream reader API (old get_bits() based one is emulated and will still be supported in the future cuz its simpler)
michaelni
parents:
468
diff
changeset
|
1570 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1571 /* copy old data before current one */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1572 ptr -= backstep; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1573 memcpy(ptr, s->inbuf1[s->inbuf_index ^ 1] + |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1574 BACKSTEP_SIZE + s->old_frame_size - backstep, backstep); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1575 /* init get bits again */ |
1025
1f9afd8b9131
GetBitContext.size is allways multiplied by 8 -> use size_in_bits to avoid useless *8 in a few inner loops
michaelni
parents:
1014
diff
changeset
|
1576 init_get_bits(&s->gb, ptr, (s->frame_size + backstep)*8); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1577 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1578 /* prepare next buffer */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1579 s->inbuf_index ^= 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1580 s->inbuf = &s->inbuf1[s->inbuf_index][BACKSTEP_SIZE]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1581 s->old_frame_size = s->frame_size; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1582 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1583 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1584 static inline void lsf_sf_expand(int *slen, |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1585 int sf, int n1, int n2, int n3) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1586 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1587 if (n3) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1588 slen[3] = sf % n3; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1589 sf /= n3; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1590 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1591 slen[3] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1592 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1593 if (n2) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1594 slen[2] = sf % n2; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1595 sf /= n2; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1596 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1597 slen[2] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1598 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1599 slen[1] = sf % n1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1600 sf /= n1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1601 slen[0] = sf; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1602 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1603 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1604 static void exponents_from_scale_factors(MPADecodeContext *s, |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1605 GranuleDef *g, |
1064 | 1606 int16_t *exponents) |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1607 { |
1064 | 1608 const uint8_t *bstab, *pretab; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1609 int len, i, j, k, l, v0, shift, gain, gains[3]; |
1064 | 1610 int16_t *exp_ptr; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1611 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1612 exp_ptr = exponents; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1613 gain = g->global_gain - 210; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1614 shift = g->scalefac_scale + 1; |
0 | 1615 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1616 bstab = band_size_long[s->sample_rate_index]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1617 pretab = mpa_pretab[g->preflag]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1618 for(i=0;i<g->long_end;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1619 v0 = gain - ((g->scale_factors[i] + pretab[i]) << shift); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1620 len = bstab[i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1621 for(j=len;j>0;j--) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1622 *exp_ptr++ = v0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1623 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1624 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1625 if (g->short_start < 13) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1626 bstab = band_size_short[s->sample_rate_index]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1627 gains[0] = gain - (g->subblock_gain[0] << 3); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1628 gains[1] = gain - (g->subblock_gain[1] << 3); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1629 gains[2] = gain - (g->subblock_gain[2] << 3); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1630 k = g->long_end; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1631 for(i=g->short_start;i<13;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1632 len = bstab[i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1633 for(l=0;l<3;l++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1634 v0 = gains[l] - (g->scale_factors[k++] << shift); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1635 for(j=len;j>0;j--) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1636 *exp_ptr++ = v0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1637 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1638 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1639 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1640 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1641 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1642 /* handle n = 0 too */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1643 static inline int get_bitsz(GetBitContext *s, int n) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1644 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1645 if (n == 0) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1646 return 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1647 else |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1648 return get_bits(s, n); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1649 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1650 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1651 static int huffman_decode(MPADecodeContext *s, GranuleDef *g, |
1064 | 1652 int16_t *exponents, int end_pos) |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1653 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1654 int s_index; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1655 int linbits, code, x, y, l, v, i, j, k, pos; |
520
19a5e2a81e1a
new bitstream reader API (old get_bits() based one is emulated and will still be supported in the future cuz its simpler)
michaelni
parents:
468
diff
changeset
|
1656 GetBitContext last_gb; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1657 VLC *vlc; |
1064 | 1658 uint8_t *code_table; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1659 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1660 /* low frequencies (called big values) */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1661 s_index = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1662 for(i=0;i<3;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1663 j = g->region_size[i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1664 if (j == 0) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1665 continue; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1666 /* select vlc table */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1667 k = g->table_select[i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1668 l = mpa_huff_data[k][0]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1669 linbits = mpa_huff_data[k][1]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1670 vlc = &huff_vlc[l]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1671 code_table = huff_code_table[l]; |
0 | 1672 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1673 /* read huffcode and compute each couple */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1674 for(;j>0;j--) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1675 if (get_bits_count(&s->gb) >= end_pos) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1676 break; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1677 if (code_table) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1678 code = get_vlc(&s->gb, vlc); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1679 if (code < 0) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1680 return -1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1681 y = code_table[code]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1682 x = y >> 4; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1683 y = y & 0x0f; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1684 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1685 x = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1686 y = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1687 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1688 dprintf("region=%d n=%d x=%d y=%d exp=%d\n", |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1689 i, g->region_size[i] - j, x, y, exponents[s_index]); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1690 if (x) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1691 if (x == 15) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1692 x += get_bitsz(&s->gb, linbits); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1693 v = l3_unscale(x, exponents[s_index]); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1694 if (get_bits1(&s->gb)) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1695 v = -v; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1696 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1697 v = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1698 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1699 g->sb_hybrid[s_index++] = v; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1700 if (y) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1701 if (y == 15) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1702 y += get_bitsz(&s->gb, linbits); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1703 v = l3_unscale(y, exponents[s_index]); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1704 if (get_bits1(&s->gb)) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1705 v = -v; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1706 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1707 v = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1708 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1709 g->sb_hybrid[s_index++] = v; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1710 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1711 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1712 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1713 /* high frequencies */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1714 vlc = &huff_quad_vlc[g->count1table_select]; |
520
19a5e2a81e1a
new bitstream reader API (old get_bits() based one is emulated and will still be supported in the future cuz its simpler)
michaelni
parents:
468
diff
changeset
|
1715 last_gb.buffer = NULL; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1716 while (s_index <= 572) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1717 pos = get_bits_count(&s->gb); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1718 if (pos >= end_pos) { |
520
19a5e2a81e1a
new bitstream reader API (old get_bits() based one is emulated and will still be supported in the future cuz its simpler)
michaelni
parents:
468
diff
changeset
|
1719 if (pos > end_pos && last_gb.buffer != NULL) { |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1720 /* some encoders generate an incorrect size for this |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1721 part. We must go back into the data */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1722 s_index -= 4; |
520
19a5e2a81e1a
new bitstream reader API (old get_bits() based one is emulated and will still be supported in the future cuz its simpler)
michaelni
parents:
468
diff
changeset
|
1723 s->gb = last_gb; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1724 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1725 break; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1726 } |
520
19a5e2a81e1a
new bitstream reader API (old get_bits() based one is emulated and will still be supported in the future cuz its simpler)
michaelni
parents:
468
diff
changeset
|
1727 last_gb= s->gb; |
19a5e2a81e1a
new bitstream reader API (old get_bits() based one is emulated and will still be supported in the future cuz its simpler)
michaelni
parents:
468
diff
changeset
|
1728 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1729 code = get_vlc(&s->gb, vlc); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1730 dprintf("t=%d code=%d\n", g->count1table_select, code); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1731 if (code < 0) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1732 return -1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1733 for(i=0;i<4;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1734 if (code & (8 >> i)) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1735 /* non zero value. Could use a hand coded function for |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1736 'one' value */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1737 v = l3_unscale(1, exponents[s_index]); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1738 if(get_bits1(&s->gb)) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1739 v = -v; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1740 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1741 v = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1742 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1743 g->sb_hybrid[s_index++] = v; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1744 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1745 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1746 while (s_index < 576) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1747 g->sb_hybrid[s_index++] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1748 return 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1749 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1750 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1751 /* Reorder short blocks from bitstream order to interleaved order. It |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1752 would be faster to do it in parsing, but the code would be far more |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1753 complicated */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1754 static void reorder_block(MPADecodeContext *s, GranuleDef *g) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1755 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1756 int i, j, k, len; |
1064 | 1757 int32_t *ptr, *dst, *ptr1; |
1758 int32_t tmp[576]; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1759 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1760 if (g->block_type != 2) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1761 return; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1762 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1763 if (g->switch_point) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1764 if (s->sample_rate_index != 8) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1765 ptr = g->sb_hybrid + 36; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1766 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1767 ptr = g->sb_hybrid + 48; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1768 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1769 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1770 ptr = g->sb_hybrid; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1771 } |
0 | 1772 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1773 for(i=g->short_start;i<13;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1774 len = band_size_short[s->sample_rate_index][i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1775 ptr1 = ptr; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1776 for(k=0;k<3;k++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1777 dst = tmp + k; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1778 for(j=len;j>0;j--) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1779 *dst = *ptr++; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1780 dst += 3; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1781 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1782 } |
1064 | 1783 memcpy(ptr1, tmp, len * 3 * sizeof(int32_t)); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1784 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1785 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1786 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1787 #define ISQRT2 FIXR(0.70710678118654752440) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1788 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1789 static void compute_stereo(MPADecodeContext *s, |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1790 GranuleDef *g0, GranuleDef *g1) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1791 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1792 int i, j, k, l; |
1064 | 1793 int32_t v1, v2; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1794 int sf_max, tmp0, tmp1, sf, len, non_zero_found; |
1064 | 1795 int32_t (*is_tab)[16]; |
1796 int32_t *tab0, *tab1; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1797 int non_zero_found_short[3]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1798 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1799 /* intensity stereo */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1800 if (s->mode_ext & MODE_EXT_I_STEREO) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1801 if (!s->lsf) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1802 is_tab = is_table; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1803 sf_max = 7; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1804 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1805 is_tab = is_table_lsf[g1->scalefac_compress & 1]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1806 sf_max = 16; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1807 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1808 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1809 tab0 = g0->sb_hybrid + 576; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1810 tab1 = g1->sb_hybrid + 576; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1811 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1812 non_zero_found_short[0] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1813 non_zero_found_short[1] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1814 non_zero_found_short[2] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1815 k = (13 - g1->short_start) * 3 + g1->long_end - 3; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1816 for(i = 12;i >= g1->short_start;i--) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1817 /* for last band, use previous scale factor */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1818 if (i != 11) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1819 k -= 3; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1820 len = band_size_short[s->sample_rate_index][i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1821 for(l=2;l>=0;l--) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1822 tab0 -= len; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1823 tab1 -= len; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1824 if (!non_zero_found_short[l]) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1825 /* test if non zero band. if so, stop doing i-stereo */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1826 for(j=0;j<len;j++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1827 if (tab1[j] != 0) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1828 non_zero_found_short[l] = 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1829 goto found1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1830 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1831 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1832 sf = g1->scale_factors[k + l]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1833 if (sf >= sf_max) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1834 goto found1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1835 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1836 v1 = is_tab[0][sf]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1837 v2 = is_tab[1][sf]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1838 for(j=0;j<len;j++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1839 tmp0 = tab0[j]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1840 tab0[j] = MULL(tmp0, v1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1841 tab1[j] = MULL(tmp0, v2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1842 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1843 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1844 found1: |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1845 if (s->mode_ext & MODE_EXT_MS_STEREO) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1846 /* lower part of the spectrum : do ms stereo |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1847 if enabled */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1848 for(j=0;j<len;j++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1849 tmp0 = tab0[j]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1850 tmp1 = tab1[j]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1851 tab0[j] = MULL(tmp0 + tmp1, ISQRT2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1852 tab1[j] = MULL(tmp0 - tmp1, ISQRT2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1853 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1854 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1855 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1856 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1857 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1858 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1859 non_zero_found = non_zero_found_short[0] | |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1860 non_zero_found_short[1] | |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1861 non_zero_found_short[2]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1862 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1863 for(i = g1->long_end - 1;i >= 0;i--) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1864 len = band_size_long[s->sample_rate_index][i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1865 tab0 -= len; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1866 tab1 -= len; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1867 /* test if non zero band. if so, stop doing i-stereo */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1868 if (!non_zero_found) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1869 for(j=0;j<len;j++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1870 if (tab1[j] != 0) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1871 non_zero_found = 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1872 goto found2; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1873 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1874 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1875 /* for last band, use previous scale factor */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1876 k = (i == 21) ? 20 : i; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1877 sf = g1->scale_factors[k]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1878 if (sf >= sf_max) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1879 goto found2; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1880 v1 = is_tab[0][sf]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1881 v2 = is_tab[1][sf]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1882 for(j=0;j<len;j++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1883 tmp0 = tab0[j]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1884 tab0[j] = MULL(tmp0, v1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1885 tab1[j] = MULL(tmp0, v2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1886 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1887 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1888 found2: |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1889 if (s->mode_ext & MODE_EXT_MS_STEREO) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1890 /* lower part of the spectrum : do ms stereo |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1891 if enabled */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1892 for(j=0;j<len;j++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1893 tmp0 = tab0[j]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1894 tmp1 = tab1[j]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1895 tab0[j] = MULL(tmp0 + tmp1, ISQRT2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1896 tab1[j] = MULL(tmp0 - tmp1, ISQRT2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1897 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1898 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1899 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1900 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1901 } else if (s->mode_ext & MODE_EXT_MS_STEREO) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1902 /* ms stereo ONLY */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1903 /* NOTE: the 1/sqrt(2) normalization factor is included in the |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1904 global gain */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1905 tab0 = g0->sb_hybrid; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1906 tab1 = g1->sb_hybrid; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1907 for(i=0;i<576;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1908 tmp0 = tab0[i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1909 tmp1 = tab1[i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1910 tab0[i] = tmp0 + tmp1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1911 tab1[i] = tmp0 - tmp1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1912 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1913 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1914 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1915 |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1916 static void compute_antialias_integer(MPADecodeContext *s, |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1917 GranuleDef *g) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1918 { |
2491 | 1919 int32_t *ptr, *csa; |
1920 int n, i; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1921 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1922 /* we antialias only "long" bands */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1923 if (g->block_type == 2) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1924 if (!g->switch_point) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1925 return; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1926 /* XXX: check this for 8000Hz case */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1927 n = 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1928 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1929 n = SBLIMIT - 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1930 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1931 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1932 ptr = g->sb_hybrid + 18; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1933 for(i = n;i > 0;i--) { |
2491 | 1934 int tmp0, tmp1, tmp2; |
1935 csa = &csa_table[0][0]; | |
1936 #define INT_AA(j) \ | |
2496
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
1937 tmp0 = ptr[-1-j];\ |
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
1938 tmp1 = ptr[ j];\ |
2491 | 1939 tmp2= MULH(tmp0 + tmp1, csa[0+4*j]);\ |
2496
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
1940 ptr[-1-j] = 4*(tmp2 - MULH(tmp1, csa[2+4*j]));\ |
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
1941 ptr[ j] = 4*(tmp2 + MULH(tmp0, csa[3+4*j])); |
2491 | 1942 |
1943 INT_AA(0) | |
1944 INT_AA(1) | |
1945 INT_AA(2) | |
1946 INT_AA(3) | |
1947 INT_AA(4) | |
1948 INT_AA(5) | |
1949 INT_AA(6) | |
1950 INT_AA(7) | |
1951 | |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1952 ptr += 18; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1953 } |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1954 } |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1955 |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1956 static void compute_antialias_float(MPADecodeContext *s, |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1957 GranuleDef *g) |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1958 { |
2491 | 1959 int32_t *ptr; |
1960 int n, i; | |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1961 |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1962 /* we antialias only "long" bands */ |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1963 if (g->block_type == 2) { |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1964 if (!g->switch_point) |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1965 return; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1966 /* XXX: check this for 8000Hz case */ |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1967 n = 1; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1968 } else { |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1969 n = SBLIMIT - 1; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1970 } |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1971 |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1972 ptr = g->sb_hybrid + 18; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1973 for(i = n;i > 0;i--) { |
2491 | 1974 float tmp0, tmp1; |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1975 float *csa = &csa_table_float[0][0]; |
2491 | 1976 #define FLOAT_AA(j)\ |
1977 tmp0= ptr[-1-j];\ | |
1978 tmp1= ptr[ j];\ | |
1979 ptr[-1-j] = lrintf(tmp0 * csa[0+4*j] - tmp1 * csa[1+4*j]);\ | |
1980 ptr[ j] = lrintf(tmp0 * csa[1+4*j] + tmp1 * csa[0+4*j]); | |
1981 | |
1982 FLOAT_AA(0) | |
1983 FLOAT_AA(1) | |
1984 FLOAT_AA(2) | |
1985 FLOAT_AA(3) | |
1986 FLOAT_AA(4) | |
1987 FLOAT_AA(5) | |
1988 FLOAT_AA(6) | |
1989 FLOAT_AA(7) | |
1990 | |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1991 ptr += 18; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1992 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1993 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1994 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1995 static void compute_imdct(MPADecodeContext *s, |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1996 GranuleDef *g, |
1064 | 1997 int32_t *sb_samples, |
1998 int32_t *mdct_buf) | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1999 { |
2495 | 2000 int32_t *ptr, *win, *win1, *buf, *out_ptr, *ptr1; |
1064 | 2001 int32_t out2[12]; |
2495 | 2002 int i, j, mdct_long_end, v, sblimit; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2003 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2004 /* find last non zero block */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2005 ptr = g->sb_hybrid + 576; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2006 ptr1 = g->sb_hybrid + 2 * 18; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2007 while (ptr >= ptr1) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2008 ptr -= 6; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2009 v = ptr[0] | ptr[1] | ptr[2] | ptr[3] | ptr[4] | ptr[5]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2010 if (v != 0) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2011 break; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2012 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2013 sblimit = ((ptr - g->sb_hybrid) / 18) + 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2014 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2015 if (g->block_type == 2) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2016 /* XXX: check for 8000 Hz */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2017 if (g->switch_point) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2018 mdct_long_end = 2; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2019 else |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2020 mdct_long_end = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2021 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2022 mdct_long_end = sblimit; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2023 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2024 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2025 buf = mdct_buf; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2026 ptr = g->sb_hybrid; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2027 for(j=0;j<mdct_long_end;j++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2028 /* apply window & overlap with previous buffer */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2029 out_ptr = sb_samples + j; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2030 /* select window */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2031 if (g->switch_point && j < 2) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2032 win1 = mdct_win[0]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2033 else |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2034 win1 = mdct_win[g->block_type]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2035 /* select frequency inversion */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2036 win = win1 + ((4 * 36) & -(j & 1)); |
2489 | 2037 imdct36(out_ptr, buf, ptr, win); |
2038 out_ptr += 18*SBLIMIT; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2039 ptr += 18; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2040 buf += 18; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2041 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2042 for(j=mdct_long_end;j<sblimit;j++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2043 /* select frequency inversion */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2044 win = mdct_win[2] + ((4 * 36) & -(j & 1)); |
2495 | 2045 out_ptr = sb_samples + j; |
2046 | |
2047 for(i=0; i<6; i++){ | |
2048 *out_ptr = buf[i]; | |
2049 out_ptr += SBLIMIT; | |
2050 } | |
2051 imdct12(out2, ptr + 0); | |
2052 for(i=0;i<6;i++) { | |
2053 *out_ptr = MULH(out2[i], win[i]) + buf[i + 6*1]; | |
2054 buf[i + 6*2] = MULH(out2[i + 6], win[i + 6]); | |
2055 out_ptr += SBLIMIT; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2056 } |
2495 | 2057 imdct12(out2, ptr + 1); |
2058 for(i=0;i<6;i++) { | |
2059 *out_ptr = MULH(out2[i], win[i]) + buf[i + 6*2]; | |
2060 buf[i + 6*0] = MULH(out2[i + 6], win[i + 6]); | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2061 out_ptr += SBLIMIT; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2062 } |
2495 | 2063 imdct12(out2, ptr + 2); |
2064 for(i=0;i<6;i++) { | |
2065 buf[i + 6*0] = MULH(out2[i], win[i]) + buf[i + 6*0]; | |
2066 buf[i + 6*1] = MULH(out2[i + 6], win[i + 6]); | |
2067 buf[i + 6*2] = 0; | |
2068 } | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2069 ptr += 18; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2070 buf += 18; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2071 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2072 /* zero bands */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2073 for(j=sblimit;j<SBLIMIT;j++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2074 /* overlap */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2075 out_ptr = sb_samples + j; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2076 for(i=0;i<18;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2077 *out_ptr = buf[i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2078 buf[i] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2079 out_ptr += SBLIMIT; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2080 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2081 buf += 18; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2082 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2083 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2084 |
404 | 2085 #if defined(DEBUG) |
1064 | 2086 void sample_dump(int fnum, int32_t *tab, int n) |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2087 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2088 static FILE *files[16], *f; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2089 char buf[512]; |
449
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2090 int i; |
1064 | 2091 int32_t v; |
449
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2092 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2093 f = files[fnum]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2094 if (!f) { |
2423 | 2095 snprintf(buf, sizeof(buf), "/tmp/out%d.%s.pcm", |
449
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2096 fnum, |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2097 #ifdef USE_HIGHPRECISION |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2098 "hp" |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2099 #else |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2100 "lp" |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2101 #endif |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2102 ); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2103 f = fopen(buf, "w"); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2104 if (!f) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2105 return; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2106 files[fnum] = f; |
0 | 2107 } |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2108 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2109 if (fnum == 0) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2110 static int pos = 0; |
2477 | 2111 av_log(NULL, AV_LOG_DEBUG, "pos=%d\n", pos); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2112 for(i=0;i<n;i++) { |
2477 | 2113 av_log(NULL, AV_LOG_DEBUG, " %0.4f", (double)tab[i] / FRAC_ONE); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2114 if ((i % 18) == 17) |
2477 | 2115 av_log(NULL, AV_LOG_DEBUG, "\n"); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2116 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2117 pos += n; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2118 } |
449
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2119 for(i=0;i<n;i++) { |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2120 /* normalize to 23 frac bits */ |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2121 v = tab[i] << (23 - FRAC_BITS); |
1064 | 2122 fwrite(&v, 1, sizeof(int32_t), f); |
449
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2123 } |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2124 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2125 #endif |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2126 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2127 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2128 /* main layer3 decoding function */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2129 static int mp_decode_layer3(MPADecodeContext *s) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2130 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2131 int nb_granules, main_data_begin, private_bits; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2132 int gr, ch, blocksplit_flag, i, j, k, n, bits_pos, bits_left; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2133 GranuleDef granules[2][2], *g; |
1064 | 2134 int16_t exponents[576]; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2135 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2136 /* read side info */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2137 if (s->lsf) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2138 main_data_begin = get_bits(&s->gb, 8); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2139 if (s->nb_channels == 2) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2140 private_bits = get_bits(&s->gb, 2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2141 else |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2142 private_bits = get_bits(&s->gb, 1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2143 nb_granules = 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2144 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2145 main_data_begin = get_bits(&s->gb, 9); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2146 if (s->nb_channels == 2) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2147 private_bits = get_bits(&s->gb, 3); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2148 else |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2149 private_bits = get_bits(&s->gb, 5); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2150 nb_granules = 2; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2151 for(ch=0;ch<s->nb_channels;ch++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2152 granules[ch][0].scfsi = 0; /* all scale factors are transmitted */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2153 granules[ch][1].scfsi = get_bits(&s->gb, 4); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2154 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2155 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2156 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2157 for(gr=0;gr<nb_granules;gr++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2158 for(ch=0;ch<s->nb_channels;ch++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2159 dprintf("gr=%d ch=%d: side_info\n", gr, ch); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2160 g = &granules[ch][gr]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2161 g->part2_3_length = get_bits(&s->gb, 12); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2162 g->big_values = get_bits(&s->gb, 9); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2163 g->global_gain = get_bits(&s->gb, 8); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2164 /* if MS stereo only is selected, we precompute the |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2165 1/sqrt(2) renormalization factor */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2166 if ((s->mode_ext & (MODE_EXT_MS_STEREO | MODE_EXT_I_STEREO)) == |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2167 MODE_EXT_MS_STEREO) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2168 g->global_gain -= 2; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2169 if (s->lsf) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2170 g->scalefac_compress = get_bits(&s->gb, 9); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2171 else |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2172 g->scalefac_compress = get_bits(&s->gb, 4); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2173 blocksplit_flag = get_bits(&s->gb, 1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2174 if (blocksplit_flag) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2175 g->block_type = get_bits(&s->gb, 2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2176 if (g->block_type == 0) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2177 return -1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2178 g->switch_point = get_bits(&s->gb, 1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2179 for(i=0;i<2;i++) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2180 g->table_select[i] = get_bits(&s->gb, 5); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2181 for(i=0;i<3;i++) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2182 g->subblock_gain[i] = get_bits(&s->gb, 3); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2183 /* compute huffman coded region sizes */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2184 if (g->block_type == 2) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2185 g->region_size[0] = (36 / 2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2186 else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2187 if (s->sample_rate_index <= 2) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2188 g->region_size[0] = (36 / 2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2189 else if (s->sample_rate_index != 8) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2190 g->region_size[0] = (54 / 2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2191 else |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2192 g->region_size[0] = (108 / 2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2193 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2194 g->region_size[1] = (576 / 2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2195 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2196 int region_address1, region_address2, l; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2197 g->block_type = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2198 g->switch_point = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2199 for(i=0;i<3;i++) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2200 g->table_select[i] = get_bits(&s->gb, 5); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2201 /* compute huffman coded region sizes */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2202 region_address1 = get_bits(&s->gb, 4); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2203 region_address2 = get_bits(&s->gb, 3); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2204 dprintf("region1=%d region2=%d\n", |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2205 region_address1, region_address2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2206 g->region_size[0] = |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2207 band_index_long[s->sample_rate_index][region_address1 + 1] >> 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2208 l = region_address1 + region_address2 + 2; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2209 /* should not overflow */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2210 if (l > 22) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2211 l = 22; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2212 g->region_size[1] = |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2213 band_index_long[s->sample_rate_index][l] >> 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2214 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2215 /* convert region offsets to region sizes and truncate |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2216 size to big_values */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2217 g->region_size[2] = (576 / 2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2218 j = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2219 for(i=0;i<3;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2220 k = g->region_size[i]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2221 if (k > g->big_values) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2222 k = g->big_values; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2223 g->region_size[i] = k - j; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2224 j = k; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2225 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2226 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2227 /* compute band indexes */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2228 if (g->block_type == 2) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2229 if (g->switch_point) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2230 /* if switched mode, we handle the 36 first samples as |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2231 long blocks. For 8000Hz, we handle the 48 first |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2232 exponents as long blocks (XXX: check this!) */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2233 if (s->sample_rate_index <= 2) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2234 g->long_end = 8; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2235 else if (s->sample_rate_index != 8) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2236 g->long_end = 6; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2237 else |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2238 g->long_end = 4; /* 8000 Hz */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2239 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2240 if (s->sample_rate_index != 8) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2241 g->short_start = 3; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2242 else |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2243 g->short_start = 2; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2244 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2245 g->long_end = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2246 g->short_start = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2247 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2248 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2249 g->short_start = 13; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2250 g->long_end = 22; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2251 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2252 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2253 g->preflag = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2254 if (!s->lsf) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2255 g->preflag = get_bits(&s->gb, 1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2256 g->scalefac_scale = get_bits(&s->gb, 1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2257 g->count1table_select = get_bits(&s->gb, 1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2258 dprintf("block_type=%d switch_point=%d\n", |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2259 g->block_type, g->switch_point); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2260 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2261 } |
0 | 2262 |
2432 | 2263 if (!s->adu_mode) { |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2264 /* now we get bits from the main_data_begin offset */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2265 dprintf("seekback: %d\n", main_data_begin); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2266 seek_to_maindata(s, main_data_begin); |
2432 | 2267 } |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2268 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2269 for(gr=0;gr<nb_granules;gr++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2270 for(ch=0;ch<s->nb_channels;ch++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2271 g = &granules[ch][gr]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2272 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2273 bits_pos = get_bits_count(&s->gb); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2274 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2275 if (!s->lsf) { |
1064 | 2276 uint8_t *sc; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2277 int slen, slen1, slen2; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2278 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2279 /* MPEG1 scale factors */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2280 slen1 = slen_table[0][g->scalefac_compress]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2281 slen2 = slen_table[1][g->scalefac_compress]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2282 dprintf("slen1=%d slen2=%d\n", slen1, slen2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2283 if (g->block_type == 2) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2284 n = g->switch_point ? 17 : 18; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2285 j = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2286 for(i=0;i<n;i++) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2287 g->scale_factors[j++] = get_bitsz(&s->gb, slen1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2288 for(i=0;i<18;i++) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2289 g->scale_factors[j++] = get_bitsz(&s->gb, slen2); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2290 for(i=0;i<3;i++) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2291 g->scale_factors[j++] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2292 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2293 sc = granules[ch][0].scale_factors; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2294 j = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2295 for(k=0;k<4;k++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2296 n = (k == 0 ? 6 : 5); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2297 if ((g->scfsi & (0x8 >> k)) == 0) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2298 slen = (k < 2) ? slen1 : slen2; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2299 for(i=0;i<n;i++) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2300 g->scale_factors[j++] = get_bitsz(&s->gb, slen); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2301 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2302 /* simply copy from last granule */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2303 for(i=0;i<n;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2304 g->scale_factors[j] = sc[j]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2305 j++; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2306 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2307 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2308 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2309 g->scale_factors[j++] = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2310 } |
404 | 2311 #if defined(DEBUG) |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2312 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2313 printf("scfsi=%x gr=%d ch=%d scale_factors:\n", |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2314 g->scfsi, gr, ch); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2315 for(i=0;i<j;i++) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2316 printf(" %d", g->scale_factors[i]); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2317 printf("\n"); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2318 } |
0 | 2319 #endif |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2320 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2321 int tindex, tindex2, slen[4], sl, sf; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2322 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2323 /* LSF scale factors */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2324 if (g->block_type == 2) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2325 tindex = g->switch_point ? 2 : 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2326 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2327 tindex = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2328 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2329 sf = g->scalefac_compress; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2330 if ((s->mode_ext & MODE_EXT_I_STEREO) && ch == 1) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2331 /* intensity stereo case */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2332 sf >>= 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2333 if (sf < 180) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2334 lsf_sf_expand(slen, sf, 6, 6, 0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2335 tindex2 = 3; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2336 } else if (sf < 244) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2337 lsf_sf_expand(slen, sf - 180, 4, 4, 0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2338 tindex2 = 4; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2339 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2340 lsf_sf_expand(slen, sf - 244, 3, 0, 0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2341 tindex2 = 5; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2342 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2343 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2344 /* normal case */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2345 if (sf < 400) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2346 lsf_sf_expand(slen, sf, 5, 4, 4); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2347 tindex2 = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2348 } else if (sf < 500) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2349 lsf_sf_expand(slen, sf - 400, 5, 4, 0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2350 tindex2 = 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2351 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2352 lsf_sf_expand(slen, sf - 500, 3, 0, 0); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2353 tindex2 = 2; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2354 g->preflag = 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2355 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2356 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2357 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2358 j = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2359 for(k=0;k<4;k++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2360 n = lsf_nsf_table[tindex2][tindex][k]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2361 sl = slen[k]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2362 for(i=0;i<n;i++) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2363 g->scale_factors[j++] = get_bitsz(&s->gb, sl); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2364 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2365 /* XXX: should compute exact size */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2366 for(;j<40;j++) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2367 g->scale_factors[j] = 0; |
404 | 2368 #if defined(DEBUG) |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2369 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2370 printf("gr=%d ch=%d scale_factors:\n", |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2371 gr, ch); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2372 for(i=0;i<40;i++) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2373 printf(" %d", g->scale_factors[i]); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2374 printf("\n"); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2375 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2376 #endif |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2377 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2378 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2379 exponents_from_scale_factors(s, g, exponents); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2380 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2381 /* read Huffman coded residue */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2382 if (huffman_decode(s, g, exponents, |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2383 bits_pos + g->part2_3_length) < 0) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2384 return -1; |
404 | 2385 #if defined(DEBUG) |
2386 sample_dump(0, g->sb_hybrid, 576); | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2387 #endif |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2388 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2389 /* skip extension bits */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2390 bits_left = g->part2_3_length - (get_bits_count(&s->gb) - bits_pos); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2391 if (bits_left < 0) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2392 dprintf("bits_left=%d\n", bits_left); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2393 return -1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2394 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2395 while (bits_left >= 16) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2396 skip_bits(&s->gb, 16); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2397 bits_left -= 16; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2398 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2399 if (bits_left > 0) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2400 skip_bits(&s->gb, bits_left); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2401 } /* ch */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2402 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2403 if (s->nb_channels == 2) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2404 compute_stereo(s, &granules[0][gr], &granules[1][gr]); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2405 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2406 for(ch=0;ch<s->nb_channels;ch++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2407 g = &granules[ch][gr]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2408 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2409 reorder_block(s, g); |
404 | 2410 #if defined(DEBUG) |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2411 sample_dump(0, g->sb_hybrid, 576); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2412 #endif |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2413 s->compute_antialias(s, g); |
449
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2414 #if defined(DEBUG) |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2415 sample_dump(1, g->sb_hybrid, 576); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2416 #endif |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2417 compute_imdct(s, g, &s->sb_samples[ch][18 * gr][0], s->mdct_buf[ch]); |
449
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2418 #if defined(DEBUG) |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2419 sample_dump(2, &s->sb_samples[ch][18 * gr][0], 576); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2420 #endif |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2421 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2422 } /* gr */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2423 return nb_granules * 18; |
0 | 2424 } |
2425 | |
2426 static int mp_decode_frame(MPADecodeContext *s, | |
2479 | 2427 OUT_INT *samples) |
0 | 2428 { |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2429 int i, nb_frames, ch; |
2479 | 2430 OUT_INT *samples_ptr; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2431 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2432 init_get_bits(&s->gb, s->inbuf + HEADER_SIZE, |
1025
1f9afd8b9131
GetBitContext.size is allways multiplied by 8 -> use size_in_bits to avoid useless *8 in a few inner loops
michaelni
parents:
1014
diff
changeset
|
2433 (s->inbuf_ptr - s->inbuf - HEADER_SIZE)*8); |
0 | 2434 |
2435 /* skip error protection field */ | |
2436 if (s->error_protection) | |
2437 get_bits(&s->gb, 16); | |
2438 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2439 dprintf("frame %d:\n", s->frame_count); |
0 | 2440 switch(s->layer) { |
2441 case 1: | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2442 nb_frames = mp_decode_layer1(s); |
0 | 2443 break; |
2444 case 2: | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2445 nb_frames = mp_decode_layer2(s); |
0 | 2446 break; |
2447 case 3: | |
2448 default: | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2449 nb_frames = mp_decode_layer3(s); |
0 | 2450 break; |
2451 } | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2452 #if defined(DEBUG) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2453 for(i=0;i<nb_frames;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2454 for(ch=0;ch<s->nb_channels;ch++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2455 int j; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2456 printf("%d-%d:", i, ch); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2457 for(j=0;j<SBLIMIT;j++) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2458 printf(" %0.6f", (double)s->sb_samples[ch][i][j] / FRAC_ONE); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2459 printf("\n"); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2460 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2461 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2462 #endif |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2463 /* apply the synthesis filter */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2464 for(ch=0;ch<s->nb_channels;ch++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2465 samples_ptr = samples + ch; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2466 for(i=0;i<nb_frames;i++) { |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
2467 ff_mpa_synth_filter(s->synth_buf[ch], &(s->synth_buf_offset[ch]), |
2473 | 2468 window, &s->dither_state, |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
2469 samples_ptr, s->nb_channels, |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2470 s->sb_samples[ch][i]); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2471 samples_ptr += 32 * s->nb_channels; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2472 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2473 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2474 #ifdef DEBUG |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2475 s->frame_count++; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2476 #endif |
2479 | 2477 return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels; |
0 | 2478 } |
2479 | |
2480 static int decode_frame(AVCodecContext * avctx, | |
2481 void *data, int *data_size, | |
1064 | 2482 uint8_t * buf, int buf_size) |
0 | 2483 { |
2484 MPADecodeContext *s = avctx->priv_data; | |
1064 | 2485 uint32_t header; |
2486 uint8_t *buf_ptr; | |
0 | 2487 int len, out_size; |
2479 | 2488 OUT_INT *out_samples = data; |
0 | 2489 |
2490 buf_ptr = buf; | |
2491 while (buf_size > 0) { | |
2492 len = s->inbuf_ptr - s->inbuf; | |
2493 if (s->frame_size == 0) { | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2494 /* special case for next header for first frame in free |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2495 format case (XXX: find a simpler method) */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2496 if (s->free_format_next_header != 0) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2497 s->inbuf[0] = s->free_format_next_header >> 24; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2498 s->inbuf[1] = s->free_format_next_header >> 16; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2499 s->inbuf[2] = s->free_format_next_header >> 8; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2500 s->inbuf[3] = s->free_format_next_header; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2501 s->inbuf_ptr = s->inbuf + 4; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2502 s->free_format_next_header = 0; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2503 goto got_header; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2504 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2505 /* no header seen : find one. We need at least HEADER_SIZE |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2506 bytes to parse it */ |
0 | 2507 len = HEADER_SIZE - len; |
2508 if (len > buf_size) | |
2509 len = buf_size; | |
143 | 2510 if (len > 0) { |
125
42a36eb08c8d
* and finaly avoid deadlock at the end of audio stream
kabi
parents:
124
diff
changeset
|
2511 memcpy(s->inbuf_ptr, buf_ptr, len); |
42a36eb08c8d
* and finaly avoid deadlock at the end of audio stream
kabi
parents:
124
diff
changeset
|
2512 buf_ptr += len; |
42a36eb08c8d
* and finaly avoid deadlock at the end of audio stream
kabi
parents:
124
diff
changeset
|
2513 buf_size -= len; |
123 | 2514 s->inbuf_ptr += len; |
2515 } | |
2516 if ((s->inbuf_ptr - s->inbuf) >= HEADER_SIZE) { | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2517 got_header: |
0 | 2518 header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) | |
2519 (s->inbuf[2] << 8) | s->inbuf[3]; | |
143 | 2520 |
2472 | 2521 if (ff_mpa_check_header(header) < 0) { |
0 | 2522 /* no sync found : move by one byte (inefficient, but simple!) */ |
1414 | 2523 memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1); |
0 | 2524 s->inbuf_ptr--; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2525 dprintf("skip %x\n", header); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2526 /* reset free format frame size to give a chance |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2527 to get a new bitrate */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2528 s->free_format_frame_size = 0; |
0 | 2529 } else { |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2530 if (decode_header(s, header) == 1) { |
449
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2531 /* free format: prepare to compute frame size */ |
125
42a36eb08c8d
* and finaly avoid deadlock at the end of audio stream
kabi
parents:
124
diff
changeset
|
2532 s->frame_size = -1; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2533 } |
449
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2534 /* update codec info */ |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2535 avctx->sample_rate = s->sample_rate; |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2536 avctx->channels = s->nb_channels; |
7b2f23b5dcdd
fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents:
440
diff
changeset
|
2537 avctx->bit_rate = s->bit_rate; |
1449
7fbe89a76b73
update sub_id in mpegaudio decoding (might need same method as MPEG2VIDEO too ?)
bellard
parents:
1448
diff
changeset
|
2538 avctx->sub_id = s->layer; |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2539 switch(s->layer) { |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2540 case 1: |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2541 avctx->frame_size = 384; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2542 break; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2543 case 2: |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2544 avctx->frame_size = 1152; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2545 break; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2546 case 3: |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2547 if (s->lsf) |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2548 avctx->frame_size = 576; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2549 else |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2550 avctx->frame_size = 1152; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2551 break; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2552 } |
0 | 2553 } |
2554 } | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2555 } else if (s->frame_size == -1) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2556 /* free format : find next sync to compute frame size */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2557 len = MPA_MAX_CODED_FRAME_SIZE - len; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2558 if (len > buf_size) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2559 len = buf_size; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2560 if (len == 0) { |
602 | 2561 /* frame too long: resync */ |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2562 s->frame_size = 0; |
1414 | 2563 memmove(s->inbuf, s->inbuf + 1, s->inbuf_ptr - s->inbuf - 1); |
602 | 2564 s->inbuf_ptr--; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2565 } else { |
1064 | 2566 uint8_t *p, *pend; |
2567 uint32_t header1; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2568 int padding; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2569 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2570 memcpy(s->inbuf_ptr, buf_ptr, len); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2571 /* check for header */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2572 p = s->inbuf_ptr - 3; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2573 pend = s->inbuf_ptr + len - 4; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2574 while (p <= pend) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2575 header = (p[0] << 24) | (p[1] << 16) | |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2576 (p[2] << 8) | p[3]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2577 header1 = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) | |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2578 (s->inbuf[2] << 8) | s->inbuf[3]; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2579 /* check with high probability that we have a |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2580 valid header */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2581 if ((header & SAME_HEADER_MASK) == |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2582 (header1 & SAME_HEADER_MASK)) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2583 /* header found: update pointers */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2584 len = (p + 4) - s->inbuf_ptr; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2585 buf_ptr += len; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2586 buf_size -= len; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2587 s->inbuf_ptr = p; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2588 /* compute frame size */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2589 s->free_format_next_header = header; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2590 s->free_format_frame_size = s->inbuf_ptr - s->inbuf; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2591 padding = (header1 >> 9) & 1; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2592 if (s->layer == 1) |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2593 s->free_format_frame_size -= padding * 4; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2594 else |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2595 s->free_format_frame_size -= padding; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2596 dprintf("free frame size=%d padding=%d\n", |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2597 s->free_format_frame_size, padding); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2598 decode_header(s, header1); |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2599 goto next_data; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2600 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2601 p++; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2602 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2603 /* not found: simply increase pointers */ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2604 buf_ptr += len; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2605 s->inbuf_ptr += len; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2606 buf_size -= len; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2607 } |
0 | 2608 } else if (len < s->frame_size) { |
124
036ec148fb18
* fixes to avoid crash when broken mp3 header is found
kabi
parents:
123
diff
changeset
|
2609 if (s->frame_size > MPA_MAX_CODED_FRAME_SIZE) |
036ec148fb18
* fixes to avoid crash when broken mp3 header is found
kabi
parents:
123
diff
changeset
|
2610 s->frame_size = MPA_MAX_CODED_FRAME_SIZE; |
0 | 2611 len = s->frame_size - len; |
2612 if (len > buf_size) | |
2613 len = buf_size; | |
2614 memcpy(s->inbuf_ptr, buf_ptr, len); | |
2615 buf_ptr += len; | |
2616 s->inbuf_ptr += len; | |
2617 buf_size -= len; | |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2618 } |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2619 next_data: |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2620 if (s->frame_size > 0 && |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2621 (s->inbuf_ptr - s->inbuf) >= s->frame_size) { |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2622 if (avctx->parse_only) { |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2623 /* simply return the frame data */ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2624 *(uint8_t **)data = s->inbuf; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2625 out_size = s->inbuf_ptr - s->inbuf; |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2626 } else { |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2627 out_size = mp_decode_frame(s, out_samples); |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2628 } |
0 | 2629 s->inbuf_ptr = s->inbuf; |
2630 s->frame_size = 0; | |
2631 *data_size = out_size; | |
2632 break; | |
2633 } | |
2634 } | |
2635 return buf_ptr - buf; | |
2636 } | |
2637 | |
2432 | 2638 |
2639 static int decode_frame_adu(AVCodecContext * avctx, | |
2640 void *data, int *data_size, | |
2641 uint8_t * buf, int buf_size) | |
2642 { | |
2643 MPADecodeContext *s = avctx->priv_data; | |
2644 uint32_t header; | |
2645 int len, out_size; | |
2479 | 2646 OUT_INT *out_samples = data; |
2432 | 2647 |
2648 len = buf_size; | |
2649 | |
2650 // Discard too short frames | |
2651 if (buf_size < HEADER_SIZE) { | |
2652 *data_size = 0; | |
2653 return buf_size; | |
2654 } | |
2655 | |
2656 | |
2657 if (len > MPA_MAX_CODED_FRAME_SIZE) | |
2658 len = MPA_MAX_CODED_FRAME_SIZE; | |
2659 | |
2660 memcpy(s->inbuf, buf, len); | |
2661 s->inbuf_ptr = s->inbuf + len; | |
2662 | |
2663 // Get header and restore sync word | |
2664 header = (s->inbuf[0] << 24) | (s->inbuf[1] << 16) | | |
2665 (s->inbuf[2] << 8) | s->inbuf[3] | 0xffe00000; | |
2666 | |
2472 | 2667 if (ff_mpa_check_header(header) < 0) { // Bad header, discard frame |
2432 | 2668 *data_size = 0; |
2669 return buf_size; | |
2670 } | |
2671 | |
2672 decode_header(s, header); | |
2673 /* update codec info */ | |
2674 avctx->sample_rate = s->sample_rate; | |
2675 avctx->channels = s->nb_channels; | |
2676 avctx->bit_rate = s->bit_rate; | |
2677 avctx->sub_id = s->layer; | |
2678 | |
2679 avctx->frame_size=s->frame_size = len; | |
2680 | |
2681 if (avctx->parse_only) { | |
2682 /* simply return the frame data */ | |
2683 *(uint8_t **)data = s->inbuf; | |
2684 out_size = s->inbuf_ptr - s->inbuf; | |
2685 } else { | |
2686 out_size = mp_decode_frame(s, out_samples); | |
2687 } | |
2688 | |
2689 *data_size = out_size; | |
2690 return buf_size; | |
2691 } | |
2692 | |
2693 | |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2694 /* Next 3 arrays are indexed by channel config number (passed via codecdata) */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2695 static int mp3Frames[16] = {0,1,1,2,3,3,4,5,2}; /* number of mp3 decoder instances */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2696 static int mp3Channels[16] = {0,1,2,3,4,5,6,8,4}; /* total output channels */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2697 /* offsets into output buffer, assume output order is FL FR BL BR C LFE */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2698 static int chan_offset[9][5] = { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2699 {0}, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2700 {0}, // C |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2701 {0}, // FLR |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2702 {2,0}, // C FLR |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2703 {2,0,3}, // C FLR BS |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2704 {4,0,2}, // C FLR BLRS |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2705 {4,0,2,5}, // C FLR BLRS LFE |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2706 {4,0,2,6,5}, // C FLR BLRS BLR LFE |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2707 {0,2} // FLR BLRS |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2708 }; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2709 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2710 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2711 static int decode_init_mp3on4(AVCodecContext * avctx) |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2712 { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2713 MP3On4DecodeContext *s = avctx->priv_data; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2714 int i; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2715 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2716 if ((avctx->extradata_size < 2) || (avctx->extradata == NULL)) { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2717 av_log(avctx, AV_LOG_ERROR, "Codec extradata missing or too short.\n"); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2718 return -1; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2719 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2720 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2721 s->chan_cfg = (((unsigned char *)avctx->extradata)[1] >> 3) & 0x0f; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2722 s->frames = mp3Frames[s->chan_cfg]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2723 if(!s->frames) { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2724 av_log(avctx, AV_LOG_ERROR, "Invalid channel config number.\n"); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2725 return -1; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2726 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2727 avctx->channels = mp3Channels[s->chan_cfg]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2728 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2729 /* Init the first mp3 decoder in standard way, so that all tables get builded |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2730 * We replace avctx->priv_data with the context of the first decoder so that |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2731 * decode_init() does not have to be changed. |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2732 * Other decoders will be inited here copying data from the first context |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2733 */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2734 // Allocate zeroed memory for the first decoder context |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2735 s->mp3decctx[0] = av_mallocz(sizeof(MPADecodeContext)); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2736 // Put decoder context in place to make init_decode() happy |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2737 avctx->priv_data = s->mp3decctx[0]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2738 decode_init(avctx); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2739 // Restore mp3on4 context pointer |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2740 avctx->priv_data = s; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2741 s->mp3decctx[0]->adu_mode = 1; // Set adu mode |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2742 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2743 /* Create a separate codec/context for each frame (first is already ok). |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2744 * Each frame is 1 or 2 channels - up to 5 frames allowed |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2745 */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2746 for (i = 1; i < s->frames; i++) { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2747 s->mp3decctx[i] = av_mallocz(sizeof(MPADecodeContext)); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2748 s->mp3decctx[i]->compute_antialias = s->mp3decctx[0]->compute_antialias; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2749 s->mp3decctx[i]->inbuf = &s->mp3decctx[i]->inbuf1[0][BACKSTEP_SIZE]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2750 s->mp3decctx[i]->inbuf_ptr = s->mp3decctx[i]->inbuf; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2751 s->mp3decctx[i]->adu_mode = 1; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2752 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2753 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2754 return 0; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2755 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2756 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2757 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2758 static int decode_close_mp3on4(AVCodecContext * avctx) |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2759 { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2760 MP3On4DecodeContext *s = avctx->priv_data; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2761 int i; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2762 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2763 for (i = 0; i < s->frames; i++) |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2764 if (s->mp3decctx[i]) |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2765 av_free(s->mp3decctx[i]); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2766 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2767 return 0; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2768 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2769 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2770 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2771 static int decode_frame_mp3on4(AVCodecContext * avctx, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2772 void *data, int *data_size, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2773 uint8_t * buf, int buf_size) |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2774 { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2775 MP3On4DecodeContext *s = avctx->priv_data; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2776 MPADecodeContext *m; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2777 int len, out_size = 0; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2778 uint32_t header; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2779 OUT_INT *out_samples = data; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2780 OUT_INT decoded_buf[MPA_FRAME_SIZE * MPA_MAX_CHANNELS]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2781 OUT_INT *outptr, *bp; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2782 int fsize; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2783 unsigned char *start2 = buf, *start; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2784 int fr, i, j, n; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2785 int off = avctx->channels; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2786 int *coff = chan_offset[s->chan_cfg]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2787 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2788 len = buf_size; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2789 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2790 // Discard too short frames |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2791 if (buf_size < HEADER_SIZE) { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2792 *data_size = 0; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2793 return buf_size; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2794 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2795 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2796 // If only one decoder interleave is not needed |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2797 outptr = s->frames == 1 ? out_samples : decoded_buf; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2798 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2799 for (fr = 0; fr < s->frames; fr++) { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2800 start = start2; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2801 fsize = (start[0] << 4) | (start[1] >> 4); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2802 start2 += fsize; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2803 if (fsize > len) |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2804 fsize = len; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2805 len -= fsize; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2806 if (fsize > MPA_MAX_CODED_FRAME_SIZE) |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2807 fsize = MPA_MAX_CODED_FRAME_SIZE; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2808 m = s->mp3decctx[fr]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2809 assert (m != NULL); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2810 /* copy original to new */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2811 m->inbuf_ptr = m->inbuf + fsize; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2812 memcpy(m->inbuf, start, fsize); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2813 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2814 // Get header |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2815 header = (m->inbuf[0] << 24) | (m->inbuf[1] << 16) | |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2816 (m->inbuf[2] << 8) | m->inbuf[3] | 0xfff00000; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2817 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2818 if (ff_mpa_check_header(header) < 0) { // Bad header, discard block |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2819 *data_size = 0; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2820 return buf_size; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2821 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2822 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2823 decode_header(m, header); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2824 mp_decode_frame(m, decoded_buf); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2825 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2826 n = MPA_FRAME_SIZE * m->nb_channels; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2827 out_size += n * sizeof(OUT_INT); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2828 if(s->frames > 1) { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2829 /* interleave output data */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2830 bp = out_samples + coff[fr]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2831 if(m->nb_channels == 1) { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2832 for(j = 0; j < n; j++) { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2833 *bp = decoded_buf[j]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2834 bp += off; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2835 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2836 } else { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2837 for(j = 0; j < n; j++) { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2838 bp[0] = decoded_buf[j++]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2839 bp[1] = decoded_buf[j]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2840 bp += off; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2841 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2842 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2843 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2844 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2845 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2846 /* update codec info */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2847 avctx->sample_rate = s->mp3decctx[0]->sample_rate; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2848 avctx->frame_size= buf_size; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2849 avctx->bit_rate = 0; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2850 for (i = 0; i < s->frames; i++) |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2851 avctx->bit_rate += s->mp3decctx[i]->bit_rate; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2852 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2853 *data_size = out_size; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2854 return buf_size; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2855 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2856 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2857 |
322 | 2858 AVCodec mp2_decoder = |
0 | 2859 { |
322 | 2860 "mp2", |
0 | 2861 CODEC_TYPE_AUDIO, |
2862 CODEC_ID_MP2, | |
2863 sizeof(MPADecodeContext), | |
2864 decode_init, | |
2865 NULL, | |
2866 NULL, | |
2867 decode_frame, | |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2868 CODEC_CAP_PARSE_ONLY, |
0 | 2869 }; |
322 | 2870 |
2871 AVCodec mp3_decoder = | |
2872 { | |
2873 "mp3", | |
2874 CODEC_TYPE_AUDIO, | |
1448 | 2875 CODEC_ID_MP3, |
322 | 2876 sizeof(MPADecodeContext), |
2877 decode_init, | |
2878 NULL, | |
2879 NULL, | |
2880 decode_frame, | |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
2881 CODEC_CAP_PARSE_ONLY, |
322 | 2882 }; |
2432 | 2883 |
2884 AVCodec mp3adu_decoder = | |
2885 { | |
2886 "mp3adu", | |
2887 CODEC_TYPE_AUDIO, | |
2888 CODEC_ID_MP3ADU, | |
2889 sizeof(MPADecodeContext), | |
2890 decode_init, | |
2891 NULL, | |
2892 NULL, | |
2893 decode_frame_adu, | |
2894 CODEC_CAP_PARSE_ONLY, | |
2895 }; | |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2896 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2897 AVCodec mp3on4_decoder = |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2898 { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2899 "mp3on4", |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2900 CODEC_TYPE_AUDIO, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2901 CODEC_ID_MP3ON4, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2902 sizeof(MP3On4DecodeContext), |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2903 decode_init_mp3on4, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2904 NULL, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2905 decode_close_mp3on4, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2906 decode_frame_mp3on4, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2907 0 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2908 }; |