From 4dd76012cd162f3738c141f1a963b69554fceb96 Mon Sep 17 00:00:00 2001 From: Thomas Goyne Date: Thu, 23 Jan 2014 07:36:37 -0800 Subject: [PATCH] Move YCbCr Matrix header setting from subtitle save to video open --- aegisub/src/video_context.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/aegisub/src/video_context.cpp b/aegisub/src/video_context.cpp index cd6f01c63..c792270f3 100644 --- a/aegisub/src/video_context.cpp +++ b/aegisub/src/video_context.cpp @@ -126,6 +126,14 @@ void VideoContext::SetVideo(const agi::fs::path &filename) { video_provider = provider->GetVideoProvider(); video_filename = filename; + // Video provider handles the case where matrix is different but + // compatible, so no need to handle it here + auto matrix = video_provider->GetColorSpace(); + if (!matrix.empty() && matrix != context->ass->GetScriptInfo("YCbCr Matrix")) { + context->ass->SetScriptInfo("YCbCr Matrix", matrix); + commit_subs = true; + } + // Check that the script resolution matches the video resolution int sx = context->ass->GetScriptInfoAsInt("PlayResX"); int sy = context->ass->GetScriptInfoAsInt("PlayResY"); @@ -253,9 +261,6 @@ void VideoContext::OnSubtitlesSave() { ar = std::to_string((int)ar_type); context->ass->SetScriptInfo("Video File", config::path->MakeRelative(video_filename, "?script").generic_string()); - auto matrix = video_provider->GetColorSpace(); - if (!matrix.empty()) - context->ass->SetScriptInfo("YCbCr Matrix", matrix); context->ass->SaveUIState("Video Aspect Ratio", ar); context->ass->SaveUIState("Video Position", std::to_string(frame_n)); }