diff --git a/.gitignore b/.gitignore index a756df5b..e630ca31 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -.svn +.* +!/.gitignore *.user *.suo *.vspscc diff --git a/src/meta/ffmpeg.c b/src/meta/ffmpeg.c index 96ae82be..53ece35b 100644 --- a/src/meta/ffmpeg.c +++ b/src/meta/ffmpeg.c @@ -4,8 +4,13 @@ #ifdef VGM_USE_FFMPEG +#define FFMPEG_DEFAULT_BLOCK_SIZE 2048 + static volatile int g_ffmpeg_initialized = 0; +/* + * Global FFmpeg init + */ static void g_init_ffmpeg() { if (g_ffmpeg_initialized == 1) @@ -22,24 +27,19 @@ static void g_init_ffmpeg() } } -ffmpeg_codec_data * init_ffmpeg_faux_riff(STREAMFILE *streamFile, int64_t fmt_offset, uint64_t stream_offset, uint64_t stream_size, int fmt_big_endian); -ffmpeg_codec_data * init_ffmpeg_offset(STREAMFILE *streamFile, uint64_t start, uint64_t size) { - return init_ffmpeg_faux_riff(streamFile, -1, start, size, 0); -} - -VGMSTREAM * init_vgmstream_ffmpeg_offset(STREAMFILE *streamFile, uint64_t start, uint64_t size); +/** + * Generic init FFmpeg and vgmstream for any file supported by FFmpeg. + * Always called by vgmstream when trying to identify the file type (if the player allows it). + */ VGMSTREAM * init_vgmstream_ffmpeg(STREAMFILE *streamFile) { return init_vgmstream_ffmpeg_offset( streamFile, 0, streamFile->get_size(streamFile) ); } -void free_ffmpeg(ffmpeg_codec_data *data); - VGMSTREAM * init_vgmstream_ffmpeg_offset(STREAMFILE *streamFile, uint64_t start, uint64_t size) { VGMSTREAM *vgmstream = NULL; - + ffmpeg_codec_data *data = init_ffmpeg_offset(streamFile, start, size); - if (!data) return NULL; vgmstream = allocate_vgmstream(data->channels, 0); @@ -53,7 +53,7 @@ VGMSTREAM * init_vgmstream_ffmpeg_offset(STREAMFILE *streamFile, uint64_t start, vgmstream->coding_type = coding_FFmpeg; vgmstream->layout_type = layout_none; vgmstream->meta_type = meta_FFmpeg; - + return vgmstream; fail: @@ -62,6 +62,10 @@ fail: return NULL; } + +/** + * AVIO callback: read stream, skipping external headers if needed + */ static int ffmpeg_read(void *opaque, uint8_t *buf, int buf_size) { ffmpeg_codec_data *data = (ffmpeg_codec_data *) opaque; @@ -100,11 +104,17 @@ static int ffmpeg_read(void *opaque, uint8_t *buf, int buf_size) return ret; } +/** + * AVIO callback: write stream not needed + */ static int ffmpeg_write(void *opaque, uint8_t *buf, int buf_size) { return -1; } +/** + * AVIO callback: seek stream, skipping external headers if needed + */ static int64_t ffmpeg_seek(void *opaque, int64_t offset, int whence) { ffmpeg_codec_data *data = (ffmpeg_codec_data *) opaque; @@ -128,6 +138,19 @@ static int64_t ffmpeg_seek(void *opaque, int64_t offset, int whence) return data->offset = offset; } + +/** + * Manually init FFmpeg only, from an offset. + * Can be used if the stream has an extra header over data recognized by FFmpeg. + */ +ffmpeg_codec_data * init_ffmpeg_offset(STREAMFILE *streamFile, uint64_t start, uint64_t size) { + return init_ffmpeg_faux_riff(streamFile, -1, start, size, 0); +} + +/** + * Manually init FFmpeg only, from an offset / fake RIFF. + * Can insert a fake RIFF header, to trick FFmpeg into demuxing/decoding the stream. + */ ffmpeg_codec_data * init_ffmpeg_faux_riff(STREAMFILE *streamFile, int64_t fmt_offset, uint64_t start, uint64_t size, int big_endian) { char filename[PATH_LIMIT]; @@ -139,12 +162,13 @@ ffmpeg_codec_data * init_ffmpeg_faux_riff(STREAMFILE *streamFile, int64_t fmt_of AVCodecParameters *codecPar; AVRational tb; - + + + /* basic setup */ g_init_ffmpeg(); data = ( ffmpeg_codec_data * ) calloc(1, sizeof(ffmpeg_codec_data)); - - if (!data) return 0; + if (!data) return NULL; streamFile->get_name( streamFile, filename, sizeof(filename) ); @@ -153,7 +177,9 @@ ffmpeg_codec_data * init_ffmpeg_faux_riff(STREAMFILE *streamFile, int64_t fmt_of data->start = start; data->size = size; - + + + /* insert fake RIFF header to trick FFmpeg into demuxing/decoding the stream */ if (fmt_offset > 0) { int max_header_size = (int)(start - fmt_offset); uint8_t *p; @@ -188,6 +214,8 @@ ffmpeg_codec_data * init_ffmpeg_faux_riff(STREAMFILE *streamFile, int64_t fmt_of put_32bitLE(p + data->header_size - 4, size); } + + /* setup IO, attempt to autodetect format and gather some info */ data->buffer = av_malloc(128 * 1024); if (!data->buffer) goto fail; @@ -199,10 +227,12 @@ ffmpeg_codec_data * init_ffmpeg_faux_riff(STREAMFILE *streamFile, int64_t fmt_of data->formatCtx->pb = data->ioCtx; - if ((errcode = avformat_open_input(&data->formatCtx, "", NULL, NULL)) < 0) goto fail; + if ((errcode = avformat_open_input(&data->formatCtx, "", NULL, NULL)) < 0) goto fail; /* autodetect */ if ((errcode = avformat_find_stream_info(data->formatCtx, NULL)) < 0) goto fail; + + /* find valid audio stream inside */ streamIndex = -1; for (i = 0; i < data->formatCtx->nb_streams; ++i) { @@ -217,6 +247,8 @@ ffmpeg_codec_data * init_ffmpeg_faux_riff(STREAMFILE *streamFile, int64_t fmt_of data->streamIndex = streamIndex; + + /* prepare codec and frame/packet buffers */ data->codecCtx = avcodec_alloc_context3(NULL); if (!data->codecCtx) goto fail; @@ -232,12 +264,16 @@ ffmpeg_codec_data * init_ffmpeg_faux_riff(STREAMFILE *streamFile, int64_t fmt_of data->lastDecodedFrame = av_frame_alloc(); if (!data->lastDecodedFrame) goto fail; av_frame_unref(data->lastDecodedFrame); + data->lastReadPacket = malloc(sizeof(AVPacket)); if (!data->lastReadPacket) goto fail; av_new_packet(data->lastReadPacket, 0); + data->readNextPacket = 1; data->bytesConsumedFromDecodedFrame = INT_MAX; - + + + /* other setup */ data->sampleRate = data->codecCtx->sample_rate; data->channels = data->codecCtx->channels; data->floatingPoint = 0; @@ -274,18 +310,21 @@ ffmpeg_codec_data * init_ffmpeg_faux_riff(STREAMFILE *streamFile, int64_t fmt_of goto fail; } - tb.num = 1; tb.den = data->codecCtx->sample_rate; - - data->totalFrames = av_rescale_q(data->formatCtx->streams[streamIndex]->duration, data->formatCtx->streams[streamIndex]->time_base, tb); data->bitrate = (int)(data->codecCtx->bit_rate); data->framesRead = 0; data->endOfStream = 0; data->endOfAudio = 0; - + + /* try to guess frames/samples (duration isn't always set) */ + tb.num = 1; tb.den = data->codecCtx->sample_rate; + data->totalFrames = av_rescale_q(data->formatCtx->streams[streamIndex]->duration, data->formatCtx->streams[streamIndex]->time_base, tb); if (data->totalFrames < 0) data->totalFrames = 0; - - data->sampleBuffer = av_malloc( 2048 * (data->bitsPerSample / 8) * data->channels ); + + + /* setup decode buffer */ + data->samplesPerBlock = FFMPEG_DEFAULT_BLOCK_SIZE; + data->sampleBuffer = av_malloc( data->samplesPerBlock * (data->bitsPerSample / 8) * data->channels ); if (!data->sampleBuffer) goto fail; @@ -297,6 +336,7 @@ fail: return NULL; } + void free_ffmpeg(ffmpeg_codec_data *data) { if (data->lastReadPacket) { av_packet_unref(data->lastReadPacket); diff --git a/src/meta/ps3_msf.c b/src/meta/ps3_msf.c index 3072c3ca..4cdacdc4 100644 --- a/src/meta/ps3_msf.c +++ b/src/meta/ps3_msf.c @@ -6,54 +6,81 @@ VGMSTREAM * init_vgmstream_ps3_msf(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; char filename[PATH_LIMIT]; - off_t start_offset; - int32_t loop_start, loop_end; + off_t start_offset, header_offset = 0; + int32_t data_size, loop_start, loop_end; int loop_flag = 0; int channel_count; int codec_id; - size_t fileLength; + +#ifdef VGM_USE_FFMPEG + ffmpeg_codec_data *ffmpeg_data = NULL; +#endif + /* check extension, case insensitive */ streamFile->get_name(streamFile,filename,sizeof(filename)); if (strcasecmp("msf",filename_extension(filename))) goto fail; - if (read_8bit(0x0,streamFile) != 0x4D) goto fail; /* M */ - if (read_8bit(0x1,streamFile) != 0x53) goto fail; /* S */ - if (read_8bit(0x2,streamFile) != 0x46) goto fail; /* F */ + /* "WMSF" variation with a mini header over the MSFC header, same extension */ + if (read_32bitBE(0x00,streamFile) == 0x574D5346) { + header_offset = 0x10; + } + start_offset = header_offset+0x40; - fileLength = get_streamfile_size(streamFile); + /* usually 0x4D534643 "MSFC" */ + if (read_8bit(header_offset+0x0,streamFile) != 0x4D) goto fail; /* M */ + if (read_8bit(header_offset+0x1,streamFile) != 0x53) goto fail; /* S */ + if (read_8bit(header_offset+0x2,streamFile) != 0x46) goto fail; /* F */ - loop_flag = (read_32bitBE(0x18,streamFile) != 0xFFFFFFFF); - if (loop_flag) - { - loop_start = read_32bitBE(0x18,streamFile); - loop_end = read_32bitBE(0x0C,streamFile); + + + data_size = read_32bitBE(header_offset+0x0C,streamFile); /* without header*/ + if (data_size==0xFFFFFFFF) { + size_t fileLength = get_streamfile_size(streamFile); + data_size = fileLength - start_offset; } - channel_count = read_32bitBE(0x8,streamFile); - codec_id = read_32bitBE(0x4,streamFile); + /* block_align/loop_type? = read_32bitBE(header_offset+0x14,streamFile);*/ /* 00/40 when no loop, 11/50/51/71 */ + + loop_start = read_32bitBE(header_offset+0x18,streamFile); + loop_end = read_32bitBE(header_offset+0x1C,streamFile); /* loop duration */ + loop_flag = loop_start != 0xFFFFFFFF; + if (loop_flag) { + if (loop_end==0xFFFFFFFF) {/* not seen */ + loop_end = data_size; + } else { + loop_end = loop_start + loop_end; /* usually equals data_size but not always */ + if ( loop_end > data_size)/* not seen */ + loop_end = data_size; + } + } + + channel_count = read_32bitBE(header_offset+0x8,streamFile); + codec_id = read_32bitBE(header_offset+0x4,streamFile); + /* build the VGMSTREAM */ vgmstream = allocate_vgmstream(channel_count,loop_flag); if (!vgmstream) goto fail; /* fill in the vital statistics */ - vgmstream->channels = channel_count; + vgmstream->channels = channel_count; - /* Sample rate hack for strange files that don't have a specified frequency */ - if (read_32bitBE(0x10,streamFile)==0x00000000) + /* Sample rate hack for strange files that don't have a specified frequency */ + if (read_32bitBE(header_offset+0x10,streamFile)==0x00000000) vgmstream->sample_rate = 48000; else - vgmstream->sample_rate = read_32bitBE(0x10,streamFile); + vgmstream->sample_rate = read_32bitBE(header_offset+0x10,streamFile); - start_offset = 0x40; + + vgmstream->meta_type = meta_PS3_MSF; switch (codec_id) { case 0x0: /* PCM (Big Endian) */ { vgmstream->coding_type = coding_PCM16BE; - vgmstream->num_samples = read_32bitBE(0x0C,streamFile)/2/channel_count; + vgmstream->num_samples = data_size/2/channel_count; if (loop_flag){ vgmstream->loop_start_sample = loop_start/2/channel_count; @@ -74,12 +101,7 @@ VGMSTREAM * init_vgmstream_ps3_msf(STREAMFILE *streamFile) { case 0x3: /* PSx ADPCM */ { vgmstream->coding_type = coding_PSX; - vgmstream->num_samples = read_32bitBE(0x0C,streamFile)*28/16/channel_count; - - if (vgmstream->num_samples == 0xFFFFFFFF) - { - vgmstream->num_samples = (fileLength - start_offset)*28/16/channel_count; - } + vgmstream->num_samples = data_size*28/16/channel_count; if (loop_flag) { @@ -94,10 +116,61 @@ VGMSTREAM * init_vgmstream_ps3_msf(STREAMFILE *streamFile) { else if (channel_count > 1) { vgmstream->layout_type = layout_interleave; - vgmstream->interleave_block_size = 0x10; // read_32bitBE(0x14,streamFile); + vgmstream->interleave_block_size = 0x10; } } break; +#ifdef VGM_USE_FFMPEG + case 0x4: /* ATRAC3 (frame size 96) */ + case 0x5: /* ATRAC3 (frame size 152) */ + case 0x6: /* ATRAC3 (frame size 192) */ + /* delegate to FFMpeg, it can parse MSF files */ + ffmpeg_data = init_ffmpeg_offset(streamFile, header_offset, streamFile->get_size(streamFile) ); + if ( !ffmpeg_data ) goto fail; + + vgmstream->coding_type = coding_FFmpeg; + vgmstream->layout_type = layout_none; + vgmstream->meta_type = meta_FFmpeg; + vgmstream->codec_data = ffmpeg_data; + + vgmstream->num_samples = ffmpeg_data->totalFrames; + if (loop_flag) { + int atrac3_frame = 1024; + int block_align = (codec_id == 0x4 ? 96 : codec_id == 0x5 ? 152 : 192) * channel_count; + /* int block_align = ffmpeg_data->codecCtx->block_align; *//* is this always set? */ + vgmstream->loop_start_sample = (loop_start / block_align) * atrac3_frame; + vgmstream->loop_end_sample = (loop_end / block_align) * atrac3_frame; + } + + break; +#endif +#if defined(VGM_USE_FFMPEG) && !defined(VGM_USE_MPEG) + case 0x7: /* MPEG */ + /* delegate to FFMpeg, it can parse MSF files */ + ffmpeg_data = init_ffmpeg_offset(streamFile, header_offset, streamFile->get_size(streamFile) ); + if ( !ffmpeg_data ) goto fail; + + vgmstream->coding_type = coding_FFmpeg; + vgmstream->layout_type = layout_none; + vgmstream->meta_type = meta_FFmpeg; + vgmstream->codec_data = ffmpeg_data; + + /* todo check CBR better (bitrate=0?) */ + + /* vgmstream->num_samples = ffmpeg_data->totalFrames; */ /* duration is not set/innacurate for MP3 in FFMpeg */ + vgmstream->num_samples = (int64_t)data_size * ffmpeg_data->sampleRate * 8 / ffmpeg_data->bitrate; + if (loop_flag) { + int frame_size = ffmpeg_data->codecCtx->frame_size; + vgmstream->loop_start_sample = (int64_t)loop_start * ffmpeg_data->sampleRate * 8 / ffmpeg_data->bitrate; + vgmstream->loop_start_sample -= vgmstream->loop_start_sample==frame_size ? frame_size + : vgmstream->loop_start_sample % frame_size; + vgmstream->loop_end_sample = (int64_t)loop_end * ffmpeg_data->sampleRate * 8 / ffmpeg_data->bitrate; + vgmstream->loop_end_sample -= vgmstream->loop_end_sample==frame_size ? frame_size + : vgmstream->loop_end_sample % frame_size; + } + + break; +#endif #ifdef VGM_USE_MPEG case 0x7: /* MPEG */ { @@ -114,7 +187,7 @@ VGMSTREAM * init_vgmstream_ps3_msf(STREAMFILE *streamFile) { vgmstream->coding_type = ct; vgmstream->layout_type = layout_mpeg; if (mi.vbr != MPG123_CBR) goto fail; - vgmstream->num_samples = mpeg_bytes_to_samples(read_32bitBE(0xC,streamFile), &mi); + vgmstream->num_samples = mpeg_bytes_to_samples(data_size, &mi); vgmstream->num_samples -= vgmstream->num_samples%576; if (loop_flag) { vgmstream->loop_start_sample = mpeg_bytes_to_samples(loop_start, &mi); @@ -130,7 +203,6 @@ VGMSTREAM * init_vgmstream_ps3_msf(STREAMFILE *streamFile) { goto fail; } - vgmstream->meta_type = meta_PS3_MSF; /* open the file for reading */ { @@ -151,6 +223,12 @@ VGMSTREAM * init_vgmstream_ps3_msf(STREAMFILE *streamFile) { /* clean up anything we may have opened */ fail: +#ifdef VGM_USE_FFMPEG + if (ffmpeg_data) { + free_ffmpeg(ffmpeg_data); + vgmstream->codec_data = NULL; + } +#endif if (vgmstream) close_vgmstream(vgmstream); return NULL; } diff --git a/src/meta/riff.c b/src/meta/riff.c index fd323220..e7d292e0 100644 --- a/src/meta/riff.c +++ b/src/meta/riff.c @@ -571,7 +571,10 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) { /* clean up anything we may have opened */ fail: #ifdef VGM_USE_FFMPEG - if (ffmpeg_data) free_ffmpeg(ffmpeg_data); + if (ffmpeg_data) { + free_ffmpeg(ffmpeg_data); + vgmstream->codec_data = NULL; + } #endif if (vgmstream) close_vgmstream(vgmstream); return NULL; diff --git a/src/vgmstream.c b/src/vgmstream.c index 2da1c841..b11bc552 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -1086,7 +1086,7 @@ int get_vgmstream_samples_per_frame(VGMSTREAM * vgmstream) { ffmpeg_codec_data *data = (ffmpeg_codec_data *) vgmstream->codec_data; if (vgmstream->codec_data) { int64_t samplesRemain = data->totalFrames - data->framesRead; - return samplesRemain > 2048 ? 2048 : samplesRemain; + return samplesRemain > data->samplesPerBlock ? data->samplesPerBlock : samplesRemain; } return 0; } @@ -1792,6 +1792,7 @@ int vgmstream_do_loop(VGMSTREAM * vgmstream) { ffmpeg_codec_data *data = (ffmpeg_codec_data *)(vgmstream->codec_data); int64_t ts; +#ifndef VGM_USE_FFMPEG_ACCURATE_LOOPING /* Seek to loop start by timestamp (closest frame) + adjust skipping some samples */ /* FFmpeg seeks by ts by design (since not all containers can accurately skip to a frame). */ /* TODO: this seems to be off by +-1 frames in some cases */ @@ -1807,6 +1808,9 @@ int vgmstream_do_loop(VGMSTREAM * vgmstream) { data->framesRead = (int)ts; ts = data->framesRead * (data->formatCtx->duration) / data->totalFrames; + avformat_seek_file(data->formatCtx, -1, ts - 1000, ts, ts, AVSEEK_FLAG_ANY); + avcodec_flush_buffers(data->codecCtx); +#endif /* ifndef VGM_USE_FFMPEG_ACCURATE_LOOPING */ #ifdef VGM_USE_FFMPEG_ACCURATE_LOOPING /* Start from 0 and discard samples until loop_start for accurate looping (slower but not too noticeable) */ @@ -1815,10 +1819,10 @@ int vgmstream_do_loop(VGMSTREAM * vgmstream) { data->samplesToDiscard = vgmstream->loop_start_sample; data->framesRead = 0; ts = 0; -#endif /* VGM_USE_FFMPEG_ACCURATE_LOOPING */ - avformat_seek_file(data->formatCtx, -1, ts - 1000, ts, ts, AVSEEK_FLAG_ANY); + avformat_seek_file(data->formatCtx, -1, ts, ts, ts, AVSEEK_FLAG_ANY); avcodec_flush_buffers(data->codecCtx); +#endif /* ifdef VGM_USE_FFMPEG_ACCURATE_LOOPING */ data->readNextPacket = 1; data->bytesConsumedFromDecodedFrame = INT_MAX; @@ -1910,7 +1914,7 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { return; } - snprintf(temp,TEMPSIZE,"sample rate %d Hz\n" + snprintf(temp,TEMPSIZE,"sample rate: %d Hz\n" "channels: %d\n", vgmstream->sample_rate,vgmstream->channels); concatn(length,desc,temp); @@ -2129,11 +2133,14 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { { ffmpeg_codec_data *data = (ffmpeg_codec_data *) vgmstream->codec_data; if (vgmstream->codec_data) { - if (data->codec) { + if (data->codec && data->codec->long_name) { snprintf(temp,TEMPSIZE,data->codec->long_name); } + else if (data->codec && data->codec->name) { + snprintf(temp,TEMPSIZE,data->codec->name); + } else { - snprintf(temp,TEMPSIZE,"FFmpeg"); + snprintf(temp,TEMPSIZE,"FFmpeg (unknown codec)"); } } else { diff --git a/src/vgmstream.h b/src/vgmstream.h index b45e7f4c..8baa0384 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -13,7 +13,12 @@ enum { PATH_LIMIT = 32768 }; * removing these defines (and the references to the libraries in the * Makefile) */ #define VGM_USE_VORBIS + +/* can be disabled to decode with FFmpeg instead */ +#ifndef VGM_DISABLE_MPEG #define VGM_USE_MPEG +#endif + /* disabled by default, defined for builds that support it */ //#define VGM_USE_G7221 //#define VGM_USE_G719 @@ -856,6 +861,7 @@ typedef struct { // inserted header, ie. fake RIFF header uint8_t *header_insert_block; + // header/fake RIFF over the real (parseable by FFmpeg) file start uint64_t header_size; // stream info @@ -869,6 +875,8 @@ typedef struct { // Intermediate buffer uint8_t *sampleBuffer; + // max samples a block can held (can be less or more than samples per decoded frame) + size_t samplesPerBlock; // FFmpeg context used for metadata AVCodec *codec; diff --git a/test/Makefile.mingw b/test/Makefile.mingw index c8a7138b..dbcebc5d 100644 --- a/test/Makefile.mingw +++ b/test/Makefile.mingw @@ -1,20 +1,29 @@ # optional parts -export ENABLE_FFMPEG=0 -ifeq ($(ENABLE_FFMPEG),1) -export FFMPEG_CC=-DVGM_USE_FFMPEG -I../../ffmpeg-dev/include -export FFMPEG_LD=-L../../ffmpeg-dev/lib -lavcodec -lavformat -lavutil +VGM_ENABLE_FFMPEG=0 +ifeq ($(VGM_ENABLE_FFMPEG),1) +FFMPEG_CC=-DVGM_USE_FFMPEG -DVGM_USE_FFMPEG_ACCURATE_LOOPING -I../../vgmstream-ffmpeg/include +FFMPEG_LD=-L../../vgmstream-ffmpeg/lib -lavcodec -lavformat -lavutil endif -export ENABLE_MAIATRAC3PLUS=1 -ifeq ($(ENABLE_MAIATRAC3PLUS),1) -export MAT3P_CC=-DVGM_USE_MAIATRAC3PLUS -export MAT3P_LD=-lat3plusdecoder +VGM_ENABLE_MAIATRAC3PLUS=1 +ifeq ($(VGM_ENABLE_MAIATRAC3PLUS),1) +MAT3P_CC=-DVGM_USE_MAIATRAC3PLUS +MAT3P_LD=-lat3plusdecoder endif +#MPEG_CC=-DVGM_USE_MPEG +MPEG_LD=-lmpg123-0 +VGM_DISABLE_MPEG=0 +ifeq ($(VGM_DISABLE_MPEG),1) +MPEG_CC=-DVGM_DISABLE_MPEG +MPEG_LD= +endif + + # config export SHELL = /bin/sh -export CFLAGS=-Wall -O3 -DVGM_USE_G7221 -DVGM_USE_G719 $(MAT3P_CC) -DVAR_ARRAYS -I../ext_includes $(FFMPEG_CC) -export LDFLAGS=-L../src -L../ext_libs -lvgmstream -lvorbis -lmpg123-0 -lg7221_decode -lg719_decode $(MAT3P_LD) -lm $(FFMPEG_LD) +export CFLAGS=-Wall -O3 $(MPEG_CC) -DVGM_USE_G7221 -DVGM_USE_G719 $(MAT3P_CC) -DVAR_ARRAYS -I../ext_includes $(FFMPEG_CC) +export LDFLAGS=-L../src -L../ext_libs -lvgmstream -lvorbis $(MPEG_LD) -lg7221_decode -lg719_decode $(MAT3P_LD) -lm $(FFMPEG_LD) #export CC=i586-mingw32msvc-gcc #export AR=i586-mingw32msvc-ar #export STRIP=i586-mingw32msvc-strip diff --git a/winamp/Makefile b/winamp/Makefile index 99abebf5..ef4c00e1 100644 --- a/winamp/Makefile +++ b/winamp/Makefile @@ -1,25 +1,33 @@ # optional parts -export ENABLE_FFMPEG=0 -ifeq ($(ENABLE_FFMPEG),1) -export FFMPEG_CC=-DVGM_USE_FFMPEG -I../../ffmpeg-dev/include -export FFMPEG_LD=-L../../ffmpeg-dev/lib -lavcodec -lavformat -lavutil +VGM_ENABLE_FFMPEG=0 +ifeq ($(VGM_ENABLE_FFMPEG),1) +FFMPEG_CC=-DVGM_USE_FFMPEG -DVGM_USE_FFMPEG_ACCURATE_LOOPING -I../../vgmstream-ffmpeg/include +FFMPEG_LD=-L../../vgmstream-ffmpeg/lib -lavcodec -lavformat -lavutil endif -export ENABLE_MAIATRAC3PLUS=1 -ifeq ($(ENABLE_MAIATRAC3PLUS),1) -export MAT3P_CC=-DVGM_USE_MAIATRAC3PLUS -export MAT3P_LD=-lat3plusdecoder +VGM_ENABLE_MAIATRAC3PLUS=1 +ifeq ($(VGM_ENABLE_MAIATRAC3PLUS),1) +MAT3P_CC=-DVGM_USE_MAIATRAC3PLUS +MAT3P_LD=-lat3plusdecoder endif +#MPEG_CC=-DVGM_USE_MPEG +MPEG_LD=-lmpg123-0 +VGM_DISABLE_MPEG=0 +ifeq ($(VGM_DISABLE_MPEG),1) +MPEG_CC=-DVGM_DISABLE_MPEG +MPEG_LD= +endif + + # config export SHELL = /bin/sh -export CFLAGS=-Wall -O3 -DVGM_USE_G7221 -DVGM_USE_G719 $(MAT3P_CC) -DWIN32 -DUSE_ALLOCA -I../ext_includes $(FFMPEG_CC) -export LDFLAGS=-L../src -L../ext_libs -lvgmstream -lvorbis -lmpg123-0 -lg7221_decode -lg719_decode $(MAT3P_LD) -lm $(FFMPEG_LD) +export CFLAGS=-Wall -O3 $(MPEG_CC) -DVGM_USE_G7221 -DVGM_USE_G719 $(MAT3P_CC) -DWIN32 -DUSE_ALLOCA -I../ext_includes $(FFMPEG_CC) +export LDFLAGS=-L../src -L../ext_libs -lvgmstream -lvorbis $(MPEG_LD) -lg7221_decode -lg719_decode $(MAT3P_LD) -lm $(FFMPEG_LD) export CC=i586-mingw32msvc-gcc export AR=i586-mingw32msvc-ar export STRIP=i586-mingw32msvc-strip export WINDRES=i586-mingw32msvc-windres - #export CC=i686-w64-mingw32-gcc #export AR=i686-w64-mingw32-ar #export STRIP=i686-w64-mingw32-strip