From 634845b1ce6f34cca9da56c15f0d025a77fce163 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Thu, 13 Jun 2013 17:42:24 -0700 Subject: [PATCH] Added preprocessor blocking around MP4/AAC parts --- fb2k/foo_input_vgmstream.vcxproj | 4 ++-- src/coding/mp4_aac_decoder.c | 4 +++- src/libvgmstream.vcxproj | 4 ++-- src/meta/akb.c | 4 +++- src/meta/meta.h | 2 ++ src/meta/mp4.c | 6 +++++- src/vgmstream.c | 12 ++++++++++++ src/vgmstream.h | 14 +++++++++++++- 8 files changed, 42 insertions(+), 8 deletions(-) diff --git a/fb2k/foo_input_vgmstream.vcxproj b/fb2k/foo_input_vgmstream.vcxproj index dfa5378f..9bdb15dc 100644 --- a/fb2k/foo_input_vgmstream.vcxproj +++ b/fb2k/foo_input_vgmstream.vcxproj @@ -68,7 +68,7 @@ Disabled ../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) + WIN32;VGM_USE_G7221;VGM_USE_MP4V2;VGM_USE_FDKAAC;_DEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug @@ -87,7 +87,7 @@ ../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) + WIN32;VGM_USE_G7221;VGM_USE_MP4V2;VGM_USE_FDKAAC;NDEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;%(PreprocessorDefinitions) MultiThreaded diff --git a/src/coding/mp4_aac_decoder.c b/src/coding/mp4_aac_decoder.c index 6047f925..7b6a2589 100644 --- a/src/coding/mp4_aac_decoder.c +++ b/src/coding/mp4_aac_decoder.c @@ -1,5 +1,6 @@ #include "../vgmstream.h" +#if defined(VGM_USE_MP4V2) && defined(VGM_USE_FDKAAC) static void convert_samples(INT_PCM * src, sample * dest, int32_t count) { int32_t i; for ( i = 0; i < count; i++ ) { @@ -80,4 +81,5 @@ void decode_mp4_aac(mp4_aac_codec_data * data, sample * outbuf, int32_t samples_ outbuf += samples_remain * stream_info->numChannels; data->sample_ptr = samples_remain; } -} \ No newline at end of file +} +#endif diff --git a/src/libvgmstream.vcxproj b/src/libvgmstream.vcxproj index 0797d568..2daadc4a 100644 --- a/src/libvgmstream.vcxproj +++ b/src/libvgmstream.vcxproj @@ -56,7 +56,7 @@ Disabled ../ext_includes;../../qaac/mp4v2/include;../../fdk-aac/libSYS/include;../../fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) - WIN32;VGM_USE_G7221;_DEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;VGM_USE_G7221;VGM_USE_MP4V2;VGM_USE_FDKAAC;_DEBUG;_LIB;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug @@ -70,7 +70,7 @@ ../ext_includes;../../qaac/mp4v2/include;../../fdk-aac/libSYS/include;../../fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) - WIN32;VGM_USE_G7221;NDEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;VGM_USE_G7221;VGM_USE_MP4V2;VGM_USE_FDKAAC;NDEBUG;_LIB;%(PreprocessorDefinitions) MultiThreaded diff --git a/src/meta/akb.c b/src/meta/akb.c index 297c74fc..d16e814d 100644 --- a/src/meta/akb.c +++ b/src/meta/akb.c @@ -1,6 +1,7 @@ #include "../vgmstream.h" #include "meta.h" +#if defined(VGM_USE_MP4V2) && defined(VGM_USE_FDKAAC) VGMSTREAM * init_vgmstream_akb(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; @@ -27,4 +28,5 @@ VGMSTREAM * init_vgmstream_akb(STREAMFILE *streamFile) { fail: return NULL; -} \ No newline at end of file +} +#endif diff --git a/src/meta/meta.h b/src/meta/meta.h index 4039dc34..01a1fe90 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -107,11 +107,13 @@ VGMSTREAM * init_vgmstream_ogg_vorbis_callbacks(STREAMFILE *streamFile, const ch VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE * streamFile); +#if defined(VGM_USE_MP4V2) && defined(VGM_USE_FDKAAC) VGMSTREAM * init_vgmstream_mp4_aac(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_mp4_aac_offset(STREAMFILE *streamFile, uint64_t start, uint64_t size); VGMSTREAM * init_vgmstream_akb(STREAMFILE *streamFile); +#endif VGMSTREAM * init_vgmstream_sfl(STREAMFILE * streamFile); #endif diff --git a/src/meta/mp4.c b/src/meta/mp4.c index 853441f7..20fd73c2 100644 --- a/src/meta/mp4.c +++ b/src/meta/mp4.c @@ -2,6 +2,7 @@ #include "meta.h" #include "../util.h" +#ifdef VGM_USE_MP4V2 void* mp4_file_open( const char* name, MP4FileMode mode ) { char * endptr; @@ -59,6 +60,7 @@ int mp4_file_close( void* handle ) MP4FileProvider mp4_file_provider = { mp4_file_open, mp4_file_seek, mp4_file_get_size, mp4_file_read, mp4_file_write, mp4_file_close }; +#ifdef VGM_USE_FDKAAC VGMSTREAM * init_vgmstream_mp4_aac_offset(STREAMFILE *streamFile, uint64_t start, uint64_t size); VGMSTREAM * init_vgmstream_mp4_aac(STREAMFILE *streamFile) { @@ -156,4 +158,6 @@ fail: free( aac_file ); } return NULL; -} \ No newline at end of file +} +#endif +#endif diff --git a/src/vgmstream.c b/src/vgmstream.c index 7d596e04..a2a2c52f 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -62,7 +62,9 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { #if 0 init_vgmstream_mp4_aac, #endif +#if defined(VGM_USE_MP4V2) && defined(VGM_USE_FDKAAC) init_vgmstream_akb, +#endif init_vgmstream_sadb, init_vgmstream_ps2_bmdx, init_vgmstream_wsi, @@ -418,12 +420,14 @@ void reset_vgmstream(VGMSTREAM * vgmstream) { ov_pcm_seek(ogg_vorbis_file, 0); } #endif +#if defined(VGM_USE_MP4V2) && defined(VGM_USE_FDKAAC) if (vgmstream->coding_type==coding_MP4_AAC) { mp4_aac_codec_data *data = vgmstream->codec_data; data->sampleId = 0; data->sample_ptr = data->samples_per_frame; data->samples_discard = 0; } +#endif #ifdef VGM_USE_MPEG if (vgmstream->layout_type==layout_mpeg || vgmstream->layout_type==layout_fake_mpeg) { @@ -586,6 +590,7 @@ void close_vgmstream(VGMSTREAM * vgmstream) { } #endif +#if defined(VGM_USE_MP4V2) && defined(VGM_USE_FDKAAC) if (vgmstream->coding_type==coding_MP4_AAC) { mp4_aac_codec_data *data = vgmstream->codec_data; if (vgmstream->codec_data) { @@ -596,6 +601,7 @@ void close_vgmstream(VGMSTREAM * vgmstream) { vgmstream->codec_data = NULL; } } +#endif #ifdef VGM_USE_MPEG if (vgmstream->layout_type==layout_fake_mpeg|| @@ -943,8 +949,10 @@ int get_vgmstream_samples_per_frame(VGMSTREAM * vgmstream) { return 54; case coding_MTAF: return 0x80*2; +#if defined(VGM_USE_MP4V2) && defined(VGM_USE_FDKAAC) case coding_MP4_AAC: return ((mp4_aac_codec_data*)vgmstream->codec_data)->samples_per_frame; +#endif default: return 0; } @@ -1312,11 +1320,13 @@ void decode_vgmstream(VGMSTREAM * vgmstream, int samples_written, int samples_to vgmstream->channels); break; #endif +#if defined(VGM_USE_MP4V2) && defined(VGM_USE_FDKAAC) case coding_MP4_AAC: decode_mp4_aac(vgmstream->codec_data, buffer+samples_written*vgmstream->channels,samples_to_do, vgmstream->channels); break; +#endif case coding_SDX2: for (chan=0;chanchannels;chan++) { decode_sdx2(&vgmstream->ch[chan],buffer+samples_written*vgmstream->channels+chan, @@ -1574,12 +1584,14 @@ int vgmstream_do_loop(VGMSTREAM * vgmstream) { ov_pcm_seek_lap(ogg_vorbis_file, vgmstream->loop_sample); } #endif +#if defined(VGM_USE_MP4V2) && defined(VGM_USE_FDKAAC) if (vgmstream->coding_type==coding_MP4_AAC) { mp4_aac_codec_data *data = (mp4_aac_codec_data *)(vgmstream->codec_data); data->sampleId = 0; data->sample_ptr = data->samples_per_frame; data->samples_discard = vgmstream->loop_sample; } +#endif #ifdef VGM_USE_MPEG /* won't work for fake MPEG */ if (vgmstream->layout_type==layout_mpeg) { diff --git a/src/vgmstream.h b/src/vgmstream.h index 7a36627f..a2aa707f 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -29,10 +29,14 @@ enum { PATH_LIMIT = 32768 }; #include "g7221.h" #endif +#ifdef VGM_USE_MP4V2 #define MP4V2_NO_STDINT_DEFS #include +#endif +#ifdef VGM_USE_FDKAAC #include +#endif #include "coding/acm_decoder.h" #include "coding/nwa_decoder.h" @@ -135,7 +139,9 @@ typedef enum { coding_LSF, /* lsf ADPCM */ coding_MTAF, /* Konami IMA-derived MTAF ADPCM */ +#if defined(VGM_USE_MP4V2) && defined(VGM_USE_FDKAAC) coding_MP4_AAC, +#endif } coding_t; /* The layout type specifies how the sound data is laid out in the file */ @@ -546,8 +552,10 @@ typedef enum { meta_PS2_MSS, // ShellShock Nam '67 (PS2) meta_PS2_HSF, // Lowrider (PS2) meta_PS3_IVAG, // Interleaved VAG files (PS3) - meta_PS2_2PFS, // Mahoromatic: Moetto - KiraKira Maid-San (PS2) + meta_PS2_2PFS, // Mahoromatic: Moetto - KiraKira Maid-San (PS2) +#ifdef VGM_USE_MP4V2 meta_MP4, +#endif } meta_t; typedef struct { @@ -762,6 +770,7 @@ typedef struct { STREAMFILE **intfiles; } scd_int_codec_data; +#ifdef VGM_USE_MP4V2 typedef struct { STREAMFILE *streamfile; uint64_t start; @@ -769,6 +778,7 @@ typedef struct { uint64_t size; } mp4_streamfile; +#ifdef VGM_USE_FDKAAC typedef struct { mp4_streamfile if_file; MP4FileHandle h_mp4file; @@ -779,6 +789,8 @@ typedef struct { unsigned int sample_ptr, samples_per_frame, samples_discard; INT_PCM sample_buffer[( (6) * (2048)*4 )]; } mp4_aac_codec_data; +#endif +#endif /* do format detection, return pointer to a usable VGMSTREAM, or NULL on failure */ VGMSTREAM * init_vgmstream(const char * const filename);