annotate mpegaudiodec.c @ 8579:dc7bfff68156 libavcodec

add the necessary include for LIBAV*_VERSION_*
author aurel
date Tue, 13 Jan 2009 00:14:43 +0000
parents c5302e0ecf4e
children d7d0cde5f308
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
1 /*
986e461dc072 Initial revision
glantau
parents:
diff changeset
2 * MPEG Audio decoder
429
718a22dc121f license/copyright change
glantau
parents: 407
diff changeset
3 * Copyright (c) 2001, 2002 Fabrice Bellard.
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
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
718a22dc121f license/copyright change
glantau
parents: 407
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
718a22dc121f license/copyright change
glantau
parents: 407
diff changeset
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
986e461dc072 Initial revision
glantau
parents:
diff changeset
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
986e461dc072 Initial revision
glantau
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
429
718a22dc121f license/copyright change
glantau
parents: 407
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
718a22dc121f license/copyright change
glantau
parents: 407
diff changeset
15 * Lesser General Public License for more details.
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
16 *
429
718a22dc121f license/copyright change
glantau
parents: 407
diff changeset
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
986e461dc072 Initial revision
glantau
parents:
diff changeset
20 */
1106
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
21
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
22 /**
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
23 * @file mpegaudiodec.c
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
24 * MPEG Audio decoder.
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
25 */
1106
1e39f273ecd6 per file doxy
michaelni
parents: 1064
diff changeset
26
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
27 #include "avcodec.h"
2398
582e635cfa08 common.c -> bitstream.c (and the single non bitstream func -> utils.c)
michael
parents: 2370
diff changeset
28 #include "bitstream.h"
1734
8aace334bcf0 lrintf patch by ("Steven M. Schultz" <sms at 2BSD dot COM>)
michael
parents: 1733
diff changeset
29 #include "dsputil.h"
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
30
986e461dc072 Initial revision
glantau
parents:
diff changeset
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
986e461dc072 Initial revision
glantau
parents:
diff changeset
35 */
986e461dc072 Initial revision
glantau
parents:
diff changeset
36
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
37 /* define USE_HIGHPRECISION to have a bit exact (but slower) mpeg
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
38 audio decoder */
449
7b2f23b5dcdd fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents: 440
diff changeset
39 #ifdef CONFIG_MPEGAUDIO_HP
3602
38b7b3629249 indent preprocessor directives
michael
parents: 3601
diff changeset
40 # define USE_HIGHPRECISION
449
7b2f23b5dcdd fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents: 440
diff changeset
41 #endif
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
42
2913
cc55bc1f8d92 QDM2 compatible decoder
rtognimp
parents: 2911
diff changeset
43 #include "mpegaudio.h"
5050
a5f6fbc9fa66 loosen dependencies over mpegaudiodec
aurel
parents: 5032
diff changeset
44 #include "mpegaudiodecheader.h"
2479
dfdb6bf4b90f support 32bit output for the mpeg audio decoder
michael
parents: 2478
diff changeset
45
3752
32b2da1060ea Use mathops
lu_zero
parents: 3732
diff changeset
46 #include "mathops.h"
32b2da1060ea Use mathops
lu_zero
parents: 3732
diff changeset
47
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
48 /* WARNING: only correct for posititive numbers */
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
49 #define FIXR(a) ((int)((a) * FRAC_ONE + 0.5))
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
50 #define FRAC_RND(a) (((a) + (FRAC_ONE/2)) >> FRAC_BITS)
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
51
2489
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
52 #define FIXHR(a) ((int)((a) * (1LL<<32) + 0.5))
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
53
82
46ee548e47e4 added 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 /****************/
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
55
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
56 #define HEADER_SIZE 4
986e461dc072 Initial revision
glantau
parents:
diff changeset
57
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
58 /* layer 3 "granule" */
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
59 typedef struct GranuleDef {
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
60 uint8_t scfsi;
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
61 int part2_3_length;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
62 int big_values;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
63 int global_gain;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
64 int scalefac_compress;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
65 uint8_t block_type;
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
66 uint8_t switch_point;
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
67 int table_select[3];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
68 int subblock_gain[3];
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
69 uint8_t scalefac_scale;
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
70 uint8_t count1table_select;
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
71 int region_size[3]; /* number of huffman codes in each region */
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
72 int preflag;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
73 int short_start, long_end; /* long/short band indexes */
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
74 uint8_t scale_factors[40];
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
75 int32_t sb_hybrid[SBLIMIT * 18]; /* 576 samples */
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
76 } GranuleDef;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
77
5031
70f194a2ee53 move some common mpeg audio tables from mpegaudiodectab.h to mpegaudiodata.c
aurel
parents: 5009
diff changeset
78 #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
79 #include "mpegaudiodectab.h"
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
80
1733
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
81 static void compute_antialias_integer(MPADecodeContext *s, GranuleDef *g);
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
82 static void compute_antialias_float(MPADecodeContext *s, GranuleDef *g);
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
83
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
84 /* vlc structure for decoding layer 3 huffman tables */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
85 static VLC huff_vlc[16];
7452
2240c6340eac Use static vlc structure to decode layer 3 huffman tables.
benoit
parents: 7330
diff changeset
86 static VLC_TYPE huff_vlc_tables[
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 ][2];
2240c6340eac Use static vlc structure to decode layer 3 huffman tables.
benoit
parents: 7330
diff changeset
90 static const int huff_vlc_tables_sizes[16] = {
2240c6340eac Use static vlc structure to decode layer 3 huffman tables.
benoit
parents: 7330
diff changeset
91 0, 128, 128, 128, 130, 128, 154, 166,
2240c6340eac Use static vlc structure to decode layer 3 huffman tables.
benoit
parents: 7330
diff changeset
92 142, 204, 190, 170, 542, 460, 662, 414
2240c6340eac Use static vlc structure to decode layer 3 huffman tables.
benoit
parents: 7330
diff changeset
93 };
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
94 static VLC huff_quad_vlc[2];
7452
2240c6340eac Use static vlc structure to decode layer 3 huffman tables.
benoit
parents: 7330
diff changeset
95 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
96 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
97 128, 16
2240c6340eac Use static vlc structure to decode layer 3 huffman tables.
benoit
parents: 7330
diff changeset
98 };
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
99 /* computed from band_size_long */
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
100 static uint16_t band_index_long[9][23];
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
101 /* XXX: free when all decoders are closed */
2490
c2c642ad6ef4 faster, simpler and more accurate l3_unscale()
michael
parents: 2489
diff changeset
102 #define TABLE_4_3_SIZE (8191 + 16)*4
4662
36c100bb7758 kill another 2 av_mallocz_static()
michael
parents: 4652
diff changeset
103 static int8_t table_4_3_exp[TABLE_4_3_SIZE];
36c100bb7758 kill another 2 av_mallocz_static()
michael
parents: 4652
diff changeset
104 static uint32_t table_4_3_value[TABLE_4_3_SIZE];
3621
d4896ea0305b replace l3_unscale(1, exponents[pos]) by LUT
michael
parents: 3620
diff changeset
105 static uint32_t exp_table[512];
3622
e88a3910f855 try to avoid l3_unscale() by using a table
michael
parents: 3621
diff changeset
106 static uint32_t expval_table[512][16];
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
107 /* intensity stereo coef table */
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
108 static int32_t is_table[2][16];
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
109 static int32_t is_table_lsf[2][2][16];
1733
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
110 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
111 static float csa_table_float[8][4];
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
112 static int32_t mdct_win[8][36];
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
113
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
114 /* lower 2 bits: modulo 3, higher bits: shift */
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
115 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
116 /* [i][j]: 2^(-j/3) * FRAC_ONE * 2^(i+2) / (2^(i+2) - 1) */
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
117 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
118 /* 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
119
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
120 #define SCALE_GEN(v) \
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
121 { FIXR(1.0 * (v)), FIXR(0.7937005259 * (v)), FIXR(0.6299605249 * (v)) }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
122
2753
ba8ecddf5598 adding a few const
michael
parents: 2647
diff changeset
123 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
124 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
125 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
126 SCALE_GEN(4.0 / 9.0), /* 9 steps */
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
127 };
986e461dc072 Initial revision
glantau
parents:
diff changeset
128
5009
4d10df33e823 Use DECLARE_ALIGNED to ease porting
reimar
parents: 4908
diff changeset
129 static DECLARE_ALIGNED_16(MPA_INT, window[512]);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
130
6138
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
131 /**
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
132 * 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
133 * size to big_values.
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
134 */
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
135 void ff_region_offset2size(GranuleDef *g){
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
136 int i, k, j=0;
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
137 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
138 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
139 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
140 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
141 j = k;
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 }
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
144
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
145 void ff_init_short_region(MPADecodeContext *s, GranuleDef *g){
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
146 if (g->block_type == 2)
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
147 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
148 else {
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
149 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
150 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
151 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
152 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
153 else
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
154 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
155 }
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
156 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
157 }
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
158
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
159 void ff_init_long_region(MPADecodeContext *s, GranuleDef *g, int ra1, int ra2){
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
160 int l;
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
161 g->region_size[0] =
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
162 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
163 /* should not overflow */
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
164 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
165 g->region_size[1] =
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
166 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
167 }
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
168
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
169 void ff_compute_band_indexes(MPADecodeContext *s, GranuleDef *g){
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
170 if (g->block_type == 2) {
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
171 if (g->switch_point) {
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
172 /* 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
173 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
174 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
175 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
176 g->long_end = 8;
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
177 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
178 g->long_end = 6;
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
179 else
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
180 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
181
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
182 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
183 } else {
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
184 g->long_end = 0;
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
185 g->short_start = 0;
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
186 }
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
187 } else {
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
188 g->short_start = 13;
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
189 g->long_end = 22;
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 }
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
192
82
46ee548e47e4 added 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 /* 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
194 /* 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
195 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
196 {
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
197 int shift, mod;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
198 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
199
46ee548e47e4 added 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 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
201 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
202 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
203 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
204 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
205 /* 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
206 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
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
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
209 static inline int 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
210 {
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
211 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
212
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
213 shift = 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
214 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
215 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
216
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 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
218 /* 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
219 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
220 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
221 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
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
46ee548e47e4 added 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 /* 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
225 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
226 {
46ee548e47e4 added 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 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
228 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
229
2490
c2c642ad6ef4 faster, simpler and more accurate l3_unscale()
michael
parents: 2489
diff changeset
230 e = table_4_3_exp [4*value + (exponent&3)];
c2c642ad6ef4 faster, simpler and more accurate l3_unscale()
michael
parents: 2489
diff changeset
231 m = table_4_3_value[4*value + (exponent&3)];
c2c642ad6ef4 faster, simpler and more accurate l3_unscale()
michael
parents: 2489
diff changeset
232 e -= (exponent >> 2);
c2c642ad6ef4 faster, simpler and more accurate l3_unscale()
michael
parents: 2489
diff changeset
233 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
234 if (e > 31)
2478
6744ea5ff950 more accurate dequant of near zero coefficients
michael
parents: 2477
diff changeset
235 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
236 m = (m + (1 << (e-1))) >> e;
2490
c2c642ad6ef4 faster, simpler and more accurate l3_unscale()
michael
parents: 2489
diff changeset
237
82
46ee548e47e4 added 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 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
239 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
240
392
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
241 /* 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
242 #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
243
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_BITS 24
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
245 #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
246 #define POW_FIX(a) ((int)((a) * POW_FRAC_ONE))
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
247 #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
248
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
249 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
250
2522
e25782262d7d kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents: 2507
diff changeset
251 #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
252 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
253 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
254 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
255 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
256 };
2522
e25782262d7d kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents: 2507
diff changeset
257 #endif
392
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
258
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
259 static void int_pow_init(void)
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
260 {
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
261 int i, a;
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
262
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
263 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
264 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
265 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
266 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
267 }
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
268 }
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
269
2522
e25782262d7d kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents: 2507
diff changeset
270 #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
271 /* 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
272 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
273 {
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
274 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
275 int a, a1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
276
392
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
277 /* renormalize */
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
278 a = i;
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
279 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
280 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
281 a = a << 1;
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
282 e--;
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
283 }
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
284 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
285 a1 = 0;
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
286 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
287 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
288 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
289 /* exponent compute (exact) */
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
290 e = e * 4;
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
291 er = e % 3;
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
292 eq = e / 3;
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
293 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
294 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
295 a = a >> 1;
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
296 eq++;
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
297 }
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
298 /* convert to float */
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
299 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
300 a = a << 1;
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
301 eq--;
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
302 }
407
c3aebacf546e fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents: 404
diff changeset
303 /* 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
304 #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
305 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
306 /* correct overflow */
c3aebacf546e fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents: 404
diff changeset
307 if (a >= 2 * (1 << FRAC_BITS)) {
c3aebacf546e fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents: 404
diff changeset
308 a = a >> 1;
c3aebacf546e fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents: 404
diff changeset
309 eq++;
c3aebacf546e fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents: 404
diff changeset
310 }
c3aebacf546e fixed incorrect global gain - slightly increased precision of n^(4/3) table
glantau
parents: 404
diff changeset
311 #endif
392
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
312 *exp_ptr = eq;
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
313 return a;
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
314 }
2522
e25782262d7d kill warnings patch by (M«©ns Rullg«©rd <mru inprovide com>)
michael
parents: 2507
diff changeset
315 #endif
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
316
986e461dc072 Initial revision
glantau
parents:
diff changeset
317 static int decode_init(AVCodecContext * avctx)
986e461dc072 Initial revision
glantau
parents:
diff changeset
318 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
319 MPADecodeContext *s = avctx->priv_data;
836
932eb34d17c1 vc++ sucks, found by ("csharprules" <csharprules at hotmail dot com>)
michaelni
parents: 602
diff changeset
320 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
321 int i, j, k;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
322
4652
6679d37a3338 Give context to dprintf
mbardiaux
parents: 4469
diff changeset
323 s->avctx = avctx;
6679d37a3338 Give context to dprintf
mbardiaux
parents: 4469
diff changeset
324
2911
7f2959d05900 Reverse patch 1.59->1.60, it break mp3 in ffplay and ffmpeg
rtognimp
parents: 2903
diff changeset
325 #if defined(USE_HIGHPRECISION) && defined(CONFIG_AUDIO_NONSHORT)
2479
dfdb6bf4b90f support 32bit output for the mpeg audio decoder
michael
parents: 2478
diff changeset
326 avctx->sample_fmt= SAMPLE_FMT_S32;
dfdb6bf4b90f support 32bit output for the mpeg audio decoder
michael
parents: 2478
diff changeset
327 #else
dfdb6bf4b90f support 32bit output for the mpeg audio decoder
michael
parents: 2478
diff changeset
328 avctx->sample_fmt= SAMPLE_FMT_S16;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
329 #endif
7831
8195c970d077 Rename error_resilience to error_recognition.
michael
parents: 7763
diff changeset
330 s->error_recognition= avctx->error_recognition;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
331
2491
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
332 if(avctx->antialias_algo != FF_AA_FLOAT)
1762
michael
parents: 1734
diff changeset
333 s->compute_antialias= compute_antialias_integer;
michael
parents: 1734
diff changeset
334 else
michael
parents: 1734
diff changeset
335 s->compute_antialias= compute_antialias_float;
michael
parents: 1734
diff changeset
336
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
337 if (!init && !avctx->parse_only) {
7452
2240c6340eac Use static vlc structure to decode layer 3 huffman tables.
benoit
parents: 7330
diff changeset
338 int offset;
2240c6340eac Use static vlc structure to decode layer 3 huffman tables.
benoit
parents: 7330
diff changeset
339
82
46ee548e47e4 added 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 /* 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
341 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
342 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
343 /* 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
344 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
345 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
346 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
347 }
46ee548e47e4 added 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
46ee548e47e4 added 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 /* 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
350 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
351 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
352 n = i + 2;
4274
07625477adfa use the standard INT64_C() macro for 64-bit constants
mru
parents: 4205
diff changeset
353 norm = ((INT64_C(1) << n) * FRAC_ONE) / ((1 << n) - 1);
8201
c6e2ffef3797 Add shift argument to MULL() macro
mru
parents: 8042
diff changeset
354 scale_factor_mult[i][0] = MULL(FIXR(1.0 * 2.0), norm, FRAC_BITS);
c6e2ffef3797 Add shift argument to MULL() macro
mru
parents: 8042
diff changeset
355 scale_factor_mult[i][1] = MULL(FIXR(0.7937005259 * 2.0), norm, FRAC_BITS);
c6e2ffef3797 Add shift argument to MULL() macro
mru
parents: 8042
diff changeset
356 scale_factor_mult[i][2] = MULL(FIXR(0.6299605249 * 2.0), norm, FRAC_BITS);
4652
6679d37a3338 Give context to dprintf
mbardiaux
parents: 4469
diff changeset
357 dprintf(avctx, "%d: norm=%x s=%x %x %x\n",
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
358 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
359 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
360 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
361 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
362 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
363
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
364 ff_mpa_synth_init(window);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
365
82
46ee548e47e4 added 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 /* huffman decode tables */
7452
2240c6340eac Use static vlc structure to decode layer 3 huffman tables.
benoit
parents: 7330
diff changeset
367 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
368 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
369 const HuffTable *h = &mpa_huff_tables[i];
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
370 int xsize, x, y;
1057
bb5de8a59da8 * static,const,compiler warning cleanup
kabi
parents: 1025
diff changeset
371 unsigned int n;
3627
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
372 uint8_t tmp_bits [512];
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
373 uint16_t tmp_codes[512];
3608
f713d34d5d01 simplify
michael
parents: 3607
diff changeset
374
f713d34d5d01 simplify
michael
parents: 3607
diff changeset
375 memset(tmp_bits , 0, sizeof(tmp_bits ));
f713d34d5d01 simplify
michael
parents: 3607
diff changeset
376 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
377
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
378 xsize = h->xsize;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
379 n = xsize * xsize;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
380
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
381 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
382 for(x=0;x<xsize;x++) {
3608
f713d34d5d01 simplify
michael
parents: 3607
diff changeset
383 for(y=0;y<xsize;y++){
3627
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
384 tmp_bits [(x << 5) | y | ((x&&y)<<4)]= h->bits [j ];
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
385 tmp_codes[(x << 5) | y | ((x&&y)<<4)]= h->codes[j++];
3608
f713d34d5d01 simplify
michael
parents: 3607
diff changeset
386 }
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
387 }
3608
f713d34d5d01 simplify
michael
parents: 3607
diff changeset
388
f713d34d5d01 simplify
michael
parents: 3607
diff changeset
389 /* XXX: fail test */
7452
2240c6340eac Use static vlc structure to decode layer 3 huffman tables.
benoit
parents: 7330
diff changeset
390 huff_vlc[i].table = huff_vlc_tables+offset;
2240c6340eac Use static vlc structure to decode layer 3 huffman tables.
benoit
parents: 7330
diff changeset
391 huff_vlc[i].table_allocated = huff_vlc_tables_sizes[i];
3627
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
392 init_vlc(&huff_vlc[i], 7, 512,
7452
2240c6340eac Use static vlc structure to decode layer 3 huffman tables.
benoit
parents: 7330
diff changeset
393 tmp_bits, 1, 1, tmp_codes, 2, 2,
2240c6340eac Use static vlc structure to decode layer 3 huffman tables.
benoit
parents: 7330
diff changeset
394 INIT_VLC_USE_NEW_STATIC);
2240c6340eac Use static vlc structure to decode layer 3 huffman tables.
benoit
parents: 7330
diff changeset
395 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
396 }
8042
e70975d5ff80 uses FF_ARRAY_ELEMS() where appropriate
aurel
parents: 7870
diff changeset
397 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
398
2240c6340eac Use static vlc structure to decode layer 3 huffman tables.
benoit
parents: 7330
diff changeset
399 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
400 for(i=0;i<2;i++) {
7452
2240c6340eac Use static vlc structure to decode layer 3 huffman tables.
benoit
parents: 7330
diff changeset
401 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
402 huff_quad_vlc[i].table_allocated = huff_quad_vlc_tables_sizes[i];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
403 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
404 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
405 INIT_VLC_USE_NEW_STATIC);
2240c6340eac Use static vlc structure to decode layer 3 huffman tables.
benoit
parents: 7330
diff changeset
406 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
407 }
8042
e70975d5ff80 uses FF_ARRAY_ELEMS() where appropriate
aurel
parents: 7870
diff changeset
408 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
409
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
410 for(i=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
411 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
412 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
413 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
414 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
415 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
416 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
417 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
418
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
419 /* compute n ^ (4/3) and store it in mantissa/exp format */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
420
392
4ef26ed29399 put all integer init code to compute n^(4/3) - memory alloc and header fixes
glantau
parents: 322
diff changeset
421 int_pow_init();
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
422 for(i=1;i<TABLE_4_3_SIZE;i++) {
2490
c2c642ad6ef4 faster, simpler and more accurate l3_unscale()
michael
parents: 2489
diff changeset
423 double f, fm;
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
424 int e, m;
2490
c2c642ad6ef4 faster, simpler and more accurate l3_unscale()
michael
parents: 2489
diff changeset
425 f = pow((double)(i/4), 4.0 / 3.0) * pow(2, (i&3)*0.25);
c2c642ad6ef4 faster, simpler and more accurate l3_unscale()
michael
parents: 2489
diff changeset
426 fm = frexp(f, &e);
2532
b7511e7dabb7 cast to uint32 as the table is uint32_t, this also worksaround a gcc or libc bug related to frexp()
michael
parents: 2522
diff changeset
427 m = (uint32_t)(fm*(1LL<<31) + 0.5);
3625
8042fcb3a62a move the +400 out of the innermost loop
michael
parents: 3624
diff changeset
428 e+= FRAC_BITS - 31 + 5 - 100;
2490
c2c642ad6ef4 faster, simpler and more accurate l3_unscale()
michael
parents: 2489
diff changeset
429
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
430 /* 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
431 table_4_3_value[i] = m;
2490
c2c642ad6ef4 faster, simpler and more accurate l3_unscale()
michael
parents: 2489
diff changeset
432 table_4_3_exp[i] = -e;
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
433 }
3622
e88a3910f855 try to avoid l3_unscale() by using a table
michael
parents: 3621
diff changeset
434 for(i=0; i<512*16; i++){
3625
8042fcb3a62a move the +400 out of the innermost loop
michael
parents: 3624
diff changeset
435 int exponent= (i>>4);
8042fcb3a62a move the +400 out of the innermost loop
michael
parents: 3624
diff changeset
436 double f= pow(i&15, 4.0 / 3.0) * pow(2, (exponent-400)*0.25 + FRAC_BITS + 5);
3732
2c0b93338765 use correct rounding functions
michael
parents: 3722
diff changeset
437 expval_table[exponent][i&15]= llrint(f);
3622
e88a3910f855 try to avoid l3_unscale() by using a table
michael
parents: 3621
diff changeset
438 if((i&15)==1)
3732
2c0b93338765 use correct rounding functions
michael
parents: 3722
diff changeset
439 exp_table[exponent]= llrint(f);
3621
d4896ea0305b replace l3_unscale(1, exponents[pos]) by LUT
michael
parents: 3620
diff changeset
440 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
441
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
442 for(i=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
443 float f;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
444 int v;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
445 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
446 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
447 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
448 } 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
449 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
450 }
46ee548e47e4 added 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 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
452 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
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 /* 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
455 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
456 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
457
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
458 for(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
459 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
460 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
461
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
462 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
463 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
464 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
465 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
466 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
467 is_table_lsf[j][k][i] = FIXR(1.0);
4652
6679d37a3338 Give context to dprintf
mbardiaux
parents: 4469
diff changeset
468 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
469 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
470 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
471 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
472
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
473 for(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
474 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
475 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
476 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
477 ca = cs * ci;
2491
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
478 csa_table[i][0] = FIXHR(cs/4);
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
479 csa_table[i][1] = FIXHR(ca/4);
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
480 csa_table[i][2] = FIXHR(ca/4) + FIXHR(cs/4);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
481 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
482 csa_table_float[i][0] = cs;
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
483 csa_table_float[i][1] = ca;
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
484 csa_table_float[i][2] = ca + cs;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
485 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
486 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
487
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
488 /* 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
489 for(i=0;i<36;i++) {
2489
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
490 for(j=0; j<4; j++){
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
491 double d;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
492
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
493 if(j==2 && i%3 != 1)
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
494 continue;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
495
2489
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
496 d= sin(M_PI * (i + 0.5) / 36.0);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
497 if(j==1){
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
498 if (i>=30) d= 0;
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
499 else if(i>=24) d= sin(M_PI * (i - 18 + 0.5) / 12.0);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
500 else if(i>=18) d= 1;
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
501 }else if(j==3){
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
502 if (i< 6) d= 0;
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
503 else if(i< 12) d= sin(M_PI * (i - 6 + 0.5) / 12.0);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
504 else if(i< 18) d= 1;
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
505 }
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
506 //merge last stage of imdct into the window coefficients
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
507 d*= 0.5 / cos(M_PI*(2*i + 19)/72);
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
508
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
509 if(j==2)
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
510 mdct_win[j][i/3] = FIXHR((d / (1<<5)));
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
511 else
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
512 mdct_win[j][i ] = FIXHR((d / (1<<5)));
2489
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
513 }
82
46ee548e47e4 added 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 /* 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
517 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
518 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
519 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
520 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
521 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
522 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
523 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
524
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
525 init = 1;
986e461dc072 Initial revision
glantau
parents:
diff changeset
526 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
527
2432
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
528 if (avctx->codec_id == CODEC_ID_MP3ADU)
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
529 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
530 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
531 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
532
1014
48349e11c9b2 C99 initializers and kill warnings patch by (mru at users dot sourceforge dot net (M«©ns Rullg«©rd))
michaelni
parents: 902
diff changeset
533 /* tab[i][j] = 1.0 / (2.0 * cos(pi*(2*k+1) / 2^(6 - j))) */
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
534
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
535 /* cos(i*pi/64) */
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
536
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
537 #define COS0_0 FIXHR(0.50060299823519630134/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
538 #define COS0_1 FIXHR(0.50547095989754365998/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
539 #define COS0_2 FIXHR(0.51544730992262454697/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
540 #define COS0_3 FIXHR(0.53104259108978417447/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
541 #define COS0_4 FIXHR(0.55310389603444452782/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
542 #define COS0_5 FIXHR(0.58293496820613387367/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
543 #define COS0_6 FIXHR(0.62250412303566481615/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
544 #define COS0_7 FIXHR(0.67480834145500574602/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
545 #define COS0_8 FIXHR(0.74453627100229844977/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
546 #define COS0_9 FIXHR(0.83934964541552703873/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
547 #define COS0_10 FIXHR(0.97256823786196069369/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
548 #define COS0_11 FIXHR(1.16943993343288495515/4)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
549 #define COS0_12 FIXHR(1.48416461631416627724/4)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
550 #define COS0_13 FIXHR(2.05778100995341155085/8)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
551 #define COS0_14 FIXHR(3.40760841846871878570/8)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
552 #define COS0_15 FIXHR(10.19000812354805681150/32)
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
553
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
554 #define COS1_0 FIXHR(0.50241928618815570551/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
555 #define COS1_1 FIXHR(0.52249861493968888062/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
556 #define COS1_2 FIXHR(0.56694403481635770368/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
557 #define COS1_3 FIXHR(0.64682178335999012954/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
558 #define COS1_4 FIXHR(0.78815462345125022473/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
559 #define COS1_5 FIXHR(1.06067768599034747134/4)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
560 #define COS1_6 FIXHR(1.72244709823833392782/4)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
561 #define COS1_7 FIXHR(5.10114861868916385802/16)
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
562
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
563 #define COS2_0 FIXHR(0.50979557910415916894/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
564 #define COS2_1 FIXHR(0.60134488693504528054/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
565 #define COS2_2 FIXHR(0.89997622313641570463/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
566 #define COS2_3 FIXHR(2.56291544774150617881/8)
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
567
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
568 #define COS3_0 FIXHR(0.54119610014619698439/2)
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
569 #define COS3_1 FIXHR(1.30656296487637652785/4)
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
570
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
571 #define COS4_0 FIXHR(0.70710678118654752439/2)
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
572
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
573 /* butterfly operator */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
574 #define BF(a, b, c, s)\
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
575 {\
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
576 tmp0 = tab[a] + tab[b];\
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
577 tmp1 = tab[a] - tab[b];\
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
578 tab[a] = tmp0;\
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
579 tab[b] = MULH(tmp1<<(s), c);\
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
580 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
581
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
582 #define BF1(a, b, c, d)\
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
583 {\
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
584 BF(a, b, COS4_0, 1);\
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
585 BF(c, d,-COS4_0, 1);\
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
586 tab[c] += tab[d];\
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
587 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
588
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
589 #define BF2(a, b, c, d)\
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
590 {\
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
591 BF(a, b, COS4_0, 1);\
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
592 BF(c, d,-COS4_0, 1);\
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
593 tab[c] += tab[d];\
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
594 tab[a] += tab[c];\
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
595 tab[c] += tab[b];\
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
596 tab[b] += tab[d];\
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
597 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
598
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
599 #define ADD(a, b) tab[a] += tab[b]
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
600
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
601 /* DCT32 without 1/sqrt(2) coef zero scaling. */
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
602 static void dct32(int32_t *out, int32_t *tab)
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
603 {
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
604 int tmp0, tmp1;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
605
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
606 /* pass 1 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
607 BF( 0, 31, COS0_0 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
608 BF(15, 16, COS0_15, 5);
3598
181b0e8f6d81 reorder butterflies to reduce memory load/store
michael
parents: 3431
diff changeset
609 /* pass 2 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
610 BF( 0, 15, COS1_0 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
611 BF(16, 31,-COS1_0 , 1);
3598
181b0e8f6d81 reorder butterflies to reduce memory load/store
michael
parents: 3431
diff changeset
612 /* pass 1 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
613 BF( 7, 24, COS0_7 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
614 BF( 8, 23, COS0_8 , 1);
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
615 /* pass 2 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
616 BF( 7, 8, COS1_7 , 4);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
617 BF(23, 24,-COS1_7 , 4);
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
618 /* pass 3 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
619 BF( 0, 7, COS2_0 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
620 BF( 8, 15,-COS2_0 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
621 BF(16, 23, COS2_0 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
622 BF(24, 31,-COS2_0 , 1);
3598
181b0e8f6d81 reorder butterflies to reduce memory load/store
michael
parents: 3431
diff changeset
623 /* pass 1 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
624 BF( 3, 28, COS0_3 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
625 BF(12, 19, COS0_12, 2);
3598
181b0e8f6d81 reorder butterflies to reduce memory load/store
michael
parents: 3431
diff changeset
626 /* pass 2 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
627 BF( 3, 12, COS1_3 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
628 BF(19, 28,-COS1_3 , 1);
3598
181b0e8f6d81 reorder butterflies to reduce memory load/store
michael
parents: 3431
diff changeset
629 /* pass 1 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
630 BF( 4, 27, COS0_4 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
631 BF(11, 20, COS0_11, 2);
3598
181b0e8f6d81 reorder butterflies to reduce memory load/store
michael
parents: 3431
diff changeset
632 /* pass 2 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
633 BF( 4, 11, COS1_4 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
634 BF(20, 27,-COS1_4 , 1);
3598
181b0e8f6d81 reorder butterflies to reduce memory load/store
michael
parents: 3431
diff changeset
635 /* pass 3 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
636 BF( 3, 4, COS2_3 , 3);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
637 BF(11, 12,-COS2_3 , 3);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
638 BF(19, 20, COS2_3 , 3);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
639 BF(27, 28,-COS2_3 , 3);
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
640 /* pass 4 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
641 BF( 0, 3, COS3_0 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
642 BF( 4, 7,-COS3_0 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
643 BF( 8, 11, COS3_0 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
644 BF(12, 15,-COS3_0 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
645 BF(16, 19, COS3_0 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
646 BF(20, 23,-COS3_0 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
647 BF(24, 27, COS3_0 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
648 BF(28, 31,-COS3_0 , 1);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
649
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
650
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
651
3598
181b0e8f6d81 reorder butterflies to reduce memory load/store
michael
parents: 3431
diff changeset
652 /* pass 1 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
653 BF( 1, 30, COS0_1 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
654 BF(14, 17, COS0_14, 3);
3598
181b0e8f6d81 reorder butterflies to reduce memory load/store
michael
parents: 3431
diff changeset
655 /* pass 2 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
656 BF( 1, 14, COS1_1 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
657 BF(17, 30,-COS1_1 , 1);
3598
181b0e8f6d81 reorder butterflies to reduce memory load/store
michael
parents: 3431
diff changeset
658 /* pass 1 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
659 BF( 6, 25, COS0_6 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
660 BF( 9, 22, COS0_9 , 1);
3598
181b0e8f6d81 reorder butterflies to reduce memory load/store
michael
parents: 3431
diff changeset
661 /* pass 2 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
662 BF( 6, 9, COS1_6 , 2);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
663 BF(22, 25,-COS1_6 , 2);
3598
181b0e8f6d81 reorder butterflies to reduce memory load/store
michael
parents: 3431
diff changeset
664 /* pass 3 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
665 BF( 1, 6, COS2_1 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
666 BF( 9, 14,-COS2_1 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
667 BF(17, 22, COS2_1 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
668 BF(25, 30,-COS2_1 , 1);
3598
181b0e8f6d81 reorder butterflies to reduce memory load/store
michael
parents: 3431
diff changeset
669
181b0e8f6d81 reorder butterflies to reduce memory load/store
michael
parents: 3431
diff changeset
670 /* pass 1 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
671 BF( 2, 29, COS0_2 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
672 BF(13, 18, COS0_13, 3);
3598
181b0e8f6d81 reorder butterflies to reduce memory load/store
michael
parents: 3431
diff changeset
673 /* pass 2 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
674 BF( 2, 13, COS1_2 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
675 BF(18, 29,-COS1_2 , 1);
3598
181b0e8f6d81 reorder butterflies to reduce memory load/store
michael
parents: 3431
diff changeset
676 /* pass 1 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
677 BF( 5, 26, COS0_5 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
678 BF(10, 21, COS0_10, 1);
3598
181b0e8f6d81 reorder butterflies to reduce memory load/store
michael
parents: 3431
diff changeset
679 /* pass 2 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
680 BF( 5, 10, COS1_5 , 2);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
681 BF(21, 26,-COS1_5 , 2);
3598
181b0e8f6d81 reorder butterflies to reduce memory load/store
michael
parents: 3431
diff changeset
682 /* pass 3 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
683 BF( 2, 5, COS2_2 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
684 BF(10, 13,-COS2_2 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
685 BF(18, 21, COS2_2 , 1);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
686 BF(26, 29,-COS2_2 , 1);
3598
181b0e8f6d81 reorder butterflies to reduce memory load/store
michael
parents: 3431
diff changeset
687 /* pass 4 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
688 BF( 1, 2, COS3_1 , 2);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
689 BF( 5, 6,-COS3_1 , 2);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
690 BF( 9, 10, COS3_1 , 2);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
691 BF(13, 14,-COS3_1 , 2);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
692 BF(17, 18, COS3_1 , 2);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
693 BF(21, 22,-COS3_1 , 2);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
694 BF(25, 26, COS3_1 , 2);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
695 BF(29, 30,-COS3_1 , 2);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
696
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
697 /* pass 5 */
3600
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
698 BF1( 0, 1, 2, 3);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
699 BF2( 4, 5, 6, 7);
949219039897 replace MULL by MULH + shift in dct32() (code is very slightly faster, and the compiler should be able to optimize the shift away on 64bit archs)
michael
parents: 3599
diff changeset
700 BF1( 8, 9, 10, 11);
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
701 BF2(12, 13, 14, 15);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
702 BF1(16, 17, 18, 19);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
703 BF2(20, 21, 22, 23);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
704 BF1(24, 25, 26, 27);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
705 BF2(28, 29, 30, 31);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
706
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
707 /* pass 6 */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
708
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
709 ADD( 8, 12);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
710 ADD(12, 10);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
711 ADD(10, 14);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
712 ADD(14, 9);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
713 ADD( 9, 13);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
714 ADD(13, 11);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
715 ADD(11, 15);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
716
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
717 out[ 0] = tab[0];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
718 out[16] = tab[1];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
719 out[ 8] = tab[2];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
720 out[24] = tab[3];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
721 out[ 4] = tab[4];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
722 out[20] = tab[5];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
723 out[12] = tab[6];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
724 out[28] = tab[7];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
725 out[ 2] = tab[8];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
726 out[18] = tab[9];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
727 out[10] = tab[10];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
728 out[26] = tab[11];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
729 out[ 6] = tab[12];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
730 out[22] = tab[13];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
731 out[14] = tab[14];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
732 out[30] = tab[15];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
733
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
734 ADD(24, 28);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
735 ADD(28, 26);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
736 ADD(26, 30);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
737 ADD(30, 25);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
738 ADD(25, 29);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
739 ADD(29, 27);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
740 ADD(27, 31);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
741
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
742 out[ 1] = tab[16] + tab[24];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
743 out[17] = tab[17] + tab[25];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
744 out[ 9] = tab[18] + tab[26];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
745 out[25] = tab[19] + tab[27];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
746 out[ 5] = tab[20] + tab[28];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
747 out[21] = tab[21] + tab[29];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
748 out[13] = tab[22] + tab[30];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
749 out[29] = tab[23] + tab[31];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
750 out[ 3] = tab[24] + tab[20];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
751 out[19] = tab[25] + tab[21];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
752 out[11] = tab[26] + tab[22];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
753 out[27] = tab[27] + tab[23];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
754 out[ 7] = tab[28] + tab[18];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
755 out[23] = tab[29] + tab[19];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
756 out[15] = tab[30] + tab[17];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
757 out[31] = tab[31];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
758 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
759
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
760 #if FRAC_BITS <= 15
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
761
2472
021dc26e760f dithering for the mpeg audio decoder
michael
parents: 2468
diff changeset
762 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
763 {
aece5836c588 fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents: 1414
diff changeset
764 int sum1;
2472
021dc26e760f dithering for the mpeg audio decoder
michael
parents: 2468
diff changeset
765 sum1 = (*sum) >> OUT_SHIFT;
021dc26e760f dithering for the mpeg audio decoder
michael
parents: 2468
diff changeset
766 *sum &= (1<<OUT_SHIFT)-1;
2479
dfdb6bf4b90f support 32bit output for the mpeg audio decoder
michael
parents: 2478
diff changeset
767 if (sum1 < OUT_MIN)
dfdb6bf4b90f support 32bit output for the mpeg audio decoder
michael
parents: 2478
diff changeset
768 sum1 = OUT_MIN;
dfdb6bf4b90f support 32bit output for the mpeg audio decoder
michael
parents: 2478
diff changeset
769 else if (sum1 > OUT_MAX)
dfdb6bf4b90f support 32bit output for the mpeg audio decoder
michael
parents: 2478
diff changeset
770 sum1 = OUT_MAX;
1428
aece5836c588 fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents: 1414
diff changeset
771 return sum1;
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
772 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
773
3752
32b2da1060ea Use mathops
lu_zero
parents: 3732
diff changeset
774 /* signed 16x16 -> 32 multiply add accumulate */
32b2da1060ea Use mathops
lu_zero
parents: 3732
diff changeset
775 #define MACS(rt, ra, rb) MAC16(rt, ra, rb)
3705
b3149af07681 armv5 optimizations
diego
parents: 3687
diff changeset
776
3752
32b2da1060ea Use mathops
lu_zero
parents: 3732
diff changeset
777 /* signed 16x16 -> 32 multiply */
32b2da1060ea Use mathops
lu_zero
parents: 3732
diff changeset
778 #define MULS(ra, rb) MUL16(ra, rb)
3705
b3149af07681 armv5 optimizations
diego
parents: 3687
diff changeset
779
7256
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
780 #define MLSS(rt, ra, rb) MLS16(rt, ra, rb)
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
781
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
782 #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
783
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
784 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
785 {
aece5836c588 fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents: 1414
diff changeset
786 int sum1;
2472
021dc26e760f dithering for the mpeg audio decoder
michael
parents: 2468
diff changeset
787 sum1 = (int)((*sum) >> OUT_SHIFT);
021dc26e760f dithering for the mpeg audio decoder
michael
parents: 2468
diff changeset
788 *sum &= (1<<OUT_SHIFT)-1;
2479
dfdb6bf4b90f support 32bit output for the mpeg audio decoder
michael
parents: 2478
diff changeset
789 if (sum1 < OUT_MIN)
dfdb6bf4b90f support 32bit output for the mpeg audio decoder
michael
parents: 2478
diff changeset
790 sum1 = OUT_MIN;
dfdb6bf4b90f support 32bit output for the mpeg audio decoder
michael
parents: 2478
diff changeset
791 else if (sum1 > OUT_MAX)
dfdb6bf4b90f support 32bit output for the mpeg audio decoder
michael
parents: 2478
diff changeset
792 sum1 = OUT_MAX;
1428
aece5836c588 fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents: 1414
diff changeset
793 return sum1;
aece5836c588 fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents: 1414
diff changeset
794 }
aece5836c588 fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents: 1414
diff changeset
795
3603
42b6cefc6c1a replacing MULH by asm for x86
michael
parents: 3602
diff changeset
796 # define MULS(ra, rb) MUL64(ra, rb)
7256
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
797 # define MACS(rt, ra, rb) MAC64(rt, ra, rb)
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
798 # 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
799 #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
800
7256
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
801 #define SUM8(op, sum, w, p) \
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
802 { \
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
803 op(sum, (w)[0 * 64], p[0 * 64]); \
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
804 op(sum, (w)[1 * 64], p[1 * 64]); \
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
805 op(sum, (w)[2 * 64], p[2 * 64]); \
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
806 op(sum, (w)[3 * 64], p[3 * 64]); \
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
807 op(sum, (w)[4 * 64], p[4 * 64]); \
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
808 op(sum, (w)[5 * 64], p[5 * 64]); \
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
809 op(sum, (w)[6 * 64], p[6 * 64]); \
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
810 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
811 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
812
1428
aece5836c588 fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents: 1414
diff changeset
813 #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
814 { \
1428
aece5836c588 fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents: 1414
diff changeset
815 int tmp;\
aece5836c588 fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents: 1414
diff changeset
816 tmp = p[0 * 64];\
7256
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
817 op1(sum1, (w1)[0 * 64], tmp);\
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
818 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
819 tmp = p[1 * 64];\
7256
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
820 op1(sum1, (w1)[1 * 64], tmp);\
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
821 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
822 tmp = p[2 * 64];\
7256
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
823 op1(sum1, (w1)[2 * 64], tmp);\
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
824 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
825 tmp = p[3 * 64];\
7256
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
826 op1(sum1, (w1)[3 * 64], tmp);\
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
827 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
828 tmp = p[4 * 64];\
7256
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
829 op1(sum1, (w1)[4 * 64], tmp);\
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
830 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
831 tmp = p[5 * 64];\
7256
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
832 op1(sum1, (w1)[5 * 64], tmp);\
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
833 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
834 tmp = p[6 * 64];\
7256
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
835 op1(sum1, (w1)[6 * 64], tmp);\
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
836 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
837 tmp = p[7 * 64];\
7256
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
838 op1(sum1, (w1)[7 * 64], tmp);\
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
839 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
840 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
841
2468
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
842 void ff_mpa_synth_init(MPA_INT *window)
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
843 {
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
844 int i;
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
845
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
846 /* max = 18760, max sum over all 16 coefs : 44736 */
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
847 for(i=0;i<257;i++) {
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
848 int v;
5032
d47ee2d1d7da add proper prefix to extern mpeg audio data tables
aurel
parents: 5031
diff changeset
849 v = ff_mpa_enwindow[i];
2468
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
850 #if WFRAC_BITS < 16
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
851 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
852 #endif
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
853 window[i] = v;
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
854 if ((i & 63) != 0)
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
855 v = -v;
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
856 if (i != 0)
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
857 window[512 - i] = v;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
858 }
2468
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
859 }
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
860
46ee548e47e4 added 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 /* 32 sub band synthesis filter. Input: 32 sub band samples, Output:
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
862 32 samples. */
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
863 /* XXX: optimize by avoiding ring buffer usage */
2468
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
864 void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
865 MPA_INT *window, int *dither_state,
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
866 OUT_INT *samples, int incr,
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
867 int32_t sb_samples[SBLIMIT])
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
868 {
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
869 int32_t tmp[32];
1428
aece5836c588 fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents: 1414
diff changeset
870 register MPA_INT *synth_buf;
2100
8bf89660fffe warning fix
alex
parents: 2028
diff changeset
871 register const MPA_INT *w, *w2, *p;
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
872 int j, offset, v;
2479
dfdb6bf4b90f support 32bit output for the mpeg audio decoder
michael
parents: 2478
diff changeset
873 OUT_INT *samples2;
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
874 #if FRAC_BITS <= 15
1428
aece5836c588 fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents: 1414
diff changeset
875 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
876 #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
877 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
878 #endif
2468
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
879
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
880 dct32(tmp, sb_samples);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
881
2468
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
882 offset = *synth_buf_offset;
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
883 synth_buf = synth_buf_ptr + offset;
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
884
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
885 for(j=0;j<32;j++) {
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
886 v = tmp[j];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
887 #if FRAC_BITS <= 15
449
7b2f23b5dcdd fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents: 440
diff changeset
888 /* NOTE: can cause a loss in precision if very high amplitude
7b2f23b5dcdd fixed layer1/2 overflow if very loud sound - fixed broken free format decoding to pass all mpeg audio standard decoding tests (please avoid patching the parser without having all test streams available - contact me if necessary)
bellard
parents: 440
diff changeset
889 sound */
5523
c2ab2ac31edb use av_clip_int16() where it makes sense
aurel
parents: 5518
diff changeset
890 v = av_clip_int16(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
891 #endif
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
892 synth_buf[j] = v;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
893 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
894 /* copy to avoid wrap */
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
895 memcpy(synth_buf + 512, synth_buf, 32 * sizeof(MPA_INT));
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
896
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
897 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
898 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
899 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
900
2473
73afecc117a3 10l (didnt test code after cvs up ...)
michael
parents: 2472
diff changeset
901 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
902 p = synth_buf + 16;
7256
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
903 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
904 p = synth_buf + 48;
7256
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
905 SUM8(MLSS, sum, w + 32, p);
2472
021dc26e760f dithering for the mpeg audio decoder
michael
parents: 2468
diff changeset
906 *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
907 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
908 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
909
aece5836c588 fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents: 1414
diff changeset
910 /* 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
911 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
912 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
913 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
914 p = synth_buf + 16 + j;
7256
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
915 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
916 p = synth_buf + 48 - j;
7256
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
917 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
918
2472
021dc26e760f dithering for the mpeg audio decoder
michael
parents: 2468
diff changeset
919 *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
920 samples += incr;
2472
021dc26e760f dithering for the mpeg audio decoder
michael
parents: 2468
diff changeset
921 sum += sum2;
021dc26e760f dithering for the mpeg audio decoder
michael
parents: 2468
diff changeset
922 *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
923 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
924 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
925 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
926 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
927
1428
aece5836c588 fixed audio frame buffering problem (should correct problems on some streams) - faster synthesis filter - prototype 'parse_only' support
bellard
parents: 1414
diff changeset
928 p = synth_buf + 32;
7256
7c13d54f389d mpegaudio: use MAC/MLS macros in ff_mpa_synth_filter
mru
parents: 7040
diff changeset
929 SUM8(MLSS, sum, w + 32, p);
2472
021dc26e760f dithering for the mpeg audio decoder
michael
parents: 2468
diff changeset
930 *samples = round_sample(&sum);
2473
73afecc117a3 10l (didnt test code after cvs up ...)
michael
parents: 2472
diff changeset
931 *dither_state= sum;
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
932
46ee548e47e4 added 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 offset = (offset - 32) & 511;
2468
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
934 *synth_buf_offset = offset;
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
935 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
936
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
937 #define C3 FIXHR(0.86602540378443864676/2)
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
938
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
939 /* 0.5 / cos(pi*(2*i+1)/36) */
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
940 static const int icos36[9] = {
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
941 FIXR(0.50190991877167369479),
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
942 FIXR(0.51763809020504152469), //0
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
943 FIXR(0.55168895948124587824),
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
944 FIXR(0.61038729438072803416),
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
945 FIXR(0.70710678118654752439), //1
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
946 FIXR(0.87172339781054900991),
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
947 FIXR(1.18310079157624925896),
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
948 FIXR(1.93185165257813657349), //2
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
949 FIXR(5.73685662283492756461),
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
950 };
82
46ee548e47e4 added 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
3599
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
952 /* 0.5 / cos(pi*(2*i+1)/36) */
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
953 static const int icos36h[9] = {
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
954 FIXHR(0.50190991877167369479/2),
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
955 FIXHR(0.51763809020504152469/2), //0
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
956 FIXHR(0.55168895948124587824/2),
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
957 FIXHR(0.61038729438072803416/2),
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
958 FIXHR(0.70710678118654752439/2), //1
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
959 FIXHR(0.87172339781054900991/2),
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
960 FIXHR(1.18310079157624925896/4),
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
961 FIXHR(1.93185165257813657349/4), //2
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
962 // FIXHR(5.73685662283492756461),
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
963 };
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
964
82
46ee548e47e4 added 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 /* 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
966 cases. */
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
967 static void imdct12(int *out, int *in)
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
968 {
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
969 int in0, in1, in2, in3, in4, in5, t1, t2;
2496
74d7fd7b49c5 merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents: 2495
diff changeset
970
74d7fd7b49c5 merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents: 2495
diff changeset
971 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
972 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
973 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
974 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
975 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
976 in5= in[5*3] + in[4*3];
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
977 in5 += in3;
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
978 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
979
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
980 in2= MULH(2*in2, C3);
3599
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
981 in3= MULH(4*in3, C3);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
982
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
983 t1 = in0 - in4;
3599
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
984 t2 = MULH(2*(in1 - in5), icos36h[4]);
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
985
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
986 out[ 7]=
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
987 out[10]= t1 + t2;
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
988 out[ 1]=
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
989 out[ 4]= t1 - t2;
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
990
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
991 in0 += in4>>1;
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
992 in4 = in0 + in2;
3599
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
993 in5 += 2*in1;
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
994 in1 = MULH(in5 + in3, icos36h[1]);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
995 out[ 8]=
3599
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
996 out[ 9]= in4 + in1;
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
997 out[ 2]=
3599
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
998 out[ 3]= in4 - in1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
999
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1000 in0 -= in2;
3599
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
1001 in5 = MULH(2*(in5 - in3), icos36h[7]);
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1002 out[ 0]=
3599
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
1003 out[ 5]= in0 - in5;
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1004 out[ 6]=
3599
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
1005 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
1006 }
46ee548e47e4 added 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
46ee548e47e4 added 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 /* cos(pi*i/18) */
2489
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1009 #define C1 FIXHR(0.98480775301220805936/2)
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1010 #define C2 FIXHR(0.93969262078590838405/2)
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1011 #define C3 FIXHR(0.86602540378443864676/2)
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1012 #define C4 FIXHR(0.76604444311897803520/2)
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1013 #define C5 FIXHR(0.64278760968653932632/2)
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1014 #define C6 FIXHR(0.5/2)
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1015 #define C7 FIXHR(0.34202014332566873304/2)
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1016 #define C8 FIXHR(0.17364817766693034885/2)
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1017
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1018
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1019 /* using Lee like decomposition followed by hand coded 9 points DCT */
2489
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1020 static void imdct36(int *out, int *buf, int *in, int *win)
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1021 {
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1022 int i, j, t0, t1, t2, t3, s0, s1, s2, s3;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1023 int tmp[18], *tmp1, *in1;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1024
46ee548e47e4 added 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 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
1026 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
1027 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
1028 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
1029
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1030 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
1031 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
1032 in1 = in + j;
2489
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1033 #if 0
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1034 //more accurate but slower
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1035 int64_t t0, t1, t2, t3;
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1036 t2 = in1[2*4] + in1[2*8] - in1[2*2];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1037
2489
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1038 t3 = (in1[2*0] + (int64_t)(in1[2*6]>>1))<<32;
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1039 t1 = in1[2*0] - in1[2*6];
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1040 tmp1[ 6] = t1 - (t2>>1);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1041 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
1042
2489
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1043 t0 = MUL64(2*(in1[2*2] + in1[2*4]), C2);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1044 t1 = MUL64( in1[2*4] - in1[2*8] , -2*C8);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1045 t2 = MUL64(2*(in1[2*2] + in1[2*8]), -C4);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1046
2489
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1047 tmp1[10] = (t3 - t0 - t2) >> 32;
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1048 tmp1[ 2] = (t3 + t0 + t1) >> 32;
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1049 tmp1[14] = (t3 + t2 - t1) >> 32;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1050
2489
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1051 tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1052 t2 = MUL64(2*(in1[2*1] + in1[2*5]), C1);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1053 t3 = MUL64( in1[2*5] - in1[2*7] , -2*C7);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1054 t0 = MUL64(2*in1[2*3], C3);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1055
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1056 t1 = MUL64(2*(in1[2*1] + in1[2*7]), -C5);
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1057
2489
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1058 tmp1[ 0] = (t2 + t3 + t0) >> 32;
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1059 tmp1[12] = (t2 + t1 - t0) >> 32;
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1060 tmp1[ 8] = (t3 - t1 - t0) >> 32;
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1061 #else
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1062 t2 = in1[2*4] + in1[2*8] - in1[2*2];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1063
2489
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1064 t3 = in1[2*0] + (in1[2*6]>>1);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1065 t1 = in1[2*0] - in1[2*6];
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1066 tmp1[ 6] = t1 - (t2>>1);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1067 tmp1[16] = t1 + t2;
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1068
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1069 t0 = MULH(2*(in1[2*2] + in1[2*4]), C2);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1070 t1 = MULH( in1[2*4] - in1[2*8] , -2*C8);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1071 t2 = MULH(2*(in1[2*2] + in1[2*8]), -C4);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1072
2489
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1073 tmp1[10] = t3 - t0 - t2;
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1074 tmp1[ 2] = t3 + t0 + t1;
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1075 tmp1[14] = t3 + t2 - t1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1076
2489
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1077 tmp1[ 4] = MULH(2*(in1[2*5] + in1[2*7] - in1[2*1]), -C3);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1078 t2 = MULH(2*(in1[2*1] + in1[2*5]), C1);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1079 t3 = MULH( in1[2*5] - in1[2*7] , -2*C7);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1080 t0 = MULH(2*in1[2*3], C3);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1081
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1082 t1 = MULH(2*(in1[2*1] + in1[2*7]), -C5);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1083
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1084 tmp1[ 0] = t2 + t3 + t0;
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1085 tmp1[12] = t2 + t1 - t0;
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1086 tmp1[ 8] = t3 - t1 - t0;
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1087 #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
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
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1090 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
1091 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
1092 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
1093 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
1094 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
1095 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
1096
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1097 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
1098 t3 = tmp[i + 3];
3599
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
1099 s1 = MULH(2*(t3 + t2), icos36h[j]);
8201
c6e2ffef3797 Add shift argument to MULL() macro
mru
parents: 8042
diff changeset
1100 s3 = MULL(t3 - t2, icos36[8 - j], FRAC_BITS);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1101
2496
74d7fd7b49c5 merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents: 2495
diff changeset
1102 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
1103 t1 = s0 - s1;
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1104 out[(9 + j)*SBLIMIT] = MULH(t1, win[9 + j]) + buf[9 + j];
2489
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1105 out[(8 - j)*SBLIMIT] = MULH(t1, win[8 - j]) + buf[8 - j];
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1106 buf[9 + j] = MULH(t0, win[18 + 9 + j]);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1107 buf[8 - j] = MULH(t0, win[18 + 8 - j]);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1108
2496
74d7fd7b49c5 merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents: 2495
diff changeset
1109 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
1110 t1 = s2 - s3;
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1111 out[(9 + 8 - j)*SBLIMIT] = MULH(t1, win[9 + 8 - j]) + buf[9 + 8 - j];
2489
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1112 out[( j)*SBLIMIT] = MULH(t1, win[ j]) + buf[ j];
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1113 buf[9 + 8 - j] = MULH(t0, win[18 + 9 + 8 - j]);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1114 buf[ + j] = MULH(t0, win[18 + j]);
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1115 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
1116 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1117
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1118 s0 = tmp[16];
3599
9a069376b7e3 replace a few MULL by MULH
michael
parents: 3598
diff changeset
1119 s1 = MULH(2*tmp[17], icos36h[4]);
2496
74d7fd7b49c5 merge a few shifts into the dequantization, faster and more accurate, lets hope it doesnt overflow
michael
parents: 2495
diff changeset
1120 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
1121 t1 = s0 - s1;
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1122 out[(9 + 4)*SBLIMIT] = MULH(t1, win[9 + 4]) + buf[9 + 4];
2489
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1123 out[(8 - 4)*SBLIMIT] = MULH(t1, win[8 - 4]) + buf[8 - 4];
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1124 buf[9 + 4] = MULH(t0, win[18 + 9 + 4]);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1125 buf[8 - 4] = MULH(t0, win[18 + 8 - 4]);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
1126 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
1127
82
46ee548e47e4 added 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 /* 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
1129 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
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 int bound, i, v, n, ch, j, mant;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
1132 uint8_t allocation[MPA_MAX_CHANNELS][SBLIMIT];
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
1133 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
1134
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1135 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
1136 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
1137 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
1138 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
1139
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1140 /* 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
1141 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
1142 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
1143 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
1144 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1145 }
46ee548e47e4 added 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 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
1147 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
1148 }
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
1149
82
46ee548e47e4 added 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 /* 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
1151 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
1152 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
1153 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
1154 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
1155 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1156 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1157 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
1158 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
1159 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
1160 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
1161 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1162 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1163
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1164 /* 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
1165 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
1166 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
1167 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
1168 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
1169 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
1170 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
1171 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
1172 } 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
1173 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
1174 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1175 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
1176 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1177 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1178 for(i=bound;i<SBLIMIT;i++) {
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1179 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
1180 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
1181 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
1182 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
1183 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
1184 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
1185 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
1186 } 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
1187 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
1188 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
1189 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1190 }
46ee548e47e4 added 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 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
1193 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1194
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1195 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
1196 {
46ee548e47e4 added 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 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
1198 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
1199 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
1200 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
1201 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
1202 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
1203 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
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 /* select decoding table */
5052
d981eb275c8f remove dependency of mpeg audio encoder over mpeg audio decoder
aurel
parents: 5051
diff changeset
1206 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
1207 s->sample_rate, s->lsf);
5032
d47ee2d1d7da add proper prefix to extern mpeg audio data tables
aurel
parents: 5031
diff changeset
1208 sblimit = ff_mpa_sblimit_table[table];
d47ee2d1d7da add proper prefix to extern mpeg audio data tables
aurel
parents: 5031
diff changeset
1209 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
1210
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1211 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
1212 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
1213 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
1214 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
1215
4652
6679d37a3338 Give context to dprintf
mbardiaux
parents: 4469
diff changeset
1216 dprintf(s->avctx, "bound=%d sblimit=%d\n", bound, sblimit);
1780
cc4c1eb18eec fixes by Gildas Bazin <gbazin at altern dot org>
michael
parents: 1762
diff changeset
1217
cc4c1eb18eec fixes by Gildas Bazin <gbazin at altern dot org>
michael
parents: 1762
diff changeset
1218 /* sanity check */
cc4c1eb18eec fixes by Gildas Bazin <gbazin at altern dot org>
michael
parents: 1762
diff changeset
1219 if( bound > sblimit ) bound = sblimit;
cc4c1eb18eec fixes by Gildas Bazin <gbazin at altern dot org>
michael
parents: 1762
diff changeset
1220
82
46ee548e47e4 added 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 /* 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
1222 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
1223 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
1224 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
1225 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
1226 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
1227 }
46ee548e47e4 added 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 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
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 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
1231 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
1232 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
1233 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
1234 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
1235 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
1236 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1237
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1238 /* 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
1239 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
1240 for(ch=0;ch<s->nb_channels;ch++) {
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1241 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
1242 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
1243 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1244 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1245
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1246 /* 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
1247 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
1248 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
1249 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
1250 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
1251 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
1252 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
1253 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
1254 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
1255 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
1256 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
1257 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
1258 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
1259 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
1260 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
1261 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
1262 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
1263 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
1264 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
1265 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
1266 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
1267 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
1268 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
1269 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
1270 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
1271 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
1272 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
1273 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1274 }
46ee548e47e4 added 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 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1276 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1277
46ee548e47e4 added 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 /* 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
1279 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
1280 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
1281 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
1282 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
1283 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
1284 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
1285 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
1286 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
1287 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
1288 qindex = alloc_table[j+b];
5032
d47ee2d1d7da add proper prefix to extern mpeg audio data tables
aurel
parents: 5031
diff changeset
1289 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
1290 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
1291 /* 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
1292 v = get_bits(&s->gb, -bits);
5032
d47ee2d1d7da add proper prefix to extern mpeg audio data tables
aurel
parents: 5031
diff changeset
1293 steps = ff_mpa_quant_steps[qindex];
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1294 s->sb_samples[ch][k * 12 + l + 0][i] =
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1295 l2_unscale_group(steps, v % steps, scale);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1296 v = v / steps;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1297 s->sb_samples[ch][k * 12 + l + 1][i] =
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1298 l2_unscale_group(steps, v % steps, scale);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1299 v = v / steps;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1300 s->sb_samples[ch][k * 12 + l + 2][i] =
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1301 l2_unscale_group(steps, v, scale);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1302 } 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
1303 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
1304 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
1305 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
1306 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
1307 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1308 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1309 } 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
1310 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
1311 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
1312 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
1313 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1314 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1315 /* next subband in alloc table */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1316 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
1317 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1318 /* 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
1319 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
1320 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
1321 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
1322 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
1323 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
1324 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
1325 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
1326 qindex = alloc_table[j+b];
5032
d47ee2d1d7da add proper prefix to extern mpeg audio data tables
aurel
parents: 5031
diff changeset
1327 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
1328 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
1329 /* 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
1330 v = get_bits(&s->gb, -bits);
5032
d47ee2d1d7da add proper prefix to extern mpeg audio data tables
aurel
parents: 5031
diff changeset
1331 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
1332 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
1333 v = v / steps;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1334 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
1335 l2_unscale_group(steps, mant, scale0);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1336 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
1337 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
1338 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
1339 v = v / steps;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1340 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
1341 l2_unscale_group(steps, mant, scale0);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1342 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
1343 l2_unscale_group(steps, mant, scale1);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1344 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
1345 l2_unscale_group(steps, v, scale0);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1346 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
1347 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
1348 } 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
1349 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
1350 mant = get_bits(&s->gb, bits);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1351 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
1352 l1_unscale(bits - 1, mant, scale0);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1353 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
1354 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
1355 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1356 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1357 } else {
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1358 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
1359 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
1360 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
1361 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
1362 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
1363 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
1364 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1365 /* next subband in alloc table */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1366 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
1367 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1368 /* 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
1369 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
1370 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
1371 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
1372 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
1373 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
1374 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1375 }
46ee548e47e4 added 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 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1377 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1378 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
1379 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1380
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1381 static inline void lsf_sf_expand(int *slen,
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1382 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
1383 {
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1384 if (n3) {
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1385 slen[3] = sf % n3;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1386 sf /= n3;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1387 } 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
1388 slen[3] = 0;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1389 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1390 if (n2) {
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1391 slen[2] = sf % n2;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1392 sf /= n2;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1393 } else {
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1394 slen[2] = 0;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1395 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1396 slen[1] = sf % n1;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1397 sf /= n1;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1398 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
1399 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1400
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1401 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
1402 GranuleDef *g,
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
1403 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
1404 {
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
1405 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
1406 int len, i, j, k, l, v0, shift, gain, gains[3];
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
1407 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
1408
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1409 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
1410 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
1411 shift = g->scalefac_scale + 1;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
1412
82
46ee548e47e4 added 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 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
1414 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
1415 for(i=0;i<g->long_end;i++) {
3625
8042fcb3a62a move the +400 out of the innermost loop
michael
parents: 3624
diff changeset
1416 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
1417 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
1418 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
1419 *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
1420 }
46ee548e47e4 added 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->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
1423 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
1424 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
1425 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
1426 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
1427 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
1428 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
1429 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
1430 for(l=0;l<3;l++) {
3625
8042fcb3a62a move the +400 out of the innermost loop
michael
parents: 3624
diff changeset
1431 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
1432 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
1433 *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
1434 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1435 }
46ee548e47e4 added 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 }
46ee548e47e4 added 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 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1438
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1439 /* 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
1440 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
1441 {
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1442 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
1443 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
1444 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
1445 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
1446 }
46ee548e47e4 added 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
4469
a2e82396193c factorize switch_buffer()
michael
parents: 4468
diff changeset
1448
a2e82396193c factorize switch_buffer()
michael
parents: 4468
diff changeset
1449 static void switch_buffer(MPADecodeContext *s, int *pos, int *end_pos, int *end_pos2){
a2e82396193c factorize switch_buffer()
michael
parents: 4468
diff changeset
1450 if(s->in_gb.buffer && *pos >= s->gb.size_in_bits){
a2e82396193c factorize switch_buffer()
michael
parents: 4468
diff changeset
1451 s->gb= s->in_gb;
a2e82396193c factorize switch_buffer()
michael
parents: 4468
diff changeset
1452 s->in_gb.buffer=NULL;
a2e82396193c factorize switch_buffer()
michael
parents: 4468
diff changeset
1453 assert((get_bits_count(&s->gb) & 7) == 0);
a2e82396193c factorize switch_buffer()
michael
parents: 4468
diff changeset
1454 skip_bits_long(&s->gb, *pos - *end_pos);
a2e82396193c factorize switch_buffer()
michael
parents: 4468
diff changeset
1455 *end_pos2=
a2e82396193c factorize switch_buffer()
michael
parents: 4468
diff changeset
1456 *end_pos= *end_pos2 + get_bits_count(&s->gb) - *pos;
a2e82396193c factorize switch_buffer()
michael
parents: 4468
diff changeset
1457 *pos= get_bits_count(&s->gb);
a2e82396193c factorize switch_buffer()
michael
parents: 4468
diff changeset
1458 }
a2e82396193c factorize switch_buffer()
michael
parents: 4468
diff changeset
1459 }
a2e82396193c factorize switch_buffer()
michael
parents: 4468
diff changeset
1460
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1461 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
1462 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
1463 {
46ee548e47e4 added 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 int s_index;
3626
a6251ee2dfdb move variable declarations so that their scope is smaller
michael
parents: 3625
diff changeset
1465 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
1466 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
1467 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
1468 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
1469
46ee548e47e4 added 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 /* 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
1471 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
1472 for(i=0;i<3;i++) {
3626
a6251ee2dfdb move variable declarations so that their scope is smaller
michael
parents: 3625
diff changeset
1473 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
1474 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
1475 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
1476 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
1477 /* 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
1478 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
1479 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
1480 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
1481 vlc = &huff_vlc[l];
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
1482
3609
6560c84eef72 use memset() instead of slow c loops
michael
parents: 3608
diff changeset
1483 if(!l){
3636
031252e99956 another silly typo which surprisingly neither valgrind nor cmp of the file output cought
michael
parents: 3635
diff changeset
1484 memset(&g->sb_hybrid[s_index], 0, sizeof(*g->sb_hybrid)*2*j);
3609
6560c84eef72 use memset() instead of slow c loops
michael
parents: 3608
diff changeset
1485 s_index += 2*j;
6560c84eef72 use memset() instead of slow c loops
michael
parents: 3608
diff changeset
1486 continue;
6560c84eef72 use memset() instead of slow c loops
michael
parents: 3608
diff changeset
1487 }
6560c84eef72 use memset() instead of slow c loops
michael
parents: 3608
diff changeset
1488
82
46ee548e47e4 added 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 /* 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
1490 for(;j>0;j--) {
3626
a6251ee2dfdb move variable declarations so that their scope is smaller
michael
parents: 3625
diff changeset
1491 int exponent, x, y, v;
3634
fa4beebb74a6 remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents: 3627
diff changeset
1492 int pos= get_bits_count(&s->gb);
3624
7d8ef3c542a1 avoid reading exponent twice
michael
parents: 3623
diff changeset
1493
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
1494 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
1495 // av_log(NULL, AV_LOG_ERROR, "pos: %d %d %d %d\n", pos, end_pos, end_pos2, s_index);
4469
a2e82396193c factorize switch_buffer()
michael
parents: 4468
diff changeset
1496 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
1497 // 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
1498 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
1499 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
1500 }
3623
d0242f36a793 reduce size of vlc table, thats slightly faster here
michael
parents: 3622
diff changeset
1501 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
1502
a20d179c79c3 faster handling of zero coeffs in the low freq decode
michael
parents: 3610
diff changeset
1503 if(!y){
a20d179c79c3 faster handling of zero coeffs in the low freq decode
michael
parents: 3610
diff changeset
1504 g->sb_hybrid[s_index ] =
a20d179c79c3 faster handling of zero coeffs in the low freq decode
michael
parents: 3610
diff changeset
1505 g->sb_hybrid[s_index+1] = 0;
a20d179c79c3 faster handling of zero coeffs in the low freq decode
michael
parents: 3610
diff changeset
1506 s_index += 2;
a20d179c79c3 faster handling of zero coeffs in the low freq decode
michael
parents: 3610
diff changeset
1507 continue;
a20d179c79c3 faster handling of zero coeffs in the low freq decode
michael
parents: 3610
diff changeset
1508 }
a20d179c79c3 faster handling of zero coeffs in the low freq decode
michael
parents: 3610
diff changeset
1509
3624
7d8ef3c542a1 avoid reading exponent twice
michael
parents: 3623
diff changeset
1510 exponent= exponents[s_index];
3609
6560c84eef72 use memset() instead of slow c loops
michael
parents: 3608
diff changeset
1511
4652
6679d37a3338 Give context to dprintf
mbardiaux
parents: 4469
diff changeset
1512 dprintf(s->avctx, "region=%d n=%d x=%d y=%d exp=%d\n",
3624
7d8ef3c542a1 avoid reading exponent twice
michael
parents: 3623
diff changeset
1513 i, g->region_size[i] - j, x, y, exponent);
3627
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
1514 if(y&16){
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
1515 x = y >> 5;
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
1516 y = y & 0x0f;
3622
e88a3910f855 try to avoid l3_unscale() by using a table
michael
parents: 3621
diff changeset
1517 if (x < 15){
3625
8042fcb3a62a move the +400 out of the innermost loop
michael
parents: 3624
diff changeset
1518 v = expval_table[ exponent ][ x ];
8042fcb3a62a move the +400 out of the innermost loop
michael
parents: 3624
diff changeset
1519 // v = expval_table[ (exponent&3) ][ x ] >> FFMIN(0 - (exponent>>2), 31);
3622
e88a3910f855 try to avoid l3_unscale() by using a table
michael
parents: 3621
diff changeset
1520 }else{
e88a3910f855 try to avoid l3_unscale() by using a table
michael
parents: 3621
diff changeset
1521 x += get_bitsz(&s->gb, linbits);
3624
7d8ef3c542a1 avoid reading exponent twice
michael
parents: 3623
diff changeset
1522 v = l3_unscale(x, exponent);
3622
e88a3910f855 try to avoid l3_unscale() by using a table
michael
parents: 3621
diff changeset
1523 }
82
46ee548e47e4 added 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 if (get_bits1(&s->gb))
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1525 v = -v;
3627
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
1526 g->sb_hybrid[s_index] = v;
3622
e88a3910f855 try to avoid l3_unscale() by using a table
michael
parents: 3621
diff changeset
1527 if (y < 15){
3625
8042fcb3a62a move the +400 out of the innermost loop
michael
parents: 3624
diff changeset
1528 v = expval_table[ exponent ][ y ];
3622
e88a3910f855 try to avoid l3_unscale() by using a table
michael
parents: 3621
diff changeset
1529 }else{
e88a3910f855 try to avoid l3_unscale() by using a table
michael
parents: 3621
diff changeset
1530 y += get_bitsz(&s->gb, linbits);
3624
7d8ef3c542a1 avoid reading exponent twice
michael
parents: 3623
diff changeset
1531 v = l3_unscale(y, exponent);
3622
e88a3910f855 try to avoid l3_unscale() by using a table
michael
parents: 3621
diff changeset
1532 }
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1533 if (get_bits1(&s->gb))
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1534 v = -v;
3627
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
1535 g->sb_hybrid[s_index+1] = v;
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
1536 }else{
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
1537 x = y >> 5;
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
1538 y = y & 0x0f;
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
1539 x += y;
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
1540 if (x < 15){
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
1541 v = expval_table[ exponent ][ x ];
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
1542 }else{
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
1543 x += get_bitsz(&s->gb, linbits);
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
1544 v = l3_unscale(x, exponent);
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
1545 }
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
1546 if (get_bits1(&s->gb))
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
1547 v = -v;
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
1548 g->sb_hybrid[s_index+!!y] = v;
3635
0087dc6b306c 10l found by valgrind
michael
parents: 3634
diff changeset
1549 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
1550 }
3627
8624a5c2824d avoid branch
michael
parents: 3626
diff changeset
1551 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
1552 }
46ee548e47e4 added 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 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1554
82
46ee548e47e4 added 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 /* 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
1556 vlc = &huff_quad_vlc[g->count1table_select];
3612
9283f094680e dont copy the whole GetBitContext around
michael
parents: 3611
diff changeset
1557 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
1558 while (s_index <= 572) {
3626
a6251ee2dfdb move variable declarations so that their scope is smaller
michael
parents: 3625
diff changeset
1559 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
1560 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
1561 if (pos >= end_pos) {
3647
4a93d7102793 fix buffer handling
michael
parents: 3644
diff changeset
1562 if (pos > end_pos2 && last_pos){
4a93d7102793 fix buffer handling
michael
parents: 3644
diff changeset
1563 /* some encoders generate an incorrect size for this
4a93d7102793 fix buffer handling
michael
parents: 3644
diff changeset
1564 part. We must go back into the data */
4a93d7102793 fix buffer handling
michael
parents: 3644
diff changeset
1565 s_index -= 4;
4a93d7102793 fix buffer handling
michael
parents: 3644
diff changeset
1566 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
1567 av_log(s->avctx, AV_LOG_INFO, "overread, skip %d enddists: %d %d\n", last_pos - pos, end_pos-pos, end_pos2-pos);
7831
8195c970d077 Rename error_resilience to error_recognition.
michael
parents: 7763
diff changeset
1568 if(s->error_recognition >= FF_ER_COMPLIANT)
4205
8c28f03cfdd5 detect a few more errors (fixes libmp3-bug.avi again)
michael
parents: 4204
diff changeset
1569 s_index=0;
3647
4a93d7102793 fix buffer handling
michael
parents: 3644
diff changeset
1570 break;
4a93d7102793 fix buffer handling
michael
parents: 3644
diff changeset
1571 }
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
1572 // av_log(NULL, AV_LOG_ERROR, "pos2: %d %d %d %d\n", pos, end_pos, end_pos2, s_index);
4469
a2e82396193c factorize switch_buffer()
michael
parents: 4468
diff changeset
1573 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
1574 // 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
1575 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
1576 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
1577 }
3612
9283f094680e dont copy the whole GetBitContext around
michael
parents: 3611
diff changeset
1578 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
1579
3610
d97b4709aaf0 optimizing high freq decode
michael
parents: 3609
diff changeset
1580 code = get_vlc2(&s->gb, vlc->table, vlc->bits, 1);
4652
6679d37a3338 Give context to dprintf
mbardiaux
parents: 4469
diff changeset
1581 dprintf(s->avctx, "t=%d code=%d\n", g->count1table_select, code);
3610
d97b4709aaf0 optimizing high freq decode
michael
parents: 3609
diff changeset
1582 g->sb_hybrid[s_index+0]=
d97b4709aaf0 optimizing high freq decode
michael
parents: 3609
diff changeset
1583 g->sb_hybrid[s_index+1]=
d97b4709aaf0 optimizing high freq decode
michael
parents: 3609
diff changeset
1584 g->sb_hybrid[s_index+2]=
d97b4709aaf0 optimizing high freq decode
michael
parents: 3609
diff changeset
1585 g->sb_hybrid[s_index+3]= 0;
d97b4709aaf0 optimizing high freq decode
michael
parents: 3609
diff changeset
1586 while(code){
4908
777f250df232 Fix multiple "¡Æinline/static¡Ç is not at beginning of declaration" warnings.
diego
parents: 4796
diff changeset
1587 static const int idxtab[16]={3,3,2,2,1,1,1,1,0,0,0,0,0,0,0,0};
3626
a6251ee2dfdb move variable declarations so that their scope is smaller
michael
parents: 3625
diff changeset
1588 int v;
3610
d97b4709aaf0 optimizing high freq decode
michael
parents: 3609
diff changeset
1589 int pos= s_index+idxtab[code];
d97b4709aaf0 optimizing high freq decode
michael
parents: 3609
diff changeset
1590 code ^= 8>>idxtab[code];
3625
8042fcb3a62a move the +400 out of the innermost loop
michael
parents: 3624
diff changeset
1591 v = exp_table[ exponents[pos] ];
8042fcb3a62a move the +400 out of the innermost loop
michael
parents: 3624
diff changeset
1592 // v = exp_table[ (exponents[pos]&3) ] >> FFMIN(0 - (exponents[pos]>>2), 31);
3610
d97b4709aaf0 optimizing high freq decode
michael
parents: 3609
diff changeset
1593 if(get_bits1(&s->gb))
d97b4709aaf0 optimizing high freq decode
michael
parents: 3609
diff changeset
1594 v = -v;
d97b4709aaf0 optimizing high freq decode
michael
parents: 3609
diff changeset
1595 g->sb_hybrid[pos] = v;
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1596 }
3610
d97b4709aaf0 optimizing high freq decode
michael
parents: 3609
diff changeset
1597 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
1598 }
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
1599 /* skip extension bits */
4468
5455cb5a759c fix decoding of takethat.mp3
michael
parents: 4295
diff changeset
1600 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
1601 //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
1602 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
1603 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
1604 s_index=0;
7831
8195c970d077 Rename error_resilience to error_recognition.
michael
parents: 7763
diff changeset
1605 }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
1606 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
1607 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
1608 }
4205
8c28f03cfdd5 detect a few more errors (fixes libmp3-bug.avi again)
michael
parents: 4204
diff changeset
1609 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
1610 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
1611
4468
5455cb5a759c fix decoding of takethat.mp3
michael
parents: 4295
diff changeset
1612 i= get_bits_count(&s->gb);
4469
a2e82396193c factorize switch_buffer()
michael
parents: 4468
diff changeset
1613 switch_buffer(s, &i, &end_pos, &end_pos2);
4468
5455cb5a759c fix decoding of takethat.mp3
michael
parents: 4295
diff changeset
1614
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1615 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
1616 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1617
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1618 /* 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
1619 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
1620 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
1621 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
1622 {
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
1623 int i, j, len;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
1624 int32_t *ptr, *dst, *ptr1;
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
1625 int32_t tmp[576];
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1626
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1627 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
1628 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
1629
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1630 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
1631 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
1632 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
1633 } 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
1634 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
1635 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1636 } else {
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1637 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
1638 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1639
82
46ee548e47e4 added 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 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
1641 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
1642 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
1643 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
1644 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
1645 *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
1646 *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
1647 *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
1648 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
1649 }
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
1650 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
1651 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
1652 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1653 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1654
46ee548e47e4 added 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 #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
1656
46ee548e47e4 added 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 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
1658 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
1659 {
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1660 int i, j, k, l;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
1661 int32_t v1, v2;
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1662 int sf_max, tmp0, tmp1, sf, len, non_zero_found;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
1663 int32_t (*is_tab)[16];
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
1664 int32_t *tab0, *tab1;
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1665 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
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 /* 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
1668 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
1669 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
1670 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
1671 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
1672 } 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
1673 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
1674 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
1675 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1676
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1677 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
1678 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
1679
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1680 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
1681 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
1682 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
1683 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
1684 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
1685 /* 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
1686 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
1687 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
1688 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
1689 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
1690 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
1691 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
1692 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
1693 /* 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
1694 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
1695 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
1696 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
1697 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
1698 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1699 }
46ee548e47e4 added 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 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
1701 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
1702 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
1703
46ee548e47e4 added 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 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
1705 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
1706 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
1707 tmp0 = tab0[j];
8201
c6e2ffef3797 Add shift argument to MULL() macro
mru
parents: 8042
diff changeset
1708 tab0[j] = MULL(tmp0, v1, FRAC_BITS);
c6e2ffef3797 Add shift argument to MULL() macro
mru
parents: 8042
diff changeset
1709 tab1[j] = MULL(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
1710 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1711 } 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
1712 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
1713 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
1714 /* 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
1715 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
1716 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
1717 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
1718 tmp1 = tab1[j];
8201
c6e2ffef3797 Add shift argument to MULL() macro
mru
parents: 8042
diff changeset
1719 tab0[j] = MULL(tmp0 + tmp1, ISQRT2, FRAC_BITS);
c6e2ffef3797 Add shift argument to MULL() macro
mru
parents: 8042
diff changeset
1720 tab1[j] = MULL(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
1721 }
46ee548e47e4 added 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 }
46ee548e47e4 added 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 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1724 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1725 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1726
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1727 non_zero_found = non_zero_found_short[0] |
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1728 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
1729 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
1730
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1731 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
1732 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
1733 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
1734 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
1735 /* 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
1736 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
1737 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
1738 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
1739 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
1740 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
1741 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1742 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1743 /* 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
1744 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
1745 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
1746 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
1747 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
1748 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
1749 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
1750 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
1751 tmp0 = tab0[j];
8201
c6e2ffef3797 Add shift argument to MULL() macro
mru
parents: 8042
diff changeset
1752 tab0[j] = MULL(tmp0, v1, FRAC_BITS);
c6e2ffef3797 Add shift argument to MULL() macro
mru
parents: 8042
diff changeset
1753 tab1[j] = MULL(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
1754 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1755 } 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 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
1757 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
1758 /* 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
1759 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
1760 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
1761 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
1762 tmp1 = tab1[j];
8201
c6e2ffef3797 Add shift argument to MULL() macro
mru
parents: 8042
diff changeset
1763 tab0[j] = MULL(tmp0 + tmp1, ISQRT2, FRAC_BITS);
c6e2ffef3797 Add shift argument to MULL() macro
mru
parents: 8042
diff changeset
1764 tab1[j] = MULL(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
1765 }
46ee548e47e4 added 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 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1767 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1768 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1769 } else 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
1770 /* 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
1771 /* 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
1772 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
1773 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
1774 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
1775 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
1776 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
1777 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
1778 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
1779 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
1780 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1781 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1782 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1783
1733
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
1784 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
1785 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
1786 {
2491
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1787 int32_t *ptr, *csa;
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1788 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
1789
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1790 /* 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
1791 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
1792 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
1793 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
1794 /* 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
1795 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
1796 } 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
1797 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
1798 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1799
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1800 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
1801 for(i = n;i > 0;i--) {
2491
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1802 int tmp0, tmp1, tmp2;
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1803 csa = &csa_table[0][0];
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1804 #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
1805 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
1806 tmp1 = ptr[ j];\
2491
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1807 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
1808 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
1809 ptr[ j] = 4*(tmp2 + MULH(tmp0, csa[3+4*j]));
2491
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1810
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1811 INT_AA(0)
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1812 INT_AA(1)
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1813 INT_AA(2)
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1814 INT_AA(3)
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1815 INT_AA(4)
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1816 INT_AA(5)
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1817 INT_AA(6)
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1818 INT_AA(7)
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1819
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1820 ptr += 18;
1733
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
1821 }
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
1822 }
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
1823
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
1824 static void compute_antialias_float(MPADecodeContext *s,
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
1825 GranuleDef *g)
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
1826 {
2491
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1827 int32_t *ptr;
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1828 int n, i;
1733
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
1829
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
1830 /* we antialias only "long" bands */
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
1831 if (g->block_type == 2) {
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
1832 if (!g->switch_point)
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
1833 return;
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
1834 /* XXX: check this for 8000Hz case */
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
1835 n = 1;
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
1836 } else {
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
1837 n = SBLIMIT - 1;
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
1838 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1839
1733
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
1840 ptr = g->sb_hybrid + 18;
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
1841 for(i = n;i > 0;i--) {
2491
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1842 float tmp0, tmp1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1843 float *csa = &csa_table_float[0][0];
2491
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1844 #define FLOAT_AA(j)\
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1845 tmp0= ptr[-1-j];\
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1846 tmp1= ptr[ j];\
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1847 ptr[-1-j] = lrintf(tmp0 * csa[0+4*j] - tmp1 * csa[1+4*j]);\
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1848 ptr[ j] = lrintf(tmp0 * csa[1+4*j] + tmp1 * csa[0+4*j]);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1849
2491
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1850 FLOAT_AA(0)
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1851 FLOAT_AA(1)
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1852 FLOAT_AA(2)
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1853 FLOAT_AA(3)
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1854 FLOAT_AA(4)
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1855 FLOAT_AA(5)
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1856 FLOAT_AA(6)
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1857 FLOAT_AA(7)
c559ea6e395c optimize antialias
michael
parents: 2490
diff changeset
1858
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1859 ptr += 18;
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1860 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1861 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1862
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1863 static void compute_imdct(MPADecodeContext *s,
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1864 GranuleDef *g,
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
1865 int32_t *sb_samples,
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
1866 int32_t *mdct_buf)
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1867 {
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1868 int32_t *ptr, *win, *win1, *buf, *out_ptr, *ptr1;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
1869 int32_t out2[12];
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1870 int i, j, mdct_long_end, v, sblimit;
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1871
46ee548e47e4 added 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 /* 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
1873 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
1874 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
1875 while (ptr >= ptr1) {
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1876 ptr -= 6;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1877 v = ptr[0] | ptr[1] | ptr[2] | ptr[3] | ptr[4] | ptr[5];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1878 if (v != 0)
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1879 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
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 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
1882
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1883 if (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
1884 /* 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
1885 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
1886 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
1887 else
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1888 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
1889 } 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
1890 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
1891 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1892
46ee548e47e4 added 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 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
1894 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
1895 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
1896 /* 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
1897 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
1898 /* 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
1899 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
1900 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
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 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
1903 /* 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
1904 win = win1 + ((4 * 36) & -(j & 1));
2489
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1905 imdct36(out_ptr, buf, ptr, win);
2e5ae040e92b optimizing imdct36()
michael
parents: 2479
diff changeset
1906 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
1907 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
1908 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
1909 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1910 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
1911 /* 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
1912 win = mdct_win[2] + ((4 * 36) & -(j & 1));
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1913 out_ptr = sb_samples + j;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1914
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1915 for(i=0; i<6; i++){
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1916 *out_ptr = buf[i];
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1917 out_ptr += SBLIMIT;
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1918 }
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1919 imdct12(out2, ptr + 0);
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1920 for(i=0;i<6;i++) {
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1921 *out_ptr = MULH(out2[i], win[i]) + buf[i + 6*1];
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1922 buf[i + 6*2] = MULH(out2[i + 6], win[i + 6]);
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1923 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
1924 }
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1925 imdct12(out2, ptr + 1);
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1926 for(i=0;i<6;i++) {
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1927 *out_ptr = MULH(out2[i], win[i]) + buf[i + 6*2];
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1928 buf[i + 6*0] = MULH(out2[i + 6], win[i + 6]);
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1929 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
1930 }
2495
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1931 imdct12(out2, ptr + 2);
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1932 for(i=0;i<6;i++) {
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1933 buf[i + 6*0] = MULH(out2[i], win[i]) + buf[i + 6*0];
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1934 buf[i + 6*1] = MULH(out2[i + 6], win[i + 6]);
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1935 buf[i + 6*2] = 0;
7a79cb42eddb optimizing imdct12
michael
parents: 2491
diff changeset
1936 }
82
46ee548e47e4 added 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 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
1938 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
1939 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1940 /* 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
1941 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
1942 /* 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
1943 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
1944 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
1945 *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
1946 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
1947 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
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 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
1950 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1951 }
46ee548e47e4 added 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
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1953 /* 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
1954 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
1955 {
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1956 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
1957 int gr, ch, blocksplit_flag, i, j, k, n, bits_pos;
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1958 GranuleDef granules[2][2], *g;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
1959 int16_t exponents[576];
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1960
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1961 /* 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
1962 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
1963 main_data_begin = get_bits(&s->gb, 8);
3613
5cb45b2211a0 simplify
michael
parents: 3612
diff changeset
1964 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
1965 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
1966 } 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
1967 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
1968 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
1969 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
1970 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
1971 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
1972 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
1973 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
1974 granules[ch][0].scfsi = 0; /* all scale factors are transmitted */
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1975 granules[ch][1].scfsi = get_bits(&s->gb, 4);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1976 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1977 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1978
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1979 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
1980 for(ch=0;ch<s->nb_channels;ch++) {
4652
6679d37a3338 Give context to dprintf
mbardiaux
parents: 4469
diff changeset
1981 dprintf(s->avctx, "gr=%d ch=%d: side_info\n", gr, ch);
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1982 g = &granules[ch][gr];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1983 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
1984 g->big_values = get_bits(&s->gb, 9);
4202
af24e0fd0d1b more checks and error messages
michael
parents: 4104
diff changeset
1985 if(g->big_values > 288){
4652
6679d37a3338 Give context to dprintf
mbardiaux
parents: 4469
diff changeset
1986 av_log(s->avctx, AV_LOG_ERROR, "big_values too big\n");
4202
af24e0fd0d1b more checks and error messages
michael
parents: 4104
diff changeset
1987 return -1;
af24e0fd0d1b more checks and error messages
michael
parents: 4104
diff changeset
1988 }
af24e0fd0d1b more checks and error messages
michael
parents: 4104
diff changeset
1989
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
1990 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
1991 /* 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
1992 1/sqrt(2) renormalization factor */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
1993 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
1994 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
1995 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
1996 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
1997 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
1998 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
1999 g->scalefac_compress = get_bits(&s->gb, 4);
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5161
diff changeset
2000 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
2001 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
2002 g->block_type = get_bits(&s->gb, 2);
4202
af24e0fd0d1b more checks and error messages
michael
parents: 4104
diff changeset
2003 if (g->block_type == 0){
7329
104a00d9abfa Supply context argument to av_log() in mpeg audio decoder.
andoma
parents: 7256
diff changeset
2004 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
2005 return -1;
4202
af24e0fd0d1b more checks and error messages
michael
parents: 4104
diff changeset
2006 }
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5161
diff changeset
2007 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
2008 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
2009 g->table_select[i] = get_bits(&s->gb, 5);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
2010 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
2011 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
2012 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
2013 } else {
6138
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
2014 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
2015 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
2016 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
2017 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
2018 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
2019 /* 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
2020 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
2021 region_address2 = get_bits(&s->gb, 3);
4652
6679d37a3338 Give context to dprintf
mbardiaux
parents: 4469
diff changeset
2022 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
2023 region_address1, region_address2);
6138
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
2024 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
2025 }
6138
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
2026 ff_region_offset2size(g);
c7a61f83de73 Factorize some code into functions, had this in my tree and will be
michael
parents: 6137
diff changeset
2027 ff_compute_band_indexes(s, g);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
2028
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2029 g->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
2030 if (!s->lsf)
5513
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5161
diff changeset
2031 g->preflag = get_bits1(&s->gb);
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5161
diff changeset
2032 g->scalefac_scale = get_bits1(&s->gb);
9f8219a3b86f use get_bits1(..) instead get_bits(.., 1)
alex
parents: 5161
diff changeset
2033 g->count1table_select = get_bits1(&s->gb);
4652
6679d37a3338 Give context to dprintf
mbardiaux
parents: 4469
diff changeset
2034 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
2035 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
2036 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2037 }
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
2038
2432
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2039 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
2040 const uint8_t *ptr = s->gb.buffer + (get_bits_count(&s->gb)>>3);
3647
4a93d7102793 fix buffer handling
michael
parents: 3644
diff changeset
2041 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
2042 /* now we get bits from the main_data_begin offset */
4652
6679d37a3338 Give context to dprintf
mbardiaux
parents: 4469
diff changeset
2043 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
2044 //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
2045
fa4beebb74a6 remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents: 3627
diff changeset
2046 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
2047 s->in_gb= s->gb;
4204
672724df5c9a making decoding more error robust
michael
parents: 4203
diff changeset
2048 init_get_bits(&s->gb, s->last_buf, s->last_buf_size*8);
672724df5c9a making decoding more error robust
michael
parents: 4203
diff changeset
2049 skip_bits_long(&s->gb, 8*(s->last_buf_size - main_data_begin));
2432
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2050 }
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2051
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2052 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
2053 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
2054 g = &granules[ch][gr];
4204
672724df5c9a making decoding more error robust
michael
parents: 4203
diff changeset
2055 if(get_bits_count(&s->gb)<0){
7329
104a00d9abfa Supply context argument to av_log() in mpeg audio decoder.
andoma
parents: 7256
diff changeset
2056 av_log(s->avctx, AV_LOG_ERROR, "mdb:%d, lastbuf:%d skipping granule %d\n",
4204
672724df5c9a making decoding more error robust
michael
parents: 4203
diff changeset
2057 main_data_begin, s->last_buf_size, gr);
672724df5c9a making decoding more error robust
michael
parents: 4203
diff changeset
2058 skip_bits_long(&s->gb, g->part2_3_length);
672724df5c9a making decoding more error robust
michael
parents: 4203
diff changeset
2059 memset(g->sb_hybrid, 0, sizeof(g->sb_hybrid));
672724df5c9a making decoding more error robust
michael
parents: 4203
diff changeset
2060 if(get_bits_count(&s->gb) >= s->gb.size_in_bits && s->in_gb.buffer){
672724df5c9a making decoding more error robust
michael
parents: 4203
diff changeset
2061 skip_bits_long(&s->in_gb, get_bits_count(&s->gb) - s->gb.size_in_bits);
672724df5c9a making decoding more error robust
michael
parents: 4203
diff changeset
2062 s->gb= s->in_gb;
672724df5c9a making decoding more error robust
michael
parents: 4203
diff changeset
2063 s->in_gb.buffer=NULL;
672724df5c9a making decoding more error robust
michael
parents: 4203
diff changeset
2064 }
672724df5c9a making decoding more error robust
michael
parents: 4203
diff changeset
2065 continue;
672724df5c9a making decoding more error robust
michael
parents: 4203
diff changeset
2066 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
2067
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2068 bits_pos = get_bits_count(&s->gb);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
2069
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2070 if (!s->lsf) {
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
2071 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
2072 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
2073
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2074 /* 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
2075 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
2076 slen2 = slen_table[1][g->scalefac_compress];
4652
6679d37a3338 Give context to dprintf
mbardiaux
parents: 4469
diff changeset
2077 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
2078 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
2079 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
2080 j = 0;
3616
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2081 if(slen1){
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2082 for(i=0;i<n;i++)
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2083 g->scale_factors[j++] = get_bits(&s->gb, slen1);
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2084 }else{
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2085 for(i=0;i<n;i++)
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2086 g->scale_factors[j++] = 0;
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2087 }
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2088 if(slen2){
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2089 for(i=0;i<18;i++)
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2090 g->scale_factors[j++] = get_bits(&s->gb, slen2);
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2091 for(i=0;i<3;i++)
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2092 g->scale_factors[j++] = 0;
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2093 }else{
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2094 for(i=0;i<21;i++)
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2095 g->scale_factors[j++] = 0;
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2096 }
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2097 } else {
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2098 sc = granules[ch][0].scale_factors;
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2099 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
2100 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
2101 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
2102 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
2103 slen = (k < 2) ? slen1 : slen2;
3616
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2104 if(slen){
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2105 for(i=0;i<n;i++)
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2106 g->scale_factors[j++] = get_bits(&s->gb, slen);
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2107 }else{
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2108 for(i=0;i<n;i++)
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2109 g->scale_factors[j++] = 0;
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2110 }
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2111 } 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
2112 /* 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
2113 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
2114 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
2115 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
2116 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2117 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2118 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2119 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
2120 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2121 } 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
2122 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
2123
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2124 /* 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
2125 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
2126 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
2127 } 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
2128 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
2129 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2130 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
2131 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
2132 /* 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
2133 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
2134 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
2135 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
2136 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
2137 } 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
2138 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
2139 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
2140 } 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
2141 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
2142 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
2143 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2144 } else {
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2145 /* 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
2146 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
2147 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
2148 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
2149 } 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
2150 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
2151 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
2152 } 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
2153 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
2154 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
2155 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
2156 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2157 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2158
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2159 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
2160 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
2161 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
2162 sl = slen[k];
3617
b2a5e44cf957 10l typo
michael
parents: 3616
diff changeset
2163 if(sl){
3616
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2164 for(i=0;i<n;i++)
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2165 g->scale_factors[j++] = get_bits(&s->gb, sl);
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2166 }else{
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2167 for(i=0;i<n;i++)
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2168 g->scale_factors[j++] = 0;
270790578711 avoid a few if(x==0) checks in the inner loops
michael
parents: 3614
diff changeset
2169 }
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2170 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2171 /* 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
2172 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
2173 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
2174 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2175
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2176 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
2177
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2178 /* read Huffman coded residue */
4204
672724df5c9a making decoding more error robust
michael
parents: 4203
diff changeset
2179 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
2180 } /* 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
2181
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2182 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
2183 compute_stereo(s, &granules[0][gr], &granules[1][gr]);
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2184
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2185 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
2186 g = &granules[ch][gr];
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2187
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2188 reorder_block(s, g);
1733
b47d56b1a049 optimize compute_antialias() and add a floating point based alternative (2x faster)
michael
parents: 1612
diff changeset
2189 s->compute_antialias(s, g);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
2190 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
2191 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2192 } /* gr */
4204
672724df5c9a making decoding more error robust
michael
parents: 4203
diff changeset
2193 if(get_bits_count(&s->gb)<0)
672724df5c9a making decoding more error robust
michael
parents: 4203
diff changeset
2194 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
2195 return nb_granules * 18;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
2196 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
2197
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
2198 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
2199 OUT_INT *samples, const uint8_t *buf, int buf_size)
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
2200 {
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2201 int i, nb_frames, ch;
2479
dfdb6bf4b90f support 32bit output for the mpeg audio decoder
michael
parents: 2478
diff changeset
2202 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
2203
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
2204 init_get_bits(&s->gb, buf + HEADER_SIZE, (buf_size - HEADER_SIZE)*8);
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2913
diff changeset
2205
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
2206 /* skip error protection field */
986e461dc072 Initial revision
glantau
parents:
diff changeset
2207 if (s->error_protection)
5518
d2ef80f5fd7e use skip_bits where appropriate
alex
parents: 5513
diff changeset
2208 skip_bits(&s->gb, 16);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
2209
4652
6679d37a3338 Give context to dprintf
mbardiaux
parents: 4469
diff changeset
2210 dprintf(s->avctx, "frame %d:\n", s->frame_count);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
2211 switch(s->layer) {
986e461dc072 Initial revision
glantau
parents:
diff changeset
2212 case 1:
6511
b5e9dae2dbc6 omg, fix compilation
bcoudurier
parents: 6510
diff changeset
2213 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
2214 nb_frames = mp_decode_layer1(s);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
2215 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
2216 case 2:
6511
b5e9dae2dbc6 omg, fix compilation
bcoudurier
parents: 6510
diff changeset
2217 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
2218 nb_frames = mp_decode_layer2(s);
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
2219 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
2220 case 3:
6511
b5e9dae2dbc6 omg, fix compilation
bcoudurier
parents: 6510
diff changeset
2221 s->avctx->frame_size = s->lsf ? 576 : 1152;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
2222 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
2223 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
2224
3643
ae1dfbbb25bb fix low bitrate mp3
michael
parents: 3641
diff changeset
2225 s->last_buf_size=0;
ae1dfbbb25bb fix low bitrate mp3
michael
parents: 3641
diff changeset
2226 if(s->in_gb.buffer){
ae1dfbbb25bb fix low bitrate mp3
michael
parents: 3641
diff changeset
2227 align_get_bits(&s->gb);
ae1dfbbb25bb fix low bitrate mp3
michael
parents: 3641
diff changeset
2228 i= (s->gb.size_in_bits - get_bits_count(&s->gb))>>3;
3647
4a93d7102793 fix buffer handling
michael
parents: 3644
diff changeset
2229 if(i >= 0 && i <= BACKSTEP_SIZE){
3643
ae1dfbbb25bb fix low bitrate mp3
michael
parents: 3641
diff changeset
2230 memmove(s->last_buf, s->gb.buffer + (get_bits_count(&s->gb)>>3), i);
ae1dfbbb25bb fix low bitrate mp3
michael
parents: 3641
diff changeset
2231 s->last_buf_size=i;
3647
4a93d7102793 fix buffer handling
michael
parents: 3644
diff changeset
2232 }else
7329
104a00d9abfa Supply context argument to av_log() in mpeg audio decoder.
andoma
parents: 7256
diff changeset
2233 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
2234 s->gb= s->in_gb;
4204
672724df5c9a making decoding more error robust
michael
parents: 4203
diff changeset
2235 s->in_gb.buffer= NULL;
3643
ae1dfbbb25bb fix low bitrate mp3
michael
parents: 3641
diff changeset
2236 }
ae1dfbbb25bb fix low bitrate mp3
michael
parents: 3641
diff changeset
2237
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
2238 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
2239 assert((get_bits_count(&s->gb) & 7) == 0);
3643
ae1dfbbb25bb fix low bitrate mp3
michael
parents: 3641
diff changeset
2240 i= (s->gb.size_in_bits - get_bits_count(&s->gb))>>3;
ae1dfbbb25bb fix low bitrate mp3
michael
parents: 3641
diff changeset
2241
3647
4a93d7102793 fix buffer handling
michael
parents: 3644
diff changeset
2242 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
2243 if(i<0)
08ef30f08a01 Only print "invalid new backstep" when it is really invalid.
michael
parents: 7867
diff changeset
2244 av_log(s->avctx, AV_LOG_ERROR, "invalid new backstep %d\n", i);
3647
4a93d7102793 fix buffer handling
michael
parents: 3644
diff changeset
2245 i= FFMIN(BACKSTEP_SIZE, buf_size - HEADER_SIZE);
4a93d7102793 fix buffer handling
michael
parents: 3644
diff changeset
2246 }
3643
ae1dfbbb25bb fix low bitrate mp3
michael
parents: 3641
diff changeset
2247 assert(i <= buf_size - HEADER_SIZE && i>= 0);
3647
4a93d7102793 fix buffer handling
michael
parents: 3644
diff changeset
2248 memcpy(s->last_buf + s->last_buf_size, s->gb.buffer + buf_size - HEADER_SIZE - i, i);
3643
ae1dfbbb25bb fix low bitrate mp3
michael
parents: 3641
diff changeset
2249 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
2250
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
2251 break;
986e461dc072 Initial revision
glantau
parents:
diff changeset
2252 }
7763
73b10d25cb8d Remove debuging junk that probably hasnt been used by anyone since years.
michael
parents: 7452
diff changeset
2253
82
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2254 /* 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
2255 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
2256 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
2257 for(i=0;i<nb_frames;i++) {
2468
1addaf6facbb exported ff_mpa_synth_filter for upcoming qdm2 decoder
alex
parents: 2432
diff changeset
2258 ff_mpa_synth_filter(s->synth_buf[ch], &(s->synth_buf_offset[ch]),
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
2259 window, &s->dither_state,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
2260 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
2261 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
2262 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
2263 }
46ee548e47e4 added completely new mpeg audio decoder (integer only, free format support, lsf/mpeg25 support, high/low precision support, simpler code)
glantau
parents: 0
diff changeset
2264 }
7763
73b10d25cb8d Remove debuging junk that probably hasnt been used by anyone since years.
michael
parents: 7452
diff changeset
2265
2479
dfdb6bf4b90f support 32bit output for the mpeg audio decoder
michael
parents: 2478
diff changeset
2266 return nb_frames * 32 * sizeof(OUT_INT) * s->nb_channels;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
2267 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
2268
986e461dc072 Initial revision
glantau
parents:
diff changeset
2269 static int decode_frame(AVCodecContext * avctx,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
2270 void *data, int *data_size,
6218
michael
parents: 6138
diff changeset
2271 const uint8_t * buf, int buf_size)
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
2272 {
986e461dc072 Initial revision
glantau
parents:
diff changeset
2273 MPADecodeContext *s = avctx->priv_data;
1064
b32afefe7d33 * UINTX -> uintx_t INTX -> intx_t
kabi
parents: 1057
diff changeset
2274 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
2275 int out_size;
2479
dfdb6bf4b90f support 32bit output for the mpeg audio decoder
michael
parents: 2478
diff changeset
2276 OUT_INT *out_samples = data;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
2277
3634
fa4beebb74a6 remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents: 3627
diff changeset
2278 retry:
fa4beebb74a6 remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents: 3627
diff changeset
2279 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
2280 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
2281
5089
bff60ecc02f9 Use AV_xx throughout libavcodec
ramiro
parents: 5076
diff changeset
2282 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
2283 if(ff_mpa_check_header(header) < 0){
fa4beebb74a6 remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents: 3627
diff changeset
2284 buf++;
fa4beebb74a6 remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents: 3627
diff changeset
2285 // buf_size--;
3938
92d8a536268f message typo fixes
diego
parents: 3777
diff changeset
2286 av_log(avctx, AV_LOG_ERROR, "Header missing skipping one byte.\n");
3634
fa4beebb74a6 remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents: 3627
diff changeset
2287 goto retry;
fa4beebb74a6 remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents: 3627
diff changeset
2288 }
143
35e3ced6cfd9 * fixed decoding busy loop
kabi
parents: 125
diff changeset
2289
5051
b908c67063c8 add a ff_ prefix to some mpegaudio funcs
aurel
parents: 5050
diff changeset
2290 if (ff_mpegaudio_decode_header(s, header) == 1) {
3634
fa4beebb74a6 remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents: 3627
diff changeset
2291 /* 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
2292 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
2293 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
2294 }
fa4beebb74a6 remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents: 3627
diff changeset
2295 /* 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
2296 avctx->channels = s->nb_channels;
fa4beebb74a6 remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents: 3627
diff changeset
2297 avctx->bit_rate = s->bit_rate;
fa4beebb74a6 remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents: 3627
diff changeset
2298 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
2299
3687
bfcf76cad06a print more correct error messges
michael
parents: 3666
diff changeset
2300 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
2301 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
2302 return -1;
3687
bfcf76cad06a print more correct error messges
michael
parents: 3666
diff changeset
2303 }else if(s->frame_size < buf_size){
bfcf76cad06a print more correct error messges
michael
parents: 3666
diff changeset
2304 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
2305 buf_size= s->frame_size;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
2306 }
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
2307
fa4beebb74a6 remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents: 3627
diff changeset
2308 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
2309 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
2310 *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
2311 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
2312 //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
2313 }else
3938
92d8a536268f message typo fixes
diego
parents: 3777
diff changeset
2314 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
2315 s->frame_size = 0;
fa4beebb74a6 remove duplicated parser, people who pass random gibblets of the bitstream into the decoder will have to pass it through a AVParser like for all other codecs too
michael
parents: 3627
diff changeset
2316 return buf_size;
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
2317 }
986e461dc072 Initial revision
glantau
parents:
diff changeset
2318
4203
14250f6ff483 reset internal buffer during seeking
michael
parents: 4202
diff changeset
2319 static void flush(AVCodecContext *avctx){
14250f6ff483 reset internal buffer during seeking
michael
parents: 4202
diff changeset
2320 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
2321 memset(s->synth_buf, 0, sizeof(s->synth_buf));
4203
14250f6ff483 reset internal buffer during seeking
michael
parents: 4202
diff changeset
2322 s->last_buf_size= 0;
14250f6ff483 reset internal buffer during seeking
michael
parents: 4202
diff changeset
2323 }
14250f6ff483 reset internal buffer during seeking
michael
parents: 4202
diff changeset
2324
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3776
diff changeset
2325 #ifdef CONFIG_MP3ADU_DECODER
2432
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2326 static int decode_frame_adu(AVCodecContext * avctx,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
2327 void *data, int *data_size,
6218
michael
parents: 6138
diff changeset
2328 const uint8_t * buf, int buf_size)
2432
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2329 {
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2330 MPADecodeContext *s = avctx->priv_data;
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2331 uint32_t header;
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2332 int len, out_size;
2479
dfdb6bf4b90f support 32bit output for the mpeg audio decoder
michael
parents: 2478
diff changeset
2333 OUT_INT *out_samples = data;
2432
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2334
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2335 len = buf_size;
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2336
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2337 // Discard too short frames
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2338 if (buf_size < HEADER_SIZE) {
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2339 *data_size = 0;
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2340 return buf_size;
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2341 }
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2342
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2343
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2344 if (len > MPA_MAX_CODED_FRAME_SIZE)
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2345 len = MPA_MAX_CODED_FRAME_SIZE;
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2346
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2347 // Get header and restore sync word
5089
bff60ecc02f9 Use AV_xx throughout libavcodec
ramiro
parents: 5076
diff changeset
2348 header = AV_RB32(buf) | 0xffe00000;
2432
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2349
2472
021dc26e760f dithering for the mpeg audio decoder
michael
parents: 2468
diff changeset
2350 if (ff_mpa_check_header(header) < 0) { // Bad header, discard frame
2432
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2351 *data_size = 0;
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2352 return buf_size;
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2353 }
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2354
5051
b908c67063c8 add a ff_ prefix to some mpegaudio funcs
aurel
parents: 5050
diff changeset
2355 ff_mpegaudio_decode_header(s, header);
2432
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2356 /* update codec info */
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2357 avctx->sample_rate = s->sample_rate;
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2358 avctx->channels = s->nb_channels;
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2359 avctx->bit_rate = s->bit_rate;
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2360 avctx->sub_id = s->layer;
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2361
6510
771eb7ea8b3f correctly set avctx->frame_size for mp3on4 and mp3adu
bcoudurier
parents: 6350
diff changeset
2362 s->frame_size = len;
2432
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2363
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2364 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
2365 out_size = buf_size;
2432
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2366 } 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
2367 out_size = mp_decode_frame(s, out_samples, buf, buf_size);
2432
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2368 }
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2369
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2370 *data_size = out_size;
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2371 return buf_size;
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2372 }
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3776
diff changeset
2373 #endif /* CONFIG_MP3ADU_DECODER */
2432
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2374
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3776
diff changeset
2375 #ifdef CONFIG_MP3ON4_DECODER
6694
a2319e5d8bd3 use mpeg4audio common code
bcoudurier
parents: 6692
diff changeset
2376
6699
99cf02b8f831 move MP3On4DecodeContext def near the code and under ifdef
bcoudurier
parents: 6698
diff changeset
2377 /**
99cf02b8f831 move MP3On4DecodeContext def near the code and under ifdef
bcoudurier
parents: 6698
diff changeset
2378 * Context for MP3On4 decoder
99cf02b8f831 move MP3On4DecodeContext def near the code and under ifdef
bcoudurier
parents: 6698
diff changeset
2379 */
99cf02b8f831 move MP3On4DecodeContext def near the code and under ifdef
bcoudurier
parents: 6698
diff changeset
2380 typedef struct MP3On4DecodeContext {
99cf02b8f831 move MP3On4DecodeContext def near the code and under ifdef
bcoudurier
parents: 6698
diff changeset
2381 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
2382 int syncword; ///< syncword patch
6700
dd38dc6306a8 simplify: remove useless fields and vars
bcoudurier
parents: 6699
diff changeset
2383 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
2384 MPADecodeContext *mp3decctx[5]; ///< MPADecodeContext for every decoder instance
99cf02b8f831 move MP3On4DecodeContext def near the code and under ifdef
bcoudurier
parents: 6698
diff changeset
2385 } MP3On4DecodeContext;
99cf02b8f831 move MP3On4DecodeContext def near the code and under ifdef
bcoudurier
parents: 6698
diff changeset
2386
6694
a2319e5d8bd3 use mpeg4audio common code
bcoudurier
parents: 6692
diff changeset
2387 #include "mpeg4audio.h"
a2319e5d8bd3 use mpeg4audio common code
bcoudurier
parents: 6692
diff changeset
2388
2507
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2389 /* 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
2390 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
2391 /* 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
2392 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
2393 {0},
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2394 {0}, // C
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2395 {0}, // FLR
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2396 {2,0}, // C FLR
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2397 {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
2398 {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
2399 {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
2400 {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
2401 };
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2402
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2403
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2404 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
2405 {
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2406 MP3On4DecodeContext *s = avctx->priv_data;
6694
a2319e5d8bd3 use mpeg4audio common code
bcoudurier
parents: 6692
diff changeset
2407 MPEG4AudioConfig cfg;
2507
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2408 int i;
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2409
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2410 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
2411 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
2412 return -1;
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2413 }
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2414
6694
a2319e5d8bd3 use mpeg4audio common code
bcoudurier
parents: 6692
diff changeset
2415 ff_mpeg4audio_get_config(&cfg, avctx->extradata, avctx->extradata_size);
a2319e5d8bd3 use mpeg4audio common code
bcoudurier
parents: 6692
diff changeset
2416 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
2417 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
2418 return -1;
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2419 }
6700
dd38dc6306a8 simplify: remove useless fields and vars
bcoudurier
parents: 6699
diff changeset
2420 s->frames = mp3Frames[cfg.chan_config];
dd38dc6306a8 simplify: remove useless fields and vars
bcoudurier
parents: 6699
diff changeset
2421 s->coff = chan_offset[cfg.chan_config];
dd38dc6306a8 simplify: remove useless fields and vars
bcoudurier
parents: 6699
diff changeset
2422 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
2423
6698
06f422f73ade correctly patch syncword for samples rates < 16000, decoder now fully support all iso ref files
bcoudurier
parents: 6697
diff changeset
2424 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
2425 s->syncword = 0xffe00000;
06f422f73ade correctly patch syncword for samples rates < 16000, decoder now fully support all iso ref files
bcoudurier
parents: 6697
diff changeset
2426 else
06f422f73ade correctly patch syncword for samples rates < 16000, decoder now fully support all iso ref files
bcoudurier
parents: 6697
diff changeset
2427 s->syncword = 0xfff00000;
06f422f73ade correctly patch syncword for samples rates < 16000, decoder now fully support all iso ref files
bcoudurier
parents: 6697
diff changeset
2428
2507
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2429 /* 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
2430 * 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
2431 * decode_init() does not have to be changed.
6350
8e63d869a904 typo fix: inited --> initialized
diego
parents: 6218
diff changeset
2432 * 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
2433 */
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2434 // 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
2435 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
2436 // 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
2437 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
2438 decode_init(avctx);
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2439 // Restore mp3on4 context pointer
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2440 avctx->priv_data = s;
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2441 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
2442
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2443 /* 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
2444 * 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
2445 */
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2446 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
2447 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
2448 s->mp3decctx[i]->compute_antialias = s->mp3decctx[0]->compute_antialias;
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2449 s->mp3decctx[i]->adu_mode = 1;
4652
6679d37a3338 Give context to dprintf
mbardiaux
parents: 4469
diff changeset
2450 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
2451 }
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2452
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2453 return 0;
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2454 }
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2455
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2456
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2457 static int decode_close_mp3on4(AVCodecContext * avctx)
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2458 {
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2459 MP3On4DecodeContext *s = avctx->priv_data;
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2460 int i;
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2461
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2462 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
2463 if (s->mp3decctx[i])
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2464 av_free(s->mp3decctx[i]);
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2465
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2466 return 0;
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2467 }
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2468
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2469
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2470 static int decode_frame_mp3on4(AVCodecContext * avctx,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
2471 void *data, int *data_size,
6218
michael
parents: 6138
diff changeset
2472 const uint8_t * buf, int buf_size)
2507
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2473 {
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2474 MP3On4DecodeContext *s = avctx->priv_data;
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2475 MPADecodeContext *m;
6704
2f439a593e56 merge init with declaration
bcoudurier
parents: 6703
diff changeset
2476 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
2477 uint32_t header;
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2478 OUT_INT *out_samples = data;
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2479 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
2480 OUT_INT *outptr, *bp;
6702
a9a28c8b40fb simplify: merge loops
bcoudurier
parents: 6701
diff changeset
2481 int fr, j, n;
2507
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2482
6688
91f5a23d6cd5 return error if buf_size is too small
bcoudurier
parents: 6687
diff changeset
2483 *data_size = 0;
2507
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2484 // Discard too short frames
6688
91f5a23d6cd5 return error if buf_size is too small
bcoudurier
parents: 6687
diff changeset
2485 if (buf_size < HEADER_SIZE)
91f5a23d6cd5 return error if buf_size is too small
bcoudurier
parents: 6687
diff changeset
2486 return -1;
2507
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2487
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2488 // 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
2489 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
2490
6702
a9a28c8b40fb simplify: merge loops
bcoudurier
parents: 6701
diff changeset
2491 avctx->bit_rate = 0;
a9a28c8b40fb simplify: merge loops
bcoudurier
parents: 6701
diff changeset
2492
2507
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2493 for (fr = 0; fr < s->frames; fr++) {
6692
25413354a79a simplify
bcoudurier
parents: 6691
diff changeset
2494 fsize = AV_RB16(buf) >> 4;
6689
85cb0c3f8e54 simplify using FFMIN3
bcoudurier
parents: 6688
diff changeset
2495 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
2496 m = s->mp3decctx[fr];
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2497 assert (m != NULL);
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2498
6698
06f422f73ade correctly patch syncword for samples rates < 16000, decoder now fully support all iso ref files
bcoudurier
parents: 6697
diff changeset
2499 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
2500
6705
d5515254fbbd break if error in header so it can output already decoded frames
bcoudurier
parents: 6704
diff changeset
2501 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
2502 break;
2507
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2503
5051
b908c67063c8 add a ff_ prefix to some mpegaudio funcs
aurel
parents: 5050
diff changeset
2504 ff_mpegaudio_decode_header(m, header);
6697
1310a89b0dcd fix 1 frame config decoding
bcoudurier
parents: 6696
diff changeset
2505 out_size += mp_decode_frame(m, outptr, buf, fsize);
6692
25413354a79a simplify
bcoudurier
parents: 6691
diff changeset
2506 buf += fsize;
25413354a79a simplify
bcoudurier
parents: 6691
diff changeset
2507 len -= fsize;
2507
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2508
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2509 if(s->frames > 1) {
6691
863e939331aa correctly compute out_size and samples number
bcoudurier
parents: 6690
diff changeset
2510 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
2511 /* interleave output data */
6700
dd38dc6306a8 simplify: remove useless fields and vars
bcoudurier
parents: 6699
diff changeset
2512 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
2513 if(m->nb_channels == 1) {
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2514 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
2515 *bp = decoded_buf[j];
6701
ef18192d8474 simplify
bcoudurier
parents: 6700
diff changeset
2516 bp += avctx->channels;
2507
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2517 }
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2518 } else {
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2519 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
2520 bp[0] = decoded_buf[j++];
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2521 bp[1] = decoded_buf[j];
6701
ef18192d8474 simplify
bcoudurier
parents: 6700
diff changeset
2522 bp += avctx->channels;
2507
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2523 }
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2524 }
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2525 }
6702
a9a28c8b40fb simplify: merge loops
bcoudurier
parents: 6701
diff changeset
2526 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
2527 }
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2528
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2529 /* update codec info */
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2530 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
2531
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2532 *data_size = out_size;
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2533 return buf_size;
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2534 }
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3776
diff changeset
2535 #endif /* CONFIG_MP3ON4_DECODER */
2507
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2536
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3776
diff changeset
2537 #ifdef CONFIG_MP2_DECODER
322
ce35fd27bbb0 - Versions defined for libav/libavcodec.
pulento
parents: 313
diff changeset
2538 AVCodec mp2_decoder =
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
2539 {
322
ce35fd27bbb0 - Versions defined for libav/libavcodec.
pulento
parents: 313
diff changeset
2540 "mp2",
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
2541 CODEC_TYPE_AUDIO,
986e461dc072 Initial revision
glantau
parents:
diff changeset
2542 CODEC_ID_MP2,
986e461dc072 Initial revision
glantau
parents:
diff changeset
2543 sizeof(MPADecodeContext),
986e461dc072 Initial revision
glantau
parents:
diff changeset
2544 decode_init,
986e461dc072 Initial revision
glantau
parents:
diff changeset
2545 NULL,
986e461dc072 Initial revision
glantau
parents:
diff changeset
2546 NULL,
986e461dc072 Initial revision
glantau
parents:
diff changeset
2547 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
2548 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
2549 .flush= flush,
7040
e943e1409077 Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents: 6712
diff changeset
2550 .long_name= NULL_IF_CONFIG_SMALL("MP2 (MPEG audio layer 2)"),
0
986e461dc072 Initial revision
glantau
parents:
diff changeset
2551 };
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3776
diff changeset
2552 #endif
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3776
diff changeset
2553 #ifdef CONFIG_MP3_DECODER
322
ce35fd27bbb0 - Versions defined for libav/libavcodec.
pulento
parents: 313
diff changeset
2554 AVCodec mp3_decoder =
ce35fd27bbb0 - Versions defined for libav/libavcodec.
pulento
parents: 313
diff changeset
2555 {
ce35fd27bbb0 - Versions defined for libav/libavcodec.
pulento
parents: 313
diff changeset
2556 "mp3",
ce35fd27bbb0 - Versions defined for libav/libavcodec.
pulento
parents: 313
diff changeset
2557 CODEC_TYPE_AUDIO,
1448
317ba7ab73bd CODEC_ID_MP3LAME is obsolete
bellard
parents: 1428
diff changeset
2558 CODEC_ID_MP3,
322
ce35fd27bbb0 - Versions defined for libav/libavcodec.
pulento
parents: 313
diff changeset
2559 sizeof(MPADecodeContext),
ce35fd27bbb0 - Versions defined for libav/libavcodec.
pulento
parents: 313
diff changeset
2560 decode_init,
ce35fd27bbb0 - Versions defined for libav/libavcodec.
pulento
parents: 313
diff changeset
2561 NULL,
ce35fd27bbb0 - Versions defined for libav/libavcodec.
pulento
parents: 313
diff changeset
2562 NULL,
ce35fd27bbb0 - Versions defined for libav/libavcodec.
pulento
parents: 313
diff changeset
2563 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
2564 CODEC_CAP_PARSE_ONLY,
4203
14250f6ff483 reset internal buffer during seeking
michael
parents: 4202
diff changeset
2565 .flush= flush,
7040
e943e1409077 Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents: 6712
diff changeset
2566 .long_name= NULL_IF_CONFIG_SMALL("MP3 (MPEG audio layer 3)"),
322
ce35fd27bbb0 - Versions defined for libav/libavcodec.
pulento
parents: 313
diff changeset
2567 };
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3776
diff changeset
2568 #endif
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3776
diff changeset
2569 #ifdef CONFIG_MP3ADU_DECODER
2432
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2570 AVCodec mp3adu_decoder =
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2571 {
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2572 "mp3adu",
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2573 CODEC_TYPE_AUDIO,
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2574 CODEC_ID_MP3ADU,
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2575 sizeof(MPADecodeContext),
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2576 decode_init,
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2577 NULL,
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2578 NULL,
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2579 decode_frame_adu,
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2580 CODEC_CAP_PARSE_ONLY,
4203
14250f6ff483 reset internal buffer during seeking
michael
parents: 4202
diff changeset
2581 .flush= flush,
7040
e943e1409077 Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents: 6712
diff changeset
2582 .long_name= NULL_IF_CONFIG_SMALL("ADU (Application Data Unit) MP3 (MPEG audio layer 3)"),
2432
d9cf90e66883 Decode MP3 in ADU format
rtognimp
parents: 2423
diff changeset
2583 };
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3776
diff changeset
2584 #endif
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3776
diff changeset
2585 #ifdef CONFIG_MP3ON4_DECODER
2507
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2586 AVCodec mp3on4_decoder =
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2587 {
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2588 "mp3on4",
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2589 CODEC_TYPE_AUDIO,
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2590 CODEC_ID_MP3ON4,
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2591 sizeof(MP3On4DecodeContext),
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2592 decode_init_mp3on4,
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2593 NULL,
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2594 decode_close_mp3on4,
0334caf0f0ce Multichannel mp3 in mp4 support ISO/IEC 14496-3:2001/FPDAM 3 (MP3onMP4)
rtognimp
parents: 2496
diff changeset
2595 decode_frame_mp3on4,
4203
14250f6ff483 reset internal buffer during seeking
michael
parents: 4202
diff changeset
2596 .flush= flush,
7040
e943e1409077 Make AVCodec long_names definition conditional depending on CONFIG_SMALL.
stefano
parents: 6712
diff changeset
2597 .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
2598 };
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3776
diff changeset
2599 #endif