Mercurial > libavcodec.hg
annotate mpegaudiodec.c @ 5131:757efe20a3c8 libavcodec
Blackfin dct_quantize_bfin routine
2x performance boost in performing quantization for mpeg encoding
author | mhoffman |
---|---|
date | Tue, 12 Jun 2007 19:13:50 +0000 |
parents | bff60ecc02f9 |
children | 94c3f01c243c |
rev | line source |
---|---|
0 | 1 /* |
2 * MPEG Audio decoder | |
429 | 3 * Copyright (c) 2001, 2002 Fabrice Bellard. |
0 | 4 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3938
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3938
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3938
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
429 | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3938
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
0 | 11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3938
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
0 | 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
429 | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * Lesser General Public License for more details. | |
0 | 16 * |
429 | 17 * You should have received a copy of the GNU Lesser General Public |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3938
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
3023
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 20 */ |
1106 | 21 |
22 /** | |
23 * @file mpegaudiodec.c | |
24 * MPEG Audio decoder. | |
2967 | 25 */ |
1106 | 26 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
27 //#define DEBUG |
0 | 28 #include "avcodec.h" |
2398
582e635cfa08
common.c -> bitstream.c (and the single non bitstream func -> utils.c)
michael
parents:
2370
diff
changeset
|
29 #include "bitstream.h" |
1734
8aace334bcf0
lrintf patch by ("Steven M. Schultz" <sms at 2BSD dot COM>)
michael
parents:
1733
diff
changeset
|
30 #include "dsputil.h" |
0 | 31 |
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
|
33 * 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
|
34 * - 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
|
35 * - test lsf / mpeg25 extensively. |
0 | 36 */ |
37 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
38 /* 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
|
39 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
|
40 #ifdef CONFIG_MPEGAUDIO_HP |
3602 | 41 # 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
|
42 #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
|
43 |
2913 | 44 #include "mpegaudio.h" |
5050 | 45 #include "mpegaudiodecheader.h" |
2479 | 46 |
3752 | 47 #include "mathops.h" |
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
|
49 #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
|
50 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
51 #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
|
52 /* 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
|
53 #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
|
54 #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
|
55 |
2489 | 56 #define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5)) |
57 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
58 /****************/ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
59 |
0 | 60 #define HEADER_SIZE 4 |
61 | |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
62 /** |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
63 * Context for MP3On4 decoder |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
64 */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
65 typedef struct MP3On4DecodeContext { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
66 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
|
67 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
|
68 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
|
69 } MP3On4DecodeContext; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
70 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
71 /* 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
|
72 typedef struct GranuleDef { |
1064 | 73 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
|
74 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
|
75 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
|
76 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
|
77 int scalefac_compress; |
1064 | 78 uint8_t block_type; |
79 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
|
80 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
|
81 int subblock_gain[3]; |
1064 | 82 uint8_t scalefac_scale; |
83 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
|
84 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
|
85 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
|
86 int short_start, long_end; /* long/short band indexes */ |
1064 | 87 uint8_t scale_factors[40]; |
88 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
|
89 } 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
|
90 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
91 #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
|
92 #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
|
93 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
94 /* 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
|
95 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
|
96 int xsize; |
1064 | 97 const uint8_t *bits; |
98 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
|
99 } 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
|
100 |
5031
70f194a2ee53
move some common mpeg audio tables from mpegaudiodectab.h to mpegaudiodata.c
aurel
parents:
5009
diff
changeset
|
101 #include "mpegaudiodata.h" |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
102 #include "mpegaudiodectab.h" |
0 | 103 |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
104 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
|
105 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
|
106 |
82
46ee548e47e4
added 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 /* vlc structure for decoding layer 3 huffman tables */ |
2967 | 108 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
|
109 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
|
110 /* computed from band_size_long */ |
1064 | 111 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
|
112 /* XXX: free when all decoders are closed */ |
2490 | 113 #define TABLE_4_3_SIZE (8191 + 16)*4 |
4662 | 114 static int8_t table_4_3_exp[TABLE_4_3_SIZE]; |
115 static uint32_t table_4_3_value[TABLE_4_3_SIZE]; | |
3621 | 116 static uint32_t exp_table[512]; |
3622 | 117 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
|
118 /* intensity stereo coef table */ |
1064 | 119 static int32_t is_table[2][16]; |
120 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
|
121 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
|
122 static float csa_table_float[8][4]; |
1064 | 123 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
|
124 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
125 /* lower 2 bits: modulo 3, higher bits: shift */ |
1064 | 126 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
|
127 /* [i][j]: 2^(-j/3) * FRAC_ONE * 2^(i+2) / (2^(i+2) - 1) */ |
1064 | 128 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
|
129 /* 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
|
130 |
46ee548e47e4
added 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 #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
|
132 { 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
|
133 |
2753 | 134 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
|
135 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
|
136 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
|
137 SCALE_GEN(4.0 / 9.0), /* 9 steps */ |
0 | 138 }; |
139 | |
5009 | 140 static DECLARE_ALIGNED_16(MPA_INT, window[512]); |
2967 | 141 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
142 /* 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
|
143 /* 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
|
144 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
|
145 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
146 int shift, mod; |
1064 | 147 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
|
148 |
46ee548e47e4
added 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 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
|
150 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
|
151 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
|
152 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
|
153 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
|
154 /* 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
|
155 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
|
156 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
157 |
46ee548e47e4
added 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 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
|
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 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
|
161 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
162 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
|
163 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
|
164 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
|
165 |
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
|
166 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
|
167 /* 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
|
168 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
|
169 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
|
170 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
|
171 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
172 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
173 /* 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
|
174 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
|
175 { |
46ee548e47e4
added 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 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
|
177 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
|
178 |
2490 | 179 e = table_4_3_exp [4*value + (exponent&3)]; |
180 m = table_4_3_value[4*value + (exponent&3)]; | |
181 e -= (exponent >> 2); | |
182 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
|
183 if (e > 31) |
2478 | 184 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
|
185 m = (m + (1 << (e-1))) >> e; |
2490 | 186 |
82
46ee548e47e4
added 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 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
|
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 |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
190 /* 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
|
191 #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
|
192 |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
193 #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
|
194 #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
|
195 #define POW_FIX(a) ((int)((a) * POW_FRAC_ONE)) |
1064 | 196 #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
|
197 |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
198 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
|
199 |
2522
e25782262d7d
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
2507
diff
changeset
|
200 #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
|
201 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
|
202 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
|
203 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
|
204 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
|
205 }; |
2522
e25782262d7d
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
2507
diff
changeset
|
206 #endif |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
207 |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
208 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
|
209 { |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
210 int i, a; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
211 |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
212 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
|
213 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
|
214 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
|
215 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
|
216 } |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
217 } |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
218 |
2522
e25782262d7d
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
2507
diff
changeset
|
219 #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
|
220 /* 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
|
221 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
|
222 { |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
223 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
|
224 int a, a1; |
2967 | 225 |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
226 /* renormalize */ |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
227 a = i; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
228 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
|
229 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
|
230 a = a << 1; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
231 e--; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
232 } |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
233 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
|
234 a1 = 0; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
235 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
|
236 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
|
237 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
|
238 /* exponent compute (exact) */ |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
239 e = e * 4; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
240 er = e % 3; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
241 eq = e / 3; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
242 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
|
243 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
|
244 a = a >> 1; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
245 eq++; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
246 } |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
247 /* convert to float */ |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
248 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
|
249 a = a << 1; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
250 eq--; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
251 } |
407
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
252 /* 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
|
253 #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
|
254 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
|
255 /* correct overflow */ |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
256 if (a >= 2 * (1 << FRAC_BITS)) { |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
257 a = a >> 1; |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
258 eq++; |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
259 } |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
260 #endif |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
261 *exp_ptr = eq; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
262 return a; |
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 |
0 | 265 |
266 static int decode_init(AVCodecContext * avctx) | |
267 { | |
268 MPADecodeContext *s = avctx->priv_data; | |
836
932eb34d17c1
vc++ sucks, found by ("csharprules" <csharprules at hotmail dot com>)
michaelni
parents:
602
diff
changeset
|
269 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
|
270 int i, j, k; |
0 | 271 |
4652 | 272 s->avctx = avctx; |
273 | |
2911
7f2959d05900
Reverse patch 1.59->1.60, it break mp3 in ffplay and ffmpeg
rtognimp
parents:
2903
diff
changeset
|
274 #if defined(USE_HIGHPRECISION) && defined(CONFIG_AUDIO_NONSHORT) |
2479 | 275 avctx->sample_fmt= SAMPLE_FMT_S32; |
276 #else | |
277 avctx->sample_fmt= SAMPLE_FMT_S16; | |
2967 | 278 #endif |
4205
8c28f03cfdd5
detect a few more errors (fixes libmp3-bug.avi again)
michael
parents:
4204
diff
changeset
|
279 s->error_resilience= avctx->error_resilience; |
2967 | 280 |
2491 | 281 if(avctx->antialias_algo != FF_AA_FLOAT) |
1762 | 282 s->compute_antialias= compute_antialias_integer; |
283 else | |
284 s->compute_antialias= compute_antialias_float; | |
285 | |
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
|
286 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
|
287 /* 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
|
288 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
|
289 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
|
290 /* 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
|
291 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
|
292 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
|
293 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
|
294 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
295 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
296 /* 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
|
297 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
|
298 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
|
299 n = i + 2; |
4274 | 300 norm = ((INT64_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
|
301 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
|
302 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
|
303 scale_factor_mult[i][2] = MULL(FIXR(0.6299605249 * 2.0), norm); |
4652 | 304 dprintf(avctx, "%d: norm=%x s=%x %x %x\n", |
2967 | 305 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
|
306 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
|
307 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
|
308 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
|
309 } |
2967 | 310 |
2979 | 311 ff_mpa_synth_init(window); |
2967 | 312 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
313 /* 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
|
314 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
|
315 const HuffTable *h = &mpa_huff_tables[i]; |
2979 | 316 int xsize, x, y; |
1057 | 317 unsigned int n; |
3627 | 318 uint8_t tmp_bits [512]; |
319 uint16_t tmp_codes[512]; | |
3608 | 320 |
321 memset(tmp_bits , 0, sizeof(tmp_bits )); | |
322 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
|
323 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
324 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
|
325 n = xsize * xsize; |
2967 | 326 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
327 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
|
328 for(x=0;x<xsize;x++) { |
3608 | 329 for(y=0;y<xsize;y++){ |
3627 | 330 tmp_bits [(x << 5) | y | ((x&&y)<<4)]= h->bits [j ]; |
331 tmp_codes[(x << 5) | y | ((x&&y)<<4)]= h->codes[j++]; | |
3608 | 332 } |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
333 } |
3608 | 334 |
335 /* XXX: fail test */ | |
3627 | 336 init_vlc(&huff_vlc[i], 7, 512, |
3608 | 337 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
|
338 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
339 for(i=0;i<2;i++) { |
2967 | 340 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
|
341 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
|
342 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 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
|
345 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
|
346 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
|
347 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
|
348 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
|
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 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
|
351 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
352 |
2979 | 353 /* compute n ^ (4/3) and store it in mantissa/exp format */ |
2967 | 354 |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
355 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
|
356 for(i=1;i<TABLE_4_3_SIZE;i++) { |
2490 | 357 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
|
358 int e, m; |
2490 | 359 f = pow((double)(i/4), 4.0 / 3.0) * pow(2, (i&3)*0.25); |
360 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
|
361 m = (uint32_t)(fm*(1LL<<31) + 0.5); |
3625 | 362 e+= FRAC_BITS - 31 + 5 - 100; |
2490 | 363 |
82
46ee548e47e4
added 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 /* 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
|
365 table_4_3_value[i] = m; |
2490 | 366 // av_log(NULL, AV_LOG_DEBUG, "%d %d %f\n", i, m, pow((double)i, 4.0 / 3.0)); |
367 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
|
368 } |
3622 | 369 for(i=0; i<512*16; i++){ |
3625 | 370 int exponent= (i>>4); |
371 double f= pow(i&15, 4.0 / 3.0) * pow(2, (exponent-400)*0.25 + FRAC_BITS + 5); | |
3732 | 372 expval_table[exponent][i&15]= llrint(f); |
3622 | 373 if((i&15)==1) |
3732 | 374 exp_table[exponent]= llrint(f); |
3621 | 375 } |
2967 | 376 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
377 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
|
378 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
|
379 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
|
380 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
|
381 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
|
382 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
|
383 } 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
|
384 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
|
385 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
386 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
|
387 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
|
388 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
389 /* 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
|
390 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
|
391 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
|
392 |
46ee548e47e4
added 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 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
|
394 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
|
395 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
|
396 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
397 for(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
|
398 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
|
399 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
|
400 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
|
401 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
|
402 is_table_lsf[j][k][i] = FIXR(1.0); |
4652 | 403 dprintf(avctx, "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
|
404 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
|
405 } |
46ee548e47e4
added 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 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
408 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
|
409 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
|
410 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
|
411 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
|
412 ca = cs * ci; |
2491 | 413 csa_table[i][0] = FIXHR(cs/4); |
414 csa_table[i][1] = FIXHR(ca/4); | |
415 csa_table[i][2] = FIXHR(ca/4) + FIXHR(cs/4); | |
2967 | 416 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
|
417 csa_table_float[i][0] = cs; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
418 csa_table_float[i][1] = ca; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
419 csa_table_float[i][2] = ca + cs; |
2967 | 420 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
|
421 // printf("%d %d %d %d\n", FIX(cs), FIX(cs-1), FIX(ca), FIX(cs)-FIX(ca)); |
2489 | 422 // 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
|
423 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
424 |
46ee548e47e4
added 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 /* 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
|
426 for(i=0;i<36;i++) { |
2489 | 427 for(j=0; j<4; j++){ |
428 double d; | |
2967 | 429 |
2495 | 430 if(j==2 && i%3 != 1) |
431 continue; | |
2967 | 432 |
2489 | 433 d= sin(M_PI * (i + 0.5) / 36.0); |
434 if(j==1){ | |
435 if (i>=30) d= 0; | |
436 else if(i>=24) d= sin(M_PI * (i - 18 + 0.5) / 12.0); | |
437 else if(i>=18) d= 1; | |
438 }else if(j==3){ | |
439 if (i< 6) d= 0; | |
440 else if(i< 12) d= sin(M_PI * (i - 6 + 0.5) / 12.0); | |
441 else if(i< 18) d= 1; | |
442 } | |
443 //merge last stage of imdct into the window coefficients | |
2495 | 444 d*= 0.5 / cos(M_PI*(2*i + 19)/72); |
445 | |
446 if(j==2) | |
447 mdct_win[j][i/3] = FIXHR((d / (1<<5))); | |
448 else | |
449 mdct_win[j][i ] = FIXHR((d / (1<<5))); | |
2489 | 450 // av_log(NULL, AV_LOG_DEBUG, "%2d %d %f\n", i,j,d / (1<<5)); |
451 } | |
82
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 /* 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
|
455 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
|
456 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
|
457 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
|
458 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
|
459 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
|
460 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 #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
|
464 for(j=0;j<8;j++) { |
3177 | 465 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
|
466 for(i=0;i<36;i++) |
3177 | 467 av_log(avctx, AV_LOG_DEBUG, "%f, ", (double)mdct_win[j][i] / FRAC_ONE); |
468 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
|
469 } |
46ee548e47e4
added 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 #endif |
0 | 471 init = 1; |
472 } | |
473 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
474 #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
|
475 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
|
476 #endif |
2432 | 477 if (avctx->codec_id == CODEC_ID_MP3ADU) |
478 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
|
479 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
|
480 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
481 |
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
|
482 /* 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
|
483 |
46ee548e47e4
added 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 /* 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
|
485 |
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
|
486 #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
|
487 #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
|
488 #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
|
489 #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
|
490 #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
|
491 #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
|
492 #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
|
493 #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
|
494 #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
|
495 #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
|
496 #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
|
497 #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
|
498 #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
|
499 #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
|
500 #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
|
501 #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
|
502 |
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
|
503 #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
|
504 #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
|
505 #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
|
506 #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
|
507 #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
|
508 #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
|
509 #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
|
510 #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
|
511 |
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
|
512 #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
|
513 #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
|
514 #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
|
515 #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
|
516 |
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
|
517 #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
|
518 #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
|
519 |
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
|
520 #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
|
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 /* 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
|
523 #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
|
524 {\ |
46ee548e47e4
added 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 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
|
526 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
|
527 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
|
528 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
|
529 } |
46ee548e47e4
added 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 #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
|
532 {\ |
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
|
533 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
|
534 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
|
535 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
|
536 } |
46ee548e47e4
added 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 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
538 #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
|
539 {\ |
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
|
540 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
|
541 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
|
542 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
|
543 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
|
544 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
|
545 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
|
546 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
547 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
548 #define 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
|
549 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
550 /* DCT32 without 1/sqrt(2) coef zero scaling. */ |
1064 | 551 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
|
552 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
553 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
|
554 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
555 /* 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
|
556 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
|
557 BF(15, 16, COS0_15, 5); |
3598 | 558 /* 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
|
559 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
|
560 BF(16, 31,-COS1_0 , 1); |
3598 | 561 /* 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
|
562 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
|
563 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
|
564 /* 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
|
565 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
|
566 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
|
567 /* 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
|
568 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
|
569 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
|
570 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
|
571 BF(24, 31,-COS2_0 , 1); |
3598 | 572 /* 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
|
573 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
|
574 BF(12, 19, COS0_12, 2); |
3598 | 575 /* 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
|
576 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
|
577 BF(19, 28,-COS1_3 , 1); |
3598 | 578 /* 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
|
579 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
|
580 BF(11, 20, COS0_11, 2); |
3598 | 581 /* 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
|
582 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
|
583 BF(20, 27,-COS1_4 , 1); |
3598 | 584 /* 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
|
585 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
|
586 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
|
587 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
|
588 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
|
589 /* 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
|
590 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
|
591 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
|
592 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
|
593 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
|
594 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
|
595 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
|
596 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
|
597 BF(28, 31,-COS3_0 , 1); |
2967 | 598 |
599 | |
600 | |
3598 | 601 /* 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
|
602 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
|
603 BF(14, 17, COS0_14, 3); |
3598 | 604 /* 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
|
605 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
|
606 BF(17, 30,-COS1_1 , 1); |
3598 | 607 /* 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
|
608 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
|
609 BF( 9, 22, COS0_9 , 1); |
3598 | 610 /* 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
|
611 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
|
612 BF(22, 25,-COS1_6 , 2); |
3598 | 613 /* 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
|
614 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
|
615 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
|
616 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
|
617 BF(25, 30,-COS2_1 , 1); |
3598 | 618 |
619 /* 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
|
620 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
|
621 BF(13, 18, COS0_13, 3); |
3598 | 622 /* 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
|
623 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
|
624 BF(18, 29,-COS1_2 , 1); |
3598 | 625 /* 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
|
626 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
|
627 BF(10, 21, COS0_10, 1); |
3598 | 628 /* 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
|
629 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
|
630 BF(21, 26,-COS1_5 , 2); |
3598 | 631 /* 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
|
632 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
|
633 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
|
634 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
|
635 BF(26, 29,-COS2_2 , 1); |
3598 | 636 /* 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
|
637 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
|
638 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
|
639 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
|
640 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
|
641 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
|
642 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
|
643 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
|
644 BF(29, 30,-COS3_1 , 2); |
2967 | 645 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
646 /* 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
|
647 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
|
648 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
|
649 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
|
650 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
|
651 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
|
652 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
|
653 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
|
654 BF2(28, 29, 30, 31); |
2967 | 655 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
656 /* pass 6 */ |
2967 | 657 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
658 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
|
659 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
|
660 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
|
661 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
|
662 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
|
663 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
|
664 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
|
665 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
666 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
|
667 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
|
668 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
|
669 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
|
670 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
|
671 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
|
672 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
|
673 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
|
674 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
|
675 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
|
676 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
|
677 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
|
678 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
|
679 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
|
680 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
|
681 out[30] = tab[15]; |
2967 | 682 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
683 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
|
684 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
|
685 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
|
686 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
|
687 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
|
688 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
|
689 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
|
690 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
691 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
|
692 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
|
693 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
|
694 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
|
695 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
|
696 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
|
697 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
|
698 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
|
699 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
|
700 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
|
701 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
|
702 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
|
703 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
|
704 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
|
705 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
|
706 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
|
707 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
708 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
709 #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
|
710 |
2472 | 711 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
|
712 { |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
713 int sum1; |
2472 | 714 sum1 = (*sum) >> OUT_SHIFT; |
715 *sum &= (1<<OUT_SHIFT)-1; | |
2479 | 716 if (sum1 < OUT_MIN) |
717 sum1 = OUT_MIN; | |
718 else if (sum1 > OUT_MAX) | |
719 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
|
720 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
|
721 } |
46ee548e47e4
added 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 |
3752 | 723 /* signed 16x16 -> 32 multiply add accumulate */ |
724 #define MACS(rt, ra, rb) MAC16(rt, ra, rb) | |
3705 | 725 |
3752 | 726 /* signed 16x16 -> 32 multiply */ |
727 #define MULS(ra, rb) MUL16(ra, rb) | |
3705 | 728 |
82
46ee548e47e4
added 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 #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
|
730 |
2967 | 731 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
|
732 { |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
733 int sum1; |
2472 | 734 sum1 = (int)((*sum) >> OUT_SHIFT); |
735 *sum &= (1<<OUT_SHIFT)-1; | |
2479 | 736 if (sum1 < OUT_MIN) |
737 sum1 = OUT_MIN; | |
738 else if (sum1 > OUT_MAX) | |
739 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
|
740 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
|
741 } |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
742 |
3603 | 743 # 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
|
744 #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
|
745 |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
746 #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
|
747 { \ |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
748 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
|
749 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
|
750 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
|
751 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
|
752 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
|
753 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
|
754 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
|
755 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
|
756 } |
46ee548e47e4
added 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 |
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
|
758 #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
|
759 { \ |
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
|
760 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
|
761 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
|
762 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
|
763 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
|
764 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
|
765 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
|
766 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
|
767 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
|
768 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
|
769 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
|
770 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
|
771 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
|
772 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
|
773 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
|
774 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
|
775 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
|
776 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
|
777 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
|
778 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
|
779 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
|
780 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
|
781 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
|
782 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
|
783 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
|
784 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
|
785 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
786 |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
787 void ff_mpa_synth_init(MPA_INT *window) |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
788 { |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
789 int i; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
790 |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
791 /* max = 18760, max sum over all 16 coefs : 44736 */ |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
792 for(i=0;i<257;i++) { |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
793 int v; |
5032 | 794 v = ff_mpa_enwindow[i]; |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
795 #if WFRAC_BITS < 16 |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
796 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
|
797 #endif |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
798 window[i] = v; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
799 if ((i & 63) != 0) |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
800 v = -v; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
801 if (i != 0) |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
802 window[512 - i] = v; |
2967 | 803 } |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
804 } |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
805 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
806 /* 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
|
807 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
|
808 /* XXX: optimize by avoiding ring buffer usage */ |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
809 void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset, |
2979 | 810 MPA_INT *window, int *dither_state, |
2967 | 811 OUT_INT *samples, int incr, |
1064 | 812 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
|
813 { |
1064 | 814 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
|
815 register MPA_INT *synth_buf; |
2100 | 816 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
|
817 int j, offset, v; |
2479 | 818 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
|
819 #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
|
820 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
|
821 #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
|
822 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
|
823 #endif |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
824 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
825 dct32(tmp, sb_samples); |
2967 | 826 |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
827 offset = *synth_buf_offset; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
828 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
|
829 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
830 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
|
831 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
|
832 #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
|
833 /* 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
|
834 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
|
835 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
|
836 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
|
837 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
|
838 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
|
839 #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
|
840 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
|
841 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
842 /* 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
|
843 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
|
844 |
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
|
845 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
|
846 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
|
847 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
|
848 |
2473 | 849 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
|
850 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
|
851 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
|
852 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
|
853 SUM8(sum, -=, w + 32, p); |
2472 | 854 *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
|
855 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
|
856 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
|
857 |
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 /* 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
|
859 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
|
860 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
|
861 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
|
862 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
|
863 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
|
864 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
|
865 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
|
866 |
2472 | 867 *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
|
868 samples += incr; |
2472 | 869 sum += sum2; |
870 *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
|
871 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
|
872 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
|
873 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
|
874 } |
2967 | 875 |
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
|
876 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
|
877 SUM8(sum, -=, w + 32, p); |
2472 | 878 *samples = round_sample(&sum); |
2473 | 879 *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
|
880 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
881 offset = (offset - 32) & 511; |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
882 *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
|
883 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
884 |
2495 | 885 #define C3 FIXHR(0.86602540378443864676/2) |
886 | |
887 /* 0.5 / cos(pi*(2*i+1)/36) */ | |
888 static const int icos36[9] = { | |
889 FIXR(0.50190991877167369479), | |
890 FIXR(0.51763809020504152469), //0 | |
891 FIXR(0.55168895948124587824), | |
892 FIXR(0.61038729438072803416), | |
893 FIXR(0.70710678118654752439), //1 | |
894 FIXR(0.87172339781054900991), | |
895 FIXR(1.18310079157624925896), | |
896 FIXR(1.93185165257813657349), //2 | |
897 FIXR(5.73685662283492756461), | |
898 }; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
899 |
3599 | 900 /* 0.5 / cos(pi*(2*i+1)/36) */ |
901 static const int icos36h[9] = { | |
902 FIXHR(0.50190991877167369479/2), | |
903 FIXHR(0.51763809020504152469/2), //0 | |
904 FIXHR(0.55168895948124587824/2), | |
905 FIXHR(0.61038729438072803416/2), | |
906 FIXHR(0.70710678118654752439/2), //1 | |
907 FIXHR(0.87172339781054900991/2), | |
908 FIXHR(1.18310079157624925896/4), | |
909 FIXHR(1.93185165257813657349/4), //2 | |
910 // FIXHR(5.73685662283492756461), | |
911 }; | |
912 | |
82
46ee548e47e4
added 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 /* 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
|
914 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
|
915 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
|
916 { |
2495 | 917 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
|
918 |
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
919 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
|
920 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
|
921 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
|
922 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
|
923 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
|
924 in5= in[5*3] + in[4*3]; |
2495 | 925 in5 += in3; |
926 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
|
927 |
2495 | 928 in2= MULH(2*in2, C3); |
3599 | 929 in3= MULH(4*in3, C3); |
2967 | 930 |
2495 | 931 t1 = in0 - in4; |
3599 | 932 t2 = MULH(2*(in1 - in5), icos36h[4]); |
2495 | 933 |
2967 | 934 out[ 7]= |
2495 | 935 out[10]= t1 + t2; |
936 out[ 1]= | |
937 out[ 4]= t1 - t2; | |
938 | |
939 in0 += in4>>1; | |
940 in4 = in0 + in2; | |
3599 | 941 in5 += 2*in1; |
942 in1 = MULH(in5 + in3, icos36h[1]); | |
2967 | 943 out[ 8]= |
3599 | 944 out[ 9]= in4 + in1; |
2495 | 945 out[ 2]= |
3599 | 946 out[ 3]= in4 - in1; |
2967 | 947 |
2495 | 948 in0 -= in2; |
3599 | 949 in5 = MULH(2*(in5 - in3), icos36h[7]); |
2495 | 950 out[ 0]= |
3599 | 951 out[ 5]= in0 - in5; |
2495 | 952 out[ 6]= |
3599 | 953 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
|
954 } |
46ee548e47e4
added 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 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
956 /* cos(pi*i/18) */ |
2489 | 957 #define C1 FIXHR(0.98480775301220805936/2) |
958 #define C2 FIXHR(0.93969262078590838405/2) | |
959 #define C3 FIXHR(0.86602540378443864676/2) | |
960 #define C4 FIXHR(0.76604444311897803520/2) | |
961 #define C5 FIXHR(0.64278760968653932632/2) | |
962 #define C6 FIXHR(0.5/2) | |
963 #define C7 FIXHR(0.34202014332566873304/2) | |
964 #define C8 FIXHR(0.17364817766693034885/2) | |
965 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
966 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
967 /* using Lee like decomposition followed by hand coded 9 points DCT */ |
2489 | 968 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
|
969 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
970 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
|
971 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
|
972 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
973 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
|
974 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
|
975 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
|
976 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
|
977 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
978 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
|
979 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
|
980 in1 = in + j; |
2489 | 981 #if 0 |
982 //more accurate but slower | |
983 int64_t t0, t1, t2, t3; | |
984 t2 = in1[2*4] + in1[2*8] - in1[2*2]; | |
2967 | 985 |
2489 | 986 t3 = (in1[2*0] + (int64_t)(in1[2*6]>>1))<<32; |
987 t1 = in1[2*0] - in1[2*6]; | |
988 tmp1[ 6] = t1 - (t2>>1); | |
989 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
|
990 |
2489 | 991 t0 = MUL64(2*(in1[2*2] + in1[2*4]), C2); |
992 t1 = MUL64( in1[2*4] - in1[2*8] , -2*C8); | |
993 t2 = MUL64(2*(in1[2*2] + in1[2*8]), -C4); | |
2967 | 994 |
2489 | 995 tmp1[10] = (t3 - t0 - t2) >> 32; |
996 tmp1[ 2] = (t3 + t0 + t1) >> 32; | |
997 tmp1[14] = (t3 + t2 - t1) >> 32; | |
2967 | 998 |
2489 | 999 tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3); |
1000 t2 = MUL64(2*(in1[2*1] + in1[2*5]), C1); | |
1001 t3 = MUL64( in1[2*5] - in1[2*7] , -2*C7); | |
1002 t0 = MUL64(2*in1[2*3], C3); | |
1003 | |
1004 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
|
1005 |
2489 | 1006 tmp1[ 0] = (t2 + t3 + t0) >> 32; |
1007 tmp1[12] = (t2 + t1 - t0) >> 32; | |
1008 tmp1[ 8] = (t3 - t1 - t0) >> 32; | |
1009 #else | |
1010 t2 = in1[2*4] + in1[2*8] - in1[2*2]; | |
2967 | 1011 |
2489 | 1012 t3 = in1[2*0] + (in1[2*6]>>1); |
1013 t1 = in1[2*0] - in1[2*6]; | |
1014 tmp1[ 6] = t1 - (t2>>1); | |
1015 tmp1[16] = t1 + t2; | |
1016 | |
1017 t0 = MULH(2*(in1[2*2] + in1[2*4]), C2); | |
1018 t1 = MULH( in1[2*4] - in1[2*8] , -2*C8); | |
1019 t2 = MULH(2*(in1[2*2] + in1[2*8]), -C4); | |
2967 | 1020 |
2489 | 1021 tmp1[10] = t3 - t0 - t2; |
1022 tmp1[ 2] = t3 + t0 + t1; | |
1023 tmp1[14] = t3 + t2 - t1; | |
2967 | 1024 |
2489 | 1025 tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3); |
1026 t2 = MULH(2*(in1[2*1] + in1[2*5]), C1); | |
1027 t3 = MULH( in1[2*5] - in1[2*7] , -2*C7); | |
1028 t0 = MULH(2*in1[2*3], C3); | |
1029 | |
1030 t1 = MULH(2*(in1[2*1] + in1[2*7]), -C5); | |
1031 | |
1032 tmp1[ 0] = t2 + t3 + t0; | |
1033 tmp1[12] = t2 + t1 - t0; | |
1034 tmp1[ 8] = t3 - t1 - t0; | |
1035 #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
|
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 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1038 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
|
1039 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
|
1040 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
|
1041 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
|
1042 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
|
1043 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
|
1044 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1045 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
|
1046 t3 = tmp[i + 3]; |
3599 | 1047 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
|
1048 s3 = MULL(t3 - t2, icos36[8 - j]); |
2967 | 1049 |
2496
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
1050 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
|
1051 t1 = s0 - s1; |
2495 | 1052 out[(9 + j)*SBLIMIT] = MULH(t1, win[9 + j]) + buf[9 + j]; |
2489 | 1053 out[(8 - j)*SBLIMIT] = MULH(t1, win[8 - j]) + buf[8 - j]; |
1054 buf[9 + j] = MULH(t0, win[18 + 9 + j]); | |
1055 buf[8 - j] = MULH(t0, win[18 + 8 - j]); | |
2967 | 1056 |
2496
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
1057 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
|
1058 t1 = s2 - s3; |
2495 | 1059 out[(9 + 8 - j)*SBLIMIT] = MULH(t1, win[9 + 8 - j]) + buf[9 + 8 - j]; |
2489 | 1060 out[( j)*SBLIMIT] = MULH(t1, win[ j]) + buf[ j]; |
1061 buf[9 + 8 - j] = MULH(t0, win[18 + 9 + 8 - j]); | |
1062 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
|
1063 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
|
1064 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1065 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1066 s0 = tmp[16]; |
3599 | 1067 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
|
1068 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
|
1069 t1 = s0 - s1; |
2495 | 1070 out[(9 + 4)*SBLIMIT] = MULH(t1, win[9 + 4]) + buf[9 + 4]; |
2489 | 1071 out[(8 - 4)*SBLIMIT] = MULH(t1, win[8 - 4]) + buf[8 - 4]; |
1072 buf[9 + 4] = MULH(t0, win[18 + 9 + 4]); | |
1073 buf[8 - 4] = MULH(t0, win[18 + 8 - 4]); | |
0 | 1074 } |
1075 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1076 /* 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
|
1077 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
|
1078 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1079 int bound, i, v, n, ch, j, mant; |
1064 | 1080 uint8_t allocation[MPA_MAX_CHANNELS][SBLIMIT]; |
1081 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
|
1082 |
2967 | 1083 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
|
1084 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
|
1085 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
|
1086 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
|
1087 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1088 /* 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
|
1089 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
|
1090 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
|
1091 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
|
1092 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1093 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1094 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
|
1095 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
|
1096 } |
0 | 1097 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1098 /* 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
|
1099 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
|
1100 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
|
1101 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
|
1102 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
|
1103 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1104 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1105 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
|
1106 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
|
1107 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
|
1108 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
|
1109 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1110 } |
2967 | 1111 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1112 /* 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
|
1113 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
|
1114 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
|
1115 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
|
1116 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
|
1117 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
|
1118 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
|
1119 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
|
1120 } 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
|
1121 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
|
1122 } |
46ee548e47e4
added 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 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
|
1124 } |
46ee548e47e4
added 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 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
|
1127 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
|
1128 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
|
1129 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
|
1130 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
|
1131 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
|
1132 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
|
1133 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
|
1134 } 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
|
1135 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
|
1136 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
|
1137 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1138 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1139 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1140 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
|
1141 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1142 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1143 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
|
1144 { |
46ee548e47e4
added 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 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
|
1146 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
|
1147 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
|
1148 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
|
1149 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
|
1150 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
|
1151 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
|
1152 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1153 /* select decoding table */ |
5052
d981eb275c8f
remove dependency of mpeg audio encoder over mpeg audio decoder
aurel
parents:
5051
diff
changeset
|
1154 table = ff_mpa_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
|
1155 s->sample_rate, s->lsf); |
5032 | 1156 sblimit = ff_mpa_sblimit_table[table]; |
1157 alloc_table = ff_mpa_alloc_tables[table]; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1158 |
2967 | 1159 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
|
1160 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
|
1161 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
|
1162 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
|
1163 |
4652 | 1164 dprintf(s->avctx, "bound=%d sblimit=%d\n", bound, sblimit); |
1780 | 1165 |
1166 /* sanity check */ | |
1167 if( bound > sblimit ) bound = sblimit; | |
1168 | |
82
46ee548e47e4
added 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 /* 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
|
1170 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
|
1171 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
|
1172 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
|
1173 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
|
1174 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
|
1175 } |
46ee548e47e4
added 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 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
|
1177 } |
46ee548e47e4
added 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 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
|
1179 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
|
1180 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
|
1181 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
|
1182 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
|
1183 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
|
1184 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 #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
|
1187 { |
46ee548e47e4
added 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 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
|
1189 for(i=0;i<sblimit;i++) |
4652 | 1190 dprintf(s->avctx, " %d", bit_alloc[ch][i]); |
1191 dprintf(s->avctx, "\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
|
1192 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1194 #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
|
1195 |
46ee548e47e4
added 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 /* 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
|
1197 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
|
1198 for(ch=0;ch<s->nb_channels;ch++) { |
2967 | 1199 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
|
1200 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
|
1201 } |
46ee548e47e4
added 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 } |
2967 | 1203 |
82
46ee548e47e4
added 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 /* 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
|
1205 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
|
1206 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
|
1207 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
|
1208 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
|
1209 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
|
1210 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
|
1211 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
|
1212 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
|
1213 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
|
1214 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
|
1215 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
|
1216 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
|
1217 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
|
1218 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
|
1219 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
|
1220 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
|
1221 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
|
1222 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
|
1223 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
|
1224 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
|
1225 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
|
1226 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
|
1227 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
|
1228 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
|
1229 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
|
1230 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
|
1231 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1233 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 #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
|
1237 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
|
1238 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
|
1239 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
|
1240 sf = scale_factors[ch][i]; |
4652 | 1241 dprintf(s->avctx, " %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
|
1242 } else { |
4652 | 1243 dprintf(s->avctx, " -"); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1244 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1245 } |
4652 | 1246 dprintf(s->avctx, "\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
|
1247 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1248 #endif |
0 | 1249 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1250 /* 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
|
1251 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
|
1252 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
|
1253 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
|
1254 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
|
1255 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
|
1256 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
|
1257 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
|
1258 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
|
1259 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
|
1260 qindex = alloc_table[j+b]; |
5032 | 1261 bits = ff_mpa_quant_bits[qindex]; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1262 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
|
1263 /* 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
|
1264 v = get_bits(&s->gb, -bits); |
5032 | 1265 steps = ff_mpa_quant_steps[qindex]; |
2967 | 1266 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
|
1267 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
|
1268 v = v / steps; |
2967 | 1269 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
|
1270 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
|
1271 v = v / steps; |
2967 | 1272 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
|
1273 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
|
1274 } 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
|
1275 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
|
1276 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
|
1277 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
|
1278 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
|
1279 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1280 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1281 } 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
|
1282 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
|
1283 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
|
1284 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
|
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 } |
46ee548e47e4
added 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 /* next subband in alloc table */ |
2967 | 1288 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
|
1289 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1290 /* 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
|
1291 for(i=bound;i<sblimit;i++) { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1292 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
|
1293 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
|
1294 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
|
1295 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
|
1296 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
|
1297 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
|
1298 qindex = alloc_table[j+b]; |
5032 | 1299 bits = ff_mpa_quant_bits[qindex]; |
82
46ee548e47e4
added 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 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
|
1301 /* 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
|
1302 v = get_bits(&s->gb, -bits); |
5032 | 1303 steps = ff_mpa_quant_steps[qindex]; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1304 mant = 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
|
1305 v = v / steps; |
2967 | 1306 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
|
1307 l2_unscale_group(steps, mant, scale0); |
2967 | 1308 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
|
1309 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
|
1310 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
|
1311 v = v / steps; |
2967 | 1312 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
|
1313 l2_unscale_group(steps, mant, scale0); |
2967 | 1314 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
|
1315 l2_unscale_group(steps, mant, scale1); |
2967 | 1316 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
|
1317 l2_unscale_group(steps, v, scale0); |
2967 | 1318 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
|
1319 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
|
1320 } else { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1321 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
|
1322 mant = get_bits(&s->gb, bits); |
2967 | 1323 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
|
1324 l1_unscale(bits - 1, mant, scale0); |
2967 | 1325 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
|
1326 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
|
1327 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1328 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1329 } 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
|
1330 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
|
1331 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
|
1332 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
|
1333 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
|
1334 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
|
1335 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
|
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 /* next subband in alloc table */ |
2967 | 1338 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
|
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 /* 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
|
1341 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
|
1342 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
|
1343 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
|
1344 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
|
1345 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
|
1346 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1347 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1348 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1349 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1350 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
|
1351 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1352 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1353 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
|
1354 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
|
1355 { |
46ee548e47e4
added 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 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
|
1357 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
|
1358 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
|
1359 } 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
|
1360 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
|
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 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
|
1363 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
|
1364 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
|
1365 } 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
|
1366 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
|
1367 } |
46ee548e47e4
added 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 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
|
1369 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
|
1370 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
|
1371 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1372 |
2967 | 1373 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
|
1374 GranuleDef *g, |
1064 | 1375 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
|
1376 { |
1064 | 1377 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
|
1378 int len, i, j, k, l, v0, shift, gain, gains[3]; |
1064 | 1379 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
|
1380 |
46ee548e47e4
added 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 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
|
1382 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
|
1383 shift = g->scalefac_scale + 1; |
0 | 1384 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1385 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
|
1386 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
|
1387 for(i=0;i<g->long_end;i++) { |
3625 | 1388 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
|
1389 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
|
1390 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
|
1391 *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
|
1392 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1393 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1394 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
|
1395 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
|
1396 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
|
1397 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
|
1398 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
|
1399 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
|
1400 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
|
1401 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
|
1402 for(l=0;l<3;l++) { |
3625 | 1403 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
|
1404 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
|
1405 *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
|
1406 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1409 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1410 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1411 /* 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
|
1412 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
|
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 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
|
1415 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
|
1416 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
|
1417 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
|
1418 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1419 |
4469 | 1420 |
1421 static void switch_buffer(MPADecodeContext *s, int *pos, int *end_pos, int *end_pos2){ | |
1422 if(s->in_gb.buffer && *pos >= s->gb.size_in_bits){ | |
1423 s->gb= s->in_gb; | |
1424 s->in_gb.buffer=NULL; | |
1425 assert((get_bits_count(&s->gb) & 7) == 0); | |
1426 skip_bits_long(&s->gb, *pos - *end_pos); | |
1427 *end_pos2= | |
1428 *end_pos= *end_pos2 + get_bits_count(&s->gb) - *pos; | |
1429 *pos= get_bits_count(&s->gb); | |
1430 } | |
1431 } | |
1432 | |
82
46ee548e47e4
added 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 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
|
1434 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
|
1435 { |
46ee548e47e4
added 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 int s_index; |
3626
a6251ee2dfdb
move variable declarations so that their scope is smaller
michael
parents:
3625
diff
changeset
|
1437 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
|
1438 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
|
1439 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
|
1440 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
|
1441 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1442 /* 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
|
1443 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
|
1444 for(i=0;i<3;i++) { |
3626
a6251ee2dfdb
move variable declarations so that their scope is smaller
michael
parents:
3625
diff
changeset
|
1445 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
|
1446 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
|
1447 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
|
1448 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
|
1449 /* 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
|
1450 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
|
1451 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
|
1452 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
|
1453 vlc = &huff_vlc[l]; |
0 | 1454 |
3609 | 1455 if(!l){ |
3636
031252e99956
another silly typo which surprisingly neither valgrind nor cmp of the file output cought
michael
parents:
3635
diff
changeset
|
1456 memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid)*2*j); |
3609 | 1457 s_index += 2*j; |
1458 continue; | |
1459 } | |
1460 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1461 /* 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
|
1462 for(;j>0;j--) { |
3626
a6251ee2dfdb
move variable declarations so that their scope is smaller
michael
parents:
3625
diff
changeset
|
1463 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
|
1464 int pos= get_bits_count(&s->gb); |
3624 | 1465 |
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
|
1466 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
|
1467 // av_log(NULL, AV_LOG_ERROR, "pos: %d %d %d %d\n", pos, end_pos, end_pos2, s_index); |
4469 | 1468 switch_buffer(s, &pos, &end_pos, &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
|
1469 // 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
|
1470 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
|
1471 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
|
1472 } |
3623
d0242f36a793
reduce size of vlc table, thats slightly faster here
michael
parents:
3622
diff
changeset
|
1473 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
|
1474 |
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1475 if(!y){ |
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1476 g->sb_hybrid[s_index ] = |
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1477 g->sb_hybrid[s_index+1] = 0; |
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1478 s_index += 2; |
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1479 continue; |
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1480 } |
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1481 |
3624 | 1482 exponent= exponents[s_index]; |
3609 | 1483 |
4652 | 1484 dprintf(s->avctx, "region=%d n=%d x=%d y=%d exp=%d\n", |
3624 | 1485 i, g->region_size[i] - j, x, y, exponent); |
3627 | 1486 if(y&16){ |
1487 x = y >> 5; | |
1488 y = y & 0x0f; | |
3622 | 1489 if (x < 15){ |
3625 | 1490 v = expval_table[ exponent ][ x ]; |
1491 // v = expval_table[ (exponent&3) ][ x ] >> FFMIN(0 - (exponent>>2), 31); | |
3622 | 1492 }else{ |
1493 x += get_bitsz(&s->gb, linbits); | |
3624 | 1494 v = l3_unscale(x, exponent); |
3622 | 1495 } |
82
46ee548e47e4
added 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 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
|
1497 v = -v; |
3627 | 1498 g->sb_hybrid[s_index] = v; |
3622 | 1499 if (y < 15){ |
3625 | 1500 v = expval_table[ exponent ][ y ]; |
3622 | 1501 }else{ |
1502 y += get_bitsz(&s->gb, linbits); | |
3624 | 1503 v = l3_unscale(y, exponent); |
3622 | 1504 } |
82
46ee548e47e4
added 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 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
|
1506 v = -v; |
3627 | 1507 g->sb_hybrid[s_index+1] = v; |
1508 }else{ | |
1509 x = y >> 5; | |
1510 y = y & 0x0f; | |
1511 x += y; | |
1512 if (x < 15){ | |
1513 v = expval_table[ exponent ][ x ]; | |
1514 }else{ | |
1515 x += get_bitsz(&s->gb, linbits); | |
1516 v = l3_unscale(x, exponent); | |
1517 } | |
1518 if (get_bits1(&s->gb)) | |
1519 v = -v; | |
1520 g->sb_hybrid[s_index+!!y] = v; | |
3635 | 1521 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
|
1522 } |
3627 | 1523 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
|
1524 } |
46ee548e47e4
added 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 } |
2967 | 1526 |
82
46ee548e47e4
added 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 /* 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
|
1528 vlc = &huff_quad_vlc[g->count1table_select]; |
3612 | 1529 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
|
1530 while (s_index <= 572) { |
3626
a6251ee2dfdb
move variable declarations so that their scope is smaller
michael
parents:
3625
diff
changeset
|
1531 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
|
1532 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
|
1533 if (pos >= end_pos) { |
3647 | 1534 if (pos > end_pos2 && last_pos){ |
1535 /* some encoders generate an incorrect size for this | |
1536 part. We must go back into the data */ | |
1537 s_index -= 4; | |
1538 skip_bits_long(&s->gb, last_pos - pos); | |
1539 av_log(NULL, AV_LOG_INFO, "overread, skip %d enddists: %d %d\n", last_pos - pos, end_pos-pos, end_pos2-pos); | |
4205
8c28f03cfdd5
detect a few more errors (fixes libmp3-bug.avi again)
michael
parents:
4204
diff
changeset
|
1540 if(s->error_resilience >= FF_ER_COMPLIANT) |
8c28f03cfdd5
detect a few more errors (fixes libmp3-bug.avi again)
michael
parents:
4204
diff
changeset
|
1541 s_index=0; |
3647 | 1542 break; |
1543 } | |
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
|
1544 // av_log(NULL, AV_LOG_ERROR, "pos2: %d %d %d %d\n", pos, end_pos, end_pos2, s_index); |
4469 | 1545 switch_buffer(s, &pos, &end_pos, &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
|
1546 // 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
|
1547 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
|
1548 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
|
1549 } |
3612 | 1550 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
|
1551 |
3610 | 1552 code = get_vlc2(&s->gb, vlc->table, vlc->bits, 1); |
4652 | 1553 dprintf(s->avctx, "t=%d code=%d\n", g->count1table_select, code); |
3610 | 1554 g->sb_hybrid[s_index+0]= |
1555 g->sb_hybrid[s_index+1]= | |
1556 g->sb_hybrid[s_index+2]= | |
1557 g->sb_hybrid[s_index+3]= 0; | |
1558 while(code){ | |
4908
777f250df232
Fix multiple "¡Æinline/static¡Ç is not at beginning of declaration" warnings.
diego
parents:
4796
diff
changeset
|
1559 static const 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
|
1560 int v; |
3610 | 1561 int pos= s_index+idxtab[code]; |
1562 code ^= 8>>idxtab[code]; | |
3625 | 1563 v = exp_table[ exponents[pos] ]; |
1564 // v = exp_table[ (exponents[pos]&3) ] >> FFMIN(0 - (exponents[pos]>>2), 31); | |
3610 | 1565 if(get_bits1(&s->gb)) |
1566 v = -v; | |
1567 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
|
1568 } |
3610 | 1569 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
|
1570 } |
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
|
1571 /* skip extension bits */ |
4468 | 1572 bits_left = end_pos2 - get_bits_count(&s->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
|
1573 //av_log(NULL, AV_LOG_ERROR, "left:%d buf:%p\n", bits_left, s->in_gb.buffer); |
4468 | 1574 if (bits_left < 0/* || bits_left > 500*/) { |
4204 | 1575 av_log(NULL, AV_LOG_ERROR, "bits_left=%d\n", bits_left); |
4205
8c28f03cfdd5
detect a few more errors (fixes libmp3-bug.avi again)
michael
parents:
4204
diff
changeset
|
1576 s_index=0; |
8c28f03cfdd5
detect a few more errors (fixes libmp3-bug.avi again)
michael
parents:
4204
diff
changeset
|
1577 }else if(bits_left > 0 && s->error_resilience >= FF_ER_AGGRESSIVE){ |
8c28f03cfdd5
detect a few more errors (fixes libmp3-bug.avi again)
michael
parents:
4204
diff
changeset
|
1578 av_log(NULL, AV_LOG_ERROR, "bits_left=%d\n", bits_left); |
8c28f03cfdd5
detect a few more errors (fixes libmp3-bug.avi again)
michael
parents:
4204
diff
changeset
|
1579 s_index=0; |
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
|
1580 } |
4205
8c28f03cfdd5
detect a few more errors (fixes libmp3-bug.avi again)
michael
parents:
4204
diff
changeset
|
1581 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
|
1582 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
|
1583 |
4468 | 1584 i= get_bits_count(&s->gb); |
4469 | 1585 switch_buffer(s, &i, &end_pos, &end_pos2); |
4468 | 1586 |
82
46ee548e47e4
added 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 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
|
1588 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 /* 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
|
1591 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
|
1592 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
|
1593 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
|
1594 { |
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
|
1595 int i, j, len; |
1064 | 1596 int32_t *ptr, *dst, *ptr1; |
1597 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
|
1598 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1599 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
|
1600 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
|
1601 |
46ee548e47e4
added 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 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
|
1603 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
|
1604 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
|
1605 } 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
|
1606 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
|
1607 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1608 } 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
|
1609 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
|
1610 } |
2967 | 1611 |
82
46ee548e47e4
added 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 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
|
1613 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
|
1614 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
|
1615 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
|
1616 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
|
1617 *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
|
1618 *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
|
1619 *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
|
1620 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
|
1621 } |
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
|
1622 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
|
1623 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
|
1624 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1625 } |
46ee548e47e4
added 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 #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
|
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 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
|
1630 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
|
1631 { |
46ee548e47e4
added 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 int i, j, k, l; |
1064 | 1633 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
|
1634 int sf_max, tmp0, tmp1, sf, len, non_zero_found; |
1064 | 1635 int32_t (*is_tab)[16]; |
1636 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
|
1637 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
|
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 /* 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
|
1640 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
|
1641 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
|
1642 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
|
1643 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
|
1644 } 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
|
1645 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
|
1646 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
|
1647 } |
2967 | 1648 |
82
46ee548e47e4
added 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 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
|
1650 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
|
1651 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1652 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
|
1653 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
|
1654 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
|
1655 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
|
1656 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
|
1657 /* 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
|
1658 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
|
1659 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
|
1660 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
|
1661 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
|
1662 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
|
1663 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
|
1664 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
|
1665 /* 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
|
1666 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
|
1667 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
|
1668 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
|
1669 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
|
1670 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1671 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1672 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
|
1673 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
|
1674 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
|
1675 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1676 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
|
1677 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
|
1678 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
|
1679 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
|
1680 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
|
1681 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
|
1682 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1683 } 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
|
1684 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
|
1685 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
|
1686 /* 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
|
1687 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
|
1688 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
|
1689 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
|
1690 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
|
1691 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
|
1692 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
|
1693 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1694 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1695 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1696 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1697 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1698 |
2967 | 1699 non_zero_found = non_zero_found_short[0] | |
1700 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
|
1701 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
|
1702 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1703 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
|
1704 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
|
1705 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
|
1706 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
|
1707 /* 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
|
1708 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
|
1709 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
|
1710 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
|
1711 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
|
1712 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
|
1713 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1714 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1715 /* 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
|
1716 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
|
1717 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
|
1718 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
|
1719 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
|
1720 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
|
1721 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
|
1722 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
|
1723 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
|
1724 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
|
1725 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
|
1726 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1727 } 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
|
1728 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
|
1729 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
|
1730 /* 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
|
1731 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
|
1732 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
|
1733 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
|
1734 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
|
1735 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
|
1736 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
|
1737 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1738 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1741 } 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
|
1742 /* 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
|
1743 /* 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
|
1744 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
|
1745 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
|
1746 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
|
1747 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
|
1748 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
|
1749 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
|
1750 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
|
1751 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
|
1752 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1753 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1754 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1755 |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1756 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
|
1757 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
|
1758 { |
2491 | 1759 int32_t *ptr, *csa; |
1760 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
|
1761 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1762 /* 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
|
1763 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
|
1764 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
|
1765 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
|
1766 /* 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
|
1767 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
|
1768 } 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
|
1769 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
|
1770 } |
2967 | 1771 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1772 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
|
1773 for(i = n;i > 0;i--) { |
2491 | 1774 int tmp0, tmp1, tmp2; |
1775 csa = &csa_table[0][0]; | |
1776 #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
|
1777 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
|
1778 tmp1 = ptr[ j];\ |
2491 | 1779 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
|
1780 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
|
1781 ptr[ j] = 4*(tmp2 + MULH(tmp0, csa[3+4*j])); |
2491 | 1782 |
1783 INT_AA(0) | |
1784 INT_AA(1) | |
1785 INT_AA(2) | |
1786 INT_AA(3) | |
1787 INT_AA(4) | |
1788 INT_AA(5) | |
1789 INT_AA(6) | |
1790 INT_AA(7) | |
2967 | 1791 |
1792 ptr += 18; | |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1793 } |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1794 } |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1795 |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1796 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
|
1797 GranuleDef *g) |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1798 { |
2491 | 1799 int32_t *ptr; |
1800 int n, i; | |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1801 |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1802 /* we antialias only "long" bands */ |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1803 if (g->block_type == 2) { |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1804 if (!g->switch_point) |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1805 return; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1806 /* XXX: check this for 8000Hz case */ |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1807 n = 1; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1808 } else { |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1809 n = SBLIMIT - 1; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1810 } |
2967 | 1811 |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1812 ptr = g->sb_hybrid + 18; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1813 for(i = n;i > 0;i--) { |
2491 | 1814 float tmp0, tmp1; |
2967 | 1815 float *csa = &csa_table_float[0][0]; |
2491 | 1816 #define FLOAT_AA(j)\ |
1817 tmp0= ptr[-1-j];\ | |
1818 tmp1= ptr[ j];\ | |
1819 ptr[-1-j] = lrintf(tmp0 * csa[0+4*j] - tmp1 * csa[1+4*j]);\ | |
1820 ptr[ j] = lrintf(tmp0 * csa[1+4*j] + tmp1 * csa[0+4*j]); | |
2967 | 1821 |
2491 | 1822 FLOAT_AA(0) |
1823 FLOAT_AA(1) | |
1824 FLOAT_AA(2) | |
1825 FLOAT_AA(3) | |
1826 FLOAT_AA(4) | |
1827 FLOAT_AA(5) | |
1828 FLOAT_AA(6) | |
1829 FLOAT_AA(7) | |
1830 | |
2967 | 1831 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
|
1832 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1833 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1834 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1835 static void compute_imdct(MPADecodeContext *s, |
2967 | 1836 GranuleDef *g, |
1064 | 1837 int32_t *sb_samples, |
1838 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
|
1839 { |
2495 | 1840 int32_t *ptr, *win, *win1, *buf, *out_ptr, *ptr1; |
1064 | 1841 int32_t out2[12]; |
2495 | 1842 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
|
1843 |
46ee548e47e4
added 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 /* 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
|
1845 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
|
1846 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
|
1847 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
|
1848 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
|
1849 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
|
1850 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
|
1851 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
|
1852 } |
46ee548e47e4
added 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 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
|
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 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
|
1856 /* 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
|
1857 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
|
1858 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
|
1859 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
|
1860 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
|
1861 } 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
|
1862 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
|
1863 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1864 |
46ee548e47e4
added 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 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
|
1866 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
|
1867 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
|
1868 /* 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
|
1869 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
|
1870 /* 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
|
1871 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
|
1872 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
|
1873 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
|
1874 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
|
1875 /* 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
|
1876 win = win1 + ((4 * 36) & -(j & 1)); |
2489 | 1877 imdct36(out_ptr, buf, ptr, win); |
1878 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
|
1879 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
|
1880 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
|
1881 } |
46ee548e47e4
added 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=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
|
1883 /* 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
|
1884 win = mdct_win[2] + ((4 * 36) & -(j & 1)); |
2495 | 1885 out_ptr = sb_samples + j; |
2967 | 1886 |
2495 | 1887 for(i=0; i<6; i++){ |
1888 *out_ptr = buf[i]; | |
1889 out_ptr += SBLIMIT; | |
1890 } | |
1891 imdct12(out2, ptr + 0); | |
1892 for(i=0;i<6;i++) { | |
1893 *out_ptr = MULH(out2[i], win[i]) + buf[i + 6*1]; | |
1894 buf[i + 6*2] = MULH(out2[i + 6], win[i + 6]); | |
1895 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
|
1896 } |
2495 | 1897 imdct12(out2, ptr + 1); |
1898 for(i=0;i<6;i++) { | |
1899 *out_ptr = MULH(out2[i], win[i]) + buf[i + 6*2]; | |
1900 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
|
1901 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
|
1902 } |
2495 | 1903 imdct12(out2, ptr + 2); |
1904 for(i=0;i<6;i++) { | |
1905 buf[i + 6*0] = MULH(out2[i], win[i]) + buf[i + 6*0]; | |
1906 buf[i + 6*1] = MULH(out2[i + 6], win[i + 6]); | |
1907 buf[i + 6*2] = 0; | |
1908 } | |
82
46ee548e47e4
added 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 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
|
1910 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
|
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 /* 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
|
1913 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
|
1914 /* 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
|
1915 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
|
1916 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
|
1917 *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
|
1918 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
|
1919 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
|
1920 } |
46ee548e47e4
added 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 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
|
1922 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 |
404 | 1925 #if defined(DEBUG) |
1064 | 1926 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
|
1927 { |
46ee548e47e4
added 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 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
|
1929 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
|
1930 int i; |
1064 | 1931 int32_t v; |
2967 | 1932 |
82
46ee548e47e4
added 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 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
|
1934 if (!f) { |
2967 | 1935 snprintf(buf, sizeof(buf), "/tmp/out%d.%s.pcm", |
1936 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
|
1937 #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
|
1938 "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
|
1939 #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
|
1940 "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
|
1941 #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
|
1942 ); |
82
46ee548e47e4
added 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 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
|
1944 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
|
1945 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
|
1946 files[fnum] = f; |
0 | 1947 } |
2967 | 1948 |
82
46ee548e47e4
added 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 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
|
1950 static int pos = 0; |
2477 | 1951 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
|
1952 for(i=0;i<n;i++) { |
2477 | 1953 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
|
1954 if ((i % 18) == 17) |
2477 | 1955 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
|
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 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
|
1958 } |
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
|
1959 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
|
1960 /* 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
|
1961 v = tab[i] << (23 - FRAC_BITS); |
1064 | 1962 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
|
1963 } |
82
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 #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
|
1966 |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 /* 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
|
1969 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
|
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 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
|
1972 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
|
1973 GranuleDef granules[2][2], *g; |
1064 | 1974 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
|
1975 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1976 /* 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
|
1977 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
|
1978 main_data_begin = get_bits(&s->gb, 8); |
3613 | 1979 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
|
1980 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
|
1981 } 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
|
1982 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
|
1983 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
|
1984 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
|
1985 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
|
1986 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
|
1987 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
|
1988 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
|
1989 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
|
1990 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
|
1991 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1992 } |
2967 | 1993 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1994 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
|
1995 for(ch=0;ch<s->nb_channels;ch++) { |
4652 | 1996 dprintf(s->avctx, "gr=%d ch=%d: side_info\n", gr, 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
|
1997 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
|
1998 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
|
1999 g->big_values = get_bits(&s->gb, 9); |
4202 | 2000 if(g->big_values > 288){ |
4652 | 2001 av_log(s->avctx, AV_LOG_ERROR, "big_values too big\n"); |
4202 | 2002 return -1; |
2003 } | |
2004 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2005 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
|
2006 /* 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
|
2007 1/sqrt(2) renormalization factor */ |
2967 | 2008 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
|
2009 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
|
2010 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
|
2011 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
|
2012 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
|
2013 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
|
2014 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
|
2015 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
|
2016 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
|
2017 g->block_type = get_bits(&s->gb, 2); |
4202 | 2018 if (g->block_type == 0){ |
2019 av_log(NULL, AV_LOG_ERROR, "invalid block type\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
|
2020 return -1; |
4202 | 2021 } |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2022 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
|
2023 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
|
2024 g->table_select[i] = get_bits(&s->gb, 5); |
2967 | 2025 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
|
2026 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
|
2027 /* 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
|
2028 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
|
2029 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
|
2030 else { |
2967 | 2031 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
|
2032 g->region_size[0] = (36 / 2); |
2967 | 2033 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
|
2034 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
|
2035 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
|
2036 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
|
2037 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2038 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
|
2039 } 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
|
2040 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
|
2041 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
|
2042 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
|
2043 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
|
2044 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
|
2045 /* 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
|
2046 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
|
2047 region_address2 = get_bits(&s->gb, 3); |
4652 | 2048 dprintf(s->avctx, "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
|
2049 region_address1, region_address2); |
2967 | 2050 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
|
2051 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
|
2052 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
|
2053 /* 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
|
2054 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
|
2055 l = 22; |
2967 | 2056 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
|
2057 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
|
2058 } |
46ee548e47e4
added 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 /* 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
|
2060 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
|
2061 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
|
2062 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
|
2063 for(i=0;i<3;i++) { |
3608 | 2064 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
|
2065 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
|
2066 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
|
2067 } |
46ee548e47e4
added 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 /* 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
|
2070 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
|
2071 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
|
2072 /* 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
|
2073 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
|
2074 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
|
2075 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
|
2076 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
|
2077 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
|
2078 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
|
2079 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
|
2080 g->long_end = 4; /* 8000 Hz */ |
2967 | 2081 |
3608 | 2082 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
|
2083 } 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
|
2084 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
|
2085 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
|
2086 } |
46ee548e47e4
added 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 } 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
|
2088 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
|
2089 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
|
2090 } |
2967 | 2091 |
82
46ee548e47e4
added 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 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
|
2093 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
|
2094 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
|
2095 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
|
2096 g->count1table_select = get_bits(&s->gb, 1); |
4652 | 2097 dprintf(s->avctx, "block_type=%d switch_point=%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
|
2098 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
|
2099 } |
46ee548e47e4
added 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 } |
0 | 2101 |
2432 | 2102 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
|
2103 const uint8_t *ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3); |
3647 | 2104 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
|
2105 /* now we get bits from the main_data_begin offset */ |
4652 | 2106 dprintf(s->avctx, "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
|
2107 //av_log(NULL, AV_LOG_ERROR, "backstep:%d, lastbuf:%d\n", main_data_begin, s->last_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
|
2108 |
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
|
2109 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
|
2110 s->in_gb= s->gb; |
4204 | 2111 init_get_bits(&s->gb, s->last_buf, s->last_buf_size*8); |
2112 skip_bits_long(&s->gb, 8*(s->last_buf_size - main_data_begin)); | |
2432 | 2113 } |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2114 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2115 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
|
2116 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
|
2117 g = &granules[ch][gr]; |
4204 | 2118 if(get_bits_count(&s->gb)<0){ |
4796 | 2119 av_log(NULL, AV_LOG_ERROR, "mdb:%d, lastbuf:%d skipping granule %d\n", |
4204 | 2120 main_data_begin, s->last_buf_size, gr); |
2121 skip_bits_long(&s->gb, g->part2_3_length); | |
2122 memset(g->sb_hybrid, 0, sizeof(g->sb_hybrid)); | |
2123 if(get_bits_count(&s->gb) >= s->gb.size_in_bits && s->in_gb.buffer){ | |
2124 skip_bits_long(&s->in_gb, get_bits_count(&s->gb) - s->gb.size_in_bits); | |
2125 s->gb= s->in_gb; | |
2126 s->in_gb.buffer=NULL; | |
2127 } | |
2128 continue; | |
2129 } | |
2967 | 2130 |
82
46ee548e47e4
added 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 bits_pos = get_bits_count(&s->gb); |
2967 | 2132 |
82
46ee548e47e4
added 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 if (!s->lsf) { |
1064 | 2134 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
|
2135 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
|
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 /* 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
|
2138 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
|
2139 slen2 = slen_table[1][g->scalefac_compress]; |
4652 | 2140 dprintf(s->avctx, "slen1=%d slen2=%d\n", slen1, slen2); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2141 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
|
2142 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
|
2143 j = 0; |
3616 | 2144 if(slen1){ |
2145 for(i=0;i<n;i++) | |
2146 g->scale_factors[j++] = get_bits(&s->gb, slen1); | |
2147 }else{ | |
2148 for(i=0;i<n;i++) | |
2149 g->scale_factors[j++] = 0; | |
2150 } | |
2151 if(slen2){ | |
2152 for(i=0;i<18;i++) | |
2153 g->scale_factors[j++] = get_bits(&s->gb, slen2); | |
2154 for(i=0;i<3;i++) | |
2155 g->scale_factors[j++] = 0; | |
2156 }else{ | |
2157 for(i=0;i<21;i++) | |
2158 g->scale_factors[j++] = 0; | |
2159 } | |
82
46ee548e47e4
added 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 } 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
|
2161 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
|
2162 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
|
2163 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
|
2164 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
|
2165 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
|
2166 slen = (k < 2) ? slen1 : slen2; |
3616 | 2167 if(slen){ |
2168 for(i=0;i<n;i++) | |
2169 g->scale_factors[j++] = get_bits(&s->gb, slen); | |
2170 }else{ | |
2171 for(i=0;i<n;i++) | |
2172 g->scale_factors[j++] = 0; | |
2173 } | |
82
46ee548e47e4
added 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 } 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
|
2175 /* 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
|
2176 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
|
2177 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
|
2178 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
|
2179 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2182 g->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
|
2183 } |
404 | 2184 #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
|
2185 { |
4652 | 2186 dprintf(s->avctx, "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
|
2187 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
|
2188 for(i=0;i<j;i++) |
4652 | 2189 dprintf(s->avctx, " %d", g->scale_factors[i]); |
2190 dprintf(s->avctx, "\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
|
2191 } |
0 | 2192 #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
|
2193 } 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
|
2194 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
|
2195 |
46ee548e47e4
added 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 /* 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
|
2197 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
|
2198 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
|
2199 } 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
|
2200 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
|
2201 } |
46ee548e47e4
added 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 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
|
2203 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
|
2204 /* 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
|
2205 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
|
2206 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
|
2207 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
|
2208 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
|
2209 } 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
|
2210 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
|
2211 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
|
2212 } 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
|
2213 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
|
2214 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
|
2215 } |
46ee548e47e4
added 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 } 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
|
2217 /* 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
|
2218 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
|
2219 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
|
2220 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
|
2221 } 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
|
2222 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
|
2223 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
|
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 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
|
2226 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
|
2227 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
|
2228 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 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
|
2232 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
|
2233 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
|
2234 sl = slen[k]; |
3617 | 2235 if(sl){ |
3616 | 2236 for(i=0;i<n;i++) |
2237 g->scale_factors[j++] = get_bits(&s->gb, sl); | |
2238 }else{ | |
2239 for(i=0;i<n;i++) | |
2240 g->scale_factors[j++] = 0; | |
2241 } | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2242 } |
46ee548e47e4
added 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 /* 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
|
2244 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
|
2245 g->scale_factors[j] = 0; |
404 | 2246 #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
|
2247 { |
4652 | 2248 dprintf(s->avctx, "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
|
2249 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
|
2250 for(i=0;i<40;i++) |
4652 | 2251 dprintf(s->avctx, " %d", g->scale_factors[i]); |
2252 dprintf(s->avctx, "\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
|
2253 } |
46ee548e47e4
added 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 #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
|
2255 } |
46ee548e47e4
added 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 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2257 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
|
2258 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2259 /* read Huffman coded residue */ |
4204 | 2260 huffman_decode(s, g, exponents, bits_pos + g->part2_3_length); |
404 | 2261 #if defined(DEBUG) |
2262 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
|
2263 #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
|
2264 } /* 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
|
2265 |
46ee548e47e4
added 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 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
|
2267 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
|
2268 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2269 for(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
|
2270 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
|
2271 |
46ee548e47e4
added 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 reorder_block(s, g); |
404 | 2273 #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
|
2274 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
|
2275 #endif |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
2276 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
|
2277 #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
|
2278 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
|
2279 #endif |
2967 | 2280 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
|
2281 #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
|
2282 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
|
2283 #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
|
2284 } |
46ee548e47e4
added 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 } /* gr */ |
4204 | 2286 if(get_bits_count(&s->gb)<0) |
2287 skip_bits_long(&s->gb, -get_bits_count(&s->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
|
2288 return nb_granules * 18; |
0 | 2289 } |
2290 | |
2967 | 2291 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
|
2292 OUT_INT *samples, const uint8_t *buf, int buf_size) |
0 | 2293 { |
82
46ee548e47e4
added 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 int i, nb_frames, ch; |
2479 | 2295 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
|
2296 |
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
|
2297 init_get_bits(&s->gb, buf + HEADER_SIZE, (buf_size - HEADER_SIZE)*8); |
2967 | 2298 |
0 | 2299 /* skip error protection field */ |
2300 if (s->error_protection) | |
2301 get_bits(&s->gb, 16); | |
2302 | |
4652 | 2303 dprintf(s->avctx, "frame %d:\n", s->frame_count); |
0 | 2304 switch(s->layer) { |
2305 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
|
2306 nb_frames = mp_decode_layer1(s); |
0 | 2307 break; |
2308 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
|
2309 nb_frames = mp_decode_layer2(s); |
0 | 2310 break; |
2311 case 3: | |
2312 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
|
2313 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
|
2314 |
3643 | 2315 s->last_buf_size=0; |
2316 if(s->in_gb.buffer){ | |
2317 align_get_bits(&s->gb); | |
2318 i= (s->gb.size_in_bits - get_bits_count(&s->gb))>>3; | |
3647 | 2319 if(i >= 0 && i <= BACKSTEP_SIZE){ |
3643 | 2320 memmove(s->last_buf, s->gb.buffer + (get_bits_count(&s->gb)>>3), i); |
2321 s->last_buf_size=i; | |
3647 | 2322 }else |
2323 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
|
2324 s->gb= s->in_gb; |
4204 | 2325 s->in_gb.buffer= NULL; |
3643 | 2326 } |
2327 | |
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
|
2328 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
|
2329 assert((get_bits_count(&s->gb) & 7) == 0); |
3643 | 2330 i= (s->gb.size_in_bits - get_bits_count(&s->gb))>>3; |
2331 | |
3647 | 2332 if(i<0 || i > BACKSTEP_SIZE || nb_frames<0){ |
2333 av_log(NULL, AV_LOG_ERROR, "invalid new backstep %d\n", i); | |
2334 i= FFMIN(BACKSTEP_SIZE, buf_size - HEADER_SIZE); | |
2335 } | |
3643 | 2336 assert(i <= buf_size - HEADER_SIZE && i>= 0); |
3647 | 2337 memcpy(s->last_buf + s->last_buf_size, s->gb.buffer + buf_size - HEADER_SIZE - i, i); |
3643 | 2338 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
|
2339 |
0 | 2340 break; |
2341 } | |
82
46ee548e47e4
added 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 #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
|
2343 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
|
2344 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
|
2345 int j; |
4652 | 2346 dprintf(s->avctx, "%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
|
2347 for(j=0;j<SBLIMIT;j++) |
4652 | 2348 dprintf(s->avctx, " %0.6f", (double)s->sb_samples[ch][i][j] / FRAC_ONE); |
2349 dprintf(s->avctx, "\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
|
2350 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2351 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2352 #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
|
2353 /* 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
|
2354 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
|
2355 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
|
2356 for(i=0;i<nb_frames;i++) { |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
2357 ff_mpa_synth_filter(s->synth_buf[ch], &(s->synth_buf_offset[ch]), |
2979 | 2358 window, &s->dither_state, |
2359 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
|
2360 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
|
2361 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
|
2362 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 #ifdef DEBUG |
2967 | 2365 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
|
2366 #endif |
2479 | 2367 return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels; |
0 | 2368 } |
2369 | |
2370 static int decode_frame(AVCodecContext * avctx, | |
2979 | 2371 void *data, int *data_size, |
2372 uint8_t * buf, int buf_size) | |
0 | 2373 { |
2374 MPADecodeContext *s = avctx->priv_data; | |
1064 | 2375 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
|
2376 int out_size; |
2479 | 2377 OUT_INT *out_samples = data; |
0 | 2378 |
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
|
2379 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
|
2380 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
|
2381 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
|
2382 |
5089 | 2383 header = AV_RB32(buf); |
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
|
2384 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
|
2385 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
|
2386 // buf_size--; |
3938 | 2387 av_log(avctx, AV_LOG_ERROR, "Header missing skipping one byte.\n"); |
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
|
2388 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
|
2389 } |
143 | 2390 |
5051 | 2391 if (ff_mpegaudio_decode_header(s, header) == 1) { |
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
|
2392 /* 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
|
2393 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
|
2394 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
|
2395 } |
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
|
2396 /* 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
|
2397 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
|
2398 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
|
2399 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
|
2400 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
|
2401 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
|
2402 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
|
2403 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
|
2404 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
|
2405 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
|
2406 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
|
2407 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
|
2408 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
|
2409 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
|
2410 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
|
2411 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
|
2412 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
|
2413 } |
82
46ee548e47e4
added 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 |
3687 | 2415 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
|
2416 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
|
2417 return -1; |
3687 | 2418 }else if(s->frame_size < buf_size){ |
2419 av_log(avctx, AV_LOG_ERROR, "incorrect frame size\n"); | |
5076
796c2a5481ad
make decoder decode the first frame properly if theres more than just one
michael
parents:
5052
diff
changeset
|
2420 buf_size= s->frame_size; |
0 | 2421 } |
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
|
2422 |
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
|
2423 out_size = mp_decode_frame(s, out_samples, buf, buf_size); |
4104
04ff8026d9c0
dont set the sampling rate just because 1 mp3 packet header says so (fixes playback speed on some old mencoder generated avis which where then dumped to mp3)
michael
parents:
4103
diff
changeset
|
2424 if(out_size>=0){ |
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
|
2425 *data_size = out_size; |
4104
04ff8026d9c0
dont set the sampling rate just because 1 mp3 packet header says so (fixes playback speed on some old mencoder generated avis which where then dumped to mp3)
michael
parents:
4103
diff
changeset
|
2426 avctx->sample_rate = s->sample_rate; |
04ff8026d9c0
dont set the sampling rate just because 1 mp3 packet header says so (fixes playback speed on some old mencoder generated avis which where then dumped to mp3)
michael
parents:
4103
diff
changeset
|
2427 //FIXME maybe move the other codec info stuff from above here too |
04ff8026d9c0
dont set the sampling rate just because 1 mp3 packet header says so (fixes playback speed on some old mencoder generated avis which where then dumped to mp3)
michael
parents:
4103
diff
changeset
|
2428 }else |
3938 | 2429 av_log(avctx, AV_LOG_DEBUG, "Error while decoding MPEG audio frame.\n"); //FIXME return -1 / but also return the number of bytes consumed |
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
|
2430 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
|
2431 return buf_size; |
0 | 2432 } |
2433 | |
4203 | 2434 static void flush(AVCodecContext *avctx){ |
2435 MPADecodeContext *s = avctx->priv_data; | |
2436 s->last_buf_size= 0; | |
2437 } | |
2438 | |
3777 | 2439 #ifdef CONFIG_MP3ADU_DECODER |
2432 | 2440 static int decode_frame_adu(AVCodecContext * avctx, |
2979 | 2441 void *data, int *data_size, |
2442 uint8_t * buf, int buf_size) | |
2432 | 2443 { |
2444 MPADecodeContext *s = avctx->priv_data; | |
2445 uint32_t header; | |
2446 int len, out_size; | |
2479 | 2447 OUT_INT *out_samples = data; |
2432 | 2448 |
2449 len = buf_size; | |
2450 | |
2451 // Discard too short frames | |
2452 if (buf_size < HEADER_SIZE) { | |
2453 *data_size = 0; | |
2454 return buf_size; | |
2455 } | |
2456 | |
2457 | |
2458 if (len > MPA_MAX_CODED_FRAME_SIZE) | |
2459 len = MPA_MAX_CODED_FRAME_SIZE; | |
2460 | |
2461 // Get header and restore sync word | |
5089 | 2462 header = AV_RB32(buf) | 0xffe00000; |
2432 | 2463 |
2472 | 2464 if (ff_mpa_check_header(header) < 0) { // Bad header, discard frame |
2432 | 2465 *data_size = 0; |
2466 return buf_size; | |
2467 } | |
2468 | |
5051 | 2469 ff_mpegaudio_decode_header(s, header); |
2432 | 2470 /* update codec info */ |
2471 avctx->sample_rate = s->sample_rate; | |
2472 avctx->channels = s->nb_channels; | |
2473 avctx->bit_rate = s->bit_rate; | |
2474 avctx->sub_id = s->layer; | |
2475 | |
2476 avctx->frame_size=s->frame_size = len; | |
2477 | |
2478 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
|
2479 out_size = buf_size; |
2432 | 2480 } 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
|
2481 out_size = mp_decode_frame(s, out_samples, buf, buf_size); |
2432 | 2482 } |
2483 | |
2484 *data_size = out_size; | |
2485 return buf_size; | |
2486 } | |
3777 | 2487 #endif /* CONFIG_MP3ADU_DECODER */ |
2432 | 2488 |
3777 | 2489 #ifdef CONFIG_MP3ON4_DECODER |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2490 /* 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
|
2491 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
|
2492 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
|
2493 /* 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
|
2494 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
|
2495 {0}, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2496 {0}, // C |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2497 {0}, // FLR |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2498 {2,0}, // C FLR |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2499 {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
|
2500 {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
|
2501 {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
|
2502 {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
|
2503 {0,2} // FLR BLRS |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2504 }; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2505 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2506 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2507 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
|
2508 { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2509 MP3On4DecodeContext *s = avctx->priv_data; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2510 int i; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2511 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2512 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
|
2513 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
|
2514 return -1; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2515 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2516 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2517 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
|
2518 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
|
2519 if(!s->frames) { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2520 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
|
2521 return -1; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2522 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2523 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
|
2524 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2525 /* 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
|
2526 * 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
|
2527 * 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
|
2528 * 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
|
2529 */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2530 // 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
|
2531 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
|
2532 // 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
|
2533 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
|
2534 decode_init(avctx); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2535 // Restore mp3on4 context pointer |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2536 avctx->priv_data = s; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2537 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
|
2538 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2539 /* 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
|
2540 * 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
|
2541 */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2542 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
|
2543 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
|
2544 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
|
2545 s->mp3decctx[i]->adu_mode = 1; |
4652 | 2546 s->mp3decctx[i]->avctx = avctx; |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2547 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2548 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2549 return 0; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2550 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2551 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2552 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2553 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
|
2554 { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2555 MP3On4DecodeContext *s = avctx->priv_data; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2556 int i; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2557 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2558 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
|
2559 if (s->mp3decctx[i]) |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2560 av_free(s->mp3decctx[i]); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2561 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2562 return 0; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2563 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2564 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2565 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2566 static int decode_frame_mp3on4(AVCodecContext * avctx, |
2979 | 2567 void *data, int *data_size, |
2568 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
|
2569 { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2570 MP3On4DecodeContext *s = avctx->priv_data; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2571 MPADecodeContext *m; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2572 int len, out_size = 0; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2573 uint32_t header; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2574 OUT_INT *out_samples = data; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2575 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
|
2576 OUT_INT *outptr, *bp; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2577 int fsize; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2578 unsigned char *start2 = buf, *start; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2579 int fr, i, j, n; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2580 int off = avctx->channels; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2581 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
|
2582 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2583 len = buf_size; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2584 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2585 // Discard too short frames |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2586 if (buf_size < HEADER_SIZE) { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2587 *data_size = 0; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2588 return buf_size; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2589 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2590 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2591 // 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
|
2592 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
|
2593 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2594 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
|
2595 start = start2; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2596 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
|
2597 start2 += fsize; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2598 if (fsize > len) |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2599 fsize = len; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2600 len -= fsize; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2601 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
|
2602 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
|
2603 m = s->mp3decctx[fr]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2604 assert (m != NULL); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2605 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2606 // Get header |
5089 | 2607 header = AV_RB32(start) | 0xfff00000; |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2608 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2609 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
|
2610 *data_size = 0; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2611 return buf_size; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2612 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2613 |
5051 | 2614 ff_mpegaudio_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
|
2615 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
|
2616 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2617 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
|
2618 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
|
2619 if(s->frames > 1) { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2620 /* interleave output data */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2621 bp = out_samples + coff[fr]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2622 if(m->nb_channels == 1) { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2623 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
|
2624 *bp = decoded_buf[j]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2625 bp += off; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2626 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2627 } else { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2628 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
|
2629 bp[0] = decoded_buf[j++]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2630 bp[1] = decoded_buf[j]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2631 bp += off; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2632 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2633 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2634 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2635 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2636 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2637 /* update codec info */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2638 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
|
2639 avctx->frame_size= buf_size; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2640 avctx->bit_rate = 0; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2641 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
|
2642 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
|
2643 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2644 *data_size = out_size; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2645 return buf_size; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2646 } |
3777 | 2647 #endif /* CONFIG_MP3ON4_DECODER */ |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2648 |
3777 | 2649 #ifdef CONFIG_MP2_DECODER |
322 | 2650 AVCodec mp2_decoder = |
0 | 2651 { |
322 | 2652 "mp2", |
0 | 2653 CODEC_TYPE_AUDIO, |
2654 CODEC_ID_MP2, | |
2655 sizeof(MPADecodeContext), | |
2656 decode_init, | |
2657 NULL, | |
2658 NULL, | |
2659 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
|
2660 CODEC_CAP_PARSE_ONLY, |
0 | 2661 }; |
3777 | 2662 #endif |
2663 #ifdef CONFIG_MP3_DECODER | |
322 | 2664 AVCodec mp3_decoder = |
2665 { | |
2666 "mp3", | |
2667 CODEC_TYPE_AUDIO, | |
1448 | 2668 CODEC_ID_MP3, |
322 | 2669 sizeof(MPADecodeContext), |
2670 decode_init, | |
2671 NULL, | |
2672 NULL, | |
2673 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
|
2674 CODEC_CAP_PARSE_ONLY, |
4203 | 2675 .flush= flush, |
322 | 2676 }; |
3777 | 2677 #endif |
2678 #ifdef CONFIG_MP3ADU_DECODER | |
2432 | 2679 AVCodec mp3adu_decoder = |
2680 { | |
2681 "mp3adu", | |
2682 CODEC_TYPE_AUDIO, | |
2683 CODEC_ID_MP3ADU, | |
2684 sizeof(MPADecodeContext), | |
2685 decode_init, | |
2686 NULL, | |
2687 NULL, | |
2688 decode_frame_adu, | |
2689 CODEC_CAP_PARSE_ONLY, | |
4203 | 2690 .flush= flush, |
2432 | 2691 }; |
3777 | 2692 #endif |
2693 #ifdef CONFIG_MP3ON4_DECODER | |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2694 AVCodec mp3on4_decoder = |
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 "mp3on4", |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2697 CODEC_TYPE_AUDIO, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2698 CODEC_ID_MP3ON4, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2699 sizeof(MP3On4DecodeContext), |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2700 decode_init_mp3on4, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2701 NULL, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2702 decode_close_mp3on4, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2703 decode_frame_mp3on4, |
4203 | 2704 .flush= flush, |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2705 }; |
3777 | 2706 #endif |