From 925b8c0c8c8d5641ec7865d102fc4a813a0940c4 Mon Sep 17 00:00:00 2001 From: James Stembridge Date: Mon, 26 Jan 2004 22:34:10 +0000 Subject: Sync with libfaad CVS CVS patchset: 6071 CVS date: 2004/01/26 22:34:10 --- src/libfaad/analysis.h | 2 +- src/libfaad/bits.c | 33 ++++- src/libfaad/bits.h | 26 +++- src/libfaad/cfft.c | 2 +- src/libfaad/cfft.h | 2 +- src/libfaad/cfft_tab.h | 2 +- src/libfaad/codebook/hcb.h | 2 +- src/libfaad/codebook/hcb_1.h | 2 +- src/libfaad/codebook/hcb_10.h | 2 +- src/libfaad/codebook/hcb_11.h | 2 +- src/libfaad/codebook/hcb_2.h | 2 +- src/libfaad/codebook/hcb_3.h | 2 +- src/libfaad/codebook/hcb_4.h | 2 +- src/libfaad/codebook/hcb_5.h | 2 +- src/libfaad/codebook/hcb_6.h | 2 +- src/libfaad/codebook/hcb_7.h | 2 +- src/libfaad/codebook/hcb_8.h | 2 +- src/libfaad/codebook/hcb_9.h | 2 +- src/libfaad/codebook/hcb_sf.h | 269 ++++------------------------------- src/libfaad/common.c | 2 +- src/libfaad/common.h | 4 +- src/libfaad/decoder.c | 228 +++++++++--------------------- src/libfaad/decoder.h | 2 +- src/libfaad/drc.c | 2 +- src/libfaad/drc.h | 2 +- src/libfaad/error.c | 13 +- src/libfaad/error.h | 4 +- src/libfaad/faad.h | 9 +- src/libfaad/filtbank.c | 73 +++++----- src/libfaad/filtbank.h | 15 +- src/libfaad/fixed.h | 2 +- src/libfaad/hcr.c | 2 +- src/libfaad/huffman.c | 45 ++---- src/libfaad/huffman.h | 2 +- src/libfaad/ic_predict.c | 2 +- src/libfaad/ic_predict.h | 2 +- src/libfaad/iq_table.h | 2 +- src/libfaad/is.c | 2 +- src/libfaad/is.h | 2 +- src/libfaad/kbd_win.h | 2 +- src/libfaad/lt_predict.c | 2 +- src/libfaad/lt_predict.h | 2 +- src/libfaad/mdct.c | 2 +- src/libfaad/mdct.h | 2 +- src/libfaad/mp4.c | 2 +- src/libfaad/mp4.h | 2 +- src/libfaad/ms.c | 2 +- src/libfaad/ms.h | 2 +- src/libfaad/output.c | 2 +- src/libfaad/output.h | 2 +- src/libfaad/pns.c | 2 +- src/libfaad/pns.h | 2 +- src/libfaad/pulse.c | 2 +- src/libfaad/pulse.h | 2 +- src/libfaad/rvlc.c | 2 +- src/libfaad/rvlc.h | 2 +- src/libfaad/sbr_dct.c | 2 +- src/libfaad/sbr_dct.h | 2 +- src/libfaad/sbr_dec.c | 320 +++++++++++++++++++++++------------------- src/libfaad/sbr_dec.h | 28 ++-- src/libfaad/sbr_e_nf.c | 2 +- src/libfaad/sbr_e_nf.h | 2 +- src/libfaad/sbr_fbt.c | 129 +++++++++++++++-- src/libfaad/sbr_fbt.h | 10 +- src/libfaad/sbr_hfadj.c | 2 +- src/libfaad/sbr_hfadj.h | 2 +- src/libfaad/sbr_hfgen.c | 2 +- src/libfaad/sbr_hfgen.h | 2 +- src/libfaad/sbr_huff.c | 2 +- src/libfaad/sbr_huff.h | 2 +- src/libfaad/sbr_noise.h | 2 +- src/libfaad/sbr_qmf.c | 2 +- src/libfaad/sbr_qmf.h | 2 +- src/libfaad/sbr_qmf_c.h | 2 +- src/libfaad/sbr_syntax.c | 158 +++++++++++++-------- src/libfaad/sbr_syntax.h | 4 +- src/libfaad/sbr_tf_grid.c | 2 +- src/libfaad/sbr_tf_grid.h | 2 +- src/libfaad/sine_win.h | 2 +- src/libfaad/specrec.c | 148 ++++++++++++++++--- src/libfaad/specrec.h | 2 +- src/libfaad/ssr.c | 2 +- src/libfaad/ssr.h | 2 +- src/libfaad/ssr_fb.c | 2 +- src/libfaad/ssr_fb.h | 2 +- src/libfaad/ssr_ipqf.c | 2 +- src/libfaad/ssr_ipqf.h | 2 +- src/libfaad/ssr_win.h | 2 +- src/libfaad/structs.h | 11 +- src/libfaad/syntax.c | 154 ++++++++++++++++---- src/libfaad/syntax.h | 5 +- src/libfaad/tns.c | 2 +- src/libfaad/tns.h | 2 +- 93 files changed, 971 insertions(+), 859 deletions(-) diff --git a/src/libfaad/analysis.h b/src/libfaad/analysis.h index 5afbce414..7130699cf 100644 --- a/src/libfaad/analysis.h +++ b/src/libfaad/analysis.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: analysis.h,v 1.4 2004/01/11 15:44:04 mroi Exp $ +** $Id: analysis.h,v 1.5 2004/01/26 22:34:10 jstembridge Exp $ **/ #ifndef __ANALYSIS_H__ diff --git a/src/libfaad/bits.c b/src/libfaad/bits.c index 2ec31a930..15c91da4d 100644 --- a/src/libfaad/bits.c +++ b/src/libfaad/bits.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: bits.c,v 1.6 2004/01/11 15:44:04 mroi Exp $ +** $Id: bits.c,v 1.7 2004/01/26 22:34:10 jstembridge Exp $ **/ #include "common.h" @@ -74,7 +74,13 @@ void faad_initbits(bitfile *ld, const void *_buffer, const uint32_t buffer_size) void faad_endbits(bitfile *ld) { if (ld) - if (ld->buffer) faad_free(ld->buffer); + { + if (ld->buffer) + { + faad_free(ld->buffer); + ld->buffer = NULL; + } + } } uint32_t faad_get_processed_bits(bitfile *ld) @@ -99,8 +105,13 @@ void faad_flushbits_ex(bitfile *ld, uint32_t bits) uint32_t tmp; ld->bufa = ld->bufb; - tmp = getdword(ld->tail); - ld->tail++; + if (ld->no_more_reading == 0) + { + tmp = getdword(ld->tail); + ld->tail++; + } else { + tmp = 0; + } ld->bufb = tmp; ld->bits_left += (32 - bits); ld->bytes_used += 4; @@ -157,6 +168,20 @@ uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits return buffer; } +#ifdef DRM +/* return the original data buffer */ +void *faad_origbitbuffer(bitfile *ld) +{ + return (void*)ld->start; +} + +/* return the original data buffer size */ +uint32_t faad_origbitbuffer_size(bitfile *ld) +{ + return ld->buffer_size; +} +#endif + /* reversed bit reading routines, used for RVLC and HCR */ void faad_initbits_rev(bitfile *ld, void *buffer, uint32_t bits_in_buffer) diff --git a/src/libfaad/bits.h b/src/libfaad/bits.h index 18f1c2a3f..7c1080967 100644 --- a/src/libfaad/bits.h +++ b/src/libfaad/bits.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: bits.h,v 1.6 2004/01/11 15:44:04 mroi Exp $ +** $Id: bits.h,v 1.7 2004/01/26 22:34:10 jstembridge Exp $ **/ #ifndef __BITS_H__ @@ -71,6 +71,8 @@ static uint32_t bitmask[] = { 0x1FFFF, 0x3FFFF, 0x7FFFF, 0xFFFFF, 0x1FFFFF, 0x3FFFFF, 0x7FFFFF, 0xFFFFFF, 0x1FFFFFF, 0x3FFFFFF, 0x7FFFFFF, 0xFFFFFFF, 0x1FFFFFFF, 0x3FFFFFFF, 0x7FFFFFFF + /* added bitmask 32, correct?!?!?! */ + , 0xFFFFFFFF }; void faad_initbits(bitfile *ld, const void *buffer, const uint32_t buffer_size); @@ -83,6 +85,10 @@ void faad_flushbits_ex(bitfile *ld, uint32_t bits); void faad_rewindbits(bitfile *ld); uint8_t *faad_getbitbuffer(bitfile *ld, uint32_t bits DEBUGDEC); +#ifdef DRM +void *faad_origbitbuffer(bitfile *ld); +uint32_t faad_origbitbuffer_size(bitfile *ld); +#endif /* circumvent memory alignment errors on ARM */ static INLINE uint32_t getdword(void *mem) @@ -160,12 +166,20 @@ static INLINE uint8_t faad_get1bit(bitfile *ld DEBUGDEC) { uint8_t r; - if (ld->bits_left == 0) - return (uint8_t)faad_getbits(ld, 1 DEBUGVAR(print,var,dbg)); - - ld->bits_left--; - r = (uint8_t)((ld->bufa >> ld->bits_left) & 1); + if (ld->bits_left > 0) + { + ld->bits_left--; + r = (uint8_t)((ld->bufa >> ld->bits_left) & 1); + return r; + } + /* bits_left == 0 */ +#if 0 + r = (uint8_t)(ld->bufb >> 31); + faad_flushbits_ex(ld, 1); +#else + r = (uint8_t)faad_getbits(ld, 1); +#endif return r; } diff --git a/src/libfaad/cfft.c b/src/libfaad/cfft.c index fa858303c..e8aff8ea3 100644 --- a/src/libfaad/cfft.c +++ b/src/libfaad/cfft.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: cfft.c,v 1.8 2004/01/11 15:44:04 mroi Exp $ +** $Id: cfft.c,v 1.9 2004/01/26 22:34:10 jstembridge Exp $ **/ /* diff --git a/src/libfaad/cfft.h b/src/libfaad/cfft.h index 7c5b0fb8e..199cdf4d2 100644 --- a/src/libfaad/cfft.h +++ b/src/libfaad/cfft.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: cfft.h,v 1.6 2004/01/11 15:44:04 mroi Exp $ +** $Id: cfft.h,v 1.7 2004/01/26 22:34:10 jstembridge Exp $ **/ #ifndef __CFFT_H__ diff --git a/src/libfaad/cfft_tab.h b/src/libfaad/cfft_tab.h index 5492040e1..ae3c2df68 100644 --- a/src/libfaad/cfft_tab.h +++ b/src/libfaad/cfft_tab.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: cfft_tab.h,v 1.3 2004/01/11 15:44:04 mroi Exp $ +** $Id: cfft_tab.h,v 1.4 2004/01/26 22:34:10 jstembridge Exp $ **/ #ifndef __CFFT_TAB_H__ diff --git a/src/libfaad/codebook/hcb.h b/src/libfaad/codebook/hcb.h index 66d937076..e1df4f398 100644 --- a/src/libfaad/codebook/hcb.h +++ b/src/libfaad/codebook/hcb.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: hcb.h,v 1.3 2003/12/30 02:00:12 miguelfreitas Exp $ +** $Id: hcb.h,v 1.4 2004/01/26 22:34:12 jstembridge Exp $ **/ #ifndef __HCB_H__ diff --git a/src/libfaad/codebook/hcb_1.h b/src/libfaad/codebook/hcb_1.h index 1c838558c..eeae02e79 100644 --- a/src/libfaad/codebook/hcb_1.h +++ b/src/libfaad/codebook/hcb_1.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: hcb_1.h,v 1.1 2003/12/30 02:00:12 miguelfreitas Exp $ +** $Id: hcb_1.h,v 1.2 2004/01/26 22:34:12 jstembridge Exp $ **/ /* 2-step huffman table HCB_1 */ diff --git a/src/libfaad/codebook/hcb_10.h b/src/libfaad/codebook/hcb_10.h index 1875fc090..8ce4ae2ac 100644 --- a/src/libfaad/codebook/hcb_10.h +++ b/src/libfaad/codebook/hcb_10.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: hcb_10.h,v 1.1 2003/12/30 02:00:12 miguelfreitas Exp $ +** $Id: hcb_10.h,v 1.2 2004/01/26 22:34:12 jstembridge Exp $ **/ /* 2-step huffman table HCB_10 */ diff --git a/src/libfaad/codebook/hcb_11.h b/src/libfaad/codebook/hcb_11.h index 352151cc2..b1eb534b7 100644 --- a/src/libfaad/codebook/hcb_11.h +++ b/src/libfaad/codebook/hcb_11.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: hcb_11.h,v 1.1 2003/12/30 02:00:12 miguelfreitas Exp $ +** $Id: hcb_11.h,v 1.2 2004/01/26 22:34:12 jstembridge Exp $ **/ /* 2-step huffman table HCB_11 */ diff --git a/src/libfaad/codebook/hcb_2.h b/src/libfaad/codebook/hcb_2.h index 16aa4308d..80f2c5883 100644 --- a/src/libfaad/codebook/hcb_2.h +++ b/src/libfaad/codebook/hcb_2.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: hcb_2.h,v 1.1 2003/12/30 02:00:12 miguelfreitas Exp $ +** $Id: hcb_2.h,v 1.2 2004/01/26 22:34:12 jstembridge Exp $ **/ /* 2-step huffman table HCB_2 */ diff --git a/src/libfaad/codebook/hcb_3.h b/src/libfaad/codebook/hcb_3.h index 6b370f4ba..5efc8f626 100644 --- a/src/libfaad/codebook/hcb_3.h +++ b/src/libfaad/codebook/hcb_3.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: hcb_3.h,v 1.1 2003/12/30 02:00:12 miguelfreitas Exp $ +** $Id: hcb_3.h,v 1.2 2004/01/26 22:34:12 jstembridge Exp $ **/ /* Binary search huffman table HCB_3 */ diff --git a/src/libfaad/codebook/hcb_4.h b/src/libfaad/codebook/hcb_4.h index 46f373bd7..68bd8df5d 100644 --- a/src/libfaad/codebook/hcb_4.h +++ b/src/libfaad/codebook/hcb_4.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: hcb_4.h,v 1.1 2003/12/30 02:00:12 miguelfreitas Exp $ +** $Id: hcb_4.h,v 1.2 2004/01/26 22:34:12 jstembridge Exp $ **/ /* 2-step huffman table HCB_4 */ diff --git a/src/libfaad/codebook/hcb_5.h b/src/libfaad/codebook/hcb_5.h index db309a4b6..ac615c77a 100644 --- a/src/libfaad/codebook/hcb_5.h +++ b/src/libfaad/codebook/hcb_5.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: hcb_5.h,v 1.1 2003/12/30 02:00:12 miguelfreitas Exp $ +** $Id: hcb_5.h,v 1.2 2004/01/26 22:34:12 jstembridge Exp $ **/ /* Binary search huffman table HCB_5 */ diff --git a/src/libfaad/codebook/hcb_6.h b/src/libfaad/codebook/hcb_6.h index 503d76ba9..4f6bcaba6 100644 --- a/src/libfaad/codebook/hcb_6.h +++ b/src/libfaad/codebook/hcb_6.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: hcb_6.h,v 1.1 2003/12/30 02:00:12 miguelfreitas Exp $ +** $Id: hcb_6.h,v 1.2 2004/01/26 22:34:12 jstembridge Exp $ **/ /* 2-step huffman table HCB_6 */ diff --git a/src/libfaad/codebook/hcb_7.h b/src/libfaad/codebook/hcb_7.h index ea881776b..54bdb8b2a 100644 --- a/src/libfaad/codebook/hcb_7.h +++ b/src/libfaad/codebook/hcb_7.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: hcb_7.h,v 1.1 2003/12/30 02:00:12 miguelfreitas Exp $ +** $Id: hcb_7.h,v 1.2 2004/01/26 22:34:12 jstembridge Exp $ **/ /* Binary search huffman table HCB_7 */ diff --git a/src/libfaad/codebook/hcb_8.h b/src/libfaad/codebook/hcb_8.h index fc4c398b9..2770882b9 100644 --- a/src/libfaad/codebook/hcb_8.h +++ b/src/libfaad/codebook/hcb_8.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: hcb_8.h,v 1.1 2003/12/30 02:00:12 miguelfreitas Exp $ +** $Id: hcb_8.h,v 1.2 2004/01/26 22:34:12 jstembridge Exp $ **/ /* 2-step huffman table HCB_8 */ diff --git a/src/libfaad/codebook/hcb_9.h b/src/libfaad/codebook/hcb_9.h index 3121bcb53..9497d3701 100644 --- a/src/libfaad/codebook/hcb_9.h +++ b/src/libfaad/codebook/hcb_9.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: hcb_9.h,v 1.1 2003/12/30 02:00:12 miguelfreitas Exp $ +** $Id: hcb_9.h,v 1.2 2004/01/26 22:34:12 jstembridge Exp $ **/ /* Binary search huffman table HCB_9 */ diff --git a/src/libfaad/codebook/hcb_sf.h b/src/libfaad/codebook/hcb_sf.h index f7be8fd8e..257fd9d35 100644 --- a/src/libfaad/codebook/hcb_sf.h +++ b/src/libfaad/codebook/hcb_sf.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -22,252 +22,31 @@ ** Commercial non-GPL licensing of this software is possible. ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. ** -** $Id: hcb_sf.h,v 1.1 2003/12/30 02:00:12 miguelfreitas Exp $ +** $Id: hcb_sf.h,v 1.2 2004/01/26 22:34:12 jstembridge Exp $ **/ /* Binary search huffman table HCB_SF */ - -static uint8_t hcb_sf[][2] = { - { /* 0 */ 1, 2 }, - { /* 1 */ 60, 0 }, - { /* 2 */ 1, 2 }, - { /* 3 */ 2, 3 }, - { /* 4 */ 3, 4 }, - { /* 5 */ 59, 0 }, - { /* 6 */ 3, 4 }, - { /* 7 */ 4, 5 }, - { /* 8 */ 5, 6 }, - { /* 9 */ 61, 0 }, - { /* 10 */ 58, 0 }, - { /* 11 */ 62, 0 }, - { /* 12 */ 3, 4 }, - { /* 13 */ 4, 5 }, - { /* 14 */ 5, 6 }, - { /* 15 */ 57, 0 }, - { /* 16 */ 63, 0 }, - { /* 17 */ 4, 5 }, - { /* 18 */ 5, 6 }, - { /* 19 */ 6, 7 }, - { /* 20 */ 7, 8 }, - { /* 21 */ 56, 0 }, - { /* 22 */ 64, 0 }, - { /* 23 */ 55, 0 }, - { /* 24 */ 65, 0 }, - { /* 25 */ 4, 5 }, - { /* 26 */ 5, 6 }, - { /* 27 */ 6, 7 }, - { /* 28 */ 7, 8 }, - { /* 29 */ 66, 0 }, - { /* 30 */ 54, 0 }, - { /* 31 */ 67, 0 }, - { /* 32 */ 5, 6 }, - { /* 33 */ 6, 7 }, - { /* 34 */ 7, 8 }, - { /* 35 */ 8, 9 }, - { /* 36 */ 9, 10 }, - { /* 37 */ 53, 0 }, - { /* 38 */ 68, 0 }, - { /* 39 */ 52, 0 }, - { /* 40 */ 69, 0 }, - { /* 41 */ 51, 0 }, - { /* 42 */ 5, 6 }, - { /* 43 */ 6, 7 }, - { /* 44 */ 7, 8 }, - { /* 45 */ 8, 9 }, - { /* 46 */ 9, 10 }, - { /* 47 */ 70, 0 }, - { /* 48 */ 50, 0 }, - { /* 49 */ 49, 0 }, - { /* 50 */ 71, 0 }, - { /* 51 */ 6, 7 }, - { /* 52 */ 7, 8 }, - { /* 53 */ 8, 9 }, - { /* 54 */ 9, 10 }, - { /* 55 */ 10, 11 }, - { /* 56 */ 11, 12 }, - { /* 57 */ 72, 0 }, - { /* 58 */ 48, 0 }, - { /* 59 */ 73, 0 }, - { /* 60 */ 47, 0 }, - { /* 61 */ 74, 0 }, - { /* 62 */ 46, 0 }, - { /* 63 */ 6, 7 }, - { /* 64 */ 7, 8 }, - { /* 65 */ 8, 9 }, - { /* 66 */ 9, 10 }, - { /* 67 */ 10, 11 }, - { /* 68 */ 11, 12 }, - { /* 69 */ 76, 0 }, - { /* 70 */ 75, 0 }, - { /* 71 */ 77, 0 }, - { /* 72 */ 78, 0 }, - { /* 73 */ 45, 0 }, - { /* 74 */ 43, 0 }, - { /* 75 */ 6, 7 }, - { /* 76 */ 7, 8 }, - { /* 77 */ 8, 9 }, - { /* 78 */ 9, 10 }, - { /* 79 */ 10, 11 }, - { /* 80 */ 11, 12 }, - { /* 81 */ 44, 0 }, - { /* 82 */ 79, 0 }, - { /* 83 */ 42, 0 }, - { /* 84 */ 41, 0 }, - { /* 85 */ 80, 0 }, - { /* 86 */ 40, 0 }, - { /* 87 */ 6, 7 }, - { /* 88 */ 7, 8 }, - { /* 89 */ 8, 9 }, - { /* 90 */ 9, 10 }, - { /* 91 */ 10, 11 }, - { /* 92 */ 11, 12 }, - { /* 93 */ 81, 0 }, - { /* 94 */ 39, 0 }, - { /* 95 */ 82, 0 }, - { /* 96 */ 38, 0 }, - { /* 97 */ 83, 0 }, - { /* 98 */ 7, 8 }, - { /* 99 */ 8, 9 }, - { /* 00 */ 9, 10 }, - { /* 01 */ 10, 11 }, - { /* 02 */ 11, 12 }, - { /* 03 */ 12, 13 }, - { /* 04 */ 13, 14 }, - { /* 05 */ 37, 0 }, - { /* 06 */ 35, 0 }, - { /* 07 */ 85, 0 }, - { /* 08 */ 33, 0 }, - { /* 09 */ 36, 0 }, - { /* 10 */ 34, 0 }, - { /* 11 */ 84, 0 }, - { /* 12 */ 32, 0 }, - { /* 13 */ 6, 7 }, - { /* 14 */ 7, 8 }, - { /* 15 */ 8, 9 }, - { /* 16 */ 9, 10 }, - { /* 17 */ 10, 11 }, - { /* 18 */ 11, 12 }, - { /* 19 */ 87, 0 }, - { /* 20 */ 89, 0 }, - { /* 21 */ 30, 0 }, - { /* 22 */ 31, 0 }, - { /* 23 */ 8, 9 }, - { /* 24 */ 9, 10 }, - { /* 25 */ 10, 11 }, - { /* 26 */ 11, 12 }, - { /* 27 */ 12, 13 }, - { /* 28 */ 13, 14 }, - { /* 29 */ 14, 15 }, - { /* 30 */ 15, 16 }, - { /* 31 */ 86, 0 }, - { /* 32 */ 29, 0 }, - { /* 33 */ 26, 0 }, - { /* 34 */ 27, 0 }, - { /* 35 */ 28, 0 }, - { /* 36 */ 24, 0 }, - { /* 37 */ 88, 0 }, - { /* 38 */ 9, 10 }, - { /* 39 */ 10, 11 }, - { /* 40 */ 11, 12 }, - { /* 41 */ 12, 13 }, - { /* 42 */ 13, 14 }, - { /* 43 */ 14, 15 }, - { /* 44 */ 15, 16 }, - { /* 45 */ 16, 17 }, - { /* 46 */ 17, 18 }, - { /* 47 */ 25, 0 }, - { /* 48 */ 22, 0 }, - { /* 49 */ 23, 0 }, - { /* 50 */ 15, 16 }, - { /* 51 */ 16, 17 }, - { /* 52 */ 17, 18 }, - { /* 53 */ 18, 19 }, - { /* 54 */ 19, 20 }, - { /* 55 */ 20, 21 }, - { /* 56 */ 21, 22 }, - { /* 57 */ 22, 23 }, - { /* 58 */ 23, 24 }, - { /* 59 */ 24, 25 }, - { /* 60 */ 25, 26 }, - { /* 61 */ 26, 27 }, - { /* 62 */ 27, 28 }, - { /* 63 */ 28, 29 }, - { /* 64 */ 29, 30 }, - { /* 65 */ 90, 0 }, - { /* 66 */ 21, 0 }, - { /* 67 */ 19, 0 }, - { /* 68 */ 3, 0 }, - { /* 69 */ 1, 0 }, - { /* 70 */ 2, 0 }, - { /* 71 */ 0, 0 }, - { /* 72 */ 23, 24 }, - { /* 73 */ 24, 25 }, - { /* 74 */ 25, 26 }, - { /* 75 */ 26, 27 }, - { /* 76 */ 27, 28 }, - { /* 77 */ 28, 29 }, - { /* 78 */ 29, 30 }, - { /* 79 */ 30, 31 }, - { /* 80 */ 31, 32 }, - { /* 81 */ 32, 33 }, - { /* 82 */ 33, 34 }, - { /* 83 */ 34, 35 }, - { /* 84 */ 35, 36 }, - { /* 85 */ 36, 37 }, - { /* 86 */ 37, 38 }, - { /* 87 */ 38, 39 }, - { /* 88 */ 39, 40 }, - { /* 89 */ 40, 41 }, - { /* 90 */ 41, 42 }, - { /* 91 */ 42, 43 }, - { /* 92 */ 43, 44 }, - { /* 93 */ 44, 45 }, - { /* 94 */ 45, 46 }, - { /* 95 */ 98, 0 }, - { /* 96 */ 99, 0 }, - { /* 97 */ 100, 0 }, - { /* 98 */ 101, 0 }, - { /* 99 */ 102, 0 }, - { /* 00 */ 117, 0 }, - { /* 01 */ 97, 0 }, - { /* 02 */ 91, 0 }, - { /* 03 */ 92, 0 }, - { /* 04 */ 93, 0 }, - { /* 05 */ 94, 0 }, - { /* 06 */ 95, 0 }, - { /* 07 */ 96, 0 }, - { /* 08 */ 104, 0 }, - { /* 09 */ 111, 0 }, - { /* 10 */ 112, 0 }, - { /* 11 */ 113, 0 }, - { /* 12 */ 114, 0 }, - { /* 13 */ 115, 0 }, - { /* 14 */ 116, 0 }, - { /* 15 */ 110, 0 }, - { /* 16 */ 105, 0 }, - { /* 17 */ 106, 0 }, - { /* 18 */ 107, 0 }, - { /* 19 */ 108, 0 }, - { /* 20 */ 109, 0 }, - { /* 21 */ 118, 0 }, - { /* 22 */ 6, 0 }, - { /* 23 */ 8, 0 }, - { /* 24 */ 9, 0 }, - { /* 25 */ 10, 0 }, - { /* 26 */ 5, 0 }, - { /* 27 */ 103, 0 }, - { /* 28 */ 120, 0 }, - { /* 29 */ 119, 0 }, - { /* 30 */ 4, 0 }, - { /* 31 */ 7, 0 }, - { /* 32 */ 15, 0 }, - { /* 33 */ 16, 0 }, - { /* 34 */ 18, 0 }, - { /* 35 */ 20, 0 }, - { /* 36 */ 17, 0 }, - { /* 37 */ 11, 0 }, - { /* 38 */ 12, 0 }, - { /* 39 */ 14, 0 }, - { /* 40 */ 13, 0 } +ALIGN static const int8_t hcb_sf[][2] = { + { -61, 1 }, { 2, 3 }, { -62, 4 }, { 5, 6 }, { -60, -63 }, { -59, 7 }, + { 8, 9 }, { -64, -58 }, { 10, 11 }, { 12, 13 }, { -65, -57 }, { -66, -56 }, + { 14, 15 }, { 16, 17 }, { -55, -67 }, { -54, 18 }, { 19, 20 }, { 21, 22 }, + { -68, -53 }, { -69, -52 }, { -70, 23 }, { 24, 25 }, { 26, 27 }, { -51, -71 }, + { -72, -50 }, { 28, 29 }, { 30, 31 }, { 32, 33 }, { -49, -73 }, { -48, -74 }, + { -47, -75 }, { 34, 35 }, { 36, 37 }, { 38, 39 }, { -45, -46 }, { -44, -43 }, + { -76, -78 }, { 40, 41 }, { 42, 43 }, { 44, 45 }, { -77, -42 }, { -79, -80 }, + { -41, -81 }, { 46, 47 }, { 48, 49 }, { 50, 51 }, { -40, -82 }, { -39, -83 }, + { -38, 52 }, { 53, 54 }, { 55, 56 }, { 57, 58 }, { -84, -86 }, { -36, -88 }, + { -85, -87 }, { -37, -89 }, { 59, 60 }, { 61, 62 }, { 63, 64 }, { -34, -32 }, + { -91, -90 }, { 65, 66 }, { 67, 68 }, { 69, 70 }, { 71, 72 }, { -35, -92 }, + { -95, -94 }, { -93, -97 }, { -33, 73 }, { 74, 75 }, { 76, 77 }, { 78, 79 }, + { 80, 81 }, { -96, -99 }, { -98, 82 }, { 83, 84 }, { 85, 86 }, { 87, 88 }, + { 89, 90 }, { 91, 92 }, { 93, 94 }, { 95, 96 }, { -31, -100 }, { -102, -118 }, + { -120, -119 }, { -121, 97 }, { 98, 99 }, { 100, 101 }, { 102, 103 }, + { 104, 105 }, { 106, 107 }, { 108, 109 }, { 110, 111 }, { 112, 113 }, + { 114, 115 }, { 116, 117 }, { 118, 119 }, { -23, -22 }, { -21, -20 }, + { -19, -4 }, { -24, -30 }, { -29, -28 }, { -27, -26 }, { -25, -17 }, + { -10, -9 }, { -8, -7 }, { -6, -5 }, { -11, -16 }, { -15, -14 }, { -13, -12 }, + { -3, -115 }, { -113, -112 }, { -111, -116 }, { -18, -1 }, { -2, -117 }, + { -114, -106 }, { -105, -103 }, { -101, -104 }, { -110, -109 } }; diff --git a/src/libfaad/common.c b/src/libfaad/common.c index a5135a05f..e4e587ae6 100644 --- a/src/libfaad/common.c +++ b/src/libfaad/common.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: common.c,v 1.5 2004/01/11 15:44:04 mroi Exp $ +** $Id: common.c,v 1.6 2004/01/26 22:34:10 jstembridge Exp $ **/ /* just some common functions that could be used anywhere */ diff --git a/src/libfaad/common.h b/src/libfaad/common.h index 577f54368..439316c2c 100644 --- a/src/libfaad/common.h +++ b/src/libfaad/common.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: common.h,v 1.10 2004/01/11 15:44:04 mroi Exp $ +** $Id: common.h,v 1.11 2004/01/26 22:34:10 jstembridge Exp $ **/ #ifndef __COMMON_H__ @@ -73,6 +73,7 @@ extern "C" { //#define SCALABLE_DEC /* Allow decoding of Digital Radio Mondiale (DRM) */ //#define DRM +//#define DRM_PS /* LD can't do without LTP */ #ifdef LD_DEC @@ -100,6 +101,7 @@ extern "C" { #define SBR_DEC //#define SBR_LOW_POWER +//#define PS_DEC /* FIXED POINT: No MAIN decoding, forced SBR Low Power decoder */ #ifdef FIXED_POINT diff --git a/src/libfaad/decoder.c b/src/libfaad/decoder.c index 09358adf4..208e4f5e0 100644 --- a/src/libfaad/decoder.c +++ b/src/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.7 2004/01/11 15:44:04 mroi Exp $ +** $Id: decoder.c,v 1.8 2004/01/26 22:34:10 jstembridge Exp $ **/ #include "common.h" @@ -36,8 +36,11 @@ #include "syntax.h" #include "error.h" #include "output.h" +#include "filtbank.h" +#include "drc.h" #ifdef SBR_DEC #include "sbr_dec.h" +#include "sbr_syntax.h" #endif #ifdef SSR_DEC #include "ssr.h" @@ -110,9 +113,7 @@ faacDecHandle FAADAPI faacDecOpen(void) { hDecoder->window_shape_prev[i] = 0; hDecoder->time_out[i] = NULL; -#ifdef SBR_DEC - hDecoder->time_out2[i] = NULL; -#endif + hDecoder->fb_intermed[i] = NULL; #ifdef SSR_DEC hDecoder->ssr_overlap[i] = NULL; hDecoder->prev_fmd[i] = NULL; @@ -127,7 +128,7 @@ faacDecHandle FAADAPI faacDecOpen(void) } #ifdef SBR_DEC - for (i = 0; i < 32; i++) + for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++) { hDecoder->sbr[i] = NULL; } @@ -370,6 +371,9 @@ int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, { uint8_t i; + if (hDecoder == NULL) + return 1; /* error */ + /* Special object type defined for DRM */ hDecoder->config.defObjectType = DRM_ER_LC; @@ -404,8 +408,8 @@ int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, hDecoder->sbr[0] = NULL; #endif - /* must be done before frameLength is divided by 2 for LD */ - hDecoder->fb = filter_bank_init(hDecoder->frameLength); + if (hDecoder->fb) filter_bank_end(hDecoder->fb); + hDecoder->fb = NULL; /* Take care of buffers */ if (hDecoder->sample_buffer) faad_free(hDecoder->sample_buffer); @@ -417,10 +421,8 @@ int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, if (hDecoder->time_out[i]) faad_free(hDecoder->time_out[i]); hDecoder->time_out[i] = NULL; -#ifdef SBR_DEC - if (hDecoder->time_out2[i]) faad_free(hDecoder->time_out2[i]); - hDecoder->time_out2[i] = NULL; -#endif + if (hDecoder->fb_intermed[i]) faad_free(hDecoder->fb_intermed[i]); + hDecoder->fb_intermed[i] = NULL; #ifdef SSR_DEC if (hDecoder->ssr_overlap[i]) faad_free(hDecoder->ssr_overlap[i]); hDecoder->ssr_overlap[i] = NULL; @@ -438,6 +440,16 @@ int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, #endif } +#ifdef SBR_DEC + for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++) + { + if (hDecoder->sbr[i]) + sbrDecodeEnd(hDecoder->sbr[i]); + } +#endif + + hDecoder->fb = filter_bank_init(hDecoder->frameLength); + return 0; } #endif @@ -460,9 +472,7 @@ void FAADAPI faacDecClose(faacDecHandle hDecoder) for (i = 0; i < MAX_CHANNELS; i++) { if (hDecoder->time_out[i]) faad_free(hDecoder->time_out[i]); -#ifdef SBR_DEC - if (hDecoder->time_out2[i]) faad_free(hDecoder->time_out2[i]); -#endif + if (hDecoder->fb_intermed[i]) faad_free(hDecoder->fb_intermed[i]); #ifdef SSR_DEC if (hDecoder->ssr_overlap[i]) faad_free(hDecoder->ssr_overlap[i]); if (hDecoder->prev_fmd[i]) faad_free(hDecoder->prev_fmd[i]); @@ -487,7 +497,7 @@ void FAADAPI faacDecClose(faacDecHandle hDecoder) if (hDecoder->sample_buffer) faad_free(hDecoder->sample_buffer); #ifdef SBR_DEC - for (i = 0; i < 32; i++) + for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++) { if (hDecoder->sbr[i]) sbrDecodeEnd(hDecoder->sbr[i]); @@ -717,35 +727,11 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, uint8_t *buffer, uint32_t buffer_size) { - adts_header adts; - uint8_t channels = 0, ch_ele = 0; + uint8_t channels = 0; uint8_t output_channels = 0; bitfile ld; 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; - uint8_t *window_shape_prev; uint16_t frame_len; -#ifdef MAIN_DEC - pred_state **pred_stat; -#endif - real_t **time_out; -#ifdef SBR_DEC - real_t **time_out2; -#endif -#ifdef SSR_DEC - real_t **ssr_overlap, **prev_fmd; -#endif - fb_info *fb; - drc_info *drc; - program_config *pce; - void *sample_buffer; #ifdef PROFILE @@ -758,25 +744,6 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, return NULL; } - sf_index = hDecoder->sf_index; - object_type = hDecoder->object_type; - channelConfiguration = hDecoder->channelConfiguration; -#ifdef MAIN_DEC - pred_stat = hDecoder->pred_stat; -#endif - window_shape_prev = hDecoder->window_shape_prev; - time_out = hDecoder->time_out; -#ifdef SBR_DEC - time_out2 = hDecoder->time_out2; -#endif -#ifdef SSR_DEC - ssr_overlap = hDecoder->ssr_overlap; - prev_fmd = hDecoder->prev_fmd; -#endif - fb = hDecoder->fb; - drc = hDecoder->drc; - outputFormat = hDecoder->config.outputFormat; - pce = &hDecoder->pce; frame_len = hDecoder->frameLength; @@ -787,7 +754,7 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, faad_initbits(&ld, buffer, buffer_size); #ifdef DRM - if (object_type == DRM_ER_LC) + if (hDecoder->object_type == DRM_ER_LC) { /* We do not support stereo right now */ if (hDecoder->channelConfiguration == 2) @@ -803,6 +770,8 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, if (hDecoder->adts_header_present) { + adts_header adts; + adts.old_format = hDecoder->config.useOldADTSFormat; if ((hInfo->error = adts_frame(&adts, &ld)) > 0) goto error; @@ -821,20 +790,26 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, #ifdef SCALABLE_DEC if ((hDecoder->object_type == 6) || (hDecoder->object_type == DRM_ER_LC)) { - aac_scalable_main_element(hDecoder, hInfo, &ld, pce, drc); + aac_scalable_main_element(hDecoder, hInfo, &ld, &hDecoder->pce, hDecoder->drc); } else { #endif - raw_data_block(hDecoder, hInfo, &ld, pce, drc); + raw_data_block(hDecoder, hInfo, &ld, &hDecoder->pce, hDecoder->drc); #ifdef SCALABLE_DEC } #endif - ch_ele = hDecoder->fr_ch_ele; channels = hDecoder->fr_channels; if (hInfo->error > 0) goto error; + /* safety check */ + if (channels == 0 || channels > MAX_CHANNELS) + { + /* invalid number of channels */ + hInfo->error = 12; + goto error; + } /* no more bit reading after this */ bitsconsumed = faad_get_processed_bits(&ld); @@ -846,46 +821,6 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, } faad_endbits(&ld); -#ifdef DRM -#ifdef SBR_DEC - if ((hDecoder->sbr_present_flag == 1) && (hDecoder->object_type == DRM_ER_LC)) - { - int32_t i; - - if (bitsconsumed + 8 > buffer_size*8) - { - hInfo->error = 14; - goto error; - } - - 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*)faad_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 = get_sample_rate(hDecoder->sf_index); - hDecoder->sbr[0]->sample_rate *= 2; - - hDecoder->sbr[0]->id_aac = hDecoder->element_id[0]; - } -#endif -#endif if (!hDecoder->adts_header_present && !hDecoder->adif_header_present) { @@ -934,18 +869,23 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, } /* allocate the buffer for the final samples */ - if (hDecoder->sample_buffer == NULL) + if ((hDecoder->sample_buffer == NULL) || + (hDecoder->alloced_channels != output_channels)) { static const uint8_t str[] = { sizeof(int16_t), sizeof(int32_t), sizeof(int32_t), sizeof(float32_t), sizeof(double), sizeof(int16_t), sizeof(int16_t), sizeof(int16_t), sizeof(int16_t), 0, 0, 0 }; - uint8_t stride = str[outputFormat-1]; + uint8_t stride = str[hDecoder->config.outputFormat-1]; #ifdef SBR_DEC if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) stride = 2 * stride; #endif - hDecoder->sample_buffer = faad_malloc(frame_len*channels*stride); + if (hDecoder->sample_buffer) + faad_free(hDecoder->sample_buffer); + hDecoder->sample_buffer = NULL; + hDecoder->sample_buffer = faad_malloc(frame_len*output_channels*stride); + hDecoder->alloced_channels = output_channels; } sample_buffer = hDecoder->sample_buffer; @@ -953,58 +893,23 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, #ifdef SBR_DEC if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) { - uint8_t i, ch = 0; - for (i = 0; i < ch_ele; i++) - { - /* following case can happen when forceUpSampling == 1 */ - if (hDecoder->sbr[i] == NULL) - { - hDecoder->sbr[i] = sbrDecodeInit(hDecoder->frameLength -#ifdef DRM - , 0 -#endif - ); - hDecoder->sbr[i]->data = NULL; - hDecoder->sbr[i]->data_size = 0; - hDecoder->sbr[i]->id_aac = hDecoder->element_id[i]; - } + uint8_t ele; - /* Allocate space for SBR output */ - if (hDecoder->time_out2[ch] == NULL) - { - hDecoder->time_out2[ch] = (real_t*)faad_malloc(hDecoder->frameLength*2*sizeof(real_t)); - memset(hDecoder->time_out2[ch], 0, hDecoder->frameLength*2*sizeof(real_t)); - } + /* this data is different when SBR is used or when the data is upsampled */ + frame_len *= 2; + hInfo->samples *= 2; + hInfo->samplerate *= 2; - if (hDecoder->sbr[i]->id_aac == ID_CPE) + /* check if every element was provided with SBR data */ + for (ele = 0; ele < hDecoder->fr_ch_ele; ele++) + { + if (hDecoder->sbr[ele] == NULL) { - /* space for 2 channels needed */ - if (hDecoder->time_out2[ch+1] == NULL) - { - hDecoder->time_out2[ch+1] = (real_t*)faad_malloc(hDecoder->frameLength*2*sizeof(real_t)); - memset(hDecoder->time_out2[ch+1], 0, hDecoder->frameLength*2*sizeof(real_t)); - } - - memcpy(time_out2[ch], - time_out[ch], frame_len*sizeof(real_t)); - memcpy(time_out2[ch+1], - time_out[ch+1], frame_len*sizeof(real_t)); - sbrDecodeFrame(hDecoder->sbr[i], - time_out2[ch], time_out2[ch+1], - hDecoder->postSeekResetFlag, hDecoder->forceUpSampling); - ch += 2; - } else { - memcpy(time_out2[ch], - time_out[ch], frame_len*sizeof(real_t)); - sbrDecodeFrame(hDecoder->sbr[i], - time_out2[ch], NULL, - hDecoder->postSeekResetFlag, hDecoder->forceUpSampling); - ch++; + hInfo->error = 25; + goto error; } } - frame_len *= 2; - hInfo->samples *= 2; - hInfo->samplerate *= 2; + /* sbr */ if (hDecoder->sbr_present_flag == 1) { @@ -1013,22 +918,18 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, } else { hInfo->sbr = NO_SBR_UPSAMPLED; } - - sample_buffer = output_to_PCM(hDecoder, time_out2, sample_buffer, - output_channels, frame_len, outputFormat); - } else { -#endif - sample_buffer = output_to_PCM(hDecoder, time_out, sample_buffer, - output_channels, frame_len, outputFormat); -#ifdef SBR_DEC } #endif + sample_buffer = output_to_PCM(hDecoder, hDecoder->time_out, sample_buffer, + output_channels, frame_len, hDecoder->config.outputFormat); + + hDecoder->postSeekResetFlag = 0; hDecoder->frame++; #ifdef LD_DEC - if (object_type != LD) + if (hDecoder->object_type != LD) { #endif if (hDecoder->frame <= 1) @@ -1054,6 +955,9 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, return sample_buffer; error: + + faad_endbits(&ld); + /* cleanup */ #ifdef ANALYSIS fflush(stdout); diff --git a/src/libfaad/decoder.h b/src/libfaad/decoder.h index 0196777ac..2b0d3d03a 100644 --- a/src/libfaad/decoder.h +++ b/src/libfaad/decoder.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: decoder.h,v 1.6 2004/01/11 15:44:05 mroi Exp $ +** $Id: decoder.h,v 1.7 2004/01/26 22:34:10 jstembridge Exp $ **/ #ifndef __DECODER_H__ diff --git a/src/libfaad/drc.c b/src/libfaad/drc.c index b8089ca18..b361e877f 100644 --- a/src/libfaad/drc.c +++ b/src/libfaad/drc.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: drc.c,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: drc.c,v 1.5 2004/01/26 22:34:10 jstembridge Exp $ **/ #include "common.h" diff --git a/src/libfaad/drc.h b/src/libfaad/drc.h index b9f666f78..86266c324 100644 --- a/src/libfaad/drc.h +++ b/src/libfaad/drc.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: drc.h,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: drc.h,v 1.5 2004/01/26 22:34:10 jstembridge Exp $ **/ #ifndef __DRC_H__ diff --git a/src/libfaad/error.c b/src/libfaad/error.c index 43af74fe7..bf832e740 100644 --- a/src/libfaad/error.c +++ b/src/libfaad/error.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: error.c,v 1.5 2004/01/11 15:44:05 mroi Exp $ +** $Id: error.c,v 1.6 2004/01/26 22:34:10 jstembridge Exp $ **/ #include "common.h" @@ -41,12 +41,19 @@ int8_t *err_msg[] = { "Error decoding huffman scalefactor (bitstream error)", "Error decoding huffman codeword (bitstream error)", "Non existent huffman codebook number found", - "Maximum number of channels exceeded", + "Invalid number of channels", "Maximum number of bitstream elements exceeded", "Input data buffer too small", "Array index out of range", "Maximum number of scalefactor bands exceeded", "Quantised value out of range", - "LTP lag out of range" + "LTP lag out of range", + "Invalid SBR parameter decoded", + "SBR called without being initialised", + "Unexpected channel configuration change", + "Error in program_config_element", + "First SBR frame is not the same as first AAC frame", + "Unexpected fill element with SBR data", + "Not all elements were provided with SBR data" }; diff --git a/src/libfaad/error.h b/src/libfaad/error.h index d25fb1026..de0b417a0 100644 --- a/src/libfaad/error.h +++ b/src/libfaad/error.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: error.h,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: error.h,v 1.5 2004/01/26 22:34:10 jstembridge Exp $ **/ #ifndef __ERROR_H__ @@ -32,7 +32,7 @@ extern "C" { #endif -#define NUM_ERROR_MESSAGES 19 +#define NUM_ERROR_MESSAGES 26 extern int8_t *err_msg[]; #ifdef __cplusplus diff --git a/src/libfaad/faad.h b/src/libfaad/faad.h index 31f8e13f1..640f66de1 100644 --- a/src/libfaad/faad.h +++ b/src/libfaad/faad.h @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com ** ** This program is free software; you can redistribute it and/or modify ** it under the terms of the GNU General Public License as published by @@ -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.5 2003/12/30 02:00:10 miguelfreitas Exp $ +** $Id: faad.h,v 1.6 2004/01/26 22:34:10 jstembridge Exp $ **/ #ifndef __AACDEC_H__ @@ -138,6 +138,7 @@ typedef struct faacDecConfiguration unsigned char outputFormat; unsigned char downMatrix; unsigned char useOldADTSFormat; + unsigned char dontUpSampleImplicitSBR; } faacDecConfiguration, *faacDecConfigurationPtr; typedef struct faacDecFrameInfo @@ -167,9 +168,9 @@ typedef struct faacDecFrameInfo char* FAADAPI faacDecGetErrorMessage(unsigned char errcode); -unsigned long FAADAPI faacDecGetCapabilities(); +unsigned long FAADAPI faacDecGetCapabilities(void); -faacDecHandle FAADAPI faacDecOpen(); +faacDecHandle FAADAPI faacDecOpen(void); faacDecConfigurationPtr FAADAPI faacDecGetCurrentConfiguration(faacDecHandle hDecoder); diff --git a/src/libfaad/filtbank.c b/src/libfaad/filtbank.c index 1ec45ac77..a664486bf 100644 --- a/src/libfaad/filtbank.c +++ b/src/libfaad/filtbank.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: filtbank.c,v 1.7 2004/01/11 15:44:05 mroi Exp $ +** $Id: filtbank.c,v 1.8 2004/01/26 22:34:10 jstembridge Exp $ **/ #include "common.h" @@ -194,7 +194,8 @@ static INLINE void mdct(fb_info *fb, real_t *in_data, real_t *out_data, uint16_t void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape, uint8_t window_shape_prev, real_t *freq_in, - real_t *time_out, uint8_t object_type, uint16_t frame_len) + real_t *time_out, real_t *overlap, + uint8_t object_type, uint16_t frame_len) { int16_t i; ALIGN real_t transf_buf[2*1024] = {0}; @@ -229,23 +230,24 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape, } #endif + switch (window_sequence) { case ONLY_LONG_SEQUENCE: imdct_long(fb, freq_in, transf_buf, 2*nlong); for (i = 0; i < nlong; i+=4) { - time_out[i] = time_out[nlong+i] + MUL_F(transf_buf[i],window_long_prev[i]); - time_out[i+1] = time_out[nlong+i+1] + MUL_F(transf_buf[i+1],window_long_prev[i+1]); - time_out[i+2] = time_out[nlong+i+2] + MUL_F(transf_buf[i+2],window_long_prev[i+2]); - time_out[i+3] = time_out[nlong+i+3] + MUL_F(transf_buf[i+3],window_long_prev[i+3]); + time_out[i] = overlap[i] + MUL_F(transf_buf[i],window_long_prev[i]); + time_out[i+1] = overlap[i+1] + MUL_F(transf_buf[i+1],window_long_prev[i+1]); + time_out[i+2] = overlap[i+2] + MUL_F(transf_buf[i+2],window_long_prev[i+2]); + time_out[i+3] = overlap[i+3] + MUL_F(transf_buf[i+3],window_long_prev[i+3]); } for (i = 0; i < nlong; i+=4) { - time_out[nlong+i] = MUL_F(transf_buf[nlong+i],window_long[nlong-1-i]); - time_out[nlong+i+1] = MUL_F(transf_buf[nlong+i+1],window_long[nlong-2-i]); - time_out[nlong+i+2] = MUL_F(transf_buf[nlong+i+2],window_long[nlong-3-i]); - time_out[nlong+i+3] = MUL_F(transf_buf[nlong+i+3],window_long[nlong-4-i]); + overlap[i] = MUL_F(transf_buf[nlong+i],window_long[nlong-1-i]); + overlap[i+1] = MUL_F(transf_buf[nlong+i+1],window_long[nlong-2-i]); + overlap[i+2] = MUL_F(transf_buf[nlong+i+2],window_long[nlong-3-i]); + overlap[i+3] = MUL_F(transf_buf[nlong+i+3],window_long[nlong-4-i]); } break; @@ -253,17 +255,17 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape, imdct_long(fb, freq_in, transf_buf, 2*nlong); for (i = 0; i < nlong; i+=4) { - time_out[i] = time_out[nlong+i] + MUL_F(transf_buf[i],window_long_prev[i]); - time_out[i+1] = time_out[nlong+i+1] + MUL_F(transf_buf[i+1],window_long_prev[i+1]); - time_out[i+2] = time_out[nlong+i+2] + MUL_F(transf_buf[i+2],window_long_prev[i+2]); - time_out[i+3] = time_out[nlong+i+3] + MUL_F(transf_buf[i+3],window_long_prev[i+3]); + time_out[i] = overlap[i] + MUL_F(transf_buf[i],window_long_prev[i]); + time_out[i+1] = overlap[i+1] + MUL_F(transf_buf[i+1],window_long_prev[i+1]); + time_out[i+2] = overlap[i+2] + MUL_F(transf_buf[i+2],window_long_prev[i+2]); + time_out[i+3] = overlap[i+3] + MUL_F(transf_buf[i+3],window_long_prev[i+3]); } for (i = 0; i < nflat_ls; i++) - time_out[nlong+i] = transf_buf[nlong+i]; + overlap[i] = transf_buf[nlong+i]; for (i = 0; i < nshort; i++) - time_out[nlong+nflat_ls+i] = MUL_F(transf_buf[nlong+nflat_ls+i],window_short[nshort-i-1]); + overlap[nflat_ls+i] = MUL_F(transf_buf[nlong+nflat_ls+i],window_short[nshort-i-1]); for (i = 0; i < nflat_ls; i++) - time_out[nlong+nflat_ls+nshort+i] = 0; + overlap[nflat_ls+nshort+i] = 0; break; case EIGHT_SHORT_SEQUENCE: @@ -276,36 +278,39 @@ void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape, faad_imdct(fb->mdct256, freq_in+6*nshort, transf_buf+2*nshort*6); faad_imdct(fb->mdct256, freq_in+7*nshort, transf_buf+2*nshort*7); for (i = 0; i < nflat_ls; i++) - time_out[i] = time_out[nlong+i]; + time_out[i] = overlap[i]; for(i = 0; i < nshort; i++) { - time_out[nflat_ls+ i] = time_out[nlong+nflat_ls+ i] + MUL_F(transf_buf[nshort*0+i],window_short_prev[i]); - time_out[nflat_ls+1*nshort+i] = time_out[nlong+nflat_ls+nshort*1+i] + MUL_F(transf_buf[nshort*1+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*2+i],window_short[i]); - time_out[nflat_ls+2*nshort+i] = time_out[nlong+nflat_ls+nshort*2+i] + MUL_F(transf_buf[nshort*3+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*4+i],window_short[i]); - time_out[nflat_ls+3*nshort+i] = time_out[nlong+nflat_ls+nshort*3+i] + MUL_F(transf_buf[nshort*5+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*6+i],window_short[i]); + time_out[nflat_ls+ i] = overlap[nflat_ls+ i] + MUL_F(transf_buf[nshort*0+i],window_short_prev[i]); + time_out[nflat_ls+1*nshort+i] = overlap[nflat_ls+nshort*1+i] + MUL_F(transf_buf[nshort*1+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*2+i],window_short[i]); + time_out[nflat_ls+2*nshort+i] = overlap[nflat_ls+nshort*2+i] + MUL_F(transf_buf[nshort*3+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*4+i],window_short[i]); + time_out[nflat_ls+3*nshort+i] = overlap[nflat_ls+nshort*3+i] + MUL_F(transf_buf[nshort*5+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*6+i],window_short[i]); if (i < trans) - time_out[nflat_ls+4*nshort+i] = time_out[nlong+nflat_ls+nshort*4+i] + MUL_F(transf_buf[nshort*7+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*8+i],window_short[i]); - else - time_out[nflat_ls+4*nshort+i] = MUL_F(transf_buf[nshort*7+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*8+i],window_short[i]); - time_out[nflat_ls+5*nshort+i] = MUL_F(transf_buf[nshort*9+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*10+i],window_short[i]); - time_out[nflat_ls+6*nshort+i] = MUL_F(transf_buf[nshort*11+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*12+i],window_short[i]); - time_out[nflat_ls+7*nshort+i] = MUL_F(transf_buf[nshort*13+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*14+i],window_short[i]); - time_out[nflat_ls+8*nshort+i] = MUL_F(transf_buf[nshort*15+i],window_short[nshort-1-i]); + time_out[nflat_ls+4*nshort+i] = overlap[nflat_ls+nshort*4+i] + MUL_F(transf_buf[nshort*7+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*8+i],window_short[i]); + } + for(i = 0; i < nshort; i++) + { + if (i >= trans) + overlap[nflat_ls+4*nshort+i-nlong] = MUL_F(transf_buf[nshort*7+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*8+i],window_short[i]); + overlap[nflat_ls+5*nshort+i-nlong] = MUL_F(transf_buf[nshort*9+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*10+i],window_short[i]); + overlap[nflat_ls+6*nshort+i-nlong] = MUL_F(transf_buf[nshort*11+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*12+i],window_short[i]); + overlap[nflat_ls+7*nshort+i-nlong] = MUL_F(transf_buf[nshort*13+i],window_short[nshort-1-i]) + MUL_F(transf_buf[nshort*14+i],window_short[i]); + overlap[nflat_ls+8*nshort+i-nlong] = MUL_F(transf_buf[nshort*15+i],window_short[nshort-1-i]); } for (i = 0; i < nflat_ls; i++) - time_out[nlong+nflat_ls+nshort+i] = 0; + overlap[nflat_ls+nshort+i] = 0; break; case LONG_STOP_SEQUENCE: imdct_long(fb, freq_in, transf_buf, 2*nlong); for (i = 0; i < nflat_ls; i++) - time_out[i] = time_out[nlong+i]; + time_out[i] = overlap[i]; for (i = 0; i < nshort; i++) - time_out[nflat_ls+i] = time_out[nlong+nflat_ls+i] + MUL_F(transf_buf[nflat_ls+i],window_short_prev[i]); + time_out[nflat_ls+i] = overlap[nflat_ls+i] + MUL_F(transf_buf[nflat_ls+i],window_short_prev[i]); for (i = 0; i < nflat_ls; i++) - time_out[nflat_ls+nshort+i] = time_out[nlong+nflat_ls+nshort+i] + transf_buf[nflat_ls+nshort+i]; + time_out[nflat_ls+nshort+i] = overlap[nflat_ls+nshort+i] + transf_buf[nflat_ls+nshort+i]; for (i = 0; i < nlong; i++) - time_out[nlong+i] = MUL_F(transf_buf[nlong+i],window_long[nlong-1-i]); + overlap[i] = MUL_F(transf_buf[nlong+i],window_long[nlong-1-i]); break; } diff --git a/src/libfaad/filtbank.h b/src/libfaad/filtbank.h index 9688d90ed..8bec0e0ab 100644 --- a/src/libfaad/filtbank.h +++ b/src/libfaad/filtbank.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: filtbank.h,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: filtbank.h,v 1.5 2004/01/26 22:34:10 jstembridge Exp $ **/ #ifndef __FILTBANK_H__ @@ -47,14 +47,11 @@ void filter_bank_ltp(fb_info *fb, uint16_t frame_len); #endif -void ifilter_bank(fb_info *fb, - uint8_t window_sequence, - uint8_t window_shape, - uint8_t window_shape_prev, - real_t *freq_in, - real_t *time_out, - uint8_t object_type, - uint16_t frame_len); +void ifilter_bank(fb_info *fb, uint8_t window_sequence, uint8_t window_shape, + uint8_t window_shape_prev, real_t *freq_in, + real_t *time_out, real_t *overlap, + uint8_t object_type, uint16_t frame_len); + #ifdef USE_SSE void ifilter_bank_sse(fb_info *fb, uint8_t window_sequence, uint8_t window_shape, uint8_t window_shape_prev, real_t *freq_in, diff --git a/src/libfaad/fixed.h b/src/libfaad/fixed.h index 8a5ac238a..a5c44b33b 100644 --- a/src/libfaad/fixed.h +++ b/src/libfaad/fixed.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: fixed.h,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: fixed.h,v 1.5 2004/01/26 22:34:10 jstembridge Exp $ **/ #ifndef __FIXED_H__ diff --git a/src/libfaad/hcr.c b/src/libfaad/hcr.c index 010958fee..8fb614969 100644 --- a/src/libfaad/hcr.c +++ b/src/libfaad/hcr.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: hcr.c,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: hcr.c,v 1.5 2004/01/26 22:34:10 jstembridge Exp $ **/ #include "common.h" diff --git a/src/libfaad/huffman.c b/src/libfaad/huffman.c index 9986e1472..ae0559ebc 100644 --- a/src/libfaad/huffman.c +++ b/src/libfaad/huffman.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: huffman.c,v 1.2 2004/01/11 15:44:05 mroi Exp $ +** $Id: huffman.c,v 1.3 2004/01/26 22:34:10 jstembridge Exp $ **/ #include "common.h" @@ -51,25 +51,18 @@ static uint8_t huffman_binary_pair(uint8_t cb, bitfile *ld, int16_t *sp); static uint8_t huffman_binary_pair_sign(uint8_t cb, bitfile *ld, int16_t *sp); static int16_t huffman_codebook(uint8_t i); - int8_t huffman_scale_factor(bitfile *ld) { - uint16_t offset = 0; + uint8_t bit; + int16_t index = 0; - while (hcb_sf[offset][1]) + while (index >= 0) { - uint8_t b = faad_get1bit(ld - DEBUGVAR(1,255,"huffman_scale_factor()")); - offset += hcb_sf[offset][b]; - - if (offset > 240) - { - /* printf("ERROR: offset into hcb_sf = %d >240!\n", offset); */ - return -1; - } + bit = (uint8_t)faad_get1bit(ld); + index = hcb_sf[index][bit]; } - return hcb_sf[offset][0]; + return index + 121; } @@ -118,16 +111,6 @@ static INLINE void huffman_sign_bits(bitfile *ld, int16_t *sp, uint8_t len) } } -#ifdef _WIN32 -static INLINE uint32_t bsr(uint32_t bits) -{ - __asm - { - bsr eax, dword ptr [bits] - } -} -#endif - static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp) { uint8_t neg, i; @@ -145,7 +128,6 @@ static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp) neg = 0; } -#ifndef _WIN32 for (i = 4; ; i++) { if (faad_get1bit(ld @@ -154,17 +136,6 @@ static INLINE int16_t huffman_getescape(bitfile *ld, int16_t sp) break; } } -#else - /* maximum quantised value is 8192, - * so the maximum number of bits for 1 value is log[2](8192)=13 - * minimum bits used when escape is present is 4 bits - * this leaves a maximum of 9 bits to be read at this point - */ - j = faad_showbits(ld, 9) | 0xFFFFFE00; - i = 12 - bsr(~j); - faad_getbits(ld, i-3 - DEBUGVAR(1,6,"huffman_getescape(): escape size")); -#endif off = faad_getbits(ld, i DEBUGVAR(1,9,"huffman_getescape(): escape")); @@ -355,7 +326,7 @@ uint8_t huffman_spectral_data(uint8_t cb, bitfile *ld, int16_t *sp) case 10: return huffman_2step_pair_sign(cb, ld, sp); case 12: { - uint8_t err = huffman_2step_quad(1, ld, sp); + uint8_t err = huffman_2step_pair(11, ld, sp); sp[0] = huffman_codebook(0); sp[1] = huffman_codebook(1); return err; } case 11: diff --git a/src/libfaad/huffman.h b/src/libfaad/huffman.h index 8a51fb8f6..e34afc9dc 100644 --- a/src/libfaad/huffman.h +++ b/src/libfaad/huffman.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: huffman.h,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: huffman.h,v 1.5 2004/01/26 22:34:10 jstembridge Exp $ **/ #ifndef __HUFFMAN_H__ diff --git a/src/libfaad/ic_predict.c b/src/libfaad/ic_predict.c index 446183a26..7eb18ab5d 100644 --- a/src/libfaad/ic_predict.c +++ b/src/libfaad/ic_predict.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: ic_predict.c,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: ic_predict.c,v 1.5 2004/01/26 22:34:10 jstembridge Exp $ **/ #include "common.h" diff --git a/src/libfaad/ic_predict.h b/src/libfaad/ic_predict.h index fc99b5879..e7fce1b4f 100644 --- a/src/libfaad/ic_predict.h +++ b/src/libfaad/ic_predict.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: ic_predict.h,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: ic_predict.h,v 1.5 2004/01/26 22:34:10 jstembridge Exp $ **/ #ifdef MAIN_DEC diff --git a/src/libfaad/iq_table.h b/src/libfaad/iq_table.h index b3ae6bb2b..f2e326973 100644 --- a/src/libfaad/iq_table.h +++ b/src/libfaad/iq_table.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: iq_table.h,v 1.3 2004/01/11 15:44:05 mroi Exp $ +** $Id: iq_table.h,v 1.4 2004/01/26 22:34:10 jstembridge Exp $ **/ #ifndef IQ_TABLE_H__ diff --git a/src/libfaad/is.c b/src/libfaad/is.c index f410ef107..5dc12e8c9 100644 --- a/src/libfaad/is.c +++ b/src/libfaad/is.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: is.c,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: is.c,v 1.5 2004/01/26 22:34:10 jstembridge Exp $ **/ #include "common.h" diff --git a/src/libfaad/is.h b/src/libfaad/is.h index 3548a1090..66b0cad28 100644 --- a/src/libfaad/is.h +++ b/src/libfaad/is.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: is.h,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: is.h,v 1.5 2004/01/26 22:34:10 jstembridge Exp $ **/ #ifndef __IS_H__ diff --git a/src/libfaad/kbd_win.h b/src/libfaad/kbd_win.h index 957b8ba1b..778606419 100644 --- a/src/libfaad/kbd_win.h +++ b/src/libfaad/kbd_win.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: kbd_win.h,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: kbd_win.h,v 1.5 2004/01/26 22:34:10 jstembridge Exp $ **/ #ifndef __KBD_WIN_H__ diff --git a/src/libfaad/lt_predict.c b/src/libfaad/lt_predict.c index 388d841c3..cb7b0ad32 100644 --- a/src/libfaad/lt_predict.c +++ b/src/libfaad/lt_predict.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: lt_predict.c,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: lt_predict.c,v 1.5 2004/01/26 22:34:10 jstembridge Exp $ **/ diff --git a/src/libfaad/lt_predict.h b/src/libfaad/lt_predict.h index 963ab1a8e..3fcf49bb7 100644 --- a/src/libfaad/lt_predict.h +++ b/src/libfaad/lt_predict.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: lt_predict.h,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: lt_predict.h,v 1.5 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifdef LTP_DEC diff --git a/src/libfaad/mdct.c b/src/libfaad/mdct.c index afa27b990..54f3a3285 100644 --- a/src/libfaad/mdct.c +++ b/src/libfaad/mdct.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: mdct.c,v 1.8 2004/01/11 15:44:05 mroi Exp $ +** $Id: mdct.c,v 1.9 2004/01/26 22:34:11 jstembridge Exp $ **/ /* diff --git a/src/libfaad/mdct.h b/src/libfaad/mdct.h index 435269137..ef9d274b3 100644 --- a/src/libfaad/mdct.h +++ b/src/libfaad/mdct.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: mdct.h,v 1.5 2004/01/11 15:44:05 mroi Exp $ +** $Id: mdct.h,v 1.6 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __MDCT_H__ diff --git a/src/libfaad/mp4.c b/src/libfaad/mp4.c index e931e965e..2079f3e48 100644 --- a/src/libfaad/mp4.c +++ b/src/libfaad/mp4.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: mp4.c,v 1.6 2004/01/11 15:44:05 mroi Exp $ +** $Id: mp4.c,v 1.7 2004/01/26 22:34:11 jstembridge Exp $ **/ #include "common.h" diff --git a/src/libfaad/mp4.h b/src/libfaad/mp4.h index dfbfcd8c6..9d3d07f0f 100644 --- a/src/libfaad/mp4.h +++ b/src/libfaad/mp4.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: mp4.h,v 1.5 2004/01/11 15:44:05 mroi Exp $ +** $Id: mp4.h,v 1.6 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __MP4_H__ diff --git a/src/libfaad/ms.c b/src/libfaad/ms.c index f53340167..d94f2e15b 100644 --- a/src/libfaad/ms.c +++ b/src/libfaad/ms.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: ms.c,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: ms.c,v 1.5 2004/01/26 22:34:11 jstembridge Exp $ **/ #include "common.h" diff --git a/src/libfaad/ms.h b/src/libfaad/ms.h index e728f0436..29a37b77a 100644 --- a/src/libfaad/ms.h +++ b/src/libfaad/ms.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: ms.h,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: ms.h,v 1.5 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __MS_H__ diff --git a/src/libfaad/output.c b/src/libfaad/output.c index 2af34a1d0..adb29db02 100644 --- a/src/libfaad/output.c +++ b/src/libfaad/output.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: output.c,v 1.4 2003/12/30 02:00:10 miguelfreitas Exp $ +** $Id: output.c,v 1.5 2004/01/26 22:34:11 jstembridge Exp $ **/ #include "common.h" diff --git a/src/libfaad/output.h b/src/libfaad/output.h index 953dbe638..bf3c9ea9d 100644 --- a/src/libfaad/output.h +++ b/src/libfaad/output.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: output.h,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: output.h,v 1.5 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __OUTPUT_H__ diff --git a/src/libfaad/pns.c b/src/libfaad/pns.c index 1802e439f..4588d11ef 100644 --- a/src/libfaad/pns.c +++ b/src/libfaad/pns.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: pns.c,v 1.5 2004/01/11 15:44:05 mroi Exp $ +** $Id: pns.c,v 1.6 2004/01/26 22:34:11 jstembridge Exp $ **/ #include "common.h" diff --git a/src/libfaad/pns.h b/src/libfaad/pns.h index 23557587b..30a52a1b7 100644 --- a/src/libfaad/pns.h +++ b/src/libfaad/pns.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: pns.h,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: pns.h,v 1.5 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __PNS_H__ diff --git a/src/libfaad/pulse.c b/src/libfaad/pulse.c index c11ee802d..28d8b58b2 100644 --- a/src/libfaad/pulse.c +++ b/src/libfaad/pulse.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: pulse.c,v 1.5 2004/01/11 15:44:05 mroi Exp $ +** $Id: pulse.c,v 1.6 2004/01/26 22:34:11 jstembridge Exp $ **/ #include "common.h" diff --git a/src/libfaad/pulse.h b/src/libfaad/pulse.h index d64625101..9844392df 100644 --- a/src/libfaad/pulse.h +++ b/src/libfaad/pulse.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: pulse.h,v 1.5 2004/01/11 15:44:05 mroi Exp $ +** $Id: pulse.h,v 1.6 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __PULSE_H__ diff --git a/src/libfaad/rvlc.c b/src/libfaad/rvlc.c index 22aa8b0ca..5c7b279f7 100644 --- a/src/libfaad/rvlc.c +++ b/src/libfaad/rvlc.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: rvlc.c,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: rvlc.c,v 1.5 2004/01/26 22:34:11 jstembridge Exp $ **/ /* RVLC scalefactor decoding diff --git a/src/libfaad/rvlc.h b/src/libfaad/rvlc.h index 65ea6721f..8028a93dd 100644 --- a/src/libfaad/rvlc.h +++ b/src/libfaad/rvlc.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: rvlc.h,v 1.3 2004/01/11 15:44:05 mroi Exp $ +** $Id: rvlc.h,v 1.4 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __RVLC_SCF_H__ diff --git a/src/libfaad/sbr_dct.c b/src/libfaad/sbr_dct.c index f21f27e40..9cfb955cd 100644 --- a/src/libfaad/sbr_dct.c +++ b/src/libfaad/sbr_dct.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_dct.c,v 1.2 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_dct.c,v 1.3 2004/01/26 22:34:11 jstembridge Exp $ **/ #include "common.h" diff --git a/src/libfaad/sbr_dct.h b/src/libfaad/sbr_dct.h index 3dace8251..1fb1b2230 100644 --- a/src/libfaad/sbr_dct.h +++ b/src/libfaad/sbr_dct.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_dct.h,v 1.2 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_dct.h,v 1.3 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __SBR_DCT_H__ diff --git a/src/libfaad/sbr_dec.c b/src/libfaad/sbr_dec.c index edbc62548..e522c787c 100644 --- a/src/libfaad/sbr_dec.c +++ b/src/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.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_dec.c,v 1.5 2004/01/26 22:34:11 jstembridge Exp $ **/ @@ -42,9 +42,10 @@ #include "sbr_hfadj.h" /* static function declarations */ -static void sbr_save_prev_data(sbr_info *sbr, uint8_t ch); +static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch); -sbr_info *sbrDecodeInit(uint16_t framelength +sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, + uint32_t sample_rate #ifdef DRM , uint8_t IsDRM #endif @@ -53,6 +54,10 @@ sbr_info *sbrDecodeInit(uint16_t framelength sbr_info *sbr = faad_malloc(sizeof(sbr_info)); memset(sbr, 0, sizeof(sbr_info)); + /* save id of the parent element */ + sbr->id_aac = id_aac; + sbr->sample_rate = sample_rate; + sbr->bs_freq_scale = 2; sbr->bs_alter_scale = 1; sbr->bs_noise_bands = 2; @@ -115,7 +120,7 @@ void sbrDecodeEnd(sbr_info *sbr) } } -static void sbr_save_prev_data(sbr_info *sbr, uint8_t ch) +static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch) { uint8_t i; @@ -124,6 +129,10 @@ static void sbr_save_prev_data(sbr_info *sbr, uint8_t ch) sbr->L_E_prev[ch] = sbr->L_E[ch]; + /* sbr->L_E[ch] can become 0 on files with bit errors */ + if (sbr->L_E[ch] <= 0) + return 19; + sbr->f_prev[ch] = sbr->f[ch][sbr->L_E[ch] - 1]; for (i = 0; i < 64; i++) { @@ -141,209 +150,230 @@ static void sbr_save_prev_data(sbr_info *sbr, uint8_t ch) sbr->prevEnvIsShort[ch] = 0; else sbr->prevEnvIsShort[ch] = -1; + + return 0; } -void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, - real_t *right_channel, - const uint8_t just_seeked, const uint8_t upsample_only) +static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, + uint8_t ch, uint8_t dont_process) { int16_t i, k, l; - uint8_t dont_process = 0; - uint8_t ch, channels, ret; - real_t *ch_buf; - ALIGN qmf_t X[MAX_NTSR][64]; #ifdef SBR_LOW_POWER ALIGN real_t deg[64]; #endif - bitfile *ld = NULL; - - channels = (sbr->id_aac == ID_SCE) ? 1 : 2; - - if (sbr->data == NULL || sbr->data_size == 0) - { - ret = 1; - } else { - ld = (bitfile*)faad_malloc(sizeof(bitfile)); - - /* initialise and read the bitstream */ - faad_initbits(ld, sbr->data, sbr->data_size); - -#ifdef DRM - if (sbr->Is_DRM_SBR) - faad_getbits(ld, 8); /* Skip 8-bit CRC */ -#endif - - ret = sbr_extension_data(ld, sbr); - -#ifdef DRM - /* Check CRC */ - if (sbr->Is_DRM_SBR) - ld->error = faad_check_CRC(ld, faad_get_processed_bits(ld) - 8); -#endif - - ret = ld->error ? ld->error : ret; - faad_endbits(ld); - if (ld) faad_free(ld); - ld = NULL; - } - - if (sbr->data) faad_free(sbr->data); - sbr->data = NULL; - - if (ret || (sbr->header_count == 0)) + if (sbr->frame == 0) { - /* don't process just upsample */ - dont_process = 1; + uint8_t j; + sbr->qmfa[ch] = qmfa_init(32); + sbr->qmfs[ch] = qmfs_init(64); - /* Re-activate reset for next frame */ - if (ret && sbr->Reset) - sbr->bs_start_freq_prev = -1; - } - - if (just_seeked) - { - sbr->just_seeked = 1; - } else { - sbr->just_seeked = 0; - } - - for (ch = 0; ch < channels; ch++) - { - if (sbr->frame == 0) + for (j = 0; j < 5; j++) { - uint8_t j; - sbr->qmfa[ch] = qmfa_init(32); - sbr->qmfs[ch] = qmfs_init(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)); + sbr->G_temp_prev[ch][j] = faad_malloc(64*sizeof(real_t)); + sbr->Q_temp_prev[ch][j] = faad_malloc(64*sizeof(real_t)); } - if (ch == 0) - ch_buf = left_channel; - else - ch_buf = right_channel; + 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], ch_buf, sbr->Xcodec[ch], sbr->tHFGen, 32); - else - sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], ch_buf, sbr->Xcodec[ch], sbr->tHFGen, sbr->kx); + /* subband analysis */ + if (dont_process) + sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xcodec[ch], sbr->tHFGen, 32); + else + sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xcodec[ch], sbr->tHFGen, sbr->kx); - if (!dont_process) - { + if (!dont_process) + { #if 1 - /* insert high frequencies here */ - /* hf generation using patching */ - hf_generation(sbr, sbr->Xcodec[ch], sbr->Xsbr[ch] + /* insert high frequencies here */ + /* hf generation using patching */ + hf_generation(sbr, sbr->Xcodec[ch], sbr->Xsbr[ch] #ifdef SBR_LOW_POWER - ,deg + ,deg #endif - ,ch); + ,ch); #endif #ifdef SBR_LOW_POWER - for (l = sbr->t_E[ch][0]; l < sbr->t_E[ch][sbr->L_E[ch]]; l++) + for (l = sbr->t_E[ch][0]; l < sbr->t_E[ch][sbr->L_E[ch]]; l++) + { + for (k = 0; k < sbr->kx; k++) { - for (k = 0; k < sbr->kx; k++) - { - QMF_RE(sbr->Xsbr[ch][sbr->tHFAdj + l][k]) = 0; - } + QMF_RE(sbr->Xsbr[ch][sbr->tHFAdj + l][k]) = 0; } + } #endif #if 1 - /* hf adjustment */ - hf_adjustment(sbr, sbr->Xsbr[ch] + /* hf adjustment */ + hf_adjustment(sbr, sbr->Xsbr[ch] #ifdef SBR_LOW_POWER - ,deg + ,deg #endif - ,ch); + ,ch); #endif - } + } - if ((sbr->just_seeked != 0) || dont_process) + if ((sbr->just_seeked != 0) || dont_process) + { + for (l = 0; l < sbr->numTimeSlotsRate; l++) { - for (l = 0; l < sbr->numTimeSlotsRate; l++) + for (k = 0; k < 32; k++) { - for (k = 0; k < 32; k++) - { - QMF_RE(X[l][k]) = QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); + QMF_RE(X[l][k]) = QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); #ifndef SBR_LOW_POWER - QMF_IM(X[l][k]) = QMF_IM(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); + QMF_IM(X[l][k]) = QMF_IM(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); #endif - } - for (k = 32; k < 64; k++) - { - QMF_RE(X[l][k]) = 0; + } + for (k = 32; k < 64; k++) + { + QMF_RE(X[l][k]) = 0; #ifndef SBR_LOW_POWER - QMF_IM(X[l][k]) = 0; + QMF_IM(X[l][k]) = 0; #endif - } } - } else { - for (l = 0; l < sbr->numTimeSlotsRate; l++) - { - uint8_t xover_band; + } + } else { + for (l = 0; l < sbr->numTimeSlotsRate; l++) + { + uint8_t xover_band; - if (l < sbr->t_E[ch][0]) - xover_band = sbr->kx_prev; - else - xover_band = sbr->kx; + if (l < sbr->t_E[ch][0]) + xover_band = sbr->kx_prev; + else + xover_band = sbr->kx; - for (k = 0; k < xover_band; k++) - { - QMF_RE(X[l][k]) = QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); + for (k = 0; k < xover_band; k++) + { + QMF_RE(X[l][k]) = QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); #ifndef SBR_LOW_POWER - QMF_IM(X[l][k]) = QMF_IM(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); + QMF_IM(X[l][k]) = QMF_IM(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); #endif - } - for (k = xover_band; k < 64; k++) - { - QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); + } + for (k = xover_band; k < 64; k++) + { + QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); #ifndef SBR_LOW_POWER - QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); + QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); #endif - } + } #ifdef SBR_LOW_POWER - QMF_RE(X[l][xover_band - 1]) += QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][xover_band - 1]); + QMF_RE(X[l][xover_band - 1]) += QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][xover_band - 1]); #endif - } } + } - /* subband synthesis */ + /* subband synthesis */ #ifndef USE_SSE - sbr_qmf_synthesis_64(sbr, sbr->qmfs[ch], X, ch_buf); + sbr_qmf_synthesis_64(sbr, sbr->qmfs[ch], X, channel_buf); #else - sbr->qmfs[ch]->qmf_func(sbr, sbr->qmfs[ch], X, ch_buf); + sbr->qmfs[ch]->qmf_func(sbr, sbr->qmfs[ch], X, channel_buf); #endif - for (i = 0; i < sbr->tHFGen; i++) - { - memmove(sbr->Xcodec[ch][i], sbr->Xcodec[ch][i+sbr->numTimeSlotsRate], 32 * sizeof(qmf_t)); - memmove(sbr->Xsbr[ch][i], sbr->Xsbr[ch][i+sbr->numTimeSlotsRate], 64 * sizeof(qmf_t)); - } + for (i = 0; i < sbr->tHFGen; i++) + { + memmove(sbr->Xcodec[ch][i], sbr->Xcodec[ch][i+sbr->numTimeSlotsRate], 32 * sizeof(qmf_t)); + memmove(sbr->Xsbr[ch][i], sbr->Xsbr[ch][i+sbr->numTimeSlotsRate], 64 * sizeof(qmf_t)); + } +} + +uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, + const uint8_t just_seeked, const uint8_t upsample_only) +{ + uint8_t dont_process = 0; + uint8_t ret = 0; + + if (sbr == NULL) + return 20; + + /* case can occur due to bit errors */ + if (sbr->id_aac != ID_CPE) + return 21; + + if (sbr->ret || (sbr->header_count == 0)) + { + /* don't process just upsample */ + dont_process = 1; + + /* Re-activate reset for next frame */ + if (sbr->ret && sbr->Reset) + sbr->bs_start_freq_prev = -1; } + if (just_seeked) + { + sbr->just_seeked = 1; + } else { + sbr->just_seeked = 0; + } + + sbr_process_channel(sbr, left_chan, 0, dont_process); + sbr_process_channel(sbr, right_chan, 1, dont_process); + if (sbr->bs_header_flag) sbr->just_seeked = 0; - if (sbr->header_count != 0) + if (sbr->header_count != 0 && sbr->ret == 0) { - for (ch = 0; ch < channels; ch++) - sbr_save_prev_data(sbr, ch); + ret = sbr_save_prev_data(sbr, 0); + if (ret) return ret; + ret = sbr_save_prev_data(sbr, 1); + if (ret) return ret; } sbr->frame++; + + return 0; +} + +uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel, + const uint8_t just_seeked, const uint8_t upsample_only) +{ + uint8_t dont_process = 0; + uint8_t ret = 0; + + if (sbr == NULL) + return 20; + + /* case can occur due to bit errors */ + if (sbr->id_aac != ID_SCE && sbr->id_aac != ID_LFE) + return 21; + + if (sbr->ret || (sbr->header_count == 0)) + { + /* don't process just upsample */ + dont_process = 1; + + /* Re-activate reset for next frame */ + if (sbr->ret && sbr->Reset) + sbr->bs_start_freq_prev = -1; + } + + if (just_seeked) + { + sbr->just_seeked = 1; + } else { + sbr->just_seeked = 0; + } + + sbr_process_channel(sbr, channel, 0, dont_process); + + if (sbr->bs_header_flag) + sbr->just_seeked = 0; + + if (sbr->header_count != 0 && sbr->ret == 0) + { + ret = sbr_save_prev_data(sbr, 0); + if (ret) return ret; + } + + sbr->frame++; + + return 0; } #endif diff --git a/src/libfaad/sbr_dec.h b/src/libfaad/sbr_dec.h index 38734afc3..bf8d82cef 100644 --- a/src/libfaad/sbr_dec.h +++ b/src/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.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_dec.h,v 1.5 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __SBR_DEC_H__ @@ -32,6 +32,12 @@ extern "C" { #endif +#ifdef PS_DEC +#include "ps_dec.h" +#endif +#ifdef DRM_PS +#include "drm_dec.h" +#endif /* MAX_NTSRHFG: maximum of number_time_slots * rate + HFGen. 16*2+8 */ #define MAX_NTSRHFG 40 @@ -58,6 +64,7 @@ typedef struct uint8_t rate; uint8_t just_seeked; + uint8_t ret; uint8_t amp_res[2]; @@ -140,9 +147,6 @@ typedef struct uint32_t frame; uint32_t header_count; - uint8_t *data; - uint16_t data_size; - uint8_t id_aac; qmfa_info *qmfa[2]; qmfs_info *qmfs[2]; @@ -153,8 +157,8 @@ typedef struct #ifdef DRM int8_t lcstereo_flag; uint8_t bs_dataextra; - uint16_t data_size_bits; uint8_t Is_DRM_SBR; + drm_ps_info drm_ps; #endif uint8_t numTimeSlotsRate; @@ -162,6 +166,10 @@ typedef struct uint8_t tHFGen; uint8_t tHFAdj; +#ifdef PS_DEC + ps_info ps; +#endif + /* to get it compiling */ /* we'll see during the coding of all the tools, whether these are all used or not. @@ -201,16 +209,18 @@ typedef struct uint8_t bs_df_noise[2][3]; } sbr_info; -sbr_info *sbrDecodeInit(uint16_t framelength +sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, + uint32_t sample_rate #ifdef DRM , uint8_t IsDRM #endif ); void sbrDecodeEnd(sbr_info *sbr); -void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, - real_t *right_channel, - const uint8_t just_seeked, const uint8_t upsample_only); +uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, + const uint8_t just_seeked, const uint8_t upsample_only); +uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel, + const uint8_t just_seeked, const uint8_t upsample_only); #ifdef __cplusplus diff --git a/src/libfaad/sbr_e_nf.c b/src/libfaad/sbr_e_nf.c index ac25abc55..2ba64219f 100644 --- a/src/libfaad/sbr_e_nf.c +++ b/src/libfaad/sbr_e_nf.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_e_nf.c,v 1.2 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_e_nf.c,v 1.3 2004/01/26 22:34:11 jstembridge Exp $ **/ #include "common.h" diff --git a/src/libfaad/sbr_e_nf.h b/src/libfaad/sbr_e_nf.h index b6b411a23..89ecc47dc 100644 --- a/src/libfaad/sbr_e_nf.h +++ b/src/libfaad/sbr_e_nf.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_e_nf.h,v 1.2 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_e_nf.h,v 1.3 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __SBR_E_NF_H__ diff --git a/src/libfaad/sbr_fbt.c b/src/libfaad/sbr_fbt.c index b18536b69..ae241a01e 100644 --- a/src/libfaad/sbr_fbt.c +++ b/src/libfaad/sbr_fbt.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_fbt.c,v 1.2 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_fbt.c,v 1.3 2004/01/26 22:34:11 jstembridge Exp $ **/ /* Calculate frequency band tables */ @@ -184,8 +184,8 @@ uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate, version for bs_freq_scale = 0 */ -void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, - uint8_t bs_alter_scale) +uint8_t master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, + uint8_t bs_alter_scale) { int8_t incr; uint8_t k; @@ -197,7 +197,7 @@ void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, if (k2 <= k0) { sbr->N_master = 0; - return; + return 0; } dk = bs_alter_scale ? 2 : 1; @@ -213,6 +213,8 @@ void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, } #endif nrBands = min(nrBands, 63); + if (nrBands <= 0) + return 1; k2Achieved = k0 + nrBands * dk; k2Diff = k2 - k2Achieved; @@ -247,6 +249,8 @@ void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, } printf("\n"); #endif + + return 0; } /* @@ -255,22 +259,93 @@ void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, */ static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1) { +#ifdef FIXED_POINT + /* table with log2() values */ + static const real_t log2Table[65] = { + COEF_CONST(0.0), COEF_CONST(0.0), COEF_CONST(1.0000000000), COEF_CONST(1.5849625007), + COEF_CONST(2.0000000000), COEF_CONST(2.3219280949), COEF_CONST(2.5849625007), COEF_CONST(2.8073549221), + COEF_CONST(3.0000000000), COEF_CONST(3.1699250014), COEF_CONST(3.3219280949), COEF_CONST(3.4594316186), + COEF_CONST(3.5849625007), COEF_CONST(3.7004397181), COEF_CONST(3.8073549221), COEF_CONST(3.9068905956), + COEF_CONST(4.0000000000), COEF_CONST(4.0874628413), COEF_CONST(4.1699250014), COEF_CONST(4.2479275134), + COEF_CONST(4.3219280949), COEF_CONST(4.3923174228), COEF_CONST(4.4594316186), COEF_CONST(4.5235619561), + COEF_CONST(4.5849625007), COEF_CONST(4.6438561898), COEF_CONST(4.7004397181), COEF_CONST(4.7548875022), + COEF_CONST(4.8073549221), COEF_CONST(4.8579809951), COEF_CONST(4.9068905956), COEF_CONST(4.9541963104), + COEF_CONST(5.0000000000), COEF_CONST(5.0443941194), COEF_CONST(5.0874628413), COEF_CONST(5.1292830169), + COEF_CONST(5.1699250014), COEF_CONST(5.2094533656), COEF_CONST(5.2479275134), COEF_CONST(5.2854022189), + COEF_CONST(5.3219280949), COEF_CONST(5.3575520046), COEF_CONST(5.3923174228), COEF_CONST(5.4262647547), + COEF_CONST(5.4594316186), COEF_CONST(5.4918530963), COEF_CONST(5.5235619561), COEF_CONST(5.5545888517), + COEF_CONST(5.5849625007), COEF_CONST(5.6147098441), COEF_CONST(5.6438561898), COEF_CONST(5.6724253420), + COEF_CONST(5.7004397181), COEF_CONST(5.7279204546), COEF_CONST(5.7548875022), COEF_CONST(5.7813597135), + COEF_CONST(5.8073549221), COEF_CONST(5.8328900142), COEF_CONST(5.8579809951), COEF_CONST(5.8826430494), + COEF_CONST(5.9068905956), COEF_CONST(5.9307373376), COEF_CONST(5.9541963104), COEF_CONST(5.9772799235), + COEF_CONST(6.0) + }; + real_t r0 = log2Table[a0]; /* coef */ + real_t r1 = log2Table[a1]; /* coef */ + real_t r2 = (r1 - r0); /* coef */ + + if (warp) + r2 = MUL_C(r2, COEF_CONST(1.0/1.3)); + + /* convert r2 to real and then multiply and round */ + r2 = (r2 >> (COEF_BITS-REAL_BITS)) * bands + (1<<(REAL_BITS-1)); + + return (r2 >> REAL_BITS); +#else real_t div = (real_t)log(2.0); if (warp) div *= (real_t)1.3; return (int32_t)(bands * log((float)a1/(float)a0)/div + 0.5); +#endif } static real_t find_initial_power(uint8_t bands, uint8_t a0, uint8_t a1) { +#ifdef FIXED_POINT + /* table with log() values */ + static const real_t logTable[65] = { + COEF_CONST(0.0), COEF_CONST(0.0), COEF_CONST(0.6931471806), COEF_CONST(1.0986122887), + COEF_CONST(1.3862943611), COEF_CONST(1.6094379124), COEF_CONST(1.7917594692), COEF_CONST(1.9459101491), + COEF_CONST(2.0794415417), COEF_CONST(2.1972245773), COEF_CONST(2.3025850930), COEF_CONST(2.3978952728), + COEF_CONST(2.4849066498), COEF_CONST(2.5649493575), COEF_CONST(2.6390573296), COEF_CONST(2.7080502011), + COEF_CONST(2.7725887222), COEF_CONST(2.8332133441), COEF_CONST(2.8903717579), COEF_CONST(2.9444389792), + COEF_CONST(2.9957322736), COEF_CONST(3.0445224377), COEF_CONST(3.0910424534), COEF_CONST(3.1354942159), + COEF_CONST(3.1780538303), COEF_CONST(3.2188758249), COEF_CONST(3.2580965380), COEF_CONST(3.2958368660), + COEF_CONST(3.3322045102), COEF_CONST(3.3672958300), COEF_CONST(3.4011973817), COEF_CONST(3.4339872045), + COEF_CONST(3.4657359028), COEF_CONST(3.4965075615), COEF_CONST(3.5263605246), COEF_CONST(3.5553480615), + COEF_CONST(3.5835189385), COEF_CONST(3.6109179126), COEF_CONST(3.6375861597), COEF_CONST(3.6635616461), + COEF_CONST(3.6888794541), COEF_CONST(3.7135720667), COEF_CONST(3.7376696183), COEF_CONST(3.7612001157), + COEF_CONST(3.7841896339), COEF_CONST(3.8066624898), COEF_CONST(3.8286413965), COEF_CONST(3.8501476017), + COEF_CONST(3.8712010109), COEF_CONST(3.8918202981), COEF_CONST(3.9120230054), COEF_CONST(3.9318256327), + COEF_CONST(3.9512437186), COEF_CONST(3.9702919136), COEF_CONST(3.9889840466), COEF_CONST(4.0073331852), + COEF_CONST(4.0253516907), COEF_CONST(4.0430512678), COEF_CONST(4.0604430105), COEF_CONST(4.0775374439), + COEF_CONST(4.0943445622), COEF_CONST(4.1108738642), COEF_CONST(4.1271343850), COEF_CONST(4.1431347264), + COEF_CONST(4.158883083) + }; + /* standard Taylor polynomial coefficients for exp(x) around 0 */ + /* a polynomial around x=1 is more precise, as most values are around 1.07, + but this is just fine already */ + static const real_t c1 = COEF_CONST(1.0); + static const real_t c2 = COEF_CONST(1.0/2.0); + static const real_t c3 = COEF_CONST(1.0/6.0); + static const real_t c4 = COEF_CONST(1.0/24.0); + + real_t r0 = logTable[a0]; /* coef */ + real_t r1 = logTable[a1]; /* coef */ + real_t r2 = (r1 - r0) / bands; /* coef */ + real_t rexp = c1 + MUL_C((c1 + MUL_C((c2 + MUL_C((c3 + MUL_C(c4,r2)), r2)), r2)), r2); + + return (rexp >> (COEF_BITS-REAL_BITS)); /* real */ +#else return (real_t)pow((real_t)a1/(real_t)a0, 1.0/(real_t)bands); +#endif } /* version for bs_freq_scale > 0 */ -void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, - uint8_t bs_freq_scale, uint8_t bs_alter_scale) +uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, + uint8_t bs_freq_scale, uint8_t bs_alter_scale) { uint8_t k, bands, twoRegions; uint8_t k1; @@ -285,12 +360,16 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, if (k2 <= k0) { sbr->N_master = 0; - return; + return 0; } bands = temp1[bs_freq_scale-1]; +#ifdef FIXED_POINT + if (REAL_CONST(k2) > MUL_R(REAL_CONST(k0),REAL_CONST(2.2449))) +#else if ((float)k2/(float)k0 > 2.2449) +#endif { twoRegions = 1; k1 = k0 << 1; @@ -301,15 +380,26 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, nrBand0 = 2 * find_bands(0, bands, k0, k1); nrBand0 = min(nrBand0, 63); + if (nrBand0 <= 0) + return 1; q = find_initial_power(nrBand0, k0, k1); qk = REAL_CONST(k0); +#ifdef FIXED_POINT + A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); +#else A_1 = (int32_t)(qk + .5); +#endif for (k = 0; k <= nrBand0; k++) { int32_t A_0 = A_1; +#ifdef FIXED_POINT + qk = MUL_R(qk,q); + A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); +#else qk *= q; A_1 = (int32_t)(qk + 0.5); +#endif vDk0[k] = A_1 - A_0; } @@ -320,6 +410,8 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, for (k = 1; k <= nrBand0; k++) { vk0[k] = vk0[k-1] + vDk0[k-1]; + if (vDk0[k-1] == 0) + return 1; } if (!twoRegions) @@ -329,7 +421,7 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, sbr->N_master = nrBand0; sbr->N_master = min(sbr->N_master, 64); - return; + return 0; } nrBand1 = 2 * find_bands(1 /* warped */, bands, k1, k2); @@ -337,12 +429,21 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, q = find_initial_power(nrBand1, k1, k2); qk = REAL_CONST(k1); +#ifdef FIXED_POINT + A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); +#else A_1 = (int32_t)(qk + .5); +#endif for (k = 0; k <= nrBand1 - 1; k++) { int32_t A_0 = A_1; +#ifdef FIXED_POINT + qk = MUL_R(qk,q); + A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); +#else qk *= q; A_1 = (int32_t)(qk + 0.5); +#endif vDk1[k] = A_1 - A_0; } @@ -363,6 +464,8 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, for (k = 1; k <= nrBand1; k++) { vk1[k] = vk1[k-1] + vDk1[k-1]; + if (vDk1[k-1] == 0) + return 1; } sbr->N_master = nrBand0 + nrBand1; @@ -384,6 +487,8 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, } printf("\n"); #endif + + return 0; } /* calculate the derived frequency border tables from f_master */ @@ -410,6 +515,10 @@ uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band, sbr->M = sbr->f_table_res[HI_RES][sbr->N_high] - sbr->f_table_res[HI_RES][0]; sbr->kx = sbr->f_table_res[HI_RES][0]; + if (sbr->kx > 32) + return 1; + if (sbr->kx + sbr->M > 64) + return 1; minus = (sbr->N_high & 1) ? 1 : 0; @@ -556,7 +665,11 @@ restart: #if 0 nOctaves = REAL_CONST(log((float)limTable[k]/(float)limTable[k-1])/log(2.0)); #endif +#ifdef FIXED_POINT + nOctaves = SBR_DIV(REAL_CONST(limTable[k]),REAL_CONST(limTable[k-1])); +#else nOctaves = (real_t)limTable[k]/(real_t)limTable[k-1]; +#endif else nOctaves = 0; diff --git a/src/libfaad/sbr_fbt.h b/src/libfaad/sbr_fbt.h index 3da8593f8..a5b29a27b 100644 --- a/src/libfaad/sbr_fbt.h +++ b/src/libfaad/sbr_fbt.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_fbt.h,v 1.2 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_fbt.h,v 1.3 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __SBR_FBT_H__ @@ -36,10 +36,10 @@ uint8_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode, uint32_t sample_rate); uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate, uint8_t k0); -void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, - uint8_t bs_alter_scale); -void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, - uint8_t bs_freq_scale, uint8_t bs_alter_scale); +uint8_t master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, + uint8_t bs_alter_scale); +uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, + uint8_t bs_freq_scale, uint8_t bs_alter_scale); uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band, uint8_t k2); void limiter_frequency_table(sbr_info *sbr); diff --git a/src/libfaad/sbr_hfadj.c b/src/libfaad/sbr_hfadj.c index 5e0faab93..dad4cc675 100644 --- a/src/libfaad/sbr_hfadj.c +++ b/src/libfaad/sbr_hfadj.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_hfadj.c,v 1.2 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_hfadj.c,v 1.3 2004/01/26 22:34:11 jstembridge Exp $ **/ /* High Frequency adjustment */ diff --git a/src/libfaad/sbr_hfadj.h b/src/libfaad/sbr_hfadj.h index 90a6f58bf..3df909159 100644 --- a/src/libfaad/sbr_hfadj.h +++ b/src/libfaad/sbr_hfadj.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_hfadj.h,v 1.2 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_hfadj.h,v 1.3 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __SBR_HFADJ_H__ diff --git a/src/libfaad/sbr_hfgen.c b/src/libfaad/sbr_hfgen.c index 588d693df..01785bdd2 100644 --- a/src/libfaad/sbr_hfgen.c +++ b/src/libfaad/sbr_hfgen.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_hfgen.c,v 1.2 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_hfgen.c,v 1.3 2004/01/26 22:34:11 jstembridge Exp $ **/ /* High Frequency generation */ diff --git a/src/libfaad/sbr_hfgen.h b/src/libfaad/sbr_hfgen.h index d5ace4ccc..d8909abc0 100644 --- a/src/libfaad/sbr_hfgen.h +++ b/src/libfaad/sbr_hfgen.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_hfgen.h,v 1.2 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_hfgen.h,v 1.3 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __SBR_HFGEN_H__ diff --git a/src/libfaad/sbr_huff.c b/src/libfaad/sbr_huff.c index 3fd043f3b..954eb2ea7 100644 --- a/src/libfaad/sbr_huff.c +++ b/src/libfaad/sbr_huff.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_huff.c,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_huff.c,v 1.5 2004/01/26 22:34:11 jstembridge Exp $ **/ #include "common.h" diff --git a/src/libfaad/sbr_huff.h b/src/libfaad/sbr_huff.h index 2830c311f..38a1170b2 100644 --- a/src/libfaad/sbr_huff.h +++ b/src/libfaad/sbr_huff.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_huff.h,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_huff.h,v 1.5 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __SBR_HUFF_H__ diff --git a/src/libfaad/sbr_noise.h b/src/libfaad/sbr_noise.h index f49df7481..7e39fd8bb 100644 --- a/src/libfaad/sbr_noise.h +++ b/src/libfaad/sbr_noise.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_noise.h,v 1.2 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_noise.h,v 1.3 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __SBR_NOISE_H__ diff --git a/src/libfaad/sbr_qmf.c b/src/libfaad/sbr_qmf.c index bc4b6c18a..93a39ed81 100644 --- a/src/libfaad/sbr_qmf.c +++ b/src/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.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_qmf.c,v 1.5 2004/01/26 22:34:11 jstembridge Exp $ **/ #include "common.h" diff --git a/src/libfaad/sbr_qmf.h b/src/libfaad/sbr_qmf.h index 7e7266c45..9cd0045e2 100644 --- a/src/libfaad/sbr_qmf.h +++ b/src/libfaad/sbr_qmf.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_qmf.h,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_qmf.h,v 1.5 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __SBR_QMF_H__ diff --git a/src/libfaad/sbr_qmf_c.h b/src/libfaad/sbr_qmf_c.h index 4b6c09b8d..df94edbdf 100644 --- a/src/libfaad/sbr_qmf_c.h +++ b/src/libfaad/sbr_qmf_c.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_qmf_c.h,v 1.2 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_qmf_c.h,v 1.3 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __SBR_QMF_C_H__ diff --git a/src/libfaad/sbr_syntax.c b/src/libfaad/sbr_syntax.c index e8cdceff5..473c90fac 100644 --- a/src/libfaad/sbr_syntax.c +++ b/src/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.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_syntax.c,v 1.5 2004/01/26 22:34:11 jstembridge Exp $ **/ #include "common.h" @@ -37,11 +37,19 @@ #include "sbr_tf_grid.h" #include "sbr_e_nf.h" #include "bits.h" +#ifdef PS_DEC +#include "ps_dec.h" +#endif +#ifdef DRM_PS +#include "drm_dec.h" +#endif #include "analysis.h" /* static function declarations */ static void sbr_header(bitfile *ld, sbr_info *sbr); static uint8_t sbr_data(bitfile *ld, sbr_info *sbr); +static uint16_t sbr_extension(bitfile *ld, sbr_info *sbr, + uint8_t bs_extension_id, uint16_t num_bits_left); static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr); static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr); static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch); @@ -98,9 +106,11 @@ static void sbr_reset(sbr_info *sbr) } /* table 2 */ -uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr) +uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt) { - uint8_t result; + uint8_t result = 0; + uint16_t num_align_bits = 0; + uint16_t num_sbr_bits = (uint16_t)faad_get_processed_bits(ld); #ifdef DRM if (!sbr->Is_DRM_SBR) @@ -122,52 +132,73 @@ uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr) if (sbr->bs_header_flag) sbr_header(ld, sbr); - /* TODO: Reset? */ + /* Reset? */ sbr_reset(sbr); /* first frame should have a header */ - if (sbr->frame == 0 && sbr->bs_header_flag == 0) - return 1; + //if (!(sbr->frame == 0 && sbr->bs_header_flag == 0)) + if (sbr->header_count != 0) + { + if (sbr->Reset || (sbr->bs_header_flag && sbr->just_seeked)) + { + uint8_t k2; + /* calculate the Master Frequency Table */ + sbr->k0 = qmf_start_channel(sbr->bs_start_freq, sbr->bs_samplerate_mode, + sbr->sample_rate); + k2 = qmf_stop_channel(sbr->bs_stop_freq, sbr->sample_rate, sbr->k0); - if (sbr->Reset || (sbr->bs_header_flag && sbr->just_seeked)) - { - uint8_t k2; + /* check k0 and k2 */ + if (sbr->sample_rate >= 48000) + { + if ((k2 - sbr->k0) > 32) + result += 1; + } else if (sbr->sample_rate <= 32000) { + if ((k2 - sbr->k0) > 48) + result += 1; + } else { /* (sbr->sample_rate == 44100) */ + if ((k2 - sbr->k0) > 45) + result += 1; + } - /* calculate the Master Frequency Table */ - sbr->k0 = qmf_start_channel(sbr->bs_start_freq, sbr->bs_samplerate_mode, - sbr->sample_rate); - k2 = qmf_stop_channel(sbr->bs_stop_freq, sbr->sample_rate, sbr->k0); + if (sbr->bs_freq_scale == 0) + { + result += master_frequency_table_fs0(sbr, sbr->k0, k2, + sbr->bs_alter_scale); + } else { + result += master_frequency_table(sbr, sbr->k0, k2, sbr->bs_freq_scale, + sbr->bs_alter_scale); + } + result += derived_frequency_table(sbr, sbr->bs_xover_band, k2); - /* check k0 and k2 */ - if (sbr->sample_rate >= 48000) - { - if ((k2 - sbr->k0) > 32) - return 1; - } else if (sbr->sample_rate <= 32000) { - if ((k2 - sbr->k0) > 48) - return 1; - } else { /* (sbr->sample_rate == 44100) */ - if ((k2 - sbr->k0) > 45) - return 1; + result = (result > 0) ? 1 : 0; } - if (sbr->bs_freq_scale == 0) + if (result == 0) + result = sbr_data(ld, sbr); + } else { + result = 1; + } + +#ifdef DRM + if (!sbr->Is_DRM_SBR) +#endif + { + num_sbr_bits = (uint16_t)faad_get_processed_bits(ld) - num_sbr_bits; + /* -4 does not apply, bs_extension_type is re-read in this function */ + num_align_bits = 8*cnt /*- 4*/ - num_sbr_bits; + + while (num_align_bits > 7) { - master_frequency_table_fs0(sbr, sbr->k0, k2, sbr->bs_alter_scale); - } else { - master_frequency_table(sbr, sbr->k0, k2, sbr->bs_freq_scale, - sbr->bs_alter_scale); + faad_getbits(ld, 8 + DEBUGVAR(1,999,"sbr_bitstream(): num_align_bits")); + num_align_bits -= 8; } - if ((result = derived_frequency_table(sbr, sbr->bs_xover_band, k2)) > 0) - return result; + faad_getbits(ld, num_align_bits + DEBUGVAR(1,999,"sbr_bitstream(): num_align_bits")); } - if ((result = sbr_data(ld, sbr)) > 0) - return result; - - /* no error */ - return 0; + return result; } /* table 3 */ @@ -330,19 +361,15 @@ static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr) sbr->bs_extension_id = (uint8_t)faad_getbits(ld, 2 DEBUGVAR(1,227,"sbr_single_channel_element(): bs_extension_id")); nr_bits_left -= 2; - /* sbr_extension(ld, sbr, 0, nr_bits_left); */ -#ifdef DRM - if (!sbr->Is_DRM_SBR) -#endif - { - sbr->bs_extension_data = (uint8_t)faad_getbits(ld, 6 - DEBUGVAR(1,279,"sbr_single_channel_element(): bs_extension_data")); - } + nr_bits_left -= sbr_extension(ld, sbr, sbr->bs_extension_id, nr_bits_left); } /* Corrigendum */ - faad_getbits(ld, nr_bits_left - DEBUGVAR(1,280,"sbr_single_channel_element(): nr_bits_left")); + if (nr_bits_left > 0) + { + faad_getbits(ld, nr_bits_left + DEBUGVAR(1,280,"sbr_single_channel_element(): nr_bits_left")); + } } return 0; @@ -461,19 +488,15 @@ static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr) sbr->bs_extension_id = (uint8_t)faad_getbits(ld, 2 DEBUGVAR(1,236,"sbr_channel_pair_element(): bs_extension_id")); nr_bits_left -= 2; - /* sbr_extension(ld, sbr, 0, nr_bits_left); */ -#ifdef DRM - if (!sbr->Is_DRM_SBR) -#endif - { - sbr->bs_extension_data = (uint8_t)faad_getbits(ld, 6 - DEBUGVAR(1,280,"sbr_channel_pair_element(): bs_extension_data")); - } + sbr_extension(ld, sbr, sbr->bs_extension_id, nr_bits_left); } /* Corrigendum */ - faad_getbits(ld, nr_bits_left - DEBUGVAR(1,280,"sbr_channel_pair_element(): nr_bits_left")); + if (nr_bits_left > 0) + { + faad_getbits(ld, nr_bits_left + DEBUGVAR(1,280,"sbr_channel_pair_element(): nr_bits_left")); + } } return 0; @@ -617,6 +640,9 @@ static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch) else sbr->L_E[ch] = min(bs_num_env, 4); + if (sbr->L_E[ch] <= 0) + return 1; + if (sbr->L_E[ch] > 1) sbr->L_Q[ch] = 2; else @@ -660,6 +686,26 @@ static void invf_mode(bitfile *ld, sbr_info *sbr, uint8_t ch) } } +static uint16_t sbr_extension(bitfile *ld, sbr_info *sbr, + uint8_t bs_extension_id, uint16_t num_bits_left) +{ + switch (bs_extension_id) + { +#ifdef PS_DEC + case EXTENSION_ID_PS: + return ps_data(&(sbr->ps), ld); +#endif +#ifdef DRM_PS + case DRM_PARAMETRIC_STEREO: + return drm_ps_data(&(sbr->drm_ps), ld); +#endif + default: + sbr->bs_extension_data = (uint8_t)faad_getbits(ld, 6 + DEBUGVAR(1,279,"sbr_single_channel_element(): bs_extension_data")); + return 6; + } +} + /* table 12 */ static void sinusoidal_coding(bitfile *ld, sbr_info *sbr, uint8_t ch) { diff --git a/src/libfaad/sbr_syntax.h b/src/libfaad/sbr_syntax.h index d3509edbb..0d91cee91 100644 --- a/src/libfaad/sbr_syntax.h +++ b/src/libfaad/sbr_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: sbr_syntax.h,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_syntax.h,v 1.5 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __SBR_SYNTAX_H__ @@ -55,7 +55,7 @@ extern "C" { #define NOISE_FLOOR_OFFSET 6 -uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr); +uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt); #ifdef __cplusplus } diff --git a/src/libfaad/sbr_tf_grid.c b/src/libfaad/sbr_tf_grid.c index 3c0de19fc..68ec86d63 100644 --- a/src/libfaad/sbr_tf_grid.c +++ b/src/libfaad/sbr_tf_grid.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_tf_grid.c,v 1.2 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_tf_grid.c,v 1.3 2004/01/26 22:34:11 jstembridge Exp $ **/ /* Time/Frequency grid */ diff --git a/src/libfaad/sbr_tf_grid.h b/src/libfaad/sbr_tf_grid.h index 771b2116a..58b03bc1e 100644 --- a/src/libfaad/sbr_tf_grid.h +++ b/src/libfaad/sbr_tf_grid.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_tf_grid.h,v 1.2 2004/01/11 15:44:05 mroi Exp $ +** $Id: sbr_tf_grid.h,v 1.3 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __SBR_TF_GRID_H__ diff --git a/src/libfaad/sine_win.h b/src/libfaad/sine_win.h index 993bab2cd..341427d53 100644 --- a/src/libfaad/sine_win.h +++ b/src/libfaad/sine_win.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: sine_win.h,v 1.3 2004/01/11 15:44:05 mroi Exp $ +** $Id: sine_win.h,v 1.4 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __SINE_WIN_H__ diff --git a/src/libfaad/specrec.c b/src/libfaad/specrec.c index 588d79656..729a80193 100644 --- a/src/libfaad/specrec.c +++ b/src/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.5 2004/01/11 15:44:05 mroi Exp $ +** $Id: specrec.c,v 1.6 2004/01/26 22:34:11 jstembridge Exp $ **/ /* @@ -44,6 +44,7 @@ #include "is.h" #include "pns.h" #include "tns.h" +#include "drc.h" #include "lt_predict.h" #include "ic_predict.h" #ifdef SSR_DEC @@ -587,8 +588,17 @@ void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, { top = ics->sect_sfb_offset[g][sfb+1]; - exp = (ics->scale_factors[g][sfb] /* - 100 */) >> 2; - frac = (ics->scale_factors[g][sfb] /* - 100 */) & 3; + /* this could be scalefactor for IS or PNS, those can be negative or bigger then 255 */ + /* just ignore them */ + if (ics->scale_factors[g][sfb] < 0 || ics->scale_factors[g][sfb] > 255) + { + exp = 0; + frac = 0; + } else { + /* ics->scale_factors[g][sfb] must be between 0 and 255 */ + exp = (ics->scale_factors[g][sfb] /* - 100 */) >> 2; + frac = (ics->scale_factors[g][sfb] /* - 100 */) & 3; + } #ifdef FIXED_POINT exp -= 25; @@ -681,7 +691,7 @@ void apply_scalefactors_sse(faacDecHandle hDecoder, ic_stream *ics, uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, element *sce, int16_t *spec_data) { - uint8_t retval; + uint8_t retval, mul; ALIGN real_t spec_coef[1024]; #ifdef PROFILE @@ -776,10 +786,27 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, drc_decode(hDecoder->drc, spec_coef); } + if (hDecoder->time_out[sce->channel] == NULL) { - hDecoder->time_out[sce->channel] = (real_t*)faad_malloc(hDecoder->frameLength*2*sizeof(real_t)); - memset(hDecoder->time_out[sce->channel], 0, hDecoder->frameLength*2*sizeof(real_t)); + mul = 1; +#ifdef SBR_DEC + hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0; + if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) + { + /* SBR requires 2 times as much output data */ + mul = 2; + hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1; + } +#endif + hDecoder->time_out[sce->channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); + memset(hDecoder->time_out[sce->channel], 0, mul*hDecoder->frameLength*sizeof(real_t)); + } + + if (hDecoder->fb_intermed[sce->channel] == NULL) + { + hDecoder->fb_intermed[sce->channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t)); + memset(hDecoder->fb_intermed[sce->channel], 0, hDecoder->frameLength*sizeof(real_t)); } /* filter bank */ @@ -794,7 +821,8 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, #else ifilter_bank(hDecoder->fb, ics->window_sequence, ics->window_shape, hDecoder->window_shape_prev[sce->channel], spec_coef, - hDecoder->time_out[sce->channel], hDecoder->object_type, hDecoder->frameLength); + hDecoder->time_out[sce->channel], hDecoder->fb_intermed[sce->channel], + hDecoder->object_type, hDecoder->frameLength); #endif #ifdef SSR_DEC } else { @@ -825,7 +853,36 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, if (is_ltp_ot(hDecoder->object_type)) { lt_update_state(hDecoder->lt_pred_stat[sce->channel], hDecoder->time_out[sce->channel], - hDecoder->time_out[sce->channel]+hDecoder->frameLength, hDecoder->frameLength, hDecoder->object_type); + hDecoder->fb_intermed[sce->channel], hDecoder->frameLength, hDecoder->object_type); + } +#endif + +#ifdef SBR_DEC + if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) + && hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) + { + uint8_t ele = hDecoder->fr_ch_ele; + uint8_t ch = sce->channel; + + /* following case can happen when forceUpSampling == 1 */ + if (hDecoder->sbr[ele] == NULL) + { + hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength, + sce->ele_id, 2*get_sample_rate(hDecoder->sf_index) +#ifdef DRM + , 0 +#endif + ); + } + + retval = sbrDecodeSingleFrame(hDecoder->sbr[ele], hDecoder->time_out[ch], + hDecoder->postSeekResetFlag, hDecoder->forceUpSampling); + if (retval > 0) + return retval; + } else if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) + && !hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) + { + return 23; } #endif @@ -835,7 +892,7 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2, element *cpe, int16_t *spec_data1, int16_t *spec_data2) { - uint8_t retval; + uint8_t retval, mul; ALIGN real_t spec_coef1[1024]; ALIGN real_t spec_coef2[1024]; @@ -923,7 +980,7 @@ uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_str if (is_ltp_ot(hDecoder->object_type)) { ltp_info *ltp1 = &(ics1->ltp); - ltp_info *ltp2 = (cpe->common_window) ? &(ics2->ltp2) : &(ics2->ltp) ; + ltp_info *ltp2 = (cpe->common_window) ? &(ics2->ltp2) : &(ics2->ltp); #ifdef LD_DEC if (hDecoder->object_type == LD) { @@ -981,13 +1038,34 @@ uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_str if (hDecoder->time_out[cpe->channel] == NULL) { - hDecoder->time_out[cpe->channel] = (real_t*)faad_malloc(hDecoder->frameLength*2*sizeof(real_t)); - memset(hDecoder->time_out[cpe->channel], 0, hDecoder->frameLength*2*sizeof(real_t)); + mul = 1; +#ifdef SBR_DEC + hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0; + if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) + { + /* SBR requires 2 times as much output data */ + mul = 2; + hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1; + } +#endif + hDecoder->time_out[cpe->channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); + memset(hDecoder->time_out[cpe->channel], 0, mul*hDecoder->frameLength*sizeof(real_t)); } if (hDecoder->time_out[cpe->paired_channel] == NULL) { - hDecoder->time_out[cpe->paired_channel] = (real_t*)faad_malloc(hDecoder->frameLength*2*sizeof(real_t)); - memset(hDecoder->time_out[cpe->paired_channel], 0, hDecoder->frameLength*2*sizeof(real_t)); + hDecoder->time_out[cpe->paired_channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); + memset(hDecoder->time_out[cpe->paired_channel], 0, mul*hDecoder->frameLength*sizeof(real_t)); + } + + if (hDecoder->fb_intermed[cpe->channel] == NULL) + { + hDecoder->fb_intermed[cpe->channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t)); + memset(hDecoder->fb_intermed[cpe->channel], 0, hDecoder->frameLength*sizeof(real_t)); + } + if (hDecoder->fb_intermed[cpe->paired_channel] == NULL) + { + hDecoder->fb_intermed[cpe->paired_channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t)); + memset(hDecoder->fb_intermed[cpe->paired_channel], 0, hDecoder->frameLength*sizeof(real_t)); } /* filter bank */ @@ -1005,10 +1083,12 @@ uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_str #else ifilter_bank(hDecoder->fb, ics1->window_sequence, ics1->window_shape, hDecoder->window_shape_prev[cpe->channel], spec_coef1, - hDecoder->time_out[cpe->channel], hDecoder->object_type, hDecoder->frameLength); + hDecoder->time_out[cpe->channel], hDecoder->fb_intermed[cpe->channel], + hDecoder->object_type, hDecoder->frameLength); ifilter_bank(hDecoder->fb, ics2->window_sequence, ics2->window_shape, hDecoder->window_shape_prev[cpe->paired_channel], spec_coef2, - hDecoder->time_out[cpe->paired_channel], hDecoder->object_type, hDecoder->frameLength); + hDecoder->time_out[cpe->paired_channel], hDecoder->fb_intermed[cpe->paired_channel], + hDecoder->object_type, hDecoder->frameLength); #endif #ifdef SSR_DEC } else { @@ -1056,10 +1136,40 @@ uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_str if (is_ltp_ot(hDecoder->object_type)) { lt_update_state(hDecoder->lt_pred_stat[cpe->channel], hDecoder->time_out[cpe->channel], - hDecoder->time_out[cpe->channel]+hDecoder->frameLength, hDecoder->frameLength, hDecoder->object_type); + hDecoder->fb_intermed[cpe->channel], hDecoder->frameLength, hDecoder->object_type); lt_update_state(hDecoder->lt_pred_stat[cpe->paired_channel], hDecoder->time_out[cpe->paired_channel], - hDecoder->time_out[cpe->paired_channel]+hDecoder->frameLength, hDecoder->frameLength, - hDecoder->object_type); + hDecoder->fb_intermed[cpe->paired_channel], hDecoder->frameLength, hDecoder->object_type); + } +#endif + +#ifdef SBR_DEC + if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) + && hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) + { + uint8_t ele = hDecoder->fr_ch_ele; + uint8_t ch0 = cpe->channel; + uint8_t ch1 = cpe->paired_channel; + + /* following case can happen when forceUpSampling == 1 */ + if (hDecoder->sbr[ele] == NULL) + { + hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength, + cpe->ele_id, 2*get_sample_rate(hDecoder->sf_index) +#ifdef DRM + , 0 +#endif + ); + } + + retval = sbrDecodeCoupleFrame(hDecoder->sbr[ele], + hDecoder->time_out[ch0], hDecoder->time_out[ch1], + hDecoder->postSeekResetFlag, hDecoder->forceUpSampling); + if (retval > 0) + return retval; + } else if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) + && !hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) + { + return 23; } #endif diff --git a/src/libfaad/specrec.h b/src/libfaad/specrec.h index 06b08f12b..83c2a0ade 100644 --- a/src/libfaad/specrec.h +++ b/src/libfaad/specrec.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: specrec.h,v 1.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: specrec.h,v 1.5 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __SPECREC_H__ diff --git a/src/libfaad/ssr.c b/src/libfaad/ssr.c index dab7504ac..cb6a19b48 100644 --- a/src/libfaad/ssr.c +++ b/src/libfaad/ssr.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: ssr.c,v 1.3 2004/01/11 15:44:05 mroi Exp $ +** $Id: ssr.c,v 1.4 2004/01/26 22:34:11 jstembridge Exp $ **/ #include "common.h" diff --git a/src/libfaad/ssr.h b/src/libfaad/ssr.h index cc635a3a3..1bd5cd7b1 100644 --- a/src/libfaad/ssr.h +++ b/src/libfaad/ssr.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: ssr.h,v 1.3 2004/01/11 15:44:05 mroi Exp $ +** $Id: ssr.h,v 1.4 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __SSR_H__ diff --git a/src/libfaad/ssr_fb.c b/src/libfaad/ssr_fb.c index 27fc655d3..99fea3c95 100644 --- a/src/libfaad/ssr_fb.c +++ b/src/libfaad/ssr_fb.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: ssr_fb.c,v 1.3 2004/01/11 15:44:05 mroi Exp $ +** $Id: ssr_fb.c,v 1.4 2004/01/26 22:34:11 jstembridge Exp $ **/ #include "common.h" diff --git a/src/libfaad/ssr_fb.h b/src/libfaad/ssr_fb.h index 860d1ad4a..e0a49b3ec 100644 --- a/src/libfaad/ssr_fb.h +++ b/src/libfaad/ssr_fb.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: ssr_fb.h,v 1.2 2003/12/30 02:00:11 miguelfreitas Exp $ +** $Id: ssr_fb.h,v 1.3 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __SSR_FB_H__ diff --git a/src/libfaad/ssr_ipqf.c b/src/libfaad/ssr_ipqf.c index c771775e1..20beaa04f 100644 --- a/src/libfaad/ssr_ipqf.c +++ b/src/libfaad/ssr_ipqf.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: ssr_ipqf.c,v 1.3 2004/01/11 15:44:05 mroi Exp $ +** $Id: ssr_ipqf.c,v 1.4 2004/01/26 22:34:11 jstembridge Exp $ **/ #include "common.h" diff --git a/src/libfaad/ssr_ipqf.h b/src/libfaad/ssr_ipqf.h index fae364020..d07664b03 100644 --- a/src/libfaad/ssr_ipqf.h +++ b/src/libfaad/ssr_ipqf.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: ssr_ipqf.h,v 1.2 2003/12/30 02:00:11 miguelfreitas Exp $ +** $Id: ssr_ipqf.h,v 1.3 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __SSR_IPQF_H__ diff --git a/src/libfaad/ssr_win.h b/src/libfaad/ssr_win.h index c7516231b..a68517bc6 100644 --- a/src/libfaad/ssr_win.h +++ b/src/libfaad/ssr_win.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: ssr_win.h,v 1.2 2003/12/30 02:00:11 miguelfreitas Exp $ +** $Id: ssr_win.h,v 1.3 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __SSR_WIN_H__ diff --git a/src/libfaad/structs.h b/src/libfaad/structs.h index e0888f3ac..c69abf9bc 100644 --- a/src/libfaad/structs.h +++ b/src/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.4 2004/01/11 15:44:05 mroi Exp $ +** $Id: structs.h,v 1.5 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __STRUCTS_H__ @@ -385,6 +385,7 @@ typedef struct uint8_t fr_ch_ele; void *sample_buffer; + uint8_t alloced_channels; uint8_t window_shape_prev[MAX_CHANNELS]; #ifdef LTP_DEC @@ -394,16 +395,14 @@ typedef struct drc_info *drc; real_t *time_out[MAX_CHANNELS]; + real_t *fb_intermed[MAX_CHANNELS]; #ifdef SBR_DEC int8_t sbr_present_flag; int8_t forceUpSampling; + uint8_t sbr_alloced[MAX_SYNTAX_ELEMENTS]; - real_t *time_out2[MAX_CHANNELS]; - - uint8_t sbr_used[32]; - - sbr_info *sbr[32]; + sbr_info *sbr[MAX_SYNTAX_ELEMENTS]; #ifdef DRM int8_t lcstereo_flag; #endif diff --git a/src/libfaad/syntax.c b/src/libfaad/syntax.c index e5e85bc80..db79a0c15 100644 --- a/src/libfaad/syntax.c +++ b/src/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.6 2004/01/11 15:44:05 mroi Exp $ +** $Id: syntax.c,v 1.7 2004/01/26 22:34:11 jstembridge Exp $ **/ /* @@ -118,7 +118,8 @@ int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC, mp4ASC->extensionFlag = faad_get1bit(ld DEBUGVAR(1,141,"GASpecificConfig(): ExtensionFlag")); if (mp4ASC->channelsConfiguration == 0) { - program_config_element(&pce, ld); + if (program_config_element(&pce, ld)) + return -3; //mp4ASC->channelsConfiguration = pce.channels; if (pce_out != NULL) @@ -158,7 +159,7 @@ int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC, PCEs transmitted in raw data blocks cannot be used to convey decoder configuration information. */ -uint8_t program_config_element(program_config *pce, bitfile *ld) +static uint8_t program_config_element(program_config *pce, bitfile *ld) { uint8_t i; @@ -303,6 +304,9 @@ uint8_t program_config_element(program_config *pce, bitfile *ld) } pce->comment_field_data[i] = 0; + if (pce->channels > MAX_CHANNELS) + return 22; + return 0; } @@ -324,8 +328,6 @@ void decode_sce_lfe(faacDecHandle hDecoder, return; } - hInfo->error = single_lfe_channel_element(hDecoder, ld, channels, &tag); - if (hDecoder->pce_set) hDecoder->internal_channel[hDecoder->pce.sce_channel[tag]] = channels; else @@ -337,6 +339,8 @@ void decode_sce_lfe(faacDecHandle hDecoder, hDecoder->channel_element[channels] = hDecoder->fr_ch_ele; hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele; + hInfo->error = single_lfe_channel_element(hDecoder, ld, channels, &tag); + hDecoder->fr_channels++; hDecoder->fr_ch_ele++; } @@ -358,8 +362,6 @@ void decode_cpe(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, bitfile *ld, return; } - hInfo->error = channel_pair_element(hDecoder, ld, channels, &tag); - if (hDecoder->pce_set) { hDecoder->internal_channel[hDecoder->pce.cpe_channel[tag]] = channels; @@ -373,6 +375,8 @@ void decode_cpe(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, bitfile *ld, hDecoder->channel_element[channels+1] = hDecoder->fr_ch_ele; hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele; + hInfo->error = channel_pair_element(hDecoder, ld, channels, &tag); + hDecoder->fr_channels += 2; hDecoder->fr_ch_ele++; } @@ -431,26 +435,24 @@ void raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, data_stream_element(hDecoder, ld); break; case ID_PCE: - if ((hInfo->error = program_config_element(pce, ld)) > 0) - return; - hDecoder->pce_set = 1; + /* 14496-4: 5.6.4.1.2.1.3: */ + /* program_configuration_element()'s in access units shall be ignored */ + program_config_element(pce, ld); + //if ((hInfo->error = program_config_element(pce, ld)) > 0) + // return; + //hDecoder->pce_set = 1; break; case ID_FIL: /* one sbr_info describes a channel_element not a channel! */ + /* if we encounter SBR data here: error */ + /* SBR data will be read directly in the SCE/LFE/CPE element */ if ((hInfo->error = fill_element(hDecoder, ld, drc #ifdef SBR_DEC - , (ch_ele-1) + //, (ch_ele == 0) ? INVALID_SBR_ELEMENT : (ch_ele-1) + , INVALID_SBR_ELEMENT #endif )) > 0) return; -#ifdef SBR_DEC - if (hDecoder->sbr_used[ch_ele-1]) - { - hDecoder->sbr_present_flag = 1; - hDecoder->sbr[ch_ele-1]->sample_rate = get_sample_rate(hDecoder->sf_index); - hDecoder->sbr[ch_ele-1]->sample_rate *= 2; - } -#endif break; } } @@ -571,6 +573,21 @@ static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, bitfile *ld, if (retval > 0) return retval; +#ifdef SBR_DEC + /* check if next bitstream element is a fill element */ + /* if so, read it now so SBR decoding can be done in case of a file with SBR */ + if (faad_showbits(ld, LEN_SE_ID) == ID_FIL) + { + faad_flushbits(ld, LEN_SE_ID); + + /* one sbr_info describes a channel_element not a channel! */ + if ((retval = fill_element(hDecoder, ld, hDecoder->drc, hDecoder->fr_ch_ele)) > 0) + { + return retval; + } + } +#endif + /* noiseless coding is done, spectral reconstruction is done now */ retval = reconstruct_single_channel(hDecoder, ics, &sce, spec_data); if (retval > 0) @@ -665,6 +682,21 @@ static uint8_t channel_pair_element(faacDecHandle hDecoder, bitfile *ld, return result; } +#ifdef SBR_DEC + /* check if next bitstream element is a fill element */ + /* if so, read it now so SBR decoding can be done in case of a file with SBR */ + if (faad_showbits(ld, LEN_SE_ID) == ID_FIL) + { + faad_flushbits(ld, LEN_SE_ID); + + /* one sbr_info describes a channel_element not a channel! */ + if ((result = fill_element(hDecoder, ld, hDecoder->drc, hDecoder->fr_ch_ele)) > 0) + { + return result; + } + } +#endif + /* noiseless coding is done, spectral reconstruction is done now */ if ((result = reconstruct_channel_pair(hDecoder, ics1, ics2, &cpe, spec_data1, spec_data2)) > 0) @@ -941,30 +973,29 @@ static uint8_t fill_element(faacDecHandle hDecoder, bitfile *ld, drc_info *drc if (count > 0) { #ifdef SBR_DEC - hDecoder->sbr_used[sbr_ele] = 0; bs_extension_type = (uint8_t)faad_showbits(ld, 4); if ((bs_extension_type == EXT_SBR_DATA) || (bs_extension_type == EXT_SBR_DATA_CRC)) { - hDecoder->sbr_used[sbr_ele] = 1; + if (sbr_ele == INVALID_SBR_ELEMENT) + return 24; if (!hDecoder->sbr[sbr_ele]) { - hDecoder->sbr[sbr_ele] = sbrDecodeInit(hDecoder->frameLength + hDecoder->sbr[sbr_ele] = sbrDecodeInit(hDecoder->frameLength, + hDecoder->element_id[sbr_ele], 2*get_sample_rate(hDecoder->sf_index) #ifdef DRM , 0 #endif ); } - /* read in all the SBR data for processing later on */ - hDecoder->sbr[sbr_ele]->data = (uint8_t*)faad_getbitbuffer(ld, count*8); - hDecoder->sbr[sbr_ele]->data_size = count; - /* save id of previous element, this sbr object belongs to that element */ - hDecoder->sbr[sbr_ele]->id_aac = hDecoder->element_id[sbr_ele]; + hDecoder->sbr_present_flag = 1; + + /* parse the SBR data */ + hDecoder->sbr[sbr_ele]->ret = sbr_extension_data(ld, hDecoder->sbr[sbr_ele], count); } else { - hDecoder->sbr_used[sbr_ele] = 0; #endif while (count > 0) { @@ -1122,6 +1153,69 @@ void aac_scalable_main_element(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, return; } +#ifdef DRM +#ifdef SBR_DEC + /* In case of DRM we need to read the SBR info before channel reconstruction */ + if ((hDecoder->sbr_present_flag == 1) && (hDecoder->object_type == DRM_ER_LC)) + { + bitfile ld_sbr = {0}; + uint32_t i; + uint16_t count = 0; + uint8_t *revbuffer; + uint8_t *prevbufstart; + uint8_t *pbufend; + + /* all forward bitreading should be finished at this point */ + uint32_t bitsconsumed = faad_get_processed_bits(ld); + uint32_t buffer_size = faad_origbitbuffer_size(ld); + uint8_t *buffer = (uint8_t*)faad_origbitbuffer(ld); + + if (bitsconsumed + 8 > buffer_size*8) + { + hInfo->error = 14; + return; + } + + if (!hDecoder->sbr[0]) + { + hDecoder->sbr[0] = sbrDecodeInit(hDecoder->frameLength, cpe.ele_id, + 2*get_sample_rate(hDecoder->sf_index), 1); + } + + /* Reverse bit reading of SBR data in DRM audio frame */ + revbuffer = (uint8_t*)faad_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 */ + /* 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; + + faad_getbits(&ld_sbr, 8); /* Skip 8-bit CRC */ + + hDecoder->sbr[0]->ret = sbr_extension_data(&ld_sbr, hDecoder->sbr[0], count); + + /* check CRC */ + /* no need to check it if there was already an error */ + if (hDecoder->sbr[0]->ret == 0) + hDecoder->sbr[0]->ret = faad_check_CRC(&ld_sbr, faad_get_processed_bits(&ld_sbr) - 8); + + faad_endbits(&ld_sbr); + + if (revbuffer) + faad_free(revbuffer); + } +#endif +#endif + if (this_layer_stereo) { hInfo->error = reconstruct_channel_pair(hDecoder, ics1, ics2, &cpe, spec_data1, spec_data2); @@ -1556,6 +1650,10 @@ static uint8_t decode_scale_factors(ic_stream *ics, bitfile *ld) break; default: /* spectral books */ + /* ics->scale_factors[g][sfb] must be between 0 and 255 */ + + ics->scale_factors[g][sfb] = 0; + /* decode scale factor */ t = huffman_scale_factor(ld); if (t < 0) diff --git a/src/libfaad/syntax.h b/src/libfaad/syntax.h index 20c742f35..3f1eb0042 100644 --- a/src/libfaad/syntax.h +++ b/src/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.7 2004/01/11 15:44:05 mroi Exp $ +** $Id: syntax.h,v 1.8 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __SYNTAX_H__ @@ -33,7 +33,6 @@ extern "C" { #endif #include "decoder.h" -#include "drc.h" #include "bits.h" #define MAIN 1 @@ -104,6 +103,8 @@ extern "C" { #define INTENSITY_HCB2 14 #define INTENSITY_HCB 15 +#define INVALID_SBR_ELEMENT 255 + int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC, program_config *pce); diff --git a/src/libfaad/tns.c b/src/libfaad/tns.c index 65bef7c33..e5414a6af 100644 --- a/src/libfaad/tns.c +++ b/src/libfaad/tns.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: tns.c,v 1.5 2004/01/11 15:44:05 mroi Exp $ +** $Id: tns.c,v 1.6 2004/01/26 22:34:11 jstembridge Exp $ **/ #include "common.h" diff --git a/src/libfaad/tns.h b/src/libfaad/tns.h index ebae23890..fb635a7ba 100644 --- a/src/libfaad/tns.h +++ b/src/libfaad/tns.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: tns.h,v 1.5 2004/01/11 15:44:05 mroi Exp $ +** $Id: tns.h,v 1.6 2004/01/26 22:34:11 jstembridge Exp $ **/ #ifndef __TNS_H__ -- cgit v1.2.3