Mercurial > libavcodec.hg
annotate mpegaudiodec.c @ 11712:25ed71436974 libavcodec
Set coded_frame to NULL when closing a codec, since it might
be invalid after the codec is "gone".
author | reimar |
---|---|
date | Wed, 12 May 2010 17:05:56 +0000 |
parents | 7ca3795af11b |
children | fcb1d0addf28 |
rev | line source |
---|---|
0 | 1 /* |
2 * MPEG Audio decoder | |
8629
04423b2f6e0b
cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents:
8598
diff
changeset
|
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 /** | |
11644
7dd2a45249a9
Remove explicit filename from Doxygen @file commands.
diego
parents:
11560
diff
changeset
|
23 * @file |
1106 | 24 * MPEG Audio decoder. |
2967 | 25 */ |
1106 | 26 |
0 | 27 #include "avcodec.h" |
9428 | 28 #include "get_bits.h" |
1734
8aace334bcf0
lrintf patch by ("Steven M. Schultz" <sms at 2BSD dot COM>)
michael
parents:
1733
diff
changeset
|
29 #include "dsputil.h" |
0 | 30 |
31 /* | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
32 * TODO: |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
33 * - in low precision mode, use more 16 bit multiplies in synth filter |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
34 * - test lsf / mpeg25 extensively. |
0 | 35 */ |
36 | |
2913 | 37 #include "mpegaudio.h" |
5050 | 38 #include "mpegaudiodecheader.h" |
2479 | 39 |
3752 | 40 #include "mathops.h" |
41 | |
11707 | 42 #if CONFIG_FLOAT |
43 # define SHR(a,b) ((a)*(1.0/(1<<(b)))) | |
44 # define compute_antialias compute_antialias_float | |
45 # define FIXR_OLD(a) ((int)((a) * FRAC_ONE + 0.5)) | |
46 # define FIXR(x) (x) | |
47 # define FIXHR(x) (x) | |
48 # define MULH3(x, y, s) ((s)*(y)*(x)) | |
49 # define MULLx(x, y, s) ((y)*(x)) | |
50 # define RENAME(a) a ## _float | |
51 #else | |
52 # define SHR(a,b) ((a)>>(b)) | |
53 # define compute_antialias compute_antialias_integer | |
82
46ee548e47e4
added 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 /* WARNING: only correct for posititive numbers */ |
11707 | 55 # define FIXR_OLD(a) ((int)((a) * FRAC_ONE + 0.5)) |
56 # define FIXR(a) ((int)((a) * FRAC_ONE + 0.5)) | |
57 # define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5)) | |
58 # define MULH3(x, y, s) MULH((s)*(x), y) | |
59 # define MULLx(x, y, s) MULL(x,y,s) | |
60 # define RENAME(a) a | |
61 #endif | |
2489 | 62 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
63 /****************/ |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
64 |
0 | 65 #define HEADER_SIZE 4 |
66 | |
5031
70f194a2ee53
move some common mpeg audio tables from mpegaudiodectab.h to mpegaudiodata.c
aurel
parents:
5009
diff
changeset
|
67 #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
|
68 #include "mpegaudiodectab.h" |
0 | 69 |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
70 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
|
71 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
|
72 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
73 /* vlc structure for decoding layer 3 huffman tables */ |
2967 | 74 static VLC huff_vlc[16]; |
7452
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
75 static VLC_TYPE huff_vlc_tables[ |
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
76 0+128+128+128+130+128+154+166+ |
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
77 142+204+190+170+542+460+662+414 |
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
78 ][2]; |
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
79 static const int huff_vlc_tables_sizes[16] = { |
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
80 0, 128, 128, 128, 130, 128, 154, 166, |
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
81 142, 204, 190, 170, 542, 460, 662, 414 |
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
82 }; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
83 static VLC huff_quad_vlc[2]; |
7452
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
84 static VLC_TYPE huff_quad_vlc_tables[128+16][2]; |
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
85 static const int huff_quad_vlc_tables_sizes[2] = { |
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
86 128, 16 |
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
87 }; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
88 /* computed from band_size_long */ |
1064 | 89 static uint16_t band_index_long[9][23]; |
10469
23ca6d60184d
Add support for hardcoding the mpegaudiodec tables.
reimar
parents:
10440
diff
changeset
|
90 #include "mpegaudio_tablegen.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
|
91 /* intensity stereo coef table */ |
11707 | 92 static INTFLOAT is_table[2][16]; |
93 static INTFLOAT 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
|
94 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
|
95 static float csa_table_float[8][4]; |
11707 | 96 static INTFLOAT 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
|
97 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
98 /* lower 2 bits: modulo 3, higher bits: shift */ |
1064 | 99 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
|
100 /* [i][j]: 2^(-j/3) * FRAC_ONE * 2^(i+2) / (2^(i+2) - 1) */ |
1064 | 101 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
|
102 /* 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
|
103 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
104 #define SCALE_GEN(v) \ |
11707 | 105 { FIXR_OLD(1.0 * (v)), FIXR_OLD(0.7937005259 * (v)), FIXR_OLD(0.6299605249 * (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
|
106 |
2753 | 107 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
|
108 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
|
109 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
|
110 SCALE_GEN(4.0 / 9.0), /* 9 steps */ |
0 | 111 }; |
112 | |
11707 | 113 DECLARE_ALIGNED(16, MPA_INT, RENAME(ff_mpa_synth_window))[512]; |
2967 | 114 |
6138
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
115 /** |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
116 * Convert region offsets to region sizes and truncate |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
117 * size to big_values. |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
118 */ |
11374 | 119 static void ff_region_offset2size(GranuleDef *g){ |
6138
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
120 int i, k, j=0; |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
121 g->region_size[2] = (576 / 2); |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
122 for(i=0;i<3;i++) { |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
123 k = FFMIN(g->region_size[i], g->big_values); |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
124 g->region_size[i] = k - j; |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
125 j = k; |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
126 } |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
127 } |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
128 |
11374 | 129 static void ff_init_short_region(MPADecodeContext *s, GranuleDef *g){ |
6138
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
130 if (g->block_type == 2) |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
131 g->region_size[0] = (36 / 2); |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
132 else { |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
133 if (s->sample_rate_index <= 2) |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
134 g->region_size[0] = (36 / 2); |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
135 else if (s->sample_rate_index != 8) |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
136 g->region_size[0] = (54 / 2); |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
137 else |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
138 g->region_size[0] = (108 / 2); |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
139 } |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
140 g->region_size[1] = (576 / 2); |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
141 } |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
142 |
11374 | 143 static void ff_init_long_region(MPADecodeContext *s, GranuleDef *g, int ra1, int ra2){ |
6138
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
144 int l; |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
145 g->region_size[0] = |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
146 band_index_long[s->sample_rate_index][ra1 + 1] >> 1; |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
147 /* should not overflow */ |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
148 l = FFMIN(ra1 + ra2 + 2, 22); |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
149 g->region_size[1] = |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
150 band_index_long[s->sample_rate_index][l] >> 1; |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
151 } |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
152 |
11374 | 153 static void ff_compute_band_indexes(MPADecodeContext *s, GranuleDef *g){ |
6138
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
154 if (g->block_type == 2) { |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
155 if (g->switch_point) { |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
156 /* if switched mode, we handle the 36 first samples as |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
157 long blocks. For 8000Hz, we handle the 48 first |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
158 exponents as long blocks (XXX: check this!) */ |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
159 if (s->sample_rate_index <= 2) |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
160 g->long_end = 8; |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
161 else if (s->sample_rate_index != 8) |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
162 g->long_end = 6; |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
163 else |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
164 g->long_end = 4; /* 8000 Hz */ |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
165 |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
166 g->short_start = 2 + (s->sample_rate_index != 8); |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
167 } else { |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
168 g->long_end = 0; |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
169 g->short_start = 0; |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
170 } |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
171 } else { |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
172 g->short_start = 13; |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
173 g->long_end = 22; |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
174 } |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
175 } |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
176 |
82
46ee548e47e4
added 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 /* 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
|
178 /* 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
|
179 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
|
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
|
181 int shift, mod; |
1064 | 182 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
|
183 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
184 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
|
185 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
|
186 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
|
187 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
|
188 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
|
189 /* 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
|
190 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
|
191 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
192 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
193 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
|
194 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
195 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
|
196 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
197 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
|
198 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
|
199 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
|
200 |
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
|
201 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
|
202 /* 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
|
203 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
|
204 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
|
205 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
|
206 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
207 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
208 /* 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
|
209 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
|
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
|
211 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
|
212 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
|
213 |
2490 | 214 e = table_4_3_exp [4*value + (exponent&3)]; |
215 m = table_4_3_value[4*value + (exponent&3)]; | |
216 e -= (exponent >> 2); | |
217 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
|
218 if (e > 31) |
2478 | 219 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
|
220 m = (m + (1 << (e-1))) >> e; |
2490 | 221 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
222 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
|
223 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
224 |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
225 /* 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
|
226 #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
|
227 |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
228 #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
|
229 #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
|
230 #define POW_FIX(a) ((int)((a) * POW_FRAC_ONE)) |
1064 | 231 #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
|
232 |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
233 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
|
234 |
2522
e25782262d7d
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
2507
diff
changeset
|
235 #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
|
236 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
|
237 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
|
238 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
|
239 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
|
240 }; |
2522
e25782262d7d
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
2507
diff
changeset
|
241 #endif |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
242 |
9007
043574c5c153
Add missing av_cold in static init/close functions.
stefano
parents:
8718
diff
changeset
|
243 static av_cold void int_pow_init(void) |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
244 { |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
245 int i, a; |
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 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
|
248 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
|
249 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
|
250 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
|
251 } |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
252 } |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
253 |
2522
e25782262d7d
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
2507
diff
changeset
|
254 #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
|
255 /* 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
|
256 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
|
257 { |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
258 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
|
259 int a, a1; |
2967 | 260 |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
261 /* renormalize */ |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
262 a = i; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
263 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
|
264 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
|
265 a = a << 1; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
266 e--; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
267 } |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
268 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
|
269 a1 = 0; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
270 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
|
271 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
|
272 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
|
273 /* exponent compute (exact) */ |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
274 e = e * 4; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
275 er = e % 3; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
276 eq = e / 3; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
277 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
|
278 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
|
279 a = a >> 1; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
280 eq++; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
281 } |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
282 /* convert to float */ |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
283 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
|
284 a = a << 1; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
285 eq--; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
286 } |
407
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
287 /* 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
|
288 #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
|
289 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
|
290 /* correct overflow */ |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
291 if (a >= 2 * (1 << FRAC_BITS)) { |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
292 a = a >> 1; |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
293 eq++; |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
294 } |
c3aebacf546e
fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents:
404
diff
changeset
|
295 #endif |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
296 *exp_ptr = eq; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
297 return a; |
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
298 } |
2522
e25782262d7d
kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents:
2507
diff
changeset
|
299 #endif |
0 | 300 |
9007
043574c5c153
Add missing av_cold in static init/close functions.
stefano
parents:
8718
diff
changeset
|
301 static av_cold int decode_init(AVCodecContext * avctx) |
0 | 302 { |
303 MPADecodeContext *s = avctx->priv_data; | |
836
932eb34d17c1
vc++ sucks, found by ("csharprules" <csharprules at hotmail dot com>)
michaelni
parents:
602
diff
changeset
|
304 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
|
305 int i, j, k; |
0 | 306 |
4652 | 307 s->avctx = avctx; |
308 | |
8598
6550218be3b7
simplify: group all the AUDIO_NONSHORT parameters in the same place
aurel
parents:
8594
diff
changeset
|
309 avctx->sample_fmt= OUT_FMT; |
7831 | 310 s->error_recognition= avctx->error_recognition; |
2967 | 311 |
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
|
312 if (!init && !avctx->parse_only) { |
7452
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
313 int offset; |
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
314 |
82
46ee548e47e4
added 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 /* 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
|
316 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
|
317 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
|
318 /* 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
|
319 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
|
320 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
|
321 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
|
322 } |
46ee548e47e4
added 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 /* 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
|
325 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
|
326 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
|
327 n = i + 2; |
4274 | 328 norm = ((INT64_C(1) << n) * FRAC_ONE) / ((1 << n) - 1); |
11707 | 329 scale_factor_mult[i][0] = MULLx(norm, FIXR(1.0 * 2.0), FRAC_BITS); |
330 scale_factor_mult[i][1] = MULLx(norm, FIXR(0.7937005259 * 2.0), FRAC_BITS); | |
331 scale_factor_mult[i][2] = MULLx(norm, FIXR(0.6299605249 * 2.0), FRAC_BITS); | |
4652 | 332 dprintf(avctx, "%d: norm=%x s=%x %x %x\n", |
2967 | 333 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
|
334 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
|
335 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
|
336 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
|
337 } |
2967 | 338 |
11707 | 339 RENAME(ff_mpa_synth_init)(RENAME(ff_mpa_synth_window)); |
2967 | 340 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
341 /* huffman decode tables */ |
7452
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
342 offset = 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
|
343 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
|
344 const HuffTable *h = &mpa_huff_tables[i]; |
2979 | 345 int xsize, x, y; |
3627 | 346 uint8_t tmp_bits [512]; |
347 uint16_t tmp_codes[512]; | |
3608 | 348 |
349 memset(tmp_bits , 0, sizeof(tmp_bits )); | |
350 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
|
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 xsize = h->xsize; |
2967 | 353 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
354 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
|
355 for(x=0;x<xsize;x++) { |
3608 | 356 for(y=0;y<xsize;y++){ |
3627 | 357 tmp_bits [(x << 5) | y | ((x&&y)<<4)]= h->bits [j ]; |
358 tmp_codes[(x << 5) | y | ((x&&y)<<4)]= h->codes[j++]; | |
3608 | 359 } |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
360 } |
3608 | 361 |
362 /* XXX: fail test */ | |
7452
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
363 huff_vlc[i].table = huff_vlc_tables+offset; |
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
364 huff_vlc[i].table_allocated = huff_vlc_tables_sizes[i]; |
3627 | 365 init_vlc(&huff_vlc[i], 7, 512, |
7452
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
366 tmp_bits, 1, 1, tmp_codes, 2, 2, |
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
367 INIT_VLC_USE_NEW_STATIC); |
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
368 offset += huff_vlc_tables_sizes[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
|
369 } |
8042 | 370 assert(offset == FF_ARRAY_ELEMS(huff_vlc_tables)); |
7452
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
371 |
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
372 offset = 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
|
373 for(i=0;i<2;i++) { |
7452
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
374 huff_quad_vlc[i].table = huff_quad_vlc_tables+offset; |
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
375 huff_quad_vlc[i].table_allocated = huff_quad_vlc_tables_sizes[i]; |
2967 | 376 init_vlc(&huff_quad_vlc[i], i == 0 ? 7 : 4, 16, |
7452
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
377 mpa_quad_bits[i], 1, 1, mpa_quad_codes[i], 1, 1, |
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
378 INIT_VLC_USE_NEW_STATIC); |
2240c6340eac
Use static vlc structure to decode layer 3 huffman tables.
benoit
parents:
7330
diff
changeset
|
379 offset += huff_quad_vlc_tables_sizes[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
|
380 } |
8042 | 381 assert(offset == FF_ARRAY_ELEMS(huff_quad_vlc_tables)); |
82
46ee548e47e4
added 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 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
383 for(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
|
384 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
|
385 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
|
386 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
|
387 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
|
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 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
|
390 } |
46ee548e47e4
added 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 |
2979 | 392 /* compute n ^ (4/3) and store it in mantissa/exp format */ |
2967 | 393 |
392
4ef26ed29399
put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents:
322
diff
changeset
|
394 int_pow_init(); |
10469
23ca6d60184d
Add support for hardcoding the mpegaudiodec tables.
reimar
parents:
10440
diff
changeset
|
395 mpegaudio_tableinit(); |
2967 | 396 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
397 for(i=0;i<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
|
398 float f; |
11707 | 399 INTFLOAT 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
|
400 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
|
401 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
|
402 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
|
403 } 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
|
404 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
|
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 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
|
407 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
|
408 } |
46ee548e47e4
added 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 /* 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
|
410 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
|
411 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
|
412 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
413 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
|
414 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
|
415 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
|
416 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
417 for(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
|
418 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
|
419 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
|
420 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
|
421 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
|
422 is_table_lsf[j][k][i] = FIXR(1.0); |
4652 | 423 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
|
424 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
|
425 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
427 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
428 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
|
429 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
|
430 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
|
431 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
|
432 ca = cs * ci; |
2491 | 433 csa_table[i][0] = FIXHR(cs/4); |
434 csa_table[i][1] = FIXHR(ca/4); | |
435 csa_table[i][2] = FIXHR(ca/4) + FIXHR(cs/4); | |
2967 | 436 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
|
437 csa_table_float[i][0] = cs; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
438 csa_table_float[i][1] = ca; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
439 csa_table_float[i][2] = ca + cs; |
2967 | 440 csa_table_float[i][3] = 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
|
441 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
442 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
443 /* 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
|
444 for(i=0;i<36;i++) { |
2489 | 445 for(j=0; j<4; j++){ |
446 double d; | |
2967 | 447 |
2495 | 448 if(j==2 && i%3 != 1) |
449 continue; | |
2967 | 450 |
2489 | 451 d= sin(M_PI * (i + 0.5) / 36.0); |
452 if(j==1){ | |
453 if (i>=30) d= 0; | |
454 else if(i>=24) d= sin(M_PI * (i - 18 + 0.5) / 12.0); | |
455 else if(i>=18) d= 1; | |
456 }else if(j==3){ | |
457 if (i< 6) d= 0; | |
458 else if(i< 12) d= sin(M_PI * (i - 6 + 0.5) / 12.0); | |
459 else if(i< 18) d= 1; | |
460 } | |
461 //merge last stage of imdct into the window coefficients | |
2495 | 462 d*= 0.5 / cos(M_PI*(2*i + 19)/72); |
463 | |
464 if(j==2) | |
465 mdct_win[j][i/3] = FIXHR((d / (1<<5))); | |
466 else | |
467 mdct_win[j][i ] = FIXHR((d / (1<<5))); | |
2489 | 468 } |
82
46ee548e47e4
added 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 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
471 /* 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
|
472 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
|
473 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
|
474 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
|
475 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
|
476 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
|
477 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
478 } |
46ee548e47e4
added 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 |
0 | 480 init = 1; |
481 } | |
482 | |
2432 | 483 if (avctx->codec_id == CODEC_ID_MP3ADU) |
484 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
|
485 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
|
486 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
487 |
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
|
488 /* 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
|
489 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
490 /* 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
|
491 |
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
|
492 #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
|
493 #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
|
494 #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
|
495 #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
|
496 #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
|
497 #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
|
498 #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
|
499 #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
|
500 #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
|
501 #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
|
502 #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
|
503 #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
|
504 #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
|
505 #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
|
506 #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
|
507 #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
|
508 |
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
|
509 #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
|
510 #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
|
511 #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
|
512 #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
|
513 #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
|
514 #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
|
515 #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
|
516 #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
|
517 |
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
|
518 #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
|
519 #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
|
520 #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
|
521 #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
|
522 |
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 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
|
524 #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
|
525 |
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
|
526 #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
|
527 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
528 /* 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
|
529 #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
|
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 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
|
532 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
|
533 tab[a] = tmp0;\ |
11707 | 534 tab[b] = MULH3(tmp1, c, 1<<(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
|
535 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
536 |
46ee548e47e4
added 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 #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
|
538 {\ |
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
|
539 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
|
540 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
|
541 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
|
542 } |
46ee548e47e4
added 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 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
544 #define 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
|
545 {\ |
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
|
546 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
|
547 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
|
548 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
|
549 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
|
550 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
|
551 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
|
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 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
554 #define 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
|
555 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
556 /* DCT32 without 1/sqrt(2) coef zero scaling. */ |
11707 | 557 static void dct32(INTFLOAT *out, INTFLOAT *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
|
558 { |
11707 | 559 INTFLOAT tmp0, tmp1; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
560 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
561 /* 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( 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
|
563 BF(15, 16, COS0_15, 5); |
3598 | 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( 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
|
566 BF(16, 31,-COS1_0 , 1); |
3598 | 567 /* 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
|
568 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
|
569 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
|
570 /* 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
|
571 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
|
572 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
|
573 /* 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
|
574 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
|
575 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
|
576 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
|
577 BF(24, 31,-COS2_0 , 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( 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
|
580 BF(12, 19, COS0_12, 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( 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
|
583 BF(19, 28,-COS1_3 , 1); |
3598 | 584 /* 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
|
585 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
|
586 BF(11, 20, COS0_11, 2); |
3598 | 587 /* 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
|
588 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
|
589 BF(20, 27,-COS1_4 , 1); |
3598 | 590 /* 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
|
591 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
|
592 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
|
593 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
|
594 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
|
595 /* 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
|
596 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
|
597 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
|
598 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
|
599 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
|
600 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
|
601 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
|
602 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
|
603 BF(28, 31,-COS3_0 , 1); |
2967 | 604 |
605 | |
606 | |
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( 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
|
609 BF(14, 17, COS0_14, 3); |
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( 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
|
612 BF(17, 30,-COS1_1 , 1); |
3598 | 613 /* 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
|
614 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
|
615 BF( 9, 22, COS0_9 , 1); |
3598 | 616 /* 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
|
617 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
|
618 BF(22, 25,-COS1_6 , 2); |
3598 | 619 /* 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
|
620 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
|
621 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
|
622 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
|
623 BF(25, 30,-COS2_1 , 1); |
3598 | 624 |
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( 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
|
627 BF(13, 18, COS0_13, 3); |
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( 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
|
630 BF(18, 29,-COS1_2 , 1); |
3598 | 631 /* 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
|
632 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
|
633 BF(10, 21, COS0_10, 1); |
3598 | 634 /* 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
|
635 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
|
636 BF(21, 26,-COS1_5 , 2); |
3598 | 637 /* 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
|
638 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
|
639 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
|
640 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
|
641 BF(26, 29,-COS2_2 , 1); |
3598 | 642 /* 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
|
643 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
|
644 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
|
645 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
|
646 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
|
647 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
|
648 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
|
649 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
|
650 BF(29, 30,-COS3_1 , 2); |
2967 | 651 |
82
46ee548e47e4
added 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 /* 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
|
653 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
|
654 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
|
655 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
|
656 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
|
657 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
|
658 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
|
659 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
|
660 BF2(28, 29, 30, 31); |
2967 | 661 |
82
46ee548e47e4
added 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 /* pass 6 */ |
2967 | 663 |
82
46ee548e47e4
added 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( 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
|
665 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
|
666 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
|
667 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
|
668 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
|
669 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
|
670 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
|
671 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
672 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
|
673 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
|
674 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
|
675 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
|
676 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
|
677 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
|
678 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
|
679 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
|
680 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
|
681 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
|
682 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
|
683 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
|
684 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
|
685 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
|
686 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
|
687 out[30] = tab[15]; |
2967 | 688 |
82
46ee548e47e4
added 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(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
|
690 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
|
691 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
|
692 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
|
693 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
|
694 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
|
695 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
|
696 |
46ee548e47e4
added 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[ 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
|
698 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
|
699 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
|
700 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
|
701 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
|
702 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
|
703 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
|
704 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
|
705 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
|
706 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
|
707 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
|
708 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
|
709 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
|
710 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
|
711 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
|
712 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
|
713 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
714 |
11707 | 715 #if CONFIG_FLOAT |
716 static inline float round_sample(float *sum) | |
717 { | |
718 float sum1=*sum; | |
719 *sum = 0; | |
720 return sum1; | |
721 } | |
722 | |
723 /* signed 16x16 -> 32 multiply add accumulate */ | |
724 #define MACS(rt, ra, rb) rt+=(ra)*(rb) | |
725 | |
726 /* signed 16x16 -> 32 multiply */ | |
727 #define MULS(ra, rb) ((ra)*(rb)) | |
728 | |
729 #define MLSS(rt, ra, rb) rt-=(ra)*(rb) | |
730 | |
731 #elif FRAC_BITS <= 15 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
732 |
2472 | 733 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
|
734 { |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
735 int sum1; |
2472 | 736 sum1 = (*sum) >> OUT_SHIFT; |
737 *sum &= (1<<OUT_SHIFT)-1; | |
9601 | 738 return av_clip(sum1, OUT_MIN, OUT_MAX); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
739 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
740 |
3752 | 741 /* signed 16x16 -> 32 multiply add accumulate */ |
742 #define MACS(rt, ra, rb) MAC16(rt, ra, rb) | |
3705 | 743 |
3752 | 744 /* signed 16x16 -> 32 multiply */ |
745 #define MULS(ra, rb) MUL16(ra, rb) | |
3705 | 746 |
7256 | 747 #define MLSS(rt, ra, rb) MLS16(rt, ra, rb) |
748 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
749 #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
|
750 |
2967 | 751 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
|
752 { |
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 int sum1; |
2472 | 754 sum1 = (int)((*sum) >> OUT_SHIFT); |
755 *sum &= (1<<OUT_SHIFT)-1; | |
9601 | 756 return av_clip(sum1, OUT_MIN, 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
|
757 } |
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 |
3603 | 759 # define MULS(ra, rb) MUL64(ra, rb) |
7256 | 760 # define MACS(rt, ra, rb) MAC64(rt, ra, rb) |
761 # define MLSS(rt, ra, rb) MLS64(rt, ra, rb) | |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
762 #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
|
763 |
7256 | 764 #define SUM8(op, sum, w, p) \ |
765 { \ | |
9603
875cd15dfd74
mpegaudio: enclose SUM8() macro args in parens when used
mru
parents:
9602
diff
changeset
|
766 op(sum, (w)[0 * 64], (p)[0 * 64]); \ |
875cd15dfd74
mpegaudio: enclose SUM8() macro args in parens when used
mru
parents:
9602
diff
changeset
|
767 op(sum, (w)[1 * 64], (p)[1 * 64]); \ |
875cd15dfd74
mpegaudio: enclose SUM8() macro args in parens when used
mru
parents:
9602
diff
changeset
|
768 op(sum, (w)[2 * 64], (p)[2 * 64]); \ |
875cd15dfd74
mpegaudio: enclose SUM8() macro args in parens when used
mru
parents:
9602
diff
changeset
|
769 op(sum, (w)[3 * 64], (p)[3 * 64]); \ |
875cd15dfd74
mpegaudio: enclose SUM8() macro args in parens when used
mru
parents:
9602
diff
changeset
|
770 op(sum, (w)[4 * 64], (p)[4 * 64]); \ |
875cd15dfd74
mpegaudio: enclose SUM8() macro args in parens when used
mru
parents:
9602
diff
changeset
|
771 op(sum, (w)[5 * 64], (p)[5 * 64]); \ |
875cd15dfd74
mpegaudio: enclose SUM8() macro args in parens when used
mru
parents:
9602
diff
changeset
|
772 op(sum, (w)[6 * 64], (p)[6 * 64]); \ |
875cd15dfd74
mpegaudio: enclose SUM8() macro args in parens when used
mru
parents:
9602
diff
changeset
|
773 op(sum, (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
|
774 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
775 |
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
|
776 #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
|
777 { \ |
11707 | 778 INTFLOAT tmp;\ |
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
|
779 tmp = p[0 * 64];\ |
7256 | 780 op1(sum1, (w1)[0 * 64], tmp);\ |
781 op2(sum2, (w2)[0 * 64], tmp);\ | |
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
|
782 tmp = p[1 * 64];\ |
7256 | 783 op1(sum1, (w1)[1 * 64], tmp);\ |
784 op2(sum2, (w2)[1 * 64], tmp);\ | |
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
|
785 tmp = p[2 * 64];\ |
7256 | 786 op1(sum1, (w1)[2 * 64], tmp);\ |
787 op2(sum2, (w2)[2 * 64], tmp);\ | |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
788 tmp = p[3 * 64];\ |
7256 | 789 op1(sum1, (w1)[3 * 64], tmp);\ |
790 op2(sum2, (w2)[3 * 64], tmp);\ | |
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
|
791 tmp = p[4 * 64];\ |
7256 | 792 op1(sum1, (w1)[4 * 64], tmp);\ |
793 op2(sum2, (w2)[4 * 64], tmp);\ | |
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
|
794 tmp = p[5 * 64];\ |
7256 | 795 op1(sum1, (w1)[5 * 64], tmp);\ |
796 op2(sum2, (w2)[5 * 64], tmp);\ | |
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
|
797 tmp = p[6 * 64];\ |
7256 | 798 op1(sum1, (w1)[6 * 64], tmp);\ |
799 op2(sum2, (w2)[6 * 64], tmp);\ | |
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
|
800 tmp = p[7 * 64];\ |
7256 | 801 op1(sum1, (w1)[7 * 64], tmp);\ |
802 op2(sum2, (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
|
803 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
804 |
11707 | 805 void av_cold RENAME(ff_mpa_synth_init)(MPA_INT *window) |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
806 { |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
807 int i; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
808 |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
809 /* max = 18760, max sum over all 16 coefs : 44736 */ |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
810 for(i=0;i<257;i++) { |
11707 | 811 INTFLOAT v; |
5032 | 812 v = ff_mpa_enwindow[i]; |
11707 | 813 #if CONFIG_FLOAT |
814 v *= 1.0 / (1LL<<(16 + FRAC_BITS)); | |
815 #elif WFRAC_BITS < 16 | |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
816 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
|
817 #endif |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
818 window[i] = v; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
819 if ((i & 63) != 0) |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
820 v = -v; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
821 if (i != 0) |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
822 window[512 - i] = v; |
2967 | 823 } |
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 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
826 /* 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
|
827 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
|
828 /* XXX: optimize by avoiding ring buffer usage */ |
11707 | 829 void RENAME(ff_mpa_synth_filter)(MPA_INT *synth_buf_ptr, int *synth_buf_offset, |
2979 | 830 MPA_INT *window, int *dither_state, |
2967 | 831 OUT_INT *samples, int incr, |
11707 | 832 INTFLOAT 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
|
833 { |
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
|
834 register MPA_INT *synth_buf; |
2100 | 835 register const MPA_INT *w, *w2, *p; |
9602
9e7665d68111
mpegaudio: avoid unnecessary copy in high-precision mode
mru
parents:
9601
diff
changeset
|
836 int j, offset; |
2479 | 837 OUT_INT *samples2; |
11707 | 838 #if CONFIG_FLOAT |
839 float sum, sum2; | |
840 #elif FRAC_BITS <= 15 | |
9602
9e7665d68111
mpegaudio: avoid unnecessary copy in high-precision mode
mru
parents:
9601
diff
changeset
|
841 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
|
842 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
|
843 #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
|
844 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
|
845 #endif |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
846 |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
847 offset = *synth_buf_offset; |
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
848 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
|
849 |
9602
9e7665d68111
mpegaudio: avoid unnecessary copy in high-precision mode
mru
parents:
9601
diff
changeset
|
850 #if FRAC_BITS <= 15 |
11707 | 851 assert(!CONFIG_FLOAT); |
9602
9e7665d68111
mpegaudio: avoid unnecessary copy in high-precision mode
mru
parents:
9601
diff
changeset
|
852 dct32(tmp, sb_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
|
853 for(j=0;j<32;j++) { |
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
|
854 /* 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
|
855 sound */ |
9602
9e7665d68111
mpegaudio: avoid unnecessary copy in high-precision mode
mru
parents:
9601
diff
changeset
|
856 synth_buf[j] = av_clip_int16(tmp[j]); |
9e7665d68111
mpegaudio: avoid unnecessary copy in high-precision mode
mru
parents:
9601
diff
changeset
|
857 } |
9e7665d68111
mpegaudio: avoid unnecessary copy in high-precision mode
mru
parents:
9601
diff
changeset
|
858 #else |
9e7665d68111
mpegaudio: avoid unnecessary copy in high-precision mode
mru
parents:
9601
diff
changeset
|
859 dct32(synth_buf, sb_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
|
860 #endif |
9602
9e7665d68111
mpegaudio: avoid unnecessary copy in high-precision mode
mru
parents:
9601
diff
changeset
|
861 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
862 /* copy to avoid wrap */ |
11707 | 863 memcpy(synth_buf + 512, synth_buf, 32 * sizeof(*synth_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
|
864 |
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
|
865 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
|
866 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
|
867 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
|
868 |
2473 | 869 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
|
870 p = synth_buf + 16; |
7256 | 871 SUM8(MACS, sum, w, p); |
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
|
872 p = synth_buf + 48; |
7256 | 873 SUM8(MLSS, sum, w + 32, p); |
2472 | 874 *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
|
875 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
|
876 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
|
877 |
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
878 /* 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
|
879 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
|
880 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
|
881 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
|
882 p = synth_buf + 16 + j; |
7256 | 883 SUM8P2(sum, MACS, sum2, MLSS, w, w2, p); |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
884 p = synth_buf + 48 - j; |
7256 | 885 SUM8P2(sum, MLSS, sum2, MLSS, w + 32, w2 + 32, p); |
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
|
886 |
2472 | 887 *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
|
888 samples += incr; |
2472 | 889 sum += sum2; |
890 *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
|
891 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
|
892 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
|
893 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
|
894 } |
2967 | 895 |
1428
aece5836c588
fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents:
1414
diff
changeset
|
896 p = synth_buf + 32; |
7256 | 897 SUM8(MLSS, sum, w + 32, p); |
2472 | 898 *samples = round_sample(&sum); |
2473 | 899 *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
|
900 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
901 offset = (offset - 32) & 511; |
2468
1addaf6facbb
exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents:
2432
diff
changeset
|
902 *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
|
903 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
904 |
2495 | 905 #define C3 FIXHR(0.86602540378443864676/2) |
906 | |
907 /* 0.5 / cos(pi*(2*i+1)/36) */ | |
11707 | 908 static const INTFLOAT icos36[9] = { |
2495 | 909 FIXR(0.50190991877167369479), |
910 FIXR(0.51763809020504152469), //0 | |
911 FIXR(0.55168895948124587824), | |
912 FIXR(0.61038729438072803416), | |
913 FIXR(0.70710678118654752439), //1 | |
914 FIXR(0.87172339781054900991), | |
915 FIXR(1.18310079157624925896), | |
916 FIXR(1.93185165257813657349), //2 | |
917 FIXR(5.73685662283492756461), | |
918 }; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
919 |
3599 | 920 /* 0.5 / cos(pi*(2*i+1)/36) */ |
11707 | 921 static const INTFLOAT icos36h[9] = { |
3599 | 922 FIXHR(0.50190991877167369479/2), |
923 FIXHR(0.51763809020504152469/2), //0 | |
924 FIXHR(0.55168895948124587824/2), | |
925 FIXHR(0.61038729438072803416/2), | |
926 FIXHR(0.70710678118654752439/2), //1 | |
927 FIXHR(0.87172339781054900991/2), | |
928 FIXHR(1.18310079157624925896/4), | |
929 FIXHR(1.93185165257813657349/4), //2 | |
930 // FIXHR(5.73685662283492756461), | |
931 }; | |
932 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
933 /* 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
|
934 cases. */ |
11707 | 935 static void imdct12(INTFLOAT *out, INTFLOAT *in) |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
936 { |
11707 | 937 INTFLOAT 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
|
938 |
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
939 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
|
940 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
|
941 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
|
942 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
|
943 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
|
944 in5= in[5*3] + in[4*3]; |
2495 | 945 in5 += in3; |
946 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
|
947 |
11707 | 948 in2= MULH3(in2, C3, 2); |
949 in3= MULH3(in3, C3, 4); | |
2967 | 950 |
2495 | 951 t1 = in0 - in4; |
11707 | 952 t2 = MULH3(in1 - in5, icos36h[4], 2); |
2495 | 953 |
2967 | 954 out[ 7]= |
2495 | 955 out[10]= t1 + t2; |
956 out[ 1]= | |
957 out[ 4]= t1 - t2; | |
958 | |
11707 | 959 in0 += SHR(in4, 1); |
2495 | 960 in4 = in0 + in2; |
3599 | 961 in5 += 2*in1; |
11707 | 962 in1 = MULH3(in5 + in3, icos36h[1], 1); |
2967 | 963 out[ 8]= |
3599 | 964 out[ 9]= in4 + in1; |
2495 | 965 out[ 2]= |
3599 | 966 out[ 3]= in4 - in1; |
2967 | 967 |
2495 | 968 in0 -= in2; |
11707 | 969 in5 = MULH3(in5 - in3, icos36h[7], 2); |
2495 | 970 out[ 0]= |
3599 | 971 out[ 5]= in0 - in5; |
2495 | 972 out[ 6]= |
3599 | 973 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
|
974 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 /* cos(pi*i/18) */ |
2489 | 977 #define C1 FIXHR(0.98480775301220805936/2) |
978 #define C2 FIXHR(0.93969262078590838405/2) | |
979 #define C3 FIXHR(0.86602540378443864676/2) | |
980 #define C4 FIXHR(0.76604444311897803520/2) | |
981 #define C5 FIXHR(0.64278760968653932632/2) | |
982 #define C6 FIXHR(0.5/2) | |
983 #define C7 FIXHR(0.34202014332566873304/2) | |
984 #define C8 FIXHR(0.17364817766693034885/2) | |
985 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
986 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
987 /* using Lee like decomposition followed by hand coded 9 points DCT */ |
11707 | 988 static void imdct36(INTFLOAT *out, INTFLOAT *buf, INTFLOAT *in, INTFLOAT *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
|
989 { |
11707 | 990 int i, j; |
991 INTFLOAT t0, t1, t2, t3, s0, s1, s2, s3; | |
992 INTFLOAT tmp[18], *tmp1, *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
|
993 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
994 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
|
995 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
|
996 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
|
997 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
|
998 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
999 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
|
1000 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
|
1001 in1 = in + j; |
11707 | 1002 |
2489 | 1003 t2 = in1[2*4] + in1[2*8] - in1[2*2]; |
2967 | 1004 |
11707 | 1005 t3 = in1[2*0] + SHR(in1[2*6],1); |
2489 | 1006 t1 = in1[2*0] - in1[2*6]; |
11707 | 1007 tmp1[ 6] = t1 - SHR(t2,1); |
2489 | 1008 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
|
1009 |
11707 | 1010 t0 = MULH3(in1[2*2] + in1[2*4] , C2, 2); |
1011 t1 = MULH3(in1[2*4] - in1[2*8] , -2*C8, 1); | |
1012 t2 = MULH3(in1[2*2] + in1[2*8] , -C4, 2); | |
2967 | 1013 |
2489 | 1014 tmp1[10] = t3 - t0 - t2; |
1015 tmp1[ 2] = t3 + t0 + t1; | |
1016 tmp1[14] = t3 + t2 - t1; | |
2967 | 1017 |
11707 | 1018 tmp1[ 4] = MULH3(in1[2*5] + in1[2*7] - in1[2*1], -C3, 2); |
1019 t2 = MULH3(in1[2*1] + in1[2*5], C1, 2); | |
1020 t3 = MULH3(in1[2*5] - in1[2*7], -2*C7, 1); | |
1021 t0 = MULH3(in1[2*3], C3, 2); | |
2489 | 1022 |
11707 | 1023 t1 = MULH3(in1[2*1] + in1[2*7], -C5, 2); |
2489 | 1024 |
1025 tmp1[ 0] = t2 + t3 + t0; | |
1026 tmp1[12] = t2 + t1 - t0; | |
1027 tmp1[ 8] = t3 - t1 - t0; | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1028 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1029 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1030 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
|
1031 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
|
1032 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
|
1033 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
|
1034 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
|
1035 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
|
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 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
|
1038 t3 = tmp[i + 3]; |
11707 | 1039 s1 = MULH3(t3 + t2, icos36h[j], 2); |
1040 s3 = MULLx(t3 - t2, icos36[8 - j], FRAC_BITS); | |
2967 | 1041 |
2496
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
1042 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
|
1043 t1 = s0 - s1; |
11707 | 1044 out[(9 + j)*SBLIMIT] = MULH3(t1, win[9 + j], 1) + buf[9 + j]; |
1045 out[(8 - j)*SBLIMIT] = MULH3(t1, win[8 - j], 1) + buf[8 - j]; | |
1046 buf[9 + j] = MULH3(t0, win[18 + 9 + j], 1); | |
1047 buf[8 - j] = MULH3(t0, win[18 + 8 - j], 1); | |
2967 | 1048 |
2496
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
1049 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
|
1050 t1 = s2 - s3; |
11707 | 1051 out[(9 + 8 - j)*SBLIMIT] = MULH3(t1, win[9 + 8 - j], 1) + buf[9 + 8 - j]; |
1052 out[( j)*SBLIMIT] = MULH3(t1, win[ j], 1) + buf[ j]; | |
1053 buf[9 + 8 - j] = MULH3(t0, win[18 + 9 + 8 - j], 1); | |
1054 buf[ + j] = MULH3(t0, win[18 + j], 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
|
1055 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
|
1056 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1057 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1058 s0 = tmp[16]; |
11707 | 1059 s1 = MULH3(tmp[17], icos36h[4], 2); |
2496
74d7fd7b49c5
merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents:
2495
diff
changeset
|
1060 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
|
1061 t1 = s0 - s1; |
11707 | 1062 out[(9 + 4)*SBLIMIT] = MULH3(t1, win[9 + 4], 1) + buf[9 + 4]; |
1063 out[(8 - 4)*SBLIMIT] = MULH3(t1, win[8 - 4], 1) + buf[8 - 4]; | |
1064 buf[9 + 4] = MULH3(t0, win[18 + 9 + 4], 1); | |
1065 buf[8 - 4] = MULH3(t0, win[18 + 8 - 4], 1); | |
0 | 1066 } |
1067 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1068 /* 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
|
1069 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
|
1070 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1071 int bound, i, v, n, ch, j, mant; |
1064 | 1072 uint8_t allocation[MPA_MAX_CHANNELS][SBLIMIT]; |
1073 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
|
1074 |
2967 | 1075 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
|
1076 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
|
1077 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
|
1078 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
|
1079 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1080 /* 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
|
1081 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
|
1082 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
|
1083 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
|
1084 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1085 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1086 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
|
1087 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
|
1088 } |
0 | 1089 |
82
46ee548e47e4
added 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 /* 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
|
1091 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
|
1092 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
|
1093 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
|
1094 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
|
1095 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1097 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
|
1098 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
|
1099 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
|
1100 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
|
1101 } |
46ee548e47e4
added 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 } |
2967 | 1103 |
82
46ee548e47e4
added 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 /* 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
|
1105 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
|
1106 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
|
1107 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
|
1108 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
|
1109 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
|
1110 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
|
1111 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
|
1112 } 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
|
1113 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
|
1114 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1115 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
|
1116 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1117 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1118 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
|
1119 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
|
1120 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
|
1121 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
|
1122 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
|
1123 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
|
1124 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
|
1125 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
|
1126 } 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
|
1127 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
|
1128 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
|
1129 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1130 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 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
|
1133 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 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
|
1136 { |
46ee548e47e4
added 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 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
|
1138 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
|
1139 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
|
1140 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
|
1141 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
|
1142 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
|
1143 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
|
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 /* select decoding table */ |
5052
d981eb275c8f
remove dependency of mpeg audio encoder over mpeg audio decoder
aurel
parents:
5051
diff
changeset
|
1146 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
|
1147 s->sample_rate, s->lsf); |
5032 | 1148 sblimit = ff_mpa_sblimit_table[table]; |
1149 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
|
1150 |
2967 | 1151 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
|
1152 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
|
1153 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
|
1154 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
|
1155 |
4652 | 1156 dprintf(s->avctx, "bound=%d sblimit=%d\n", bound, sblimit); |
1780 | 1157 |
1158 /* sanity check */ | |
1159 if( bound > sblimit ) bound = sblimit; | |
1160 | |
82
46ee548e47e4
added 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 /* 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
|
1162 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
|
1163 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
|
1164 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
|
1165 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
|
1166 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
|
1167 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1168 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
|
1169 } |
46ee548e47e4
added 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 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
|
1171 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
|
1172 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
|
1173 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
|
1174 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
|
1175 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
|
1176 } |
46ee548e47e4
added 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 /* 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
|
1179 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
|
1180 for(ch=0;ch<s->nb_channels;ch++) { |
2967 | 1181 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
|
1182 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
|
1183 } |
46ee548e47e4
added 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 } |
2967 | 1185 |
82
46ee548e47e4
added 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 /* 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
|
1187 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
|
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 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
|
1190 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
|
1191 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
|
1192 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
|
1193 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
|
1194 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
|
1195 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
|
1196 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
|
1197 break; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1198 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
|
1199 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
|
1200 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
|
1201 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
|
1202 break; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1203 case 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
|
1204 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
|
1205 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
|
1206 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
|
1207 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
|
1208 case 3: |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1209 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
|
1210 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
|
1211 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
|
1212 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
|
1213 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1215 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1216 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 /* 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
|
1219 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
|
1220 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
|
1221 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
|
1222 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
|
1223 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
|
1224 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
|
1225 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
|
1226 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
|
1227 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
|
1228 qindex = alloc_table[j+b]; |
5032 | 1229 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
|
1230 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
|
1231 /* 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
|
1232 v = get_bits(&s->gb, -bits); |
5032 | 1233 steps = ff_mpa_quant_steps[qindex]; |
2967 | 1234 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
|
1235 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
|
1236 v = v / steps; |
2967 | 1237 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
|
1238 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
|
1239 v = v / steps; |
2967 | 1240 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
|
1241 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
|
1242 } 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
|
1243 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
|
1244 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
|
1245 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
|
1246 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
|
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 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1249 } 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
|
1250 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
|
1251 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
|
1252 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
|
1253 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 /* next subband in alloc table */ |
2967 | 1256 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
|
1257 } |
46ee548e47e4
added 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 /* 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
|
1259 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
|
1260 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
|
1261 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
|
1262 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
|
1263 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
|
1264 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
|
1265 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
|
1266 qindex = alloc_table[j+b]; |
5032 | 1267 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
|
1268 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
|
1269 /* 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
|
1270 v = get_bits(&s->gb, -bits); |
5032 | 1271 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
|
1272 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
|
1273 v = v / steps; |
2967 | 1274 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
|
1275 l2_unscale_group(steps, mant, scale0); |
2967 | 1276 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
|
1277 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
|
1278 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
|
1279 v = v / steps; |
2967 | 1280 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
|
1281 l2_unscale_group(steps, mant, scale0); |
2967 | 1282 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
|
1283 l2_unscale_group(steps, mant, scale1); |
2967 | 1284 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
|
1285 l2_unscale_group(steps, v, scale0); |
2967 | 1286 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
|
1287 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
|
1288 } 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
|
1289 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
|
1290 mant = get_bits(&s->gb, bits); |
2967 | 1291 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
|
1292 l1_unscale(bits - 1, mant, scale0); |
2967 | 1293 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
|
1294 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
|
1295 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1296 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1297 } 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
|
1298 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
|
1299 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
|
1300 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
|
1301 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
|
1302 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
|
1303 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
|
1304 } |
46ee548e47e4
added 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 /* next subband in alloc table */ |
2967 | 1306 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
|
1307 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1308 /* 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
|
1309 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
|
1310 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
|
1311 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
|
1312 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
|
1313 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
|
1314 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1316 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1318 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
|
1319 } |
46ee548e47e4
added 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 |
11708 | 1321 #define SPLIT(dst,sf,n)\ |
1322 if(n==3){\ | |
1323 int m= (sf*171)>>9;\ | |
1324 dst= sf - 3*m;\ | |
1325 sf=m;\ | |
1326 }else if(n==4){\ | |
1327 dst= sf&3;\ | |
1328 sf>>=2;\ | |
1329 }else if(n==5){\ | |
1330 int m= (sf*205)>>10;\ | |
1331 dst= sf - 5*m;\ | |
1332 sf=m;\ | |
1333 }else if(n==6){\ | |
1334 int m= (sf*171)>>10;\ | |
1335 dst= sf - 6*m;\ | |
1336 sf=m;\ | |
1337 }else{\ | |
1338 dst=0;\ | |
1339 } | |
1340 | |
1341 static av_always_inline void lsf_sf_expand(int *slen, | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1342 int 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
|
1343 { |
11708 | 1344 SPLIT(slen[3], sf, n3) |
1345 SPLIT(slen[2], sf, n2) | |
1346 SPLIT(slen[1], sf, n1) | |
82
46ee548e47e4
added 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 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
|
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 |
2967 | 1350 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
|
1351 GranuleDef *g, |
1064 | 1352 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
|
1353 { |
1064 | 1354 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
|
1355 int len, i, j, k, l, v0, shift, gain, gains[3]; |
1064 | 1356 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
|
1357 |
46ee548e47e4
added 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 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
|
1359 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
|
1360 shift = g->scalefac_scale + 1; |
0 | 1361 |
82
46ee548e47e4
added 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 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
|
1363 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
|
1364 for(i=0;i<g->long_end;i++) { |
3625 | 1365 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
|
1366 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
|
1367 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
|
1368 *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
|
1369 } |
46ee548e47e4
added 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 |
46ee548e47e4
added 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 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
|
1372 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
|
1373 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
|
1374 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
|
1375 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
|
1376 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
|
1377 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
|
1378 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
|
1379 for(l=0;l<3;l++) { |
3625 | 1380 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
|
1381 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
|
1382 *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
|
1383 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1384 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1385 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1386 } |
46ee548e47e4
added 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 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1388 /* 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
|
1389 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
|
1390 { |
46ee548e47e4
added 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 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
|
1392 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
|
1393 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
|
1394 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
|
1395 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1396 |
4469 | 1397 |
1398 static void switch_buffer(MPADecodeContext *s, int *pos, int *end_pos, int *end_pos2){ | |
1399 if(s->in_gb.buffer && *pos >= s->gb.size_in_bits){ | |
1400 s->gb= s->in_gb; | |
1401 s->in_gb.buffer=NULL; | |
1402 assert((get_bits_count(&s->gb) & 7) == 0); | |
1403 skip_bits_long(&s->gb, *pos - *end_pos); | |
1404 *end_pos2= | |
1405 *end_pos= *end_pos2 + get_bits_count(&s->gb) - *pos; | |
1406 *pos= get_bits_count(&s->gb); | |
1407 } | |
1408 } | |
1409 | |
11710 | 1410 /* Following is a optimized code for |
1411 INTFLOAT v = *src | |
1412 if(get_bits1(&s->gb)) | |
1413 v = -v; | |
1414 *dst = v; | |
1415 */ | |
1416 #if CONFIG_FLOAT | |
1417 #define READ_FLIP_SIGN(dst,src)\ | |
1418 v = AV_RN32A(src) ^ (get_bits1(&s->gb)<<31);\ | |
1419 AV_WN32A(dst, v); | |
1420 #else | |
1421 #define READ_FLIP_SIGN(dst,src)\ | |
1422 v= -get_bits1(&s->gb);\ | |
1423 *(dst) = (*(src) ^ v) - v; | |
1424 #endif | |
1425 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1426 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
|
1427 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
|
1428 { |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1429 int s_index; |
3626
a6251ee2dfdb
move variable declarations so that their scope is smaller
michael
parents:
3625
diff
changeset
|
1430 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
|
1431 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
|
1432 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
|
1433 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
|
1434 |
46ee548e47e4
added 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 /* 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
|
1436 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
|
1437 for(i=0;i<3;i++) { |
3626
a6251ee2dfdb
move variable declarations so that their scope is smaller
michael
parents:
3625
diff
changeset
|
1438 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
|
1439 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
|
1440 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
|
1441 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
|
1442 /* 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
|
1443 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
|
1444 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
|
1445 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
|
1446 vlc = &huff_vlc[l]; |
0 | 1447 |
3609 | 1448 if(!l){ |
3636
031252e99956
another silly typo which surprisingly neither valgrind nor cmp of the file output cought
michael
parents:
3635
diff
changeset
|
1449 memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid)*2*j); |
3609 | 1450 s_index += 2*j; |
1451 continue; | |
1452 } | |
1453 | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1454 /* 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
|
1455 for(;j>0;j--) { |
11707 | 1456 int exponent, x, y; |
11711
7ca3795af11b
Do the same sign flip optimization to the low freq decoder.
michael
parents:
11710
diff
changeset
|
1457 int 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
|
1458 int pos= get_bits_count(&s->gb); |
3624 | 1459 |
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
|
1460 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
|
1461 // av_log(NULL, AV_LOG_ERROR, "pos: %d %d %d %d\n", pos, end_pos, end_pos2, s_index); |
4469 | 1462 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
|
1463 // 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
|
1464 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
|
1465 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
|
1466 } |
3623
d0242f36a793
reduce size of vlc table, thats slightly faster here
michael
parents:
3622
diff
changeset
|
1467 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
|
1468 |
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1469 if(!y){ |
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1470 g->sb_hybrid[s_index ] = |
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1471 g->sb_hybrid[s_index+1] = 0; |
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1472 s_index += 2; |
a20d179c79c3
faster handling of zero coeffs in the low freq decode
michael
parents:
3610
diff
changeset
|
1473 continue; |
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 |
3624 | 1476 exponent= exponents[s_index]; |
3609 | 1477 |
4652 | 1478 dprintf(s->avctx, "region=%d n=%d x=%d y=%d exp=%d\n", |
3624 | 1479 i, g->region_size[i] - j, x, y, exponent); |
3627 | 1480 if(y&16){ |
1481 x = y >> 5; | |
1482 y = y & 0x0f; | |
3622 | 1483 if (x < 15){ |
11711
7ca3795af11b
Do the same sign flip optimization to the low freq decoder.
michael
parents:
11710
diff
changeset
|
1484 READ_FLIP_SIGN(g->sb_hybrid+s_index, RENAME(expval_table)[ exponent ]+x) |
3622 | 1485 }else{ |
1486 x += get_bitsz(&s->gb, linbits); | |
3624 | 1487 v = l3_unscale(x, exponent); |
11711
7ca3795af11b
Do the same sign flip optimization to the low freq decoder.
michael
parents:
11710
diff
changeset
|
1488 if (get_bits1(&s->gb)) |
7ca3795af11b
Do the same sign flip optimization to the low freq decoder.
michael
parents:
11710
diff
changeset
|
1489 v = -v; |
7ca3795af11b
Do the same sign flip optimization to the low freq decoder.
michael
parents:
11710
diff
changeset
|
1490 g->sb_hybrid[s_index] = v; |
3622 | 1491 } |
1492 if (y < 15){ | |
11711
7ca3795af11b
Do the same sign flip optimization to the low freq decoder.
michael
parents:
11710
diff
changeset
|
1493 READ_FLIP_SIGN(g->sb_hybrid+s_index+1, RENAME(expval_table)[ exponent ]+y) |
3622 | 1494 }else{ |
1495 y += get_bitsz(&s->gb, linbits); | |
3624 | 1496 v = l3_unscale(y, exponent); |
11711
7ca3795af11b
Do the same sign flip optimization to the low freq decoder.
michael
parents:
11710
diff
changeset
|
1497 if (get_bits1(&s->gb)) |
7ca3795af11b
Do the same sign flip optimization to the low freq decoder.
michael
parents:
11710
diff
changeset
|
1498 v = -v; |
7ca3795af11b
Do the same sign flip optimization to the low freq decoder.
michael
parents:
11710
diff
changeset
|
1499 g->sb_hybrid[s_index+1] = v; |
3622 | 1500 } |
3627 | 1501 }else{ |
1502 x = y >> 5; | |
1503 y = y & 0x0f; | |
1504 x += y; | |
1505 if (x < 15){ | |
11711
7ca3795af11b
Do the same sign flip optimization to the low freq decoder.
michael
parents:
11710
diff
changeset
|
1506 READ_FLIP_SIGN(g->sb_hybrid+s_index+!!y, RENAME(expval_table)[ exponent ]+x) |
3627 | 1507 }else{ |
1508 x += get_bitsz(&s->gb, linbits); | |
1509 v = l3_unscale(x, exponent); | |
11711
7ca3795af11b
Do the same sign flip optimization to the low freq decoder.
michael
parents:
11710
diff
changeset
|
1510 if (get_bits1(&s->gb)) |
7ca3795af11b
Do the same sign flip optimization to the low freq decoder.
michael
parents:
11710
diff
changeset
|
1511 v = -v; |
7ca3795af11b
Do the same sign flip optimization to the low freq decoder.
michael
parents:
11710
diff
changeset
|
1512 g->sb_hybrid[s_index+!!y] = v; |
3627 | 1513 } |
3635 | 1514 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
|
1515 } |
3627 | 1516 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
|
1517 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1518 } |
2967 | 1519 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1520 /* 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
|
1521 vlc = &huff_quad_vlc[g->count1table_select]; |
3612 | 1522 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
|
1523 while (s_index <= 572) { |
3626
a6251ee2dfdb
move variable declarations so that their scope is smaller
michael
parents:
3625
diff
changeset
|
1524 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
|
1525 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
|
1526 if (pos >= end_pos) { |
3647 | 1527 if (pos > end_pos2 && last_pos){ |
1528 /* some encoders generate an incorrect size for this | |
1529 part. We must go back into the data */ | |
1530 s_index -= 4; | |
1531 skip_bits_long(&s->gb, last_pos - pos); | |
7329
104a00d9abfa
Supply context argument to av_log() in mpeg audio decoder.
andoma
parents:
7256
diff
changeset
|
1532 av_log(s->avctx, AV_LOG_INFO, "overread, skip %d enddists: %d %d\n", last_pos - pos, end_pos-pos, end_pos2-pos); |
7831 | 1533 if(s->error_recognition >= FF_ER_COMPLIANT) |
4205
8c28f03cfdd5
detect a few more errors (fixes libmp3-bug.avi again)
michael
parents:
4204
diff
changeset
|
1534 s_index=0; |
3647 | 1535 break; |
1536 } | |
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
|
1537 // av_log(NULL, AV_LOG_ERROR, "pos2: %d %d %d %d\n", pos, end_pos, end_pos2, s_index); |
4469 | 1538 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
|
1539 // 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
|
1540 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
|
1541 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
|
1542 } |
3612 | 1543 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
|
1544 |
3610 | 1545 code = get_vlc2(&s->gb, vlc->table, vlc->bits, 1); |
4652 | 1546 dprintf(s->avctx, "t=%d code=%d\n", g->count1table_select, code); |
3610 | 1547 g->sb_hybrid[s_index+0]= |
1548 g->sb_hybrid[s_index+1]= | |
1549 g->sb_hybrid[s_index+2]= | |
1550 g->sb_hybrid[s_index+3]= 0; | |
1551 while(code){ | |
4908
777f250df232
Fix multiple "¡Æinline/static¡Ç is not at beginning of declaration" warnings.
diego
parents:
4796
diff
changeset
|
1552 static const int idxtab[16]={3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0}; |
11709 | 1553 int v; |
3610 | 1554 int pos= s_index+idxtab[code]; |
1555 code ^= 8>>idxtab[code]; | |
11710 | 1556 READ_FLIP_SIGN(g->sb_hybrid+pos, RENAME(exp_table)+exponents[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
|
1557 } |
3610 | 1558 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
|
1559 } |
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
|
1560 /* skip extension bits */ |
4468 | 1561 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
|
1562 //av_log(NULL, AV_LOG_ERROR, "left:%d buf:%p\n", bits_left, s->in_gb.buffer); |
7867
2a611af7bcbe
Make decoder more robust by default against broken encoders.
michael
parents:
7831
diff
changeset
|
1563 if (bits_left < 0 && s->error_recognition >= FF_ER_COMPLIANT) { |
7329
104a00d9abfa
Supply context argument to av_log() in mpeg audio decoder.
andoma
parents:
7256
diff
changeset
|
1564 av_log(s->avctx, 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
|
1565 s_index=0; |
7831 | 1566 }else if(bits_left > 0 && s->error_recognition >= FF_ER_AGGRESSIVE){ |
7329
104a00d9abfa
Supply context argument to av_log() in mpeg audio decoder.
andoma
parents:
7256
diff
changeset
|
1567 av_log(s->avctx, 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
|
1568 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
|
1569 } |
4205
8c28f03cfdd5
detect a few more errors (fixes libmp3-bug.avi again)
michael
parents:
4204
diff
changeset
|
1570 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
|
1571 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
|
1572 |
4468 | 1573 i= get_bits_count(&s->gb); |
4469 | 1574 switch_buffer(s, &i, &end_pos, &end_pos2); |
4468 | 1575 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1576 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
|
1577 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1578 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1579 /* 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
|
1580 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
|
1581 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
|
1582 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
|
1583 { |
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
|
1584 int i, j, len; |
11707 | 1585 INTFLOAT *ptr, *dst, *ptr1; |
1586 INTFLOAT 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
|
1587 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1588 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
|
1589 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
|
1590 |
46ee548e47e4
added 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 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
|
1592 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
|
1593 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
|
1594 } 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
|
1595 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
|
1596 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1597 } 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
|
1598 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
|
1599 } |
2967 | 1600 |
82
46ee548e47e4
added 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 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
|
1602 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
|
1603 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
|
1604 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
|
1605 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
|
1606 *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
|
1607 *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
|
1608 *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
|
1609 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
|
1610 } |
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
|
1611 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
|
1612 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
|
1613 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1614 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1615 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1616 #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
|
1617 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1618 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
|
1619 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
|
1620 { |
46ee548e47e4
added 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 int i, j, k, l; |
11707 | 1622 int sf_max, sf, len, non_zero_found; |
1623 INTFLOAT (*is_tab)[16], *tab0, *tab1, tmp0, tmp1, 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
|
1624 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
|
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 /* 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
|
1627 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
|
1628 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
|
1629 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
|
1630 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
|
1631 } 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
|
1632 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
|
1633 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
|
1634 } |
2967 | 1635 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1636 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
|
1637 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
|
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 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
|
1640 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
|
1641 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
|
1642 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
|
1643 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
|
1644 /* 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
|
1645 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
|
1646 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
|
1647 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
|
1648 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
|
1649 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
|
1650 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
|
1651 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
|
1652 /* 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
|
1653 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
|
1654 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
|
1655 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
|
1656 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
|
1657 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 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
|
1660 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
|
1661 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
|
1662 |
46ee548e47e4
added 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 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
|
1664 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
|
1665 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
|
1666 tmp0 = tab0[j]; |
11707 | 1667 tab0[j] = MULLx(tmp0, v1, FRAC_BITS); |
1668 tab1[j] = MULLx(tmp0, v2, FRAC_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
|
1669 } |
46ee548e47e4
added 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 } 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
|
1671 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
|
1672 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
|
1673 /* 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
|
1674 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
|
1675 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
|
1676 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
|
1677 tmp1 = tab1[j]; |
11707 | 1678 tab0[j] = MULLx(tmp0 + tmp1, ISQRT2, FRAC_BITS); |
1679 tab1[j] = MULLx(tmp0 - tmp1, ISQRT2, FRAC_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
|
1680 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 |
2967 | 1686 non_zero_found = non_zero_found_short[0] | |
1687 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
|
1688 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
|
1689 |
46ee548e47e4
added 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 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
|
1691 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
|
1692 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
|
1693 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
|
1694 /* 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
|
1695 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
|
1696 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
|
1697 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
|
1698 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
|
1699 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
|
1700 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 /* 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
|
1703 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
|
1704 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
|
1705 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
|
1706 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
|
1707 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
|
1708 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
|
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 tmp0 = tab0[j]; |
11707 | 1711 tab0[j] = MULLx(tmp0, v1, FRAC_BITS); |
1712 tab1[j] = MULLx(tmp0, v2, FRAC_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
|
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 } 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
|
1715 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
|
1716 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
|
1717 /* 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
|
1718 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
|
1719 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
|
1720 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
|
1721 tmp1 = tab1[j]; |
11707 | 1722 tab0[j] = MULLx(tmp0 + tmp1, ISQRT2, FRAC_BITS); |
1723 tab1[j] = MULLx(tmp0 - tmp1, ISQRT2, FRAC_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
|
1724 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1725 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 } 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
|
1729 /* 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
|
1730 /* 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
|
1731 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
|
1732 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
|
1733 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
|
1734 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
|
1735 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
|
1736 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
|
1737 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
|
1738 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
|
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 } |
46ee548e47e4
added 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 |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1743 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
|
1744 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
|
1745 { |
2491 | 1746 int32_t *ptr, *csa; |
1747 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
|
1748 |
46ee548e47e4
added 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 /* 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
|
1750 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
|
1751 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
|
1752 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
|
1753 /* 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
|
1754 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
|
1755 } 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
|
1756 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
|
1757 } |
2967 | 1758 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1759 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
|
1760 for(i = n;i > 0;i--) { |
2491 | 1761 int tmp0, tmp1, tmp2; |
1762 csa = &csa_table[0][0]; | |
1763 #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
|
1764 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
|
1765 tmp1 = ptr[ j];\ |
2491 | 1766 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
|
1767 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
|
1768 ptr[ j] = 4*(tmp2 + MULH(tmp0, csa[3+4*j])); |
2491 | 1769 |
1770 INT_AA(0) | |
1771 INT_AA(1) | |
1772 INT_AA(2) | |
1773 INT_AA(3) | |
1774 INT_AA(4) | |
1775 INT_AA(5) | |
1776 INT_AA(6) | |
1777 INT_AA(7) | |
2967 | 1778 |
1779 ptr += 18; | |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1780 } |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1781 } |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1782 |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1783 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
|
1784 GranuleDef *g) |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1785 { |
11707 | 1786 float *ptr; |
2491 | 1787 int n, i; |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1788 |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1789 /* we antialias only "long" bands */ |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1790 if (g->block_type == 2) { |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1791 if (!g->switch_point) |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1792 return; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1793 /* XXX: check this for 8000Hz case */ |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1794 n = 1; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1795 } else { |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1796 n = SBLIMIT - 1; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1797 } |
2967 | 1798 |
1733
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1799 ptr = g->sb_hybrid + 18; |
b47d56b1a049
optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents:
1612
diff
changeset
|
1800 for(i = n;i > 0;i--) { |
2491 | 1801 float tmp0, tmp1; |
2967 | 1802 float *csa = &csa_table_float[0][0]; |
2491 | 1803 #define FLOAT_AA(j)\ |
1804 tmp0= ptr[-1-j];\ | |
1805 tmp1= ptr[ j];\ | |
11707 | 1806 ptr[-1-j] = tmp0 * csa[0+4*j] - tmp1 * csa[1+4*j];\ |
1807 ptr[ j] = tmp0 * csa[1+4*j] + tmp1 * csa[0+4*j]; | |
2967 | 1808 |
2491 | 1809 FLOAT_AA(0) |
1810 FLOAT_AA(1) | |
1811 FLOAT_AA(2) | |
1812 FLOAT_AA(3) | |
1813 FLOAT_AA(4) | |
1814 FLOAT_AA(5) | |
1815 FLOAT_AA(6) | |
1816 FLOAT_AA(7) | |
1817 | |
2967 | 1818 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
|
1819 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1820 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1821 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1822 static void compute_imdct(MPADecodeContext *s, |
2967 | 1823 GranuleDef *g, |
11707 | 1824 INTFLOAT *sb_samples, |
1825 INTFLOAT *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
|
1826 { |
11707 | 1827 INTFLOAT *win, *win1, *out_ptr, *ptr, *buf, *ptr1; |
1828 INTFLOAT out2[12]; | |
1829 int i, j, mdct_long_end, 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
|
1830 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1831 /* 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
|
1832 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
|
1833 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
|
1834 while (ptr >= ptr1) { |
11707 | 1835 int32_t *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
|
1836 ptr -= 6; |
11707 | 1837 p= (int32_t*)ptr; |
1838 if(p[0] | p[1] | p[2] | p[3] | p[4] | p[5]) | |
82
46ee548e47e4
added 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 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
|
1840 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1841 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
|
1842 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1843 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
|
1844 /* 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
|
1845 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
|
1846 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
|
1847 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
|
1848 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
|
1849 } 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
|
1850 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
|
1851 } |
46ee548e47e4
added 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 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
|
1854 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
|
1855 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
|
1856 /* 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
|
1857 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
|
1858 /* 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
|
1859 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
|
1860 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
|
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 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
|
1863 /* 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
|
1864 win = win1 + ((4 * 36) & -(j & 1)); |
2489 | 1865 imdct36(out_ptr, buf, ptr, win); |
1866 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
|
1867 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
|
1868 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
|
1869 } |
46ee548e47e4
added 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 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
|
1871 /* 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
|
1872 win = mdct_win[2] + ((4 * 36) & -(j & 1)); |
2495 | 1873 out_ptr = sb_samples + j; |
2967 | 1874 |
2495 | 1875 for(i=0; i<6; i++){ |
1876 *out_ptr = buf[i]; | |
1877 out_ptr += SBLIMIT; | |
1878 } | |
1879 imdct12(out2, ptr + 0); | |
1880 for(i=0;i<6;i++) { | |
11707 | 1881 *out_ptr = MULH3(out2[i ], win[i ], 1) + buf[i + 6*1]; |
1882 buf[i + 6*2] = MULH3(out2[i + 6], win[i + 6], 1); | |
2495 | 1883 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
|
1884 } |
2495 | 1885 imdct12(out2, ptr + 1); |
1886 for(i=0;i<6;i++) { | |
11707 | 1887 *out_ptr = MULH3(out2[i ], win[i ], 1) + buf[i + 6*2]; |
1888 buf[i + 6*0] = MULH3(out2[i + 6], win[i + 6], 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
|
1889 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
|
1890 } |
2495 | 1891 imdct12(out2, ptr + 2); |
1892 for(i=0;i<6;i++) { | |
11707 | 1893 buf[i + 6*0] = MULH3(out2[i ], win[i ], 1) + buf[i + 6*0]; |
1894 buf[i + 6*1] = MULH3(out2[i + 6], win[i + 6], 1); | |
2495 | 1895 buf[i + 6*2] = 0; |
1896 } | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1897 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
|
1898 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
|
1899 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1900 /* 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
|
1901 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
|
1902 /* 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
|
1903 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
|
1904 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
|
1905 *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
|
1906 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
|
1907 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
|
1908 } |
46ee548e47e4
added 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 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
|
1910 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1911 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1912 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1913 /* 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
|
1914 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
|
1915 { |
46ee548e47e4
added 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 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
|
1917 int gr, ch, blocksplit_flag, i, j, k, n, bits_pos; |
10494 | 1918 GranuleDef *g; |
11707 | 1919 int16_t exponents[576]; //FIXME try INTFLOAT |
82
46ee548e47e4
added 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 /* 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
|
1922 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
|
1923 main_data_begin = get_bits(&s->gb, 8); |
3613 | 1924 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
|
1925 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
|
1926 } 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
|
1927 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
|
1928 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
|
1929 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
|
1930 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
|
1931 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
|
1932 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
|
1933 for(ch=0;ch<s->nb_channels;ch++) { |
10494 | 1934 s->granules[ch][0].scfsi = 0;/* all scale factors are transmitted */ |
1935 s->granules[ch][1].scfsi = get_bits(&s->gb, 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
|
1936 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1937 } |
2967 | 1938 |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
1939 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
|
1940 for(ch=0;ch<s->nb_channels;ch++) { |
4652 | 1941 dprintf(s->avctx, "gr=%d ch=%d: side_info\n", gr, ch); |
10494 | 1942 g = &s->granules[ch][gr]; |
82
46ee548e47e4
added 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 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
|
1944 g->big_values = get_bits(&s->gb, 9); |
4202 | 1945 if(g->big_values > 288){ |
4652 | 1946 av_log(s->avctx, AV_LOG_ERROR, "big_values too big\n"); |
4202 | 1947 return -1; |
1948 } | |
1949 | |
82
46ee548e47e4
added 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 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
|
1951 /* 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
|
1952 1/sqrt(2) renormalization factor */ |
2967 | 1953 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
|
1954 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
|
1955 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
|
1956 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
|
1957 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
|
1958 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
|
1959 g->scalefac_compress = get_bits(&s->gb, 4); |
5513 | 1960 blocksplit_flag = get_bits1(&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
|
1961 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
|
1962 g->block_type = get_bits(&s->gb, 2); |
4202 | 1963 if (g->block_type == 0){ |
7329
104a00d9abfa
Supply context argument to av_log() in mpeg audio decoder.
andoma
parents:
7256
diff
changeset
|
1964 av_log(s->avctx, 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
|
1965 return -1; |
4202 | 1966 } |
5513 | 1967 g->switch_point = get_bits1(&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
|
1968 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
|
1969 g->table_select[i] = get_bits(&s->gb, 5); |
2967 | 1970 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
|
1971 g->subblock_gain[i] = get_bits(&s->gb, 3); |
6138
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
1972 ff_init_short_region(s, g); |
82
46ee548e47e4
added 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 } else { |
6138
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
1974 int region_address1, region_address2; |
82
46ee548e47e4
added 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 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
|
1976 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
|
1977 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
|
1978 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
|
1979 /* 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
|
1980 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
|
1981 region_address2 = get_bits(&s->gb, 3); |
4652 | 1982 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
|
1983 region_address1, region_address2); |
6138
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
1984 ff_init_long_region(s, g, region_address1, region_address2); |
82
46ee548e47e4
added 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 } |
6138
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
1986 ff_region_offset2size(g); |
c7a61f83de73
Factorize some code into functions, had this in my tree and will be
michael
parents:
6137
diff
changeset
|
1987 ff_compute_band_indexes(s, g); |
2967 | 1988 |
82
46ee548e47e4
added 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 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
|
1990 if (!s->lsf) |
5513 | 1991 g->preflag = get_bits1(&s->gb); |
1992 g->scalefac_scale = get_bits1(&s->gb); | |
1993 g->count1table_select = get_bits1(&s->gb); | |
4652 | 1994 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
|
1995 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
|
1996 } |
46ee548e47e4
added 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 } |
0 | 1998 |
2432 | 1999 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
|
2000 const uint8_t *ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3); |
3647 | 2001 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
|
2002 /* now we get bits from the main_data_begin offset */ |
4652 | 2003 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
|
2004 //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
|
2005 |
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
|
2006 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
|
2007 s->in_gb= s->gb; |
4204 | 2008 init_get_bits(&s->gb, s->last_buf, s->last_buf_size*8); |
2009 skip_bits_long(&s->gb, 8*(s->last_buf_size - main_data_begin)); | |
2432 | 2010 } |
82
46ee548e47e4
added 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 |
46ee548e47e4
added 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 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
|
2013 for(ch=0;ch<s->nb_channels;ch++) { |
10494 | 2014 g = &s->granules[ch][gr]; |
4204 | 2015 if(get_bits_count(&s->gb)<0){ |
10125
67b0747c4192
Reduce pointless verbosity after seeks in the MP3 decoder.
diego
parents:
9896
diff
changeset
|
2016 av_log(s->avctx, AV_LOG_DEBUG, "mdb:%d, lastbuf:%d skipping granule %d\n", |
4204 | 2017 main_data_begin, s->last_buf_size, gr); |
2018 skip_bits_long(&s->gb, g->part2_3_length); | |
2019 memset(g->sb_hybrid, 0, sizeof(g->sb_hybrid)); | |
2020 if(get_bits_count(&s->gb) >= s->gb.size_in_bits && s->in_gb.buffer){ | |
2021 skip_bits_long(&s->in_gb, get_bits_count(&s->gb) - s->gb.size_in_bits); | |
2022 s->gb= s->in_gb; | |
2023 s->in_gb.buffer=NULL; | |
2024 } | |
2025 continue; | |
2026 } | |
2967 | 2027 |
82
46ee548e47e4
added 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 bits_pos = get_bits_count(&s->gb); |
2967 | 2029 |
82
46ee548e47e4
added 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 if (!s->lsf) { |
1064 | 2031 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
|
2032 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
|
2033 |
46ee548e47e4
added 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 /* 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
|
2035 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
|
2036 slen2 = slen_table[1][g->scalefac_compress]; |
4652 | 2037 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
|
2038 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
|
2039 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
|
2040 j = 0; |
3616 | 2041 if(slen1){ |
2042 for(i=0;i<n;i++) | |
2043 g->scale_factors[j++] = get_bits(&s->gb, slen1); | |
2044 }else{ | |
2045 for(i=0;i<n;i++) | |
2046 g->scale_factors[j++] = 0; | |
2047 } | |
2048 if(slen2){ | |
2049 for(i=0;i<18;i++) | |
2050 g->scale_factors[j++] = get_bits(&s->gb, slen2); | |
2051 for(i=0;i<3;i++) | |
2052 g->scale_factors[j++] = 0; | |
2053 }else{ | |
2054 for(i=0;i<21;i++) | |
2055 g->scale_factors[j++] = 0; | |
2056 } | |
82
46ee548e47e4
added 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 } else { |
10494 | 2058 sc = s->granules[ch][0].scale_factors; |
82
46ee548e47e4
added 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 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
|
2060 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
|
2061 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
|
2062 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
|
2063 slen = (k < 2) ? slen1 : slen2; |
3616 | 2064 if(slen){ |
2065 for(i=0;i<n;i++) | |
2066 g->scale_factors[j++] = get_bits(&s->gb, slen); | |
2067 }else{ | |
2068 for(i=0;i<n;i++) | |
2069 g->scale_factors[j++] = 0; | |
2070 } | |
82
46ee548e47e4
added 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 } 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
|
2072 /* 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
|
2073 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
|
2074 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
|
2075 j++; |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2076 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 } |
46ee548e47e4
added 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 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
|
2080 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2081 } 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
|
2082 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
|
2083 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2084 /* 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
|
2085 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
|
2086 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
|
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 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
|
2089 } |
46ee548e47e4
added 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 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
|
2091 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
|
2092 /* 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
|
2093 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
|
2094 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
|
2095 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
|
2096 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
|
2097 } 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
|
2098 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
|
2099 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
|
2100 } 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
|
2101 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
|
2102 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
|
2103 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2104 } 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
|
2105 /* 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
|
2106 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
|
2107 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
|
2108 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
|
2109 } 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
|
2110 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
|
2111 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
|
2112 } 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
|
2113 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
|
2114 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
|
2115 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
|
2116 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2117 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2118 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2119 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
|
2120 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
|
2121 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
|
2122 sl = slen[k]; |
3617 | 2123 if(sl){ |
3616 | 2124 for(i=0;i<n;i++) |
2125 g->scale_factors[j++] = get_bits(&s->gb, sl); | |
2126 }else{ | |
2127 for(i=0;i<n;i++) | |
2128 g->scale_factors[j++] = 0; | |
2129 } | |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2130 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2131 /* 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
|
2132 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
|
2133 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
|
2134 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2135 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2136 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
|
2137 |
46ee548e47e4
added 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 /* read Huffman coded residue */ |
4204 | 2139 huffman_decode(s, g, exponents, bits_pos + g->part2_3_length); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2140 } /* 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
|
2141 |
46ee548e47e4
added 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 if (s->nb_channels == 2) |
10494 | 2143 compute_stereo(s, &s->granules[0][gr], &s->granules[1][gr]); |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2144 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2145 for(ch=0;ch<s->nb_channels;ch++) { |
10494 | 2146 g = &s->granules[ch][gr]; |
82
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2147 |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2148 reorder_block(s, g); |
11707 | 2149 compute_antialias(s, g); |
2967 | 2150 compute_imdct(s, g, &s->sb_samples[ch][18 * gr][0], s->mdct_buf[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
|
2151 } |
46ee548e47e4
added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents:
0
diff
changeset
|
2152 } /* gr */ |
4204 | 2153 if(get_bits_count(&s->gb)<0) |
2154 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
|
2155 return nb_granules * 18; |
0 | 2156 } |
2157 | |
2967 | 2158 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
|
2159 OUT_INT *samples, const uint8_t *buf, int buf_size) |
0 | 2160 { |
82
46ee548e47e4
added 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 int i, nb_frames, ch; |
2479 | 2162 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
|
2163 |
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
|
2164 init_get_bits(&s->gb, buf + HEADER_SIZE, (buf_size - HEADER_SIZE)*8); |
2967 | 2165 |
0 | 2166 /* skip error protection field */ |
2167 if (s->error_protection) | |
5518 | 2168 skip_bits(&s->gb, 16); |
0 | 2169 |
4652 | 2170 dprintf(s->avctx, "frame %d:\n", s->frame_count); |
0 | 2171 switch(s->layer) { |
2172 case 1: | |
6511 | 2173 s->avctx->frame_size = 384; |
82
46ee548e47e4
added 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 nb_frames = mp_decode_layer1(s); |
0 | 2175 break; |
2176 case 2: | |
6511 | 2177 s->avctx->frame_size = 1152; |
82
46ee548e47e4
added 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 nb_frames = mp_decode_layer2(s); |
0 | 2179 break; |
2180 case 3: | |
6511 | 2181 s->avctx->frame_size = s->lsf ? 576 : 1152; |
0 | 2182 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
|
2183 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
|
2184 |
3643 | 2185 s->last_buf_size=0; |
2186 if(s->in_gb.buffer){ | |
2187 align_get_bits(&s->gb); | |
10535
95f3daa991a2
Use get_bits_left() instead of size_in_bits - get_bits_count().
rbultje
parents:
10494
diff
changeset
|
2188 i= get_bits_left(&s->gb)>>3; |
3647 | 2189 if(i >= 0 && i <= BACKSTEP_SIZE){ |
3643 | 2190 memmove(s->last_buf, s->gb.buffer + (get_bits_count(&s->gb)>>3), i); |
2191 s->last_buf_size=i; | |
3647 | 2192 }else |
7329
104a00d9abfa
Supply context argument to av_log() in mpeg audio decoder.
andoma
parents:
7256
diff
changeset
|
2193 av_log(s->avctx, 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
|
2194 s->gb= s->in_gb; |
4204 | 2195 s->in_gb.buffer= NULL; |
3643 | 2196 } |
2197 | |
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
|
2198 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
|
2199 assert((get_bits_count(&s->gb) & 7) == 0); |
10535
95f3daa991a2
Use get_bits_left() instead of size_in_bits - get_bits_count().
rbultje
parents:
10494
diff
changeset
|
2200 i= get_bits_left(&s->gb)>>3; |
3643 | 2201 |
3647 | 2202 if(i<0 || i > BACKSTEP_SIZE || nb_frames<0){ |
7870
08ef30f08a01
Only print "invalid new backstep" when it is really invalid.
michael
parents:
7867
diff
changeset
|
2203 if(i<0) |
08ef30f08a01
Only print "invalid new backstep" when it is really invalid.
michael
parents:
7867
diff
changeset
|
2204 av_log(s->avctx, AV_LOG_ERROR, "invalid new backstep %d\n", i); |
3647 | 2205 i= FFMIN(BACKSTEP_SIZE, buf_size - HEADER_SIZE); |
2206 } | |
3643 | 2207 assert(i <= buf_size - HEADER_SIZE && i>= 0); |
3647 | 2208 memcpy(s->last_buf + s->last_buf_size, s->gb.buffer + buf_size - HEADER_SIZE - i, i); |
3643 | 2209 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
|
2210 |
0 | 2211 break; |
2212 } | |
7763
73b10d25cb8d
Remove debuging junk that probably hasnt been used by anyone since years.
michael
parents:
7452
diff
changeset
|
2213 |
82
46ee548e47e4
added 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 /* 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
|
2215 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
|
2216 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
|
2217 for(i=0;i<nb_frames;i++) { |
11707 | 2218 RENAME(ff_mpa_synth_filter)(s->synth_buf[ch], &(s->synth_buf_offset[ch]), |
2219 RENAME(ff_mpa_synth_window), &s->dither_state, | |
2979 | 2220 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
|
2221 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
|
2222 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
|
2223 } |
46ee548e47e4
added 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 } |
7763
73b10d25cb8d
Remove debuging junk that probably hasnt been used by anyone since years.
michael
parents:
7452
diff
changeset
|
2225 |
2479 | 2226 return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels; |
0 | 2227 } |
2228 | |
2229 static int decode_frame(AVCodecContext * avctx, | |
2979 | 2230 void *data, int *data_size, |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
9007
diff
changeset
|
2231 AVPacket *avpkt) |
0 | 2232 { |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
9007
diff
changeset
|
2233 const uint8_t *buf = avpkt->data; |
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
9007
diff
changeset
|
2234 int buf_size = avpkt->size; |
0 | 2235 MPADecodeContext *s = avctx->priv_data; |
1064 | 2236 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
|
2237 int out_size; |
2479 | 2238 OUT_INT *out_samples = data; |
0 | 2239 |
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
|
2240 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
|
2241 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
|
2242 |
5089 | 2243 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
|
2244 if(ff_mpa_check_header(header) < 0){ |
9896
bbefbca72722
Drop code that attempts to decode frames that are prefixed by junk.
michael
parents:
9603
diff
changeset
|
2245 av_log(avctx, AV_LOG_ERROR, "Header missing\n"); |
bbefbca72722
Drop code that attempts to decode frames that are prefixed by junk.
michael
parents:
9603
diff
changeset
|
2246 return -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
|
2247 } |
143 | 2248 |
8641 | 2249 if (ff_mpegaudio_decode_header((MPADecodeHeader *)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
|
2250 /* 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
|
2251 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
|
2252 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
|
2253 } |
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
|
2254 /* 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
|
2255 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
|
2256 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
|
2257 avctx->sub_id = s->layer; |
82
46ee548e47e4
added 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 |
10240 | 2259 if(*data_size < 1152*avctx->channels*sizeof(OUT_INT)) |
2260 return -1; | |
10242
359554637332
Set data_size to 0 to avoid having it uninitialized.
michael
parents:
10241
diff
changeset
|
2261 *data_size = 0; |
10240 | 2262 |
3687 | 2263 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
|
2264 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
|
2265 return -1; |
3687 | 2266 }else if(s->frame_size < buf_size){ |
2267 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
|
2268 buf_size= s->frame_size; |
0 | 2269 } |
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
|
2270 |
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
|
2271 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
|
2272 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
|
2273 *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
|
2274 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
|
2275 //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
|
2276 }else |
3938 | 2277 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
|
2278 s->frame_size = 0; |
9896
bbefbca72722
Drop code that attempts to decode frames that are prefixed by junk.
michael
parents:
9603
diff
changeset
|
2279 return buf_size; |
0 | 2280 } |
2281 | |
4203 | 2282 static void flush(AVCodecContext *avctx){ |
2283 MPADecodeContext *s = avctx->priv_data; | |
6137
5ef885b008c0
Clear synth_buf on flush(). Part of a patch by Brian Brice bbrice gmail com.
michael
parents:
6136
diff
changeset
|
2284 memset(s->synth_buf, 0, sizeof(s->synth_buf)); |
4203 | 2285 s->last_buf_size= 0; |
2286 } | |
2287 | |
8590 | 2288 #if CONFIG_MP3ADU_DECODER |
2432 | 2289 static int decode_frame_adu(AVCodecContext * avctx, |
2979 | 2290 void *data, int *data_size, |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
9007
diff
changeset
|
2291 AVPacket *avpkt) |
2432 | 2292 { |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
9007
diff
changeset
|
2293 const uint8_t *buf = avpkt->data; |
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
9007
diff
changeset
|
2294 int buf_size = avpkt->size; |
2432 | 2295 MPADecodeContext *s = avctx->priv_data; |
2296 uint32_t header; | |
2297 int len, out_size; | |
2479 | 2298 OUT_INT *out_samples = data; |
2432 | 2299 |
2300 len = buf_size; | |
2301 | |
2302 // Discard too short frames | |
2303 if (buf_size < HEADER_SIZE) { | |
2304 *data_size = 0; | |
2305 return buf_size; | |
2306 } | |
2307 | |
2308 | |
2309 if (len > MPA_MAX_CODED_FRAME_SIZE) | |
2310 len = MPA_MAX_CODED_FRAME_SIZE; | |
2311 | |
2312 // Get header and restore sync word | |
5089 | 2313 header = AV_RB32(buf) | 0xffe00000; |
2432 | 2314 |
2472 | 2315 if (ff_mpa_check_header(header) < 0) { // Bad header, discard frame |
2432 | 2316 *data_size = 0; |
2317 return buf_size; | |
2318 } | |
2319 | |
8641 | 2320 ff_mpegaudio_decode_header((MPADecodeHeader *)s, header); |
2432 | 2321 /* update codec info */ |
2322 avctx->sample_rate = s->sample_rate; | |
2323 avctx->channels = s->nb_channels; | |
2324 avctx->bit_rate = s->bit_rate; | |
2325 avctx->sub_id = s->layer; | |
2326 | |
6510
771eb7ea8b3f
correctly set avctx->frame_size for mp3on4 and mp3adu
bcoudurier
parents:
6350
diff
changeset
|
2327 s->frame_size = len; |
2432 | 2328 |
2329 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
|
2330 out_size = buf_size; |
2432 | 2331 } 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
|
2332 out_size = mp_decode_frame(s, out_samples, buf, buf_size); |
2432 | 2333 } |
2334 | |
2335 *data_size = out_size; | |
2336 return buf_size; | |
2337 } | |
3777 | 2338 #endif /* CONFIG_MP3ADU_DECODER */ |
2432 | 2339 |
8590 | 2340 #if CONFIG_MP3ON4_DECODER |
6694 | 2341 |
6699
99cf02b8f831
move MP3On4DecodeContext def near the code and under ifdef
bcoudurier
parents:
6698
diff
changeset
|
2342 /** |
99cf02b8f831
move MP3On4DecodeContext def near the code and under ifdef
bcoudurier
parents:
6698
diff
changeset
|
2343 * Context for MP3On4 decoder |
99cf02b8f831
move MP3On4DecodeContext def near the code and under ifdef
bcoudurier
parents:
6698
diff
changeset
|
2344 */ |
99cf02b8f831
move MP3On4DecodeContext def near the code and under ifdef
bcoudurier
parents:
6698
diff
changeset
|
2345 typedef struct MP3On4DecodeContext { |
99cf02b8f831
move MP3On4DecodeContext def near the code and under ifdef
bcoudurier
parents:
6698
diff
changeset
|
2346 int frames; ///< number of mp3 frames per block (number of mp3 decoder instances) |
99cf02b8f831
move MP3On4DecodeContext def near the code and under ifdef
bcoudurier
parents:
6698
diff
changeset
|
2347 int syncword; ///< syncword patch |
6700 | 2348 const uint8_t *coff; ///< channels offsets in output buffer |
6699
99cf02b8f831
move MP3On4DecodeContext def near the code and under ifdef
bcoudurier
parents:
6698
diff
changeset
|
2349 MPADecodeContext *mp3decctx[5]; ///< MPADecodeContext for every decoder instance |
99cf02b8f831
move MP3On4DecodeContext def near the code and under ifdef
bcoudurier
parents:
6698
diff
changeset
|
2350 } MP3On4DecodeContext; |
99cf02b8f831
move MP3On4DecodeContext def near the code and under ifdef
bcoudurier
parents:
6698
diff
changeset
|
2351 |
6694 | 2352 #include "mpeg4audio.h" |
2353 | |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2354 /* Next 3 arrays are indexed by channel config number (passed via codecdata) */ |
6696
c3182ffe1689
remove old draft last case not present anymore in iso specs
bcoudurier
parents:
6694
diff
changeset
|
2355 static const uint8_t mp3Frames[8] = {0,1,1,2,3,3,4,5}; /* number of mp3 decoder instances */ |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2356 /* offsets into output buffer, assume output order is FL FR BL BR C LFE */ |
6696
c3182ffe1689
remove old draft last case not present anymore in iso specs
bcoudurier
parents:
6694
diff
changeset
|
2357 static const uint8_t chan_offset[8][5] = { |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2358 {0}, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2359 {0}, // C |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2360 {0}, // FLR |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2361 {2,0}, // C FLR |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2362 {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
|
2363 {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
|
2364 {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
|
2365 {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
|
2366 }; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2367 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2368 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2369 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
|
2370 { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2371 MP3On4DecodeContext *s = avctx->priv_data; |
6694 | 2372 MPEG4AudioConfig cfg; |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2373 int i; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2374 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2375 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
|
2376 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
|
2377 return -1; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2378 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2379 |
6694 | 2380 ff_mpeg4audio_get_config(&cfg, avctx->extradata, avctx->extradata_size); |
2381 if (!cfg.chan_config || cfg.chan_config > 7) { | |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2382 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
|
2383 return -1; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2384 } |
6700 | 2385 s->frames = mp3Frames[cfg.chan_config]; |
2386 s->coff = chan_offset[cfg.chan_config]; | |
2387 avctx->channels = ff_mpeg4audio_channels[cfg.chan_config]; | |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2388 |
6698
06f422f73ade
correctly patch syncword for samples rates < 16000, decoder now fully support all iso ref files
bcoudurier
parents:
6697
diff
changeset
|
2389 if (cfg.sample_rate < 16000) |
06f422f73ade
correctly patch syncword for samples rates < 16000, decoder now fully support all iso ref files
bcoudurier
parents:
6697
diff
changeset
|
2390 s->syncword = 0xffe00000; |
06f422f73ade
correctly patch syncword for samples rates < 16000, decoder now fully support all iso ref files
bcoudurier
parents:
6697
diff
changeset
|
2391 else |
06f422f73ade
correctly patch syncword for samples rates < 16000, decoder now fully support all iso ref files
bcoudurier
parents:
6697
diff
changeset
|
2392 s->syncword = 0xfff00000; |
06f422f73ade
correctly patch syncword for samples rates < 16000, decoder now fully support all iso ref files
bcoudurier
parents:
6697
diff
changeset
|
2393 |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2394 /* 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
|
2395 * 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
|
2396 * decode_init() does not have to be changed. |
6350 | 2397 * Other decoders will be initialized here copying data from the first context |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2398 */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2399 // 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
|
2400 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
|
2401 // 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
|
2402 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
|
2403 decode_init(avctx); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2404 // Restore mp3on4 context pointer |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2405 avctx->priv_data = s; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2406 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
|
2407 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2408 /* 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
|
2409 * 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
|
2410 */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2411 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
|
2412 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
|
2413 s->mp3decctx[i]->adu_mode = 1; |
4652 | 2414 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
|
2415 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2416 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2417 return 0; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2418 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2419 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2420 |
9007
043574c5c153
Add missing av_cold in static init/close functions.
stefano
parents:
8718
diff
changeset
|
2421 static av_cold int decode_close_mp3on4(AVCodecContext * avctx) |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2422 { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2423 MP3On4DecodeContext *s = avctx->priv_data; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2424 int i; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2425 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2426 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
|
2427 if (s->mp3decctx[i]) |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2428 av_free(s->mp3decctx[i]); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2429 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2430 return 0; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2431 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2432 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2433 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2434 static int decode_frame_mp3on4(AVCodecContext * avctx, |
2979 | 2435 void *data, int *data_size, |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
9007
diff
changeset
|
2436 AVPacket *avpkt) |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2437 { |
9355
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
9007
diff
changeset
|
2438 const uint8_t *buf = avpkt->data; |
54bc8a2727b0
Implement avcodec_decode_video2(), _audio3() and _subtitle2() which takes an
rbultje
parents:
9007
diff
changeset
|
2439 int buf_size = avpkt->size; |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2440 MP3On4DecodeContext *s = avctx->priv_data; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2441 MPADecodeContext *m; |
6704 | 2442 int fsize, len = buf_size, out_size = 0; |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2443 uint32_t header; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2444 OUT_INT *out_samples = data; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2445 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
|
2446 OUT_INT *outptr, *bp; |
6702 | 2447 int fr, j, n; |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2448 |
10241 | 2449 if(*data_size < MPA_FRAME_SIZE * MPA_MAX_CHANNELS * s->frames * sizeof(OUT_INT)) |
2450 return -1; | |
2451 | |
6688 | 2452 *data_size = 0; |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2453 // Discard too short frames |
6688 | 2454 if (buf_size < HEADER_SIZE) |
2455 return -1; | |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2456 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2457 // 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
|
2458 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
|
2459 |
6702 | 2460 avctx->bit_rate = 0; |
2461 | |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2462 for (fr = 0; fr < s->frames; fr++) { |
6692 | 2463 fsize = AV_RB16(buf) >> 4; |
6689 | 2464 fsize = FFMIN3(fsize, len, MPA_MAX_CODED_FRAME_SIZE); |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2465 m = s->mp3decctx[fr]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2466 assert (m != NULL); |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2467 |
6698
06f422f73ade
correctly patch syncword for samples rates < 16000, decoder now fully support all iso ref files
bcoudurier
parents:
6697
diff
changeset
|
2468 header = (AV_RB32(buf) & 0x000fffff) | s->syncword; // patch header |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2469 |
6705
d5515254fbbd
break if error in header so it can output already decoded frames
bcoudurier
parents:
6704
diff
changeset
|
2470 if (ff_mpa_check_header(header) < 0) // Bad header, discard block |
d5515254fbbd
break if error in header so it can output already decoded frames
bcoudurier
parents:
6704
diff
changeset
|
2471 break; |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2472 |
8641 | 2473 ff_mpegaudio_decode_header((MPADecodeHeader *)m, header); |
6697 | 2474 out_size += mp_decode_frame(m, outptr, buf, fsize); |
6692 | 2475 buf += fsize; |
2476 len -= fsize; | |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2477 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2478 if(s->frames > 1) { |
6691 | 2479 n = m->avctx->frame_size*m->nb_channels; |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2480 /* interleave output data */ |
6700 | 2481 bp = out_samples + s->coff[fr]; |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2482 if(m->nb_channels == 1) { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2483 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
|
2484 *bp = decoded_buf[j]; |
6701 | 2485 bp += avctx->channels; |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2486 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2487 } else { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2488 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
|
2489 bp[0] = decoded_buf[j++]; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2490 bp[1] = decoded_buf[j]; |
6701 | 2491 bp += avctx->channels; |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2492 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2493 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2494 } |
6702 | 2495 avctx->bit_rate += m->bit_rate; |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2496 } |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2497 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2498 /* update codec info */ |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2499 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
|
2500 |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2501 *data_size = out_size; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2502 return buf_size; |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2503 } |
3777 | 2504 #endif /* CONFIG_MP3ON4_DECODER */ |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2505 |
11707 | 2506 #if !CONFIG_FLOAT |
8590 | 2507 #if CONFIG_MP1_DECODER |
8586
d7d0cde5f308
Add dummy mp1_decoder to complement the existing dummy mp2/mp3 decoders.
michael
parents:
8439
diff
changeset
|
2508 AVCodec mp1_decoder = |
d7d0cde5f308
Add dummy mp1_decoder to complement the existing dummy mp2/mp3 decoders.
michael
parents:
8439
diff
changeset
|
2509 { |
d7d0cde5f308
Add dummy mp1_decoder to complement the existing dummy mp2/mp3 decoders.
michael
parents:
8439
diff
changeset
|
2510 "mp1", |
11560
8a4984c5cacc
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
11374
diff
changeset
|
2511 AVMEDIA_TYPE_AUDIO, |
8586
d7d0cde5f308
Add dummy mp1_decoder to complement the existing dummy mp2/mp3 decoders.
michael
parents:
8439
diff
changeset
|
2512 CODEC_ID_MP1, |
d7d0cde5f308
Add dummy mp1_decoder to complement the existing dummy mp2/mp3 decoders.
michael
parents:
8439
diff
changeset
|
2513 sizeof(MPADecodeContext), |
d7d0cde5f308
Add dummy mp1_decoder to complement the existing dummy mp2/mp3 decoders.
michael
parents:
8439
diff
changeset
|
2514 decode_init, |
d7d0cde5f308
Add dummy mp1_decoder to complement the existing dummy mp2/mp3 decoders.
michael
parents:
8439
diff
changeset
|
2515 NULL, |
d7d0cde5f308
Add dummy mp1_decoder to complement the existing dummy mp2/mp3 decoders.
michael
parents:
8439
diff
changeset
|
2516 NULL, |
d7d0cde5f308
Add dummy mp1_decoder to complement the existing dummy mp2/mp3 decoders.
michael
parents:
8439
diff
changeset
|
2517 decode_frame, |
d7d0cde5f308
Add dummy mp1_decoder to complement the existing dummy mp2/mp3 decoders.
michael
parents:
8439
diff
changeset
|
2518 CODEC_CAP_PARSE_ONLY, |
d7d0cde5f308
Add dummy mp1_decoder to complement the existing dummy mp2/mp3 decoders.
michael
parents:
8439
diff
changeset
|
2519 .flush= flush, |
d7d0cde5f308
Add dummy mp1_decoder to complement the existing dummy mp2/mp3 decoders.
michael
parents:
8439
diff
changeset
|
2520 .long_name= NULL_IF_CONFIG_SMALL("MP1 (MPEG audio layer 1)"), |
d7d0cde5f308
Add dummy mp1_decoder to complement the existing dummy mp2/mp3 decoders.
michael
parents:
8439
diff
changeset
|
2521 }; |
d7d0cde5f308
Add dummy mp1_decoder to complement the existing dummy mp2/mp3 decoders.
michael
parents:
8439
diff
changeset
|
2522 #endif |
8590 | 2523 #if CONFIG_MP2_DECODER |
322 | 2524 AVCodec mp2_decoder = |
0 | 2525 { |
322 | 2526 "mp2", |
11560
8a4984c5cacc
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
11374
diff
changeset
|
2527 AVMEDIA_TYPE_AUDIO, |
0 | 2528 CODEC_ID_MP2, |
2529 sizeof(MPADecodeContext), | |
2530 decode_init, | |
2531 NULL, | |
2532 NULL, | |
2533 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
|
2534 CODEC_CAP_PARSE_ONLY, |
6136
85f3acb225e9
Flush mp2 as well on seeking. Part of a patch by Brian Brice bbrice gmail com.
michael
parents:
5886
diff
changeset
|
2535 .flush= flush, |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6712
diff
changeset
|
2536 .long_name= NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"), |
0 | 2537 }; |
3777 | 2538 #endif |
8590 | 2539 #if CONFIG_MP3_DECODER |
322 | 2540 AVCodec mp3_decoder = |
2541 { | |
2542 "mp3", | |
11560
8a4984c5cacc
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
11374
diff
changeset
|
2543 AVMEDIA_TYPE_AUDIO, |
1448 | 2544 CODEC_ID_MP3, |
322 | 2545 sizeof(MPADecodeContext), |
2546 decode_init, | |
2547 NULL, | |
2548 NULL, | |
2549 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
|
2550 CODEC_CAP_PARSE_ONLY, |
4203 | 2551 .flush= flush, |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6712
diff
changeset
|
2552 .long_name= NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"), |
322 | 2553 }; |
3777 | 2554 #endif |
8590 | 2555 #if CONFIG_MP3ADU_DECODER |
2432 | 2556 AVCodec mp3adu_decoder = |
2557 { | |
2558 "mp3adu", | |
11560
8a4984c5cacc
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
11374
diff
changeset
|
2559 AVMEDIA_TYPE_AUDIO, |
2432 | 2560 CODEC_ID_MP3ADU, |
2561 sizeof(MPADecodeContext), | |
2562 decode_init, | |
2563 NULL, | |
2564 NULL, | |
2565 decode_frame_adu, | |
2566 CODEC_CAP_PARSE_ONLY, | |
4203 | 2567 .flush= flush, |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6712
diff
changeset
|
2568 .long_name= NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"), |
2432 | 2569 }; |
3777 | 2570 #endif |
8590 | 2571 #if CONFIG_MP3ON4_DECODER |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2572 AVCodec mp3on4_decoder = |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2573 { |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2574 "mp3on4", |
11560
8a4984c5cacc
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
11374
diff
changeset
|
2575 AVMEDIA_TYPE_AUDIO, |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2576 CODEC_ID_MP3ON4, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2577 sizeof(MP3On4DecodeContext), |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2578 decode_init_mp3on4, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2579 NULL, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2580 decode_close_mp3on4, |
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2581 decode_frame_mp3on4, |
4203 | 2582 .flush= flush, |
7040
e943e1409077
Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents:
6712
diff
changeset
|
2583 .long_name= NULL_IF_CONFIG_SMALL("MP3onMP4"), |
2507
0334caf0f0ce
Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents:
2496
diff
changeset
|
2584 }; |
3777 | 2585 #endif |
11707 | 2586 #endif |