ref: 493e73cf0b0c76ce1d7d2cbe8a5fc6d7357765f6
parent: 0800217ce58d978ce9bb762179ee02477cba8e89
author: menno <menno>
date: Tue Mar 2 14:37:27 EST 2004
Bugfixes
--- a/include/faad.h
+++ b/include/faad.h
@@ -22,7 +22,7 @@
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
-** $Id: faad.h,v 1.41 2004/02/26 09:32:50 menno Exp $
+** $Id: faad.h,v 1.42 2004/03/02 19:37:26 menno Exp $
**/
#ifndef __AACDEC_H__
@@ -98,8 +98,8 @@
#define DRMCH_MONO 1
#define DRMCH_STEREO 2
#define DRMCH_SBR_MONO 3
-#define DRMCH_SBR_LC_STEREO 4
-#define DRMCH_SBR_STEREO 5
+#define DRMCH_SBR_STEREO 4
+#define DRMCH_SBR_PS_STEREO 5
/* A decode call can eat up to FAAD_MIN_STREAMSIZE bytes per decoded channel,
--- a/libfaad/decoder.c
+++ b/libfaad/decoder.c
@@ -22,7 +22,7 @@
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
-** $Id: decoder.c,v 1.95 2004/02/26 09:29:26 menno Exp $
+** $Id: decoder.c,v 1.96 2004/03/02 19:37:26 menno Exp $
**/
#include "common.h"
@@ -396,11 +396,6 @@
hDecoder->channelConfiguration = 1;
#ifdef SBR_DEC
- if (channels == DRMCH_SBR_LC_STEREO)
- hDecoder->lcstereo_flag = 1;
- else
- hDecoder->lcstereo_flag = 0;
-
if ((channels == DRMCH_MONO) || (channels == DRMCH_STEREO))
hDecoder->sbr_present_flag = 0;
else
--- a/libfaad/sbr_dec.c
+++ b/libfaad/sbr_dec.c
@@ -22,7 +22,7 @@
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
-** $Id: sbr_dec.c,v 1.27 2004/02/26 09:29:28 menno Exp $
+** $Id: sbr_dec.c,v 1.30 2004/03/10 19:45:41 menno Exp $
**/
@@ -45,7 +45,7 @@
static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch);
sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac,
- uint32_t sample_rate
+ uint32_t sample_rate, uint8_t downSampledSBR
#ifdef DRM
, uint8_t IsDRM
#endif
@@ -71,6 +71,7 @@
sbr->prevEnvIsShort[0] = -1;
sbr->prevEnvIsShort[1] = -1;
sbr->header_count = 0;
+ sbr->Reset = 1;
#ifdef DRM
sbr->Is_DRM_SBR = IsDRM;
@@ -91,6 +92,44 @@
sbr->numTimeSlots = NO_TIME_SLOTS;
}
+ if (id_aac == ID_CPE)
+ {
+ /* stereo */
+ uint8_t j;
+ sbr->qmfa[0] = qmfa_init(32);
+ sbr->qmfa[1] = qmfa_init(32);
+ sbr->qmfs[0] = qmfs_init((downSampledSBR)?32:64);
+ sbr->qmfs[1] = qmfs_init((downSampledSBR)?32:64);
+
+ for (j = 0; j < 5; j++)
+ {
+ sbr->G_temp_prev[0][j] = faad_malloc(64*sizeof(real_t));
+ sbr->G_temp_prev[1][j] = faad_malloc(64*sizeof(real_t));
+ sbr->Q_temp_prev[0][j] = faad_malloc(64*sizeof(real_t));
+ sbr->Q_temp_prev[1][j] = faad_malloc(64*sizeof(real_t));
+ }
+
+ memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
+ memset(sbr->Xsbr[1], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
+ memset(sbr->Xcodec[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*32 * sizeof(qmf_t));
+ memset(sbr->Xcodec[1], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*32 * sizeof(qmf_t));
+ } else {
+ /* mono */
+ uint8_t j;
+ sbr->qmfa[0] = qmfa_init(32);
+ sbr->qmfs[0] = qmfs_init((downSampledSBR)?32:64);
+ sbr->qmfs[1] = NULL;
+
+ for (j = 0; j < 5; j++)
+ {
+ sbr->G_temp_prev[0][j] = faad_malloc(64*sizeof(real_t));
+ sbr->Q_temp_prev[0][j] = faad_malloc(64*sizeof(real_t));
+ }
+
+ memset(sbr->Xsbr[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
+ memset(sbr->Xcodec[0], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*32 * sizeof(qmf_t));
+ }
+
return sbr;
}
@@ -164,22 +203,6 @@
ALIGN real_t deg[64];
#endif
- if (sbr->frame == 0)
- {
- uint8_t j;
- sbr->qmfa[ch] = qmfa_init(32);
- sbr->qmfs[ch] = qmfs_init((downSampledSBR)?32:64);
-
- for (j = 0; j < 5; j++)
- {
- sbr->G_temp_prev[ch][j] = faad_malloc(64*sizeof(real_t));
- sbr->Q_temp_prev[ch][j] = faad_malloc(64*sizeof(real_t));
- }
-
- memset(sbr->Xsbr[ch], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t));
- memset(sbr->Xcodec[ch], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*32 * sizeof(qmf_t));
- }
-
/* subband analysis */
if (dont_process)
sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xcodec[ch], sbr->tHFGen, 32);
@@ -412,8 +435,8 @@
uint8_t l, k;
uint8_t dont_process = 0;
uint8_t ret = 0;
- ALIGN qmf_t X_left[38][64];
- ALIGN qmf_t X_right[38][64];
+ ALIGN qmf_t X_left[38][64] = {{0}};
+ ALIGN qmf_t X_right[38][64] = {{0}}; /* must set this to 0 */
if (sbr == NULL)
return 20;
@@ -439,9 +462,9 @@
sbr->just_seeked = 0;
}
- if (sbr->frame == 0)
+ if (sbr->qmfs[1] == NULL)
{
- sbr->qmfs[1] = qmfs_init(64);
+ sbr->qmfs[1] = qmfs_init((downSampledSBR)?32:64);
}
sbr_process_channel(sbr, left_channel, X_left, 0, dont_process, downSampledSBR);
@@ -460,7 +483,7 @@
#ifdef DRM
if (sbr->Is_DRM_SBR)
{
- drm_ps_decode(sbr->drm_ps, X_left, X_right);
+ drm_ps_decode(sbr->drm_ps, sbr->sample_rate, X_left, X_right);
} else {
#endif
#ifdef PS_DEC
--- a/libfaad/sbr_dec.h
+++ b/libfaad/sbr_dec.h
@@ -22,7 +22,7 @@
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
-** $Id: sbr_dec.h,v 1.24 2004/02/26 09:29:28 menno Exp $
+** $Id: sbr_dec.h,v 1.25 2004/03/02 19:37:26 menno Exp $
**/
#ifndef __SBR_DEC_H__
@@ -157,7 +157,6 @@
qmf_t Xcodec[2][MAX_NTSRHFG][32];
#ifdef DRM
- int8_t lcstereo_flag;
uint8_t bs_dataextra;
uint8_t Is_DRM_SBR;
#ifdef DRM_PS
@@ -217,7 +216,7 @@
} sbr_info;
sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac,
- uint32_t sample_rate
+ uint32_t sample_rate, uint8_t downSampledSBR
#ifdef DRM
, uint8_t IsDRM
#endif
--- a/libfaad/sbr_qmf.c
+++ b/libfaad/sbr_qmf.c
@@ -22,7 +22,7 @@
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
-** $Id: sbr_qmf.c,v 1.20 2004/02/26 09:29:28 menno Exp $
+** $Id: sbr_qmf.c,v 1.22 2004/03/10 19:45:42 menno Exp $
**/
#include "common.h"
@@ -252,7 +252,7 @@
/* even n samples */
DCT2_16_unscaled(x, x);
- /* uneven n samples */
+ /* odd n samples */
DCT4_16(y, y);
for (n = 8; n < 24; n++)
@@ -337,7 +337,7 @@
/* even n samples */
DCT2_32_unscaled(x, x);
- /* uneven n samples */
+ /* odd n samples */
DCT4_32(y, y);
for (n = 16; n < 48; n++)
@@ -389,7 +389,9 @@
real_t *output)
{
ALIGN real_t x1[32], x2[32];
+#ifndef FIXED_POINT
real_t scale = 1.f/64.f;
+#endif
int16_t n, k, out = 0;
uint8_t l;
@@ -414,8 +416,13 @@
x1[k] = QMF_RE(X[l][k]) * RE(qmfs->pre_twiddle[k]) - QMF_IM(X[l][k]) * IM(qmfs->pre_twiddle[k]);
x2[k] = QMF_IM(X[l][k]) * RE(qmfs->pre_twiddle[k]) + QMF_RE(X[l][k]) * IM(qmfs->pre_twiddle[k]);
+#ifndef FIXED_POINT
x1[k] *= scale;
x2[k] *= scale;
+#else
+ x1[k] >>= 1;
+ x2[k] >>= 1;
+#endif
}
/* transform */
@@ -449,7 +456,9 @@
real_t *output)
{
ALIGN real_t x1[64], x2[64];
+#ifndef FIXED_POINT
real_t scale = 1.f/64.f;
+#endif
int16_t n, k, out = 0;
uint8_t l;
@@ -468,6 +477,7 @@
qmfs->v_index = (qmfs->v_index + 1) & 0x1;
/* calculate 128 samples */
+#ifndef FIXED_POINT
x1[0] = scale*QMF_RE(X[l][0]);
x2[63] = scale*QMF_IM(X[l][0]);
for (k = 0; k < 31; k++)
@@ -480,6 +490,20 @@
}
x1[63] = scale*QMF_RE(X[l][63]);
x2[0] = scale*QMF_IM(X[l][63]);
+#else
+ x1[0] = QMF_RE(X[l][0])>>1;
+ x2[63] = QMF_IM(X[l][0])>>1;
+ for (k = 0; k < 31; k++)
+ {
+ x1[2*k+1] = (QMF_RE(X[l][2*k+1]) - QMF_RE(X[l][2*k+2]))>>1;
+ x1[2*k+2] = (QMF_RE(X[l][2*k+1]) + QMF_RE(X[l][2*k+2]))>>1;
+
+ x2[61 - 2*k] = (QMF_IM(X[l][2*k+2]) - QMF_IM(X[l][2*k+1]))>>1;
+ x2[62 - 2*k] = (QMF_IM(X[l][2*k+2]) + QMF_IM(X[l][2*k+1]))>>1;
+ }
+ x1[63] = QMF_RE(X[l][63])>>1;
+ x2[0] = QMF_IM(X[l][63])>>1;
+#endif
DCT4_64_kernel(x1, x1);
DCT4_64_kernel(x2, x2);
--- a/libfaad/sbr_syntax.c
+++ b/libfaad/sbr_syntax.c
@@ -22,7 +22,7 @@
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
-** $Id: sbr_syntax.c,v 1.26 2004/02/26 09:29:28 menno Exp $
+** $Id: sbr_syntax.c,v 1.28 2004/03/10 19:45:42 menno Exp $
**/
#include "common.h"
@@ -98,11 +98,6 @@
sbr->bs_alter_scale_prev = sbr->bs_alter_scale;
sbr->bs_xover_band_prev = sbr->bs_xover_band;
sbr->bs_noise_bands_prev = sbr->bs_noise_bands;
-
- if (sbr->frame == 0)
- {
- sbr->Reset = 1;
- }
}
/* table 2 */
@@ -703,7 +698,7 @@
sbr->ps_used = 1;
if (!sbr->ps)
{
- sbr->ps = ps_init();
+ sbr->ps = ps_init(get_sr_index(sbr->sample_rate));
}
return ps_data(sbr->ps, ld);
#endif
--- a/libfaad/specrec.c
+++ b/libfaad/specrec.c
@@ -22,7 +22,7 @@
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
-** $Id: specrec.c,v 1.44 2004/02/26 09:29:28 menno Exp $
+** $Id: specrec.c,v 1.45 2004/03/02 19:37:26 menno Exp $
**/
/*
@@ -900,7 +900,6 @@
return 21;
}
-
if (hDecoder->element_alloced[hDecoder->fr_ch_ele] == 0)
{
retval = allocate_single_channel(hDecoder, sce->channel, output_channels);
@@ -1032,7 +1031,8 @@
if (hDecoder->sbr[ele] == NULL)
{
hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength,
- sce->ele_id, 2*get_sample_rate(hDecoder->sf_index)
+ sce->ele_id, 2*get_sample_rate(hDecoder->sf_index),
+ hDecoder->downSampledSBR
#ifdef DRM
, 0
#endif
@@ -1257,7 +1257,8 @@
if (hDecoder->sbr[ele] == NULL)
{
hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength,
- cpe->ele_id, 2*get_sample_rate(hDecoder->sf_index)
+ cpe->ele_id, 2*get_sample_rate(hDecoder->sf_index),
+ hDecoder->downSampledSBR
#ifdef DRM
, 0
#endif
--- a/libfaad/structs.h
+++ b/libfaad/structs.h
@@ -22,7 +22,7 @@
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
-** $Id: structs.h,v 1.32 2004/02/26 09:29:28 menno Exp $
+** $Id: structs.h,v 1.33 2004/03/02 19:37:26 menno Exp $
**/
#ifndef __STRUCTS_H__
@@ -421,9 +421,6 @@
uint8_t sbr_alloced[MAX_SYNTAX_ELEMENTS];
sbr_info *sbr[MAX_SYNTAX_ELEMENTS];
-#ifdef DRM
- int8_t lcstereo_flag;
-#endif
#endif
#if (defined(PS_DEC) || defined(DRM_PS))
uint8_t ps_used[MAX_SYNTAX_ELEMENTS];
--- a/libfaad/syntax.c
+++ b/libfaad/syntax.c
@@ -22,7 +22,7 @@
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
-** $Id: syntax.c,v 1.72 2004/02/26 09:29:28 menno Exp $
+** $Id: syntax.c,v 1.73 2004/03/02 19:37:26 menno Exp $
**/
/*
@@ -986,7 +986,8 @@
if (!hDecoder->sbr[sbr_ele])
{
hDecoder->sbr[sbr_ele] = sbrDecodeInit(hDecoder->frameLength,
- hDecoder->element_id[sbr_ele], 2*get_sample_rate(hDecoder->sf_index)
+ hDecoder->element_id[sbr_ele], 2*get_sample_rate(hDecoder->sf_index),
+ hDecoder->downSampledSBR
#ifdef DRM
, 0
#endif
@@ -1145,12 +1146,14 @@
cpe.common_window = 1;
if (this_layer_stereo)
+ {
cpe.ele_id = ID_CPE;
- else
+ if (hDecoder->element_output_channels[hDecoder->fr_ch_ele] == 0)
+ hDecoder->element_output_channels[hDecoder->fr_ch_ele] = 2;
+ } else {
cpe.ele_id = ID_SCE;
+ }
- hDecoder->element_output_channels[hDecoder->fr_ch_ele] = (this_layer_stereo ? 2 : 0);
-
for (ch = 0; ch < (this_layer_stereo ? 2 : 1); ch++)
{
ic_stream *ics;
@@ -1194,7 +1197,7 @@
if (!hDecoder->sbr[0])
{
hDecoder->sbr[0] = sbrDecodeInit(hDecoder->frameLength, cpe.ele_id,
- 2*get_sample_rate(hDecoder->sf_index), 1);
+ 2*get_sample_rate(hDecoder->sf_index), 0 /* ds SBR */, 1);
}
/* Reverse bit reading of SBR data in DRM audio frame */
@@ -1208,8 +1211,6 @@
/* consider 8 bits from AAC-CRC */
count = (uint16_t)bit2byte(buffer_size*8 - bitsconsumed);
faad_initbits(&ld_sbr, revbuffer, count);
-
- hDecoder->sbr[0]->lcstereo_flag = hDecoder->lcstereo_flag;
hDecoder->sbr[0]->sample_rate = get_sample_rate(hDecoder->sf_index);
hDecoder->sbr[0]->sample_rate *= 2;
--- a/libfaad/syntax.h
+++ b/libfaad/syntax.h
@@ -22,7 +22,7 @@
** Commercial non-GPL licensing of this software is possible.
** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
**
-** $Id: syntax.h,v 1.49 2004/02/26 09:29:28 menno Exp $
+** $Id: syntax.h,v 1.50 2004/03/02 19:37:27 menno Exp $
**/
#ifndef __SYNTAX_H__
@@ -60,8 +60,8 @@
#define DRMCH_MONO 1
#define DRMCH_STEREO 2
#define DRMCH_SBR_MONO 3
-#define DRMCH_SBR_LC_STEREO 4
-#define DRMCH_SBR_STEREO 5
+#define DRMCH_SBR_STEREO 4
+#define DRMCH_SBR_PS_STEREO 5
/* First object type that has ER */