Properly set colorspace when loading video

FFMS2 originally would automatically attempt to guess the color space
if not manually specified, but this was removed in
7c2e08109d
and Aegisub never adapted to the change
This commit is contained in:
Ryan Lucia 2017-02-15 11:21:39 -05:00 committed by Thomas Goyne
parent 1042226531
commit 3e2c165852
1 changed files with 7 additions and 3 deletions

View File

@ -235,7 +235,7 @@ void FFmpegSourceVideoProvider::LoadVideo(agi::fs::path const& filename, std::st
else
DAR = double(Width) / Height;
CS = TempFrame->ColorSpace;
int VideoCS = CS = TempFrame->ColorSpace;
CR = TempFrame->ColorRange;
if (CS == FFMS_CS_UNSPECIFIED)
@ -244,10 +244,14 @@ void FFmpegSourceVideoProvider::LoadVideo(agi::fs::path const& filename, std::st
#if FFMS_VERSION >= ((2 << 24) | (17 << 16) | (1 << 8) | 0)
if (CS != FFMS_CS_RGB && CS != FFMS_CS_BT470BG && ColorSpace != colormatrix && (colormatrix == "TV.601" || OPT_GET("Video/Force BT.601")->GetBool())) {
if (FFMS_SetInputFormatV(VideoSource, FFMS_CS_BT470BG, CR, FFMS_GetPixFmt(""), &ErrInfo))
throw VideoOpenError(std::string("Failed to set input format: ") + ErrInfo.Buffer);
CS = FFMS_CS_BT470BG;
ColorSpace = colormatrix_description(FFMS_CS_BT470BG, CR);
}
if (CS != VideoCS) {
if (FFMS_SetInputFormatV(VideoSource, CS, CR, FFMS_GetPixFmt(""), &ErrInfo))
throw VideoOpenError(std::string("Failed to set input format: ") + ErrInfo.Buffer);
}
#endif
const int TargetFormat[] = { FFMS_GetPixFmt("bgra"), -1 };