ref: df15fc14a83c77af73c59839fc79cf3b1364a80a
parent: 76aaa6d04038d6ec0dc48f9c9aa071a4a5574950
author: menno <menno>
date: Wed Sep 10 08:25:54 EDT 2003
DRM patches
--- 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.27 2003/08/07 17:21:21 menno Exp $
+** $Id: faad.h,v 1.28 2003/09/10 12:25:53 menno Exp $
**/
#ifndef __AACDEC_H__
@@ -91,7 +91,14 @@
#define LFE_CHANNEL (9)
#define UNKNOWN_CHANNEL (0)
+/* DRM channel definitions */
+#define DRMCH_MONO 1
+#define DRMCH_STEREO 2
+#define DRMCH_SBR_MONO 3
+#define DRMCH_SBR_LC_STEREO 4
+#define DRMCH_SBR_STEREO 5
+
/* A decode call can eat up to FAAD_MIN_STREAMSIZE bytes per decoded channel,
so at least so much bytes per channel should be available in this stream */
#define FAAD_MIN_STREAMSIZE 768 /* 6144 bits/channel */
@@ -171,6 +178,8 @@
char FAADAPI faacDecInitDRM(faacDecHandle hDecoder, unsigned long samplerate,
unsigned char channels);
+void FAADAPI faacDecPostSeekReset(faacDecHandle hDecoder, long frame);
+
void FAADAPI faacDecClose(faacDecHandle hDecoder);
void* FAADAPI faacDecDecode(faacDecHandle hDecoder,
@@ -181,8 +190,6 @@
char FAADAPI AudioSpecificConfig(unsigned char *pBuffer,
unsigned long buffer_size,
mp4AudioSpecificConfig *mp4ASC);
-
-void FAADAPI faacDecPostSeekReset(faacDecHandle hDecoder, unsigned long frame);
#ifdef _WIN32
#pragma pack(pop)
--- 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.64 2003/09/09 18:09:51 menno Exp $
+** $Id: decoder.c,v 1.65 2003/09/10 12:25:54 menno Exp $
**/
#include "common.h"
@@ -698,6 +698,12 @@
uint8_t channels = 0, ch_ele = 0;
uint8_t output_channels = 0;
bitfile *ld = (bitfile*)malloc(sizeof(bitfile));
+ uint32_t bitsconsumed;
+#ifdef DRM
+ uint8_t *revbuffer;
+ uint8_t *prevbufstart;
+ uint8_t *pbufend;
+#endif
/* local copy of globals */
uint8_t sf_index, object_type, channelConfiguration, outputFormat;
@@ -820,7 +826,8 @@
/* no more bit reading after this */
- hInfo->bytesconsumed = bit2byte(faad_get_processed_bits(ld));
+ bitsconsumed = faad_get_processed_bits(ld);
+ hInfo->bytesconsumed = bit2byte(bitsconsumed);
if (ld->error)
{
hInfo->error = 14;
@@ -829,6 +836,37 @@
faad_endbits(ld);
if (ld) free(ld);
ld = NULL;
+
+#ifdef DRM
+#ifdef SBR_DEC
+ if ((hDecoder->sbr_present_flag == 1) && (hDecoder->object_type == DRM_ER_LC))
+ {
+ hDecoder->sbr_used[0] = 1;
+
+ if (!hDecoder->sbr[0])
+ hDecoder->sbr[0] = sbrDecodeInit(hDecoder->frameLength, 1);
+
+ /* Reverse bit reading of SBR data in DRM audio frame */
+ revbuffer = (uint8_t*)malloc(buffer_size*sizeof(uint8_t));
+ prevbufstart = revbuffer;
+ pbufend = &buffer[buffer_size - 1];
+ for (i = 0; i < buffer_size; i++)
+ *prevbufstart++ = tabFlipbits[*pbufend--];
+
+ /* Set SBR data */
+ hDecoder->sbr[0]->data = revbuffer;
+ /* consider 8 bits from AAC-CRC */
+ hDecoder->sbr[0]->data_size_bits = buffer_size*8 - bitsconsumed - 8;
+ hDecoder->sbr[0]->data_size =
+ bit2byte(hDecoder->sbr[0]->data_size_bits + 8);
+
+ hDecoder->sbr[0]->lcstereo_flag = hDecoder->lcstereo_flag;
+
+ hDecoder->sbr[0]->sample_rate = set_sample_rate(hDecoder->sf_index);
+ hDecoder->sbr[0]->sample_rate *= 2;
+ }
+#endif
+#endif
if (!hDecoder->adts_header_present && !hDecoder->adif_header_present)
{
--- 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.8 2003/09/09 18:37:32 menno Exp $
+** $Id: sbr_dec.c,v 1.9 2003/09/10 12:25:54 menno Exp $
**/
@@ -201,6 +201,10 @@
{
/* don't process just upsample */
dont_process = 1;
+
+ /* Re-activate reset for next frame */
+ if (ret && sbr->Reset)
+ sbr->bs_start_freq_prev = -1;
}
if (just_seeked)
--- 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.9 2003/09/09 18:37:32 menno Exp $
+** $Id: sbr_syntax.c,v 1.10 2003/09/10 12:25:54 menno Exp $
**/
#include "common.h"
@@ -181,7 +181,8 @@
return result;
}
- sbr_data(ld, sbr, id_aac);
+ if ((result = sbr_data(ld, sbr, id_aac)) > 0)
+ return result;
/* no error */
return 0;
--- 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.11 2003/09/09 18:09:52 menno Exp $
+** $Id: structs.h,v 1.12 2003/09/10 12:25:54 menno Exp $
**/
#ifndef __STRUCTS_H__
@@ -387,6 +387,9 @@
uint8_t sbr_used[32];
sbr_info *sbr[32];
+#ifdef DRM
+ int8_t lcstereo_flag;
+#endif
#endif
#ifdef SSR_DEC
--- 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.52 2003/09/09 18:09:52 menno Exp $
+** $Id: syntax.c,v 1.53 2003/09/10 12:25:54 menno Exp $
**/
/*
@@ -521,7 +521,12 @@
#endif
/* new in corrigendum 14496-3:2002 */
- faad_byte_align(ld);
+#ifdef DRM
+ if (hDecoder->object_type != DRM_ER_LC)
+#endif
+ {
+ faad_byte_align(ld);
+ }
return elements;
}