History

Stability fixes

menno committed 22 years ago

Commit dcebb7e1 parent 394d1b717 files · +287 −117Browse files

Unified · Split

17 files
  1. libfaad/bits.c +8 −2
  2. libfaad/bits.h +2 −2
  3. libfaad/decoder.c +30 −6
  4. libfaad/error.c +10 −3
  5. libfaad/error.h +2 −2
  6. libfaad/huffman.c +1 −9
  7. libfaad/is.c +1 −1
  8. libfaad/rvlc.c +1 −1
  9. libfaad/sbr_dec.c +34 −34
  10. libfaad/sbr_dec.h +5 −5
  11. libfaad/sbr_fbt.c +121 −8
  12. libfaad/sbr_fbt.h +5 −5
  13. libfaad/sbr_syntax.c +16 −10
  14. libfaad/specrec.c +24 −17
  15. libfaad/structs.h +4 −3
  16. libfaad/syntax.c +20 −7
  17. libfaad/syntax.h +3 −2
libfaad/bits.c+8−2
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 ** Commercial non-GPL licensing of this software is possible.
2323 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
2424 **
25−** $Id: bits.c,v 1.34 2004/01/14 20:32:30 menno Exp $
25+** $Id: bits.c,v 1.35 2004/01/16 20:20:32 menno Exp $
2626 **/
2727
2828 #include "common.h"
@@ -74,7 +74,13 @@ void faad_initbits(bitfile *ld, const void *_buffer, const uint32_t buffer_size) · 45 unmodified lines
7474 void faad_endbits(bitfile *ld)
7575 {
7676 if (ld)
77− if (ld->buffer) faad_free(ld->buffer);
77+ {
78+ if (ld->buffer)
79+ {
80+ faad_free(ld->buffer);
81+ ld->buffer = NULL;
82+ }
83+ }
7884 }
7985
8086 uint32_t faad_get_processed_bits(bitfile *ld)
libfaad/bits.h+2−2
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 ** Commercial non-GPL licensing of this software is possible.
2323 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
2424 **
25−** $Id: bits.h,v 1.33 2004/01/14 20:36:22 menno Exp $
25+** $Id: bits.h,v 1.34 2004/01/16 20:20:32 menno Exp $
2626 **/
2727
2828 #ifndef __BITS_H__
@@ -178,7 +178,7 @@ static INLINE uint8_t faad_get1bit(bitfile *ld DEBUGDEC) · 149 unmodified lines
178178 r = (uint8_t)(ld->bufb >> 31);
179179 faad_flushbits_ex(ld, 1);
180180 #else
181− r = faad_getbits(ld, 1);
181+ r = (uint8_t)faad_getbits(ld, 1);
182182 #endif
183183 return r;
184184 }
libfaad/decoder.c+30−6
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 ** Commercial non-GPL licensing of this software is possible.
2323 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
2424 **
25−** $Id: decoder.c,v 1.91 2004/01/14 20:32:30 menno Exp $
25+** $Id: decoder.c,v 1.92 2004/01/16 20:20:32 menno Exp $
2626 **/
2727
2828 #include "common.h"
@@ -128,7 +128,7 @@ faacDecHandle FAADAPI faacDecOpen(void) · 99 unmodified lines
128128 }
129129
130130 #ifdef SBR_DEC
131− for (i = 0; i < 32; i++)
131+ for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++)
132132 {
133133 hDecoder->sbr[i] = NULL;
134134 }
@@ -441,7 +441,7 @@ int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, · 306 unmodified lines
441441 }
442442
443443 #ifdef SBR_DEC
444− for (i = 0; i < 32; i++)
444+ for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++)
445445 {
446446 if (hDecoder->sbr[i])
447447 sbrDecodeEnd(hDecoder->sbr[i]);
@@ -497,7 +497,7 @@ void FAADAPI faacDecClose(faacDecHandle hDecoder) · 49 unmodified lines
497497 if (hDecoder->sample_buffer) faad_free(hDecoder->sample_buffer);
498498
499499 #ifdef SBR_DEC
500− for (i = 0; i < 32; i++)
500+ for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++)
501501 {
502502 if (hDecoder->sbr[i])
503503 sbrDecodeEnd(hDecoder->sbr[i]);
@@ -803,6 +803,13 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 299 unmodified lines
803803 if (hInfo->error > 0)
804804 goto error;
805805
806+ /* safety check */
807+ if (channels == 0 || channels > MAX_CHANNELS)
808+ {
809+ /* invalid number of channels */
810+ hInfo->error = 12;
811+ goto error;
812+ }
806813
807814 /* no more bit reading after this */
808815 bitsconsumed = faad_get_processed_bits(&ld);
@@ -862,7 +869,8 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 53 unmodified lines
862869 }
863870
864871 /* allocate the buffer for the final samples */
865− if (hDecoder->sample_buffer == NULL)
872+ if ((hDecoder->sample_buffer == NULL) ||
873+ (hDecoder->alloced_channels != output_channels))
866874 {
867875 static const uint8_t str[] = { sizeof(int16_t), sizeof(int32_t), sizeof(int32_t),
868876 sizeof(float32_t), sizeof(double), sizeof(int16_t), sizeof(int16_t),
@@ -873,7 +881,11 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 4 unmodified lines
873881 if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
874882 stride = 2 * stride;
875883 #endif
876− hDecoder->sample_buffer = faad_malloc(frame_len*channels*stride);
884+ if (hDecoder->sample_buffer)
885+ faad_free(hDecoder->sample_buffer);
886+ hDecoder->sample_buffer = NULL;
887+ hDecoder->sample_buffer = faad_malloc(frame_len*output_channels*stride);
888+ hDecoder->alloced_channels = output_channels;
877889 }
878890
879891 sample_buffer = hDecoder->sample_buffer;
@@ -881,11 +893,23 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 1 unmodified line
881893 #ifdef SBR_DEC
882894 if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
883895 {
896+ uint8_t ele;
897+
884898 /* this data is different when SBR is used or when the data is upsampled */
885899 frame_len *= 2;
886900 hInfo->samples *= 2;
887901 hInfo->samplerate *= 2;
888902
903+ /* check if every element was provided with SBR data */
904+ for (ele = 0; ele < hDecoder->fr_ch_ele; ele++)
905+ {
906+ if (hDecoder->sbr[ele] == NULL)
907+ {
908+ hInfo->error = 25;
909+ goto error;
910+ }
911+ }
912+
889913 /* sbr */
890914 if (hDecoder->sbr_present_flag == 1)
891915 {
libfaad/error.c+10−3
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 ** Commercial non-GPL licensing of this software is possible.
2323 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
2424 **
25−** $Id: error.c,v 1.19 2004/01/05 14:05:11 menno Exp $
25+** $Id: error.c,v 1.20 2004/01/16 20:20:32 menno Exp $
2626 **/
2727
2828 #include "common.h"
@@ -41,12 +41,19 @@ int8_t *err_msg[] = { · 12 unmodified lines
4141 "Error decoding huffman scalefactor (bitstream error)",
4242 "Error decoding huffman codeword (bitstream error)",
4343 "Non existent huffman codebook number found",
44− "Maximum number of channels exceeded",
44+ "Invalid number of channels",
4545 "Maximum number of bitstream elements exceeded",
4646 "Input data buffer too small",
4747 "Array index out of range",
4848 "Maximum number of scalefactor bands exceeded",
4949 "Quantised value out of range",
50− "LTP lag out of range"
50+ "LTP lag out of range",
51+ "Invalid SBR parameter decoded",
52+ "SBR called without being initialised",
53+ "Unexpected channel configuration change",
54+ "Error in program_config_element",
55+ "First SBR frame is not the same as first AAC frame",
56+ "Unexpected fill element with SBR data",
57+ "Not all elements were provided with SBR data"
5158 };
5259
libfaad/error.h+2−2
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 ** Commercial non-GPL licensing of this software is possible.
2323 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
2424 **
25−** $Id: error.h,v 1.14 2004/01/05 14:05:11 menno Exp $
25+** $Id: error.h,v 1.15 2004/01/16 20:20:32 menno Exp $
2626 **/
2727
2828 #ifndef __ERROR_H__
@@ -32,7 +32,7 @@ · 3 unmodified lines
3232 extern "C" {
3333 #endif
3434
35−#define NUM_ERROR_MESSAGES 19
35+#define NUM_ERROR_MESSAGES 26
3636 extern int8_t *err_msg[];
3737
3838 #ifdef __cplusplus
libfaad/huffman.c+1−9
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 ** Commercial non-GPL licensing of this software is possible.
2323 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
2424 **
25−** $Id: huffman.c,v 1.14 2004/01/14 20:39:59 menno Exp $
25+** $Id: huffman.c,v 1.15 2004/01/16 20:20:32 menno Exp $
2626 **/
2727
2828 #include "common.h"
@@ -168,12 +168,8 @@ static uint8_t huffman_2step_quad(uint8_t cb, bitfile *ld, int16_t *sp) · 139 unmodified lines
168168 {
169169 /* we know for sure it's more than hcbN[cb] bits long */
170170 faad_flushbits(ld, hcbN[cb]);
171−#if 1
172171 offset += (uint16_t)faad_showbits(ld, extra_bits);
173172 faad_flushbits(ld, hcb_2_quad_table[cb][offset].bits - hcbN[cb]);
174−#else
175− offset += (uint16_t)faad_getbits(ld, extra_bits);
176−#endif
177173 } else {
178174 faad_flushbits(ld, hcb_2_quad_table[cb][offset].bits);
179175 }
@@ -215,12 +211,8 @@ static uint8_t huffman_2step_pair(uint8_t cb, bitfile *ld, int16_t *sp) · 35 unmodified lines
215211 {
216212 /* we know for sure it's more than hcbN[cb] bits long */
217213 faad_flushbits(ld, hcbN[cb]);
218−#if 1
219214 offset += (uint16_t)faad_showbits(ld, extra_bits);
220215 faad_flushbits(ld, hcb_2_pair_table[cb][offset].bits - hcbN[cb]);
221−#else
222− offset += (uint16_t)faad_getbits(ld, extra_bits);
223−#endif
224216 } else {
225217 faad_flushbits(ld, hcb_2_pair_table[cb][offset].bits);
226218 }
libfaad/is.c+1−1
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 ** Commercial non-GPL licensing of this software is possible.
2323 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
2424 **
25−** $Id: is.c,v 1.19 2004/01/05 14:05:12 menno Exp $
25+** $Id: is.c,v 1.21 2004/02/26 09:29:27 menno Exp $
2626 **/
2727
2828 #include "common.h"
libfaad/rvlc.c+1−1
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 ** Commercial non-GPL licensing of this software is possible.
2323 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
2424 **
25−** $Id: rvlc.c,v 1.13 2004/01/05 14:05:12 menno Exp $
25+** $Id: rvlc.c,v 1.17 2004/09/04 14:56:28 menno Exp $
2626 **/
2727
2828 /* RVLC scalefactor decoding
libfaad/sbr_dec.c+34−34
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 ** Commercial non-GPL licensing of this software is possible.
2323 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
2424 **
25−** $Id: sbr_dec.c,v 1.24 2004/01/14 20:32:30 menno Exp $
25+** $Id: sbr_dec.c,v 1.25 2004/01/16 20:20:32 menno Exp $
2626 **/
2727
2828
@@ -42,7 +42,7 @@ · 13 unmodified lines
4242 #include "sbr_hfadj.h"
4343
4444 /* static function declarations */
45−static void sbr_save_prev_data(sbr_info *sbr, uint8_t ch);
45+static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch);
4646
4747 sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac,
4848 uint32_t sample_rate
@@ -120,7 +120,7 @@ void sbrDecodeEnd(sbr_info *sbr) · 71 unmodified lines
120120 }
121121 }
122122
123−static void sbr_save_prev_data(sbr_info *sbr, uint8_t ch)
123+static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch)
124124 {
125125 uint8_t i;
126126
@@ -130,21 +130,14 @@ static void sbr_save_prev_data(sbr_info *sbr, uint8_t ch) · 3 unmodified lines
130130 sbr->L_E_prev[ch] = sbr->L_E[ch];
131131
132132 /* sbr->L_E[ch] can become 0 on files with bit errors */
133− if (sbr->L_E[ch] > 0)
133+ if (sbr->L_E[ch] <= 0)
134+ return 19;
135+
136+ sbr->f_prev[ch] = sbr->f[ch][sbr->L_E[ch] - 1];
137+ for (i = 0; i < 64; i++)
134138 {
135− sbr->f_prev[ch] = sbr->f[ch][sbr->L_E[ch] - 1];
136− for (i = 0; i < 64; i++)
137− {
138− sbr->E_prev[ch][i] = sbr->E[ch][i][sbr->L_E[ch] - 1];
139− sbr->Q_prev[ch][i] = sbr->Q[ch][i][sbr->L_Q[ch] - 1];
140− }
141− } else {
142− sbr->f_prev[ch] = 0;
143− for (i = 0; i < 64; i++)
144− {
145− sbr->E_prev[ch][i] = 0;
146− sbr->Q_prev[ch][i] = 0;
147− }
139+ sbr->E_prev[ch][i] = sbr->E[ch][i][sbr->L_E[ch] - 1];
140+ sbr->Q_prev[ch][i] = sbr->Q[ch][i][sbr->L_Q[ch] - 1];
148141 }
149142
150143 for (i = 0; i < 64; i++)
@@ -157,6 +150,8 @@ static void sbr_save_prev_data(sbr_info *sbr, uint8_t ch) · 6 unmodified lines
157150 sbr->prevEnvIsShort[ch] = 0;
158151 else
159152 sbr->prevEnvIsShort[ch] = -1;
153+
154+ return 0;
160155 }
161156
162157 static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf,
@@ -252,10 +247,6 @@ static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, · 89 unmodified lines
252247 else
253248 xover_band = sbr->kx;
254249
255− /* kx can be > 32 in cases of bit errors */
256− /* TODO: should be checked somewhere else */
257− xover_band = min(xover_band, 32);
258−
259250 for (k = 0; k < xover_band; k++)
260251 {
261252 QMF_RE(X[l][k]) = QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]);
@@ -290,17 +281,18 @@ static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, · 28 unmodified lines
290281 }
291282 }
292283
293−void sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan,
294− const uint8_t just_seeked, const uint8_t upsample_only)
284+uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan,
285+ const uint8_t just_seeked, const uint8_t upsample_only)
295286 {
296287 uint8_t dont_process = 0;
288+ uint8_t ret = 0;
297289
298290 if (sbr == NULL)
299− return;
291+ return 20;
300292
301293 /* case can occur due to bit errors */
302294 if (sbr->id_aac != ID_CPE)
303− return;
295+ return 21;
304296
305297 if (sbr->ret || (sbr->header_count == 0))
306298 {
@@ -325,26 +317,31 @@ void sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, · 18 unmodified lines
325317 if (sbr->bs_header_flag)
326318 sbr->just_seeked = 0;
327319
328− if (sbr->header_count != 0)
320+ if (sbr->header_count != 0 && sbr->ret == 0)
329321 {
330− sbr_save_prev_data(sbr, 0);
331− sbr_save_prev_data(sbr, 1);
322+ ret = sbr_save_prev_data(sbr, 0);
323+ if (ret) return ret;
324+ ret = sbr_save_prev_data(sbr, 1);
325+ if (ret) return ret;
332326 }
333327
334328 sbr->frame++;
329+
330+ return 0;
335331 }
336332
337−void sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel,
338− const uint8_t just_seeked, const uint8_t upsample_only)
333+uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel,
334+ const uint8_t just_seeked, const uint8_t upsample_only)
339335 {
340336 uint8_t dont_process = 0;
337+ uint8_t ret = 0;
341338
342339 if (sbr == NULL)
343− return;
340+ return 20;
344341
345342 /* case can occur due to bit errors */
346343 if (sbr->id_aac != ID_SCE && sbr->id_aac != ID_LFE)
347− return;
344+ return 21;
348345
349346 if (sbr->ret || (sbr->header_count == 0))
350347 {
@@ -368,12 +365,15 @@ void sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel, · 17 unmodified lines
368365 if (sbr->bs_header_flag)
369366 sbr->just_seeked = 0;
370367
371− if (sbr->header_count != 0)
368+ if (sbr->header_count != 0 && sbr->ret == 0)
372369 {
373− sbr_save_prev_data(sbr, 0);
370+ ret = sbr_save_prev_data(sbr, 0);
371+ if (ret) return ret;
374372 }
375373
376374 sbr->frame++;
375+
376+ return 0;
377377 }
378378
379379 #endif
libfaad/sbr_dec.h+5−5
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 ** Commercial non-GPL licensing of this software is possible.
2323 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
2424 **
25−** $Id: sbr_dec.h,v 1.18 2004/01/14 20:32:30 menno Exp $
25+** $Id: sbr_dec.h,v 1.19 2004/01/16 20:20:32 menno Exp $
2626 **/
2727
2828 #ifndef __SBR_DEC_H__
@@ -213,10 +213,10 @@ sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, · 184 unmodified lines
213213 );
214214 void sbrDecodeEnd(sbr_info *sbr);
215215
216−void sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan,
217− const uint8_t just_seeked, const uint8_t upsample_only);
218−void sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel,
219− const uint8_t just_seeked, const uint8_t upsample_only);
216+uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan,
217+ const uint8_t just_seeked, const uint8_t upsample_only);
218+uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel,
219+ const uint8_t just_seeked, const uint8_t upsample_only);
220220
221221
222222 #ifdef __cplusplus
libfaad/sbr_fbt.c+121−8
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 ** Commercial non-GPL licensing of this software is possible.
2323 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
2424 **
25−** $Id: sbr_fbt.c,v 1.9 2004/01/05 14:05:12 menno Exp $
25+** $Id: sbr_fbt.c,v 1.10 2004/01/16 20:20:32 menno Exp $
2626 **/
2727
2828 /* Calculate frequency band tables */
@@ -184,8 +184,8 @@ uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate, · 155 unmodified lines
184184
185185 version for bs_freq_scale = 0
186186 */
187−void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2,
188− uint8_t bs_alter_scale)
187+uint8_t master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2,
188+ uint8_t bs_alter_scale)
189189 {
190190 int8_t incr;
191191 uint8_t k;
@@ -197,7 +197,7 @@ void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, · 5 unmodified lines
197197 if (k2 <= k0)
198198 {
199199 sbr->N_master = 0;
200− return;
200+ return 0;
201201 }
202202
203203 dk = bs_alter_scale ? 2 : 1;
@@ -213,6 +213,8 @@ void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, · 9 unmodified lines
213213 }
214214 #endif
215215 nrBands = min(nrBands, 63);
216+ if (nrBands <= 0)
217+ return 1;
216218
217219 k2Achieved = k0 + nrBands * dk;
218220 k2Diff = k2 - k2Achieved;
@@ -247,6 +249,8 @@ void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, · 28 unmodified lines
247249 }
248250 printf("\n");
249251 #endif
252+
253+ return 0;
250254 }
251255
252256 /*
@@ -255,22 +259,93 @@ void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, · 2 unmodified lines
255259 */
256260 static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1)
257261 {
262+#ifdef FIXED_POINT
263+ /* table with log2() values */
264+ static const real_t log2Table[65] = {
265+ COEF_CONST(0.0), COEF_CONST(0.0), COEF_CONST(1.0000000000), COEF_CONST(1.5849625007),
266+ COEF_CONST(2.0000000000), COEF_CONST(2.3219280949), COEF_CONST(2.5849625007), COEF_CONST(2.8073549221),
267+ COEF_CONST(3.0000000000), COEF_CONST(3.1699250014), COEF_CONST(3.3219280949), COEF_CONST(3.4594316186),
268+ COEF_CONST(3.5849625007), COEF_CONST(3.7004397181), COEF_CONST(3.8073549221), COEF_CONST(3.9068905956),
269+ COEF_CONST(4.0000000000), COEF_CONST(4.0874628413), COEF_CONST(4.1699250014), COEF_CONST(4.2479275134),
270+ COEF_CONST(4.3219280949), COEF_CONST(4.3923174228), COEF_CONST(4.4594316186), COEF_CONST(4.5235619561),
271+ COEF_CONST(4.5849625007), COEF_CONST(4.6438561898), COEF_CONST(4.7004397181), COEF_CONST(4.7548875022),
272+ COEF_CONST(4.8073549221), COEF_CONST(4.8579809951), COEF_CONST(4.9068905956), COEF_CONST(4.9541963104),
273+ COEF_CONST(5.0000000000), COEF_CONST(5.0443941194), COEF_CONST(5.0874628413), COEF_CONST(5.1292830169),
274+ COEF_CONST(5.1699250014), COEF_CONST(5.2094533656), COEF_CONST(5.2479275134), COEF_CONST(5.2854022189),
275+ COEF_CONST(5.3219280949), COEF_CONST(5.3575520046), COEF_CONST(5.3923174228), COEF_CONST(5.4262647547),
276+ COEF_CONST(5.4594316186), COEF_CONST(5.4918530963), COEF_CONST(5.5235619561), COEF_CONST(5.5545888517),
277+ COEF_CONST(5.5849625007), COEF_CONST(5.6147098441), COEF_CONST(5.6438561898), COEF_CONST(5.6724253420),
278+ COEF_CONST(5.7004397181), COEF_CONST(5.7279204546), COEF_CONST(5.7548875022), COEF_CONST(5.7813597135),
279+ COEF_CONST(5.8073549221), COEF_CONST(5.8328900142), COEF_CONST(5.8579809951), COEF_CONST(5.8826430494),
280+ COEF_CONST(5.9068905956), COEF_CONST(5.9307373376), COEF_CONST(5.9541963104), COEF_CONST(5.9772799235),
281+ COEF_CONST(6.0)
282+ };
283+ real_t r0 = log2Table[a0]; /* coef */
284+ real_t r1 = log2Table[a1]; /* coef */
285+ real_t r2 = (r1 - r0); /* coef */
286+
287+ if (warp)
288+ r2 = MUL_C(r2, COEF_CONST(1.0/1.3));
289+
290+ /* convert r2 to real and then multiply and round */
291+ r2 = (r2 >> (COEF_BITS-REAL_BITS)) * bands + (1<<(REAL_BITS-1));
292+
293+ return (r2 >> REAL_BITS);
294+#else
258295 real_t div = (real_t)log(2.0);
259296 if (warp) div *= (real_t)1.3;
260297
261298 return (int32_t)(bands * log((float)a1/(float)a0)/div + 0.5);
299+#endif
262300 }
263301
264302 static real_t find_initial_power(uint8_t bands, uint8_t a0, uint8_t a1)
265303 {
304+#ifdef FIXED_POINT
305+ /* table with log() values */
306+ static const real_t logTable[65] = {
307+ COEF_CONST(0.0), COEF_CONST(0.0), COEF_CONST(0.6931471806), COEF_CONST(1.0986122887),
308+ COEF_CONST(1.3862943611), COEF_CONST(1.6094379124), COEF_CONST(1.7917594692), COEF_CONST(1.9459101491),
309+ COEF_CONST(2.0794415417), COEF_CONST(2.1972245773), COEF_CONST(2.3025850930), COEF_CONST(2.3978952728),
310+ COEF_CONST(2.4849066498), COEF_CONST(2.5649493575), COEF_CONST(2.6390573296), COEF_CONST(2.7080502011),
311+ COEF_CONST(2.7725887222), COEF_CONST(2.8332133441), COEF_CONST(2.8903717579), COEF_CONST(2.9444389792),
312+ COEF_CONST(2.9957322736), COEF_CONST(3.0445224377), COEF_CONST(3.0910424534), COEF_CONST(3.1354942159),
313+ COEF_CONST(3.1780538303), COEF_CONST(3.2188758249), COEF_CONST(3.2580965380), COEF_CONST(3.2958368660),
314+ COEF_CONST(3.3322045102), COEF_CONST(3.3672958300), COEF_CONST(3.4011973817), COEF_CONST(3.4339872045),
315+ COEF_CONST(3.4657359028), COEF_CONST(3.4965075615), COEF_CONST(3.5263605246), COEF_CONST(3.5553480615),
316+ COEF_CONST(3.5835189385), COEF_CONST(3.6109179126), COEF_CONST(3.6375861597), COEF_CONST(3.6635616461),
317+ COEF_CONST(3.6888794541), COEF_CONST(3.7135720667), COEF_CONST(3.7376696183), COEF_CONST(3.7612001157),
318+ COEF_CONST(3.7841896339), COEF_CONST(3.8066624898), COEF_CONST(3.8286413965), COEF_CONST(3.8501476017),
319+ COEF_CONST(3.8712010109), COEF_CONST(3.8918202981), COEF_CONST(3.9120230054), COEF_CONST(3.9318256327),
320+ COEF_CONST(3.9512437186), COEF_CONST(3.9702919136), COEF_CONST(3.9889840466), COEF_CONST(4.0073331852),
321+ COEF_CONST(4.0253516907), COEF_CONST(4.0430512678), COEF_CONST(4.0604430105), COEF_CONST(4.0775374439),
322+ COEF_CONST(4.0943445622), COEF_CONST(4.1108738642), COEF_CONST(4.1271343850), COEF_CONST(4.1431347264),
323+ COEF_CONST(4.158883083)
324+ };
325+ /* standard Taylor polynomial coefficients for exp(x) around 0 */
326+ /* a polynomial around x=1 is more precise, as most values are around 1.07,
327+ but this is just fine already */
328+ static const real_t c1 = COEF_CONST(1.0);
329+ static const real_t c2 = COEF_CONST(1.0/2.0);
330+ static const real_t c3 = COEF_CONST(1.0/6.0);
331+ static const real_t c4 = COEF_CONST(1.0/24.0);
332+
333+ real_t r0 = logTable[a0]; /* coef */
334+ real_t r1 = logTable[a1]; /* coef */
335+ real_t r2 = (r1 - r0) / bands; /* coef */
336+ real_t rexp = c1 + MUL_C((c1 + MUL_C((c2 + MUL_C((c3 + MUL_C(c4,r2)), r2)), r2)), r2);
337+
338+ return (rexp >> (COEF_BITS-REAL_BITS)); /* real */
339+#else
266340 return (real_t)pow((real_t)a1/(real_t)a0, 1.0/(real_t)bands);
341+#endif
267342 }
268343
269344 /*
270345 version for bs_freq_scale > 0
271346 */
272−void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2,
273− uint8_t bs_freq_scale, uint8_t bs_alter_scale)
347+uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2,
348+ uint8_t bs_freq_scale, uint8_t bs_alter_scale)
274349 {
275350 uint8_t k, bands, twoRegions;
276351 uint8_t k1;
@@ -285,12 +360,16 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 8 unmodified lines
285360 if (k2 <= k0)
286361 {
287362 sbr->N_master = 0;
288− return;
363+ return 0;
289364 }
290365
291366 bands = temp1[bs_freq_scale-1];
292367
368+#ifdef FIXED_POINT
369+ if (REAL_CONST(k2) > MUL_R(REAL_CONST(k0),REAL_CONST(2.2449)))
370+#else
293371 if ((float)k2/(float)k0 > 2.2449)
372+#endif
294373 {
295374 twoRegions = 1;
296375 k1 = k0 << 1;
@@ -301,15 +380,26 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 4 unmodified lines
301380
302381 nrBand0 = 2 * find_bands(0, bands, k0, k1);
303382 nrBand0 = min(nrBand0, 63);
383+ if (nrBand0 <= 0)
384+ return 1;
304385
305386 q = find_initial_power(nrBand0, k0, k1);
306387 qk = REAL_CONST(k0);
388+#ifdef FIXED_POINT
389+ A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS);
390+#else
307391 A_1 = (int32_t)(qk + .5);
392+#endif
308393 for (k = 0; k <= nrBand0; k++)
309394 {
310395 int32_t A_0 = A_1;
396+#ifdef FIXED_POINT
397+ qk = MUL_R(qk,q);
398+ A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS);
399+#else
311400 qk *= q;
312401 A_1 = (int32_t)(qk + 0.5);
402+#endif
313403 vDk0[k] = A_1 - A_0;
314404 }
315405
@@ -320,6 +410,8 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 4 unmodified lines
320410 for (k = 1; k <= nrBand0; k++)
321411 {
322412 vk0[k] = vk0[k-1] + vDk0[k-1];
413+ if (vDk0[k-1] == 0)
414+ return 1;
323415 }
324416
325417 if (!twoRegions)
@@ -329,7 +421,7 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 3 unmodified lines
329421
330422 sbr->N_master = nrBand0;
331423 sbr->N_master = min(sbr->N_master, 64);
332− return;
424+ return 0;
333425 }
334426
335427 nrBand1 = 2 * find_bands(1 /* warped */, bands, k1, k2);
@@ -337,12 +429,21 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 1 unmodified line
337429
338430 q = find_initial_power(nrBand1, k1, k2);
339431 qk = REAL_CONST(k1);
432+#ifdef FIXED_POINT
433+ A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS);
434+#else
340435 A_1 = (int32_t)(qk + .5);
436+#endif
341437 for (k = 0; k <= nrBand1 - 1; k++)
342438 {
343439 int32_t A_0 = A_1;
440+#ifdef FIXED_POINT
441+ qk = MUL_R(qk,q);
442+ A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS);
443+#else
344444 qk *= q;
345445 A_1 = (int32_t)(qk + 0.5);
446+#endif
346447 vDk1[k] = A_1 - A_0;
347448 }
348449
@@ -363,6 +464,8 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 14 unmodified lines
363464 for (k = 1; k <= nrBand1; k++)
364465 {
365466 vk1[k] = vk1[k-1] + vDk1[k-1];
467+ if (vDk1[k-1] == 0)
468+ return 1;
366469 }
367470
368471 sbr->N_master = nrBand0 + nrBand1;
@@ -384,6 +487,8 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 15 unmodified lines
384487 }
385488 printf("\n");
386489 #endif
490+
491+ return 0;
387492 }
388493
389494 /* calculate the derived frequency border tables from f_master */
@@ -410,6 +515,10 @@ uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band, · 20 unmodified lines
410515
411516 sbr->M = sbr->f_table_res[HI_RES][sbr->N_high] - sbr->f_table_res[HI_RES][0];
412517 sbr->kx = sbr->f_table_res[HI_RES][0];
518+ if (sbr->kx > 32)
519+ return 1;
520+ if (sbr->kx + sbr->M > 64)
521+ return 1;
413522
414523 minus = (sbr->N_high & 1) ? 1 : 0;
415524
@@ -556,7 +665,11 @@ restart: · 140 unmodified lines
556665 #if 0
557666 nOctaves = REAL_CONST(log((float)limTable[k]/(float)limTable[k-1])/log(2.0));
558667 #endif
668+#ifdef FIXED_POINT
669+ nOctaves = SBR_DIV(REAL_CONST(limTable[k]),REAL_CONST(limTable[k-1]));
670+#else
559671 nOctaves = (real_t)limTable[k]/(real_t)limTable[k-1];
672+#endif
560673 else
561674 nOctaves = 0;
562675
libfaad/sbr_fbt.h+5−5
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 ** Commercial non-GPL licensing of this software is possible.
2323 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
2424 **
25−** $Id: sbr_fbt.h,v 1.9 2004/01/05 14:05:12 menno Exp $
25+** $Id: sbr_fbt.h,v 1.10 2004/01/16 20:20:32 menno Exp $
2626 **/
2727
2828 #ifndef __SBR_FBT_H__
@@ -36,10 +36,10 @@ uint8_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode, · 7 unmodified lines
3636 uint32_t sample_rate);
3737 uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate,
3838 uint8_t k0);
39−void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2,
40− uint8_t bs_alter_scale);
41−void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2,
42− uint8_t bs_freq_scale, uint8_t bs_alter_scale);
39+uint8_t master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2,
40+ uint8_t bs_alter_scale);
41+uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2,
42+ uint8_t bs_freq_scale, uint8_t bs_alter_scale);
4343 uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band,
4444 uint8_t k2);
4545 void limiter_frequency_table(sbr_info *sbr);
libfaad/sbr_syntax.c+16−10
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 ** Commercial non-GPL licensing of this software is possible.
2323 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
2424 **
25−** $Id: sbr_syntax.c,v 1.21 2004/01/13 14:24:10 menno Exp $
25+** $Id: sbr_syntax.c,v 1.22 2004/01/16 20:20:32 menno Exp $
2626 **/
2727
2828 #include "common.h"
@@ -105,7 +105,7 @@ static void sbr_reset(sbr_info *sbr) · 76 unmodified lines
105105 /* table 2 */
106106 uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt)
107107 {
108− uint8_t result;
108+ uint8_t result = 0;
109109 uint16_t num_align_bits = 0;
110110 uint16_t num_sbr_bits = (uint16_t)faad_get_processed_bits(ld);
111111
@@ -149,27 +149,30 @@ uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt) · 37 unmodified lines
149149 if (sbr->sample_rate >= 48000)
150150 {
151151 if ((k2 - sbr->k0) > 32)
152− return 1;
152+ result += 1;
153153 } else if (sbr->sample_rate <= 32000) {
154154 if ((k2 - sbr->k0) > 48)
155− return 1;
155+ result += 1;
156156 } else { /* (sbr->sample_rate == 44100) */
157157 if ((k2 - sbr->k0) > 45)
158− return 1;
158+ result += 1;
159159 }
160160
161161 if (sbr->bs_freq_scale == 0)
162162 {
163− master_frequency_table_fs0(sbr, sbr->k0, k2, sbr->bs_alter_scale);
163+ result += master_frequency_table_fs0(sbr, sbr->k0, k2,
164+ sbr->bs_alter_scale);
164165 } else {
165− master_frequency_table(sbr, sbr->k0, k2, sbr->bs_freq_scale,
166+ result += master_frequency_table(sbr, sbr->k0, k2, sbr->bs_freq_scale,
166167 sbr->bs_alter_scale);
167168 }
168− if ((result = derived_frequency_table(sbr, sbr->bs_xover_band, k2)) > 0)
169− return result;
169+ result += derived_frequency_table(sbr, sbr->bs_xover_band, k2);
170+
171+ result = (result > 0) ? 1 : 0;
170172 }
171173
172− result = sbr_data(ld, sbr);
174+ if (result == 0)
175+ result = sbr_data(ld, sbr);
173176 } else {
174177 result = 1;
175178 }
@@ -634,6 +637,9 @@ static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch) · 458 unmodified lines
634637 else
635638 sbr->L_E[ch] = min(bs_num_env, 4);
636639
640+ if (sbr->L_E[ch] <= 0)
641+ return 1;
642+
637643 if (sbr->L_E[ch] > 1)
638644 sbr->L_Q[ch] = 2;
639645 else
libfaad/specrec.c+24−17
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 ** Commercial non-GPL licensing of this software is possible.
2323 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
2424 **
25−** $Id: specrec.c,v 1.40 2004/01/14 20:32:30 menno Exp $
25+** $Id: specrec.c,v 1.41 2004/01/16 20:20:32 menno Exp $
2626 **/
2727
2828 /*
@@ -588,7 +588,8 @@ void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, · 559 unmodified lines
588588 {
589589 top = ics->sect_sfb_offset[g][sfb+1];
590590
591− /* this could be scalefactor for IS or PNS, those could be negative or bigger then 255??? */
591+ /* this could be scalefactor for IS or PNS, those can be negative or bigger then 255 */
592+ /* just ignore them */
592593 if (ics->scale_factors[g][sfb] < 0 || ics->scale_factors[g][sfb] > 255)
593594 {
594595 exp = 0;
@@ -790,12 +791,12 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, · 195 unmodified lines
790791 {
791792 mul = 1;
792793 #ifdef SBR_DEC
793− hDecoder->sbr_alloced = 0;
794+ hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0;
794795 if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
795796 {
796797 /* SBR requires 2 times as much output data */
797798 mul = 2;
798− hDecoder->sbr_alloced = 1;
799+ hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1;
799800 }
800801 #endif
801802 hDecoder->time_out[sce->channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t));
@@ -858,7 +859,7 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, · 56 unmodified lines
858859
859860 #ifdef SBR_DEC
860861 if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
861− && hDecoder->sbr_alloced)
862+ && hDecoder->sbr_alloced[hDecoder->fr_ch_ele])
862863 {
863864 uint8_t ele = hDecoder->fr_ch_ele;
864865 uint8_t ch = sce->channel;
@@ -874,11 +875,14 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, · 9 unmodified lines
874875 );
875876 }
876877
877− sbrDecodeSingleFrame(hDecoder->sbr[ele], hDecoder->time_out[ch],
878+ retval = sbrDecodeSingleFrame(hDecoder->sbr[ele], hDecoder->time_out[ch],
878879 hDecoder->postSeekResetFlag, hDecoder->forceUpSampling);
879− } else {
880− hDecoder->sbr_present_flag = 0;
881− hDecoder->forceUpSampling = 0;
880+ if (retval > 0)
881+ return retval;
882+ } else if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
883+ && !hDecoder->sbr_alloced[hDecoder->fr_ch_ele])
884+ {
885+ return 23;
882886 }
883887 #endif
884888
@@ -976,7 +980,7 @@ uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_str · 91 unmodified lines
976980 if (is_ltp_ot(hDecoder->object_type))
977981 {
978982 ltp_info *ltp1 = &(ics1->ltp);
979− ltp_info *ltp2 = (cpe->common_window) ? &(ics2->ltp2) : &(ics2->ltp) ;
983+ ltp_info *ltp2 = (cpe->common_window) ? &(ics2->ltp2) : &(ics2->ltp);
980984 #ifdef LD_DEC
981985 if (hDecoder->object_type == LD)
982986 {
@@ -1036,12 +1040,12 @@ uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_str · 53 unmodified lines
10361040 {
10371041 mul = 1;
10381042 #ifdef SBR_DEC
1039− hDecoder->sbr_alloced = 0;
1043+ hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0;
10401044 if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
10411045 {
10421046 /* SBR requires 2 times as much output data */
10431047 mul = 2;
1044− hDecoder->sbr_alloced = 1;
1048+ hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1;
10451049 }
10461050 #endif
10471051 hDecoder->time_out[cpe->channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t));
@@ -1140,7 +1144,7 @@ uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_str · 92 unmodified lines
11401144
11411145 #ifdef SBR_DEC
11421146 if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
1143− && hDecoder->sbr_alloced)
1147+ && hDecoder->sbr_alloced[hDecoder->fr_ch_ele])
11441148 {
11451149 uint8_t ele = hDecoder->fr_ch_ele;
11461150 uint8_t ch0 = cpe->channel;
@@ -1157,12 +1161,15 @@ uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_str · 10 unmodified lines
11571161 );
11581162 }
11591163
1160− sbrDecodeCoupleFrame(hDecoder->sbr[ele],
1164+ retval = sbrDecodeCoupleFrame(hDecoder->sbr[ele],
11611165 hDecoder->time_out[ch0], hDecoder->time_out[ch1],
11621166 hDecoder->postSeekResetFlag, hDecoder->forceUpSampling);
1163− } else {
1164− hDecoder->sbr_present_flag = 0;
1165− hDecoder->forceUpSampling = 0;
1167+ if (retval > 0)
1168+ return retval;
1169+ } else if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
1170+ && !hDecoder->sbr_alloced[hDecoder->fr_ch_ele])
1171+ {
1172+ return 23;
11661173 }
11671174 #endif
11681175
libfaad/structs.h+4−3
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 ** Commercial non-GPL licensing of this software is possible.
2323 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
2424 **
25−** $Id: structs.h,v 1.28 2004/01/14 20:32:30 menno Exp $
25+** $Id: structs.h,v 1.29 2004/01/16 20:20:32 menno Exp $
2626 **/
2727
2828 #ifndef __STRUCTS_H__
@@ -385,6 +385,7 @@ typedef struct · 356 unmodified lines
385385 uint8_t fr_ch_ele;
386386
387387 void *sample_buffer;
388+ uint8_t alloced_channels;
388389
389390 uint8_t window_shape_prev[MAX_CHANNELS];
390391 #ifdef LTP_DEC
@@ -399,9 +400,9 @@ typedef struct · 8 unmodified lines
399400 #ifdef SBR_DEC
400401 int8_t sbr_present_flag;
401402 int8_t forceUpSampling;
402− uint8_t sbr_alloced;
403+ uint8_t sbr_alloced[MAX_SYNTAX_ELEMENTS];
403404
404− sbr_info *sbr[32];
405+ sbr_info *sbr[MAX_SYNTAX_ELEMENTS];
405406 #ifdef DRM
406407 int8_t lcstereo_flag;
407408 #endif
libfaad/syntax.c+20−7
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 ** Commercial non-GPL licensing of this software is possible.
2323 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
2424 **
25−** $Id: syntax.c,v 1.67 2004/01/14 20:32:30 menno Exp $
25+** $Id: syntax.c,v 1.68 2004/01/16 20:20:32 menno Exp $
2626 **/
2727
2828 /*
@@ -118,7 +118,8 @@ int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC, · 89 unmodified lines
118118 mp4ASC->extensionFlag = faad_get1bit(ld DEBUGVAR(1,141,"GASpecificConfig(): ExtensionFlag"));
119119 if (mp4ASC->channelsConfiguration == 0)
120120 {
121− program_config_element(&pce, ld);
121+ if (program_config_element(&pce, ld))
122+ return -3;
122123 //mp4ASC->channelsConfiguration = pce.channels;
123124
124125 if (pce_out != NULL)
@@ -158,7 +159,7 @@ int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC, · 33 unmodified lines
158159 PCEs transmitted in raw data blocks cannot be used to convey decoder
159160 configuration information.
160161 */
161−uint8_t program_config_element(program_config *pce, bitfile *ld)
162+static uint8_t program_config_element(program_config *pce, bitfile *ld)
162163 {
163164 uint8_t i;
164165
@@ -303,6 +304,9 @@ uint8_t program_config_element(program_config *pce, bitfile *ld) · 138 unmodified lines
303304 }
304305 pce->comment_field_data[i] = 0;
305306
307+ if (pce->channels > MAX_CHANNELS)
308+ return 22;
309+
306310 return 0;
307311 }
308312
@@ -431,15 +435,21 @@ void raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, · 122 unmodified lines
431435 data_stream_element(hDecoder, ld);
432436 break;
433437 case ID_PCE:
434− if ((hInfo->error = program_config_element(pce, ld)) > 0)
435− return;
436− hDecoder->pce_set = 1;
438+ /* 14496-4: 5.6.4.1.2.1.3: */
439+ /* program_configuration_element()'s in access units shall be ignored */
440+ program_config_element(pce, ld);
441+ //if ((hInfo->error = program_config_element(pce, ld)) > 0)
442+ // return;
443+ //hDecoder->pce_set = 1;
437444 break;
438445 case ID_FIL:
439446 /* one sbr_info describes a channel_element not a channel! */
447+ /* if we encounter SBR data here: error */
448+ /* SBR data will be read directly in the SCE/LFE/CPE element */
440449 if ((hInfo->error = fill_element(hDecoder, ld, drc
441450 #ifdef SBR_DEC
442− , (ch_ele == 0) ? 0 : (ch_ele-1)
451+ //, (ch_ele == 0) ? INVALID_SBR_ELEMENT : (ch_ele-1)
452+ , INVALID_SBR_ELEMENT
443453 #endif
444454 )) > 0)
445455 return;
@@ -968,6 +978,9 @@ static uint8_t fill_element(faacDecHandle hDecoder, bitfile *ld, drc_info *drc · 522 unmodified lines
968978 if ((bs_extension_type == EXT_SBR_DATA) ||
969979 (bs_extension_type == EXT_SBR_DATA_CRC))
970980 {
981+ if (sbr_ele == INVALID_SBR_ELEMENT)
982+ return 24;
983+
971984 if (!hDecoder->sbr[sbr_ele])
972985 {
973986 hDecoder->sbr[sbr_ele] = sbrDecodeInit(hDecoder->frameLength,
libfaad/syntax.h+3−2
@@ -22,7 +22,7 @@ · 21 unmodified lines
2222 ** Commercial non-GPL licensing of this software is possible.
2323 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
2424 **
25−** $Id: syntax.h,v 1.45 2004/01/05 14:05:12 menno Exp $
25+** $Id: syntax.h,v 1.46 2004/01/16 20:20:32 menno Exp $
2626 **/
2727
2828 #ifndef __SYNTAX_H__
@@ -33,7 +33,6 @@ extern "C" { · 4 unmodified lines
3333 #endif
3434
3535 #include "decoder.h"
36−#include "drc.h"
3736 #include "bits.h"
3837
3938 #define MAIN 1
@@ -104,6 +103,8 @@ extern "C" { · 64 unmodified lines
104103 #define INTENSITY_HCB2 14
105104 #define INTENSITY_HCB 15
106105
106+#define INVALID_SBR_ELEMENT 255
107+
107108 int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC,
108109 program_config *pce);
109110

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t