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