summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--debian/changelog8
-rw-r--r--debian/patches/remove-unconditional-Wno-c++11-narrowing.patch22
-rw-r--r--debian/patches/series4
-rw-r--r--debian/patches/update-ffms2-agi-colorspaces.patch33
-rw-r--r--debian/patches/update-ffms2-doindexing2.patch256
-rw-r--r--debian/patches/update-ffms2-x11-none.patch22
-rw-r--r--debian/patches/update-ffms2.patch108
-rw-r--r--src/Makefile2
-rw-r--r--src/audio_provider_ffmpegsource.cpp40
-rw-r--r--src/ffmpegsource_common.cpp58
-rw-r--r--src/ffmpegsource_common.h28
-rw-r--r--src/video_provider_ffmpegsource.cpp61
13 files changed, 560 insertions, 84 deletions
diff --git a/configure.ac b/configure.ac
index 0c0d13a..c8bebf0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -150,7 +150,7 @@ AS_IF([test x$enable_compiler_flags != xno], [
CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-parameter -std=gnu99 -pipe -g"
CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wno-unused-parameter -fno-strict-aliasing -pipe -g"
AC_CXX_FLAG([-std=c++11])
- AC_CXX_FLAG([-Wno-c++11-narrowing])
+ AC_CXX_FLAG([-Wno-narrowing])
AC_C_FLAG([-Wno-unused-local-typedefs])
AC_CXX_FLAG([-Wno-unused-local-typedefs])
diff --git a/debian/changelog b/debian/changelog
index 5552336..9c61256 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+aegisub (3.2.2+dfsg-6.3) unstable; urgency=medium
+
+ * Non-maintainer upload.
+ * Replace -Wno-c++11-narrowing with -Wno-narrowing.
+ * Add upstream patches for newer ffmpeg and FFMS2.
+
+ -- Andrej Shadura <andrewsh@debian.org> Wed, 20 Jul 2022 21:00:23 +0200
+
aegisub (3.2.2+dfsg-6.2) unstable; urgency=medium
* Non-maintainer upload.
diff --git a/debian/patches/remove-unconditional-Wno-c++11-narrowing.patch b/debian/patches/remove-unconditional-Wno-c++11-narrowing.patch
index 8204e60..f499084 100644
--- a/debian/patches/remove-unconditional-Wno-c++11-narrowing.patch
+++ b/debian/patches/remove-unconditional-Wno-c++11-narrowing.patch
@@ -1,13 +1,27 @@
From: Andrej Shadura <andrewsh@debian.org>
Date: Wed, 20 Jul 2022 16:11:30 +0200
-Subject: Remove unconditional -Wno-c++11-narrowing
+Subject: Replace -Wno-c++11-narrowing with -Wno-narrowing
---
+ configure.ac | 2 +-
src/Makefile | 2 +-
- 1 file changed, 1 insertion(+), 1 deletion(-)
+ 2 files changed, 2 insertions(+), 2 deletions(-)
+diff --git a/configure.ac b/configure.ac
+index 0c0d13a..c8bebf0 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -150,7 +150,7 @@ AS_IF([test x$enable_compiler_flags != xno], [
+ CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused-parameter -std=gnu99 -pipe -g"
+ CXXFLAGS="$CXXFLAGS -Wall -Wextra -Wno-unused-parameter -fno-strict-aliasing -pipe -g"
+ AC_CXX_FLAG([-std=c++11])
+- AC_CXX_FLAG([-Wno-c++11-narrowing])
++ AC_CXX_FLAG([-Wno-narrowing])
+ AC_C_FLAG([-Wno-unused-local-typedefs])
+ AC_CXX_FLAG([-Wno-unused-local-typedefs])
+
diff --git a/src/Makefile b/src/Makefile
-index 6252392..f1139d5 100644
+index 6252392..a1c3ba8 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -190,7 +190,7 @@ $(d)auto4_base.o_FLAGS := $(CFLAGS_FREETYPE)
@@ -15,7 +29,7 @@ index 6252392..f1139d5 100644
$(d)font_file_lister_fontconfig.o_FLAGS := $(CFLAGS_FONTCONFIG)
$(d)subtitles_provider.o_FLAGS := $(CFLAGS_LIBASS)
-$(d)subtitles_provider_libass.o_FLAGS := $(CFLAGS_LIBASS) -Wno-c++11-narrowing
-+$(d)subtitles_provider_libass.o_FLAGS := $(CFLAGS_LIBASS)
++$(d)subtitles_provider_libass.o_FLAGS := $(CFLAGS_LIBASS) -Wno-narrowing
$(d)text_file_reader.o_FLAGS := -D_X86_
$(d)video_provider_manager.o_FLAGS := $(CFLAGS_FFMS2)
$(d)auto4_lua.o_FLAGS := `pkg-config --silence-errors --cflags luajit` `pkg-config --silence-errors --cflags lua51`
diff --git a/debian/patches/series b/debian/patches/series
index fac629c..c06dc45 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -22,3 +22,7 @@ integrate-appdata-with-build.patch
configure.ac-Use-explicit-AM_GETTEXT_VERSION.patch
refresh-libboost-searching-m4macros.patch
remove-unconditional-Wno-c++11-narrowing.patch
+update-ffms2.patch
+update-ffms2-doindexing2.patch
+update-ffms2-x11-none.patch
+update-ffms2-agi-colorspaces.patch
diff --git a/debian/patches/update-ffms2-agi-colorspaces.patch b/debian/patches/update-ffms2-agi-colorspaces.patch
new file mode 100644
index 0000000..7ca7192
--- /dev/null
+++ b/debian/patches/update-ffms2-agi-colorspaces.patch
@@ -0,0 +1,33 @@
+From: Thomas Goyne <plorkyeran@aegisub.org>
+Date: Fri, 8 Apr 2016 13:29:32 -0700
+Subject: Fix compilation with old versions of ffms2
+
+---
+ src/ffmpegsource_common.cpp | 14 ++++++++++++++
+ 1 file changed, 14 insertions(+)
+
+diff --git a/src/ffmpegsource_common.cpp b/src/ffmpegsource_common.cpp
+index 11a5abd..6eaf75d 100644
+--- a/src/ffmpegsource_common.cpp
++++ b/src/ffmpegsource_common.cpp
+@@ -50,6 +50,20 @@
+ #include <wx/intl.h>
+ #include <wx/choicdlg.h>
+
++#if FFMS_VERSION < ((2 << 24) | (22 << 16) | (0 << 8) | 0)
++enum {
++ FFMS_LOG_QUIET = -8,
++ FFMS_LOG_PANIC = 0,
++ FFMS_LOG_FATAL = 8,
++ FFMS_LOG_ERROR = 16,
++ FFMS_LOG_WARNING = 24,
++ FFMS_LOG_INFO = 32,
++ FFMS_LOG_VERBOSE = 40,
++ FFMS_LOG_DEBUG = 48,
++ FFMS_LOG_TRACE = 56
++};
++#endif
++
+ #ifdef _WIN32
+ #include <objbase.h>
+
diff --git a/debian/patches/update-ffms2-doindexing2.patch b/debian/patches/update-ffms2-doindexing2.patch
new file mode 100644
index 0000000..254d3f6
--- /dev/null
+++ b/debian/patches/update-ffms2-doindexing2.patch
@@ -0,0 +1,256 @@
+From: Thomas Goyne <plorkyeran@aegisub.org>
+Date: Wed, 6 Apr 2016 11:24:21 -0700
+Subject: Use FFMS_DoIndexing2 when using a recent version of ffms2
+
+And clean up the audio track selection logic a bit.
+---
+ src/audio_provider_ffmpegsource.cpp | 40 ++++++++++-----------------------
+ src/ffmpegsource_common.cpp | 44 +++++++++++++++++++++++++++----------
+ src/ffmpegsource_common.h | 25 ++++++---------------
+ src/video_provider_ffmpegsource.cpp | 12 +++++-----
+ 4 files changed, 56 insertions(+), 65 deletions(-)
+
+diff --git a/src/audio_provider_ffmpegsource.cpp b/src/audio_provider_ffmpegsource.cpp
+index 4e44b1d..606d5b4 100644
+--- a/src/audio_provider_ffmpegsource.cpp
++++ b/src/audio_provider_ffmpegsource.cpp
+@@ -91,18 +91,20 @@ void FFmpegSourceAudioProvider::LoadAudio(agi::fs::path const& filename) {
+ }
+
+ std::map<int, std::string> TrackList = GetTracksOfType(Indexer, FFMS_TYPE_AUDIO);
+- if (TrackList.empty())
+- throw agi::AudioDataNotFound("no audio tracks found");
+
+ // initialize the track number to an invalid value so we can detect later on
+ // whether the user actually had to choose a track or not
+ int TrackNumber = -1;
+ if (TrackList.size() > 1) {
+- TrackNumber = AskForTrackSelection(TrackList, FFMS_TYPE_AUDIO);
+- // if it's still -1 here, user pressed cancel
+- if (TrackNumber == -1)
++ auto Selection = AskForTrackSelection(TrackList, FFMS_TYPE_AUDIO);
++ if (Selection == TrackSelection::None)
+ throw agi::UserCancelException("audio loading canceled by user");
++ TrackNumber = static_cast<int>(Selection);
+ }
++ else if (TrackList.size() == 1)
++ TrackNumber = TrackList.begin()->first;
++ else
++ throw agi::AudioDataNotFound("no audio tracks found");
+
+ // generate a name for the cache file
+ agi::fs::path CacheName = GetCacheFilename(filename);
+@@ -114,24 +116,13 @@ void FFmpegSourceAudioProvider::LoadAudio(agi::fs::path const& filename) {
+ if (Index && FFMS_IndexBelongsToFile(Index, filename.string().c_str(), &ErrInfo))
+ Index = nullptr;
+
+- // index valid but track number still not set?
+ if (Index) {
+- // track number not set? just grab the first track
+- if (TrackNumber < 0)
+- TrackNumber = FFMS_GetFirstTrackOfType(Index, FFMS_TYPE_AUDIO, &ErrInfo);
+- if (TrackNumber < 0)
+- throw agi::AudioDataNotFound(std::string("Couldn't find any audio tracks: ") + ErrInfo.Buffer);
+-
+- // index is valid and track number is now set,
+- // but do we have indexing info for the desired audio track?
++ // we already have an index, but the desired track may not have been
++ // indexed, and if it wasn't we need to reindex
+ FFMS_Track *TempTrackData = FFMS_GetTrackFromIndex(Index, TrackNumber);
+ if (FFMS_GetNumFrames(TempTrackData) <= 0)
+ Index = nullptr;
+ }
+- // no valid index exists and the file only has one audio track, index it
+- else if (TrackNumber < 0)
+- TrackNumber = FFMS_TRACKMASK_ALL;
+- // else: do nothing (keep track mask as it is)
+
+ // reindex if the error handling mode has changed
+ FFMS_IndexErrorHandling ErrorHandling = GetErrorHandlingMode();
+@@ -142,17 +133,10 @@ void FFmpegSourceAudioProvider::LoadAudio(agi::fs::path const& filename) {
+
+ // moment of truth
+ if (!Index) {
+- int TrackMask;
+- if (OPT_GET("Provider/FFmpegSource/Index All Tracks")->GetBool() || TrackNumber == FFMS_TRACKMASK_ALL)
+- TrackMask = FFMS_TRACKMASK_ALL;
+- else
+- TrackMask = (1 << TrackNumber);
+-
++ TrackSelection TrackMask = static_cast<TrackSelection>(TrackNumber);
++ if (OPT_GET("Provider/FFmpegSource/Index All Tracks")->GetBool())
++ TrackMask = TrackSelection::All;
+ Index = DoIndexing(Indexer, CacheName, TrackMask, ErrorHandling);
+-
+- // if tracknumber still isn't set we need to set it now
+- if (TrackNumber == FFMS_TRACKMASK_ALL)
+- TrackNumber = FFMS_GetFirstTrackOfType(Index, FFMS_TYPE_AUDIO, &ErrInfo);
+ }
+ else
+ FFMS_CancelIndexing(Indexer);
+diff --git a/src/ffmpegsource_common.cpp b/src/ffmpegsource_common.cpp
+index 5ebb073..11a5abd 100644
+--- a/src/ffmpegsource_common.cpp
++++ b/src/ffmpegsource_common.cpp
+@@ -80,7 +80,10 @@ FFmpegSourceProvider::FFmpegSourceProvider(agi::BackgroundRunner *br)
+ /// @param Indexer A pointer to the indexer object representing the file to be indexed
+ /// @param CacheName The filename of the output index file
+ /// @param Trackmask A binary mask of the track numbers to index
+-FFMS_Index *FFmpegSourceProvider::DoIndexing(FFMS_Indexer *Indexer, agi::fs::path const& CacheName, int Trackmask, FFMS_IndexErrorHandling IndexEH) {
++FFMS_Index *FFmpegSourceProvider::DoIndexing(FFMS_Indexer *Indexer,
++ agi::fs::path const& CacheName,
++ TrackSelection Track,
++ FFMS_IndexErrorHandling IndexEH) {
+ char FFMSErrMsg[1024];
+ FFMS_ErrorInfo ErrInfo;
+ ErrInfo.Buffer = FFMSErrMsg;
+@@ -98,8 +101,22 @@ FFMS_Index *FFmpegSourceProvider::DoIndexing(FFMS_Indexer *Indexer, agi::fs::pat
+ ps->SetProgress(Current, Total);
+ return ps->IsCancelled();
+ };
+- Index = FFMS_DoIndexing(Indexer, Trackmask, FFMS_TRACKMASK_NONE,
++#if FFMS_VERSION >= ((2 << 24) | (21 << 16) | (0 << 8) | 0)
++ if (Track == TrackSelection::All)
++ FFMS_TrackTypeIndexSettings(Indexer, FFMS_TYPE_AUDIO, 1, 0);
++ else if (Track != TrackSelection::None)
++ FFMS_TrackIndexSettings(Indexer, static_cast<int>(Track), 1, 0);
++ FFMS_SetProgressCallback(Indexer, callback, ps);
++ Index = FFMS_DoIndexing2(Indexer, IndexEH, &ErrInfo);
++#else
++ int Trackmask = 0;
++ if (Track == TrackSelection::All)
++ Trackmask = std::numeric_limits<int>::max();
++ else if (Track != TrackSelection::None)
++ Trackmask = 1 << static_cast<int>(Track);
++ Index = FFMS_DoIndexing(Indexer, Trackmask, 0,
+ nullptr, nullptr, IndexEH, callback, ps, &ErrInfo);
++#endif
+ });
+
+ if (Index == nullptr)
+@@ -119,21 +136,24 @@ std::map<int, std::string> FFmpegSourceProvider::GetTracksOfType(FFMS_Indexer *I
+ std::map<int,std::string> TrackList;
+ int NumTracks = FFMS_GetNumTracksI(Indexer);
+
++ // older versions of ffms2 can't index audio tracks past 31
++#if FFMS_VERSION < ((2 << 24) | (21 << 16) | (0 << 8) | 0)
++ if (Type == FFMS_TYPE_AUDIO)
++ NumTracks = std::min(NumTracks, std::numeric_limits<int>::digits);
++#endif
++
+ for (int i=0; i<NumTracks; i++) {
+ if (FFMS_GetTrackTypeI(Indexer, i) == Type) {
+- const char *CodecName = FFMS_GetCodecNameI(Indexer, i);
+- if (CodecName)
+- TrackList.insert(std::pair<int,std::string>(i, CodecName));
++ if (auto CodecName = FFMS_GetCodecNameI(Indexer, i))
++ TrackList[i] = CodecName;
+ }
+ }
+ return TrackList;
+ }
+
+-/// @brief Ask user for which track he wants to load
+-/// @param TrackList A std::map with the track numbers as keys and codec names as values
+-/// @param Type The track type to ask about
+-/// @return Returns the track number chosen (an integer >= 0) on success, or a negative integer if the user cancelled.
+-int FFmpegSourceProvider::AskForTrackSelection(const std::map<int, std::string> &TrackList, FFMS_TrackType Type) {
++FFmpegSourceProvider::TrackSelection
++FFmpegSourceProvider::AskForTrackSelection(const std::map<int, std::string> &TrackList,
++ FFMS_TrackType Type) {
+ std::vector<int> TrackNumbers;
+ wxArrayString Choices;
+
+@@ -148,8 +168,8 @@ int FFmpegSourceProvider::AskForTrackSelection(const std::map<int, std::string>
+ Choices);
+
+ if (Choice < 0)
+- return Choice;
+- return TrackNumbers[Choice];
++ return TrackSelection::None;
++ return static_cast<TrackSelection>(TrackNumbers[Choice]);
+ }
+
+ /// @brief Set ffms2 log level according to setting in config.dat
+diff --git a/src/ffmpegsource_common.h b/src/ffmpegsource_common.h
+index 5ef44b6..26a8a5f 100644
+--- a/src/ffmpegsource_common.h
++++ b/src/ffmpegsource_common.h
+@@ -42,11 +42,6 @@
+
+ namespace agi { class BackgroundRunner; }
+
+-/// Index all tracks
+-#define FFMS_TRACKMASK_ALL -1
+-/// Index no tracks
+-#define FFMS_TRACKMASK_NONE 0
+-
+ /// @class FFmpegSourceProvider
+ /// @brief Base class for FFMS2 source providers; contains common functions etc
+ class FFmpegSourceProvider {
+@@ -57,24 +52,18 @@ class FFmpegSourceProvider {
+ public:
+ FFmpegSourceProvider(agi::BackgroundRunner *br);
+
+- /// Logging level constants from avutil/log.h
+- enum FFMS_LogLevel {
+- /// nothing printed
+- FFMS_LOG_QUIET = -8,
+- FFMS_LOG_PANIC = 0,
+- FFMS_LOG_FATAL = 8,
+- FFMS_LOG_ERROR = 16,
+- FFMS_LOG_WARNING = 24,
+- FFMS_LOG_INFO = 32,
+- FFMS_LOG_VERBOSE = 40,
+- FFMS_LOG_DEBUG = 48,
++ enum class TrackSelection : int {
++ None = -1,
++ All = -2
+ };
+
+ void CleanCache();
+
+- FFMS_Index *DoIndexing(FFMS_Indexer *Indexer, agi::fs::path const& Cachename, int Trackmask, FFMS_IndexErrorHandling IndexEH);
++ FFMS_Index *DoIndexing(FFMS_Indexer *Indexer, agi::fs::path const& Cachename,
++ TrackSelection Track,
++ FFMS_IndexErrorHandling IndexEH);
+ std::map<int, std::string> GetTracksOfType(FFMS_Indexer *Indexer, FFMS_TrackType Type);
+- int AskForTrackSelection(const std::map<int, std::string>& TrackList, FFMS_TrackType Type);
++ TrackSelection AskForTrackSelection(const std::map<int, std::string>& TrackList, FFMS_TrackType Type);
+ agi::fs::path GetCacheFilename(agi::fs::path const& filename);
+ void SetLogLevel();
+ FFMS_IndexErrorHandling GetErrorHandlingMode();
+diff --git a/src/video_provider_ffmpegsource.cpp b/src/video_provider_ffmpegsource.cpp
+index 5231a08..f4ed6a2 100644
+--- a/src/video_provider_ffmpegsource.cpp
++++ b/src/video_provider_ffmpegsource.cpp
+@@ -166,14 +166,12 @@ void FFmpegSourceVideoProvider::LoadVideo(agi::fs::path const& filename, std::st
+ if (TrackList.size() <= 0)
+ throw VideoNotSupported("no video tracks found");
+
+- // initialize the track number to an invalid value so we can detect later on
+- // whether the user actually had to choose a track or not
+ int TrackNumber = -1;
+ if (TrackList.size() > 1) {
+- TrackNumber = AskForTrackSelection(TrackList, FFMS_TYPE_VIDEO);
+- // if it's still -1 here, user pressed cancel
+- if (TrackNumber == -1)
++ auto Selection = AskForTrackSelection(TrackList, FFMS_TYPE_VIDEO);
++ if (Selection == TrackSelection::None)
+ throw agi::UserCancelException("video loading cancelled by user");
++ TrackNumber = static_cast<int>(Selection);
+ }
+
+ // generate a name for the cache file
+@@ -197,9 +195,9 @@ void FFmpegSourceVideoProvider::LoadVideo(agi::fs::path const& filename, std::st
+
+ // moment of truth
+ if (!Index) {
+- int TrackMask = FFMS_TRACKMASK_NONE;
++ auto TrackMask = TrackSelection::None;
+ if (OPT_GET("Provider/FFmpegSource/Index All Tracks")->GetBool() || OPT_GET("Video/Open Audio")->GetBool())
+- TrackMask = FFMS_TRACKMASK_ALL;
++ TrackMask = TrackSelection::All;
+ Index = DoIndexing(Indexer, CacheName, TrackMask, GetErrorHandlingMode());
+ }
+ else {
diff --git a/debian/patches/update-ffms2-x11-none.patch b/debian/patches/update-ffms2-x11-none.patch
new file mode 100644
index 0000000..975abf2
--- /dev/null
+++ b/debian/patches/update-ffms2-x11-none.patch
@@ -0,0 +1,22 @@
+From: Thomas Goyne <plorkyeran@aegisub.org>
+Date: Fri, 8 Apr 2016 12:14:28 -0700
+Subject: Fix compilation on X11-using platforms
+
+---
+ src/ffmpegsource_common.h | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/src/ffmpegsource_common.h b/src/ffmpegsource_common.h
+index 26a8a5f..210d403 100644
+--- a/src/ffmpegsource_common.h
++++ b/src/ffmpegsource_common.h
+@@ -52,6 +52,9 @@ class FFmpegSourceProvider {
+ public:
+ FFmpegSourceProvider(agi::BackgroundRunner *br);
+
++ // X11 is wonderful
++#undef None
++
+ enum class TrackSelection : int {
+ None = -1,
+ All = -2
diff --git a/debian/patches/update-ffms2.patch b/debian/patches/update-ffms2.patch
new file mode 100644
index 0000000..7ca4672
--- /dev/null
+++ b/debian/patches/update-ffms2.patch
@@ -0,0 +1,108 @@
+From: Thomas Goyne <plorkyeran@aegisub.org>
+Date: Wed, 21 Nov 2018 16:41:05 -0800
+Subject: Update ffmpeg and ffms2
+
+---
+ src/video_provider_ffmpegsource.cpp | 49 +++++++++++++++++++++++++++----------
+ 1 file changed, 36 insertions(+), 13 deletions(-)
+
+diff --git a/src/video_provider_ffmpegsource.cpp b/src/video_provider_ffmpegsource.cpp
+index 5fd14f6..5231a08 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");
+@@ -208,8 +225,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?
+@@ -237,18 +256,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
+
diff --git a/src/Makefile b/src/Makefile
index f1139d5..a1c3ba8 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -190,7 +190,7 @@ $(d)auto4_base.o_FLAGS := $(CFLAGS_FREETYPE)
$(d)charset_detect.o_FLAGS := -D_X86_
$(d)font_file_lister_fontconfig.o_FLAGS := $(CFLAGS_FONTCONFIG)
$(d)subtitles_provider.o_FLAGS := $(CFLAGS_LIBASS)
-$(d)subtitles_provider_libass.o_FLAGS := $(CFLAGS_LIBASS)
+$(d)subtitles_provider_libass.o_FLAGS := $(CFLAGS_LIBASS) -Wno-narrowing
$(d)text_file_reader.o_FLAGS := -D_X86_
$(d)video_provider_manager.o_FLAGS := $(CFLAGS_FFMS2)
$(d)auto4_lua.o_FLAGS := `pkg-config --silence-errors --cflags luajit` `pkg-config --silence-errors --cflags lua51`
diff --git a/src/audio_provider_ffmpegsource.cpp b/src/audio_provider_ffmpegsource.cpp
index 4e44b1d..606d5b4 100644
--- a/src/audio_provider_ffmpegsource.cpp
+++ b/src/audio_provider_ffmpegsource.cpp
@@ -91,18 +91,20 @@ void FFmpegSourceAudioProvider::LoadAudio(agi::fs::path const& filename) {
}
std::map<int, std::string> TrackList = GetTracksOfType(Indexer, FFMS_TYPE_AUDIO);
- if (TrackList.empty())
- throw agi::AudioDataNotFound("no audio tracks found");
// initialize the track number to an invalid value so we can detect later on
// whether the user actually had to choose a track or not
int TrackNumber = -1;
if (TrackList.size() > 1) {
- TrackNumber = AskForTrackSelection(TrackList, FFMS_TYPE_AUDIO);
- // if it's still -1 here, user pressed cancel
- if (TrackNumber == -1)
+ auto Selection = AskForTrackSelection(TrackList, FFMS_TYPE_AUDIO);
+ if (Selection == TrackSelection::None)
throw agi::UserCancelException("audio loading canceled by user");
+ TrackNumber = static_cast<int>(Selection);
}
+ else if (TrackList.size() == 1)
+ TrackNumber = TrackList.begin()->first;
+ else
+ throw agi::AudioDataNotFound("no audio tracks found");
// generate a name for the cache file
agi::fs::path CacheName = GetCacheFilename(filename);
@@ -114,24 +116,13 @@ void FFmpegSourceAudioProvider::LoadAudio(agi::fs::path const& filename) {
if (Index && FFMS_IndexBelongsToFile(Index, filename.string().c_str(), &ErrInfo))
Index = nullptr;
- // index valid but track number still not set?
if (Index) {
- // track number not set? just grab the first track
- if (TrackNumber < 0)
- TrackNumber = FFMS_GetFirstTrackOfType(Index, FFMS_TYPE_AUDIO, &ErrInfo);
- if (TrackNumber < 0)
- throw agi::AudioDataNotFound(std::string("Couldn't find any audio tracks: ") + ErrInfo.Buffer);
-
- // index is valid and track number is now set,
- // but do we have indexing info for the desired audio track?
+ // we already have an index, but the desired track may not have been
+ // indexed, and if it wasn't we need to reindex
FFMS_Track *TempTrackData = FFMS_GetTrackFromIndex(Index, TrackNumber);
if (FFMS_GetNumFrames(TempTrackData) <= 0)
Index = nullptr;
}
- // no valid index exists and the file only has one audio track, index it
- else if (TrackNumber < 0)
- TrackNumber = FFMS_TRACKMASK_ALL;
- // else: do nothing (keep track mask as it is)
// reindex if the error handling mode has changed
FFMS_IndexErrorHandling ErrorHandling = GetErrorHandlingMode();
@@ -142,17 +133,10 @@ void FFmpegSourceAudioProvider::LoadAudio(agi::fs::path const& filename) {
// moment of truth
if (!Index) {
- int TrackMask;
- if (OPT_GET("Provider/FFmpegSource/Index All Tracks")->GetBool() || TrackNumber == FFMS_TRACKMASK_ALL)
- TrackMask = FFMS_TRACKMASK_ALL;
- else
- TrackMask = (1 << TrackNumber);
-
+ TrackSelection TrackMask = static_cast<TrackSelection>(TrackNumber);
+ if (OPT_GET("Provider/FFmpegSource/Index All Tracks")->GetBool())
+ TrackMask = TrackSelection::All;
Index = DoIndexing(Indexer, CacheName, TrackMask, ErrorHandling);
-
- // if tracknumber still isn't set we need to set it now
- if (TrackNumber == FFMS_TRACKMASK_ALL)
- TrackNumber = FFMS_GetFirstTrackOfType(Index, FFMS_TYPE_AUDIO, &ErrInfo);
}
else
FFMS_CancelIndexing(Indexer);
diff --git a/src/ffmpegsource_common.cpp b/src/ffmpegsource_common.cpp
index 5ebb073..6eaf75d 100644
--- a/src/ffmpegsource_common.cpp
+++ b/src/ffmpegsource_common.cpp
@@ -50,6 +50,20 @@
#include <wx/intl.h>
#include <wx/choicdlg.h>
+#if FFMS_VERSION < ((2 << 24) | (22 << 16) | (0 << 8) | 0)
+enum {
+ FFMS_LOG_QUIET = -8,
+ FFMS_LOG_PANIC = 0,
+ FFMS_LOG_FATAL = 8,
+ FFMS_LOG_ERROR = 16,
+ FFMS_LOG_WARNING = 24,
+ FFMS_LOG_INFO = 32,
+ FFMS_LOG_VERBOSE = 40,
+ FFMS_LOG_DEBUG = 48,
+ FFMS_LOG_TRACE = 56
+};
+#endif
+
#ifdef _WIN32
#include <objbase.h>
@@ -80,7 +94,10 @@ FFmpegSourceProvider::FFmpegSourceProvider(agi::BackgroundRunner *br)
/// @param Indexer A pointer to the indexer object representing the file to be indexed
/// @param CacheName The filename of the output index file
/// @param Trackmask A binary mask of the track numbers to index
-FFMS_Index *FFmpegSourceProvider::DoIndexing(FFMS_Indexer *Indexer, agi::fs::path const& CacheName, int Trackmask, FFMS_IndexErrorHandling IndexEH) {
+FFMS_Index *FFmpegSourceProvider::DoIndexing(FFMS_Indexer *Indexer,
+ agi::fs::path const& CacheName,
+ TrackSelection Track,
+ FFMS_IndexErrorHandling IndexEH) {
char FFMSErrMsg[1024];
FFMS_ErrorInfo ErrInfo;
ErrInfo.Buffer = FFMSErrMsg;
@@ -98,8 +115,22 @@ FFMS_Index *FFmpegSourceProvider::DoIndexing(FFMS_Indexer *Indexer, agi::fs::pat
ps->SetProgress(Current, Total);
return ps->IsCancelled();
};
- Index = FFMS_DoIndexing(Indexer, Trackmask, FFMS_TRACKMASK_NONE,
+#if FFMS_VERSION >= ((2 << 24) | (21 << 16) | (0 << 8) | 0)
+ if (Track == TrackSelection::All)
+ FFMS_TrackTypeIndexSettings(Indexer, FFMS_TYPE_AUDIO, 1, 0);
+ else if (Track != TrackSelection::None)
+ FFMS_TrackIndexSettings(Indexer, static_cast<int>(Track), 1, 0);
+ FFMS_SetProgressCallback(Indexer, callback, ps);
+ Index = FFMS_DoIndexing2(Indexer, IndexEH, &ErrInfo);
+#else
+ int Trackmask = 0;
+ if (Track == TrackSelection::All)
+ Trackmask = std::numeric_limits<int>::max();
+ else if (Track != TrackSelection::None)
+ Trackmask = 1 << static_cast<int>(Track);
+ Index = FFMS_DoIndexing(Indexer, Trackmask, 0,
nullptr, nullptr, IndexEH, callback, ps, &ErrInfo);
+#endif
});
if (Index == nullptr)
@@ -119,21 +150,24 @@ std::map<int, std::string> FFmpegSourceProvider::GetTracksOfType(FFMS_Indexer *I
std::map<int,std::string> TrackList;
int NumTracks = FFMS_GetNumTracksI(Indexer);
+ // older versions of ffms2 can't index audio tracks past 31
+#if FFMS_VERSION < ((2 << 24) | (21 << 16) | (0 << 8) | 0)
+ if (Type == FFMS_TYPE_AUDIO)
+ NumTracks = std::min(NumTracks, std::numeric_limits<int>::digits);
+#endif
+
for (int i=0; i<NumTracks; i++) {
if (FFMS_GetTrackTypeI(Indexer, i) == Type) {
- const char *CodecName = FFMS_GetCodecNameI(Indexer, i);
- if (CodecName)
- TrackList.insert(std::pair<int,std::string>(i, CodecName));
+ if (auto CodecName = FFMS_GetCodecNameI(Indexer, i))
+ TrackList[i] = CodecName;
}
}
return TrackList;
}
-/// @brief Ask user for which track he wants to load
-/// @param TrackList A std::map with the track numbers as keys and codec names as values
-/// @param Type The track type to ask about
-/// @return Returns the track number chosen (an integer >= 0) on success, or a negative integer if the user cancelled.
-int FFmpegSourceProvider::AskForTrackSelection(const std::map<int, std::string> &TrackList, FFMS_TrackType Type) {
+FFmpegSourceProvider::TrackSelection
+FFmpegSourceProvider::AskForTrackSelection(const std::map<int, std::string> &TrackList,
+ FFMS_TrackType Type) {
std::vector<int> TrackNumbers;
wxArrayString Choices;
@@ -148,8 +182,8 @@ int FFmpegSourceProvider::AskForTrackSelection(const std::map<int, std::string>
Choices);
if (Choice < 0)
- return Choice;
- return TrackNumbers[Choice];
+ return TrackSelection::None;
+ return static_cast<TrackSelection>(TrackNumbers[Choice]);
}
/// @brief Set ffms2 log level according to setting in config.dat
diff --git a/src/ffmpegsource_common.h b/src/ffmpegsource_common.h
index 5ef44b6..210d403 100644
--- a/src/ffmpegsource_common.h
+++ b/src/ffmpegsource_common.h
@@ -42,11 +42,6 @@
namespace agi { class BackgroundRunner; }
-/// Index all tracks
-#define FFMS_TRACKMASK_ALL -1
-/// Index no tracks
-#define FFMS_TRACKMASK_NONE 0
-
/// @class FFmpegSourceProvider
/// @brief Base class for FFMS2 source providers; contains common functions etc
class FFmpegSourceProvider {
@@ -57,24 +52,21 @@ class FFmpegSourceProvider {
public:
FFmpegSourceProvider(agi::BackgroundRunner *br);
- /// Logging level constants from avutil/log.h
- enum FFMS_LogLevel {
- /// nothing printed
- FFMS_LOG_QUIET = -8,
- FFMS_LOG_PANIC = 0,
- FFMS_LOG_FATAL = 8,
- FFMS_LOG_ERROR = 16,
- FFMS_LOG_WARNING = 24,
- FFMS_LOG_INFO = 32,
- FFMS_LOG_VERBOSE = 40,
- FFMS_LOG_DEBUG = 48,
+ // X11 is wonderful
+#undef None
+
+ enum class TrackSelection : int {
+ None = -1,
+ All = -2
};
void CleanCache();
- FFMS_Index *DoIndexing(FFMS_Indexer *Indexer, agi::fs::path const& Cachename, int Trackmask, FFMS_IndexErrorHandling IndexEH);
+ FFMS_Index *DoIndexing(FFMS_Indexer *Indexer, agi::fs::path const& Cachename,
+ TrackSelection Track,
+ FFMS_IndexErrorHandling IndexEH);
std::map<int, std::string> GetTracksOfType(FFMS_Indexer *Indexer, FFMS_TrackType Type);
- int AskForTrackSelection(const std::map<int, std::string>& TrackList, FFMS_TrackType Type);
+ TrackSelection AskForTrackSelection(const std::map<int, std::string>& TrackList, FFMS_TrackType Type);
agi::fs::path GetCacheFilename(agi::fs::path const& filename);
void SetLogLevel();
FFMS_IndexErrorHandling GetErrorHandlingMode();
diff --git a/src/video_provider_ffmpegsource.cpp b/src/video_provider_ffmpegsource.cpp
index 5fd14f6..f4ed6a2 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");
@@ -149,14 +166,12 @@ void FFmpegSourceVideoProvider::LoadVideo(agi::fs::path const& filename, std::st
if (TrackList.size() <= 0)
throw VideoNotSupported("no video tracks found");
- // initialize the track number to an invalid value so we can detect later on
- // whether the user actually had to choose a track or not
int TrackNumber = -1;
if (TrackList.size() > 1) {
- TrackNumber = AskForTrackSelection(TrackList, FFMS_TYPE_VIDEO);
- // if it's still -1 here, user pressed cancel
- if (TrackNumber == -1)
+ auto Selection = AskForTrackSelection(TrackList, FFMS_TYPE_VIDEO);
+ if (Selection == TrackSelection::None)
throw agi::UserCancelException("video loading cancelled by user");
+ TrackNumber = static_cast<int>(Selection);
}
// generate a name for the cache file
@@ -180,9 +195,9 @@ void FFmpegSourceVideoProvider::LoadVideo(agi::fs::path const& filename, std::st
// moment of truth
if (!Index) {
- int TrackMask = FFMS_TRACKMASK_NONE;
+ auto TrackMask = TrackSelection::None;
if (OPT_GET("Provider/FFmpegSource/Index All Tracks")->GetBool() || OPT_GET("Video/Open Audio")->GetBool())
- TrackMask = FFMS_TRACKMASK_ALL;
+ TrackMask = TrackSelection::All;
Index = DoIndexing(Indexer, CacheName, TrackMask, GetErrorHandlingMode());
}
else {
@@ -208,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?
@@ -237,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