From 366baff2f81d03e6f4e3faf43815b51db140cd07 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Wed, 7 Mar 2012 04:25:46 +0000 Subject: [PATCH] Add option to force all video opened with FFMS2 to BT.601 for VSFilter compatibility Originally committed to SVN as r6535. --- aegisub/src/libresrc/default_config.json | 1 + aegisub/src/preferences.cpp | 7 +++++++ aegisub/src/video_context.cpp | 1 + aegisub/src/video_provider_ffmpegsource.cpp | 12 +++++++++++- 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/aegisub/src/libresrc/default_config.json b/aegisub/src/libresrc/default_config.json index 1d54c8b4d..1332e48ec 100644 --- a/aegisub/src/libresrc/default_config.json +++ b/aegisub/src/libresrc/default_config.json @@ -344,6 +344,7 @@ }, "FFmpegSource" : { "Decoding Threads" : -1, + "Force BT.601" : false, "Unsafe Seeking" : false } } diff --git a/aegisub/src/preferences.cpp b/aegisub/src/preferences.cpp index 589c22a07..5118614e9 100644 --- a/aegisub/src/preferences.cpp +++ b/aegisub/src/preferences.cpp @@ -59,6 +59,10 @@ #include "audio_player_portaudio.h" #endif +#ifdef WITH_FFMS2 +#include +#endif + static wxArrayString vec_to_arrstr(std::vector const& vec) { wxArrayString arrstr; transform(vec.begin(), vec.end(), std::back_inserter(arrstr), &lagi_wxString); @@ -589,6 +593,9 @@ Advanced_Video::Advanced_Video(wxTreebook *book, Preferences *parent): OptionPag OptionAdd(ffms, _("Decoding threads"), "Provider/Video/FFmpegSource/Decoding Threads"); OptionAdd(ffms, _("Enable unsafe seeking"), "Provider/Video/FFmpegSource/Unsafe Seeking"); +#if FFMS_VERSION >= ((2 << 24) | (17 << 16) | (1 << 8) | 0) + OptionAdd(ffms, _("Force BT.601"), "Provider/Video/FFmpegSource/Force BT.601"); +#endif #endif SetSizerAndFit(sizer); diff --git a/aegisub/src/video_context.cpp b/aegisub/src/video_context.cpp index 8d6e8897c..a60965351 100644 --- a/aegisub/src/video_context.cpp +++ b/aegisub/src/video_context.cpp @@ -94,6 +94,7 @@ VideoContext::VideoContext() OPT_SUB("Provider/Video/FFmpegSource/Decoding Threads", &VideoContext::Reload, this); OPT_SUB("Provider/Video/FFmpegSource/Unsafe Seeking", &VideoContext::Reload, this); + OPT_SUB("Provider/Video/FFmpegSource/Force BT.601", &VideoContext::Reload, this); } VideoContext::~VideoContext () { diff --git a/aegisub/src/video_provider_ffmpegsource.cpp b/aegisub/src/video_provider_ffmpegsource.cpp index 5def6d435..0f7515df7 100644 --- a/aegisub/src/video_provider_ffmpegsource.cpp +++ b/aegisub/src/video_provider_ffmpegsource.cpp @@ -179,7 +179,17 @@ void FFmpegSourceVideoProvider::LoadVideo(wxString filename) { else DAR = double(Width) / Height; - switch (TempFrame->ColorSpace) { + int CS = TempFrame->ColorSpace; +#if FFMS_VERSION >= ((2 << 24) | (17 << 16) | (1 << 8) | 0) + if (CS != FFMS_CS_RGB && CS != FFMS_CS_BT470BG && OPT_GET("Provider/Video/FFmpegSource/Force BT.601")->GetBool()) { + if (FFMS_SetInputFormatV(VideoSource, FFMS_CS_BT470BG, FFMS_CR_MPEG, FFMS_GetPixFmt(""), &ErrInfo)) + throw VideoOpenError(std::string("Failed to set input format: ") + ErrInfo.Buffer); + + CS = FFMS_CS_BT470BG; + } +#endif + + switch (CS) { case FFMS_CS_RGB: ColorSpace = "RGB"; break; case FFMS_CS_BT709: ColorSpace = "BT.709"; break; case FFMS_CS_BT470BG: ColorSpace = "BT.601"; break;