annotate libfaad2/hcr.c @ 12929:e31bab90b91c

Preliminary Support for building MPlayer with Intel C++ compiler. Still needs some work to use the proper optimization parameters. I haven't yet fixed the loader/dmo/dshow code so compile those dirs using make -C loader CC=gcc [...] for the meantime. To try use CC=icc ./configure with ICC 8.0 or later.
author atmos4
date Mon, 02 Aug 2004 04:24:36 +0000
parents d81145997036
children 6d50ef45a058
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
1 /*
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
3 ** Copyright (C) 2002-2004 A. Kurpiers
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
4 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
5 ** This program is free software; you can redistribute it and/or modify
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
6 ** it under the terms of the GNU General Public License as published by
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
7 ** the Free Software Foundation; either version 2 of the License, or
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
8 ** (at your option) any later version.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
9 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
10 ** This program is distributed in the hope that it will be useful,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
11 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
12 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
13 ** GNU General Public License for more details.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
14 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
15 ** You should have received a copy of the GNU General Public License
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
16 ** along with this program; if not, write to the Free Software
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
18 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
19 ** Any non-GPL usage of this software or parts of this software is strictly
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
20 ** forbidden.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
21 **
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
22 ** Commercial non-GPL licensing of this software is possible.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
24 **
12625
d81145997036 More information about modifications to comply more closely with GPL 2a.
diego
parents: 12527
diff changeset
25 ** Initially modified for use with MPlayer by Arpad Gereöffy on 2003/08/30
d81145997036 More information about modifications to comply more closely with GPL 2a.
diego
parents: 12527
diff changeset
26 ** $Id: hcr.c,v 1.3 2004/06/02 22:59:03 diego Exp $
d81145997036 More information about modifications to comply more closely with GPL 2a.
diego
parents: 12527
diff changeset
27 ** detailed CVS changelog at http://www.mplayerhq.hu/cgi-bin/cvsweb.cgi/main/
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
28 **/
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
29
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
30 #include "common.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
31 #include "structs.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
32
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
33 #include <stdlib.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
34 #include <string.h>
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
35
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
36 #include "syntax.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
37 #include "specrec.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
38 #include "bits.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
39 #include "pulse.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
40 #include "analysis.h"
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
41 #include "bits.h"
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
42 #include "huffman.h"
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
43
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
44 /* Implements the HCR11 tool as described in ISO/IEC 14496-3/Amd.1, 8.5.3.3 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
45
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
46 #ifdef ERROR_RESILIENCE
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
47
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
48 /* rewind len (max. 32) bits so that the MSB becomes LSB */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
49
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
50 static uint32_t rewind_word( uint32_t W, uint8_t len)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
51 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
52 uint8_t i;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
53 uint32_t tmp_W=0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
54
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
55 for ( i=0; i<len; i++ )
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
56 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
57 tmp_W<<=1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
58 if (W & (1<<i)) tmp_W |= 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
59 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
60 return tmp_W;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
61 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
62
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
63 static void rewind_lword( uint32_t *highW, uint32_t *lowW, uint8_t len)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
64 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
65 uint32_t tmp_lW=0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
66
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
67 if (len > 32)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
68 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
69 tmp_lW = rewind_word( (*highW << (64-len)) | (*lowW >> (len-32)), 32);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
70 *highW = rewind_word( *lowW << (64-len) , 32);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
71 *lowW = tmp_lW;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
72 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
73 *highW = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
74 *lowW = rewind_word( *lowW, len);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
75 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
76 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
77
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
78 /* Takes a codeword as stored in r, rewinds the remaining bits and stores it back */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
79 static void rewind_bits(bits_t * r)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
80 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
81 uint32_t hw, lw;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
82
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
83 if (r->len == 0) return;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
84
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
85 if (r->len >32)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
86 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
87 lw = r->bufa;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
88 hw = r->bufb & (0xFFFFFFFF >> (64 - r->len));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
89 rewind_lword( &hw, &lw, r->len );
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
90 r->bufa = lw;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
91 r->bufb = hw;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
92
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
93 } else {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
94 lw = showbits_hcr(r, r->len );
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
95 r->bufa = rewind_word( lw, r->len);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
96 r->bufb = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
97 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
98 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
99
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
100 /* takes codewords from a and b, concatenate them and store them in b */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
101 static void concat_bits( bits_t * a, bits_t * b)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
102 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
103 uint32_t hwa, lwa, hwb, lwb;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
104
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
105 if (a->len == 0) return;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
106
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
107 if (a->len >32)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
108 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
109 lwa = a->bufa;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
110 hwa = a->bufb & (0xFFFFFFFF >> (64 - a->len));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
111 } else {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
112 lwa = showbits_hcr(a, a->len );
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
113 hwa = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
114 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
115 if (b->len >=32) {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
116 lwb = b->bufa;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
117 hwb = (b->bufb & (0xFFFFFFFF >> (64 - b->len)) ) | ( lwa << (b->len - 32));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
118 } else {
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
119 lwb = showbits_hcr(b, b->len ) | (lwa << (b->len));
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
120 hwb = (lwa >> (32 - b->len)) | (hwa << (b->len));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
121 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
122
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
123 b->bufa = lwb;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
124 b->bufb = hwb;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
125 b->len += a->len;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
126 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
127
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
128 /* 8.5.3.3.1 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
129
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
130 static const uint8_t PresortedCodebook_VCB11[] = { 11, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16, 9, 7, 5, 3, 1};
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
131 static const uint8_t PresortedCodebook[] = { 11, 9, 7, 5, 3, 1};
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
132
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
133 static const uint8_t maxCwLen[32] = {0, 11, 9, 20, 16, 13, 11, 14, 12, 17, 14, 49,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
134 0, 0, 0, 0, 14, 17, 21, 21, 25, 25, 29, 29, 29, 29, 33, 33, 33, 37, 37, 41};
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
135
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
136 typedef struct
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
137 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
138 bits_t bits;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
139 uint8_t decoded;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
140 uint16_t sp_offset;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
141 uint8_t cb;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
142 } codeword_state;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
143
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
144
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
145 #define segmentWidth( codebook ) min( maxCwLen[codebook], ics->length_of_longest_codeword )
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
146
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
147 uint8_t reordered_spectral_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld,
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
148 int16_t *spectral_data)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
149 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
150 uint16_t sp_offset[8];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
151 uint16_t g,i, presort;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
152 uint16_t NrCodeWords=0, numberOfSegments=0, BitsRead=0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
153 uint8_t numberOfSets, set;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
154 codeword_state Codewords[ 1024 ]; // FIXME max length? PCWs are not stored, so index is Codewordnr - numberOfSegments!, maybe malloc()?
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
155 bits_t Segment[ 512 ];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
156
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
157 uint8_t PCW_decoded=0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
158 uint16_t nshort = hDecoder->frameLength/8;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
159
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
160
12527
4a370c80fe5c update to the 2.0 release of faad, patch by adland
diego
parents: 10989
diff changeset
161 /*memset (spectral_data, 0, hDecoder->frameLength*sizeof(uint16_t));*/
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
162
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
163 if (ics->length_of_reordered_spectral_data == 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
164 return 0; /* nothing to do */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
165
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
166 /* if we have a corrupted bitstream this can happen... */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
167 if ((ics->length_of_longest_codeword == 0) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
168 (ics->length_of_reordered_spectral_data <
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
169 ics->length_of_longest_codeword) ||
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
170 (ics->max_sfb == 0))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
171 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
172 return 10; /* this is not good... */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
173 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
174
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
175 /* store the offset into the spectral data for all the window groups because we can't do it later */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
176
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
177 sp_offset[0] = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
178 for (g=1; g < ics->num_window_groups; g++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
179 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
180 sp_offset[g] = sp_offset[g-1] + nshort*ics->window_group_length[g-1];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
181 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
182
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
183 /* All data is sorted according to the codebook used */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
184 for (presort = 0; presort < (hDecoder->aacSectionDataResilienceFlag ? 22 : 6); presort++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
185 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
186 uint8_t sfb;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
187
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
188 /* next codebook that has to be processed according to presorting */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
189 uint8_t nextCB = hDecoder->aacSectionDataResilienceFlag ? PresortedCodebook_VCB11[ presort ] : PresortedCodebook[ presort ];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
190
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
191 /* Data belonging to the same spectral unit and having the same codebook comes in consecutive codewords.
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
192 This is done by scanning all sfbs for possible codewords. For sfbs with more than 4 elements this has to be
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
193 repeated */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
194
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
195 for (sfb=0; sfb<ics->max_sfb; sfb ++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
196 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
197 uint8_t sect_cb, w;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
198
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
199 for (w=0; w< (ics->swb_offset[sfb+1] - ics->swb_offset[sfb]); w+=4)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
200 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
201 for(g = 0; g < ics->num_window_groups; g++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
202 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
203 for (i = 0; i < ics->num_sec[g]; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
204 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
205 sect_cb = ics->sect_cb[g][i];
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
206
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
207 if (
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
208 /* process only sections that are due now */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
209 (( sect_cb == nextCB ) || (( nextCB < ESC_HCB ) && ( sect_cb == nextCB+1)) ) &&
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
210
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
211 /* process only sfb's that are due now */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
212 ((ics->sect_start[g][i] <= sfb) && (ics->sect_end[g][i] > sfb))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
213 )
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
214 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
215 if ((sect_cb != ZERO_HCB) &&
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
216 (sect_cb != NOISE_HCB) &&
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
217 (sect_cb != INTENSITY_HCB) &&
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
218 (sect_cb != INTENSITY_HCB2))
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
219 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
220 uint8_t inc = (sect_cb < FIRST_PAIR_HCB) ? QUAD_LEN : PAIR_LEN;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
221 uint16_t k;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
222
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
223 uint32_t hw, lw;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
224
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
225 for (k=0; (k < (4/inc)*ics->window_group_length[g]) &&
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
226 ( (k+w*ics->window_group_length[g]/inc) < (ics->sect_sfb_offset[g][sfb+1] - ics->sect_sfb_offset[g][sfb])); k++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
227 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
228 uint16_t sp = sp_offset[g] + ics->sect_sfb_offset[g][sfb] + inc*(k+w*ics->window_group_length[g]/inc);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
229
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
230 if (!PCW_decoded)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
231 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
232 /* if we haven't yet read until the end of the buffer, we can directly decode the so-called PCWs */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
233 if ((BitsRead + segmentWidth( sect_cb ))<= ics->length_of_reordered_spectral_data)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
234 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
235 Segment[ numberOfSegments ].len = segmentWidth( sect_cb );
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
236
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
237 if (segmentWidth( sect_cb ) > 32)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
238 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
239 Segment[ numberOfSegments ].bufb = faad_showbits(ld, segmentWidth( sect_cb ) - 32);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
240 faad_flushbits(ld, segmentWidth( sect_cb) - 32);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
241 Segment[ numberOfSegments ].bufa = faad_showbits(ld, 32),
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
242 faad_flushbits(ld, 32 );
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
243
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
244 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
245 Segment[ numberOfSegments ].bufa = faad_showbits(ld, segmentWidth( sect_cb ));
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
246 Segment[ numberOfSegments ].bufb = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
247 faad_flushbits(ld, segmentWidth( sect_cb) );
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
248 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
249
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
250 huffman_spectral_data_2(sect_cb, &Segment[ numberOfSegments ], &spectral_data[sp]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
251
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
252 BitsRead += segmentWidth( sect_cb );
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
253
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
254 /* skip to next segment, but store left bits in new buffer */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
255 rewind_bits( &Segment[ numberOfSegments ]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
256
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
257 numberOfSegments++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
258 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
259
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
260 /* the last segment is extended until length_of_reordered_spectral_data */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
261
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
262 if (BitsRead < ics->length_of_reordered_spectral_data)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
263 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
264
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
265 uint8_t additional_bits = (ics->length_of_reordered_spectral_data - BitsRead);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
266
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
267 if ( additional_bits > 32)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
268 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
269 hw = faad_showbits(ld, additional_bits - 32);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
270 faad_flushbits(ld, additional_bits - 32);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
271 lw = faad_showbits(ld, 32);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
272 faad_flushbits(ld, 32 );
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
273 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
274 lw = faad_showbits(ld, additional_bits);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
275 hw = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
276 faad_flushbits(ld, additional_bits );
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
277 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
278 rewind_lword( &hw, &lw, additional_bits + Segment[ numberOfSegments-1 ].len );
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
279 if (Segment[ numberOfSegments-1 ].len > 32)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
280 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
281 Segment[ numberOfSegments-1 ].bufb = hw +
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
282 showbits_hcr(&Segment[ numberOfSegments-1 ], Segment[ numberOfSegments-1 ].len - 32);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
283 Segment[ numberOfSegments-1 ].bufa = lw +
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
284 showbits_hcr(&Segment[ numberOfSegments-1 ], 32);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
285 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
286 Segment[ numberOfSegments-1 ].bufa = lw +
10989
3185f64f6350 synced with current cvs
alex
parents: 10725
diff changeset
287 showbits_hcr(&Segment[ numberOfSegments-1 ], Segment[ numberOfSegments-1 ].len);
10725
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
288 Segment[ numberOfSegments-1 ].bufb = hw;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
289 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
290 Segment[ numberOfSegments-1 ].len += additional_bits;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
291 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
292 BitsRead = ics->length_of_reordered_spectral_data;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
293 PCW_decoded = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
294
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
295 Codewords[ 0 ].sp_offset = sp;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
296 Codewords[ 0 ].cb = sect_cb;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
297 Codewords[ 0 ].decoded = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
298 Codewords[ 0 ].bits.len = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
299 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
300 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
301 Codewords[ NrCodeWords - numberOfSegments ].sp_offset = sp;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
302 Codewords[ NrCodeWords - numberOfSegments ].cb = sect_cb;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
303 Codewords[ NrCodeWords - numberOfSegments ].decoded = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
304 Codewords[ NrCodeWords - numberOfSegments ].bits.len = 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
305
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
306 } /* PCW decoded */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
307 NrCodeWords++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
308 } /* of k */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
309 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
310 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
311 } /* of i */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
312 } /* of g */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
313 } /* of w */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
314 } /* of sfb */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
315 } /* of presort */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
316
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
317 /* Avoid divide by zero */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
318 if (numberOfSegments == 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
319 return 10; /* this is not good... */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
320
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
321 numberOfSets = NrCodeWords / numberOfSegments;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
322
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
323 /* second step: decode nonPCWs */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
324
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
325 for (set = 1; set <= numberOfSets; set++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
326 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
327 uint16_t trial;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
328
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
329 for (trial = 0; trial < numberOfSegments; trial++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
330 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
331 uint16_t codewordBase;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
332 uint16_t set_decoded=numberOfSegments;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
333
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
334 if (set == numberOfSets)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
335 set_decoded = NrCodeWords - set*numberOfSegments; /* last set is shorter than the rest */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
336
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
337 for (codewordBase = 0; codewordBase < numberOfSegments; codewordBase++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
338 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
339 uint16_t segment_index = (trial + codewordBase) % numberOfSegments;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
340 uint16_t codeword_index = codewordBase + set*numberOfSegments - numberOfSegments;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
341
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
342 if ((codeword_index + numberOfSegments) >= NrCodeWords)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
343 break;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
344 if (!Codewords[ codeword_index ].decoded)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
345 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
346 if ( Segment[ segment_index ].len > 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
347 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
348 uint8_t tmplen;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
349
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
350 if (Codewords[ codeword_index ].bits.len != 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
351 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
352 /* on the first trial the data is only stored in Segment[], not in Codewords[].
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
353 On next trials first collect the data stored for this codeword and
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
354 concatenate the new data from Segment[] */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
355
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
356 concat_bits( &Codewords[ codeword_index ].bits, &Segment[ segment_index ]);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
357 /* Now everthing is stored in Segment[] */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
358 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
359 tmplen = Segment[ segment_index ].len;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
360 if ( huffman_spectral_data_2(Codewords[ codeword_index ].cb, &Segment[ segment_index ],
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
361 &spectral_data[ Codewords[ codeword_index ].sp_offset ]) >=0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
362 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
363 /* CW did fit into segment */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
364
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
365 Codewords[ codeword_index ].decoded = 1;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
366 set_decoded--;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
367 } else {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
368
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
369 /* CW did not fit, so store for later use */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
370
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
371 Codewords[ codeword_index ].bits.len = tmplen;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
372 Codewords[ codeword_index ].bits.bufa = Segment[ segment_index ].bufa;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
373 Codewords[ codeword_index ].bits.bufb = Segment[ segment_index ].bufb;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
374 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
375 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
376 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
377 } /* of codewordBase */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
378
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
379 if (set_decoded == 0) break; /* no undecoded codewords left in this set */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
380
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
381 } /* of trial */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
382
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
383 /* rewind all bits in remaining segments with len>0 */
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
384 for (i=0; i < numberOfSegments; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
385 rewind_bits( &Segment[ i ] );
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
386 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
387
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
388 #if 0
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
389 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
390 int i, r=0, c=0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
391 for (i=0; i< numberOfSegments; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
392 r += Segment[ i ].len;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
393 if (r != 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
394 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
395 printf("reordered_spectral_data: %d bits remaining!\n", r);
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
396 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
397 for (i=0; i< NrCodeWords - numberOfSegments; i++)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
398 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
399 if (Codewords[ i ].decoded == 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
400 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
401 c++;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
402 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
403 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
404 if (c != 0)
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
405 {
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
406 printf("reordered_spectral_data: %d Undecoded Codewords remaining!\n",c );
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
407 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
408 if ((r !=0) || (c!=0)) return 10;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
409 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
410 #endif
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
411
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
412 return 0;
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
413 }
e989150f8216 libfaad2 v2.0rc1 imported
arpi
parents:
diff changeset
414 #endif