From f560539e561cc24f2f9b464a57dc2eeb855b3091 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Thu, 30 Aug 2012 05:35:12 -0700 Subject: [PATCH] Implemented MP4 AAC support for iOS AKB format --- fb2k/foo_input_vgmstream.vcxproj | 10 ++++++++-- fb2k/version.h | 2 +- src/libvgmstream.vcxproj | 7 +++++-- src/libvgmstream.vcxproj.filters | 9 +++++++++ src/meta/mp4.c | 7 +++++++ src/vgmstream.c | 7 ++++++- src/vgmstream.h | 1 + 7 files changed, 37 insertions(+), 6 deletions(-) diff --git a/fb2k/foo_input_vgmstream.vcxproj b/fb2k/foo_input_vgmstream.vcxproj index 030acd5d..ec4caf19 100644 --- a/fb2k/foo_input_vgmstream.vcxproj +++ b/fb2k/foo_input_vgmstream.vcxproj @@ -62,7 +62,7 @@ Disabled - ../ext_includes;..\..\foobar\foobar2000\SDK;..\..\foobar\foobar2000\helpers;..\..\foobar\foobar2000\ATLHelpers;..\..\foobar\foobar2000\shared;%(AdditionalIncludeDirectories) + ../ext_includes;..\..\foobar\foobar2000\SDK;..\..\foobar\foobar2000\helpers;..\..\foobar\foobar2000\ATLHelpers;..\..\foobar\foobar2000\shared;../../qaac/mp4v2/include;../../fdk-aac/libSYS/include;../../fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) WIN32;VGM_USE_G7221;_DEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;%(PreprocessorDefinitions) true EnableFastChecks @@ -81,7 +81,7 @@ - ../ext_includes;..\..\foobar\foobar2000\SDK;..\..\foobar\foobar2000\helpers;..\..\foobar\foobar2000\ATLHelpers;..\..\foobar\foobar2000\shared;%(AdditionalIncludeDirectories) + ../ext_includes;..\..\foobar\foobar2000\SDK;..\..\foobar\foobar2000\helpers;..\..\foobar\foobar2000\ATLHelpers;..\..\foobar\foobar2000\shared;../../qaac/mp4v2/include;../../fdk-aac/libSYS/include;../../fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) WIN32;VGM_USE_G7221;NDEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;%(PreprocessorDefinitions) MultiThreaded @@ -114,6 +114,9 @@ + + {308e2ad5-be31-4770-9441-a8d50f56895c} + {622e8b19-8109-4717-bd4d-9657aa78363e} @@ -129,6 +132,9 @@ {ebfffb4e-261d-44d3-b89c-957b31a0bf9c} + + {86a064e2-c81b-4eee-8be0-a39a2e7c7c76} + {10e6bfc6-1e5b-46e4-ba42-f04dfbd0abff} diff --git a/fb2k/version.h b/fb2k/version.h index 3a9be6a5..6da80b4a 100755 --- a/fb2k/version.h +++ b/fb2k/version.h @@ -1 +1 @@ -#define VERSION "r995" +#define VERSION "r995-1" diff --git a/src/libvgmstream.vcxproj b/src/libvgmstream.vcxproj index 0a39ac75..0795d756 100644 --- a/src/libvgmstream.vcxproj +++ b/src/libvgmstream.vcxproj @@ -53,7 +53,7 @@ Disabled - ../ext_includes;%(AdditionalIncludeDirectories) + ../ext_includes;../../qaac/mp4v2/include;../../fdk-aac/libSYS/include;../../fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) WIN32;VGM_USE_G7221;_DEBUG;_LIB;%(PreprocessorDefinitions) true EnableFastChecks @@ -67,7 +67,7 @@ - ../ext_includes;%(AdditionalIncludeDirectories) + ../ext_includes;../../qaac/mp4v2/include;../../fdk-aac/libSYS/include;../../fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) WIN32;VGM_USE_G7221;NDEBUG;_LIB;%(PreprocessorDefinitions) MultiThreaded @@ -90,16 +90,19 @@ + + + diff --git a/src/libvgmstream.vcxproj.filters b/src/libvgmstream.vcxproj.filters index c945a4eb..3a31a0ad 100644 --- a/src/libvgmstream.vcxproj.filters +++ b/src/libvgmstream.vcxproj.filters @@ -937,5 +937,14 @@ meta\Source Files + + meta\Source Files + + + coding\Source Files + + + meta\Source Files + \ No newline at end of file diff --git a/src/meta/mp4.c b/src/meta/mp4.c index 8d4b0a80..b744f84c 100644 --- a/src/meta/mp4.c +++ b/src/meta/mp4.c @@ -91,12 +91,18 @@ VGMSTREAM * init_vgmstream_mp4_aac_offset(STREAMFILE *streamFile, uint64_t start aacDecoder_SetParam( aac_file->h_aacdecoder, AAC_PCM_OUTPUT_CHANNELS, 2 ); +<<<<<<< HEAD MP4GetTrackESConfiguration( aac_file->h_mp4file, aac_file->track_id, (uint8_t**)(&buffer), (uint32_t*)(&buffer_size)); ubuffer_size = buffer_size; if ( aacDecoder_ConfigRaw( aac_file->h_aacdecoder, &buffer, &ubuffer_size ) ) goto fail; free( buffer ); buffer = NULL; +======= + MP4GetTrackESConfiguration( aac_file->h_mp4file, aac_file->track_id, (uint8_t**)(&aac_file->codec_init_data), (uint32_t*)(&aac_file->codec_init_data_size)); + + if ( aacDecoder_ConfigRaw( aac_file->h_aacdecoder, &aac_file->codec_init_data, &aac_file->codec_init_data_size ) ) goto fail; +>>>>>>> Implemented MP4 AAC support for iOS AKB format aac_file->sampleId = 1; aac_file->numSamples = MP4GetTrackNumberOfSamples( aac_file->h_mp4file, aac_file->track_id ); @@ -145,6 +151,7 @@ fail: if ( aac_file ) { 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->codec_init_data ) free( aac_file->codec_init_data ); free( aac_file ); } return NULL; diff --git a/src/vgmstream.c b/src/vgmstream.c index 5af57e33..9d02af41 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -420,7 +420,7 @@ void reset_vgmstream(VGMSTREAM * vgmstream) { #endif if (vgmstream->coding_type==coding_MP4_AAC) { mp4_aac_codec_data *data = vgmstream->codec_data; - data->sampleId = 0; + data->sampleId = 1; data->sample_ptr = data->samples_per_frame; data->samples_discard = 0; } @@ -592,6 +592,7 @@ void close_vgmstream(VGMSTREAM * vgmstream) { if (data->h_aacdecoder) aacDecoder_Close(data->h_aacdecoder); if (data->h_mp4file) MP4Close(data->h_mp4file, 0); 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); vgmstream->codec_data = NULL; } @@ -1579,6 +1580,10 @@ int vgmstream_do_loop(VGMSTREAM * vgmstream) { data->sampleId = 0; data->sample_ptr = data->samples_per_frame; 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 /* won't work for fake MPEG */ diff --git a/src/vgmstream.h b/src/vgmstream.h index e3303cd7..7f9caf46 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -772,6 +772,7 @@ typedef struct { MP4FileHandle h_mp4file; MP4TrackId track_id; unsigned long sampleId, numSamples; + uint8_t * codec_init_data; UINT codec_init_data_size; HANDLE_AACDECODER h_aacdecoder; unsigned int sample_ptr, samples_per_frame, samples_discard;