From 228ca70d485e2660c2e381d7112cbcca65c156a0 Mon Sep 17 00:00:00 2001 From: diego Date: Wed, 2 Jun 2004 22:59:04 +0000 Subject: update to the 2.0 release of faad, patch by adland git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@12528 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libfaad2/tns.c | 50 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 13 deletions(-) (limited to 'libfaad2/tns.c') diff --git a/libfaad2/tns.c b/libfaad2/tns.c index ef32ab4cfa..0882dbbfc9 100644 --- a/libfaad2/tns.c +++ b/libfaad2/tns.c @@ -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: tns.c,v 1.22 2003/09/09 18:09:52 menno Exp $ +** $Id: tns.c,v 1.2 2003/10/03 22:22:27 alex Exp $ **/ #include "common.h" @@ -31,6 +31,16 @@ #include "syntax.h" #include "tns.h" + +/* static function declarations */ +static void tns_decode_coef(uint8_t order, uint8_t coef_res_bits, uint8_t coef_compress, + uint8_t *coef, real_t *a); +static void tns_ar_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *lpc, + uint8_t order); +static void tns_ma_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *lpc, + uint8_t order); + + #ifdef _MSC_VER #pragma warning(disable:4305) #pragma warning(disable:4244) @@ -71,7 +81,8 @@ void tns_decode_frame(ic_stream *ics, tns_info *tns, uint8_t sr_index, { uint8_t w, f, tns_order; int8_t inc; - uint16_t bottom, top, start, end, size; + int16_t size; + uint16_t bottom, top, start, end; uint16_t nshort = frame_len/8; real_t lpc[TNS_MAX_ORDER+1]; @@ -93,10 +104,16 @@ void tns_decode_frame(ic_stream *ics, tns_info *tns, uint8_t sr_index, tns_decode_coef(tns_order, tns->coef_res[w]+3, tns->coef_compress[w][f], tns->coef[w][f], lpc); - start = ics->swb_offset[min(bottom, ics->max_sfb)]; - end = ics->swb_offset[min(top, ics->max_sfb)]; + start = min(bottom, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE))); + start = min(start, ics->max_sfb); + start = ics->swb_offset[start]; - if ((size = end - start) <= 0) + end = min(top, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE))); + end = min(end, ics->max_sfb); + end = ics->swb_offset[end]; + + size = end - start; + if (size <= 0) continue; if (tns->direction[w][f]) @@ -118,7 +135,8 @@ void tns_encode_frame(ic_stream *ics, tns_info *tns, uint8_t sr_index, { uint8_t w, f, tns_order; int8_t inc; - uint16_t bottom, top, start, end, size; + int16_t size; + uint16_t bottom, top, start, end; uint16_t nshort = frame_len/8; real_t lpc[TNS_MAX_ORDER+1]; @@ -140,10 +158,16 @@ void tns_encode_frame(ic_stream *ics, tns_info *tns, uint8_t sr_index, tns_decode_coef(tns_order, tns->coef_res[w]+3, tns->coef_compress[w][f], tns->coef[w][f], lpc); - start = ics->swb_offset[min(bottom, ics->max_sfb)]; - end = ics->swb_offset[min(top, ics->max_sfb)]; + start = min(bottom, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE))); + start = min(start, ics->max_sfb); + start = ics->swb_offset[start]; + + end = min(top, max_tns_sfb(sr_index, object_type, (ics->window_sequence == EIGHT_SHORT_SEQUENCE))); + end = min(end, ics->max_sfb); + end = ics->swb_offset[end]; - if ((size = end - start) <= 0) + size = end - start; + if (size <= 0) continue; if (tns->direction[w][f]) @@ -192,7 +216,7 @@ static void tns_decode_coef(uint8_t order, uint8_t coef_res_bits, uint8_t coef_c for (m = 1; m <= order; m++) { for (i = 1; i < m; i++) /* loop only while i 0; j--) state[j] = state[j-1]; @@ -260,7 +284,7 @@ static void tns_ma_filter(real_t *spectrum, uint16_t size, int8_t inc, real_t *l y = *spectrum; for (j = 0; j < order; j++) - y += MUL_R_C(state[j], lpc[j+1]); + y += MUL_C(state[j], lpc[j+1]); for (j = order-1; j > 0; j--) state[j] = state[j-1]; -- cgit v1.2.3