mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-25 23:23:07 +00:00
106 lines
3.8 KiB
Diff
106 lines
3.8 KiB
Diff
|
commit 89c4e8d34ab77c3322f097b91fd9de22cbea7a37
|
||
|
Author: Thomas Goyne <plorkyeran@aegisub.org>
|
||
|
Date: Wed Nov 21 16:41:05 2018 -0800
|
||
|
|
||
|
Update ffmpeg and ffms2
|
||
|
|
||
|
diff --git a/src/video_provider_ffmpegsource.cpp b/src/video_provider_ffmpegsource.cpp
|
||
|
index 8bd68fbbf..f4ed6a2f2 100644
|
||
|
--- a/src/video_provider_ffmpegsource.cpp
|
||
|
+++ b/src/video_provider_ffmpegsource.cpp
|
||
|
@@ -44,6 +44,23 @@
|
||
|
#include <libaegisub/make_unique.h>
|
||
|
|
||
|
namespace {
|
||
|
+typedef enum AGI_ColorSpaces {
|
||
|
+ AGI_CS_RGB = 0,
|
||
|
+ AGI_CS_BT709 = 1,
|
||
|
+ AGI_CS_UNSPECIFIED = 2,
|
||
|
+ AGI_CS_FCC = 4,
|
||
|
+ AGI_CS_BT470BG = 5,
|
||
|
+ AGI_CS_SMPTE170M = 6,
|
||
|
+ AGI_CS_SMPTE240M = 7,
|
||
|
+ AGI_CS_YCOCG = 8,
|
||
|
+ AGI_CS_BT2020_NCL = 9,
|
||
|
+ AGI_CS_BT2020_CL = 10,
|
||
|
+ AGI_CS_SMPTE2085 = 11,
|
||
|
+ AGI_CS_CHROMATICITY_DERIVED_NCL = 12,
|
||
|
+ AGI_CS_CHROMATICITY_DERIVED_CL = 13,
|
||
|
+ AGI_CS_ICTCP = 14
|
||
|
+} AGI_ColorSpaces;
|
||
|
+
|
||
|
/// @class FFmpegSourceVideoProvider
|
||
|
/// @brief Implements video loading through the FFMS library.
|
||
|
class FFmpegSourceVideoProvider final : public VideoProvider, FFmpegSourceProvider {
|
||
|
@@ -78,7 +95,7 @@ public:
|
||
|
if (matrix == RealColorSpace)
|
||
|
FFMS_SetInputFormatV(VideoSource, CS, CR, FFMS_GetPixFmt(""), nullptr);
|
||
|
else if (matrix == "TV.601")
|
||
|
- FFMS_SetInputFormatV(VideoSource, FFMS_CS_BT470BG, CR, FFMS_GetPixFmt(""), nullptr);
|
||
|
+ FFMS_SetInputFormatV(VideoSource, AGI_CS_BT470BG, CR, FFMS_GetPixFmt(""), nullptr);
|
||
|
else
|
||
|
return;
|
||
|
ColorSpace = matrix;
|
||
|
@@ -103,16 +120,16 @@ std::string colormatrix_description(int cs, int cr) {
|
||
|
std::string str = cr == FFMS_CR_JPEG ? "PC" : "TV";
|
||
|
|
||
|
switch (cs) {
|
||
|
- case FFMS_CS_RGB:
|
||
|
+ case AGI_CS_RGB:
|
||
|
return "None";
|
||
|
- case FFMS_CS_BT709:
|
||
|
+ case AGI_CS_BT709:
|
||
|
return str + ".709";
|
||
|
- case FFMS_CS_FCC:
|
||
|
+ case AGI_CS_FCC:
|
||
|
return str + ".FCC";
|
||
|
- case FFMS_CS_BT470BG:
|
||
|
- case FFMS_CS_SMPTE170M:
|
||
|
+ case AGI_CS_BT470BG:
|
||
|
+ case AGI_CS_SMPTE170M:
|
||
|
return str + ".601";
|
||
|
- case FFMS_CS_SMPTE240M:
|
||
|
+ case AGI_CS_SMPTE240M:
|
||
|
return str + ".240M";
|
||
|
default:
|
||
|
throw VideoOpenError("Unknown video color space");
|
||
|
@@ -206,8 +223,10 @@ void FFmpegSourceVideoProvider::LoadVideo(agi::fs::path const& filename, std::st
|
||
|
|
||
|
// set thread count
|
||
|
int Threads = OPT_GET("Provider/Video/FFmpegSource/Decoding Threads")->GetInt();
|
||
|
+#if FFMS_VERSION < ((2 << 24) | (30 << 16) | (0 << 8) | 0)
|
||
|
if (FFMS_GetVersion() < ((2 << 24) | (17 << 16) | (2 << 8) | 1) && FFMS_GetSourceType(Index) == FFMS_SOURCE_LAVF)
|
||
|
Threads = 1;
|
||
|
+#endif
|
||
|
|
||
|
// set seekmode
|
||
|
// TODO: give this its own option?
|
||
|
@@ -235,18 +254,22 @@ 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)
|
||
|
- CS = Width > 1024 || Height >= 600 ? FFMS_CS_BT709 : FFMS_CS_BT470BG;
|
||
|
+ if (CS == AGI_CS_UNSPECIFIED)
|
||
|
+ CS = Width > 1024 || Height >= 600 ? AGI_CS_BT709 : AGI_CS_BT470BG;
|
||
|
RealColorSpace = ColorSpace = colormatrix_description(CS, CR);
|
||
|
|
||
|
#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))
|
||
|
+ if (CS != AGI_CS_RGB && CS != AGI_CS_BT470BG && ColorSpace != colormatrix && (colormatrix == "TV.601" || OPT_GET("Video/Force BT.601")->GetBool())) {
|
||
|
+ CS = AGI_CS_BT470BG;
|
||
|
+ ColorSpace = colormatrix_description(AGI_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);
|
||
|
- ColorSpace = colormatrix_description(FFMS_CS_BT470BG, CR);
|
||
|
}
|
||
|
#endif
|