Mercurial > audlegacy-plugins
diff src/aac/libfaad2/sbr_syntax.c @ 681:1d8b08df98c3 trunk
[svn] - synchronise with FAAD 2.5
author | nenolod |
---|---|
date | Tue, 20 Feb 2007 04:37:37 -0800 |
parents | 3da1b8942b8b |
children | e6c5fdae6e88 |
line wrap: on
line diff
--- a/src/aac/libfaad2/sbr_syntax.c Tue Feb 20 04:36:01 2007 -0800 +++ b/src/aac/libfaad2/sbr_syntax.c Tue Feb 20 04:37:37 2007 -0800 @@ -1,6 +1,6 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2004 M. Bakker, Ahead Software AG, http://www.nero.com +** Copyright (C) 2003-2005 M. Bakker, Nero 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 @@ -14,15 +14,20 @@ ** ** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ** ** Any non-GPL usage of this software or parts of this software is strictly ** forbidden. ** +** Software using this code must display the following message visibly in or +** on each copy of the software: +** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com" +** in, for example, the about-box or help/startup screen. +** ** Commercial non-GPL licensing of this software is possible. -** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. +** For more info contact Nero AG through Mpeg4AAClicense@nero.com. ** -** $Id: sbr_syntax.c,v 1.34 2004/09/04 14:56:28 menno Exp $ +** $Id: sbr_syntax.c,v 1.36 2006/05/07 18:09:02 menno Exp $ **/ #include "common.h" @@ -46,6 +51,7 @@ #include "analysis.h" /* static function declarations */ +/* static function declarations */ static void sbr_header(bitfile *ld, sbr_info *sbr); static uint8_t calc_sbr_tables(sbr_info *sbr, uint8_t start_freq, uint8_t stop_freq, uint8_t samplerate_mode, uint8_t freq_scale, @@ -131,16 +137,23 @@ } /* table 2 */ -uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt) +uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt, + uint8_t psResetFlag) { uint8_t result = 0; uint16_t num_align_bits = 0; - uint16_t num_sbr_bits = (uint16_t)faad_get_processed_bits(ld); + uint16_t num_sbr_bits1 = (uint16_t)faad_get_processed_bits(ld); + uint16_t num_sbr_bits2; uint8_t saved_start_freq, saved_samplerate_mode; uint8_t saved_stop_freq, saved_freq_scale; uint8_t saved_alter_scale, saved_xover_band; +#if (defined(PS_DEC) || defined(DRM_PS)) + if (psResetFlag) + sbr->psResetFlag = psResetFlag; +#endif + #ifdef DRM if (!sbr->Is_DRM_SBR) #endif @@ -206,28 +219,40 @@ { calc_sbr_tables(sbr, saved_start_freq, saved_stop_freq, saved_samplerate_mode, saved_freq_scale, - saved_alter_scale, saved_xover_band); + saved_alter_scale, saved_xover_band); } - /* we should be able to safely set result to 0 now */ - result = 0; + /* we should be able to safely set result to 0 now, */ + /* but practise indicates this doesn't work well */ } } else { result = 1; } + num_sbr_bits2 = (uint16_t)faad_get_processed_bits(ld) - num_sbr_bits1; + + /* check if we read more bits then were available for sbr */ + if (8*cnt < num_sbr_bits2) + { + faad_resetbits(ld, num_sbr_bits1 + 8*cnt); + num_sbr_bits2 = 8*cnt; + +#ifdef PS_DEC + /* turn off PS for the unfortunate case that we randomly read some + * PS data that looks correct */ + sbr->ps_used = 0; +#endif + + /* Make sure it doesn't decode SBR in this frame, or we'll get glitches */ + return 1; + } + #ifdef DRM if (!sbr->Is_DRM_SBR) #endif - { - num_sbr_bits = (uint16_t)faad_get_processed_bits(ld) - num_sbr_bits; - - /* check if we read more bits then were available for sbr */ - if (8*cnt < num_sbr_bits) - return 1; - + { /* -4 does not apply, bs_extension_type is re-read in this function */ - num_align_bits = 8*cnt /*- 4*/ - num_sbr_bits; + num_align_bits = 8*cnt /*- 4*/ - num_sbr_bits2; while (num_align_bits > 7) { @@ -364,11 +389,14 @@ #ifdef DRM /* bs_coupling, from sbr_channel_pair_base_element(bs_amp_res) */ if (sbr->Is_DRM_SBR) + { faad_get1bit(ld); + } #endif if ((result = sbr_grid(ld, sbr, 0)) > 0) return result; + sbr_dtdf(ld, sbr, 0); invf_mode(ld, sbr, 0); sbr_envelope(ld, sbr, 0); @@ -431,7 +459,11 @@ } else { /* to be safe make it 3, will switch to "default" * in sbr_extension() */ +#ifdef DRM + return 1; +#else sbr->bs_extension_id = 3; +#endif } } #endif @@ -829,6 +861,10 @@ { sbr->ps = ps_init(get_sr_index(sbr->sample_rate)); } + if (sbr->psResetFlag) + { + sbr->ps->header_read = 0; + } ret = ps_data(sbr->ps, ld, &header); /* enable PS if and only if: a header has been decoded */ @@ -837,6 +873,11 @@ sbr->ps_used = 1; } + if (header == 1) + { + sbr->psResetFlag = 0; + } + return ret; #endif #ifdef DRM_PS