History

new channel allocation

menno committed 22 years ago

Commit 7c7d6301 parent fcae26813 files · +256 −195Browse files

Unified · Split

13 files
  1. libfaad/bits.c +1 −1
  2. libfaad/bits.h +1 −1
  3. libfaad/common.h +1 −1
  4. libfaad/decoder.c +1 −1
  5. libfaad/error.c +1 −1
  6. libfaad/error.h +1 −1
  7. libfaad/fixed.h +1 −1
  8. libfaad/huffman.c +2 −2
  9. libfaad/output.c +31 −5
  10. libfaad/specrec.c +198 −133
  11. libfaad/structs.h +2 −1
  12. libfaad/syntax.c +15 −46
  13. libfaad/syntax.h +1 −1
libfaad/bits.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: bits.c,v 1.35 2004/01/16 20:20:32 menno Exp $
25+** $Id: bits.c,v 1.39 2004/09/04 14:56:27 menno Exp $
2626 **/
2727
2828 #include "common.h"
libfaad/bits.h+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: bits.h,v 1.34 2004/01/16 20:20:32 menno Exp $
25+** $Id: bits.h,v 1.35 2004/01/28 19:17:25 menno Exp $
2626 **/
2727
2828 #ifndef __BITS_H__
libfaad/common.h+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: common.h,v 1.47 2004/01/20 18:42:51 menno Exp $
25+** $Id: common.h,v 1.49 2004/01/29 11:31:11 menno Exp $
2626 **/
2727
2828 #ifndef __COMMON_H__
libfaad/decoder.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: decoder.c,v 1.92 2004/01/16 20:20:32 menno Exp $
25+** $Id: decoder.c,v 1.93 2004/01/28 19:17:25 menno Exp $
2626 **/
2727
2828 #include "common.h"
libfaad/error.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: error.c,v 1.20 2004/01/16 20:20:32 menno Exp $
25+** $Id: error.c,v 1.21 2004/01/28 19:17:25 menno Exp $
2626 **/
2727
2828 #include "common.h"
libfaad/error.h+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: error.h,v 1.15 2004/01/16 20:20:32 menno Exp $
25+** $Id: error.h,v 1.16 2004/01/28 19:17:25 menno Exp $
2626 **/
2727
2828 #ifndef __ERROR_H__
libfaad/fixed.h+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: fixed.h,v 1.17 2004/01/05 14:05:11 menno Exp $
25+** $Id: fixed.h,v 1.18 2004/01/28 19:17:25 menno Exp $
2626 **/
2727
2828 #ifndef __FIXED_H__
libfaad/huffman.c+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: huffman.c,v 1.16 2004/01/20 18:42:51 menno Exp $
25+** $Id: huffman.c,v 1.17 2004/01/28 19:17:25 menno Exp $
2626 **/
2727
2828 #include "common.h"
@@ -62,7 +62,7 @@ int8_t huffman_scale_factor(bitfile *ld) · 33 unmodified lines
6262 index = hcb_sf[index][bit];
6363 }
6464
65− return index + 121;
65+ return index + 61;
6666 }
6767
6868
libfaad/output.c+31−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: output.c,v 1.33 2003/12/23 18:41:42 menno Exp $
25+** $Id: output.c,v 1.35 2004/02/26 09:29:27 menno Exp $
2626 **/
2727
2828 #include "common.h"
@@ -36,7 +36,7 @@ · 7 unmodified lines
3636
3737 #define FLOAT_SCALE (1.0f/(1<<15))
3838
39−#define DM_MUL REAL_CONST(0.4142135623730950488) // 1/(1+sqrt(2))
39+#define DM_MUL REAL_CONST(0.3203772410170407) // 1/(1+sqrt(2) + 1/sqrt(2))
4040 #define RSQRT2 REAL_CONST(0.7071067811865475244) // 1/sqrt(2)
4141
4242
@@ -370,6 +370,29 @@ void *output_to_PCM(faacDecHandle hDecoder, · 327 unmodified lines
370370
371371 #else
372372
373+#define DM_MUL FRAC_CONST(0.3203772410170407) // 1/(1+sqrt(2) + 1/sqrt(2))
374+#define RSQRT2 FRAC_CONST(0.7071067811865475244) // 1/sqrt(2)
375+
376+static INLINE real_t get_sample(real_t **input, uint8_t channel, uint16_t sample,
377+ uint8_t down_matrix, uint8_t *internal_channel)
378+{
379+ if (!down_matrix)
380+ return input[internal_channel[channel]][sample];
381+
382+ if (channel == 0)
383+ {
384+ real_t C = MUL_F(input[internal_channel[0]][sample], RSQRT2);
385+ real_t L_S = MUL_F(input[internal_channel[3]][sample], RSQRT2);
386+ real_t cum = input[internal_channel[1]][sample] + C + L_S;
387+ return MUL_F(cum, DM_MUL);
388+ } else {
389+ real_t C = MUL_F(input[internal_channel[0]][sample], RSQRT2);
390+ real_t R_S = MUL_F(input[internal_channel[4]][sample], RSQRT2);
391+ real_t cum = input[internal_channel[2]][sample] + C + R_S;
392+ return MUL_F(cum, DM_MUL);
393+ }
394+}
395+
373396 void* output_to_PCM(faacDecHandle hDecoder,
374397 real_t **input, void *sample_buffer, uint8_t channels,
375398 uint16_t frame_len, uint8_t format)
@@ -387,7 +410,8 @@ void* output_to_PCM(faacDecHandle hDecoder, · 11 unmodified lines
387410 case FAAD_FMT_16BIT:
388411 for(i = 0; i < frame_len; i++)
389412 {
390− int32_t tmp = input[ch][i];
413+ //int32_t tmp = input[ch][i];
414+ int32_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel);
391415 if (tmp >= 0)
392416 {
393417 tmp += (1 << (REAL_BITS-1));
@@ -409,7 +433,8 @@ void* output_to_PCM(faacDecHandle hDecoder, · 15 unmodified lines
409433 case FAAD_FMT_24BIT:
410434 for(i = 0; i < frame_len; i++)
411435 {
412− int32_t tmp = input[ch][i];
436+ //int32_t tmp = input[ch][i];
437+ int32_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel);
413438 if (tmp >= 0)
414439 {
415440 tmp += (1 << (REAL_BITS-9));
@@ -432,7 +457,8 @@ void* output_to_PCM(faacDecHandle hDecoder, · 16 unmodified lines
432457 case FAAD_FMT_32BIT:
433458 for(i = 0; i < frame_len; i++)
434459 {
435− int32_t tmp = input[ch][i];
460+ //int32_t tmp = input[ch][i];
461+ int32_t tmp = get_sample(input, ch, i, hDecoder->downMatrix, hDecoder->internal_channel);
436462 if (tmp >= 0)
437463 {
438464 tmp += (1 << (16-REAL_BITS-1));
libfaad/specrec.c+198−133
@@ -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.41 2004/01/16 20:20:32 menno Exp $
25+** $Id: specrec.c,v 1.42 2004/01/28 19:17:26 menno Exp $
2626 **/
2727
2828 /*
@@ -688,16 +688,203 @@ void apply_scalefactors_sse(faacDecHandle hDecoder, ic_stream *ics, · 659 unmodified lines
688688 }
689689 #endif
690690
691+static uint8_t allocate_single_channel(faacDecHandle hDecoder, uint8_t channel)
692+{
693+ uint8_t mul = 1;
694+
695+#ifdef MAIN_DEC
696+ /* MAIN object type prediction */
697+ if (hDecoder->object_type == MAIN)
698+ {
699+ /* allocate the state only when needed */
700+ if (hDecoder->pred_stat[channel] == NULL)
701+ {
702+ hDecoder->pred_stat[channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state));
703+ reset_all_predictors(hDecoder->pred_stat[channel], hDecoder->frameLength);
704+ }
705+ }
706+#endif
707+
708+#ifdef LTP_DEC
709+ if (is_ltp_ot(hDecoder->object_type))
710+ {
711+ /* allocate the state only when needed */
712+ if (hDecoder->lt_pred_stat[channel] == NULL)
713+ {
714+ hDecoder->lt_pred_stat[channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t));
715+ memset(hDecoder->lt_pred_stat[channel], 0, hDecoder->frameLength*4 * sizeof(int16_t));
716+ }
717+ }
718+#endif
719+
720+ if (hDecoder->time_out[channel] == NULL)
721+ {
722+ mul = 1;
723+#ifdef SBR_DEC
724+ hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0;
725+ if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
726+ {
727+ /* SBR requires 2 times as much output data */
728+ mul = 2;
729+ hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1;
730+ }
731+#endif
732+ hDecoder->time_out[channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t));
733+ memset(hDecoder->time_out[channel], 0, mul*hDecoder->frameLength*sizeof(real_t));
734+ }
735+
736+ if (hDecoder->fb_intermed[channel] == NULL)
737+ {
738+ hDecoder->fb_intermed[channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t));
739+ memset(hDecoder->fb_intermed[channel], 0, hDecoder->frameLength*sizeof(real_t));
740+ }
741+
742+#ifdef SSR_DEC
743+ if (hDecoder->object_type == SSR)
744+ {
745+ if (hDecoder->ssr_overlap[channel] == NULL)
746+ {
747+ hDecoder->ssr_overlap[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
748+ memset(hDecoder->ssr_overlap[channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
749+ }
750+ if (hDecoder->prev_fmd[channel] == NULL)
751+ {
752+ uint16_t k;
753+ hDecoder->prev_fmd[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
754+ for (k = 0; k < 2*hDecoder->frameLength; k++)
755+ hDecoder->prev_fmd[channel][k] = REAL_CONST(-1);
756+ }
757+ }
758+#endif
759+
760+ return 0;
761+}
762+
763+static uint8_t allocate_channel_pair(faacDecHandle hDecoder,
764+ uint8_t channel, uint8_t paired_channel)
765+{
766+ uint8_t mul = 1;
767+
768+#ifdef MAIN_DEC
769+ /* MAIN object type prediction */
770+ if (hDecoder->object_type == MAIN)
771+ {
772+ /* allocate the state only when needed */
773+ if (hDecoder->pred_stat[channel] == NULL)
774+ {
775+ hDecoder->pred_stat[channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state));
776+ reset_all_predictors(hDecoder->pred_stat[channel], hDecoder->frameLength);
777+ }
778+ if (hDecoder->pred_stat[paired_channel] == NULL)
779+ {
780+ hDecoder->pred_stat[paired_channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state));
781+ reset_all_predictors(hDecoder->pred_stat[paired_channel], hDecoder->frameLength);
782+ }
783+ }
784+#endif
785+
786+#ifdef LTP_DEC
787+ if (is_ltp_ot(hDecoder->object_type))
788+ {
789+ /* allocate the state only when needed */
790+ if (hDecoder->lt_pred_stat[channel] == NULL)
791+ {
792+ hDecoder->lt_pred_stat[channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t));
793+ memset(hDecoder->lt_pred_stat[channel], 0, hDecoder->frameLength*4 * sizeof(int16_t));
794+ }
795+ if (hDecoder->lt_pred_stat[paired_channel] == NULL)
796+ {
797+ hDecoder->lt_pred_stat[paired_channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t));
798+ memset(hDecoder->lt_pred_stat[paired_channel], 0, hDecoder->frameLength*4 * sizeof(int16_t));
799+ }
800+ }
801+#endif
802+
803+ if (hDecoder->time_out[channel] == NULL)
804+ {
805+ mul = 1;
806+#ifdef SBR_DEC
807+ hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0;
808+ if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
809+ {
810+ /* SBR requires 2 times as much output data */
811+ mul = 2;
812+ hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1;
813+ }
814+#endif
815+ hDecoder->time_out[channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t));
816+ memset(hDecoder->time_out[channel], 0, mul*hDecoder->frameLength*sizeof(real_t));
817+ }
818+ if (hDecoder->time_out[paired_channel] == NULL)
819+ {
820+ hDecoder->time_out[paired_channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t));
821+ memset(hDecoder->time_out[paired_channel], 0, mul*hDecoder->frameLength*sizeof(real_t));
822+ }
823+
824+ if (hDecoder->fb_intermed[channel] == NULL)
825+ {
826+ hDecoder->fb_intermed[channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t));
827+ memset(hDecoder->fb_intermed[channel], 0, hDecoder->frameLength*sizeof(real_t));
828+ }
829+ if (hDecoder->fb_intermed[paired_channel] == NULL)
830+ {
831+ hDecoder->fb_intermed[paired_channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t));
832+ memset(hDecoder->fb_intermed[paired_channel], 0, hDecoder->frameLength*sizeof(real_t));
833+ }
834+
835+#ifdef SSR_DEC
836+ if (hDecoder->object_type == SSR)
837+ {
838+ if (hDecoder->ssr_overlap[cpe->channel] == NULL)
839+ {
840+ hDecoder->ssr_overlap[cpe->channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
841+ memset(hDecoder->ssr_overlap[cpe->channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
842+ }
843+ if (hDecoder->ssr_overlap[cpe->paired_channel] == NULL)
844+ {
845+ hDecoder->ssr_overlap[cpe->paired_channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
846+ memset(hDecoder->ssr_overlap[cpe->paired_channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
847+ }
848+ if (hDecoder->prev_fmd[cpe->channel] == NULL)
849+ {
850+ uint16_t k;
851+ hDecoder->prev_fmd[cpe->channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
852+ for (k = 0; k < 2*hDecoder->frameLength; k++)
853+ hDecoder->prev_fmd[cpe->channel][k] = REAL_CONST(-1);
854+ }
855+ if (hDecoder->prev_fmd[cpe->paired_channel] == NULL)
856+ {
857+ uint16_t k;
858+ hDecoder->prev_fmd[cpe->paired_channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
859+ for (k = 0; k < 2*hDecoder->frameLength; k++)
860+ hDecoder->prev_fmd[cpe->paired_channel][k] = REAL_CONST(-1);
861+ }
862+ }
863+#endif
864+
865+ return 0;
866+}
867+
691868 uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics,
692869 element *sce, int16_t *spec_data)
693870 {
694− uint8_t retval, mul;
871+ uint8_t retval;
695872 ALIGN real_t spec_coef[1024];
696873
697874 #ifdef PROFILE
698875 int64_t count = faad_get_ts();
699876 #endif
700877
878+ if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0)
879+ {
880+ retval = allocate_single_channel(hDecoder, sce->channel);
881+ if (retval > 0)
882+ return retval;
883+
884+ hDecoder->element_alloced[hDecoder->fr_ch_ele] = 1;
885+ }
886+
887+
701888 /* inverse quantization */
702889 retval = inverse_quantization(spec_coef, spec_data, hDecoder->frameLength);
703890 if (retval > 0)
@@ -727,13 +914,6 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, · 23 unmodified lines
727914 /* MAIN object type prediction */
728915 if (hDecoder->object_type == MAIN)
729916 {
730− /* allocate the state only when needed */
731− if (hDecoder->pred_stat[sce->channel] == NULL)
732− {
733− hDecoder->pred_stat[sce->channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state));
734− reset_all_predictors(hDecoder->pred_stat[sce->channel], hDecoder->frameLength);
735− }
736−
737917 /* intra channel prediction */
738918 ic_prediction(ics, spec_coef, hDecoder->pred_stat[sce->channel], hDecoder->frameLength,
739919 hDecoder->sf_index);
@@ -761,13 +941,6 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, · 21 unmodified lines
761941 }
762942 #endif
763943
764− /* allocate the state only when needed */
765− if (hDecoder->lt_pred_stat[sce->channel] == NULL)
766− {
767− hDecoder->lt_pred_stat[sce->channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t));
768− memset(hDecoder->lt_pred_stat[sce->channel], 0, hDecoder->frameLength*4 * sizeof(int16_t));
769− }
770−
771944 /* long term prediction */
772945 lt_prediction(ics, &(ics->ltp), spec_coef, hDecoder->lt_pred_stat[sce->channel], hDecoder->fb,
773946 ics->window_shape, hDecoder->window_shape_prev[sce->channel],
@@ -787,28 +960,6 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, · 13 unmodified lines
787960 }
788961
789962
790− if (hDecoder->time_out[sce->channel] == NULL)
791− {
792− mul = 1;
793−#ifdef SBR_DEC
794− hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0;
795− if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
796− {
797− /* SBR requires 2 times as much output data */
798− mul = 2;
799− hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1;
800− }
801−#endif
802− hDecoder->time_out[sce->channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t));
803− memset(hDecoder->time_out[sce->channel], 0, mul*hDecoder->frameLength*sizeof(real_t));
804− }
805−
806− if (hDecoder->fb_intermed[sce->channel] == NULL)
807− {
808− hDecoder->fb_intermed[sce->channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t));
809− memset(hDecoder->fb_intermed[sce->channel], 0, hDecoder->frameLength*sizeof(real_t));
810− }
811−
812963 /* filter bank */
813964 #ifdef SSR_DEC
814965 if (hDecoder->object_type != SSR)
@@ -826,19 +977,6 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, · 11 unmodified lines
826977 #endif
827978 #ifdef SSR_DEC
828979 } else {
829− if (hDecoder->ssr_overlap[sce->channel] == NULL)
830− {
831− hDecoder->ssr_overlap[sce->channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
832− memset(hDecoder->ssr_overlap[sce->channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
833− }
834− if (hDecoder->prev_fmd[sce->channel] == NULL)
835− {
836− uint16_t k;
837− hDecoder->prev_fmd[sce->channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
838− for (k = 0; k < 2*hDecoder->frameLength; k++)
839− hDecoder->prev_fmd[sce->channel][k] = REAL_CONST(-1);
840− }
841−
842980 ssr_decode(&(ics->ssr), hDecoder->fb, ics->window_sequence, ics->window_shape,
843981 hDecoder->window_shape_prev[sce->channel], spec_coef, hDecoder->time_out[sce->channel],
844982 hDecoder->ssr_overlap[sce->channel], hDecoder->ipqf_buffer[sce->channel], hDecoder->prev_fmd[sce->channel],
@@ -892,13 +1030,21 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, · 47 unmodified lines
8921030 uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2,
8931031 element *cpe, int16_t *spec_data1, int16_t *spec_data2)
8941032 {
895− uint8_t retval, mul;
1033+ uint8_t retval;
8961034 ALIGN real_t spec_coef1[1024];
8971035 ALIGN real_t spec_coef2[1024];
8981036
8991037 #ifdef PROFILE
9001038 int64_t count = faad_get_ts();
9011039 #endif
1040+ if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0)
1041+ {
1042+ retval = allocate_channel_pair(hDecoder, cpe->channel, cpe->paired_channel);
1043+ if (retval > 0)
1044+ return retval;
1045+
1046+ hDecoder->element_alloced[hDecoder->fr_ch_ele] = 1;
1047+ }
9021048
9031049 /* inverse quantization */
9041050 retval = inverse_quantization(spec_coef1, spec_data1, hDecoder->frameLength);
@@ -949,18 +1095,6 @@ uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_str · 44 unmodified lines
9491095 /* MAIN object type prediction */
9501096 if (hDecoder->object_type == MAIN)
9511097 {
952− /* allocate the state only when needed */
953− if (hDecoder->pred_stat[cpe->channel] == NULL)
954− {
955− hDecoder->pred_stat[cpe->channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state));
956− reset_all_predictors(hDecoder->pred_stat[cpe->channel], hDecoder->frameLength);
957− }
958− if (hDecoder->pred_stat[cpe->paired_channel] == NULL)
959− {
960− hDecoder->pred_stat[cpe->paired_channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state));
961− reset_all_predictors(hDecoder->pred_stat[cpe->paired_channel], hDecoder->frameLength);
962− }
963−
9641098 /* intra channel prediction */
9651099 ic_prediction(ics1, spec_coef1, hDecoder->pred_stat[cpe->channel], hDecoder->frameLength,
9661100 hDecoder->sf_index);
@@ -999,18 +1133,6 @@ uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_str · 32 unmodified lines
9991133 }
10001134 #endif
10011135
1002− /* allocate the state only when needed */
1003− if (hDecoder->lt_pred_stat[cpe->channel] == NULL)
1004− {
1005− hDecoder->lt_pred_stat[cpe->channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t));
1006− memset(hDecoder->lt_pred_stat[cpe->channel], 0, hDecoder->frameLength*4 * sizeof(int16_t));
1007− }
1008− if (hDecoder->lt_pred_stat[cpe->paired_channel] == NULL)
1009− {
1010− hDecoder->lt_pred_stat[cpe->paired_channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t));
1011− memset(hDecoder->lt_pred_stat[cpe->paired_channel], 0, hDecoder->frameLength*4 * sizeof(int16_t));
1012− }
1013−
10141136 /* long term prediction */
10151137 lt_prediction(ics1, ltp1, spec_coef1, hDecoder->lt_pred_stat[cpe->channel], hDecoder->fb,
10161138 ics1->window_shape, hDecoder->window_shape_prev[cpe->channel],
@@ -1036,38 +1158,6 @@ uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_str · 19 unmodified lines
10361158 drc_decode(hDecoder->drc, spec_coef2);
10371159 }
10381160
1039− if (hDecoder->time_out[cpe->channel] == NULL)
1040− {
1041− mul = 1;
1042−#ifdef SBR_DEC
1043− hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0;
1044− if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
1045− {
1046− /* SBR requires 2 times as much output data */
1047− mul = 2;
1048− hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1;
1049− }
1050−#endif
1051− hDecoder->time_out[cpe->channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t));
1052− memset(hDecoder->time_out[cpe->channel], 0, mul*hDecoder->frameLength*sizeof(real_t));
1053− }
1054− if (hDecoder->time_out[cpe->paired_channel] == NULL)
1055− {
1056− hDecoder->time_out[cpe->paired_channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t));
1057− memset(hDecoder->time_out[cpe->paired_channel], 0, mul*hDecoder->frameLength*sizeof(real_t));
1058− }
1059−
1060− if (hDecoder->fb_intermed[cpe->channel] == NULL)
1061− {
1062− hDecoder->fb_intermed[cpe->channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t));
1063− memset(hDecoder->fb_intermed[cpe->channel], 0, hDecoder->frameLength*sizeof(real_t));
1064− }
1065− if (hDecoder->fb_intermed[cpe->paired_channel] == NULL)
1066− {
1067− hDecoder->fb_intermed[cpe->paired_channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t));
1068− memset(hDecoder->fb_intermed[cpe->paired_channel], 0, hDecoder->frameLength*sizeof(real_t));
1069− }
1070−
10711161 /* filter bank */
10721162 #ifdef SSR_DEC
10731163 if (hDecoder->object_type != SSR)
@@ -1092,31 +1182,6 @@ uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_str · 18 unmodified lines
10921182 #endif
10931183 #ifdef SSR_DEC
10941184 } else {
1095− if (hDecoder->ssr_overlap[cpe->channel] == NULL)
1096− {
1097− hDecoder->ssr_overlap[cpe->channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
1098− memset(hDecoder->ssr_overlap[cpe->channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
1099− }
1100− if (hDecoder->ssr_overlap[cpe->paired_channel] == NULL)
1101− {
1102− hDecoder->ssr_overlap[cpe->paired_channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
1103− memset(hDecoder->ssr_overlap[cpe->paired_channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
1104− }
1105− if (hDecoder->prev_fmd[cpe->channel] == NULL)
1106− {
1107− uint16_t k;
1108− hDecoder->prev_fmd[cpe->channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
1109− for (k = 0; k < 2*hDecoder->frameLength; k++)
1110− hDecoder->prev_fmd[cpe->channel][k] = REAL_CONST(-1);
1111− }
1112− if (hDecoder->prev_fmd[cpe->paired_channel] == NULL)
1113− {
1114− uint16_t k;
1115− hDecoder->prev_fmd[cpe->paired_channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t));
1116− for (k = 0; k < 2*hDecoder->frameLength; k++)
1117− hDecoder->prev_fmd[cpe->paired_channel][k] = REAL_CONST(-1);
1118− }
1119−
11201185 ssr_decode(&(ics1->ssr), hDecoder->fb, ics1->window_sequence, ics1->window_shape,
11211186 hDecoder->window_shape_prev[cpe->channel], spec_coef1, hDecoder->time_out[cpe->channel],
11221187 hDecoder->ssr_overlap[cpe->channel], hDecoder->ipqf_buffer[cpe->channel],
libfaad/structs.h+2−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: structs.h,v 1.29 2004/01/16 20:20:32 menno Exp $
25+** $Id: structs.h,v 1.30 2004/01/28 19:17:26 menno Exp $
2626 **/
2727
2828 #ifndef __STRUCTS_H__
@@ -386,6 +386,7 @@ typedef struct · 357 unmodified lines
386386
387387 void *sample_buffer;
388388 uint8_t alloced_channels;
389+ uint8_t element_alloced[MAX_SYNTAX_ELEMENTS];
389390
390391 uint8_t window_shape_prev[MAX_CHANNELS];
391392 #ifdef LTP_DEC
libfaad/syntax.c+15−46
@@ -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.68 2004/01/16 20:20:32 menno Exp $
25+** $Id: syntax.c,v 1.69 2004/01/28 19:17:26 menno Exp $
2626 **/
2727
2828 /*
@@ -328,11 +328,6 @@ void decode_sce_lfe(faacDecHandle hDecoder, · 299 unmodified lines
328328 return;
329329 }
330330
331− if (hDecoder->pce_set)
332− hDecoder->internal_channel[hDecoder->pce.sce_channel[tag]] = channels;
333− else
334− hDecoder->internal_channel[channels] = channels;
335−
336331 if (id_syn_ele == ID_SCE)
337332 hDecoder->channel_element[channels] = hDecoder->fr_ch_ele;
338333 else /* LFE */
@@ -341,6 +336,11 @@ void decode_sce_lfe(faacDecHandle hDecoder, · 2 unmodified lines
341336
342337 hInfo->error = single_lfe_channel_element(hDecoder, ld, channels, &tag);
343338
339+ if (hDecoder->pce_set)
340+ hDecoder->internal_channel[hDecoder->pce.sce_channel[tag]] = channels;
341+ else
342+ hDecoder->internal_channel[channels] = channels;
343+
344344 hDecoder->fr_channels++;
345345 hDecoder->fr_ch_ele++;
346346 }
@@ -362,6 +362,12 @@ void decode_cpe(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, bitfile *ld, · 15 unmodified lines
362362 return;
363363 }
364364
365+ hDecoder->channel_element[channels] = hDecoder->fr_ch_ele;
366+ hDecoder->channel_element[channels+1] = hDecoder->fr_ch_ele;
367+ hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele;
368+
369+ hInfo->error = channel_pair_element(hDecoder, ld, channels, &tag);
370+
365371 if (hDecoder->pce_set)
366372 {
367373 hDecoder->internal_channel[hDecoder->pce.cpe_channel[tag]] = channels;
@@ -371,12 +377,6 @@ void decode_cpe(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, bitfile *ld, · 3 unmodified lines
371377 hDecoder->internal_channel[channels+1] = channels+1;
372378 }
373379
374− hDecoder->channel_element[channels] = hDecoder->fr_ch_ele;
375− hDecoder->channel_element[channels+1] = hDecoder->fr_ch_ele;
376− hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele;
377−
378− hInfo->error = channel_pair_element(hDecoder, ld, channels, &tag);
379−
380380 hDecoder->fr_channels += 2;
381381 hDecoder->fr_ch_ele++;
382382 }
@@ -385,7 +385,6 @@ void raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, · 2 unmodified lines
385385 bitfile *ld, program_config *pce, drc_info *drc)
386386 {
387387 uint8_t id_syn_ele;
388− uint8_t ch_ele = 0;
389388
390389 hDecoder->fr_channels = 0;
391390 hDecoder->fr_ch_ele = 0;
@@ -404,21 +403,18 @@ void raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, · 12 unmodified lines
404403 case ID_SCE:
405404 if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele;
406405 decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele);
407− ch_ele++;
408406 if (hInfo->error > 0)
409407 return;
410408 break;
411409 case ID_CPE:
412410 if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele;
413411 decode_cpe(hDecoder, hInfo, ld, id_syn_ele);
414− ch_ele++;
415412 if (hInfo->error > 0)
416413 return;
417414 break;
418415 case ID_LFE:
419416 hDecoder->has_lfe++;
420417 decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele);
421− ch_ele++;
422418 if (hInfo->error > 0)
423419 return;
424420 break;
@@ -448,7 +444,6 @@ void raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, · 23 unmodified lines
448444 /* SBR data will be read directly in the SCE/LFE/CPE element */
449445 if ((hInfo->error = fill_element(hDecoder, ld, drc
450446 #ifdef SBR_DEC
451− //, (ch_ele == 0) ? INVALID_SBR_ELEMENT : (ch_ele-1)
452447 , INVALID_SBR_ELEMENT
453448 #endif
454449 )) > 0)
@@ -463,67 +458,48 @@ void raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, · 8 unmodified lines
463458 {
464459 case 1:
465460 decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
466− ch_ele++;
467461 if (hInfo->error > 0)
468462 return;
469463 break;
470464 case 2:
471465 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
472− ch_ele++;
473466 if (hInfo->error > 0)
474467 return;
475468 break;
476469 case 3:
477470 decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
478− ch_ele++;
479471 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
480− ch_ele++;
481472 if (hInfo->error > 0)
482473 return;
483474 break;
484475 case 4:
485476 decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
486− ch_ele++;
487477 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
488− ch_ele++;
489478 decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
490− ch_ele++;
491479 if (hInfo->error > 0)
492480 return;
493481 break;
494482 case 5:
495483 decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
496− ch_ele++;
497484 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
498− ch_ele++;
499485 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
500− ch_ele++;
501486 if (hInfo->error > 0)
502487 return;
503488 break;
504489 case 6:
505490 decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
506− ch_ele++;
507491 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
508− ch_ele++;
509492 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
510− ch_ele++;
511493 decode_sce_lfe(hDecoder, hInfo, ld, ID_LFE);
512− ch_ele++;
513494 if (hInfo->error > 0)
514495 return;
515496 break;
516− case 7:
497+ case 7: /* 8 channels */
517498 decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
518− ch_ele++;
519499 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
520− ch_ele++;
521500 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
522− ch_ele++;
523501 decode_cpe(hDecoder, hInfo, ld, ID_CPE);
524− ch_ele++;
525502 decode_sce_lfe(hDecoder, hInfo, ld, ID_LFE);
526− ch_ele++;
527503 if (hInfo->error > 0)
528504 return;
529505 break;
@@ -1624,9 +1600,7 @@ static uint8_t decode_scale_factors(ic_stream *ics, bitfile *ld) · 1094 unmodified lines
16241600
16251601 /* decode intensity position */
16261602 t = huffman_scale_factor(ld);
1627− if (t < 0)
1628− return 9;
1629− is_position += (t - 60);
1603+ is_position += t;
16301604 ics->scale_factors[g][sfb] = is_position;
16311605
16321606 break;
@@ -1640,9 +1614,6 @@ static uint8_t decode_scale_factors(ic_stream *ics, bitfile *ld) · 7 unmodified lines
16401614 DEBUGVAR(1,73,"scale_factor_data(): first noise")) - 256;
16411615 } else {
16421616 t = huffman_scale_factor(ld);
1643− if (t < 0)
1644− return 9;
1645− t -= 60;
16461617 }
16471618 noise_energy += t;
16481619 ics->scale_factors[g][sfb] = noise_energy;
@@ -1656,9 +1627,7 @@ static uint8_t decode_scale_factors(ic_stream *ics, bitfile *ld) · 7 unmodified lines
16561627
16571628 /* decode scale factor */
16581629 t = huffman_scale_factor(ld);
1659− if (t < 0)
1660− return 9;
1661− scale_factor += (t - 60);
1630+ scale_factor += t;
16621631 if (scale_factor < 0 || scale_factor > 255)
16631632 return 4;
16641633 ics->scale_factors[g][sfb] = scale_factor;
libfaad/syntax.h+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: syntax.h,v 1.46 2004/01/16 20:20:32 menno Exp $
25+** $Id: syntax.h,v 1.47 2004/01/28 19:17:26 menno Exp $
2626 **/
2727
2828 #ifndef __SYNTAX_H__

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