Mercurial > audlegacy-plugins
diff src/aac/libfaad2/decoder.c @ 691:e6c5fdae6e88 trunk
[svn] - oh yes, commit mplayer patches as well
author | nenolod |
---|---|
date | Tue, 20 Feb 2007 06:38:03 -0800 |
parents | 1d8b08df98c3 |
children | f1b6f1b2cdb3 |
line wrap: on
line diff
--- a/src/aac/libfaad2/decoder.c Tue Feb 20 06:31:29 2007 -0800 +++ b/src/aac/libfaad2/decoder.c Tue Feb 20 06:38:03 2007 -0800 @@ -1,33 +1,28 @@ /* ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding -** Copyright (C) 2003-2005 M. Bakker, Nero 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 ** the Free Software Foundation; either version 2 of the License, or ** (at your option) any later version. -** +** ** This program is distributed in the hope that it will be useful, ** but WITHOUT ANY WARRANTY; without even the implied warranty of ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ** GNU General Public License for more details. -** +** ** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software +** along with this program; if not, write to the Free Software ** 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. ** -** Commercial non-GPL licensing of this software is possible. -** For more info contact Nero AG through Mpeg4AAClicense@nero.com. -** -** $Id: decoder.c,v 1.109 2006/05/07 18:09:00 menno Exp $ +** $Id: decoder.c,v 1.107 2004/09/08 09:43:11 gcp Exp $ **/ #include "common.h" @@ -121,9 +116,6 @@ hDecoder->frame = 0; hDecoder->sample_buffer = NULL; - hDecoder->__r1 = 1; - hDecoder->__r2 = 1; - for (i = 0; i < MAX_CHANNELS; i++) { hDecoder->window_shape_prev[i] = 0; @@ -202,7 +194,6 @@ return 0; } - int32_t NEAACDECAPI NeAACDecInit(NeAACDecHandle hDecoder, uint8_t *buffer, uint32_t buffer_size, uint32_t *samplerate, uint8_t *channels) @@ -212,7 +203,6 @@ adif_header adif; adts_header adts; - if ((hDecoder == NULL) || (samplerate == NULL) || (channels == NULL)) return -1; @@ -267,6 +257,7 @@ } faad_endbits(&ld); } + hDecoder->channelConfiguration = *channels; #if (defined(PS_DEC) || defined(DRM_PS)) /* check if we have a mono file */ @@ -277,8 +268,6 @@ } #endif - hDecoder->channelConfiguration = *channels; - #ifdef SBR_DEC /* implicit signalling */ if (*samplerate <= 24000 && !(hDecoder->config.dontUpSampleImplicitSBR)) @@ -433,8 +422,8 @@ if ((channels == DRMCH_MONO) || (channels == DRMCH_STEREO)) (*hDecoder)->sbr_present_flag = 0; else - (*hDecoder)->sbr_present_flag = 1; -#endif + (*hDecoder)->sbr_present_flag = 1; +#endif (*hDecoder)->fb = filter_bank_init((*hDecoder)->frameLength); @@ -536,14 +525,8 @@ chdir = hInfo->num_front_channels; if (chdir & 1) { -#if (defined(PS_DEC) || defined(DRM_PS)) - /* When PS is enabled output is always stereo */ - hInfo->channel_position[chpos++] = FRONT_CHANNEL_LEFT; - hInfo->channel_position[chpos++] = FRONT_CHANNEL_RIGHT; -#else hInfo->channel_position[chpos++] = FRONT_CHANNEL_CENTER; chdir--; -#endif } for (i = 0; i < chdir; i += 2) { @@ -582,15 +565,8 @@ switch (hDecoder->channelConfiguration) { case 1: -#if (defined(PS_DEC) || defined(DRM_PS)) - /* When PS is enabled output is always stereo */ - hInfo->num_front_channels = 2; - hInfo->channel_position[0] = FRONT_CHANNEL_LEFT; - hInfo->channel_position[1] = FRONT_CHANNEL_RIGHT; -#else hInfo->num_front_channels = 1; hInfo->channel_position[0] = FRONT_CHANNEL_CENTER; -#endif break; case 2: hInfo->num_front_channels = 2; @@ -746,25 +722,13 @@ sample_buffer, sample_buffer_size); } -#ifdef DRM - -#define ERROR_STATE_INIT 6 - -static void conceal_output(NeAACDecHandle hDecoder, uint16_t frame_len, - uint8_t out_ch, void *sample_buffer) -{ - return; -} -#endif - static void* aac_frame_decode(NeAACDecHandle hDecoder, NeAACDecFrameInfo *hInfo, uint8_t *buffer, uint32_t buffer_size, void **sample_buffer2, uint32_t sample_buffer_size) { - uint16_t i; uint8_t channels = 0; uint8_t output_channels = 0; - bitfile ld = {0}; + bitfile ld; uint32_t bitsconsumed; uint16_t frame_len; void *sample_buffer; @@ -789,33 +753,6 @@ memset(hInfo, 0, sizeof(NeAACDecFrameInfo)); memset(hDecoder->internal_channel, 0, MAX_CHANNELS*sizeof(hDecoder->internal_channel[0])); -#ifdef USE_TIME_LIMIT - if ((TIME_LIMIT * get_sample_rate(hDecoder->sf_index)) > hDecoder->TL_count) - { - hDecoder->TL_count += 1024; - } else { - hInfo->error = (NUM_ERROR_MESSAGES-1); - goto error; - } -#endif - - - /* check for some common metadata tag types in the bitstream - * No need to return an error - */ - /* ID3 */ - if (buffer_size >= 128) - { - if (memcmp(buffer, "TAG", 3) == 0) - { - /* found it */ - hInfo->bytesconsumed = 128; /* 128 bytes fixed size */ - /* no error, but no output either */ - return NULL; - } - } - - /* initialize the bitstream */ faad_initbits(&ld, buffer, buffer_size); @@ -843,7 +780,7 @@ /* We do not support stereo right now */ if (0) //(hDecoder->channelConfiguration == 2) { - hInfo->error = 28; // Throw CRC error + hInfo->error = 8; // Throw CRC error goto error; } @@ -871,14 +808,14 @@ #endif /* decode the complete bitstream */ -#ifdef DRM - if (/*(hDecoder->object_type == 6) ||*/ (hDecoder->object_type == DRM_ER_LC)) +#ifdef SCALABLE_DEC + if ((hDecoder->object_type == 6) || (hDecoder->object_type == DRM_ER_LC)) { - DRM_aac_scalable_main_element(hDecoder, hInfo, &ld, &hDecoder->pce, hDecoder->drc); + aac_scalable_main_element(hDecoder, hInfo, &ld, &hDecoder->pce, hDecoder->drc); } else { #endif raw_data_block(hDecoder, hInfo, &ld, &hDecoder->pce, hDecoder->drc); -#ifdef DRM +#ifdef SCALABLE_DEC } #endif @@ -1041,16 +978,10 @@ } #endif - sample_buffer = output_to_PCM(hDecoder, hDecoder->time_out, sample_buffer, output_channels, frame_len, hDecoder->config.outputFormat); -#ifdef DRM - //conceal_output(hDecoder, frame_len, output_channels, sample_buffer); -#endif - - hDecoder->postSeekResetFlag = 0; hDecoder->frame++; @@ -1082,30 +1013,6 @@ error: - -#ifdef DRM - hDecoder->error_state = ERROR_STATE_INIT; -#endif - - /* reset filterbank state */ - for (i = 0; i < MAX_CHANNELS; i++) - { - if (hDecoder->fb_intermed[i] != NULL) - { - memset(hDecoder->fb_intermed[i], 0, hDecoder->frameLength*sizeof(real_t)); - } - } -#ifdef SBR_DEC - for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++) - { - if (hDecoder->sbr[i] != NULL) - { - sbrReset(hDecoder->sbr[i]); - } - } -#endif - - faad_endbits(&ld); /* cleanup */