Mercurial > libavcodec.hg
annotate mpegaudiodec.c @ 3726:49fb1958d8e1 libavcodec
clean up #ifdef HAVE_IPP
author | mru |
---|---|
date | Fri, 15 Sep 2006 23:20:58 +0000 |
parents | 0da2c9abe11b |
children | 2c0b93338765 |
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 | |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
3023
diff
changeset
|
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 */ |
1106 | 19 |
20 /** | |
21 * @file mpegaudiodec.c | |
22 * MPEG Audio decoder. | |
2967 | 23 */ |
1106 | 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" |
1734
8aace334bcf0
lrintf patch by ("Steven M. Schultz" <sms at 2BSD dot COM>)
michael
parents:
1733
diff
changeset
|
28 #include "dsputil.h" |
0 | 29 |
30 /* | |
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
|
31 * 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
|
32 * - 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
|
33 * - test lsf / mpeg25 extensively. |
0 | 34 */ |
35 | |
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
|
36 /* 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
|
37 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
|
38 #ifdef CONFIG_MPEGAUDIO_HP |
3602 | 39 # define USE_HIGHPRECISION |
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
|
40 #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
|
41 |
2913 | 42 #include "mpegaudio.h" |
2479 | 43 |
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
|
44 #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
|
45 |
3603 | 46 #ifdef ARCH_X86 |
3604
dad0296d4522
replace MULL with asm too, no significnat speedup but its probably better to not take any chances, some versions of gcc will almost certainly mess it up too if they can
michael
parents:
3603
diff
changeset
|
47 # define MULL(ra, rb) \ |
dad0296d4522
replace MULL with asm too, no significnat speedup but its probably better to not take any chances, some versions of gcc will almost certainly mess it up too if they can
michael
parents:
3603
diff
changeset
|
48 ({ int rt, dummy; asm (\ |
dad0296d4522
replace MULL with asm too, no significnat speedup but its probably better to not take any chances, some versions of gcc will almost certainly mess it up too if they can
michael
parents:
3603
diff
changeset
|
49 "imull %3 \n\t"\ |
dad0296d4522
replace MULL with asm too, no significnat speedup but its probably better to not take any chances, some versions of gcc will almost certainly mess it up too if they can
michael
parents:
3603
diff
changeset
|
50 "shrdl %4, %%edx, %%eax \n\t"\ |
dad0296d4522
replace MULL with asm too, no significnat speedup but its probably better to not take any chances, some versions of gcc will almost certainly mess it up too if they can
michael
parents:
3603
diff
changeset
|
51 : "=a"(rt), "=d"(dummy)\ |
dad0296d4522
replace MULL with asm too, no significnat speedup but its probably better to not take any chances, some versions of gcc will almost certainly mess it up too if they can
michael
parents:
3603
diff
changeset
|
52 : "a" (ra), "rm" (rb), "i"(FRAC_BITS));\ |
dad0296d4522
replace MULL with asm too, no significnat speedup but its probably better to not take any chances, some versions of gcc will almost certainly mess it up too if they can
michael
parents:
3603
diff
changeset
|
53 rt; }) |
3603 | 54 # define MUL64(ra, rb) \ |
55 ({ int64_t rt; asm ("imull %2\n\t" : "=A"(rt) : "a" (ra), "g" (rb)); rt; }) | |
56 # define MULH(ra, rb) \ | |
57 ({ int rt, dummy; asm ("imull %3\n\t" : "=d"(rt), "=a"(dummy): "a" (ra), "rm" (rb)); rt; }) | |
3605
6702a154df1f
MUL* for ARM code based on a patch by Siarhei Siamashka
michael
parents:
3604
diff
changeset
|
58 #elif defined(ARCH_ARMV4L) |
6702a154df1f
MUL* for ARM code based on a patch by Siarhei Siamashka
michael
parents:
3604
diff
changeset
|
59 # define MULL(a, b) \ |
6702a154df1f
MUL* for ARM code based on a patch by Siarhei Siamashka
michael
parents:
3604
diff
changeset
|
60 ({ int lo, hi;\ |
6702a154df1f
MUL* for ARM code based on a patch by Siarhei Siamashka
michael
parents:
3604
diff
changeset
|
61 asm("smull %0, %1, %2, %3 \n\t"\ |
3607 | 62 "mov %0, %0, lsr %4\n\t"\ |
63 "add %1, %0, %1, lsl %5\n\t"\ | |
64 : "=&r"(lo), "=&r"(hi)\ | |
3605
6702a154df1f
MUL* for ARM code based on a patch by Siarhei Siamashka
michael
parents:
3604
diff
changeset
|
65 : "r"(b), "r"(a), "i"(FRAC_BITS), "i"(32-FRAC_BITS));\ |
6702a154df1f
MUL* for ARM code based on a patch by Siarhei Siamashka
michael
parents:
3604
diff
changeset
|
66 hi; }) |
6702a154df1f
MUL* for ARM code based on a patch by Siarhei Siamashka
michael
parents:
3604
diff
changeset
|
67 # define MUL64(a,b) ((int64_t)(a) * (int64_t)(b)) |
3607 | 68 # define MULH(a, b) ({ int lo, hi; asm ("smull %0, %1, %2, %3" : "=&r"(lo), "=&r"(hi) : "r"(b), "r"(a)); hi; }) |
3603 | 69 #else |
70 # define MULL(a,b) (((int64_t)(a) * (int64_t)(b)) >> FRAC_BITS) | |
71 # define MUL64(a,b) ((int64_t)(a) * (int64_t)(b)) | |
72 //#define MULH(a,b) (((int64_t)(a) * (int64_t)(b))>>32) //gcc 3.4 creates an incredibly bloated mess out of this | |
73 static always_inline int MULH(int a, int b){ | |
74 return ((int64_t)(a) * (int64_t)(b))>>32; | |
75 } | |
76 #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
|
77 #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
|
78 /* 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
|
79 #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
|
80 #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
|
81 |
2489 | 82 #define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5)) |
83 | |
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
|
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 | |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
88 #define EXTRABYTES 24 |
0 | 89 |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
90 struct GranuleDef; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
91 |
0 | 92 typedef struct MPADecodeContext { |
3647 | 93 DECLARE_ALIGNED_8(uint8_t, last_buf[2*BACKSTEP_SIZE + EXTRABYTES]); |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
94 int last_buf_size; |
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 /* next header (used in free format parsing) */ |
2967 | 97 uint32_t free_format_next_header; |
0 | 98 int error_protection; |
99 int layer; | |
100 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
|
101 int sample_rate_index; /* between 0 and 8 */ |
0 | 102 int bit_rate; |
103 GetBitContext gb; | |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
104 GetBitContext in_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
|
105 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
|
106 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
|
107 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
|
108 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
|
109 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
|
110 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
|
111 int32_t sb_samples[MPA_MAX_CHANNELS][36][SBLIMIT] __attribute__((aligned(16))); |
1064 | 112 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
|
113 #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
|
114 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
|
115 #endif |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
116 void (*compute_antialias)(struct MPADecodeContext *s, struct GranuleDef *g); |
2432 | 117 int adu_mode; ///< 0 for standard mp3, 1 for adu formatted mp3 |
2472 | 118 unsigned int dither_state; |
0 | 119 } MPADecodeContext; |
120 | |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
121 /** |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
122 * Context for MP3On4 decoder |
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 typedef struct MP3On4DecodeContext { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
125 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
|
126 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
|
127 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
|
128 } MP3On4DecodeContext; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
129 |
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
|
130 /* 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
|
131 typedef struct GranuleDef { |
1064 | 132 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
|
133 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
|
134 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
|
135 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
|
136 int scalefac_compress; |
1064 | 137 uint8_t block_type; |
138 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
|
139 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
|
140 int subblock_gain[3]; |
1064 | 141 uint8_t scalefac_scale; |
142 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
|
143 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
|
144 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
|
145 int short_start, long_end; /* long/short band indexes */ |
1064 | 146 uint8_t scale_factors[40]; |
147 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
|
148 } 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
|
149 |
46ee548e47e4
added 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 #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
|
151 #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
|
152 |
46ee548e47e4
added 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 /* 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
|
154 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
|
155 int xsize; |
1064 | 156 const uint8_t *bits; |
157 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
|
158 } 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
|
159 |
46ee548e47e4
added 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 #include "mpegaudiodectab.h" |
0 | 161 |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
162 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
|
163 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
|
164 |
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
|
165 /* vlc structure for decoding layer 3 huffman tables */ |
2967 | 166 static VLC huff_vlc[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
|
167 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
|
168 /* computed from band_size_long */ |
1064 | 169 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
|
170 /* XXX: free when all decoders are closed */ |
2490 | 171 #define TABLE_4_3_SIZE (8191 + 16)*4 |
1064 | 172 static int8_t *table_4_3_exp; |
173 static uint32_t *table_4_3_value; | |
3621 | 174 static uint32_t exp_table[512]; |
3622 | 175 static uint32_t expval_table[512][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
|
176 /* intensity stereo coef table */ |
1064 | 177 static int32_t is_table[2][16]; |
178 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
|
179 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
|
180 static float csa_table_float[8][4]; |
1064 | 181 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
|
182 |
46ee548e47e4
added 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 /* lower 2 bits: modulo 3, higher bits: shift */ |
1064 | 184 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
|
185 /* [i][j]: 2^(-j/3) * FRAC_ONE * 2^(i+2) / (2^(i+2) - 1) */ |
1064 | 186 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
|
187 /* 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
|
188 |
46ee548e47e4
added 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 #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
|
190 { 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
|
191 |
2753 | 192 static const 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
|
193 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
|
194 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
|
195 SCALE_GEN(4.0 / 9.0), /* 9 steps */ |
0 | 196 }; |
197 | |
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
|
198 static MPA_INT window[512] __attribute__((aligned(16))); |
2967 | 199 |
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
|
200 /* 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
|
201 /* 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
|
202 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
|
203 { |
46ee548e47e4
added 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 int shift, mod; |
1064 | 205 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
|
206 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
207 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
|
208 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
|
209 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
|
210 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
|
211 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
|
212 /* 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
|
213 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
|
214 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
215 |
46ee548e47e4
added 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 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
|
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 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
|
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 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
|
221 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
|
222 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
|
223 |
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
|
224 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
|
225 /* 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
|
226 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
|
227 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
|
228 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
|
229 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
230 |
46ee548e47e4
added 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 /* 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
|
232 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
|
233 { |
46ee548e47e4
added 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 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
|
235 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
|
236 |
2490 | 237 e = table_4_3_exp [4*value + (exponent&3)]; |
238 m = table_4_3_value[4*value + (exponent&3)]; | |
239 e -= (exponent >> 2); | |
240 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
|
241 if (e > 31) |
2478 | 242 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
|
243 m = (m + (1 << (e-1))) >> e; |
2490 | 244 |
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 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
|
246 } |
46ee548e47e4
added 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 |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
248 /* 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
|
249 #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
|
250 |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
251 #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
|
252 #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
|
253 #define POW_FIX(a) ((int)((a) * POW_FRAC_ONE)) |
1064 | 254 #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
|
255 |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
256 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
|
257 |
2522
e25782262d7d
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
2507
diff
changeset
|
258 #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
|
259 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
|
260 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
|
261 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
|
262 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
|
263 }; |
2522
e25782262d7d
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
2507
diff
changeset
|
264 #endif |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
265 |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
266 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
|
267 { |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
268 int i, a; |
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 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
|
271 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
|
272 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
|
273 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
|
274 } |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
275 } |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
276 |
2522
e25782262d7d
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
2507
diff
changeset
|
277 #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
|
278 /* 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
|
279 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
|
280 { |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
281 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
|
282 int a, a1; |
2967 | 283 |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
284 /* renormalize */ |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
285 a = i; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
286 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
|
287 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
|
288 a = a << 1; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
289 e--; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
290 } |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
291 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
|
292 a1 = 0; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
293 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
|
294 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
|
295 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
|
296 /* exponent compute (exact) */ |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
297 e = e * 4; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
298 er = e % 3; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
299 eq = e / 3; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
300 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
|
301 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
|
302 a = a >> 1; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
303 eq++; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
304 } |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
305 /* convert to float */ |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
306 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
|
307 a = a << 1; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
308 eq--; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
309 } |
407
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
310 /* 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
|
311 #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
|
312 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
|
313 /* correct overflow */ |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
314 if (a >= 2 * (1 << FRAC_BITS)) { |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
315 a = a >> 1; |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
316 eq++; |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
317 } |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
318 #endif |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
319 *exp_ptr = eq; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
320 return a; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
321 } |
2522
e25782262d7d
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
2507
diff
changeset
|
322 #endif |
0 | 323 |
324 static int decode_init(AVCodecContext * avctx) | |
325 { | |
326 MPADecodeContext *s = avctx->priv_data; | |
836
932eb34d17c1
vc++ sucks, found by ("csharprules" <csharprules at hotmail dot com>)
michaelni
parents:
602
diff
changeset
|
327 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
|
328 int i, j, k; |
0 | 329 |
2911
7f2959d05900
Reverse patch 1.59->1.60, it break mp3 in ffplay and ffmpeg
rtognimp
parents:
2903
diff
changeset
|
330 #if defined(USE_HIGHPRECISION) && defined(CONFIG_AUDIO_NONSHORT) |
2479 | 331 avctx->sample_fmt= SAMPLE_FMT_S32; |
332 #else | |
333 avctx->sample_fmt= SAMPLE_FMT_S16; | |
2967 | 334 #endif |
335 | |
2491 | 336 if(avctx->antialias_algo != FF_AA_FLOAT) |
1762 | 337 s->compute_antialias= compute_antialias_integer; |
338 else | |
339 s->compute_antialias= compute_antialias_float; | |
340 | |
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
|
341 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
|
342 /* 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
|
343 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
|
344 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
|
345 /* 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
|
346 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
|
347 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
|
348 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
|
349 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 /* 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
|
352 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
|
353 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
|
354 n = i + 2; |
1064 | 355 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
|
356 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
|
357 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
|
358 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
|
359 dprintf("%d: norm=%x s=%x %x %x\n", |
2967 | 360 i, 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 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
|
362 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
|
363 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
|
364 } |
2967 | 365 |
2979 | 366 ff_mpa_synth_init(window); |
2967 | 367 |
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
|
368 /* 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
|
369 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
|
370 const HuffTable *h = &mpa_huff_tables[i]; |
2979 | 371 int xsize, x, y; |
1057 | 372 unsigned int n; |
3627 | 373 uint8_t tmp_bits [512]; |
374 uint16_t tmp_codes[512]; | |
3608 | 375 |
376 memset(tmp_bits , 0, sizeof(tmp_bits )); | |
377 memset(tmp_codes, 0, sizeof(tmp_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
|
378 |
46ee548e47e4
added 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 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
|
380 n = xsize * xsize; |
2967 | 381 |
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
|
382 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
|
383 for(x=0;x<xsize;x++) { |
3608 | 384 for(y=0;y<xsize;y++){ |
3627 | 385 tmp_bits [(x << 5) | y | ((x&&y)<<4)]= h->bits [j ]; |
386 tmp_codes[(x << 5) | y | ((x&&y)<<4)]= h->codes[j++]; | |
3608 | 387 } |
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
|
388 } |
3608 | 389 |
390 /* XXX: fail test */ | |
3627 | 391 init_vlc(&huff_vlc[i], 7, 512, |
3608 | 392 tmp_bits, 1, 1, tmp_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
|
393 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
394 for(i=0;i<2;i++) { |
2967 | 395 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
|
396 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
|
397 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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(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
|
400 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
|
401 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
|
402 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
|
403 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
|
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 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
|
406 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
407 |
2979 | 408 /* compute n ^ (4/3) and store it in mantissa/exp format */ |
409 table_4_3_exp= av_mallocz_static(TABLE_4_3_SIZE * sizeof(table_4_3_exp[0])); | |
1900
5cde80c5d929
static allocation rewrite (old code was plain a broken mess)
michael
parents:
1780
diff
changeset
|
410 if(!table_4_3_exp) |
2979 | 411 return -1; |
412 table_4_3_value= av_mallocz_static(TABLE_4_3_SIZE * sizeof(table_4_3_value[0])); | |
1900
5cde80c5d929
static allocation rewrite (old code was plain a broken mess)
michael
parents:
1780
diff
changeset
|
413 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
|
414 return -1; |
2967 | 415 |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
416 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
|
417 for(i=1;i<TABLE_4_3_SIZE;i++) { |
2490 | 418 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
|
419 int e, m; |
2490 | 420 f = pow((double)(i/4), 4.0 / 3.0) * pow(2, (i&3)*0.25); |
421 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
|
422 m = (uint32_t)(fm*(1LL<<31) + 0.5); |
3625 | 423 e+= FRAC_BITS - 31 + 5 - 100; |
2490 | 424 |
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
|
425 /* 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
|
426 table_4_3_value[i] = m; |
2490 | 427 // av_log(NULL, AV_LOG_DEBUG, "%d %d %f\n", i, m, pow((double)i, 4.0 / 3.0)); |
428 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
|
429 } |
3622 | 430 for(i=0; i<512*16; i++){ |
3625 | 431 int exponent= (i>>4); |
432 double f= pow(i&15, 4.0 / 3.0) * pow(2, (exponent-400)*0.25 + FRAC_BITS + 5); | |
433 expval_table[exponent][i&15]= lrintf(f); | |
3622 | 434 if((i&15)==1) |
3625 | 435 exp_table[exponent]= lrintf(f); |
3621 | 436 } |
2967 | 437 |
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
|
438 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
|
439 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
|
440 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
|
441 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
|
442 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
|
443 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
|
444 } 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
|
445 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
|
446 } |
46ee548e47e4
added 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 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
|
448 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
|
449 } |
46ee548e47e4
added 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 /* 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
|
451 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
|
452 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
|
453 |
46ee548e47e4
added 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 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
|
455 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
|
456 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
|
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 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
|
459 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
|
460 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
|
461 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
|
462 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
|
463 is_table_lsf[j][k][i] = FIXR(1.0); |
2967 | 464 dprintf("is_table_lsf %d %d: %x %x\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
|
465 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
|
466 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
467 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
468 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
469 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
|
470 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
|
471 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
|
472 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
|
473 ca = cs * ci; |
2491 | 474 csa_table[i][0] = FIXHR(cs/4); |
475 csa_table[i][1] = FIXHR(ca/4); | |
476 csa_table[i][2] = FIXHR(ca/4) + FIXHR(cs/4); | |
2967 | 477 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
|
478 csa_table_float[i][0] = cs; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
479 csa_table_float[i][1] = ca; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
480 csa_table_float[i][2] = ca + cs; |
2967 | 481 csa_table_float[i][3] = ca - cs; |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
482 // printf("%d %d %d %d\n", FIX(cs), FIX(cs-1), FIX(ca), FIX(cs)-FIX(ca)); |
2489 | 483 // 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
|
484 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
485 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
486 /* 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
|
487 for(i=0;i<36;i++) { |
2489 | 488 for(j=0; j<4; j++){ |
489 double d; | |
2967 | 490 |
2495 | 491 if(j==2 && i%3 != 1) |
492 continue; | |
2967 | 493 |
2489 | 494 d= sin(M_PI * (i + 0.5) / 36.0); |
495 if(j==1){ | |
496 if (i>=30) d= 0; | |
497 else if(i>=24) d= sin(M_PI * (i - 18 + 0.5) / 12.0); | |
498 else if(i>=18) d= 1; | |
499 }else if(j==3){ | |
500 if (i< 6) d= 0; | |
501 else if(i< 12) d= sin(M_PI * (i - 6 + 0.5) / 12.0); | |
502 else if(i< 18) d= 1; | |
503 } | |
504 //merge last stage of imdct into the window coefficients | |
2495 | 505 d*= 0.5 / cos(M_PI*(2*i + 19)/72); |
506 | |
507 if(j==2) | |
508 mdct_win[j][i/3] = FIXHR((d / (1<<5))); | |
509 else | |
510 mdct_win[j][i ] = FIXHR((d / (1<<5))); | |
2489 | 511 // av_log(NULL, AV_LOG_DEBUG, "%2d %d %f\n", i,j,d / (1<<5)); |
512 } | |
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
|
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 /* 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
|
516 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
|
517 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
|
518 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
|
519 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
|
520 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
|
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 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
523 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
524 #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
|
525 for(j=0;j<8;j++) { |
3177 | 526 av_log(avctx, AV_LOG_DEBUG, "win%d=\n", 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
|
527 for(i=0;i<36;i++) |
3177 | 528 av_log(avctx, AV_LOG_DEBUG, "%f, ", (double)mdct_win[j][i] / FRAC_ONE); |
529 av_log(avctx, 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
|
530 } |
46ee548e47e4
added 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 |
0 | 532 init = 1; |
533 } | |
534 | |
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
|
535 #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
|
536 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
|
537 #endif |
2432 | 538 if (avctx->codec_id == CODEC_ID_MP3ADU) |
539 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
|
540 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
|
541 } |
46ee548e47e4
added 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 |
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
|
543 /* 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
|
544 |
46ee548e47e4
added 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 /* 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
|
546 |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
547 #define COS0_0 FIXHR(0.50060299823519630134/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
548 #define COS0_1 FIXHR(0.50547095989754365998/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
549 #define COS0_2 FIXHR(0.51544730992262454697/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
550 #define COS0_3 FIXHR(0.53104259108978417447/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
551 #define COS0_4 FIXHR(0.55310389603444452782/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
552 #define COS0_5 FIXHR(0.58293496820613387367/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
553 #define COS0_6 FIXHR(0.62250412303566481615/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
554 #define COS0_7 FIXHR(0.67480834145500574602/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
555 #define COS0_8 FIXHR(0.74453627100229844977/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
556 #define COS0_9 FIXHR(0.83934964541552703873/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
557 #define COS0_10 FIXHR(0.97256823786196069369/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
558 #define COS0_11 FIXHR(1.16943993343288495515/4) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
559 #define COS0_12 FIXHR(1.48416461631416627724/4) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
560 #define COS0_13 FIXHR(2.05778100995341155085/8) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
561 #define COS0_14 FIXHR(3.40760841846871878570/8) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
562 #define COS0_15 FIXHR(10.19000812354805681150/32) |
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
|
563 |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
564 #define COS1_0 FIXHR(0.50241928618815570551/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
565 #define COS1_1 FIXHR(0.52249861493968888062/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
566 #define COS1_2 FIXHR(0.56694403481635770368/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
567 #define COS1_3 FIXHR(0.64682178335999012954/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
568 #define COS1_4 FIXHR(0.78815462345125022473/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
569 #define COS1_5 FIXHR(1.06067768599034747134/4) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
570 #define COS1_6 FIXHR(1.72244709823833392782/4) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
571 #define COS1_7 FIXHR(5.10114861868916385802/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
|
572 |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
573 #define COS2_0 FIXHR(0.50979557910415916894/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
574 #define COS2_1 FIXHR(0.60134488693504528054/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
575 #define COS2_2 FIXHR(0.89997622313641570463/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
576 #define COS2_3 FIXHR(2.56291544774150617881/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
|
577 |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
578 #define COS3_0 FIXHR(0.54119610014619698439/2) |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
579 #define COS3_1 FIXHR(1.30656296487637652785/4) |
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
|
580 |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
581 #define COS4_0 FIXHR(0.70710678118654752439/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
|
582 |
46ee548e47e4
added 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 /* butterfly operator */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
584 #define BF(a, b, c, 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
|
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 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
|
587 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
|
588 tab[a] = tmp0;\ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
589 tab[b] = MULH(tmp1<<(s), c);\ |
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
|
590 } |
46ee548e47e4
added 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 #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
|
593 {\ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
594 BF(a, b, COS4_0, 1);\ |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
595 BF(c, d,-COS4_0, 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
|
596 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
|
597 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 #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
|
600 {\ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
601 BF(a, b, COS4_0, 1);\ |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
602 BF(c, d,-COS4_0, 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
|
603 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
|
604 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
|
605 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
|
606 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
|
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 |
46ee548e47e4
added 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 #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
|
610 |
46ee548e47e4
added 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 /* DCT32 without 1/sqrt(2) coef zero scaling. */ |
1064 | 612 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
|
613 { |
46ee548e47e4
added 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 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
|
615 |
46ee548e47e4
added 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 /* pass 1 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
617 BF( 0, 31, COS0_0 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
618 BF(15, 16, COS0_15, 5); |
3598 | 619 /* pass 2 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
620 BF( 0, 15, COS1_0 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
621 BF(16, 31,-COS1_0 , 1); |
3598 | 622 /* pass 1 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
623 BF( 7, 24, COS0_7 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
624 BF( 8, 23, COS0_8 , 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
|
625 /* pass 2 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
626 BF( 7, 8, COS1_7 , 4); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
627 BF(23, 24,-COS1_7 , 4); |
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
|
628 /* pass 3 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
629 BF( 0, 7, COS2_0 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
630 BF( 8, 15,-COS2_0 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
631 BF(16, 23, COS2_0 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
632 BF(24, 31,-COS2_0 , 1); |
3598 | 633 /* pass 1 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
634 BF( 3, 28, COS0_3 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
635 BF(12, 19, COS0_12, 2); |
3598 | 636 /* pass 2 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
637 BF( 3, 12, COS1_3 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
638 BF(19, 28,-COS1_3 , 1); |
3598 | 639 /* pass 1 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
640 BF( 4, 27, COS0_4 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
641 BF(11, 20, COS0_11, 2); |
3598 | 642 /* pass 2 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
643 BF( 4, 11, COS1_4 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
644 BF(20, 27,-COS1_4 , 1); |
3598 | 645 /* pass 3 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
646 BF( 3, 4, COS2_3 , 3); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
647 BF(11, 12,-COS2_3 , 3); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
648 BF(19, 20, COS2_3 , 3); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
649 BF(27, 28,-COS2_3 , 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
|
650 /* pass 4 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
651 BF( 0, 3, COS3_0 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
652 BF( 4, 7,-COS3_0 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
653 BF( 8, 11, COS3_0 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
654 BF(12, 15,-COS3_0 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
655 BF(16, 19, COS3_0 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
656 BF(20, 23,-COS3_0 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
657 BF(24, 27, COS3_0 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
658 BF(28, 31,-COS3_0 , 1); |
2967 | 659 |
660 | |
661 | |
3598 | 662 /* pass 1 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
663 BF( 1, 30, COS0_1 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
664 BF(14, 17, COS0_14, 3); |
3598 | 665 /* pass 2 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
666 BF( 1, 14, COS1_1 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
667 BF(17, 30,-COS1_1 , 1); |
3598 | 668 /* pass 1 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
669 BF( 6, 25, COS0_6 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
670 BF( 9, 22, COS0_9 , 1); |
3598 | 671 /* pass 2 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
672 BF( 6, 9, COS1_6 , 2); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
673 BF(22, 25,-COS1_6 , 2); |
3598 | 674 /* pass 3 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
675 BF( 1, 6, COS2_1 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
676 BF( 9, 14,-COS2_1 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
677 BF(17, 22, COS2_1 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
678 BF(25, 30,-COS2_1 , 1); |
3598 | 679 |
680 /* pass 1 */ | |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
681 BF( 2, 29, COS0_2 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
682 BF(13, 18, COS0_13, 3); |
3598 | 683 /* pass 2 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
684 BF( 2, 13, COS1_2 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
685 BF(18, 29,-COS1_2 , 1); |
3598 | 686 /* pass 1 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
687 BF( 5, 26, COS0_5 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
688 BF(10, 21, COS0_10, 1); |
3598 | 689 /* pass 2 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
690 BF( 5, 10, COS1_5 , 2); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
691 BF(21, 26,-COS1_5 , 2); |
3598 | 692 /* pass 3 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
693 BF( 2, 5, COS2_2 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
694 BF(10, 13,-COS2_2 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
695 BF(18, 21, COS2_2 , 1); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
696 BF(26, 29,-COS2_2 , 1); |
3598 | 697 /* pass 4 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
698 BF( 1, 2, COS3_1 , 2); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
699 BF( 5, 6,-COS3_1 , 2); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
700 BF( 9, 10, COS3_1 , 2); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
701 BF(13, 14,-COS3_1 , 2); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
702 BF(17, 18, COS3_1 , 2); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
703 BF(21, 22,-COS3_1 , 2); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
704 BF(25, 26, COS3_1 , 2); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
705 BF(29, 30,-COS3_1 , 2); |
2967 | 706 |
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
|
707 /* pass 5 */ |
3600
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
708 BF1( 0, 1, 2, 3); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
709 BF2( 4, 5, 6, 7); |
949219039897
replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents:
3599
diff
changeset
|
710 BF1( 8, 9, 10, 11); |
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
|
711 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
|
712 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
|
713 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
|
714 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
|
715 BF2(28, 29, 30, 31); |
2967 | 716 |
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
|
717 /* pass 6 */ |
2967 | 718 |
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
|
719 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
|
720 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
|
721 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
|
722 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
|
723 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
|
724 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
|
725 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
|
726 |
46ee548e47e4
added 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[ 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
|
728 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
|
729 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
|
730 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
|
731 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
|
732 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
|
733 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
|
734 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
|
735 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
|
736 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
|
737 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
|
738 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
|
739 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
|
740 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
|
741 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
|
742 out[30] = tab[15]; |
2967 | 743 |
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
|
744 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
|
745 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
|
746 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
|
747 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
|
748 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
|
749 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
|
750 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
|
751 |
46ee548e47e4
added 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[ 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
|
753 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
|
754 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
|
755 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
|
756 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
|
757 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
|
758 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
|
759 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
|
760 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
|
761 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
|
762 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
|
763 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
|
764 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
|
765 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
|
766 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
|
767 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
|
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 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
770 #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
|
771 |
2472 | 772 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
|
773 { |
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 int sum1; |
2472 | 775 sum1 = (*sum) >> OUT_SHIFT; |
776 *sum &= (1<<OUT_SHIFT)-1; | |
2479 | 777 if (sum1 < OUT_MIN) |
778 sum1 = OUT_MIN; | |
779 else if (sum1 > OUT_MAX) | |
780 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
|
781 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
|
782 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
783 |
3602 | 784 # if defined(ARCH_POWERPC_405) |
785 /* signed 16x16 -> 32 multiply add accumulate */ | |
786 # define MACS(rt, ra, rb) \ | |
787 asm ("maclhw %0, %2, %3" : "=r" (rt) : "0" (rt), "r" (ra), "r" (rb)); | |
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
|
788 |
3602 | 789 /* signed 16x16 -> 32 multiply */ |
790 # define MULS(ra, rb) \ | |
791 ({ int __rt; asm ("mullhw %0, %1, %2" : "=r" (__rt) : "r" (ra), "r" (rb)); __rt; }) | |
3705 | 792 |
3716 | 793 # elif defined(HAVE_ARMV5TE) |
3705 | 794 |
795 /* signed 16x16 -> 32 multiply add accumulate */ | |
796 # define MACS(rt, ra, rb) \ | |
797 asm ("smlabb %0, %2, %3, %0" : "=r" (rt) : "0" (rt), "r" (ra), "r" (rb)); | |
798 | |
799 /* signed 16x16 -> 32 multiply */ | |
800 # define MULS(ra, rb) \ | |
801 ({ int __rt; asm ("smulbb %0, %1, %2" : "=r" (__rt) : "r" (ra), "r" (rb)); __rt; }) | |
802 | |
3602 | 803 # else |
804 /* signed 16x16 -> 32 multiply add accumulate */ | |
805 # define MACS(rt, ra, rb) rt += (ra) * (rb) | |
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
|
806 |
3602 | 807 /* signed 16x16 -> 32 multiply */ |
808 # define MULS(ra, rb) ((ra) * (rb)) | |
809 # 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
|
810 #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
|
811 |
2967 | 812 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
|
813 { |
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 int sum1; |
2472 | 815 sum1 = (int)((*sum) >> OUT_SHIFT); |
816 *sum &= (1<<OUT_SHIFT)-1; | |
2479 | 817 if (sum1 < OUT_MIN) |
818 sum1 = OUT_MIN; | |
819 else if (sum1 > OUT_MAX) | |
820 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
|
821 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
|
822 } |
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 |
3603 | 824 # define MULS(ra, rb) MUL64(ra, rb) |
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
|
825 #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
|
826 |
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 #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
|
828 { \ |
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 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
|
830 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
|
831 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
|
832 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
|
833 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
|
834 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
|
835 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
|
836 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
|
837 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
838 |
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
|
839 #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
|
840 { \ |
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
|
841 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
|
842 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
|
843 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
|
844 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
|
845 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
|
846 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
|
847 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
|
848 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
|
849 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
|
850 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
|
851 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
|
852 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
|
853 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
|
854 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
|
855 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
|
856 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
|
857 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
|
858 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
|
859 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
|
860 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
|
861 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
|
862 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
|
863 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
|
864 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
|
865 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
|
866 } |
46ee548e47e4
added 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 |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
868 void ff_mpa_synth_init(MPA_INT *window) |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
869 { |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
870 int i; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
871 |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
872 /* max = 18760, max sum over all 16 coefs : 44736 */ |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
873 for(i=0;i<257;i++) { |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
874 int v; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
875 v = mpa_enwindow[i]; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
876 #if WFRAC_BITS < 16 |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
877 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
|
878 #endif |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
879 window[i] = v; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
880 if ((i & 63) != 0) |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
881 v = -v; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
882 if (i != 0) |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
883 window[512 - i] = v; |
2967 | 884 } |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
885 } |
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
|
886 |
46ee548e47e4
added 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 /* 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
|
888 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
|
889 /* XXX: optimize by avoiding ring buffer usage */ |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
890 void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset, |
2979 | 891 MPA_INT *window, int *dither_state, |
2967 | 892 OUT_INT *samples, int incr, |
1064 | 893 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
|
894 { |
1064 | 895 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
|
896 register MPA_INT *synth_buf; |
2100 | 897 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
|
898 int j, offset, v; |
2479 | 899 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
|
900 #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
|
901 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
|
902 #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
|
903 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
|
904 #endif |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
905 |
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
|
906 dct32(tmp, sb_samples); |
2967 | 907 |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
908 offset = *synth_buf_offset; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
909 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
|
910 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
911 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
|
912 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
|
913 #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
|
914 /* 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
|
915 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
|
916 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
|
917 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
|
918 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
|
919 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
|
920 #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
|
921 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
|
922 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
923 /* 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
|
924 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
|
925 |
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
|
926 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
|
927 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
|
928 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
|
929 |
2473 | 930 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
|
931 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
|
932 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
|
933 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
|
934 SUM8(sum, -=, w + 32, p); |
2472 | 935 *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
|
936 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
|
937 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
|
938 |
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 /* 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
|
940 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
|
941 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
|
942 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
|
943 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
|
944 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
|
945 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
|
946 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
|
947 |
2472 | 948 *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
|
949 samples += incr; |
2472 | 950 sum += sum2; |
951 *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
|
952 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
|
953 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
|
954 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
|
955 } |
2967 | 956 |
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
|
957 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
|
958 SUM8(sum, -=, w + 32, p); |
2472 | 959 *samples = round_sample(&sum); |
2473 | 960 *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
|
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 offset = (offset - 32) & 511; |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
963 *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
|
964 } |
46ee548e47e4
added 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 #define C3 FIXHR(0.86602540378443864676/2) |
967 | |
968 /* 0.5 / cos(pi*(2*i+1)/36) */ | |
969 static const int icos36[9] = { | |
970 FIXR(0.50190991877167369479), | |
971 FIXR(0.51763809020504152469), //0 | |
972 FIXR(0.55168895948124587824), | |
973 FIXR(0.61038729438072803416), | |
974 FIXR(0.70710678118654752439), //1 | |
975 FIXR(0.87172339781054900991), | |
976 FIXR(1.18310079157624925896), | |
977 FIXR(1.93185165257813657349), //2 | |
978 FIXR(5.73685662283492756461), | |
979 }; | |
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
|
980 |
3599 | 981 /* 0.5 / cos(pi*(2*i+1)/36) */ |
982 static const int icos36h[9] = { | |
983 FIXHR(0.50190991877167369479/2), | |
984 FIXHR(0.51763809020504152469/2), //0 | |
985 FIXHR(0.55168895948124587824/2), | |
986 FIXHR(0.61038729438072803416/2), | |
987 FIXHR(0.70710678118654752439/2), //1 | |
988 FIXHR(0.87172339781054900991/2), | |
989 FIXHR(1.18310079157624925896/4), | |
990 FIXHR(1.93185165257813657349/4), //2 | |
991 // FIXHR(5.73685662283492756461), | |
992 }; | |
993 | |
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
|
994 /* 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
|
995 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
|
996 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
|
997 { |
2495 | 998 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
|
999 |
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
1000 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
|
1001 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
|
1002 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
|
1003 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
|
1004 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
|
1005 in5= in[5*3] + in[4*3]; |
2495 | 1006 in5 += in3; |
1007 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
|
1008 |
2495 | 1009 in2= MULH(2*in2, C3); |
3599 | 1010 in3= MULH(4*in3, C3); |
2967 | 1011 |
2495 | 1012 t1 = in0 - in4; |
3599 | 1013 t2 = MULH(2*(in1 - in5), icos36h[4]); |
2495 | 1014 |
2967 | 1015 out[ 7]= |
2495 | 1016 out[10]= t1 + t2; |
1017 out[ 1]= | |
1018 out[ 4]= t1 - t2; | |
1019 | |
1020 in0 += in4>>1; | |
1021 in4 = in0 + in2; | |
3599 | 1022 in5 += 2*in1; |
1023 in1 = MULH(in5 + in3, icos36h[1]); | |
2967 | 1024 out[ 8]= |
3599 | 1025 out[ 9]= in4 + in1; |
2495 | 1026 out[ 2]= |
3599 | 1027 out[ 3]= in4 - in1; |
2967 | 1028 |
2495 | 1029 in0 -= in2; |
3599 | 1030 in5 = MULH(2*(in5 - in3), icos36h[7]); |
2495 | 1031 out[ 0]= |
3599 | 1032 out[ 5]= in0 - in5; |
2495 | 1033 out[ 6]= |
3599 | 1034 out[11]= in0 + in5; |
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
|
1035 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1036 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1037 /* cos(pi*i/18) */ |
2489 | 1038 #define C1 FIXHR(0.98480775301220805936/2) |
1039 #define C2 FIXHR(0.93969262078590838405/2) | |
1040 #define C3 FIXHR(0.86602540378443864676/2) | |
1041 #define C4 FIXHR(0.76604444311897803520/2) | |
1042 #define C5 FIXHR(0.64278760968653932632/2) | |
1043 #define C6 FIXHR(0.5/2) | |
1044 #define C7 FIXHR(0.34202014332566873304/2) | |
1045 #define C8 FIXHR(0.17364817766693034885/2) | |
1046 | |
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
|
1047 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1048 /* using Lee like decomposition followed by hand coded 9 points DCT */ |
2489 | 1049 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
|
1050 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1051 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
|
1052 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
|
1053 |
46ee548e47e4
added 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 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
|
1055 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
|
1056 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
|
1057 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
|
1058 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1059 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
|
1060 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
|
1061 in1 = in + j; |
2489 | 1062 #if 0 |
1063 //more accurate but slower | |
1064 int64_t t0, t1, t2, t3; | |
1065 t2 = in1[2*4] + in1[2*8] - in1[2*2]; | |
2967 | 1066 |
2489 | 1067 t3 = (in1[2*0] + (int64_t)(in1[2*6]>>1))<<32; |
1068 t1 = in1[2*0] - in1[2*6]; | |
1069 tmp1[ 6] = t1 - (t2>>1); | |
1070 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
|
1071 |
2489 | 1072 t0 = MUL64(2*(in1[2*2] + in1[2*4]), C2); |
1073 t1 = MUL64( in1[2*4] - in1[2*8] , -2*C8); | |
1074 t2 = MUL64(2*(in1[2*2] + in1[2*8]), -C4); | |
2967 | 1075 |
2489 | 1076 tmp1[10] = (t3 - t0 - t2) >> 32; |
1077 tmp1[ 2] = (t3 + t0 + t1) >> 32; | |
1078 tmp1[14] = (t3 + t2 - t1) >> 32; | |
2967 | 1079 |
2489 | 1080 tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3); |
1081 t2 = MUL64(2*(in1[2*1] + in1[2*5]), C1); | |
1082 t3 = MUL64( in1[2*5] - in1[2*7] , -2*C7); | |
1083 t0 = MUL64(2*in1[2*3], C3); | |
1084 | |
1085 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
|
1086 |
2489 | 1087 tmp1[ 0] = (t2 + t3 + t0) >> 32; |
1088 tmp1[12] = (t2 + t1 - t0) >> 32; | |
1089 tmp1[ 8] = (t3 - t1 - t0) >> 32; | |
1090 #else | |
1091 t2 = in1[2*4] + in1[2*8] - in1[2*2]; | |
2967 | 1092 |
2489 | 1093 t3 = in1[2*0] + (in1[2*6]>>1); |
1094 t1 = in1[2*0] - in1[2*6]; | |
1095 tmp1[ 6] = t1 - (t2>>1); | |
1096 tmp1[16] = t1 + t2; | |
1097 | |
1098 t0 = MULH(2*(in1[2*2] + in1[2*4]), C2); | |
1099 t1 = MULH( in1[2*4] - in1[2*8] , -2*C8); | |
1100 t2 = MULH(2*(in1[2*2] + in1[2*8]), -C4); | |
2967 | 1101 |
2489 | 1102 tmp1[10] = t3 - t0 - t2; |
1103 tmp1[ 2] = t3 + t0 + t1; | |
1104 tmp1[14] = t3 + t2 - t1; | |
2967 | 1105 |
2489 | 1106 tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3); |
1107 t2 = MULH(2*(in1[2*1] + in1[2*5]), C1); | |
1108 t3 = MULH( in1[2*5] - in1[2*7] , -2*C7); | |
1109 t0 = MULH(2*in1[2*3], C3); | |
1110 | |
1111 t1 = MULH(2*(in1[2*1] + in1[2*7]), -C5); | |
1112 | |
1113 tmp1[ 0] = t2 + t3 + t0; | |
1114 tmp1[12] = t2 + t1 - t0; | |
1115 tmp1[ 8] = t3 - t1 - t0; | |
1116 #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
|
1117 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1118 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1119 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
|
1120 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
|
1121 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
|
1122 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
|
1123 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
|
1124 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
|
1125 |
46ee548e47e4
added 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 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
|
1127 t3 = tmp[i + 3]; |
3599 | 1128 s1 = MULH(2*(t3 + t2), icos36h[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
|
1129 s3 = MULL(t3 - t2, icos36[8 - j]); |
2967 | 1130 |
2496
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
1131 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
|
1132 t1 = s0 - s1; |
2495 | 1133 out[(9 + j)*SBLIMIT] = MULH(t1, win[9 + j]) + buf[9 + j]; |
2489 | 1134 out[(8 - j)*SBLIMIT] = MULH(t1, win[8 - j]) + buf[8 - j]; |
1135 buf[9 + j] = MULH(t0, win[18 + 9 + j]); | |
1136 buf[8 - j] = MULH(t0, win[18 + 8 - j]); | |
2967 | 1137 |
2496
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
1138 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
|
1139 t1 = s2 - s3; |
2495 | 1140 out[(9 + 8 - j)*SBLIMIT] = MULH(t1, win[9 + 8 - j]) + buf[9 + 8 - j]; |
2489 | 1141 out[( j)*SBLIMIT] = MULH(t1, win[ j]) + buf[ j]; |
1142 buf[9 + 8 - j] = MULH(t0, win[18 + 9 + 8 - j]); | |
1143 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
|
1144 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
|
1145 } |
46ee548e47e4
added 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 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1147 s0 = tmp[16]; |
3599 | 1148 s1 = MULH(2*tmp[17], icos36h[4]); |
2496
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
1149 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
|
1150 t1 = s0 - s1; |
2495 | 1151 out[(9 + 4)*SBLIMIT] = MULH(t1, win[9 + 4]) + buf[9 + 4]; |
2489 | 1152 out[(8 - 4)*SBLIMIT] = MULH(t1, win[8 - 4]) + buf[8 - 4]; |
1153 buf[9 + 4] = MULH(t0, win[18 + 9 + 4]); | |
1154 buf[8 - 4] = MULH(t0, win[18 + 8 - 4]); | |
0 | 1155 } |
1156 | |
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
|
1157 /* 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
|
1158 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
|
1159 that the frame size must be computed externally */ |
1064 | 1160 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
|
1161 { |
46ee548e47e4
added 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 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
|
1163 int sample_rate_index, bitrate_index; |
0 | 1164 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
|
1165 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
|
1166 mpeg25 = 0; |
0 | 1167 } 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
|
1168 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
|
1169 mpeg25 = 1; |
0 | 1170 } |
2967 | 1171 |
0 | 1172 s->layer = 4 - ((header >> 17) & 3); |
1173 /* 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
|
1174 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
|
1175 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
|
1176 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
|
1177 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
|
1178 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
|
1179 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
|
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 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
|
1182 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
|
1183 //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
|
1184 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
|
1185 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
|
1186 //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
|
1187 //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
|
1188 //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
|
1189 |
46ee548e47e4
added 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 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
|
1191 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
|
1192 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
|
1193 s->nb_channels = 2; |
2967 | 1194 |
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
|
1195 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
|
1196 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
|
1197 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
|
1198 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
|
1199 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
|
1200 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
|
1201 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
|
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 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
|
1204 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
|
1205 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
|
1206 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
|
1207 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
|
1208 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
|
1209 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
|
1210 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
|
1211 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
|
1212 } |
46ee548e47e4
added 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 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
|
1214 } 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
|
1215 /* if no frame size computed, signal it */ |
3722
0da2c9abe11b
remove unused, uninitialized free format frame size
bcoudurier
parents:
3716
diff
changeset
|
1216 return 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
|
1217 } |
2967 | 1218 |
431 | 1219 #if defined(DEBUG) |
3177 | 1220 dprintf("layer%d, %d Hz, %d kbits/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
|
1221 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
|
1222 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
|
1223 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
|
1224 if (s->mode_ext & MODE_EXT_MS_STEREO) |
3177 | 1225 dprintf("ms-"); |
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
|
1226 if (s->mode_ext & MODE_EXT_I_STEREO) |
3177 | 1227 dprintf("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
|
1228 } |
3177 | 1229 dprintf("stereo"); |
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
|
1230 } else { |
3177 | 1231 dprintf("mono"); |
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
|
1232 } |
3177 | 1233 dprintf("\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
|
1234 #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
|
1235 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
|
1236 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1237 |
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
|
1238 /* useful helper to get mpeg audio stream infos. Return -1 if error in |
1612 | 1239 header, otherwise the coded frame size in bytes */ |
1240 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
|
1241 { |
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 MPADecodeContext s1, *s = &s1; |
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 |
2472 | 1244 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
|
1245 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
|
1246 |
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 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
|
1248 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
|
1249 } |
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 |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1251 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
|
1252 case 1: |
1612 | 1253 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
|
1254 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
|
1255 case 2: |
1612 | 1256 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
|
1257 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
|
1258 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
|
1259 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
|
1260 if (s->lsf) |
1612 | 1261 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
|
1262 else |
1612 | 1263 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
|
1264 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
|
1265 } |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1266 |
1612 | 1267 avctx->sample_rate = s->sample_rate; |
1268 avctx->channels = s->nb_channels; | |
1269 avctx->bit_rate = s->bit_rate; | |
1270 avctx->sub_id = s->layer; | |
1271 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
|
1272 } |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
1273 |
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
|
1274 /* 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
|
1275 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
|
1276 { |
46ee548e47e4
added 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 int bound, i, v, n, ch, j, mant; |
1064 | 1278 uint8_t allocation[MPA_MAX_CHANNELS][SBLIMIT]; |
1279 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
|
1280 |
2967 | 1281 if (s->mode == MPA_JSTEREO) |
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
|
1282 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
|
1283 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
|
1284 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
|
1285 |
46ee548e47e4
added 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 /* 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
|
1287 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
|
1288 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
|
1289 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
|
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 } |
46ee548e47e4
added 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 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
|
1293 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
|
1294 } |
0 | 1295 |
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
|
1296 /* 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
|
1297 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
|
1298 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
|
1299 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
|
1300 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
|
1301 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 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
|
1304 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
|
1305 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
|
1306 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
|
1307 } |
46ee548e47e4
added 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 } |
2967 | 1309 |
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
|
1310 /* 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
|
1311 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
|
1312 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
|
1313 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
|
1314 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
|
1315 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
|
1316 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
|
1317 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
|
1318 } 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
|
1319 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
|
1320 } |
46ee548e47e4
added 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[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
|
1322 } |
46ee548e47e4
added 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 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
|
1325 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
|
1326 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
|
1327 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
|
1328 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
|
1329 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
|
1330 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
|
1331 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
|
1332 } 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
|
1333 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
|
1334 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
|
1335 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 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
|
1339 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 /* 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
|
1342 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
|
1343 { |
46ee548e47e4
added 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 int ch_bitrate, table; |
2967 | 1345 |
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
|
1346 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
|
1347 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
|
1348 if ((freq == 48000 && ch_bitrate >= 56) || |
2967 | 1349 (ch_bitrate >= 56 && ch_bitrate <= 80)) |
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
|
1350 table = 0; |
2967 | 1351 else if (freq != 48000 && ch_bitrate >= 96) |
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
|
1352 table = 1; |
2967 | 1353 else if (freq != 32000 && ch_bitrate <= 48) |
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
|
1354 table = 2; |
2967 | 1355 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
|
1356 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
|
1357 } 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
|
1358 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
|
1359 } |
46ee548e47e4
added 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 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
|
1361 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 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
|
1364 { |
46ee548e47e4
added 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 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
|
1366 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
|
1367 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
|
1368 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
|
1369 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
|
1370 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
|
1371 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
|
1372 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1373 /* select decoding table */ |
2967 | 1374 table = l2_select_table(s->bit_rate / 1000, 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
|
1375 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
|
1376 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
|
1377 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
|
1378 |
2967 | 1379 if (s->mode == MPA_JSTEREO) |
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
|
1380 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
|
1381 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
|
1382 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
|
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 dprintf("bound=%d sblimit=%d\n", bound, sblimit); |
1780 | 1385 |
1386 /* sanity check */ | |
1387 if( bound > sblimit ) bound = sblimit; | |
1388 | |
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
|
1389 /* 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
|
1390 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
|
1391 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
|
1392 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
|
1393 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
|
1394 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
|
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 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
|
1397 } |
46ee548e47e4
added 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 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
|
1399 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
|
1400 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
|
1401 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
|
1402 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
|
1403 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
|
1404 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 #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
|
1407 { |
46ee548e47e4
added 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 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
|
1409 for(i=0;i<sblimit;i++) |
3177 | 1410 dprintf(" %d", bit_alloc[ch][i]); |
1411 dprintf("\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
|
1412 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 #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
|
1415 |
46ee548e47e4
added 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 /* 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
|
1417 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
|
1418 for(ch=0;ch<s->nb_channels;ch++) { |
2967 | 1419 if (bit_alloc[ch][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
|
1420 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
|
1421 } |
46ee548e47e4
added 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 } |
2967 | 1423 |
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
|
1424 /* 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
|
1425 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
|
1426 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
|
1427 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
|
1428 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
|
1429 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
|
1430 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
|
1431 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
|
1432 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
|
1433 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
|
1434 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
|
1435 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
|
1436 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
|
1437 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
|
1438 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
|
1439 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
|
1440 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
|
1441 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
|
1442 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
|
1443 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
|
1444 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
|
1445 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
|
1446 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
|
1447 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
|
1448 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
|
1449 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 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
|
1451 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 #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
|
1457 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
|
1458 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
|
1459 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
|
1460 sf = scale_factors[ch][i]; |
3177 | 1461 dprintf(" %d %d %d", sf[0], sf[1], sf[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
|
1462 } else { |
3177 | 1463 dprintf(" -"); |
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
|
1464 } |
46ee548e47e4
added 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 } |
3177 | 1466 dprintf("\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
|
1467 } |
46ee548e47e4
added 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 #endif |
0 | 1469 |
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
|
1470 /* 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
|
1471 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
|
1472 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
|
1473 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
|
1474 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
|
1475 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
|
1476 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
|
1477 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
|
1478 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
|
1479 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
|
1480 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
|
1481 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
|
1482 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
|
1483 /* 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
|
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 steps = quant_steps[qindex]; |
2967 | 1486 s->sb_samples[ch][k * 12 + l + 0][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
|
1487 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
|
1488 v = v / steps; |
2967 | 1489 s->sb_samples[ch][k * 12 + l + 1][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
|
1490 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
|
1491 v = v / steps; |
2967 | 1492 s->sb_samples[ch][k * 12 + l + 2][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
|
1493 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
|
1494 } 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
|
1495 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
|
1496 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
|
1497 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
|
1498 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
|
1499 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 } 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
|
1502 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
|
1503 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
|
1504 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
|
1505 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 /* next subband in alloc table */ |
2967 | 1508 j += 1 << bit_alloc_bits; |
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
|
1509 } |
46ee548e47e4
added 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 /* 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
|
1511 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
|
1512 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
|
1513 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
|
1514 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
|
1515 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
|
1516 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
|
1517 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
|
1518 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
|
1519 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
|
1520 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
|
1521 /* 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
|
1522 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
|
1523 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
|
1524 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
|
1525 v = v / steps; |
2967 | 1526 s->sb_samples[0][k * 12 + l + 0][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
|
1527 l2_unscale_group(steps, mant, scale0); |
2967 | 1528 s->sb_samples[1][k * 12 + l + 0][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
|
1529 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
|
1530 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
|
1531 v = v / steps; |
2967 | 1532 s->sb_samples[0][k * 12 + l + 1][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
|
1533 l2_unscale_group(steps, mant, scale0); |
2967 | 1534 s->sb_samples[1][k * 12 + l + 1][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
|
1535 l2_unscale_group(steps, mant, scale1); |
2967 | 1536 s->sb_samples[0][k * 12 + l + 2][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
|
1537 l2_unscale_group(steps, v, scale0); |
2967 | 1538 s->sb_samples[1][k * 12 + l + 2][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
|
1539 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
|
1540 } 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
|
1541 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
|
1542 mant = get_bits(&s->gb, bits); |
2967 | 1543 s->sb_samples[0][k * 12 + l + m][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
|
1544 l1_unscale(bits - 1, mant, scale0); |
2967 | 1545 s->sb_samples[1][k * 12 + l + m][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
|
1546 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
|
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 } |
46ee548e47e4
added 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 } 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
|
1550 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
|
1551 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
|
1552 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
|
1553 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
|
1554 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
|
1555 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
|
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 /* next subband in alloc table */ |
2967 | 1558 j += 1 << bit_alloc_bits; |
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
|
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 /* 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
|
1561 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
|
1562 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
|
1563 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
|
1564 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
|
1565 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
|
1566 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1569 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1570 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
|
1571 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 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
|
1574 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
|
1575 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1576 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
|
1577 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
|
1578 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
|
1579 } 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
|
1580 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
|
1581 } |
46ee548e47e4
added 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 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
|
1583 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
|
1584 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
|
1585 } 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
|
1586 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
|
1587 } |
46ee548e47e4
added 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[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
|
1589 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
|
1590 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
|
1591 } |
46ee548e47e4
added 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 |
2967 | 1593 static void exponents_from_scale_factors(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
|
1594 GranuleDef *g, |
1064 | 1595 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
|
1596 { |
1064 | 1597 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
|
1598 int len, i, j, k, l, v0, shift, gain, gains[3]; |
1064 | 1599 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
|
1600 |
46ee548e47e4
added 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 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
|
1602 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
|
1603 shift = g->scalefac_scale + 1; |
0 | 1604 |
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
|
1605 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
|
1606 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
|
1607 for(i=0;i<g->long_end;i++) { |
3625 | 1608 v0 = gain - ((g->scale_factors[i] + pretab[i]) << shift) + 400; |
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 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
|
1610 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
|
1611 *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
|
1612 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 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
|
1615 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
|
1616 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
|
1617 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
|
1618 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
|
1619 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
|
1620 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
|
1621 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
|
1622 for(l=0;l<3;l++) { |
3625 | 1623 v0 = gains[l] - (g->scale_factors[k++] << shift) + 400; |
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
|
1624 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
|
1625 *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
|
1626 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 /* 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
|
1632 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
|
1633 { |
46ee548e47e4
added 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 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
|
1635 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
|
1636 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
|
1637 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
|
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 static int huffman_decode(MPADecodeContext *s, GranuleDef *g, |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1641 int16_t *exponents, int end_pos2) |
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
|
1642 { |
46ee548e47e4
added 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 int s_index; |
3626
a6251ee2dfdb
move variable declarations so that their scope is smaller
michael
parents:
3625
diff
changeset
|
1644 int i; |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1645 int last_pos, bits_left; |
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
|
1646 VLC *vlc; |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1647 int end_pos= FFMIN(end_pos2, s->gb.size_in_bits); |
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
|
1648 |
46ee548e47e4
added 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 /* 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
|
1650 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
|
1651 for(i=0;i<3;i++) { |
3626
a6251ee2dfdb
move variable declarations so that their scope is smaller
michael
parents:
3625
diff
changeset
|
1652 int j, k, l, linbits; |
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 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
|
1654 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
|
1655 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
|
1656 /* 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
|
1657 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
|
1658 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
|
1659 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
|
1660 vlc = &huff_vlc[l]; |
0 | 1661 |
3609 | 1662 if(!l){ |
3636
031252e99956
another silly typo which surprisingly neither valgrind nor cmp of the file output cought
michael
parents:
3635
diff
changeset
|
1663 memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid)*2*j); |
3609 | 1664 s_index += 2*j; |
1665 continue; | |
1666 } | |
1667 | |
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
|
1668 /* 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
|
1669 for(;j>0;j--) { |
3626
a6251ee2dfdb
move variable declarations so that their scope is smaller
michael
parents:
3625
diff
changeset
|
1670 int exponent, x, y, v; |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1671 int pos= get_bits_count(&s->gb); |
3624 | 1672 |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1673 if (pos >= end_pos){ |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1674 // av_log(NULL, AV_LOG_ERROR, "pos: %d %d %d %d\n", pos, end_pos, end_pos2, s_index); |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1675 if(s->in_gb.buffer && pos >= s->gb.size_in_bits){ |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1676 s->gb= s->in_gb; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1677 s->in_gb.buffer=NULL; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1678 assert((get_bits_count(&s->gb) & 7) == 0); |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1679 skip_bits_long(&s->gb, pos - end_pos); |
3647 | 1680 end_pos2= |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1681 end_pos= end_pos2 + get_bits_count(&s->gb) - pos; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1682 pos= get_bits_count(&s->gb); |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1683 } |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1684 // av_log(NULL, AV_LOG_ERROR, "new pos: %d %d\n", pos, end_pos); |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1685 if(pos >= end_pos) |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1686 break; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1687 } |
3623
d0242f36a793
reduce size of vlc table, thats slightly faster here
michael
parents:
3622
diff
changeset
|
1688 y = get_vlc2(&s->gb, vlc->table, 7, 3); |
3611
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1689 |
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1690 if(!y){ |
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1691 g->sb_hybrid[s_index ] = |
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1692 g->sb_hybrid[s_index+1] = 0; |
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1693 s_index += 2; |
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1694 continue; |
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1695 } |
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1696 |
3624 | 1697 exponent= exponents[s_index]; |
3609 | 1698 |
2967 | 1699 dprintf("region=%d n=%d x=%d y=%d exp=%d\n", |
3624 | 1700 i, g->region_size[i] - j, x, y, exponent); |
3627 | 1701 if(y&16){ |
1702 x = y >> 5; | |
1703 y = y & 0x0f; | |
3622 | 1704 if (x < 15){ |
3625 | 1705 v = expval_table[ exponent ][ x ]; |
1706 // v = expval_table[ (exponent&3) ][ x ] >> FFMIN(0 - (exponent>>2), 31); | |
3622 | 1707 }else{ |
1708 x += get_bitsz(&s->gb, linbits); | |
3624 | 1709 v = l3_unscale(x, exponent); |
3622 | 1710 } |
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
|
1711 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
|
1712 v = -v; |
3627 | 1713 g->sb_hybrid[s_index] = v; |
3622 | 1714 if (y < 15){ |
3625 | 1715 v = expval_table[ exponent ][ y ]; |
3622 | 1716 }else{ |
1717 y += get_bitsz(&s->gb, linbits); | |
3624 | 1718 v = l3_unscale(y, exponent); |
3622 | 1719 } |
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 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
|
1721 v = -v; |
3627 | 1722 g->sb_hybrid[s_index+1] = v; |
1723 }else{ | |
1724 x = y >> 5; | |
1725 y = y & 0x0f; | |
1726 x += y; | |
1727 if (x < 15){ | |
1728 v = expval_table[ exponent ][ x ]; | |
1729 }else{ | |
1730 x += get_bitsz(&s->gb, linbits); | |
1731 v = l3_unscale(x, exponent); | |
1732 } | |
1733 if (get_bits1(&s->gb)) | |
1734 v = -v; | |
1735 g->sb_hybrid[s_index+!!y] = v; | |
3635 | 1736 g->sb_hybrid[s_index+ !y] = 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
|
1737 } |
3627 | 1738 s_index+=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
|
1739 } |
46ee548e47e4
added 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 } |
2967 | 1741 |
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
|
1742 /* 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
|
1743 vlc = &huff_quad_vlc[g->count1table_select]; |
3612 | 1744 last_pos=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
|
1745 while (s_index <= 572) { |
3626
a6251ee2dfdb
move variable declarations so that their scope is smaller
michael
parents:
3625
diff
changeset
|
1746 int pos, code; |
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
|
1747 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
|
1748 if (pos >= end_pos) { |
3647 | 1749 if (pos > end_pos2 && last_pos){ |
1750 /* some encoders generate an incorrect size for this | |
1751 part. We must go back into the data */ | |
1752 s_index -= 4; | |
1753 skip_bits_long(&s->gb, last_pos - pos); | |
1754 av_log(NULL, AV_LOG_INFO, "overread, skip %d enddists: %d %d\n", last_pos - pos, end_pos-pos, end_pos2-pos); | |
1755 break; | |
1756 } | |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1757 // av_log(NULL, AV_LOG_ERROR, "pos2: %d %d %d %d\n", pos, end_pos, end_pos2, s_index); |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1758 if(s->in_gb.buffer && pos >= s->gb.size_in_bits){ |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1759 s->gb= s->in_gb; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1760 s->in_gb.buffer=NULL; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1761 assert((get_bits_count(&s->gb) & 7) == 0); |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1762 skip_bits_long(&s->gb, pos - end_pos); |
3647 | 1763 end_pos2= |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1764 end_pos= end_pos2 + get_bits_count(&s->gb) - pos; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1765 pos= get_bits_count(&s->gb); |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1766 } |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1767 // av_log(NULL, AV_LOG_ERROR, "new pos2: %d %d %d\n", pos, end_pos, s_index); |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1768 if(pos >= end_pos) |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1769 break; |
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
|
1770 } |
3612 | 1771 last_pos= 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
|
1772 |
3610 | 1773 code = get_vlc2(&s->gb, vlc->table, vlc->bits, 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
|
1774 dprintf("t=%d code=%d\n", g->count1table_select, code); |
3610 | 1775 g->sb_hybrid[s_index+0]= |
1776 g->sb_hybrid[s_index+1]= | |
1777 g->sb_hybrid[s_index+2]= | |
1778 g->sb_hybrid[s_index+3]= 0; | |
1779 while(code){ | |
1780 const static int idxtab[16]={3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0}; | |
3626
a6251ee2dfdb
move variable declarations so that their scope is smaller
michael
parents:
3625
diff
changeset
|
1781 int v; |
3610 | 1782 int pos= s_index+idxtab[code]; |
1783 code ^= 8>>idxtab[code]; | |
3625 | 1784 v = exp_table[ exponents[pos] ]; |
1785 // v = exp_table[ (exponents[pos]&3) ] >> FFMIN(0 - (exponents[pos]>>2), 31); | |
3610 | 1786 if(get_bits1(&s->gb)) |
1787 v = -v; | |
1788 g->sb_hybrid[pos] = v; | |
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
|
1789 } |
3610 | 1790 s_index+=4; |
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
|
1791 } |
3609 | 1792 memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid)*(576 - s_index)); |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1793 |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1794 /* skip extension bits */ |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1795 bits_left = end_pos - get_bits_count(&s->gb); |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1796 //av_log(NULL, AV_LOG_ERROR, "left:%d buf:%p\n", bits_left, s->in_gb.buffer); |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1797 if (bits_left < 0) { |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1798 dprintf("bits_left=%d\n", bits_left); |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1799 return -1; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1800 } |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1801 skip_bits_long(&s->gb, bits_left); |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
1802 |
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
|
1803 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
|
1804 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 /* 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
|
1807 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
|
1808 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
|
1809 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
|
1810 { |
3614
d0310d1cce13
optimize reorder_block() though this function seems to be executed too rarely for this to make much difference
michael
parents:
3613
diff
changeset
|
1811 int i, j, len; |
1064 | 1812 int32_t *ptr, *dst, *ptr1; |
1813 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
|
1814 |
46ee548e47e4
added 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 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
|
1816 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
|
1817 |
46ee548e47e4
added 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 (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
|
1819 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
|
1820 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
|
1821 } 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
|
1822 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
|
1823 } |
46ee548e47e4
added 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 } 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
|
1825 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
|
1826 } |
2967 | 1827 |
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
|
1828 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
|
1829 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
|
1830 ptr1 = ptr; |
3614
d0310d1cce13
optimize reorder_block() though this function seems to be executed too rarely for this to make much difference
michael
parents:
3613
diff
changeset
|
1831 dst = tmp; |
d0310d1cce13
optimize reorder_block() though this function seems to be executed too rarely for this to make much difference
michael
parents:
3613
diff
changeset
|
1832 for(j=len;j>0;j--) { |
d0310d1cce13
optimize reorder_block() though this function seems to be executed too rarely for this to make much difference
michael
parents:
3613
diff
changeset
|
1833 *dst++ = ptr[0*len]; |
d0310d1cce13
optimize reorder_block() though this function seems to be executed too rarely for this to make much difference
michael
parents:
3613
diff
changeset
|
1834 *dst++ = ptr[1*len]; |
d0310d1cce13
optimize reorder_block() though this function seems to be executed too rarely for this to make much difference
michael
parents:
3613
diff
changeset
|
1835 *dst++ = ptr[2*len]; |
d0310d1cce13
optimize reorder_block() though this function seems to be executed too rarely for this to make much difference
michael
parents:
3613
diff
changeset
|
1836 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
|
1837 } |
3614
d0310d1cce13
optimize reorder_block() though this function seems to be executed too rarely for this to make much difference
michael
parents:
3613
diff
changeset
|
1838 ptr+=2*len; |
d0310d1cce13
optimize reorder_block() though this function seems to be executed too rarely for this to make much difference
michael
parents:
3613
diff
changeset
|
1839 memcpy(ptr1, tmp, len * 3 * sizeof(*ptr1)); |
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
|
1840 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 #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
|
1844 |
46ee548e47e4
added 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 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
|
1846 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
|
1847 { |
46ee548e47e4
added 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 int i, j, k, l; |
1064 | 1849 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
|
1850 int sf_max, tmp0, tmp1, sf, len, non_zero_found; |
1064 | 1851 int32_t (*is_tab)[16]; |
1852 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
|
1853 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
|
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 /* 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
|
1856 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
|
1857 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
|
1858 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
|
1859 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
|
1860 } 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
|
1861 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
|
1862 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
|
1863 } |
2967 | 1864 |
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
|
1865 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
|
1866 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
|
1867 |
46ee548e47e4
added 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 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
|
1869 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
|
1870 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
|
1871 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
|
1872 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
|
1873 /* 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
|
1874 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
|
1875 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
|
1876 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
|
1877 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
|
1878 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
|
1879 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
|
1880 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
|
1881 /* 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
|
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 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
|
1884 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
|
1885 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
|
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 } |
46ee548e47e4
added 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 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
|
1889 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
|
1890 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
|
1891 |
46ee548e47e4
added 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 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
|
1893 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
|
1894 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
|
1895 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
|
1896 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
|
1897 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
|
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 } 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
|
1900 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
|
1901 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 /* 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
|
1903 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
|
1904 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
|
1905 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
|
1906 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
|
1907 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
|
1908 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
|
1909 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 |
2967 | 1915 non_zero_found = non_zero_found_short[0] | |
1916 non_zero_found_short[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
|
1917 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
|
1918 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1919 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
|
1920 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
|
1921 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
|
1922 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
|
1923 /* 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
|
1924 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
|
1925 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
|
1926 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
|
1927 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
|
1928 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
|
1929 } |
46ee548e47e4
added 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 /* 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
|
1932 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
|
1933 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
|
1934 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
|
1935 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
|
1936 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
|
1937 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
|
1938 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
|
1939 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
|
1940 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
|
1941 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
|
1942 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1943 } 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
|
1944 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
|
1945 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
|
1946 /* 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
|
1947 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
|
1948 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
|
1949 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
|
1950 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
|
1951 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
|
1952 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
|
1953 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1954 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1955 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1956 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1957 } 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
|
1958 /* 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
|
1959 /* 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
|
1960 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
|
1961 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
|
1962 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
|
1963 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
|
1964 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
|
1965 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
|
1966 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
|
1967 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
|
1968 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1969 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1970 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1971 |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1972 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
|
1973 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
|
1974 { |
2491 | 1975 int32_t *ptr, *csa; |
1976 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
|
1977 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1978 /* 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
|
1979 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
|
1980 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
|
1981 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
|
1982 /* 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
|
1983 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
|
1984 } 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
|
1985 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
|
1986 } |
2967 | 1987 |
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
|
1988 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
|
1989 for(i = n;i > 0;i--) { |
2491 | 1990 int tmp0, tmp1, tmp2; |
1991 csa = &csa_table[0][0]; | |
1992 #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
|
1993 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
|
1994 tmp1 = ptr[ j];\ |
2491 | 1995 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
|
1996 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
|
1997 ptr[ j] = 4*(tmp2 + MULH(tmp0, csa[3+4*j])); |
2491 | 1998 |
1999 INT_AA(0) | |
2000 INT_AA(1) | |
2001 INT_AA(2) | |
2002 INT_AA(3) | |
2003 INT_AA(4) | |
2004 INT_AA(5) | |
2005 INT_AA(6) | |
2006 INT_AA(7) | |
2967 | 2007 |
2008 ptr += 18; | |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2009 } |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2010 } |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2011 |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2012 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
|
2013 GranuleDef *g) |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2014 { |
2491 | 2015 int32_t *ptr; |
2016 int n, i; | |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2017 |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2018 /* we antialias only "long" bands */ |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2019 if (g->block_type == 2) { |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2020 if (!g->switch_point) |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2021 return; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2022 /* XXX: check this for 8000Hz case */ |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2023 n = 1; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2024 } else { |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2025 n = SBLIMIT - 1; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2026 } |
2967 | 2027 |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2028 ptr = g->sb_hybrid + 18; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2029 for(i = n;i > 0;i--) { |
2491 | 2030 float tmp0, tmp1; |
2967 | 2031 float *csa = &csa_table_float[0][0]; |
2491 | 2032 #define FLOAT_AA(j)\ |
2033 tmp0= ptr[-1-j];\ | |
2034 tmp1= ptr[ j];\ | |
2035 ptr[-1-j] = lrintf(tmp0 * csa[0+4*j] - tmp1 * csa[1+4*j]);\ | |
2036 ptr[ j] = lrintf(tmp0 * csa[1+4*j] + tmp1 * csa[0+4*j]); | |
2967 | 2037 |
2491 | 2038 FLOAT_AA(0) |
2039 FLOAT_AA(1) | |
2040 FLOAT_AA(2) | |
2041 FLOAT_AA(3) | |
2042 FLOAT_AA(4) | |
2043 FLOAT_AA(5) | |
2044 FLOAT_AA(6) | |
2045 FLOAT_AA(7) | |
2046 | |
2967 | 2047 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
|
2048 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2049 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2050 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2051 static void compute_imdct(MPADecodeContext *s, |
2967 | 2052 GranuleDef *g, |
1064 | 2053 int32_t *sb_samples, |
2054 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
|
2055 { |
2495 | 2056 int32_t *ptr, *win, *win1, *buf, *out_ptr, *ptr1; |
1064 | 2057 int32_t out2[12]; |
2495 | 2058 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
|
2059 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2060 /* 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
|
2061 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
|
2062 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
|
2063 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
|
2064 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
|
2065 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
|
2066 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
|
2067 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
|
2068 } |
46ee548e47e4
added 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 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
|
2070 |
46ee548e47e4
added 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 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
|
2072 /* 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
|
2073 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
|
2074 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
|
2075 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
|
2076 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
|
2077 } 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
|
2078 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
|
2079 } |
46ee548e47e4
added 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 = 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
|
2082 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
|
2083 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
|
2084 /* 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
|
2085 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
|
2086 /* 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
|
2087 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
|
2088 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
|
2089 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
|
2090 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
|
2091 /* 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
|
2092 win = win1 + ((4 * 36) & -(j & 1)); |
2489 | 2093 imdct36(out_ptr, buf, ptr, win); |
2094 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
|
2095 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
|
2096 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
|
2097 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2098 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
|
2099 /* 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
|
2100 win = mdct_win[2] + ((4 * 36) & -(j & 1)); |
2495 | 2101 out_ptr = sb_samples + j; |
2967 | 2102 |
2495 | 2103 for(i=0; i<6; i++){ |
2104 *out_ptr = buf[i]; | |
2105 out_ptr += SBLIMIT; | |
2106 } | |
2107 imdct12(out2, ptr + 0); | |
2108 for(i=0;i<6;i++) { | |
2109 *out_ptr = MULH(out2[i], win[i]) + buf[i + 6*1]; | |
2110 buf[i + 6*2] = MULH(out2[i + 6], win[i + 6]); | |
2111 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
|
2112 } |
2495 | 2113 imdct12(out2, ptr + 1); |
2114 for(i=0;i<6;i++) { | |
2115 *out_ptr = MULH(out2[i], win[i]) + buf[i + 6*2]; | |
2116 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
|
2117 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
|
2118 } |
2495 | 2119 imdct12(out2, ptr + 2); |
2120 for(i=0;i<6;i++) { | |
2121 buf[i + 6*0] = MULH(out2[i], win[i]) + buf[i + 6*0]; | |
2122 buf[i + 6*1] = MULH(out2[i + 6], win[i + 6]); | |
2123 buf[i + 6*2] = 0; | |
2124 } | |
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
|
2125 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
|
2126 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
|
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 /* 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
|
2129 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
|
2130 /* 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
|
2131 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
|
2132 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
|
2133 *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
|
2134 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
|
2135 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
|
2136 } |
46ee548e47e4
added 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 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
|
2138 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 |
404 | 2141 #if defined(DEBUG) |
1064 | 2142 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
|
2143 { |
46ee548e47e4
added 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 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
|
2145 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
|
2146 int i; |
1064 | 2147 int32_t v; |
2967 | 2148 |
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
|
2149 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
|
2150 if (!f) { |
2967 | 2151 snprintf(buf, sizeof(buf), "/tmp/out%d.%s.pcm", |
2152 fnum, | |
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
|
2153 #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
|
2154 "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
|
2155 #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
|
2156 "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
|
2157 #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
|
2158 ); |
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
|
2159 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
|
2160 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
|
2161 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
|
2162 files[fnum] = f; |
0 | 2163 } |
2967 | 2164 |
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
|
2165 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
|
2166 static int pos = 0; |
2477 | 2167 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
|
2168 for(i=0;i<n;i++) { |
2477 | 2169 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
|
2170 if ((i % 18) == 17) |
2477 | 2171 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
|
2172 } |
46ee548e47e4
added 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 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
|
2174 } |
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
|
2175 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
|
2176 /* 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
|
2177 v = tab[i] << (23 - FRAC_BITS); |
1064 | 2178 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
|
2179 } |
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
|
2180 } |
46ee548e47e4
added 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 #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
|
2182 |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 /* 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
|
2185 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
|
2186 { |
46ee548e47e4
added 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 int nb_granules, main_data_begin, private_bits; |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2188 int gr, ch, blocksplit_flag, i, j, k, n, bits_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
|
2189 GranuleDef granules[2][2], *g; |
1064 | 2190 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
|
2191 |
46ee548e47e4
added 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 /* 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
|
2193 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
|
2194 main_data_begin = get_bits(&s->gb, 8); |
3613 | 2195 private_bits = get_bits(&s->gb, 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
|
2196 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
|
2197 } 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
|
2198 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
|
2199 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
|
2200 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
|
2201 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
|
2202 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
|
2203 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
|
2204 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
|
2205 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
|
2206 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
|
2207 } |
46ee548e47e4
added 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 } |
2967 | 2209 |
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
|
2210 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
|
2211 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
|
2212 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
|
2213 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
|
2214 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
|
2215 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
|
2216 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
|
2217 /* 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
|
2218 1/sqrt(2) renormalization factor */ |
2967 | 2219 if ((s->mode_ext & (MODE_EXT_MS_STEREO | MODE_EXT_I_STEREO)) == |
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
|
2220 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
|
2221 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
|
2222 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
|
2223 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
|
2224 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
|
2225 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
|
2226 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
|
2227 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
|
2228 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
|
2229 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
|
2230 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
|
2231 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
|
2232 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
|
2233 g->table_select[i] = get_bits(&s->gb, 5); |
2967 | 2234 for(i=0;i<3;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
|
2235 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
|
2236 /* 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
|
2237 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
|
2238 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
|
2239 else { |
2967 | 2240 if (s->sample_rate_index <= 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
|
2241 g->region_size[0] = (36 / 2); |
2967 | 2242 else if (s->sample_rate_index != 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
|
2243 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
|
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->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
|
2246 } |
46ee548e47e4
added 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 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
|
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 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
|
2250 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
|
2251 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
|
2252 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
|
2253 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
|
2254 /* 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
|
2255 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
|
2256 region_address2 = get_bits(&s->gb, 3); |
2967 | 2257 dprintf("region1=%d region2=%d\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
|
2258 region_address1, region_address2); |
2967 | 2259 g->region_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
|
2260 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
|
2261 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
|
2262 /* 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
|
2263 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
|
2264 l = 22; |
2967 | 2265 g->region_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
|
2266 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
|
2267 } |
46ee548e47e4
added 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 /* 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
|
2269 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
|
2270 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
|
2271 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
|
2272 for(i=0;i<3;i++) { |
3608 | 2273 k = FFMIN(g->region_size[i], g->big_values); |
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
|
2274 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
|
2275 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
|
2276 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 /* 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
|
2279 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
|
2280 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
|
2281 /* 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
|
2282 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
|
2283 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
|
2284 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
|
2285 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
|
2286 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
|
2287 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
|
2288 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
|
2289 g->long_end = 4; /* 8000 Hz */ |
2967 | 2290 |
3608 | 2291 g->short_start = 2 + (s->sample_rate_index != 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
|
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 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
|
2294 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
|
2295 } |
46ee548e47e4
added 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 } 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
|
2297 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
|
2298 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
|
2299 } |
2967 | 2300 |
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
|
2301 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
|
2302 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
|
2303 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
|
2304 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
|
2305 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
|
2306 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
|
2307 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
|
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 } |
0 | 2310 |
2432 | 2311 if (!s->adu_mode) { |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2312 const uint8_t *ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3); |
3647 | 2313 assert((get_bits_count(&s->gb) & 7) == 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
|
2314 /* 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
|
2315 dprintf("seekback: %d\n", main_data_begin); |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2316 //av_log(NULL, AV_LOG_ERROR, "backstep:%d, lastbuf:%d\n", main_data_begin, s->last_buf_size); |
3647 | 2317 if(main_data_begin > s->last_buf_size){ |
2318 av_log(NULL, AV_LOG_ERROR, "backstep:%d, lastbuf:%d\n", main_data_begin, s->last_buf_size); | |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2319 s->last_buf_size= main_data_begin; |
3647 | 2320 } |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2321 |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2322 memcpy(s->last_buf + s->last_buf_size, ptr, EXTRABYTES); |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2323 s->in_gb= s->gb; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2324 init_get_bits(&s->gb, s->last_buf + s->last_buf_size - main_data_begin, main_data_begin*8); |
2432 | 2325 } |
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
|
2326 |
46ee548e47e4
added 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 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
|
2328 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
|
2329 g = &granules[ch][gr]; |
2967 | 2330 |
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
|
2331 bits_pos = get_bits_count(&s->gb); |
2967 | 2332 |
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
|
2333 if (!s->lsf) { |
1064 | 2334 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
|
2335 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
|
2336 |
46ee548e47e4
added 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 /* 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
|
2338 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
|
2339 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
|
2340 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
|
2341 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
|
2342 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
|
2343 j = 0; |
3616 | 2344 if(slen1){ |
2345 for(i=0;i<n;i++) | |
2346 g->scale_factors[j++] = get_bits(&s->gb, slen1); | |
2347 }else{ | |
2348 for(i=0;i<n;i++) | |
2349 g->scale_factors[j++] = 0; | |
2350 } | |
2351 if(slen2){ | |
2352 for(i=0;i<18;i++) | |
2353 g->scale_factors[j++] = get_bits(&s->gb, slen2); | |
2354 for(i=0;i<3;i++) | |
2355 g->scale_factors[j++] = 0; | |
2356 }else{ | |
2357 for(i=0;i<21;i++) | |
2358 g->scale_factors[j++] = 0; | |
2359 } | |
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
|
2360 } 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
|
2361 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
|
2362 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
|
2363 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
|
2364 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
|
2365 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
|
2366 slen = (k < 2) ? slen1 : slen2; |
3616 | 2367 if(slen){ |
2368 for(i=0;i<n;i++) | |
2369 g->scale_factors[j++] = get_bits(&s->gb, slen); | |
2370 }else{ | |
2371 for(i=0;i<n;i++) | |
2372 g->scale_factors[j++] = 0; | |
2373 } | |
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
|
2374 } 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
|
2375 /* 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
|
2376 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
|
2377 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
|
2378 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
|
2379 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 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
|
2383 } |
404 | 2384 #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
|
2385 { |
3177 | 2386 dprintf("scfsi=%x gr=%d ch=%d scale_factors:\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
|
2387 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
|
2388 for(i=0;i<j;i++) |
3177 | 2389 dprintf(" %d", g->scale_factors[i]); |
2390 dprintf("\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
|
2391 } |
0 | 2392 #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
|
2393 } 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
|
2394 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
|
2395 |
46ee548e47e4
added 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 /* 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
|
2397 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
|
2398 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
|
2399 } 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
|
2400 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
|
2401 } |
46ee548e47e4
added 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 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
|
2403 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
|
2404 /* 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
|
2405 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
|
2406 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
|
2407 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
|
2408 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
|
2409 } 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
|
2410 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
|
2411 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
|
2412 } 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
|
2413 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
|
2414 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
|
2415 } |
46ee548e47e4
added 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 } 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
|
2417 /* 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
|
2418 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
|
2419 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
|
2420 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
|
2421 } 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
|
2422 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
|
2423 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
|
2424 } 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
|
2425 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
|
2426 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
|
2427 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
|
2428 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2430 |
46ee548e47e4
added 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 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
|
2432 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
|
2433 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
|
2434 sl = slen[k]; |
3617 | 2435 if(sl){ |
3616 | 2436 for(i=0;i<n;i++) |
2437 g->scale_factors[j++] = get_bits(&s->gb, sl); | |
2438 }else{ | |
2439 for(i=0;i<n;i++) | |
2440 g->scale_factors[j++] = 0; | |
2441 } | |
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 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2443 /* 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
|
2444 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
|
2445 g->scale_factors[j] = 0; |
404 | 2446 #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
|
2447 { |
3177 | 2448 dprintf("gr=%d ch=%d scale_factors:\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
|
2449 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
|
2450 for(i=0;i<40;i++) |
3177 | 2451 dprintf(" %d", g->scale_factors[i]); |
2452 dprintf("\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
|
2453 } |
46ee548e47e4
added 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 #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
|
2455 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 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
|
2458 |
46ee548e47e4
added 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 /* 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
|
2460 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
|
2461 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
|
2462 return -1; |
404 | 2463 #if defined(DEBUG) |
2464 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
|
2465 #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
|
2466 } /* 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
|
2467 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2468 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
|
2469 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
|
2470 |
46ee548e47e4
added 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 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
|
2472 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
|
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 reorder_block(s, g); |
404 | 2475 #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
|
2476 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
|
2477 #endif |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2478 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
|
2479 #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
|
2480 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
|
2481 #endif |
2967 | 2482 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
|
2483 #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
|
2484 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
|
2485 #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
|
2486 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2487 } /* 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
|
2488 return nb_granules * 18; |
0 | 2489 } |
2490 | |
2967 | 2491 static int mp_decode_frame(MPADecodeContext *s, |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2492 OUT_INT *samples, const uint8_t *buf, int buf_size) |
0 | 2493 { |
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 int i, nb_frames, ch; |
2479 | 2495 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
|
2496 |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2497 init_get_bits(&s->gb, buf + HEADER_SIZE, (buf_size - HEADER_SIZE)*8); |
2967 | 2498 |
0 | 2499 /* skip error protection field */ |
2500 if (s->error_protection) | |
2501 get_bits(&s->gb, 16); | |
2502 | |
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
|
2503 dprintf("frame %d:\n", s->frame_count); |
0 | 2504 switch(s->layer) { |
2505 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
|
2506 nb_frames = mp_decode_layer1(s); |
0 | 2507 break; |
2508 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
|
2509 nb_frames = mp_decode_layer2(s); |
0 | 2510 break; |
2511 case 3: | |
2512 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
|
2513 nb_frames = mp_decode_layer3(s); |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2514 |
3643 | 2515 s->last_buf_size=0; |
2516 if(s->in_gb.buffer){ | |
2517 align_get_bits(&s->gb); | |
2518 i= (s->gb.size_in_bits - get_bits_count(&s->gb))>>3; | |
3647 | 2519 if(i >= 0 && i <= BACKSTEP_SIZE){ |
3643 | 2520 memmove(s->last_buf, s->gb.buffer + (get_bits_count(&s->gb)>>3), i); |
2521 s->last_buf_size=i; | |
3647 | 2522 }else |
2523 av_log(NULL, AV_LOG_ERROR, "invalid old backstep %d\n", i); | |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2524 s->gb= s->in_gb; |
3643 | 2525 } |
2526 | |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2527 align_get_bits(&s->gb); |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2528 assert((get_bits_count(&s->gb) & 7) == 0); |
3643 | 2529 i= (s->gb.size_in_bits - get_bits_count(&s->gb))>>3; |
2530 | |
3647 | 2531 if(i<0 || i > BACKSTEP_SIZE || nb_frames<0){ |
2532 av_log(NULL, AV_LOG_ERROR, "invalid new backstep %d\n", i); | |
2533 i= FFMIN(BACKSTEP_SIZE, buf_size - HEADER_SIZE); | |
2534 } | |
3643 | 2535 assert(i <= buf_size - HEADER_SIZE && i>= 0); |
3647 | 2536 memcpy(s->last_buf + s->last_buf_size, s->gb.buffer + buf_size - HEADER_SIZE - i, i); |
3643 | 2537 s->last_buf_size += i; |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2538 |
0 | 2539 break; |
2540 } | |
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
|
2541 #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
|
2542 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
|
2543 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
|
2544 int j; |
3177 | 2545 dprintf("%d-%d:", i, ch); |
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
|
2546 for(j=0;j<SBLIMIT;j++) |
3177 | 2547 dprintf(" %0.6f", (double)s->sb_samples[ch][i][j] / FRAC_ONE); |
2548 dprintf("\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
|
2549 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2550 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2551 #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
|
2552 /* 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
|
2553 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
|
2554 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
|
2555 for(i=0;i<nb_frames;i++) { |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
2556 ff_mpa_synth_filter(s->synth_buf[ch], &(s->synth_buf_offset[ch]), |
2979 | 2557 window, &s->dither_state, |
2558 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
|
2559 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
|
2560 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
|
2561 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2563 #ifdef DEBUG |
2967 | 2564 s->frame_count++; |
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 #endif |
2479 | 2566 return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels; |
0 | 2567 } |
2568 | |
2569 static int decode_frame(AVCodecContext * avctx, | |
2979 | 2570 void *data, int *data_size, |
2571 uint8_t * buf, int buf_size) | |
0 | 2572 { |
2573 MPADecodeContext *s = avctx->priv_data; | |
1064 | 2574 uint32_t header; |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2575 int out_size; |
2479 | 2576 OUT_INT *out_samples = data; |
0 | 2577 |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2578 retry: |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2579 if(buf_size < HEADER_SIZE) |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2580 return -1; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2581 |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2582 header = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3]; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2583 if(ff_mpa_check_header(header) < 0){ |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2584 buf++; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2585 // buf_size--; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2586 av_log(avctx, AV_LOG_ERROR, "header missing skiping one byte\n"); |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2587 goto retry; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2588 } |
143 | 2589 |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2590 if (decode_header(s, header) == 1) { |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2591 /* free format: prepare to compute frame size */ |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2592 s->frame_size = -1; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2593 return -1; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2594 } |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2595 /* update codec info */ |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2596 avctx->sample_rate = s->sample_rate; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2597 avctx->channels = s->nb_channels; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2598 avctx->bit_rate = s->bit_rate; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2599 avctx->sub_id = s->layer; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2600 switch(s->layer) { |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2601 case 1: |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2602 avctx->frame_size = 384; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2603 break; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2604 case 2: |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2605 avctx->frame_size = 1152; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2606 break; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2607 case 3: |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2608 if (s->lsf) |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2609 avctx->frame_size = 576; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2610 else |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2611 avctx->frame_size = 1152; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2612 break; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2613 } |
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
|
2614 |
3687 | 2615 if(s->frame_size<=0 || s->frame_size > buf_size){ |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2616 av_log(avctx, AV_LOG_ERROR, "incomplete frame\n"); |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2617 return -1; |
3687 | 2618 }else if(s->frame_size < buf_size){ |
2619 av_log(avctx, AV_LOG_ERROR, "incorrect frame size\n"); | |
0 | 2620 } |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2621 |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2622 out_size = mp_decode_frame(s, out_samples, buf, buf_size); |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2623 if(out_size>=0) |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2624 *data_size = out_size; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2625 else |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2626 av_log(avctx, AV_LOG_DEBUG, "Error while decoding mpeg audio frame\n"); //FIXME return -1 / but also return the number of bytes consumed |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2627 s->frame_size = 0; |
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2628 return buf_size; |
0 | 2629 } |
2630 | |
2432 | 2631 |
2632 static int decode_frame_adu(AVCodecContext * avctx, | |
2979 | 2633 void *data, int *data_size, |
2634 uint8_t * buf, int buf_size) | |
2432 | 2635 { |
2636 MPADecodeContext *s = avctx->priv_data; | |
2637 uint32_t header; | |
2638 int len, out_size; | |
2479 | 2639 OUT_INT *out_samples = data; |
2432 | 2640 |
2641 len = buf_size; | |
2642 | |
2643 // Discard too short frames | |
2644 if (buf_size < HEADER_SIZE) { | |
2645 *data_size = 0; | |
2646 return buf_size; | |
2647 } | |
2648 | |
2649 | |
2650 if (len > MPA_MAX_CODED_FRAME_SIZE) | |
2651 len = MPA_MAX_CODED_FRAME_SIZE; | |
2652 | |
2653 // Get header and restore sync word | |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2654 header = (buf[0] << 24) | (buf[1] << 16) | (buf[2] << 8) | buf[3] | 0xffe00000; |
2432 | 2655 |
2472 | 2656 if (ff_mpa_check_header(header) < 0) { // Bad header, discard frame |
2432 | 2657 *data_size = 0; |
2658 return buf_size; | |
2659 } | |
2660 | |
2661 decode_header(s, header); | |
2662 /* update codec info */ | |
2663 avctx->sample_rate = s->sample_rate; | |
2664 avctx->channels = s->nb_channels; | |
2665 avctx->bit_rate = s->bit_rate; | |
2666 avctx->sub_id = s->layer; | |
2667 | |
2668 avctx->frame_size=s->frame_size = len; | |
2669 | |
2670 if (avctx->parse_only) { | |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2671 out_size = buf_size; |
2432 | 2672 } else { |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2673 out_size = mp_decode_frame(s, out_samples, buf, buf_size); |
2432 | 2674 } |
2675 | |
2676 *data_size = out_size; | |
2677 return buf_size; | |
2678 } | |
2679 | |
2680 | |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2681 /* 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
|
2682 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
|
2683 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
|
2684 /* 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
|
2685 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
|
2686 {0}, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2687 {0}, // C |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2688 {0}, // FLR |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2689 {2,0}, // C FLR |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2690 {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
|
2691 {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
|
2692 {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
|
2693 {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
|
2694 {0,2} // FLR BLRS |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2695 }; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2696 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2697 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2698 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
|
2699 { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2700 MP3On4DecodeContext *s = avctx->priv_data; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2701 int i; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2702 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2703 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
|
2704 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
|
2705 return -1; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2706 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2707 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2708 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
|
2709 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
|
2710 if(!s->frames) { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2711 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
|
2712 return -1; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2713 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2714 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
|
2715 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2716 /* 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
|
2717 * 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
|
2718 * 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
|
2719 * 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
|
2720 */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2721 // 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
|
2722 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
|
2723 // 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
|
2724 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
|
2725 decode_init(avctx); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2726 // Restore mp3on4 context pointer |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2727 avctx->priv_data = s; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2728 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
|
2729 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2730 /* 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
|
2731 * 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
|
2732 */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2733 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
|
2734 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
|
2735 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
|
2736 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
|
2737 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2738 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2739 return 0; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2740 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2741 |
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 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
|
2744 { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2745 MP3On4DecodeContext *s = avctx->priv_data; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2746 int i; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2747 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2748 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
|
2749 if (s->mp3decctx[i]) |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2750 av_free(s->mp3decctx[i]); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2751 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2752 return 0; |
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 |
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 static int decode_frame_mp3on4(AVCodecContext * avctx, |
2979 | 2757 void *data, int *data_size, |
2758 uint8_t * buf, int buf_size) | |
2507
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 MPADecodeContext *m; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2762 int len, out_size = 0; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2763 uint32_t header; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2764 OUT_INT *out_samples = data; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2765 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
|
2766 OUT_INT *outptr, *bp; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2767 int fsize; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2768 unsigned char *start2 = buf, *start; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2769 int fr, i, j, n; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2770 int off = avctx->channels; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2771 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
|
2772 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2773 len = 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 // Discard too short frames |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2776 if (buf_size < HEADER_SIZE) { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2777 *data_size = 0; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2778 return buf_size; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2779 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2780 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2781 // 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
|
2782 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
|
2783 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2784 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
|
2785 start = start2; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2786 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
|
2787 start2 += fsize; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2788 if (fsize > len) |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2789 fsize = len; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2790 len -= fsize; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2791 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
|
2792 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
|
2793 m = s->mp3decctx[fr]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2794 assert (m != NULL); |
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 // Get header |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2797 header = (start[0] << 24) | (start[1] << 16) | (start[2] << 8) | start[3] | 0xfff00000; |
2507
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 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
|
2800 *data_size = 0; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2801 return buf_size; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2802 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2803 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2804 decode_header(m, header); |
3634
fa4beebb74a6
remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents:
3627
diff
changeset
|
2805 mp_decode_frame(m, decoded_buf, start, fsize); |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2806 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2807 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
|
2808 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
|
2809 if(s->frames > 1) { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2810 /* interleave output data */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2811 bp = out_samples + coff[fr]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2812 if(m->nb_channels == 1) { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2813 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
|
2814 *bp = decoded_buf[j]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2815 bp += off; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2816 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2817 } else { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2818 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
|
2819 bp[0] = decoded_buf[j++]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2820 bp[1] = decoded_buf[j]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2821 bp += off; |
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 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2824 } |
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 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2827 /* update codec info */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2828 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
|
2829 avctx->frame_size= buf_size; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2830 avctx->bit_rate = 0; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2831 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
|
2832 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
|
2833 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2834 *data_size = out_size; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2835 return buf_size; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2836 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2837 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2838 |
322 | 2839 AVCodec mp2_decoder = |
0 | 2840 { |
322 | 2841 "mp2", |
0 | 2842 CODEC_TYPE_AUDIO, |
2843 CODEC_ID_MP2, | |
2844 sizeof(MPADecodeContext), | |
2845 decode_init, | |
2846 NULL, | |
2847 NULL, | |
2848 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
|
2849 CODEC_CAP_PARSE_ONLY, |
0 | 2850 }; |
322 | 2851 |
2852 AVCodec mp3_decoder = | |
2853 { | |
2854 "mp3", | |
2855 CODEC_TYPE_AUDIO, | |
1448 | 2856 CODEC_ID_MP3, |
322 | 2857 sizeof(MPADecodeContext), |
2858 decode_init, | |
2859 NULL, | |
2860 NULL, | |
2861 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
|
2862 CODEC_CAP_PARSE_ONLY, |
322 | 2863 }; |
2432 | 2864 |
2865 AVCodec mp3adu_decoder = | |
2866 { | |
2867 "mp3adu", | |
2868 CODEC_TYPE_AUDIO, | |
2869 CODEC_ID_MP3ADU, | |
2870 sizeof(MPADecodeContext), | |
2871 decode_init, | |
2872 NULL, | |
2873 NULL, | |
2874 decode_frame_adu, | |
2875 CODEC_CAP_PARSE_ONLY, | |
2876 }; | |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2877 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2878 AVCodec mp3on4_decoder = |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2879 { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2880 "mp3on4", |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2881 CODEC_TYPE_AUDIO, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2882 CODEC_ID_MP3ON4, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2883 sizeof(MP3On4DecodeContext), |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2884 decode_init_mp3on4, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2885 NULL, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2886 decode_close_mp3on4, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2887 decode_frame_mp3on4, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2888 0 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2889 }; |