ref: 95b26ea83a1a4e62640bc3f13b47d35ea9baa6bd
parent: 9b53c17284995a80830741f4d0e89b935957f46c
author: menno <menno>
date: Thu May 30 13:55:08 EDT 2002
More ER stuff Still not working at all, but it is compilable now
--- a/frontend/main.c
+++ b/frontend/main.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: main.c,v 1.14 2002/02/25 19:58:32 menno Exp $
+** $Id: main.c,v 1.15 2002/05/30 17:55:08 menno Exp $
**/
#ifdef _WIN32
@@ -307,7 +307,8 @@
if (buff)
{
- rc = AudioSpecificConfig(buff, &dummy32, &dummy8, &dummy8, &dummy8);
+ rc = AudioSpecificConfig(buff, &dummy32, &dummy8, &dummy8, &dummy8,
+ &dummy8, &dummy8, &dummy8);
free(buff);
if (rc < 0)
--- a/include/faad.h
+++ b/include/faad.h
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: faad.h,v 1.5 2002/02/25 19:58:33 menno Exp $
+** $Id: faad.h,v 1.6 2002/05/30 17:55:08 menno Exp $
**/
#ifndef __AACDEC_H__
@@ -99,10 +99,13 @@
unsigned char *buffer);
char FAADAPI AudioSpecificConfig(unsigned char *pBuffer,
- unsigned long *samplerate,
- unsigned char *channels,
- unsigned char *sf_index,
- unsigned char *object_type);
+ unsigned long *samplerate,
+ unsigned char *channels,
+ unsigned char *sf_index,
+ unsigned char *object_type,
+ unsigned char *aacSectionDataResilienceFlag,
+ unsigned char *aacScalefactorDataResilienceFlag,
+ unsigned char *aacSpectralDataResilienceFlag);
#ifdef _WIN32
#pragma pack(pop)
--- a/libfaad/common.h
+++ b/libfaad/common.h
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: common.h,v 1.11 2002/05/24 17:26:11 menno Exp $
+** $Id: common.h,v 1.12 2002/05/30 17:55:08 menno Exp $
**/
#ifndef __COMMON_H__
@@ -73,6 +73,7 @@
#endif
//#define SBR
+//#define ERROR_RESILIENCE
/* END COMPILE TIME DEFINITIONS */
--- a/libfaad/decoder.c
+++ b/libfaad/decoder.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: decoder.c,v 1.13 2002/03/16 19:18:11 menno Exp $
+** $Id: decoder.c,v 1.14 2002/05/30 17:55:08 menno Exp $
**/
#include <stdlib.h>
@@ -62,6 +62,9 @@
hDecoder->config.defSampleRate = 44100; /* Default: 44.1kHz */
hDecoder->adts_header_present = 0;
hDecoder->adif_header_present = 0;
+ hDecoder->aacSectionDataResilienceFlag = 0;
+ hDecoder->aacScalefactorDataResilienceFlag = 0;
+ hDecoder->aacSpectralDataResilienceFlag = 0;
hDecoder->frame = 0;
hDecoder->sample_buffer = NULL;
@@ -234,7 +237,10 @@
}
rc = AudioSpecificConfig(pBuffer, samplerate, channels,
- &hDecoder->sf_index, &hDecoder->object_type);
+ &hDecoder->sf_index, &hDecoder->object_type,
+ &hDecoder->aacSectionDataResilienceFlag,
+ &hDecoder->aacScalefactorDataResilienceFlag,
+ &hDecoder->aacSpectralDataResilienceFlag);
#ifdef LD_DEC
if (hDecoder->object_type != LD)
#endif
@@ -271,6 +277,7 @@
if (hDecoder) free(hDecoder);
}
+#ifdef ERROR_RESILIENCE
#define decode_sce_lfe() \
spec_data[channels] = (int16_t*)malloc(frame_len*sizeof(int16_t)); \
spec_coef[channels] = (real_t*)malloc(frame_len*sizeof(real_t)); \
@@ -281,6 +288,28 @@
syntax_elements[ch_ele]->channel = channels; \
\
if ((hInfo->error = single_lfe_channel_element(syntax_elements[ch_ele], \
+ ld, spec_data[channels], sf_index, object_type, \
+ aacSectionDataResilienceFlag, aacScalefactorDataResilienceFlag, \
+ aacSpectralDataResilienceFlag)) > 0) \
+ { \
+ /* to make sure everything gets deallocated */ \
+ channels++; ch_ele++; \
+ goto error; \
+ } \
+ \
+ channels++; \
+ ch_ele++;
+#else
+#define decode_sce_lfe() \
+ spec_data[channels] = (int16_t*)malloc(frame_len*sizeof(int16_t)); \
+ spec_coef[channels] = (real_t*)malloc(frame_len*sizeof(real_t)); \
+ \
+ syntax_elements[ch_ele] = (element*)malloc(sizeof(element)); \
+ memset(syntax_elements[ch_ele], 0, sizeof(element)); \
+ syntax_elements[ch_ele]->ele_id = id_syn_ele; \
+ syntax_elements[ch_ele]->channel = channels; \
+ \
+ if ((hInfo->error = single_lfe_channel_element(syntax_elements[ch_ele], \
ld, spec_data[channels], sf_index, object_type)) > 0) \
{ \
/* to make sure everything gets deallocated */ \
@@ -290,7 +319,9 @@
\
channels++; \
ch_ele++;
+#endif
+#ifdef ERROR_RESILIENCE
#define decode_cpe() \
spec_data[channels] = (int16_t*)malloc(frame_len*sizeof(int16_t)); \
spec_data[channels+1] = (int16_t*)malloc(frame_len*sizeof(int16_t)); \
@@ -305,6 +336,32 @@
\
if ((hInfo->error = channel_pair_element(syntax_elements[ch_ele], \
ld, spec_data[channels], spec_data[channels+1], \
+ sf_index, object_type, \
+ aacSectionDataResilienceFlag, aacScalefactorDataResilienceFlag, \
+ aacSpectralDataResilienceFlag)) > 0) \
+ { \
+ /* to make sure everything gets deallocated */ \
+ channels+=2; ch_ele++; \
+ goto error; \
+ } \
+ \
+ channels += 2; \
+ ch_ele++;
+#else
+#define decode_cpe() \
+ spec_data[channels] = (int16_t*)malloc(frame_len*sizeof(int16_t)); \
+ spec_data[channels+1] = (int16_t*)malloc(frame_len*sizeof(int16_t)); \
+ spec_coef[channels] = (real_t*)malloc(frame_len*sizeof(real_t)); \
+ spec_coef[channels+1] = (real_t*)malloc(frame_len*sizeof(real_t)); \
+ \
+ syntax_elements[ch_ele] = (element*)malloc(sizeof(element)); \
+ memset(syntax_elements[ch_ele], 0, sizeof(element)); \
+ syntax_elements[ch_ele]->ele_id = id_syn_ele; \
+ syntax_elements[ch_ele]->channel = channels; \
+ syntax_elements[ch_ele]->paired_channel = channels+1; \
+ \
+ if ((hInfo->error = channel_pair_element(syntax_elements[ch_ele], \
+ ld, spec_data[channels], spec_data[channels+1], \
sf_index, object_type)) > 0) \
{ \
/* to make sure everything gets deallocated */ \
@@ -314,6 +371,7 @@
\
channels += 2; \
ch_ele++;
+#endif
void* FAADAPI faacDecDecode(faacDecHandle hDecoder,
faacDecFrameInfo *hInfo,
@@ -349,6 +407,11 @@
uint8_t outputFormat = hDecoder->config.outputFormat;
#ifdef LTP_DEC
uint16_t *ltp_lag = hDecoder->ltp_lag;
+#endif
+#ifdef ERROR_RESILIENCE
+ uint8_t aacSectionDataResilienceFlag = hDecoder->aacSectionDataResilienceFlag;
+ uint8_t aacScalefactorDataResilienceFlag = hDecoder->aacScalefactorDataResilienceFlag;
+ uint8_t aacSpectralDataResilienceFlag = hDecoder->aacSpectralDataResilienceFlag;
#endif
program_config pce;
--- a/libfaad/decoder.h
+++ b/libfaad/decoder.h
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: decoder.h,v 1.5 2002/03/16 13:38:37 menno Exp $
+** $Id: decoder.h,v 1.6 2002/05/30 17:55:08 menno Exp $
**/
#ifndef __DECODER_H__
@@ -71,6 +71,9 @@
uint8_t sf_index;
uint8_t object_type;
uint8_t channelConfiguration;
+ uint8_t aacSectionDataResilienceFlag;
+ uint8_t aacScalefactorDataResilienceFlag;
+ uint8_t aacSpectralDataResilienceFlag;
uint32_t frame;
--- a/libfaad/mp4.c
+++ b/libfaad/mp4.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: mp4.c,v 1.5 2002/04/07 21:26:04 menno Exp $
+** $Id: mp4.c,v 1.6 2002/05/30 17:55:08 menno Exp $
**/
#include "common.h"
@@ -80,7 +80,10 @@
uint32_t *samplerate,
uint8_t *channels,
uint8_t *sf_index,
- uint8_t *object_type)
+ uint8_t *object_type,
+ uint8_t *aacSectionDataResilienceFlag,
+ uint8_t *aacScalefactorDataResilienceFlag,
+ uint8_t *aacSpectralDataResilienceFlag)
{
bitfile ld;
uint8_t ObjectTypeIndex, SamplingFrequencyIndex, ChannelsConfiguration;
@@ -125,10 +128,16 @@
ObjectTypeIndex == 3 || ObjectTypeIndex == 4 ||
ObjectTypeIndex == 6 || ObjectTypeIndex == 7)
{
- return GASpecificConfig(&ld, channels, ObjectTypeIndex);
+ return GASpecificConfig(&ld, channels, ObjectTypeIndex,
+ aacSectionDataResilienceFlag,
+ aacScalefactorDataResilienceFlag,
+ aacSpectralDataResilienceFlag);
#ifdef LD_DEC
} else if (ObjectTypeIndex == 23) { /* ER AAC LD */
- uint8_t result = GASpecificConfig(&ld, channels, ObjectTypeIndex);
+ uint8_t result = GASpecificConfig(&ld, channels, ObjectTypeIndex,
+ aacSectionDataResilienceFlag,
+ aacScalefactorDataResilienceFlag,
+ aacSpectralDataResilienceFlag);
uint8_t ep_config = (uint8_t)faad_getbits(&ld, 2
DEBUGVAR(1,143,"parse_audio_decoder_specific_info(): epConfig"));
if (ep_config != 0)
--- a/libfaad/mp4.h
+++ b/libfaad/mp4.h
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: mp4.h,v 1.3 2002/02/25 19:58:33 menno Exp $
+** $Id: mp4.h,v 1.4 2002/05/30 17:55:08 menno Exp $
**/
#ifndef __MP4_H__
@@ -32,7 +32,10 @@
uint32_t *samplerate,
uint8_t *channels,
uint8_t *sf_index,
- uint8_t *object_type);
+ uint8_t *object_type,
+ uint8_t *aacSectionDataResilienceFlag,
+ uint8_t *aacScalefactorDataResilienceFlag,
+ uint8_t *aacSpectralDataResilienceFlag);
#ifdef __cplusplus
}
--- a/libfaad/syntax.c
+++ b/libfaad/syntax.c
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: syntax.c,v 1.12 2002/04/20 14:45:13 menno Exp $
+** $Id: syntax.c,v 1.13 2002/05/30 17:55:08 menno Exp $
**/
/*
@@ -44,7 +44,10 @@
/* Table 4.4.1 */
uint8_t GASpecificConfig(bitfile *ld, uint8_t *channelConfiguration,
- uint8_t object_type)
+ uint8_t object_type,
+ uint8_t *aacSectionDataResilienceFlag,
+ uint8_t *aacScalefactorDataResilienceFlag,
+ uint8_t *aacSpectralDataResilienceFlag)
{
uint8_t frameLengthFlag, dependsOnCoreCoder, extensionFlag;
uint16_t coreCoderDelay;
@@ -77,19 +80,12 @@
/* Error resilience not supported yet */
if (object_type == 23)
{
- uint8_t tmp;
- tmp = faad_get1bit(ld
+ *aacSectionDataResilienceFlag = faad_get1bit(ld
DEBUGVAR(1,144,"GASpecificConfig(): aacSectionDataResilienceFlag"));
- if (tmp)
- return -6;
- tmp = faad_get1bit(ld
+ *aacScalefactorDataResilienceFlag = faad_get1bit(ld
DEBUGVAR(1,145,"GASpecificConfig(): aacScalefactorDataResilienceFlag"));
- if (tmp)
- return -6;
- tmp = faad_get1bit(ld
+ *aacSpectralDataResilienceFlag = faad_get1bit(ld
DEBUGVAR(1,146,"GASpecificConfig(): aacSpectralDataResilienceFlag"));
- if (tmp)
- return -6;
/* 1 bit: extensionFlag3 */
}
@@ -236,7 +232,13 @@
/* Table 4.4.4 and */
/* Table 4.4.9 */
uint8_t single_lfe_channel_element(element *sce, bitfile *ld, int16_t *spec_data,
- uint8_t sf_index, uint8_t object_type)
+ uint8_t sf_index, uint8_t object_type
+#ifdef ERROR_RESILIENCE
+ ,uint8_t aacSectionDataResilienceFlag,
+ uint8_t aacScalefactorDataResilienceFlag,
+ uint8_t aacSpectralDataResilienceFlag
+#endif
+ )
{
ic_stream *ics = &(sce->ics1);
@@ -244,12 +246,24 @@
DEBUGVAR(1,38,"single_lfe_channel_element(): element_instance_tag"));
return individual_channel_stream(sce, ld, ics, 0, spec_data, sf_index,
- object_type);
+ object_type
+#ifdef ERROR_RESILIENCE
+ ,aacSectionDataResilienceFlag,
+ aacScalefactorDataResilienceFlag,
+ aacSpectralDataResilienceFlag
+#endif
+ );
}
/* Table 4.4.5 */
uint8_t channel_pair_element(element *cpe, bitfile *ld, int16_t *spec_data1,
- int16_t *spec_data2, uint8_t sf_index, uint8_t object_type)
+ int16_t *spec_data2, uint8_t sf_index, uint8_t object_type
+#ifdef ERROR_RESILIENCE
+ ,uint8_t aacSectionDataResilienceFlag,
+ uint8_t aacScalefactorDataResilienceFlag,
+ uint8_t aacSpectralDataResilienceFlag
+#endif
+ )
{
uint8_t result;
ic_stream *ics1 = &(cpe->ics1);
@@ -287,10 +301,22 @@
}
if ((result = individual_channel_stream(cpe, ld, ics1, 0, spec_data1,
- sf_index, object_type)) > 0)
+ sf_index, object_type
+#ifdef ERROR_RESILIENCE
+ ,aacSectionDataResilienceFlag,
+ aacScalefactorDataResilienceFlag,
+ aacSpectralDataResilienceFlag
+#endif
+ )) > 0)
return result;
if ((result = individual_channel_stream(cpe, ld, ics2, 0, spec_data2,
- sf_index, object_type)) > 0)
+ sf_index, object_type
+#ifdef ERROR_RESILIENCE
+ ,aacSectionDataResilienceFlag,
+ aacScalefactorDataResilienceFlag,
+ aacSpectralDataResilienceFlag
+#endif
+ )) > 0)
return result;
return 0;
@@ -478,7 +504,9 @@
int16_t *spec_data, uint8_t sf_index,
uint8_t object_type
#ifdef ERROR_RESILIENCE
- ,uint8_t aacSpectralDataResilienceFlag
+ ,uint8_t aacSectionDataResilienceFlag,
+ uint8_t aacScalefactorDataResilienceFlag,
+ uint8_t aacSpectralDataResilienceFlag
#endif
)
{
@@ -498,8 +526,16 @@
object_type)) > 0)
return result;
}
- section_data(ics, ld);
- if ((result = scale_factor_data(ics, ld)) > 0)
+ section_data(ics, ld
+#ifdef ERROR_RESILIENCE
+ ,aacSectionDataResilienceFlag
+#endif
+ );
+ if ((result = scale_factor_data(ics, ld
+#ifdef ERROR_RESILIENCE
+ ,aacScalefactorDataResilienceFlag
+#endif
+ )) > 0)
return result;
if (!scal_flag)
@@ -545,9 +581,11 @@
ics->length_of_longest_codeword = (uint8_t)faad_getbits(ld, 6
DEBUGVAR(1,148,"individual_channel_stream(): length_of_longest_codeword"));
+#if 0
/* error resilient spectral data decoding */
if ((result = reordered_spectral_data()) > 0)
return result;
+#endif
}
#endif
@@ -718,6 +756,7 @@
return decode_scale_factors(ics, ld);
#ifdef ERROR_RESILIENCE
} else {
+#if 0
uint32_t bits_used, length_of_rvlc_sf;
uint8_t bits = 11;
@@ -791,6 +830,7 @@
{
dpcm_noise_last_position; 9 uimsbf
}
+#endif
}
#endif
}
--- a/libfaad/syntax.h
+++ b/libfaad/syntax.h
@@ -16,7 +16,7 @@
** along with this program; if not, write to the Free Software
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
-** $Id: syntax.h,v 1.7 2002/04/20 14:45:13 menno Exp $
+** $Id: syntax.h,v 1.8 2002/05/30 17:55:08 menno Exp $
**/
#ifndef __SYNTAX_H__
@@ -242,6 +242,12 @@
pred_info pred;
ltp_info ltp;
ltp_info ltp2;
+
+#ifdef ERROR_RESILIENCE
+ /* ER data */
+ uint16_t length_of_reordered_spectral_data;
+ uint8_t length_of_longest_codeword;
+#endif
} ic_stream; /* individual channel stream */
typedef struct
@@ -260,7 +266,10 @@
uint8_t GASpecificConfig(bitfile *ld, uint8_t *channelConfiguration,
- uint8_t object_type);
+ uint8_t object_type,
+ uint8_t *aacSectionDataResilienceFlag,
+ uint8_t *aacScalefactorDataResilienceFlag,
+ uint8_t *aacSpectralDataResilienceFlag);
uint8_t raw_data_block(bitfile *ld, int16_t ***spec_data, real_t ***spec_coef,
element ***syntax_elements,
uint8_t *channels, uint8_t *ele, uint8_t *ch_ele,
@@ -267,9 +276,21 @@
uint16_t frame_len, uint8_t sf_index, uint8_t object_type,
drc_info *drc);
uint8_t single_lfe_channel_element(element *sce, bitfile *ld, int16_t *spec_data,
- uint8_t sf_index, uint8_t object_type);
+ uint8_t sf_index, uint8_t object_type
+#ifdef ERROR_RESILIENCE
+ ,uint8_t aacSectionDataResilienceFlag,
+ uint8_t aacScalefactorDataResilienceFlag,
+ uint8_t aacSpectralDataResilienceFlag
+#endif
+ );
uint8_t channel_pair_element(element *cpe, bitfile *ld, int16_t *spec_data1,
- int16_t *spec_data2, uint8_t sf_index, uint8_t object_type);
+ int16_t *spec_data2, uint8_t sf_index, uint8_t object_type
+#ifdef ERROR_RESILIENCE
+ ,uint8_t aacSectionDataResilienceFlag,
+ uint8_t aacScalefactorDataResilienceFlag,
+ uint8_t aacSpectralDataResilienceFlag
+#endif
+ );
uint16_t data_stream_element(bitfile *ld);
uint8_t program_config_element(program_config *pce, bitfile *ld);
uint8_t fill_element(bitfile *ld, drc_info *drc
@@ -285,11 +306,25 @@
static uint8_t individual_channel_stream(element *ele, bitfile *ld,
ic_stream *ics, uint8_t scal_flag,
int16_t *spec_data, uint8_t sf_index,
- uint8_t object_type);
+ uint8_t object_type
+#ifdef ERROR_RESILIENCE
+ ,uint8_t aacSectionDataResilienceFlag,
+ uint8_t aacScalefactorDataResilienceFlag,
+ uint8_t aacSpectralDataResilienceFlag
+#endif
+ );
static uint8_t ics_info(ic_stream *ics, bitfile *ld,
uint8_t common_window, uint8_t fs_index, uint8_t object_type);
-static void section_data(ic_stream *ics, bitfile *ld);
-static uint8_t scale_factor_data(ic_stream *ics, bitfile *ld);
+static void section_data(ic_stream *ics, bitfile *ld
+#ifdef ERROR_RESILIENCE
+ ,uint8_t aacSectionDataResilienceFlag
+#endif
+ );
+static uint8_t scale_factor_data(ic_stream *ics, bitfile *ld
+#ifdef ERROR_RESILIENCE
+ ,uint8_t aacScalefactorDataResilienceFlag
+#endif
+ );
static uint8_t spectral_data(ic_stream *ics, bitfile *ld, int16_t *spectral_data,
uint16_t frame_len);
static uint16_t extension_payload(bitfile *ld, drc_info *drc, uint16_t count);