History

some small changes... - less memory usage - no more mallocing on every frame

menno committed 23 years ago

Commit e8edc601 parent 2569c4733 files · +866 −726Browse files

Unified · Split

33 files
  1. libfaad/bits.h +1 −1
  2. libfaad/cfft.h +9 −1
  3. libfaad/common.c +2 −1
  4. libfaad/common.h +9 −3
  5. libfaad/decoder.c +48 −243
  6. libfaad/decoder.h +1 −11
  7. libfaad/fixed.h +25 −1
  8. libfaad/lt_predict.c +21 −1
  9. libfaad/lt_predict.h +3 −1
  10. libfaad/mp4.c +1 −1
  11. libfaad/output.c +11 −13
  12. libfaad/sbr_dct.c +20 −13
  13. libfaad/sbr_dct.h +2 −1
  14. libfaad/sbr_dec.c +25 −60
  15. libfaad/sbr_dec.h +4 −4
  16. libfaad/sbr_e_nf.c +7 −1
  17. libfaad/sbr_fbt.c +29 −25
  18. libfaad/sbr_hfadj.c +21 −22
  19. libfaad/sbr_hfadj.h +4 −4
  20. libfaad/sbr_hfgen.c +47 −53
  21. libfaad/sbr_hfgen.h +4 −4
  22. libfaad/sbr_qmf.c +47 −27
  23. libfaad/sbr_qmf.h +3 −5
  24. libfaad/sbr_qmf_c.h +1 −1
  25. libfaad/sbr_syntax.c +17 −17
  26. libfaad/sbr_syntax.h +4 −4
  27. libfaad/sbr_tf_grid.c +5 −5
  28. libfaad/specrec.c +352 −18
  29. libfaad/specrec.h +10 −5
  30. libfaad/ssr.c +3 −6
  31. libfaad/structs.h +3 −10
  32. libfaad/syntax.c +116 −157
  33. libfaad/syntax.h +11 −7
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.22 2003/09/09 18:09:51 menno Exp $
25+** $Id: bits.h,v 1.23 2003/10/09 20:04:24 menno Exp $
2626 **/
2727
2828 #ifndef __BITS_H__
libfaad/cfft.h+9−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: cfft.h,v 1.7 2003/09/09 18:09:51 menno Exp $
25+** $Id: cfft.h,v 1.8 2003/10/09 20:04:24 menno Exp $
2626 **/
2727
2828 #ifndef __CFFT_H__
@@ -32,6 +32,14 @@ · 3 unmodified lines
3232 extern "C" {
3333 #endif
3434
35+typedef struct
36+{
37+ uint16_t n;
38+ uint16_t ifac[15];
39+ complex_t *work;
40+ complex_t *tab;
41+} cfft_info;
42+
3543
3644 void cfftf(cfft_info *cfft, complex_t *c);
3745 void cfftb(cfft_info *cfft, complex_t *c);
libfaad/common.c+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: common.c,v 1.7 2003/09/09 18:09:51 menno Exp $
25+** $Id: common.c,v 1.8 2003/10/09 20:04:24 menno Exp $
2626 **/
2727
2828 /* just some common functions that could be used anywhere */
@@ -117,6 +117,7 @@ int8_t can_decode_ot(uint8_t object_type) · 88 unmodified lines
117117 return -1;
118118 }
119119
120+
120121 static const uint8_t Parity [256] = { // parity
121122 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,
122123 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,
libfaad/common.h+9−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: common.h,v 1.31 2003/09/09 18:09:51 menno Exp $
25+** $Id: common.h,v 1.32 2003/10/09 20:04:24 menno Exp $
2626 **/
2727
2828 #ifndef __COMMON_H__
@@ -41,7 +41,6 @@ extern "C" { · 12 unmodified lines
4141 #define min(a, b) (((a) < (b)) ? (a) : (b))
4242 #endif
4343
44−
4544 /* COMPILE TIME DEFINITIONS */
4645
4746 /* use double precision */
@@ -49,6 +48,11 @@ extern "C" { · 1 unmodified line
4948 /* use fixed point reals */
5049 //#define FIXED_POINT
5150
51+#ifdef _WIN32_WCE
52+#define FIXED_POINT
53+#endif
54+
55+
5256 #define ERROR_RESILIENCE
5357
5458
@@ -60,6 +64,8 @@ extern "C" { · 5 unmodified lines
6064 #define LTP_DEC
6165 /* Allow decoding of LD profile AAC */
6266 #define LD_DEC
67+/* Allow decoding of Digital Radio Mondiale (DRM) */
68+//#define DRM
6369
6470 /* LD can't do without LTP */
6571 #ifdef LD_DEC
@@ -94,7 +100,7 @@ extern "C" { · 28 unmodified lines
94100 #else
95101 #define qmf_t real_t
96102 #define QMF_RE(A) (A)
97−#define QMF_IM(A) 0
103+#define QMF_IM(A)
98104 #endif
99105
100106
libfaad/decoder.c+48−243
@@ -1,19 +1,19 @@
11 /*
22 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
33 ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
4−**
4+**
55 ** This program is free software; you can redistribute it and/or modify
66 ** it under the terms of the GNU General Public License as published by
77 ** the Free Software Foundation; either version 2 of the License, or
88 ** (at your option) any later version.
9−**
9+**
1010 ** This program is distributed in the hope that it will be useful,
1111 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1212 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313 ** GNU General Public License for more details.
14−**
14+**
1515 ** You should have received a copy of the GNU General Public License
16−** along with this program; if not, write to the Free Software
16+** along with this program; if not, write to the Free Software
1717 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1818 **
1919 ** Any non-GPL usage of this software or parts of this software is strictly
@@ -22,7 +22,7 @@ · 2 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.73 2003/10/05 15:22:10 menno Exp $
25+** $Id: decoder.c,v 1.74 2003/10/09 20:04:24 menno Exp $
2626 **/
2727
2828 #include "common.h"
@@ -34,20 +34,9 @@ · 5 unmodified lines
3434 #include "decoder.h"
3535 #include "mp4.h"
3636 #include "syntax.h"
37−#include "tns.h"
38−#include "pns.h"
39−#include "is.h"
40−#include "ms.h"
41−#include "ic_predict.h"
42−#include "lt_predict.h"
43−#include "drc.h"
4437 #include "error.h"
4538 #include "output.h"
4639 #include "dither.h"
47−#ifdef SSR_DEC
48−#include "ssr.h"
49−#include "ssr_fb.h"
50−#endif
5140 #ifdef SBR_DEC
5241 #include "sbr_dec.h"
5342 #endif
@@ -102,6 +91,7 @@ faacDecHandle FAADAPI faacDecOpen() · 48 unmodified lines
10291 hDecoder->config.outputFormat = FAAD_FMT_16BIT;
10392 hDecoder->config.defObjectType = MAIN;
10493 hDecoder->config.defSampleRate = 44100; /* Default: 44.1kHz */
94+ hDecoder->config.downMatrix = 0;
10595 hDecoder->adts_header_present = 0;
10696 hDecoder->adif_header_present = 0;
10797 #ifdef ERROR_RESILIENCE
@@ -377,7 +367,6 @@ int8_t FAADAPI faacDecInit2(faacDecHandle hDecoder, uint8_t *pBuffer, · 269 unmodified lines
377367 return 0;
378368 }
379369
380−#ifdef DRM
381370 int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate,
382371 uint8_t channels)
383372 {
@@ -385,9 +374,11 @@ int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, · 1 unmodified line
385374 hDecoder->config.defObjectType = DRM_ER_LC;
386375
387376 hDecoder->config.defSampleRate = samplerate;
377+#ifdef ERROR_RESILIENCE // This shoudl always be defined for DRM
388378 hDecoder->aacSectionDataResilienceFlag = 1; /* VCB11 */
389379 hDecoder->aacScalefactorDataResilienceFlag = 0; /* no RVLC */
390380 hDecoder->aacSpectralDataResilienceFlag = 1; /* HCR */
381+#endif
391382 hDecoder->frameLength = 960;
392383 hDecoder->sf_index = get_sr_index(hDecoder->config.defSampleRate);
393384 hDecoder->object_type = hDecoder->config.defObjectType;
@@ -398,6 +389,7 @@ int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, · 4 unmodified lines
398389 hDecoder->channelConfiguration = 1;
399390
400391 #ifdef SBR_DEC
392+#ifdef DRM
401393 if (channels == DRMCH_SBR_LC_STEREO)
402394 hDecoder->lcstereo_flag = 1;
403395 else
@@ -411,6 +403,7 @@ int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, · 7 unmodified lines
411403 /* Reset sbr for new initialization */
412404 sbrDecodeEnd(hDecoder->sbr[0]);
413405 hDecoder->sbr[0] = NULL;
406+#endif
414407 #endif
415408
416409 /* must be done before frameLength is divided by 2 for LD */
@@ -423,7 +416,6 @@ int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, · 6 unmodified lines
423416
424417 return 0;
425418 }
426−#endif
427419
428420 void FAADAPI faacDecClose(faacDecHandle hDecoder)
429421 {
@@ -699,7 +691,6 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 269 unmodified lines
699691 uint8_t *buffer, uint32_t buffer_size)
700692 {
701693 int32_t i;
702− uint8_t ch;
703694 adts_header adts;
704695 uint8_t channels = 0, ch_ele = 0;
705696 uint8_t output_channels = 0;
@@ -707,8 +698,8 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 1 unmodified line
707698 uint32_t bitsconsumed;
708699 #ifdef DRM
709700 uint8_t *revbuffer;
710− uint8_t *prevbufstart;
711− uint8_t *pbufend;
701+ uint8_t *prevbufstart;
702+ uint8_t *pbufend;
712703 #endif
713704
714705 /* local copy of globals */
@@ -736,9 +727,6 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 21 unmodified lines
736727 program_config *pce;
737728
738729 void *sample_buffer;
739− element *syntax_elements[MAX_SYNTAX_ELEMENTS];
740− element **elements;
741− real_t *spec_coef[MAX_CHANNELS];
742730
743731 /* safety checks */
744732 if ((hDecoder == NULL) || (hInfo == NULL) || (buffer == NULL) || (ld == NULL))
@@ -804,11 +792,8 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 59 unmodified lines
804792 dbg_count = 0;
805793 #endif
806794
807− elements = syntax_elements;
808−
809795 /* decode the complete bitstream */
810− elements = raw_data_block(hDecoder, hInfo, ld, syntax_elements,
811− spec_coef, pce, drc);
796+ raw_data_block(hDecoder, hInfo, ld, pce, drc);
812797
813798 ch_ele = hDecoder->fr_ch_ele;
814799 channels = hDecoder->fr_channels;
@@ -912,202 +897,27 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 97 unmodified lines
912897 return NULL;
913898 }
914899
900+ /* allocate the buffer for the final samples */
915901 if (hDecoder->sample_buffer == NULL)
916902 {
903+ static const uint8_t str[] = { sizeof(int16_t), sizeof(int32_t), sizeof(int32_t),
904+ sizeof(float32_t), sizeof(double), sizeof(int16_t), sizeof(int16_t),
905+ sizeof(int16_t), sizeof(int16_t), 0, 0, 0
906+ };
907+ uint8_t stride = str[outputFormat-1];
917908 #ifdef SBR_DEC
918909 if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
919− {
920− if (hDecoder->config.outputFormat == FAAD_FMT_DOUBLE)
921− hDecoder->sample_buffer = malloc(2*frame_len*channels*sizeof(double));
922− else
923− hDecoder->sample_buffer = malloc(2*frame_len*channels*sizeof(real_t));
924− } else {
925−#endif
926− if (hDecoder->config.outputFormat == FAAD_FMT_DOUBLE)
927− hDecoder->sample_buffer = malloc(frame_len*channels*sizeof(double));
928− else
929− hDecoder->sample_buffer = malloc(frame_len*channels*sizeof(real_t));
930−#ifdef SBR_DEC
931− }
910+ stride = 2 * stride;
932911 #endif
912+ hDecoder->sample_buffer = malloc(frame_len*channels*stride);
933913 }
934914
935915 sample_buffer = hDecoder->sample_buffer;
936916
937−
938− /* Because for ms, is and pns both channels spectral coefficients are needed
939− we have to restart running through all channels here.
940− */
941− for (ch = 0; ch < channels; ch++)
942− {
943− int16_t pch = -1;
944− uint8_t right_channel;
945− ic_stream *ics, *icsr;
946− ltp_info *ltp;
947−
948− /* find the syntax element to which this channel belongs */
949− if (syntax_elements[hDecoder->channel_element[ch]]->channel == ch)
950− {
951− ics = &(syntax_elements[hDecoder->channel_element[ch]]->ics1);
952− icsr = &(syntax_elements[hDecoder->channel_element[ch]]->ics2);
953− ltp = &(ics->ltp);
954− pch = syntax_elements[hDecoder->channel_element[ch]]->paired_channel;
955− right_channel = 0;
956− } else if (syntax_elements[hDecoder->channel_element[ch]]->paired_channel == ch) {
957− ics = &(syntax_elements[hDecoder->channel_element[ch]]->ics2);
958− if (syntax_elements[hDecoder->channel_element[ch]]->common_window)
959− ltp = &(ics->ltp2);
960− else
961− ltp = &(ics->ltp);
962− right_channel = 1;
963− }
964−
965− /* pns decoding */
966− if ((!right_channel) && (pch != -1) && (ics->ms_mask_present))
967− pns_decode(ics, icsr, spec_coef[ch], spec_coef[pch], frame_len, 1, object_type);
968− else if ((pch == -1) || ((pch != -1) && (!ics->ms_mask_present)))
969− pns_decode(ics, NULL, spec_coef[ch], NULL, frame_len, 0, object_type);
970−
971− if (!right_channel && (pch != -1))
972− {
973− /* mid/side decoding */
974− ms_decode(ics, icsr, spec_coef[ch], spec_coef[pch], frame_len);
975−
976− /* intensity stereo decoding */
977− is_decode(ics, icsr, spec_coef[ch], spec_coef[pch], frame_len);
978− }
979−
980−#ifdef MAIN_DEC
981− /* MAIN object type prediction */
982− if (object_type == MAIN)
983− {
984− /* allocate the state only when needed */
985− if (pred_stat[ch] == NULL)
986− {
987− pred_stat[ch] = (pred_state*)malloc(frame_len * sizeof(pred_state));
988− reset_all_predictors(pred_stat[ch], frame_len);
989− }
990−
991− /* intra channel prediction */
992− ic_prediction(ics, spec_coef[ch], pred_stat[ch], frame_len);
993−
994− /* In addition, for scalefactor bands coded by perceptual
995− noise substitution the predictors belonging to the
996− corresponding spectral coefficients are reset.
997− */
998− pns_reset_pred_state(ics, pred_stat[ch]);
999− }
1000−#endif
1001−#ifdef LTP_DEC
1002− if ((object_type == LTP)
1003−#ifdef ERROR_RESILIENCE
1004− || (object_type == ER_LTP)
1005−#endif
1006−#ifdef LD_DEC
1007− || (object_type == LD)
1008−#endif
1009− )
1010− {
1011−#ifdef LD_DEC
1012− if (object_type == LD)
1013− {
1014− if (ltp->data_present)
1015− {
1016− if (ltp->lag_update)
1017− ltp_lag[ch] = ltp->lag;
1018− }
1019− ltp->lag = ltp_lag[ch];
1020− }
1021−#endif
1022−
1023− /* allocate the state only when needed */
1024− if (lt_pred_stat[ch] == NULL)
1025− {
1026− lt_pred_stat[ch] = (real_t*)malloc(frame_len*4 * sizeof(real_t));
1027− memset(lt_pred_stat[ch], 0, frame_len*4 * sizeof(real_t));
1028− }
1029−
1030− /* long term prediction */
1031− lt_prediction(ics, ltp, spec_coef[ch], lt_pred_stat[ch], fb,
1032− ics->window_shape, window_shape_prev[ch],
1033− sf_index, object_type, frame_len);
1034− }
1035−#endif
1036−
1037− /* tns decoding */
1038− tns_decode_frame(ics, &(ics->tns), sf_index, object_type,
1039− spec_coef[ch], frame_len);
1040−
1041− /* drc decoding */
1042− if (drc->present)
1043− {
1044− if (!drc->exclude_mask[ch] || !drc->excluded_chns_present)
1045− drc_decode(drc, spec_coef[ch]);
1046− }
1047−
1048− if (time_out[ch] == NULL)
1049− {
1050− time_out[ch] = (real_t*)malloc(frame_len*2*sizeof(real_t));
1051− memset(time_out[ch], 0, frame_len*2*sizeof(real_t));
1052− }
1053−#ifdef SBR_DEC
1054− if (time_out2[ch] == NULL)
1055− {
1056− time_out2[ch] = (real_t*)malloc(frame_len*2*sizeof(real_t));
1057− memset(time_out2[ch], 0, frame_len*2*sizeof(real_t));
1058− }
1059−#endif
1060−
1061− /* filter bank */
1062−#ifdef SSR_DEC
1063− if (object_type != SSR)
1064− {
1065−#endif
1066− ifilter_bank(fb, ics->window_sequence, ics->window_shape,
1067− window_shape_prev[ch], spec_coef[ch],
1068− time_out[ch], object_type, frame_len);
1069−#ifdef SSR_DEC
1070− } else {
1071− if (ssr_overlap[ch] == NULL)
1072− {
1073− ssr_overlap[ch] = (real_t*)malloc(2*frame_len*sizeof(real_t));
1074− memset(ssr_overlap[ch], 0, 2*frame_len*sizeof(real_t));
1075− }
1076− if (prev_fmd[ch] == NULL)
1077− {
1078− uint16_t k;
1079− prev_fmd[ch] = (real_t*)malloc(2*frame_len*sizeof(real_t));
1080− for (k = 0; k < 2*frame_len; k++)
1081− prev_fmd[ch][k] = REAL_CONST(-1);
1082− }
1083−
1084− ssr_decode(&(ics->ssr), fb, ics->window_sequence, ics->window_shape,
1085− window_shape_prev[ch], spec_coef[ch], time_out[ch],
1086− ssr_overlap[ch], hDecoder->ipqf_buffer[ch], prev_fmd[ch], frame_len);
1087− }
1088−#endif
1089− /* save window shape for next frame */
1090− window_shape_prev[ch] = ics->window_shape;
1091−
1092−#ifdef LTP_DEC
1093− if ((object_type == LTP)
1094−#ifdef ERROR_RESILIENCE
1095− || (object_type == ER_LTP)
1096−#endif
1097−#ifdef LD_DEC
1098− || (object_type == LD)
1099−#endif
1100− )
1101− {
1102− lt_update_state(lt_pred_stat[ch], time_out[ch], time_out[ch]+frame_len,
1103− frame_len, object_type);
1104− }
1105−#endif
1106− }
1107−
1108917 #ifdef SBR_DEC
1109918 if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1))
1110919 {
920+ uint8_t ch = 0;
1111921 for (i = 0; i < ch_ele; i++)
1112922 {
1113923 /* following case can happen when forceUpSampling == 1 */
@@ -1120,25 +930,40 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 6 unmodified lines
1120930 );
1121931 hDecoder->sbr[i]->data = NULL;
1122932 hDecoder->sbr[i]->data_size = 0;
933+ hDecoder->sbr[i]->id_aac = hDecoder->element_id[i];
934+ }
935+
936+ /* Allocate space for SBR output */
937+ if (hDecoder->time_out2[ch] == NULL)
938+ {
939+ hDecoder->time_out2[ch] = (real_t*)malloc(hDecoder->frameLength*2*sizeof(real_t));
940+ memset(hDecoder->time_out2[ch], 0, hDecoder->frameLength*2*sizeof(real_t));
1123941 }
1124942
1125− if (syntax_elements[i]->paired_channel != -1)
943+ if (hDecoder->sbr[i]->id_aac == ID_CPE)
1126944 {
1127− memcpy(time_out2[syntax_elements[i]->channel],
1128− time_out[syntax_elements[i]->channel], frame_len*sizeof(real_t));
1129− memcpy(time_out2[syntax_elements[i]->paired_channel],
1130− time_out[syntax_elements[i]->paired_channel], frame_len*sizeof(real_t));
945+ /* space for 2 channels needed */
946+ if (hDecoder->time_out2[ch+1] == NULL)
947+ {
948+ hDecoder->time_out2[ch+1] = (real_t*)malloc(hDecoder->frameLength*2*sizeof(real_t));
949+ memset(hDecoder->time_out2[ch+1], 0, hDecoder->frameLength*2*sizeof(real_t));
950+ }
951+
952+ memcpy(time_out2[ch],
953+ time_out[ch], frame_len*sizeof(real_t));
954+ memcpy(time_out2[ch+1],
955+ time_out[ch+1], frame_len*sizeof(real_t));
1131956 sbrDecodeFrame(hDecoder->sbr[i],
1132− time_out2[syntax_elements[i]->channel],
1133− time_out2[syntax_elements[i]->paired_channel], ID_CPE,
957+ time_out2[ch], time_out2[ch+1],
1134958 hDecoder->postSeekResetFlag, hDecoder->forceUpSampling);
959+ ch += 2;
1135960 } else {
1136− memcpy(time_out2[syntax_elements[i]->channel],
1137− time_out[syntax_elements[i]->channel], frame_len*sizeof(real_t));
961+ memcpy(time_out2[ch],
962+ time_out[ch], frame_len*sizeof(real_t));
1138963 sbrDecodeFrame(hDecoder->sbr[i],
1139− time_out2[syntax_elements[i]->channel],
1140− NULL, ID_SCE,
964+ time_out2[ch], NULL,
1141965 hDecoder->postSeekResetFlag, hDecoder->forceUpSampling);
966+ ch++;
1142967 }
1143968 }
1144969 frame_len *= 2;
@@ -1181,16 +1006,6 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 36 unmodified lines
11811006 #endif
11821007
11831008 /* cleanup */
1184− for (ch = 0; ch < channels; ch++)
1185− {
1186− if (spec_coef[ch]) free(spec_coef[ch]);
1187− }
1188−
1189− for (i = 0; i < ch_ele; i++)
1190− {
1191− if (syntax_elements[i]) free(syntax_elements[i]);
1192− }
1193−
11941009 #ifdef ANALYSIS
11951010 fflush(stdout);
11961011 #endif
@@ -1203,16 +1018,6 @@ error: · 6 unmodified lines
12031018 if (ld) free(ld);
12041019
12051020 /* cleanup */
1206− for (ch = 0; ch < channels; ch++)
1207− {
1208− if (spec_coef[ch]) free(spec_coef[ch]);
1209− }
1210−
1211− for (i = 0; i < ch_ele; i++)
1212− {
1213− if (syntax_elements[i]) free(syntax_elements[i]);
1214− }
1215−
12161021 #ifdef ANALYSIS
12171022 fflush(stdout);
12181023 #endif
libfaad/decoder.h+1−11
@@ -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.h,v 1.28 2003/09/24 08:05:44 menno Exp $
25+** $Id: decoder.h,v 1.29 2003/10/09 20:04:24 menno Exp $
2626 **/
2727
2828 #ifndef __DECODER_H__
@@ -118,16 +118,6 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 89 unmodified lines
118118 uint8_t *buffer,
119119 uint32_t buffer_size);
120120
121−element *decode_sce_lfe(faacDecHandle hDecoder,
122− faacDecFrameInfo *hInfo, bitfile *ld,
123− real_t **spec_coef, uint8_t id_syn_ele);
124−element *decode_cpe(faacDecHandle hDecoder,
125− faacDecFrameInfo *hInfo, bitfile *ld,
126− real_t **spec_coef, uint8_t id_syn_ele);
127−element **raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
128− bitfile *ld, element **elements,
129− real_t **spec_coef, program_config *pce, drc_info *drc);
130−
131121 #ifdef _WIN32
132122 #pragma pack(pop)
133123 #endif
libfaad/fixed.h+25−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.10 2003/09/09 18:09:51 menno Exp $
25+** $Id: fixed.h,v 1.11 2003/10/09 20:04:24 menno Exp $
2626 **/
2727
2828 #ifndef __FIXED_H__
@@ -95,6 +95,30 @@ static INLINE MUL_R_C(real_t A, real_t B) · 66 unmodified lines
9595 }
9696 }
9797
98+#elif 0 //defined(_WIN32_WCE) && defined(ARM)
99+
100+/* multiply real with real */
101+static INLINE MUL(real_t A, real_t B)
102+{
103+ __emit(0xe0c23190); // smull r3, r2, r0, r1
104+ __emit(0xe1b03723); // movs r3, r3, lsr #14
105+ __emit(0xe0a30902); // adc r0, r3, r2, lsl #18
106+}
107+/* multiply coef with coef */
108+static INLINE MUL_C_C(real_t A, real_t B)
109+{
110+ __emit(0xe0c23190); // smull r3, r2, r0, r1
111+ __emit(0xe1b03e23); // movs r3, r3, lsr #28
112+ __emit(0xe0a30202); // adc r0, r3, r2, lsl #4
113+}
114+/* multiply real with coef */
115+static INLINE MUL_R_C(real_t A, real_t B)
116+{
117+ __emit(0xe0c23190); // smull r3, r2, r0, r1
118+ __emit(0xe1b03e23); // movs r3, r3, lsr #28
119+ __emit(0xe0a30202); // adc r0, r3, r2, lsl #4
120+}
121+
98122 #elif defined(__GNUC__) && defined (__arm__)
99123
100124 /* taken from MAD */
libfaad/lt_predict.c+21−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: lt_predict.c,v 1.12 2003/09/09 18:09:52 menno Exp $
25+** $Id: lt_predict.c,v 1.13 2003/10/09 20:04:24 menno Exp $
2626 **/
2727
2828
@@ -37,6 +37,26 @@ · 8 unmodified lines
3737 #include "filtbank.h"
3838 #include "tns.h"
3939
40+/* check if the object type is an object type that can have LTP */
41+uint8_t is_ltp_ot(uint8_t object_type)
42+{
43+#ifdef LTP_DEC
44+ if ((object_type == LTP)
45+#ifdef ERROR_RESILIENCE
46+ || (object_type == ER_LTP)
47+#endif
48+#ifdef LD_DEC
49+ || (object_type == LD)
50+#endif
51+ )
52+ {
53+ return 1;
54+ }
55+#endif
56+
57+ return 0;
58+}
59+
4060 static real_t codebook[8] =
4161 {
4262 COEF_CONST(0.570829),
libfaad/lt_predict.h+3−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: lt_predict.h,v 1.6 2003/09/09 18:09:52 menno Exp $
25+** $Id: lt_predict.h,v 1.7 2003/10/09 20:04:24 menno Exp $
2626 **/
2727
2828 #ifdef LTP_DEC
@@ -36,6 +36,8 @@ extern "C" { · 7 unmodified lines
3636
3737 #include "filtbank.h"
3838
39+uint8_t is_ltp_ot(uint8_t object_type);
40+
3941 void lt_prediction(ic_stream *ics,
4042 ltp_info *ltp,
4143 real_t *spec,
libfaad/mp4.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: mp4.c,v 1.19 2003/09/18 13:38:38 menno Exp $
25+** $Id: mp4.c,v 1.24 2003/11/12 20:47:58 menno Exp $
2626 **/
2727
2828 #include "common.h"
libfaad/output.c+11−13
@@ -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.21 2003/09/09 18:09:52 menno Exp $
25+** $Id: output.c,v 1.22 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 #include "common.h"
@@ -55,20 +55,18 @@ double doubletmp; · 26 unmodified lines
5555 static INLINE real_t get_sample(real_t **input, uint8_t channel, uint16_t sample,
5656 uint8_t downMatrix, uint8_t *internal_channel)
5757 {
58− if (downMatrix)
58+ if (!downMatrix)
59+ return input[internal_channel[channel]][sample];
60+
61+ if (channel == 0)
5962 {
60− if (channel == 0)
61− {
62− return DM_MUL * (input[internal_channel[1]][sample] +
63− input[internal_channel[0]][sample]/(real_t)sqrt(2.) +
64− input[internal_channel[3]][sample]/(real_t)sqrt(2.));
65− } else {
66− return DM_MUL * (input[internal_channel[2]][sample] +
67− input[internal_channel[0]][sample]/(real_t)sqrt(2.) +
68− input[internal_channel[4]][sample]/(real_t)sqrt(2.));
69− }
63+ return DM_MUL * (input[internal_channel[1]][sample] +
64+ input[internal_channel[0]][sample]/(real_t)sqrt(2.) +
65+ input[internal_channel[3]][sample]/(real_t)sqrt(2.));
7066 } else {
71− return input[internal_channel[channel]][sample];
67+ return DM_MUL * (input[internal_channel[2]][sample] +
68+ input[internal_channel[0]][sample]/(real_t)sqrt(2.) +
69+ input[internal_channel[4]][sample]/(real_t)sqrt(2.));
7270 }
7371 }
7472
libfaad/sbr_dct.c+20−13
@@ -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_dct.c,v 1.4 2003/09/24 11:52:12 menno Exp $
25+** $Id: sbr_dct.c,v 1.5 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 #include "common.h"
@@ -1099,6 +1099,21 @@ void DCT2_64_unscaled(real_t *y, real_t *x) · 1070 unmodified lines
10991099 void DCT4_64(real_t *y, real_t *x)
11001100 {
11011101 int16_t i0;
1102+ static real_t t2[64];
1103+
1104+ t2[0] = x[0];
1105+ for (i0=0; i0<31; i0++)
1106+ {
1107+ t2[2*i0+1] = x[2*i0+1] - x[2*i0+2];
1108+ t2[2*i0+2] = x[2*i0+1] + x[2*i0+2];
1109+ }
1110+ t2[63] = x[63];
1111+
1112+ DCT4_64_kernel(y, t2);
1113+}
1114+
1115+void DCT4_64_kernel(real_t *y, real_t *t2)
1116+{
11021117 real_t f2;
11031118 real_t f3;
11041119 real_t f4;
@@ -1837,18 +1852,10 @@ void DCT4_64(real_t *y, real_t *x) · 732 unmodified lines
18371852 real_t f799;
18381853 real_t f800;
18391854 real_t f801;
1840− static real_t t2[64];
18411855
1842− t2[0] = x[0];
1843− for (i0=0; i0<31; i0++)
1844− {
1845− t2[2*i0+1] = x[2*i0+1] - x[2*i0+2];
1846− t2[2*i0+2] = x[2*i0+1] + x[2*i0+2];
1847− }
1848− t2[63] = x[63];
18491856 f2 = 0.7071067811865476 * t2[32];
1850− f3 = x[0] - f2;
1851− f4 = x[0] + f2;
1857+ f3 = t2[0] - f2;
1858+ f4 = t2[0] + f2;
18521859 f5 = t2[16] + t2[48];
18531860 f6 = 1.3065629648763766 * t2[16];
18541861 f7 = (-0.9238795325112866) * f5;
@@ -2312,8 +2319,8 @@ void DCT4_64(real_t *y, real_t *x) · 457 unmodified lines
23122319 f465 = 0.7071067811865474 * f463;
23132320 f466 = 0.7071067811865474 * f464;
23142321 f467 = 0.7071067811865476 * t2[31];
2315− f468 = x[63] - f467;
2316− f469 = x[63] + f467;
2322+ f468 = t2[63] - f467;
2323+ f469 = t2[63] + f467;
23172324 f470 = t2[47] + t2[15];
23182325 f471 = 1.3065629648763766 * t2[47];
23192326 f472 = (-0.9238795325112866) * f470;
libfaad/sbr_dct.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: sbr_dct.h,v 1.3 2003/09/24 11:52:12 menno Exp $
25+** $Id: sbr_dct.h,v 1.4 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 #ifndef __SBR_DCT_H__
@@ -35,6 +35,7 @@ extern "C" { · 6 unmodified lines
3535 void DCT3_32_unscaled(real_t *y, real_t *x);
3636 void DCT2_64_unscaled(real_t *y, real_t *x);
3737 void DCT4_64(real_t *y, real_t *x);
38+void DCT4_64_kernel(real_t *y, real_t *t2);
3839
3940
4041 #ifdef __cplusplus
libfaad/sbr_dec.c+25−60
@@ -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.12 2003/09/25 12:04:31 menno Exp $
25+** $Id: sbr_dec.c,v 1.13 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828
@@ -111,10 +111,10 @@ void sbrDecodeEnd(sbr_info *sbr) · 82 unmodified lines
111111 qmfs_end(sbr->qmfs[1]);
112112 }
113113
114− if (sbr->Xcodec[0]) free(sbr->Xcodec[0]);
115− if (sbr->Xsbr[0]) free(sbr->Xsbr[0]);
116− if (sbr->Xcodec[1]) free(sbr->Xcodec[1]);
117− if (sbr->Xsbr[1]) free(sbr->Xsbr[1]);
114+ //if (sbr->Xcodec[0]) free(sbr->Xcodec[0]);
115+ //if (sbr->Xsbr[0]) free(sbr->Xsbr[0]);
116+ //if (sbr->Xcodec[1]) free(sbr->Xcodec[1]);
117+ //if (sbr->Xsbr[1]) free(sbr->Xsbr[1]);
118118
119119 for (j = 0; j < 5; j++)
120120 {
@@ -157,7 +157,7 @@ void sbr_save_prev_data(sbr_info *sbr, uint8_t ch) · 36 unmodified lines
157157 }
158158
159159 void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel,
160− real_t *right_channel, uint8_t id_aac,
160+ real_t *right_channel,
161161 uint8_t just_seeked, uint8_t upsample_only)
162162 {
163163 int16_t i, k, l;
@@ -166,15 +166,14 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 2 unmodified lines
166166 uint8_t ch, channels, ret;
167167 real_t *ch_buf;
168168
169− qmf_t X[32*64];
169+ qmf_t X[32][64];
170170 #ifdef SBR_LOW_POWER
171171 real_t deg[64];
172172 #endif
173173
174174 bitfile *ld = NULL;
175175
176− sbr->id_aac = id_aac;
177− channels = (id_aac == ID_SCE) ? 1 : 2;
176+ channels = (sbr->id_aac == ID_SCE) ? 1 : 2;
178177
179178 if (sbr->data == NULL || sbr->data_size == 0)
180179 {
@@ -185,7 +184,7 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 4 unmodified lines
185184 /* initialise and read the bitstream */
186185 faad_initbits(ld, sbr->data, sbr->data_size);
187186
188− ret = sbr_extension_data(ld, sbr, id_aac);
187+ ret = sbr_extension_data(ld, sbr, sbr->id_aac);
189188
190189 ret = ld->error ? ld->error : ret;
191190 faad_endbits(ld);
@@ -227,9 +226,6 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 35 unmodified lines
227226 sbr->Q_temp_prev[ch][j] = malloc(64*sizeof(real_t));
228227 }
229228
230− sbr->Xsbr[ch] = malloc((sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
231− sbr->Xcodec[ch] = malloc((sbr->numTimeSlotsRate+sbr->tHFGen)*32 * sizeof(qmf_t));
232−
233229 memset(sbr->Xsbr[ch], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
234230 memset(sbr->Xcodec[ch], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*32 * sizeof(qmf_t));
235231 }
@@ -239,20 +235,6 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 3 unmodified lines
239235 else
240236 ch_buf = right_channel;
241237
242−#if 0
243− for (i = 0; i < sbr->tHFAdj; i++)
244− {
245− int8_t j;
246− for (j = sbr->kx_prev; j < sbr->kx; j++)
247− {
248− QMF_RE(sbr->Xcodec[ch][i*32 + j]) = 0;
249−#ifndef SBR_LOW_POWER
250− QMF_IM(sbr->Xcodec[ch][i*32 + j]) = 0;
251−#endif
252− }
253− }
254−#endif
255−
256238 /* subband analysis */
257239 if (dont_process)
258240 sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], ch_buf, sbr->Xcodec[ch], sbr->tHFGen, 32);
@@ -274,7 +256,7 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 15 unmodified lines
274256 {
275257 for (k = 0; k < sbr->kx; k++)
276258 {
277− QMF_RE(sbr->Xsbr[ch][(sbr->tHFAdj + l)*64 + k]) = 0;
259+ QMF_RE(sbr->Xsbr[ch][sbr->tHFAdj + l][k]) = 0;
278260 }
279261 }
280262 #endif
@@ -295,16 +277,16 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 14 unmodified lines
295277 {
296278 for (k = 0; k < 32; k++)
297279 {
298− QMF_RE(X[l * 64 + k]) = QMF_RE(sbr->Xcodec[ch][(l + sbr->tHFAdj)*32 + k]);
280+ QMF_RE(X[l][k]) = QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]);
299281 #ifndef SBR_LOW_POWER
300− QMF_IM(X[l * 64 + k]) = QMF_IM(sbr->Xcodec[ch][(l + sbr->tHFAdj)*32 + k]);
282+ QMF_IM(X[l][k]) = QMF_IM(sbr->Xcodec[ch][l + sbr->tHFAdj][k]);
301283 #endif
302284 }
303285 for (k = 32; k < 64; k++)
304286 {
305− QMF_RE(X[l * 64 + k]) = 0;
287+ QMF_RE(X[l][k]) = 0;
306288 #ifndef SBR_LOW_POWER
307− QMF_IM(X[l * 64 + k]) = 0;
289+ QMF_IM(X[l][k]) = 0;
308290 #endif
309291 }
310292 }
@@ -325,28 +307,28 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 14 unmodified lines
325307
326308 for (k = 0; k < xover_band; k++)
327309 {
328− QMF_RE(X[l * 64 + k]) = QMF_RE(sbr->Xcodec[ch][(l + sbr->tHFAdj)*32 + k]);
310+ QMF_RE(X[l][k]) = QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]);
329311 #ifndef SBR_LOW_POWER
330− QMF_IM(X[l * 64 + k]) = QMF_IM(sbr->Xcodec[ch][(l + sbr->tHFAdj)*32 + k]);
312+ QMF_IM(X[l][k]) = QMF_IM(sbr->Xcodec[ch][l + sbr->tHFAdj][k]);
331313 #endif
332314 }
333315 for (k = xover_band; k < 64; k++)
334316 {
335− QMF_RE(X[l * 64 + k]) = QMF_RE(sbr->Xsbr[ch][(l + sbr->tHFAdj)*64 + k]);
317+ QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]);
336318 #ifndef SBR_LOW_POWER
337− QMF_IM(X[l * 64 + k]) = QMF_IM(sbr->Xsbr[ch][(l + sbr->tHFAdj)*64 + k]);
319+ QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]);
338320 #endif
339321 }
340322 #ifdef SBR_LOW_POWER
341− QMF_RE(X[l * 64 + xover_band - 1]) += QMF_RE(sbr->Xsbr[ch][(l + sbr->tHFAdj)*64 + xover_band - 1]);
323+ QMF_RE(X[l][xover_band - 1]) += QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][xover_band - 1]);
342324 #endif
343325 #ifdef DRM
344326 if (sbr->Is_DRM_SBR)
345327 {
346328 for (k = xover_band; k < xover_band + 4; k++)
347329 {
348− QMF_RE(X[l * 64 + k]) += QMF_RE(sbr->Xcodec[ch][(l + sbr->tHFAdj)*32 + k]);
349− QMF_IM(X[l * 64 + k]) += QMF_IM(sbr->Xcodec[ch][(l + sbr->tHFAdj)*32 + k]);
330+ QMF_RE(X[l][k]) += QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]);
331+ QMF_IM(X[l][k]) += QMF_IM(sbr->Xcodec[ch][l + sbr->tHFAdj][k]);
350332 }
351333 }
352334 #endif
@@ -354,29 +336,12 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 1 unmodified line
354336 }
355337
356338 /* subband synthesis */
357− sbr_qmf_synthesis_64(sbr, sbr->qmfs[ch], (const complex_t*)X, ch_buf);
339+ sbr_qmf_synthesis_64(sbr, sbr->qmfs[ch], X, ch_buf);
358340
359− for (i = 0; i < 32; i++)
341+ for (i = 0; i < sbr->tHFGen; i++)
360342 {
361− int8_t j;
362− for (j = 0; j < sbr->tHFGen; j++)
363− {
364− QMF_RE(sbr->Xcodec[ch][j*32 + i]) = QMF_RE(sbr->Xcodec[ch][(j+sbr->numTimeSlotsRate)*32 + i]);
365−#ifndef SBR_LOW_POWER
366− QMF_IM(sbr->Xcodec[ch][j*32 + i]) = QMF_IM(sbr->Xcodec[ch][(j+sbr->numTimeSlotsRate)*32 + i]);
367−#endif
368− }
369− }
370− for (i = 0; i < 64; i++)
371− {
372− int8_t j;
373− for (j = 0; j < sbr->tHFGen; j++)
374− {
375− QMF_RE(sbr->Xsbr[ch][j*64 + i]) = QMF_RE(sbr->Xsbr[ch][(j+sbr->numTimeSlotsRate)*64 + i]);
376−#ifndef SBR_LOW_POWER
377− QMF_IM(sbr->Xsbr[ch][j*64 + i]) = QMF_IM(sbr->Xsbr[ch][(j+sbr->numTimeSlotsRate)*64 + i]);
378−#endif
379− }
343+ memmove(sbr->Xcodec[ch][i], sbr->Xcodec[ch][i+sbr->numTimeSlotsRate], 32 * sizeof(qmf_t));
344+ memmove(sbr->Xsbr[ch][i], sbr->Xsbr[ch][i+sbr->numTimeSlotsRate], 64 * sizeof(qmf_t));
380345 }
381346 }
382347
libfaad/sbr_dec.h+4−4
@@ -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.7 2003/09/25 12:04:31 menno Exp $
25+** $Id: sbr_dec.h,v 1.8 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 #ifndef __SBR_DEC_H__
@@ -138,8 +138,8 @@ typedef struct · 109 unmodified lines
138138 qmfa_info *qmfa[2];
139139 qmfs_info *qmfs[2];
140140
141− qmf_t *Xsbr[2];
142− qmf_t *Xcodec[2];
141+ qmf_t Xsbr[2][40][64];
142+ qmf_t Xcodec[2][40][32];
143143
144144 #ifdef DRM
145145 int8_t lcstereo_flag;
@@ -200,7 +200,7 @@ sbr_info *sbrDecodeInit(uint16_t framelength · 54 unmodified lines
200200 void sbrDecodeEnd(sbr_info *sbr);
201201
202202 void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel,
203− real_t *right_channel, uint8_t id_aac,
203+ real_t *right_channel,
204204 uint8_t just_seeked, uint8_t upsample_only);
205205
206206
libfaad/sbr_e_nf.c+7−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: sbr_e_nf.c,v 1.4 2003/09/09 18:37:32 menno Exp $
25+** $Id: sbr_e_nf.c,v 1.5 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 #include "common.h"
@@ -186,6 +186,12 @@ void unmap_envelope_noise(sbr_info *sbr) · 157 unmodified lines
186186 r_temp = (real_t)pow(2, sbr->E[1][k][l]*amp1 - 12);
187187
188188 sbr->E_orig[1][k][l] = l_temp / ((real_t)1.0 + r_temp);
189+
190+ /*
191+ E_orig[1]: integer
192+ r_temp: fixed point
193+ fixed point multiplication gives integer
194+ */
189195 sbr->E_orig[0][k][l] = MUL(r_temp, sbr->E_orig[1][k][l]);
190196 }
191197 }
libfaad/sbr_fbt.c+29−25
@@ -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.3 2003/09/09 18:37:32 menno Exp $
25+** $Id: sbr_fbt.c,v 1.4 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 /* Calculate frequency band tables */
@@ -187,9 +187,7 @@ void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, · 158 unmodified lines
187187 uint8_t k;
188188 uint8_t dk;
189189 uint32_t nrBands, k2Achieved;
190− int32_t k2Diff, vDk[64];
191−
192− memset(vDk, 0, 64*sizeof(int32_t));
190+ int32_t k2Diff, vDk[64] = {0};
193191
194192 /* mft only defined for k2 > k0 */
195193 if (k2 <= k0)
@@ -247,7 +245,6 @@ void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, · 51 unmodified lines
247245 #endif
248246 }
249247
250−
251248 /*
252249 This function finds the number of bands using this formula:
253250 bands * log(a1/a0)/log(2.0) + 0.5
@@ -260,6 +257,10 @@ static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1) · 6 unmodified lines
260257 return (int32_t)(bands * log((float)a1/(float)a0)/div + 0.5);
261258 }
262259
260+static real_t find_initial_power(uint8_t bands, uint8_t a0, uint8_t a1)
261+{
262+ return pow((real_t)a1/(real_t)a0, 1.0/(real_t)bands);
263+}
263264
264265 /*
265266 version for bs_freq_scale > 0
@@ -269,17 +270,12 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 3 unmodified lines
269270 {
270271 uint8_t k, bands, twoRegions;
271272 uint8_t k1;
272− uint32_t nrBand0, nrBand1;
273− int32_t vDk0[64], vDk1[64];
274− int32_t vk0[64], vk1[64];
273+ uint8_t nrBand0, nrBand1;
274+ int32_t vDk0[64] = {0}, vDk1[64] = {0};
275+ int32_t vk0[64] = {0}, vk1[64] = {0};
275276 uint8_t temp1[] = { 6, 5, 4 };
276−
277− /* without memset code enters infinite loop,
278− so there must be some wrong table access */
279− memset(vDk0, 0, 64*sizeof(int32_t));
280− memset(vDk1, 0, 64*sizeof(int32_t));
281− memset(vk0, 0, 64*sizeof(int32_t));
282− memset(vk1, 0, 64*sizeof(int32_t));
277+ real_t q, qk;
278+ int32_t A_1;
283279
284280 /* mft only defined for k2 > k0 */
285281 if (k2 <= k0)
@@ -302,11 +298,15 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 16 unmodified lines
302298 nrBand0 = 2 * find_bands(0, bands, k0, k1);
303299 nrBand0 = min(nrBand0, 63);
304300
301+ q = find_initial_power(nrBand0, k0, k1);
302+ qk = REAL_CONST(k0);
303+ A_1 = (int32_t)(qk + .5);
305304 for (k = 0; k <= nrBand0; k++)
306305 {
307− /* diverging power series */
308− vDk0[k] = (int32_t)(k0 * pow((float)k1/(float)k0, (k+1)/(float)nrBand0)+0.5) -
309− (int32_t)(k0 * pow((float)k1/(float)k0, k/(float)nrBand0)+0.5);
306+ int32_t A_0 = A_1;
307+ qk *= q;
308+ A_1 = (int32_t)(qk + 0.5);
309+ vDk0[k] = A_1 - A_0;
310310 }
311311
312312 /* needed? */
@@ -331,10 +331,15 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 18 unmodified lines
331331 nrBand1 = 2 * find_bands(1 /* warped */, bands, k1, k2);
332332 nrBand1 = min(nrBand1, 63);
333333
334+ q = find_initial_power(nrBand1, k1, k2);
335+ qk = REAL_CONST(k1);
336+ A_1 = (int32_t)(qk + .5);
334337 for (k = 0; k <= nrBand1 - 1; k++)
335338 {
336− vDk1[k] = (int32_t)(k1 * pow((float)k2/(float)k1, (k+1)/(float)nrBand1)+0.5) -
337− (int32_t)(k1 * pow((float)k2/(float)k1, k/(float)nrBand1)+0.5);
339+ int32_t A_0 = A_1;
340+ qk *= q;
341+ A_1 = (int32_t)(qk + 0.5);
342+ vDk1[k] = A_1 - A_0;
338343 }
339344
340345 if (vDk1[0] < vDk0[nrBand0 - 1])
@@ -448,8 +453,8 @@ uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band, · 107 unmodified lines
448453 if (k == 0)
449454 {
450455 i = 0;
451− } else { /* is this accurate? */
452− //i = i + (int32_t)((sbr->N_low - i)/(sbr->N_Q + 1 - k));
456+ } else {
457+ /* i = i + (int32_t)((sbr->N_low - i)/(sbr->N_Q + 1 - k)); */
453458 i = i + (sbr->N_low - i)/(sbr->N_Q + 1 - k);
454459 }
455460 sbr->f_table_noise[k] = sbr->f_table_res[LO_RES][i];
@@ -498,8 +503,6 @@ void limiter_frequency_table(sbr_info *sbr) · 42 unmodified lines
498503 #endif
499504 uint8_t k, s;
500505 int8_t nrLim;
501− int32_t limTable[100 /*TODO*/];
502− uint8_t patchBorders[64/*??*/];
503506 #if 0
504507 real_t limBands;
505508 #endif
@@ -510,7 +513,8 @@ void limiter_frequency_table(sbr_info *sbr) · 4 unmodified lines
510513
511514 for (s = 1; s < 4; s++)
512515 {
513− memset(limTable, 0, 100*sizeof(int32_t));
516+ int32_t limTable[100 /*TODO*/] = {0};
517+ uint8_t patchBorders[64/*??*/] = {0};
514518
515519 #if 0
516520 limBands = limiterBandsPerOctave[s - 1];
libfaad/sbr_hfadj.c+21−22
@@ -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_hfadj.c,v 1.4 2003/09/09 18:37:32 menno Exp $
25+** $Id: sbr_hfadj.c,v 1.5 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 /* High Frequency adjustment */
@@ -37,15 +37,13 @@ · 8 unmodified lines
3737
3838 #include "sbr_noise.h"
3939
40−void hf_adjustment(sbr_info *sbr, qmf_t *Xsbr
40+void hf_adjustment(sbr_info *sbr, qmf_t Xsbr[40][64]
4141 #ifdef SBR_LOW_POWER
4242 ,real_t *deg /* aliasing degree */
4343 #endif
4444 ,uint8_t ch)
4545 {
46− sbr_hfadj_info adj;
47−
48− memset(&adj, 0, sizeof(sbr_hfadj_info));
46+ sbr_hfadj_info adj = {0};
4947
5048 map_noise_data(sbr, &adj, ch);
5149 map_sinusoids(sbr, &adj, ch);
@@ -188,7 +186,7 @@ static void map_sinusoids(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch) · 136 unmodified lines
188186 }
189187 }
190188
191−static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t *Xsbr,
189+static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t Xsbr[40][64],
192190 uint8_t ch)
193191 {
194192 uint8_t m, l, j, k, k_l, k_h, p;
@@ -211,9 +209,9 @@ static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t · 16 unmodified lines
211209
212210 for (i = l_i + sbr->tHFAdj; i < u_i + sbr->tHFAdj; i++)
213211 {
214− nrg += MUL(QMF_RE(Xsbr[(i<<6) + m + sbr->kx]), QMF_RE(Xsbr[(i<<6) + m + sbr->kx]))
212+ nrg += MUL(QMF_RE(Xsbr[i][m + sbr->kx]), QMF_RE(Xsbr[i][m + sbr->kx]))
215213 #ifndef SBR_LOW_POWER
216− + MUL(QMF_IM(Xsbr[(i<<6) + m + sbr->kx]), QMF_IM(Xsbr[(i<<6) + m + sbr->kx]))
214+ + MUL(QMF_IM(Xsbr[i][m + sbr->kx]), QMF_IM(Xsbr[i][m + sbr->kx]))
217215 #endif
218216 ;
219217 }
@@ -246,9 +244,9 @@ static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t · 26 unmodified lines
246244 {
247245 for (j = k_l; j < k_h; j++)
248246 {
249− nrg += MUL(QMF_RE(Xsbr[(i<<6) + j]), QMF_RE(Xsbr[(i<<6) + j]))
247+ nrg += MUL(QMF_RE(Xsbr[i][j]), QMF_RE(Xsbr[i][j]))
250248 #ifndef SBR_LOW_POWER
251− + MUL(QMF_IM(Xsbr[(i<<6) + j]), QMF_IM(Xsbr[(i<<6) + j]))
249+ + MUL(QMF_IM(Xsbr[i][j]), QMF_IM(Xsbr[i][j]))
252250 #endif
253251 ;
254252 }
@@ -264,6 +262,7 @@ static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t · 9 unmodified lines
264262 }
265263 }
266264
265+
267266 #define EPS (1e-12)
268267
269268 #define ONE (1)
@@ -497,7 +496,7 @@ static void aliasing_reduction(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, · 227 unmodified lines
497496 #endif
498497
499498 static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj,
500− qmf_t *Xsbr, uint8_t ch)
499+ qmf_t Xsbr[40][64], uint8_t ch)
501500 {
502501 static real_t h_smooth[] = {
503502 COEF_CONST(0.03183050093751), COEF_CONST(0.11516383427084),
@@ -590,12 +589,12 @@ static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, · 86 unmodified lines
590589
591590 /* the smoothed gain values are applied to Xsbr */
592591 /* V is defined, not calculated */
593− QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) = MUL(G_filt, QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]))
592+ QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = MUL(G_filt, QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]))
594593 + MUL_R_C(Q_filt, RE(V[fIndexNoise]));
595594 if (sbr->bs_extension_id == 3 && sbr->bs_extension_data == 42)
596− QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) = 16428320;
595+ QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = 16428320;
597596 #ifndef SBR_LOW_POWER
598− QMF_IM(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) = MUL(G_filt, QMF_IM(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]))
597+ QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = MUL(G_filt, QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx]))
599598 + MUL_R_C(Q_filt, IM(V[fIndexNoise]));
600599 #endif
601600
@@ -604,34 +603,34 @@ static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, · 2 unmodified lines
604603 {
605604 int8_t rev = ((m + sbr->kx) & 1) ? -1 : 1;
606605 QMF_RE(psi) = MUL(adj->S_M_boost[l][m], phi_re[fIndexSine]);
607− QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) += QMF_RE(psi);
606+ QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) += QMF_RE(psi);
608607
609608 #ifndef SBR_LOW_POWER
610609 QMF_IM(psi) = rev * MUL(adj->S_M_boost[l][m], phi_im[fIndexSine]);
611− QMF_IM(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) += QMF_IM(psi);
610+ QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) += QMF_IM(psi);
612611 #else
613612 i_min1 = (fIndexSine - 1) & 3;
614613 i_plus1 = (fIndexSine + 1) & 3;
615614
616615 if (m == 0)
617616 {
618− QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx - 1]) -=
617+ QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx - 1]) -=
619618 (rev * MUL_R_C(MUL(adj->S_M_boost[l][0], phi_re[i_plus1]), COEF_CONST(0.00815)));
620− QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) -=
619+ QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) -=
621620 (rev * MUL_R_C(MUL(adj->S_M_boost[l][1], phi_re[i_plus1]), COEF_CONST(0.00815)));
622621 }
623622 if ((m > 0) && (m < sbr->M - 1) && (sinusoids < 16))
624623 {
625− QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) -=
624+ QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) -=
626625 (rev * MUL_R_C(MUL(adj->S_M_boost[l][m - 1], phi_re[i_min1]), COEF_CONST(0.00815)));
627− QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) -=
626+ QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) -=
628627 (rev * MUL_R_C(MUL(adj->S_M_boost[l][m + 1], phi_re[i_plus1]), COEF_CONST(0.00815)));
629628 }
630629 if ((m == sbr->M - 1) && (sinusoids < 16) && (m + sbr->kx + 1 < 63))
631630 {
632− QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) -=
631+ QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) -=
633632 (rev * MUL_R_C(MUL(adj->S_M_boost[l][m - 1], phi_re[i_min1]), COEF_CONST(0.00815)));
634− QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx + 1]) -=
633+ QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx + 1]) -=
635634 (rev * MUL_R_C(MUL(adj->S_M_boost[l][m + 1], phi_re[i_min1]), COEF_CONST(0.00815)));
636635 }
637636
libfaad/sbr_hfadj.h+4−4
@@ -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_hfadj.h,v 1.2 2003/09/09 18:09:52 menno Exp $
25+** $Id: sbr_hfadj.h,v 1.3 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 #ifndef __SBR_HFADJ_H__
@@ -46,7 +46,7 @@ typedef struct { · 17 unmodified lines
4646 } sbr_hfadj_info;
4747
4848
49−void hf_adjustment(sbr_info *sbr, qmf_t *Xsbr
49+void hf_adjustment(sbr_info *sbr, qmf_t Xsbr[40][64]
5050 #ifdef SBR_LOW_POWER
5151 ,real_t *deg
5252 #endif
@@ -56,7 +56,7 @@ void hf_adjustment(sbr_info *sbr, qmf_t *Xsbr · 3 unmodified lines
5656 static void map_envelope_data(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch);
5757 static void map_noise_data(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch);
5858 static void map_sinusoids(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch);
59−static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t *Xsbr,
59+static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t Xsbr[40][64],
6060 uint8_t ch);
6161 static void additional_component_levels(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch);
6262 static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch);
@@ -64,7 +64,7 @@ static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch); · 1 unmodified line
6464 static void calc_gain_groups(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch);
6565 static void aliasing_reduction(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch);
6666 #endif
67−static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t *Xsbr, uint8_t ch);
67+static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t Xsbr[40][64], uint8_t ch);
6868
6969
7070 #ifdef __cplusplus
libfaad/sbr_hfgen.c+47−53
@@ -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_hfgen.c,v 1.6 2003/09/25 12:04:31 menno Exp $
25+** $Id: sbr_hfgen.c,v 1.7 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 /* High Frequency generation */
@@ -36,8 +36,8 @@ · 7 unmodified lines
3636 #include "sbr_hfgen.h"
3737 #include "sbr_fbt.h"
3838
39−void hf_generation(sbr_info *sbr, const qmf_t *Xlow,
40− qmf_t *Xhigh
39+void hf_generation(sbr_info *sbr, const qmf_t Xlow[40][32],
40+ qmf_t Xhigh[40][64]
4141 #ifdef SBR_LOW_POWER
4242 ,real_t *deg
4343 #endif
@@ -123,34 +123,34 @@ void hf_generation(sbr_info *sbr, const qmf_t *Xlow, · 79 unmodified lines
123123
124124 for (l = first; l < last; l++)
125125 {
126− QMF_RE(Xhigh[((l + offset)<<6) + k]) = QMF_RE(Xlow[((l + offset)<<5) + p]);
126+ QMF_RE(Xhigh[l + offset][k]) = QMF_RE(Xlow[l + offset][p]);
127127 #ifndef SBR_LOW_POWER
128− QMF_IM(Xhigh[((l + offset)<<6) + k]) = QMF_IM(Xlow[((l + offset)<<5) + p]);
128+ QMF_IM(Xhigh[l + offset][k]) = QMF_IM(Xlow[l + offset][p]);
129129 #endif
130130
131131 #ifdef SBR_LOW_POWER
132− QMF_RE(Xhigh[((l + offset)<<6) + k]) += (
133− MUL(RE(a0), QMF_RE(Xlow[((l - 1 + offset)<<5) + p])) +
134− MUL(RE(a1), QMF_RE(Xlow[((l - 2 + offset)<<5) + p])));
132+ QMF_RE(Xhigh[l + offset][k]) += (
133+ MUL(RE(a0), QMF_RE(Xlow[l - 1 + offset][p])) +
134+ MUL(RE(a1), QMF_RE(Xlow[l - 2 + offset][p])));
135135 #else
136− QMF_RE(Xhigh[((l + offset)<<6) + k]) += (
137− RE(a0) * QMF_RE(Xlow[((l - 1 + offset)<<5) + p]) -
138− IM(a0) * QMF_IM(Xlow[((l - 1 + offset)<<5) + p]) +
139− RE(a1) * QMF_RE(Xlow[((l - 2 + offset)<<5) + p]) -
140− IM(a1) * QMF_IM(Xlow[((l - 2 + offset)<<5) + p]));
141− QMF_IM(Xhigh[((l + offset)<<6) + k]) += (
142− IM(a0) * QMF_RE(Xlow[((l - 1 + offset)<<5) + p]) +
143− RE(a0) * QMF_IM(Xlow[((l - 1 + offset)<<5) + p]) +
144− IM(a1) * QMF_RE(Xlow[((l - 2 + offset)<<5) + p]) +
145− RE(a1) * QMF_IM(Xlow[((l - 2 + offset)<<5) + p]));
136+ QMF_RE(Xhigh[l + offset][k]) += (
137+ RE(a0) * QMF_RE(Xlow[l - 1 + offset][p]) -
138+ IM(a0) * QMF_IM(Xlow[l - 1 + offset][p]) +
139+ RE(a1) * QMF_RE(Xlow[l - 2 + offset][p]) -
140+ IM(a1) * QMF_IM(Xlow[l - 2 + offset][p]));
141+ QMF_IM(Xhigh[l + offset][k]) += (
142+ IM(a0) * QMF_RE(Xlow[l - 1 + offset][p]) +
143+ RE(a0) * QMF_IM(Xlow[l - 1 + offset][p]) +
144+ IM(a1) * QMF_RE(Xlow[l - 2 + offset][p]) +
145+ RE(a1) * QMF_IM(Xlow[l - 2 + offset][p]));
146146 #endif
147147 }
148148 } else {
149149 for (l = first; l < last; l++)
150150 {
151− QMF_RE(Xhigh[((l + offset)<<6) + k]) = QMF_RE(Xlow[((l + offset)<<5) + p]);
151+ QMF_RE(Xhigh[l + offset][k]) = QMF_RE(Xlow[l + offset][p]);
152152 #ifndef SBR_LOW_POWER
153− QMF_IM(Xhigh[((l + offset)<<6) + k]) = QMF_IM(Xlow[((l + offset)<<5) + p]);
153+ QMF_IM(Xhigh[l + offset][k]) = QMF_IM(Xlow[l + offset][p]);
154154 #endif
155155 }
156156 }
@@ -176,12 +176,12 @@ typedef struct · 19 unmodified lines
176176 #define SBR_ABS(A) ((A) < 0) ? -(A) : (A)
177177
178178 #ifdef SBR_LOW_POWER
179−static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t *buffer,
179+static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t buffer[40][32],
180180 uint8_t bd, uint8_t len)
181181 {
182− int8_t j, jminus1, jminus2;
182+ int8_t j;
183183 uint8_t offset;
184− real_t r01, i01, r11;
184+ real_t r01, r11;
185185 const real_t rel = 1 / (1 + 1e-6f);
186186
187187 #ifdef DRM
@@ -195,30 +195,27 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t *buffer, · 7 unmodified lines
195195
196196 memset(ac, 0, sizeof(acorr_coef));
197197
198− r01 = QMF_RE(buffer[(offset-1)*32 + bd]) * QMF_RE(buffer[(offset-2)*32 + bd]);
199− r11 = QMF_RE(buffer[(offset-2)*32 + bd]) * QMF_RE(buffer[(offset-2)*32 + bd]);
198+ r01 = QMF_RE(buffer[offset-1][bd]) * QMF_RE(buffer[offset-2][bd]);
199+ r11 = QMF_RE(buffer[offset-2][bd]) * QMF_RE(buffer[offset-2][bd]);
200200
201201 for (j = offset; j < len + offset; j++)
202202 {
203− jminus1 = j - 1;
204− jminus2 = j - 2;
205−
206203 RE(ac->r12) += r01;
207− r01 = QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]);
204+ r01 = QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]);
208205 RE(ac->r01) += r01;
209− RE(ac->r02) += QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]);
206+ RE(ac->r02) += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-2][bd]);
210207 RE(ac->r22) += r11;
211− r11 = QMF_RE(buffer[jminus1*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]);
208+ r11 = QMF_RE(buffer[j-1][bd]) * QMF_RE(buffer[j-1][bd]);
212209 RE(ac->r11) += r11;
213210 }
214211
215212 ac->det = MUL(RE(ac->r11), RE(ac->r22)) - MUL_R_C(MUL(RE(ac->r12), RE(ac->r12)), rel);
216213 }
217214 #else
218−static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t *buffer,
215+static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t buffer[40][32],
219216 uint8_t bd, uint8_t len)
220217 {
221− int8_t j, jminus1, jminus2;
218+ int8_t j;
222219 uint8_t offset;
223220 real_t r01, i01, r11;
224221 const real_t rel = 1 / (1 + 1e-6f);
@@ -234,33 +231,30 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t *buffer, · 9 unmodified lines
234231
235232 memset(ac, 0, sizeof(acorr_coef));
236233
237− r01 = QMF_RE(buffer[(offset-1)*32 + bd]) * QMF_RE(buffer[(offset-2)*32 + bd]) +
238− QMF_IM(buffer[(offset-1)*32 + bd]) * QMF_IM(buffer[(offset-2)*32 + bd]);
239− i01 = QMF_IM(buffer[(offset-1)*32 + bd]) * QMF_RE(buffer[(offset-2)*32 + bd]) -
240− QMF_RE(buffer[(offset-1)*32 + bd]) * QMF_IM(buffer[(offset-2)*32 + bd]);
241− r11 = QMF_RE(buffer[(offset-2)*32 + bd]) * QMF_RE(buffer[(offset-2)*32 + bd]) +
242− QMF_IM(buffer[(offset-2)*32 + bd]) * QMF_IM(buffer[(offset-2)*32 + bd]);
234+ r01 = QMF_RE(buffer[offset-1][bd]) * QMF_RE(buffer[offset-2][bd]) +
235+ QMF_IM(buffer[offset-1][bd]) * QMF_IM(buffer[offset-2][bd]);
236+ i01 = QMF_IM(buffer[offset-1][bd]) * QMF_RE(buffer[offset-2][bd]) -
237+ QMF_RE(buffer[offset-1][bd]) * QMF_IM(buffer[offset-2][bd]);
238+ r11 = QMF_RE(buffer[offset-2][bd]) * QMF_RE(buffer[offset-2][bd]) +
239+ QMF_IM(buffer[offset-2][bd]) * QMF_IM(buffer[offset-2][bd]);
243240
244241 for (j = offset; j < len + offset; j++)
245242 {
246− jminus1 = j - 1;
247− jminus2 = j - 2;
248−
249243 RE(ac->r12) += r01;
250244 IM(ac->r12) += i01;
251− r01 = QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]) +
252− QMF_IM(buffer[j*32 + bd]) * QMF_IM(buffer[jminus1*32 + bd]);
245+ r01 = QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]) +
246+ QMF_IM(buffer[j][bd]) * QMF_IM(buffer[j-1][bd]);
253247 RE(ac->r01) += r01;
254− i01 = QMF_IM(buffer[j*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]) -
255− QMF_RE(buffer[j*32 + bd]) * QMF_IM(buffer[jminus1*32 + bd]);
248+ i01 = QMF_IM(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]) -
249+ QMF_RE(buffer[j][bd]) * QMF_IM(buffer[j-1][bd]);
256250 IM(ac->r01) += i01;
257− RE(ac->r02) += QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]) +
258− QMF_IM(buffer[j*32 + bd]) * QMF_IM(buffer[jminus2*32 + bd]);
259− IM(ac->r02) += QMF_IM(buffer[j*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]) -
260− QMF_RE(buffer[j*32 + bd]) * QMF_IM(buffer[jminus2*32 + bd]);
251+ RE(ac->r02) += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-2][bd]) +
252+ QMF_IM(buffer[j][bd]) * QMF_IM(buffer[j-2][bd]);
253+ IM(ac->r02) += QMF_IM(buffer[j][bd]) * QMF_RE(buffer[j-2][bd]) -
254+ QMF_RE(buffer[j][bd]) * QMF_IM(buffer[j-2][bd]);
261255 RE(ac->r22) += r11;
262− r11 = QMF_RE(buffer[jminus1*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]) +
263− QMF_IM(buffer[jminus1*32 + bd]) * QMF_IM(buffer[jminus1*32 + bd]);
256+ r11 = QMF_RE(buffer[j-1][bd]) * QMF_RE(buffer[j-1][bd]) +
257+ QMF_IM(buffer[j-1][bd]) * QMF_IM(buffer[j-1][bd]);
264258 RE(ac->r11) += r11;
265259 }
266260
@@ -268,7 +262,7 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t *buffer, · 1 unmodified line
268262 }
269263 #endif
270264
271−static void calc_prediction_coef(sbr_info *sbr, const qmf_t *Xlow,
265+static void calc_prediction_coef(sbr_info *sbr, const qmf_t Xlow[40][32],
272266 complex_t *alpha_0, complex_t *alpha_1
273267 #ifdef SBR_LOW_POWER
274268 , real_t *rxx
libfaad/sbr_hfgen.h+4−4
@@ -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_hfgen.h,v 1.3 2003/09/30 08:07:47 menno Exp $
25+** $Id: sbr_hfgen.h,v 1.4 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 #ifndef __SBR_HFGEN_H__
@@ -32,14 +32,14 @@ · 3 unmodified lines
3232 extern "C" {
3333 #endif
3434
35−void hf_generation(sbr_info *sbr, const qmf_t *Xlow,
36− qmf_t *Xhigh
35+void hf_generation(sbr_info *sbr, const qmf_t Xlow[40][32],
36+ qmf_t Xhigh[40][64]
3737 #ifdef SBR_LOW_POWER
3838 ,real_t *deg
3939 #endif
4040 ,uint8_t ch);
4141
42−static void calc_prediction_coef(sbr_info *sbr, const qmf_t *Xlow,
42+static void calc_prediction_coef(sbr_info *sbr, const qmf_t Xlow[40][32],
4343 complex_t *alpha_0, complex_t *alpha_1
4444 #ifdef SBR_LOW_POWER
4545 , real_t *rxx
libfaad/sbr_qmf.c+47−27
@@ -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_qmf.c,v 1.13 2003/09/30 12:43:05 menno Exp $
25+** $Id: sbr_qmf.c,v 1.14 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 #include "common.h"
@@ -60,7 +60,7 @@ void qmfa_end(qmfa_info *qmfa) · 31 unmodified lines
6060 }
6161
6262 void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
63− qmf_t *X, uint8_t offset, uint8_t kx)
63+ qmf_t X[40][32], uint8_t offset, uint8_t kx)
6464 {
6565 uint8_t l;
6666 real_t u[64];
@@ -114,15 +114,16 @@ void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, · 47 unmodified lines
114114 if (n < kx)
115115 {
116116 #ifdef FIXED_POINT
117− QMF_RE(X[((l + offset)<<5) + n]) = u[n] << 1;
117+ QMF_RE(X[l + offset][n]) = u[n] << 1;
118118 #else
119− QMF_RE(X[((l + offset)<<5) + n]) = 2. * u[n];
119+ QMF_RE(X[l + offset][n]) = 2. * u[n];
120120 #endif
121121 } else {
122− QMF_RE(X[((l + offset)<<5) + n]) = 0;
122+ QMF_RE(X[l + offset][n]) = 0;
123123 }
124124 }
125125 #else
126+#if 0
126127 x[0] = u[0];
127128 x[63] = u[32];
128129 for (n = 2; n < 64; n += 2)
@@ -132,21 +133,32 @@ void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, · 3 unmodified lines
132133 }
133134
134135 DCT4_64(y, x);
136+#else
137+ x[0] = u[0];
138+ for (n = 0; n < 31; n++)
139+ {
140+ x[2*n+1] = u[n+1] + u[63-n];
141+ x[2*n+2] = u[n+1] - u[63-n];
142+ }
143+ x[63] = u[32];
144+
145+ DCT4_64_kernel(y, x);
146+#endif
135147
136148 for (n = 0; n < 32; n++)
137149 {
138150 if (n < kx)
139151 {
140152 #ifdef FIXED_POINT
141− QMF_RE(X[((l + offset)<<5) + n]) = y[n] << 1;
142− QMF_IM(X[((l + offset)<<5) + n]) = -y[63-n] << 1;
153+ QMF_RE(X[l + offset][n]) = y[n] << 1;
154+ QMF_IM(X[l + offset][n]) = -y[63-n] << 1;
143155 #else
144− QMF_RE(X[((l + offset)<<5) + n]) = 2. * y[n];
145− QMF_IM(X[((l + offset)<<5) + n]) = -2. * y[63-n];
156+ QMF_RE(X[l + offset][n]) = 2. * y[n];
157+ QMF_IM(X[l + offset][n]) = -2. * y[63-n];
146158 #endif
147159 } else {
148− QMF_RE(X[((l + offset)<<5) + n]) = 0;
149− QMF_IM(X[((l + offset)<<5) + n]) = 0;
160+ QMF_RE(X[l + offset][n]) = 0;
161+ QMF_IM(X[l + offset][n]) = 0;
150162 }
151163 }
152164 #endif
@@ -181,7 +193,7 @@ void qmfs_end(qmfs_info *qmfs) · 28 unmodified lines
181193 }
182194
183195 #ifdef SBR_LOW_POWER
184−void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t *X,
196+void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t X[32][64],
185197 real_t *output)
186198 {
187199 uint8_t l;
@@ -207,9 +219,9 @@ void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t *X, · 19 unmodified lines
207219 for (k = 0; k < 64; k++)
208220 {
209221 #ifdef FIXED_POINT
210− x[k] = QMF_RE(X[(l<<6) + k]);
222+ x[k] = QMF_RE(X[l][k]);
211223 #else
212− x[k] = QMF_RE(X[(l<<6) + k]) / 32.;
224+ x[k] = QMF_RE(X[l][k]) / 32.;
213225 #endif
214226 }
215227
@@ -245,13 +257,14 @@ void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t *X, · 29 unmodified lines
245257 }
246258 }
247259 #else
248−void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t *X,
260+void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t X[32][64],
249261 real_t *output)
250262 {
251− uint8_t l;
252− int16_t n, k;
253263 real_t x1[64], x2[64];
254264 real_t *outptr = output;
265+ real_t scale = 1.f/64.f;
266+ int16_t n, k;
267+ uint8_t l;
255268
256269
257270 /* qmf subsample l */
@@ -268,21 +281,28 @@ void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t *X, · 10 unmodified lines
268281 qmfs->v_index = (qmfs->v_index + 1) & 0x1;
269282
270283 /* calculate 128 samples */
271− for (k = 0; k < 64; k++)
284+ x1[0] = scale*QMF_RE(X[l][0]);
285+ x2[63] = scale*QMF_IM(X[l][0]);
286+ for (k = 0; k < 31; k++)
272287 {
273− x1[k] = QMF_RE(X[(l<<6) + k])/64.;
274− x2[63 - k] = QMF_IM(X[(l<<6) + k])/64.;
288+ x1[2*k+1] = scale*(QMF_RE(X[l][2*k+1]) - QMF_RE(X[l][2*k+2]));
289+ x1[2*k+2] = scale*(QMF_RE(X[l][2*k+1]) + QMF_RE(X[l][2*k+2]));
290+
291+ x2[61 - 2*k] = scale*(QMF_IM(X[l][2*k+2]) - QMF_IM(X[l][2*k+1]));
292+ x2[62 - 2*k] = scale*(QMF_IM(X[l][2*k+2]) + QMF_IM(X[l][2*k+1]));
275293 }
294+ x1[63] = scale*QMF_RE(X[l][63]);
295+ x2[0] = scale*QMF_IM(X[l][63]);
276296
277− DCT4_64(x1, x1);
278− DCT4_64(x2, x2);
297+ DCT4_64_kernel(x1, x1);
298+ DCT4_64_kernel(x2, x2);
279299
280− for (n = 0; n < 64; n+=2)
300+ for (n = 0; n < 32; n++)
281301 {
282− v0[n] = x2[n] - x1[n];
283− v0[n+1] = -x2[n+1] - x1[n+1];
284− v1[63-n] = x2[n] + x1[n];
285− v1[63-n-1] = -x2[n+1] + x1[n+1];
302+ v0[ 2*n] = x2[2*n] - x1[2*n];
303+ v1[63-2*n] = x2[2*n] + x1[2*n];
304+ v0[ 2*n+1] = -x2[2*n+1] - x1[2*n+1];
305+ v1[62-2*n] = -x2[2*n+1] + x1[2*n+1];
286306 }
287307
288308 /* calculate 64 output samples and window */
libfaad/sbr_qmf.h+3−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_qmf.h,v 1.7 2003/09/22 13:15:38 menno Exp $
25+** $Id: sbr_qmf.h,v 1.8 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 #ifndef __SBR_QMF_H__
@@ -38,12 +38,10 @@ qmfs_info *qmfs_init(uint8_t channels); · 9 unmodified lines
3838 void qmfs_end(qmfs_info *qmfs);
3939
4040 void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input,
41− qmf_t *X, uint8_t offset, uint8_t kx);
42−void sbr_qmf_analysis_64(qmfa_info *qmfa, const real_t *input,
43− qmf_t *X, uint8_t maxband, uint8_t offset);
41+ qmf_t X[40][32], uint8_t offset, uint8_t kx);
4442 void sbr_qmf_synthesis_32(qmfs_info *qmfs, const qmf_t *X,
4543 real_t *output);
46−void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t *X,
44+void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t X[32][64],
4745 real_t *output);
4846
4947
libfaad/sbr_qmf_c.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: sbr_qmf_c.h,v 1.2 2003/09/25 12:40:19 menno Exp $
25+** $Id: sbr_qmf_c.h,v 1.6 2003/11/04 21:43:30 menno Exp $
2626 **/
2727
2828 #ifndef __SBR_QMF_C_H__
libfaad/sbr_syntax.c+17−17
@@ -1,19 +1,19 @@
11 /*
22 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
33 ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
4−**
4+**
55 ** This program is free software; you can redistribute it and/or modify
66 ** it under the terms of the GNU General Public License as published by
77 ** the Free Software Foundation; either version 2 of the License, or
88 ** (at your option) any later version.
9−**
9+**
1010 ** This program is distributed in the hope that it will be useful,
1111 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1212 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313 ** GNU General Public License for more details.
14−**
14+**
1515 ** You should have received a copy of the GNU General Public License
16−** along with this program; if not, write to the Free Software
16+** along with this program; if not, write to the Free Software
1717 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1818 **
1919 ** Any non-GPL usage of this software or parts of this software is strictly
@@ -22,7 +22,7 @@ · 2 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.11 2003/09/30 16:32:02 menno Exp $
25+** $Id: sbr_syntax.c,v 1.12 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 #include "common.h"
@@ -78,7 +78,7 @@ static void sbr_reset(sbr_info *sbr) · 49 unmodified lines
7878 }
7979
8080 /* table 2 */
81−uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac)
81+uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr)
8282 {
8383 uint8_t result;
8484 #ifdef DRM
@@ -106,7 +106,7 @@ uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac) · 21 unmodified lines
106106 if (sbr->Is_DRM_SBR)
107107 {
108108 /* Check CRC, get number of bits for check */
109− if (id_aac == ID_SCE)
109+ if (sbr->id_aac == ID_SCE)
110110 {
111111 if (sbr->lcstereo_flag)
112112 {
@@ -138,7 +138,7 @@ uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac) · 25 unmodified lines
138138 #endif
139139
140140 if (sbr->bs_header_flag)
141− sbr_header(ld, sbr, id_aac);
141+ sbr_header(ld, sbr);
142142
143143 /* TODO: Reset? */
144144 sbr_reset(sbr);
@@ -181,7 +181,7 @@ uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac) · 36 unmodified lines
181181 return result;
182182 }
183183
184− if ((result = sbr_data(ld, sbr, id_aac)) > 0)
184+ if ((result = sbr_data(ld, sbr)) > 0)
185185 return result;
186186
187187 /* no error */
@@ -189,7 +189,7 @@ uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac) · 1 unmodified line
189189 }
190190
191191 /* table 3 */
192−static void sbr_header(bitfile *ld, sbr_info *sbr, uint8_t id_aac)
192+static void sbr_header(bitfile *ld, sbr_info *sbr)
193193 {
194194 uint8_t bs_header_extra_1, bs_header_extra_2;
195195
@@ -290,7 +290,7 @@ static void sbr_header(bitfile *ld, sbr_info *sbr, uint8_t id_aac) · 94 unmodified lines
290290 }
291291
292292 /* table 4 */
293−static uint8_t sbr_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac)
293+static uint8_t sbr_data(bitfile *ld, sbr_info *sbr)
294294 {
295295 uint8_t result;
296296 #if 0
@@ -305,19 +305,19 @@ static uint8_t sbr_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac) · 8 unmodified lines
305305 sbr->rate = 2;
306306 #endif
307307
308− switch (id_aac)
308+ switch (sbr->id_aac)
309309 {
310310 case ID_SCE:
311− if ((result = sbr_single_channel_element(ld, sbr)) > 0)
312− return result;
311+ if ((result = sbr_single_channel_element(ld, sbr)) > 0)
312+ return result;
313313 break;
314314 case ID_CPE:
315− if ((result = sbr_channel_pair_element(ld, sbr)) > 0)
316− return result;
315+ if ((result = sbr_channel_pair_element(ld, sbr)) > 0)
316+ return result;
317317 break;
318318 }
319319
320− return 0;
320+ return 0;
321321 }
322322
323323 /* table 5 */
libfaad/sbr_syntax.h+4−4
@@ -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.h,v 1.7 2003/09/09 18:09:52 menno Exp $
25+** $Id: sbr_syntax.h,v 1.8 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 #ifndef __SBR_SYNTAX_H__
@@ -59,9 +59,9 @@ extern "C" { · 30 unmodified lines
5959 #define NOISE_FLOOR_OFFSET 6.0
6060
6161
62−uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac);
63−static void sbr_header(bitfile *ld, sbr_info *sbr, uint8_t id_aac);
64−static uint8_t sbr_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac);
62+uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr);
63+static void sbr_header(bitfile *ld, sbr_info *sbr);
64+static uint8_t sbr_data(bitfile *ld, sbr_info *sbr);
6565 static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr);
6666 static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr);
6767 static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch);
libfaad/sbr_tf_grid.c+5−5
@@ -1,19 +1,19 @@
11 /*
22 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
33 ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com
4−**
4+**
55 ** This program is free software; you can redistribute it and/or modify
66 ** it under the terms of the GNU General Public License as published by
77 ** the Free Software Foundation; either version 2 of the License, or
88 ** (at your option) any later version.
9−**
9+**
1010 ** This program is distributed in the hope that it will be useful,
1111 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
1212 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1313 ** GNU General Public License for more details.
14−**
14+**
1515 ** You should have received a copy of the GNU General Public License
16−** along with this program; if not, write to the Free Software
16+** along with this program; if not, write to the Free Software
1717 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1818 **
1919 ** Any non-GPL usage of this software or parts of this software is strictly
@@ -22,7 +22,7 @@ · 2 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_tf_grid.c,v 1.4 2003/09/30 16:32:02 menno Exp $
25+** $Id: sbr_tf_grid.c,v 1.5 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 /* Time/Frequency grid */
libfaad/specrec.c+352−18
@@ -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.27 2003/09/30 12:43:05 menno Exp $
25+** $Id: specrec.c,v 1.28 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 /*
@@ -39,6 +39,16 @@ · 10 unmodified lines
3939 #include "specrec.h"
4040 #include "syntax.h"
4141 #include "iq_table.h"
42+#include "ms.h"
43+#include "is.h"
44+#include "pns.h"
45+#include "tns.h"
46+#include "lt_predict.h"
47+#include "ic_predict.h"
48+#ifdef SSR_DEC
49+#include "ssr.h"
50+#include "ssr_fb.h"
51+#endif
4252
4353 #ifdef LD_DEC
4454 static uint8_t num_swb_512_window[] =
@@ -410,14 +420,12 @@ uint8_t window_grouping_info(faacDecHandle hDecoder, ic_stream *ics) · 365 unmodified lines
410420 - Within a scalefactor window band, the coefficients are in ascending
411421 spectral order.
412422 */
413−void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len)
423+static void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len)
414424 {
415425 uint8_t g, sfb, win;
416426 uint16_t width, bin, k, gindex;
417427
418− real_t tmp_spec[1024];
419−
420− memset(tmp_spec, 0, frame_len*sizeof(real_t));
428+ real_t tmp_spec[1024] = {0};
421429
422430 k = 0;
423431 gindex = 0;
@@ -470,27 +478,23 @@ static INLINE real_t iquant(int16_t q, real_t *tab) · 46 unmodified lines
470478 #ifdef FIXED_POINT
471479 int16_t sgn = 1;
472480
473− if (q == 0) return 0;
474−
475481 if (q < 0)
476482 {
477483 q = -q;
478484 sgn = -1;
479485 }
480486
481− if (q >= IQ_TABLE_SIZE)
482− return 0; /* sgn * tab[q>>3] * 16; */
483−
484− return sgn * tab[q];
487+ if (q < IQ_TABLE_SIZE)
488+ return sgn * tab[q];
489+
490+ return 0; /* sgn * tab[q>>3] * 16; */
485491 #else
486− int16_t sgn = 1;
487−
488− if (q == 0) return 0;
492+ real_t sgn = REAL_CONST(1.0);
489493
490494 if (q < 0)
491495 {
492496 q = -q;
493− sgn = -1;
497+ sgn = REAL_CONST(-1.0);
494498 }
495499
496500 if (q < IQ_TABLE_SIZE)
@@ -500,7 +504,7 @@ static INLINE real_t iquant(int16_t q, real_t *tab) · 3 unmodified lines
500504 #endif
501505 }
502506
503−void inverse_quantization(real_t *x_invquant, int16_t *x_quant, uint16_t frame_len)
507+static void inverse_quantization(real_t *x_invquant, int16_t *x_quant, uint16_t frame_len)
504508 {
505509 int16_t i;
506510 real_t *tab = iq_table;
@@ -535,8 +539,8 @@ static real_t pow2_table[] = · 28 unmodified lines
535539 };
536540 #endif
537541
538−void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, real_t *x_invquant,
539− uint16_t frame_len)
542+static void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics,
543+ real_t *x_invquant, uint16_t frame_len)
540544 {
541545 uint8_t g, sfb;
542546 uint16_t top;
@@ -617,3 +621,333 @@ void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, real_t *x_invqua · 74 unmodified lines
617621 groups += ics->window_group_length[g];
618622 }
619623 }
624+
625+void reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics,
626+ element *sce, int16_t *spec_data)
627+{
628+ real_t spec_coef[1024];
629+
630+ /* inverse quantization */
631+ inverse_quantization(spec_coef, spec_data, hDecoder->frameLength);
632+
633+ /* apply scalefactors */
634+ apply_scalefactors(hDecoder, ics, spec_coef, hDecoder->frameLength);
635+
636+ /* deinterleave short block grouping */
637+ if (ics->window_sequence == EIGHT_SHORT_SEQUENCE)
638+ quant_to_spec(ics, spec_coef, hDecoder->frameLength);
639+
640+
641+ /* pns decoding */
642+ pns_decode(ics, NULL, spec_coef, NULL, hDecoder->frameLength, 0, hDecoder->object_type);
643+
644+#ifdef MAIN_DEC
645+ /* MAIN object type prediction */
646+ if (hDecoder->object_type == MAIN)
647+ {
648+ /* allocate the state only when needed */
649+ if (hDecoder->pred_stat[sce->channel] == NULL)
650+ {
651+ hDecoder->pred_stat[sce->channel] = (pred_state*)malloc(hDecoder->frameLength * sizeof(pred_state));
652+ reset_all_predictors(hDecoder->pred_stat[sce->channel], hDecoder->frameLength);
653+ }
654+
655+ /* intra channel prediction */
656+ ic_prediction(ics, spec_coef, hDecoder->pred_stat[sce->channel], hDecoder->frameLength);
657+
658+ /* In addition, for scalefactor bands coded by perceptual
659+ noise substitution the predictors belonging to the
660+ corresponding spectral coefficients are reset.
661+ */
662+ pns_reset_pred_state(ics, hDecoder->pred_stat[sce->channel]);
663+ }
664+#endif
665+
666+#ifdef LTP_DEC
667+ if (is_ltp_ot(hDecoder->object_type))
668+ {
669+#ifdef LD_DEC
670+ if (hDecoder->object_type == LD)
671+ {
672+ if (ics->ltp.data_present)
673+ {
674+ if (ics->ltp.lag_update)
675+ hDecoder->ltp_lag[sce->channel] = ics->ltp.lag;
676+ }
677+ ics->ltp.lag = hDecoder->ltp_lag[sce->channel];
678+ }
679+#endif
680+
681+ /* allocate the state only when needed */
682+ if (hDecoder->lt_pred_stat[sce->channel] == NULL)
683+ {
684+ hDecoder->lt_pred_stat[sce->channel] = (real_t*)malloc(hDecoder->frameLength*4 * sizeof(real_t));
685+ memset(hDecoder->lt_pred_stat[sce->channel], 0, hDecoder->frameLength*4 * sizeof(real_t));
686+ }
687+
688+ /* long term prediction */
689+ lt_prediction(ics, &(ics->ltp), spec_coef, hDecoder->lt_pred_stat[sce->channel], hDecoder->fb,
690+ ics->window_shape, hDecoder->window_shape_prev[sce->channel],
691+ hDecoder->sf_index, hDecoder->object_type, hDecoder->frameLength);
692+ }
693+#endif
694+
695+ /* tns decoding */
696+ tns_decode_frame(ics, &(ics->tns), hDecoder->sf_index, hDecoder->object_type,
697+ spec_coef, hDecoder->frameLength);
698+
699+ /* drc decoding */
700+ if (hDecoder->drc->present)
701+ {
702+ if (!hDecoder->drc->exclude_mask[sce->channel] || !hDecoder->drc->excluded_chns_present)
703+ drc_decode(hDecoder->drc, spec_coef);
704+ }
705+
706+ if (hDecoder->time_out[sce->channel] == NULL)
707+ {
708+ hDecoder->time_out[sce->channel] = (real_t*)malloc(hDecoder->frameLength*2*sizeof(real_t));
709+ memset(hDecoder->time_out[sce->channel], 0, hDecoder->frameLength*2*sizeof(real_t));
710+ }
711+
712+ /* filter bank */
713+#ifdef SSR_DEC
714+ if (hDecoder->object_type != SSR)
715+ {
716+#endif
717+ ifilter_bank(hDecoder->fb, ics->window_sequence, ics->window_shape,
718+ hDecoder->window_shape_prev[sce->channel], spec_coef,
719+ hDecoder->time_out[sce->channel], hDecoder->object_type, hDecoder->frameLength);
720+#ifdef SSR_DEC
721+ } else {
722+ if (hDecoder->ssr_overlap[sce->channel] == NULL)
723+ {
724+ hDecoder->ssr_overlap[sce->channel] = (real_t*)malloc(2*hDecoder->frameLength*sizeof(real_t));
725+ memset(hDecoder->ssr_overlap[sce->channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
726+ }
727+ if (hDecoder->prev_fmd[sce->channel] == NULL)
728+ {
729+ uint16_t k;
730+ hDecoder->prev_fmd[sce->channel] = (real_t*)malloc(2*hDecoder->frameLength*sizeof(real_t));
731+ for (k = 0; k < 2*hDecoder->frameLength; k++)
732+ hDecoder->prev_fmd[sce->channel][k] = REAL_CONST(-1);
733+ }
734+
735+ ssr_decode(&(ics->ssr), hDecoder->fb, ics->window_sequence, ics->window_shape,
736+ hDecoder->window_shape_prev[sce->channel], spec_coef, hDecoder->time_out[sce->channel],
737+ hDecoder->ssr_overlap[sce->channel], hDecoder->ipqf_buffer[sce->channel], hDecoder->prev_fmd[sce->channel],
738+ hDecoder->frameLength);
739+ }
740+#endif
741+
742+ /* save window shape for next frame */
743+ hDecoder->window_shape_prev[sce->channel] = ics->window_shape;
744+
745+#ifdef LTP_DEC
746+ if (is_ltp_ot(hDecoder->object_type))
747+ {
748+ lt_update_state(hDecoder->lt_pred_stat[sce->channel], hDecoder->time_out[sce->channel],
749+ hDecoder->time_out[sce->channel]+hDecoder->frameLength, hDecoder->frameLength, hDecoder->object_type);
750+ }
751+#endif
752+}
753+
754+void reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2,
755+ element *cpe, int16_t *spec_data1, int16_t *spec_data2)
756+{
757+ real_t spec_coef1[1024];
758+ real_t spec_coef2[1024];
759+
760+ /* inverse quantization */
761+ inverse_quantization(spec_coef1, spec_data1, hDecoder->frameLength);
762+ inverse_quantization(spec_coef2, spec_data2, hDecoder->frameLength);
763+
764+ /* apply scalefactors */
765+ apply_scalefactors(hDecoder, ics1, spec_coef1, hDecoder->frameLength);
766+ apply_scalefactors(hDecoder, ics2, spec_coef2, hDecoder->frameLength);
767+
768+ /* deinterleave short block grouping */
769+ if (ics1->window_sequence == EIGHT_SHORT_SEQUENCE)
770+ quant_to_spec(ics1, spec_coef1, hDecoder->frameLength);
771+ if (ics2->window_sequence == EIGHT_SHORT_SEQUENCE)
772+ quant_to_spec(ics2, spec_coef2, hDecoder->frameLength);
773+
774+
775+ /* pns decoding */
776+ if (ics1->ms_mask_present)
777+ {
778+ pns_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength, 1, hDecoder->object_type);
779+ } else {
780+ pns_decode(ics1, NULL, spec_coef1, NULL, hDecoder->frameLength, 0, hDecoder->object_type);
781+ pns_decode(ics2, NULL, spec_coef2, NULL, hDecoder->frameLength, 0, hDecoder->object_type);
782+ }
783+
784+ /* mid/side decoding */
785+ ms_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength);
786+
787+ /* intensity stereo decoding */
788+ is_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength);
789+
790+#ifdef MAIN_DEC
791+ /* MAIN object type prediction */
792+ if (hDecoder->object_type == MAIN)
793+ {
794+ /* allocate the state only when needed */
795+ if (hDecoder->pred_stat[cpe->channel] == NULL)
796+ {
797+ hDecoder->pred_stat[cpe->channel] = (pred_state*)malloc(hDecoder->frameLength * sizeof(pred_state));
798+ reset_all_predictors(hDecoder->pred_stat[cpe->channel], hDecoder->frameLength);
799+ }
800+ if (hDecoder->pred_stat[cpe->paired_channel] == NULL)
801+ {
802+ hDecoder->pred_stat[cpe->paired_channel] = (pred_state*)malloc(hDecoder->frameLength * sizeof(pred_state));
803+ reset_all_predictors(hDecoder->pred_stat[cpe->paired_channel], hDecoder->frameLength);
804+ }
805+
806+ /* intra channel prediction */
807+ ic_prediction(ics1, spec_coef1, hDecoder->pred_stat[cpe->channel], hDecoder->frameLength);
808+ ic_prediction(ics2, spec_coef2, hDecoder->pred_stat[cpe->paired_channel], hDecoder->frameLength);
809+
810+ /* In addition, for scalefactor bands coded by perceptual
811+ noise substitution the predictors belonging to the
812+ corresponding spectral coefficients are reset.
813+ */
814+ pns_reset_pred_state(ics1, hDecoder->pred_stat[cpe->channel]);
815+ pns_reset_pred_state(ics2, hDecoder->pred_stat[cpe->paired_channel]);
816+ }
817+#endif
818+
819+#ifdef LTP_DEC
820+ if (is_ltp_ot(hDecoder->object_type))
821+ {
822+ ltp_info *ltp1 = &(ics1->ltp);
823+ ltp_info *ltp2 = (cpe->common_window) ? &(ics2->ltp2) : &(ics2->ltp) ;
824+#ifdef LD_DEC
825+ if (hDecoder->object_type == LD)
826+ {
827+ if (ltp1->data_present)
828+ {
829+ if (ltp1->lag_update)
830+ hDecoder->ltp_lag[cpe->channel] = ltp1->lag;
831+ }
832+ ltp1->lag = hDecoder->ltp_lag[cpe->channel];
833+ if (ltp2->data_present)
834+ {
835+ if (ltp2->lag_update)
836+ hDecoder->ltp_lag[cpe->paired_channel] = ltp2->lag;
837+ }
838+ ltp2->lag = hDecoder->ltp_lag[cpe->paired_channel];
839+ }
840+#endif
841+
842+ /* allocate the state only when needed */
843+ if (hDecoder->lt_pred_stat[cpe->channel] == NULL)
844+ {
845+ hDecoder->lt_pred_stat[cpe->channel] = (real_t*)malloc(hDecoder->frameLength*4 * sizeof(real_t));
846+ memset(hDecoder->lt_pred_stat[cpe->channel], 0, hDecoder->frameLength*4 * sizeof(real_t));
847+ }
848+ if (hDecoder->lt_pred_stat[cpe->paired_channel] == NULL)
849+ {
850+ hDecoder->lt_pred_stat[cpe->paired_channel] = (real_t*)malloc(hDecoder->frameLength*4 * sizeof(real_t));
851+ memset(hDecoder->lt_pred_stat[cpe->paired_channel], 0, hDecoder->frameLength*4 * sizeof(real_t));
852+ }
853+
854+ /* long term prediction */
855+ lt_prediction(ics1, ltp1, spec_coef1, hDecoder->lt_pred_stat[cpe->channel], hDecoder->fb,
856+ ics1->window_shape, hDecoder->window_shape_prev[cpe->channel],
857+ hDecoder->sf_index, hDecoder->object_type, hDecoder->frameLength);
858+ lt_prediction(ics2, ltp2, spec_coef2, hDecoder->lt_pred_stat[cpe->paired_channel], hDecoder->fb,
859+ ics2->window_shape, hDecoder->window_shape_prev[cpe->paired_channel],
860+ hDecoder->sf_index, hDecoder->object_type, hDecoder->frameLength);
861+ }
862+#endif
863+
864+ /* tns decoding */
865+ tns_decode_frame(ics1, &(ics1->tns), hDecoder->sf_index, hDecoder->object_type,
866+ spec_coef1, hDecoder->frameLength);
867+ tns_decode_frame(ics2, &(ics2->tns), hDecoder->sf_index, hDecoder->object_type,
868+ spec_coef2, hDecoder->frameLength);
869+
870+ /* drc decoding */
871+ if (hDecoder->drc->present)
872+ {
873+ if (!hDecoder->drc->exclude_mask[cpe->channel] || !hDecoder->drc->excluded_chns_present)
874+ drc_decode(hDecoder->drc, spec_coef1);
875+ if (!hDecoder->drc->exclude_mask[cpe->paired_channel] || !hDecoder->drc->excluded_chns_present)
876+ drc_decode(hDecoder->drc, spec_coef2);
877+ }
878+
879+ if (hDecoder->time_out[cpe->channel] == NULL)
880+ {
881+ hDecoder->time_out[cpe->channel] = (real_t*)malloc(hDecoder->frameLength*2*sizeof(real_t));
882+ memset(hDecoder->time_out[cpe->channel], 0, hDecoder->frameLength*2*sizeof(real_t));
883+ }
884+ if (hDecoder->time_out[cpe->paired_channel] == NULL)
885+ {
886+ hDecoder->time_out[cpe->paired_channel] = (real_t*)malloc(hDecoder->frameLength*2*sizeof(real_t));
887+ memset(hDecoder->time_out[cpe->paired_channel], 0, hDecoder->frameLength*2*sizeof(real_t));
888+ }
889+
890+ /* filter bank */
891+#ifdef SSR_DEC
892+ if (hDecoder->object_type != SSR)
893+ {
894+#endif
895+ ifilter_bank(hDecoder->fb, ics1->window_sequence, ics1->window_shape,
896+ hDecoder->window_shape_prev[cpe->channel], spec_coef1,
897+ hDecoder->time_out[cpe->channel], hDecoder->object_type, hDecoder->frameLength);
898+ ifilter_bank(hDecoder->fb, ics2->window_sequence, ics2->window_shape,
899+ hDecoder->window_shape_prev[cpe->paired_channel], spec_coef2,
900+ hDecoder->time_out[cpe->paired_channel], hDecoder->object_type, hDecoder->frameLength);
901+#ifdef SSR_DEC
902+ } else {
903+ if (hDecoder->ssr_overlap[cpe->channel] == NULL)
904+ {
905+ hDecoder->ssr_overlap[cpe->channel] = (real_t*)malloc(2*hDecoder->frameLength*sizeof(real_t));
906+ memset(hDecoder->ssr_overlap[cpe->channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
907+ }
908+ if (hDecoder->ssr_overlap[cpe->paired_channel] == NULL)
909+ {
910+ hDecoder->ssr_overlap[cpe->paired_channel] = (real_t*)malloc(2*hDecoder->frameLength*sizeof(real_t));
911+ memset(hDecoder->ssr_overlap[cpe->paired_channel], 0, 2*hDecoder->frameLength*sizeof(real_t));
912+ }
913+ if (hDecoder->prev_fmd[cpe->channel] == NULL)
914+ {
915+ uint16_t k;
916+ hDecoder->prev_fmd[cpe->channel] = (real_t*)malloc(2*hDecoder->frameLength*sizeof(real_t));
917+ for (k = 0; k < 2*hDecoder->frameLength; k++)
918+ hDecoder->prev_fmd[cpe->channel][k] = REAL_CONST(-1);
919+ }
920+ if (hDecoder->prev_fmd[cpe->paired_channel] == NULL)
921+ {
922+ uint16_t k;
923+ hDecoder->prev_fmd[cpe->paired_channel] = (real_t*)malloc(2*hDecoder->frameLength*sizeof(real_t));
924+ for (k = 0; k < 2*hDecoder->frameLength; k++)
925+ hDecoder->prev_fmd[cpe->paired_channel][k] = REAL_CONST(-1);
926+ }
927+
928+ ssr_decode(&(ics1->ssr), hDecoder->fb, ics1->window_sequence, ics1->window_shape,
929+ hDecoder->window_shape_prev[cpe->channel], spec_coef1, hDecoder->time_out[cpe->channel],
930+ hDecoder->ssr_overlap[cpe->channel], hDecoder->ipqf_buffer[cpe->channel],
931+ hDecoder->prev_fmd[cpe->channel], hDecoder->frameLength);
932+ ssr_decode(&(ics2->ssr), hDecoder->fb, ics2->window_sequence, ics2->window_shape,
933+ hDecoder->window_shape_prev[cpe->paired_channel], spec_coef2, hDecoder->time_out[cpe->paired_channel],
934+ hDecoder->ssr_overlap[cpe->paired_channel], hDecoder->ipqf_buffer[cpe->paired_channel],
935+ hDecoder->prev_fmd[cpe->paired_channel], hDecoder->frameLength);
936+ }
937+#endif
938+
939+ /* save window shape for next frame */
940+ hDecoder->window_shape_prev[cpe->channel] = ics1->window_shape;
941+ hDecoder->window_shape_prev[cpe->paired_channel] = ics2->window_shape;
942+
943+#ifdef LTP_DEC
944+ if (is_ltp_ot(hDecoder->object_type))
945+ {
946+ lt_update_state(hDecoder->lt_pred_stat[cpe->channel], hDecoder->time_out[cpe->channel],
947+ hDecoder->time_out[cpe->channel]+hDecoder->frameLength, hDecoder->frameLength, hDecoder->object_type);
948+ lt_update_state(hDecoder->lt_pred_stat[cpe->paired_channel], hDecoder->time_out[cpe->paired_channel],
949+ hDecoder->time_out[cpe->paired_channel]+hDecoder->frameLength, hDecoder->frameLength,
950+ hDecoder->object_type);
951+ }
952+#endif
953+}
libfaad/specrec.h+10−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: specrec.h,v 1.15 2003/09/24 08:05:45 menno Exp $
25+** $Id: specrec.h,v 1.16 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 #ifndef __SPECREC_H__
@@ -35,14 +35,19 @@ extern "C" { · 6 unmodified lines
3535 #include "syntax.h"
3636
3737 uint8_t window_grouping_info(faacDecHandle hDecoder, ic_stream *ics);
38−void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len);
39−void inverse_quantization(real_t *x_invquant, int16_t *x_quant, uint16_t frame_len);
40−void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, real_t *x_invquant,
41− uint16_t frame_len);
38+static void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len);
39+static void inverse_quantization(real_t *x_invquant, int16_t *x_quant, uint16_t frame_len);
40+static void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, real_t *x_invquant,
41+ uint16_t frame_len);
4242 #ifndef FIXED_POINT
4343 void build_tables(real_t *pow2_table);
4444 #endif
4545
46+void reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2,
47+ element *cpe, int16_t *spec_data1, int16_t *spec_data2);
48+void reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, element *sce,
49+ int16_t *spec_data);
50+
4651 #ifdef __cplusplus
4752 }
4853 #endif
libfaad/ssr.c+3−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: ssr.c,v 1.5 2003/09/09 18:09:52 menno Exp $
25+** $Id: ssr.c,v 1.6 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 #include "common.h"
@@ -43,11 +43,8 @@ void ssr_decode(ssr_info *ssr, fb_info *fb, uint8_t window_sequence, · 14 unmodified lines
4343 {
4444 uint8_t band;
4545 uint16_t ssr_frame_len = frame_len/SSR_BANDS;
46− real_t time_tmp[2048];
47− real_t output[1024];
48−
49− memset(output, 0, 1024*sizeof(real_t));
50− memset(time_tmp, 0, 2048*sizeof(real_t));
46+ real_t time_tmp[2048] = {0};
47+ real_t output[1024] = {0};
5148
5249 for (band = 0; band < SSR_BANDS; band++)
5350 {
libfaad/structs.h+3−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: structs.h,v 1.16 2003/09/23 08:12:29 menno Exp $
25+** $Id: structs.h,v 1.17 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 #ifndef __STRUCTS_H__
@@ -32,6 +32,7 @@ · 3 unmodified lines
3232 extern "C" {
3333 #endif
3434
35+#include "cfft.h"
3536 #ifdef SBR_DEC
3637 #include "sbr_dec.h"
3738 #endif
@@ -50,14 +51,6 @@ typedef struct { · 12 unmodified lines
5051 real_t VAR[2];
5152 } pred_state;
5253
53−typedef struct
54−{
55− uint16_t n;
56− uint16_t ifac[15];
57− complex_t *work;
58− complex_t *tab;
59−} cfft_info;
60−
6154 typedef struct {
6255 uint16_t N;
6356 cfft_info *cfft;
@@ -377,7 +370,6 @@ typedef struct · 313 unmodified lines
377370
378371 uint8_t downMatrix;
379372 uint8_t first_syn_ele;
380− uint8_t last_syn_ele;
381373 uint8_t has_lfe;
382374 uint8_t fr_channels;
383375 uint8_t fr_ch_ele;
@@ -429,6 +421,7 @@ typedef struct · 45 unmodified lines
429421 /* Program Config Element */
430422 uint8_t pce_set;
431423 program_config pce;
424+ uint8_t element_id[MAX_CHANNELS];
432425 uint8_t channel_element[MAX_CHANNELS];
433426 uint8_t internal_channel[MAX_CHANNELS];
434427
libfaad/syntax.c+116−157
@@ -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.56 2003/09/30 12:43:05 menno Exp $
25+** $Id: syntax.c,v 1.57 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 /*
@@ -260,37 +260,28 @@ uint8_t program_config_element(program_config *pce, bitfile *ld) · 231 unmodified lines
260260 return 0;
261261 }
262262
263−element *decode_sce_lfe(faacDecHandle hDecoder,
264− faacDecFrameInfo *hInfo, bitfile *ld,
265− real_t **spec_coef, uint8_t id_syn_ele)
263+void decode_sce_lfe(faacDecHandle hDecoder,
264+ faacDecFrameInfo *hInfo, bitfile *ld,
265+ uint8_t id_syn_ele)
266266 {
267− element *ele;
268267 uint8_t channels = hDecoder->fr_channels;
268+ uint8_t tag = 0;
269269
270270 if (channels+1 > MAX_CHANNELS)
271271 {
272272 hInfo->error = 12;
273− return NULL;
273+ return;
274274 }
275275 if (hDecoder->fr_ch_ele+1 > MAX_SYNTAX_ELEMENTS)
276276 {
277277 hInfo->error = 13;
278− return NULL;
278+ return;
279279 }
280280
281− spec_coef[channels] = (real_t*)malloc(hDecoder->frameLength*sizeof(real_t));
282−
283− ele = (element*)malloc(sizeof(element));
284− memset(ele, 0, sizeof(element));
285− ele->ele_id = id_syn_ele;
286− ele->channel = channels;
287− ele->paired_channel = -1;
288−
289− hInfo->error = single_lfe_channel_element(hDecoder, ele,
290− ld, spec_coef[channels]);
281+ hInfo->error = single_lfe_channel_element(hDecoder, ld, channels, &tag);
291282
292283 if (hDecoder->pce_set)
293− hDecoder->internal_channel[hDecoder->pce.sce_channel[ele->element_instance_tag]] = channels;
284+ hDecoder->internal_channel[hDecoder->pce.sce_channel[tag]] = channels;
294285 else
295286 hDecoder->internal_channel[channels] = channels;
296287
@@ -298,47 +289,35 @@ element *decode_sce_lfe(faacDecHandle hDecoder, · 1 unmodified line
298289 hDecoder->channel_element[channels] = hDecoder->fr_ch_ele;
299290 else /* LFE */
300291 hDecoder->channel_element[channels] = hDecoder->fr_ch_ele;
292+ hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele;
301293
302294 hDecoder->fr_channels++;
303295 hDecoder->fr_ch_ele++;
304−
305− return ele;
306296 }
307297
308−element *decode_cpe(faacDecHandle hDecoder,
309− faacDecFrameInfo *hInfo, bitfile *ld,
310− real_t **spec_coef, uint8_t id_syn_ele)
298+void decode_cpe(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, bitfile *ld,
299+ uint8_t id_syn_ele)
311300 {
312− element *ele;
313301 uint8_t channels = hDecoder->fr_channels;
302+ uint8_t tag = 0;
314303
315304 if (channels+2 > MAX_CHANNELS)
316305 {
317306 hInfo->error = 12;
318− return NULL;
307+ return;
319308 }
320309 if (hDecoder->fr_ch_ele+1 > MAX_SYNTAX_ELEMENTS)
321310 {
322311 hInfo->error = 13;
323− return NULL;
312+ return;
324313 }
325314
326− spec_coef[channels] = (real_t*)malloc(hDecoder->frameLength*sizeof(real_t));
327− spec_coef[channels+1] = (real_t*)malloc(hDecoder->frameLength*sizeof(real_t));
328−
329− ele = (element*)malloc(sizeof(element));
330− memset(ele, 0, sizeof(element));
331− ele->ele_id = id_syn_ele;
332− ele->channel = channels;
333− ele->paired_channel = channels+1;
334−
335− hInfo->error = channel_pair_element(hDecoder, ele,
336− ld, spec_coef[channels], spec_coef[channels+1]);
315+ hInfo->error = channel_pair_element(hDecoder, ld, channels, &tag);
337316
338317 if (hDecoder->pce_set)
339318 {
340− hDecoder->internal_channel[hDecoder->pce.cpe_channel[ele->element_instance_tag]] = channels;
341− hDecoder->internal_channel[hDecoder->pce.cpe_channel[ele->element_instance_tag]+1] = channels+1;
319+ hDecoder->internal_channel[hDecoder->pce.cpe_channel[tag]] = channels;
320+ hDecoder->internal_channel[hDecoder->pce.cpe_channel[tag]+1] = channels+1;
342321 } else {
343322 hDecoder->internal_channel[channels] = channels;
344323 hDecoder->internal_channel[channels+1] = channels+1;
@@ -346,16 +325,14 @@ element *decode_cpe(faacDecHandle hDecoder, · 1 unmodified line
346325
347326 hDecoder->channel_element[channels] = hDecoder->fr_ch_ele;
348327 hDecoder->channel_element[channels+1] = hDecoder->fr_ch_ele;
328+ hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele;
349329
350330 hDecoder->fr_channels += 2;
351331 hDecoder->fr_ch_ele++;
352−
353− return ele;
354332 }
355333
356−element **raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
357− bitfile *ld, element **elements,
358− real_t **spec_coef, program_config *pce, drc_info *drc)
334+void raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
335+ bitfile *ld, program_config *pce, drc_info *drc)
359336 {
360337 uint8_t id_syn_ele;
361338 uint8_t ch_ele = 0;
@@ -376,38 +353,36 @@ element **raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, · 14 unmodified lines
376353 switch (id_syn_ele) {
377354 case ID_SCE:
378355 if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele;
379− hDecoder->last_syn_ele = id_syn_ele;
380− elements[ch_ele++] = decode_sce_lfe(hDecoder,
381− hInfo, ld, spec_coef, id_syn_ele);
356+ decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele);
357+ ch_ele++;
382358 if (hInfo->error > 0)
383− return elements;
359+ return;
384360 break;
385361 case ID_CPE:
386362 if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele;
387− hDecoder->last_syn_ele = id_syn_ele;
388− elements[ch_ele++] = decode_cpe(hDecoder,
389− hInfo, ld, spec_coef, id_syn_ele);
363+ decode_cpe(hDecoder, hInfo, ld, id_syn_ele);
364+ ch_ele++;
390365 if (hInfo->error > 0)
391− return elements;
366+ return;
392367 break;
393368 case ID_LFE:
394369 hDecoder->has_lfe++;
395− elements[ch_ele++] = decode_sce_lfe(hDecoder,
396− hInfo, ld, spec_coef, id_syn_ele);
370+ decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele);
371+ ch_ele++;
397372 if (hInfo->error > 0)
398− return elements;
373+ return;
399374 break;
400375 case ID_CCE: /* not implemented yet, but skip the bits */
401376 hInfo->error = coupling_channel_element(hDecoder, ld);
402377 if (hInfo->error > 0)
403− return elements;
378+ return;
404379 break;
405380 case ID_DSE:
406381 data_stream_element(hDecoder, ld);
407382 break;
408383 case ID_PCE:
409384 if ((hInfo->error = program_config_element(pce, ld)) > 0)
410− return elements;
385+ return;
411386 hDecoder->pce_set = 1;
412387 break;
413388 case ID_FIL:
@@ -417,7 +392,7 @@ element **raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, · 3 unmodified lines
417392 , (ch_ele-1)
418393 #endif
419394 )) > 0)
420− return elements;
395+ return;
421396 #ifdef SBR_DEC
422397 if (hDecoder->sbr_used[ch_ele-1])
423398 {
@@ -435,74 +410,74 @@ element **raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, · 11 unmodified lines
435410 switch (hDecoder->channelConfiguration)
436411 {
437412 case 1:
438− elements[ch_ele++] = decode_sce_lfe(hDecoder,
439− hInfo, ld, spec_coef, ID_SCE);
413+ decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
414+ ch_ele++;
440415 if (hInfo->error > 0)
441− return elements;
416+ return;
442417 break;
443418 case 2:
444− elements[ch_ele++] = decode_cpe(hDecoder,
445− hInfo, ld, spec_coef, ID_CPE);
419+ decode_cpe(hDecoder, hInfo, ld, ID_CPE);
420+ ch_ele++;
446421 if (hInfo->error > 0)
447− return elements;
422+ return;
448423 break;
449424 case 3:
450− elements[ch_ele++] = decode_sce_lfe(hDecoder,
451− hInfo, ld, spec_coef, ID_SCE);
452− elements[ch_ele++] = decode_cpe(hDecoder,
453− hInfo, ld, spec_coef, ID_CPE);
425+ decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
426+ ch_ele++;
427+ decode_cpe(hDecoder, hInfo, ld, ID_CPE);
428+ ch_ele++;
454429 if (hInfo->error > 0)
455− return elements;
430+ return;
456431 break;
457432 case 4:
458− elements[ch_ele++] = decode_sce_lfe(hDecoder,
459− hInfo, ld, spec_coef, ID_SCE);
460− elements[ch_ele++] = decode_cpe(hDecoder,
461− hInfo, ld, spec_coef, ID_CPE);
462− elements[ch_ele++] = decode_sce_lfe(hDecoder,
463− hInfo, ld, spec_coef, ID_SCE);
433+ decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
434+ ch_ele++;
435+ decode_cpe(hDecoder, hInfo, ld, ID_CPE);
436+ ch_ele++;
437+ decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
438+ ch_ele++;
464439 if (hInfo->error > 0)
465− return elements;
440+ return;
466441 break;
467442 case 5:
468− elements[ch_ele++] = decode_sce_lfe(hDecoder,
469− hInfo, ld, spec_coef, ID_SCE);
470− elements[ch_ele++] = decode_cpe(hDecoder,
471− hInfo, ld, spec_coef, ID_CPE);
472− elements[ch_ele++] = decode_cpe(hDecoder,
473− hInfo, ld, spec_coef, ID_CPE);
443+ decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
444+ ch_ele++;
445+ decode_cpe(hDecoder, hInfo, ld, ID_CPE);
446+ ch_ele++;
447+ decode_cpe(hDecoder, hInfo, ld, ID_CPE);
448+ ch_ele++;
474449 if (hInfo->error > 0)
475− return elements;
450+ return;
476451 break;
477452 case 6:
478− elements[ch_ele++] = decode_sce_lfe(hDecoder,
479− hInfo, ld, spec_coef, ID_SCE);
480− elements[ch_ele++] = decode_cpe(hDecoder,
481− hInfo, ld, spec_coef, ID_CPE);
482− elements[ch_ele++] = decode_cpe(hDecoder,
483− hInfo, ld, spec_coef, ID_CPE);
484− elements[ch_ele++] = decode_sce_lfe(hDecoder,
485− hInfo, ld, spec_coef, ID_LFE);
453+ decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
454+ ch_ele++;
455+ decode_cpe(hDecoder, hInfo, ld, ID_CPE);
456+ ch_ele++;
457+ decode_cpe(hDecoder, hInfo, ld, ID_CPE);
458+ ch_ele++;
459+ decode_sce_lfe(hDecoder, hInfo, ld, ID_LFE);
460+ ch_ele++;
486461 if (hInfo->error > 0)
487− return elements;
462+ return;
488463 break;
489464 case 7:
490− elements[ch_ele++] = decode_sce_lfe(hDecoder,
491− hInfo, ld, spec_coef, ID_SCE);
492− elements[ch_ele++] = decode_cpe(hDecoder,
493− hInfo, ld, spec_coef, ID_CPE);
494− elements[ch_ele++] = decode_cpe(hDecoder,
495− hInfo, ld, spec_coef, ID_CPE);
496− elements[ch_ele++] = decode_cpe(hDecoder,
497− hInfo, ld, spec_coef, ID_CPE);
498− elements[ch_ele++] = decode_sce_lfe(hDecoder,
499− hInfo, ld, spec_coef, ID_LFE);
465+ decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE);
466+ ch_ele++;
467+ decode_cpe(hDecoder, hInfo, ld, ID_CPE);
468+ ch_ele++;
469+ decode_cpe(hDecoder, hInfo, ld, ID_CPE);
470+ ch_ele++;
471+ decode_cpe(hDecoder, hInfo, ld, ID_CPE);
472+ ch_ele++;
473+ decode_sce_lfe(hDecoder, hInfo, ld, ID_LFE);
474+ ch_ele++;
500475 if (hInfo->error > 0)
501− return elements;
476+ return;
502477 break;
503478 default:
504479 hInfo->error = 7;
505− return elements;
480+ return;
506481 }
507482 #if 0
508483 cnt = bits_to_decode() / 8;
@@ -522,30 +497,34 @@ element **raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, · 13 unmodified lines
522497 faad_byte_align(ld);
523498 }
524499
525− return elements;
500+ return;
526501 }
527502
528503 /* Table 4.4.4 and */
529504 /* Table 4.4.9 */
530−static uint8_t single_lfe_channel_element(faacDecHandle hDecoder,
531− element *sce, bitfile *ld,
532− real_t *spec_coef)
505+static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, bitfile *ld,
506+ uint8_t channel, uint8_t *tag)
533507 {
534508 uint8_t retval = 0;
535− ic_stream *ics = &(sce->ics1);
536− int16_t spec_data[1024];
509+ element sce = {0};
510+ ic_stream *ics = &(sce.ics1);
511+ int16_t spec_data[1024] = {0};
537512 #ifdef DRM
538513 uint8_t result;
539514
540515 if (hDecoder->object_type != DRM_ER_LC)
541516 #endif
542− sce->element_instance_tag = (uint8_t)faad_getbits(ld, LEN_TAG
517+ sce.element_instance_tag = (uint8_t)faad_getbits(ld, LEN_TAG
543518 DEBUGVAR(1,38,"single_lfe_channel_element(): element_instance_tag"));
544519
520+ *tag = sce.element_instance_tag;
521+ sce.channel = channel;
522+ sce.paired_channel = -1;
523+
545524 #ifdef DRM
546525 if (hDecoder->object_type == DRM_ER_LC)
547526 {
548− individual_channel_stream(hDecoder, sce, ld, ics, 0, spec_data);
527+ individual_channel_stream(hDecoder, &sce, ld, ics, 0, spec_data);
549528
550529 if (ics->tns_data_present)
551530 tns_data(ics, &(ics->tns), ld);
@@ -571,49 +550,43 @@ static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, · 19 unmodified lines
571550 } else
572551 #endif
573552 {
574− retval = individual_channel_stream(hDecoder, sce, ld, ics, 0, spec_data);
553+ retval = individual_channel_stream(hDecoder, &sce, ld, ics, 0, spec_data);
575554 if (retval > 0)
576555 return retval;
577556 }
578557
579−
580558 /* noiseless coding is done, spectral reconstruction is done now */
581−
582− /* inverse quantization */
583− inverse_quantization(spec_coef, spec_data, hDecoder->frameLength);
584−
585− /* apply scalefactors */
586− apply_scalefactors(hDecoder, ics, spec_coef, hDecoder->frameLength);
587−
588− /* deinterleave short block grouping */
589− if (ics->window_sequence == EIGHT_SHORT_SEQUENCE)
590− quant_to_spec(ics, spec_coef, hDecoder->frameLength);
559+ reconstruct_single_channel(hDecoder, ics, &sce, spec_data);
591560
592561 return 0;
593562 }
594563
595564 /* Table 4.4.5 */
596−static uint8_t channel_pair_element(faacDecHandle hDecoder, element *cpe,
597− bitfile *ld,
598− real_t *spec_coef1, real_t *spec_coef2)
565+static uint8_t channel_pair_element(faacDecHandle hDecoder, bitfile *ld,
566+ uint8_t channels, uint8_t *tag)
599567 {
568+ int16_t spec_data1[1024] = {0};
569+ int16_t spec_data2[1024] = {0};
570+ element cpe = {0};
571+ ic_stream *ics1 = &(cpe.ics1);
572+ ic_stream *ics2 = &(cpe.ics2);
600573 uint8_t result;
601− ic_stream *ics1 = &(cpe->ics1);
602− ic_stream *ics2 = &(cpe->ics2);
603− int16_t spec_data1[1024];
604− int16_t spec_data2[1024];
574+
575+ cpe.channel = channels;
576+ cpe.paired_channel = channels+1;
605577
606578 #ifdef DRM
607579 if (hDecoder->object_type != DRM_ER_LC)
608580 #endif
609− cpe->element_instance_tag = (uint8_t)faad_getbits(ld, LEN_TAG
581+ cpe.element_instance_tag = (uint8_t)faad_getbits(ld, LEN_TAG
610582 DEBUGVAR(1,39,"channel_pair_element(): element_instance_tag"));
583+ *tag = cpe.element_instance_tag;
611584
612− if ((cpe->common_window = faad_get1bit(ld
585+ if ((cpe.common_window = faad_get1bit(ld
613586 DEBUGVAR(1,40,"channel_pair_element(): common_window"))) & 1)
614587 {
615588 /* both channels have common ics information */
616− if ((result = ics_info(hDecoder, ics1, ld, cpe->common_window)) > 0)
589+ if ((result = ics_info(hDecoder, ics1, ld, cpe.common_window)) > 0)
617590 return result;
618591
619592 ics1->ms_mask_present = (uint8_t)faad_getbits(ld, 2
@@ -647,14 +620,14 @@ static uint8_t channel_pair_element(faacDecHandle hDecoder, element *cpe, · 27 unmodified lines
647620 ics1->ms_mask_present = 0;
648621 }
649622
650− if ((result = individual_channel_stream(hDecoder, cpe, ld, ics1,
623+ if ((result = individual_channel_stream(hDecoder, &cpe, ld, ics1,
651624 0, spec_data1)) > 0)
652625 {
653626 return result;
654627 }
655628
656629 #ifdef ERROR_RESILIENCE
657− if (cpe->common_window && (hDecoder->object_type >= ER_OBJECT_START) &&
630+ if (cpe.common_window && (hDecoder->object_type >= ER_OBJECT_START) &&
658631 (ics1->predictor_data_present))
659632 {
660633 if ((ics1->ltp2.data_present = faad_get1bit(ld
@@ -665,7 +638,7 @@ static uint8_t channel_pair_element(faacDecHandle hDecoder, element *cpe, · 4 unmodified lines
665638 }
666639 #endif
667640
668− if ((result = individual_channel_stream(hDecoder, cpe, ld, ics2,
641+ if ((result = individual_channel_stream(hDecoder, &cpe, ld, ics2,
669642 0, spec_data2)) > 0)
670643 {
671644 return result;
@@ -713,20 +686,7 @@ static uint8_t channel_pair_element(faacDecHandle hDecoder, element *cpe, · 41 unmodified lines
713686 #endif
714687
715688 /* noiseless coding is done, spectral reconstruction is done now */
716−
717− /* inverse quantization */
718− inverse_quantization(spec_coef1, spec_data1, hDecoder->frameLength);
719− inverse_quantization(spec_coef2, spec_data2, hDecoder->frameLength);
720−
721− /* apply scalefactors */
722− apply_scalefactors(hDecoder, ics1, spec_coef1, hDecoder->frameLength);
723− apply_scalefactors(hDecoder, ics2, spec_coef2, hDecoder->frameLength);
724−
725− /* deinterleave short block grouping */
726− if (ics1->window_sequence == EIGHT_SHORT_SEQUENCE)
727− quant_to_spec(ics1, spec_coef1, hDecoder->frameLength);
728− if (ics2->window_sequence == EIGHT_SHORT_SEQUENCE)
729− quant_to_spec(ics2, spec_coef2, hDecoder->frameLength);
689+ reconstruct_channel_pair(hDecoder, ics1, ics2, &cpe, spec_data1, spec_data2);
730690
731691 return 0;
732692 }
@@ -873,13 +833,10 @@ static uint8_t coupling_channel_element(faacDecHandle hDecoder, bitfile *ld) · 140 unmodified lines
873833 uint8_t num_gain_element_lists = 0;
874834 uint8_t num_coupled_elements = 0;
875835
876− element el_empty;
877− ic_stream ics_empty;
836+ element el_empty = {0};
837+ ic_stream ics_empty = {0};
878838 int16_t sh_data[1024];
879839
880− memset(&el_empty, 0, sizeof(element));
881− memset(&ics_empty, 0, sizeof(ic_stream));
882−
883840 c = faad_getbits(ld, LEN_TAG
884841 DEBUGVAR(1,900,"coupling_channel_element(): element_instance_tag"));
885842
@@ -1028,6 +985,8 @@ static uint8_t fill_element(faacDecHandle hDecoder, bitfile *ld, drc_info *drc · 142 unmodified lines
1028985 /* read in all the SBR data for processing later on */
1029986 hDecoder->sbr[sbr_ele]->data = (uint8_t*)faad_getbitbuffer(ld, count*8);
1030987 hDecoder->sbr[sbr_ele]->data_size = count;
988+ /* save id of previous element, this sbr object belongs to that element */
989+ hDecoder->sbr[sbr_ele]->id_aac = hDecoder->element_id[sbr_ele];
1031990 } else {
1032991 hDecoder->sbr_used[sbr_ele] = 0;
1033992 #endif
@@ -1602,7 +1561,7 @@ static uint8_t spectral_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld · 568 unmodified lines
16021561 uint16_t nshort = hDecoder->frameLength/8;
16031562
16041563 sp = spectral_data;
1605− memset(sp, 0, hDecoder->frameLength*sizeof(int16_t));
1564+ /*memset(sp, 0, hDecoder->frameLength*sizeof(int16_t));*/
16061565
16071566 for(g = 0; g < ics->num_window_groups; g++)
16081567 {
libfaad/syntax.h+11−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.h,v 1.37 2003/09/24 19:55:34 menno Exp $
25+** $Id: syntax.h,v 1.38 2003/10/09 20:04:25 menno Exp $
2626 **/
2727
2828 #ifndef __SYNTAX_H__
@@ -109,15 +109,19 @@ int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC, · 80 unmodified lines
109109
110110 uint8_t adts_frame(adts_header *adts, bitfile *ld);
111111 void get_adif_header(adif_header *adif, bitfile *ld);
112+void decode_sce_lfe(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, bitfile *ld,
113+ uint8_t id_syn_ele);
114+void decode_cpe(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, bitfile *ld,
115+ uint8_t id_syn_ele);
116+void raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo,
117+ bitfile *ld, program_config *pce, drc_info *drc);
112118
113119
114120 /* static functions */
115−static uint8_t single_lfe_channel_element(faacDecHandle hDecoder,
116− element *sce, bitfile *ld,
117− real_t *spec_coef);
118−static uint8_t channel_pair_element(faacDecHandle hDecoder, element *cpe,
119− bitfile *ld,
120− real_t *spec_coef1, real_t *spec_coef2);
121+static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, bitfile *ld,
122+ uint8_t channel, uint8_t *tag);
123+static uint8_t channel_pair_element(faacDecHandle hDecoder, bitfile *ld,
124+ uint8_t channel, uint8_t *tag);
121125 static uint8_t coupling_channel_element(faacDecHandle hDecoder, bitfile *ld);
122126 static uint16_t data_stream_element(faacDecHandle hDecoder, bitfile *ld);
123127 static uint8_t program_config_element(program_config *pce, bitfile *ld);

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