From 7e520162a3f61a33285a07fbb673316a6774c6b2 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sun, 8 Jan 2017 02:54:18 +0100 Subject: [PATCH] FFmpeg: remove ACCURATE_LOOPING flag now it's battle-tested It's fast enough and the older looping code would need to be redone anyway --- fb2k/foo_input_vgmstream.vcproj | 4 ++-- src/coding/ffmpeg_decoder.c | 33 ++------------------------------- src/libvgmstream.vcproj | 4 ++-- src/libvgmstream.vcxproj | 4 ++-- test/Makefile.mingw | 2 +- winamp/Makefile | 2 +- xmp-vgmstream/Makefile | 2 +- 7 files changed, 11 insertions(+), 40 deletions(-) diff --git a/fb2k/foo_input_vgmstream.vcproj b/fb2k/foo_input_vgmstream.vcproj index 7b1ed887..382cf138 100644 --- a/fb2k/foo_input_vgmstream.vcproj +++ b/fb2k/foo_input_vgmstream.vcproj @@ -42,7 +42,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="../ext_includes" - PreprocessorDefinitions="WIN32;VGM_USE_FFMPEG;VGM_USE_FFMPEG_ACCURATE_LOOPING;VGM_USE_G719;VGM_USE_G7221;_DEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;" + PreprocessorDefinitions="WIN32;VGM_USE_FFMPEG;VGM_USE_G719;VGM_USE_G7221;_DEBUG;_WINDOWS;_USRDLL;IN_VGMSTREAM_EXPORTS;" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -120,7 +120,7 @@ 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 */ - ts = num_sample; - if (ts >= data->sampleRate * 2) { - data->samplesToDiscard = data->sampleRate * 2; - ts -= data->samplesToDiscard; - } - else { - data->samplesToDiscard = (int)ts; - ts = 0; - } - - /* todo fix this properly */ - if (data->totalSamples) { - ts = (int)ts * (data->formatCtx->duration) / data->totalSamples; - } else { - data->samplesToDiscard = num_sample; - ts = 0; - } - - avformat_seek_file(data->formatCtx, data->streamIndex, 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) */ - /* We could also seek by offset (AVSEEK_FLAG_BYTE) to the frame closest to the loop then discard - * some samples, which is fast but would need calculations per format / when frame size is not constant */ + /* Start from 0 and discard samples until loop_start (slower but not too noticeable) */ + /* Due to various FFmpeg quirks seeking to a sample is erratic in many formats (would need extra steps) */ data->samplesToDiscard = num_sample; ts = 0; avformat_seek_file(data->formatCtx, data->streamIndex, 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; diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index 563fe21d..622ed96d 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -41,7 +41,7 @@ Name="VCCLCompilerTool" Optimization="0" AdditionalIncludeDirectories="../ext_includes" - PreprocessorDefinitions="WIN32;VGM_USE_FFMPEG;VGM_USE_FFMPEG_ACCURATE_LOOPING;VGM_USE_G7221;VGM_USE_G719;USE_ALLOCA;_DEBUG;_LIB;" + PreprocessorDefinitions="WIN32;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_G719;USE_ALLOCA;_DEBUG;_LIB;" MinimalRebuild="true" BasicRuntimeChecks="3" RuntimeLibrary="3" @@ -103,7 +103,7 @@ Disabled ../ext_includes;../../qaac/mp4v2/include;../../fdk-aac/libSYS/include;../../fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) - WIN32;VGM_USE_FFMPEG;VGM_USE_FFMPEG_ACCURATE_LOOPING;VGM_USE_G7221;VGM_USE_G719;VGM_USE_MP4V2;VGM_USE_FDKAAC;VGM_USE_MAIATRAC3PLUS;USE_ALLOCA;_DEBUG;_LIB;%(PreprocessorDefinitions) + WIN32;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_G719;VGM_USE_MP4V2;VGM_USE_FDKAAC;VGM_USE_MAIATRAC3PLUS;USE_ALLOCA;_DEBUG;_LIB;%(PreprocessorDefinitions) true EnableFastChecks MultiThreadedDebug @@ -71,7 +71,7 @@ ../ext_includes;../../qaac/mp4v2/include;../../fdk-aac/libSYS/include;../../fdk-aac/libAACdec/include;%(AdditionalIncludeDirectories) - _WIN32_WINNT=0x501;WIN32;VGM_USE_FFMPEG;VGM_USE_FFMPEG_ACCURATE_LOOPING;VGM_USE_G7221;VGM_USE_G719;VGM_USE_MP4V2;VGM_USE_FDKAAC;VGM_USE_MAIATRAC3PLUS;USE_ALLOCA;NDEBUG;_LIB;%(PreprocessorDefinitions) + _WIN32_WINNT=0x501;WIN32;VGM_USE_FFMPEG;VGM_USE_G7221;VGM_USE_G719;VGM_USE_MP4V2;VGM_USE_FDKAAC;VGM_USE_MAIATRAC3PLUS;USE_ALLOCA;NDEBUG;_LIB;%(PreprocessorDefinitions) MultiThreaded diff --git a/test/Makefile.mingw b/test/Makefile.mingw index 752f0654..5fc4578f 100644 --- a/test/Makefile.mingw +++ b/test/Makefile.mingw @@ -1,7 +1,7 @@ # optional parts VGM_ENABLE_FFMPEG=1 ifeq ($(VGM_ENABLE_FFMPEG),1) -FFMPEG_CC=-DVGM_USE_FFMPEG -DVGM_USE_FFMPEG_ACCURATE_LOOPING +FFMPEG_CC=-DVGM_USE_FFMPEG FFMPEG_LD=-lavcodec -lavformat -lavutil endif diff --git a/winamp/Makefile b/winamp/Makefile index 6817686c..bd1f96ab 100644 --- a/winamp/Makefile +++ b/winamp/Makefile @@ -1,7 +1,7 @@ # optional parts VGM_ENABLE_FFMPEG=1 ifeq ($(VGM_ENABLE_FFMPEG),1) -FFMPEG_CC=-DVGM_USE_FFMPEG -DVGM_USE_FFMPEG_ACCURATE_LOOPING +FFMPEG_CC=-DVGM_USE_FFMPEG FFMPEG_LD=-lavcodec -lavformat -lavutil endif diff --git a/xmp-vgmstream/Makefile b/xmp-vgmstream/Makefile index 03ca7116..48d2f9c0 100644 --- a/xmp-vgmstream/Makefile +++ b/xmp-vgmstream/Makefile @@ -1,7 +1,7 @@ # optional parts VGM_ENABLE_FFMPEG=1 ifeq ($(VGM_ENABLE_FFMPEG),1) -FFMPEG_CC=-DVGM_USE_FFMPEG -DVGM_USE_FFMPEG_ACCURATE_LOOPING +FFMPEG_CC=-DVGM_USE_FFMPEG FFMPEG_LD=-lavcodec -lavformat -lavutil endif