Removed unnecessary reinitialization

This commit is contained in:
Chris Moeller 2012-08-30 05:49:07 -07:00
parent e1dc9ba487
commit 29bcc68bde
3 changed files with 6 additions and 10 deletions

View File

@ -91,9 +91,12 @@ VGMSTREAM * init_vgmstream_mp4_aac_offset(STREAMFILE *streamFile, uint64_t start
aacDecoder_SetParam( aac_file->h_aacdecoder, AAC_PCM_OUTPUT_CHANNELS, 2 ); aacDecoder_SetParam( aac_file->h_aacdecoder, AAC_PCM_OUTPUT_CHANNELS, 2 );
MP4GetTrackESConfiguration( aac_file->h_mp4file, aac_file->track_id, (uint8_t**)(&aac_file->codec_init_data), (uint32_t*)(&aac_file->codec_init_data_size)); MP4GetTrackESConfiguration( aac_file->h_mp4file, aac_file->track_id, (uint8_t**)(&buffer), (uint32_t*)(&buffer_size));
if ( aacDecoder_ConfigRaw( aac_file->h_aacdecoder, &aac_file->codec_init_data, &aac_file->codec_init_data_size ) ) goto fail; ubuffer_size = buffer_size;
if ( aacDecoder_ConfigRaw( aac_file->h_aacdecoder, &buffer, &ubuffer_size ) ) goto fail;
free( buffer ); buffer = NULL;
aac_file->sampleId = 1; aac_file->sampleId = 1;
aac_file->numSamples = MP4GetTrackNumberOfSamples( aac_file->h_mp4file, aac_file->track_id ); aac_file->numSamples = MP4GetTrackNumberOfSamples( aac_file->h_mp4file, aac_file->track_id );
@ -142,7 +145,6 @@ fail:
if ( aac_file ) { if ( aac_file ) {
if ( aac_file->h_aacdecoder ) aacDecoder_Close( aac_file->h_aacdecoder ); if ( aac_file->h_aacdecoder ) aacDecoder_Close( aac_file->h_aacdecoder );
if ( aac_file->h_mp4file ) MP4Close( aac_file->h_mp4file, 0 ); if ( aac_file->h_mp4file ) MP4Close( aac_file->h_mp4file, 0 );
if ( aac_file->codec_init_data ) free( aac_file->codec_init_data );
free( aac_file ); free( aac_file );
} }
return NULL; return NULL;

View File

@ -420,7 +420,7 @@ void reset_vgmstream(VGMSTREAM * vgmstream) {
#endif #endif
if (vgmstream->coding_type==coding_MP4_AAC) { if (vgmstream->coding_type==coding_MP4_AAC) {
mp4_aac_codec_data *data = vgmstream->codec_data; mp4_aac_codec_data *data = vgmstream->codec_data;
data->sampleId = 1; data->sampleId = 0;
data->sample_ptr = data->samples_per_frame; data->sample_ptr = data->samples_per_frame;
data->samples_discard = 0; data->samples_discard = 0;
} }
@ -592,7 +592,6 @@ void close_vgmstream(VGMSTREAM * vgmstream) {
if (data->h_aacdecoder) aacDecoder_Close(data->h_aacdecoder); if (data->h_aacdecoder) aacDecoder_Close(data->h_aacdecoder);
if (data->h_mp4file) MP4Close(data->h_mp4file, 0); if (data->h_mp4file) MP4Close(data->h_mp4file, 0);
if (data->if_file.streamfile) close_streamfile(data->if_file.streamfile); if (data->if_file.streamfile) close_streamfile(data->if_file.streamfile);
if (data->codec_init_data) free(data->codec_init_data);
free(vgmstream->codec_data); free(vgmstream->codec_data);
vgmstream->codec_data = NULL; vgmstream->codec_data = NULL;
} }
@ -1580,10 +1579,6 @@ int vgmstream_do_loop(VGMSTREAM * vgmstream) {
data->sampleId = 0; data->sampleId = 0;
data->sample_ptr = data->samples_per_frame; data->sample_ptr = data->samples_per_frame;
data->samples_discard = vgmstream->loop_sample; data->samples_discard = vgmstream->loop_sample;
aacDecoder_Close(data->h_aacdecoder);
data->h_aacdecoder = aacDecoder_Open( TT_MP4_RAW, 1 );
aacDecoder_SetParam( data->h_aacdecoder, AAC_PCM_OUTPUT_CHANNELS, 2 );
aacDecoder_ConfigRaw( data->h_aacdecoder, &data->codec_init_data, &data->codec_init_data_size );
} }
#ifdef VGM_USE_MPEG #ifdef VGM_USE_MPEG
/* won't work for fake MPEG */ /* won't work for fake MPEG */

View File

@ -772,7 +772,6 @@ typedef struct {
MP4FileHandle h_mp4file; MP4FileHandle h_mp4file;
MP4TrackId track_id; MP4TrackId track_id;
unsigned long sampleId, numSamples; unsigned long sampleId, numSamples;
uint8_t * codec_init_data;
UINT codec_init_data_size; UINT codec_init_data_size;
HANDLE_AACDECODER h_aacdecoder; HANDLE_AACDECODER h_aacdecoder;
unsigned int sample_ptr, samples_per_frame, samples_discard; unsigned int sample_ptr, samples_per_frame, samples_discard;