Separate FFmpegSubtitlePeriod.
authorCarl Hetherington <cth@carlh.net>
Wed, 26 Aug 2015 19:27:45 +0000 (20:27 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 26 Aug 2015 19:27:45 +0000 (20:27 +0100)
src/lib/ffmpeg.cc
src/lib/ffmpeg.h
src/lib/ffmpeg_subtitle_period.h [new file with mode: 0644]
src/lib/film.h
src/lib/util.cc
src/lib/util.h

index 1620b32b40a3c393567c714f68223b860d57a67d..bba6424847855f9a603d13ddcd3a245be988ddb5 100644 (file)
@@ -246,3 +246,19 @@ FFmpeg::avio_seek (int64_t const pos, int whence)
 
        return _file_group.seek (pos, whence);
 }
+
+FFmpegSubtitlePeriod
+FFmpeg::subtitle_period (AVSubtitle const & sub)
+{
+       ContentTime const packet_time = ContentTime::from_seconds (static_cast<double> (sub.pts) / AV_TIME_BASE);
+
+       if (sub.end_display_time == static_cast<uint32_t> (-1)) {
+               /* End time is not known */
+               return FFmpegSubtitlePeriod (packet_time + ContentTime::from_seconds (sub.start_display_time / 1e3));
+       }
+
+       return FFmpegSubtitlePeriod (
+               packet_time + ContentTime::from_seconds (sub.start_display_time / 1e3),
+               packet_time + ContentTime::from_seconds (sub.end_display_time / 1e3)
+               );
+}
index 9e9d5125aa02ecb033df751b6b8a872e9a65e53c..961f5cbb1e2b259b8d205ceb93e808bc0867e767 100644 (file)
 #ifndef DCPOMATIC_FFMPEG_H
 #define DCPOMATIC_FFMPEG_H
 
+#include "file_group.h"
+#include "ffmpeg_subtitle_period.h"
 extern "C" {
 #include <libavcodec/avcodec.h>
 }
-#include "file_group.h"
 #include <boost/shared_ptr.hpp>
 #include <boost/thread/mutex.hpp>
 
@@ -50,6 +51,7 @@ public:
 protected:
        AVCodecContext* video_codec_context () const;
        AVCodecContext* subtitle_codec_context () const;
+       static FFmpegSubtitlePeriod subtitle_period (AVSubtitle const &);
 
        boost::shared_ptr<const FFmpegContent> _ffmpeg_content;
 
diff --git a/src/lib/ffmpeg_subtitle_period.h b/src/lib/ffmpeg_subtitle_period.h
new file mode 100644 (file)
index 0000000..b6565a2
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+*/
+
+#include "dcpomatic_time.h"
+#include <boost/optional.hpp>
+
+class FFmpegSubtitlePeriod
+{
+public:
+       FFmpegSubtitlePeriod (ContentTime f)
+               : from (f)
+       {}
+
+       FFmpegSubtitlePeriod (ContentTime f, ContentTime t)
+               : from (f)
+               , to (t)
+       {}
+
+       ContentTime from;
+       boost::optional<ContentTime> to;
+};
index a9a3979834eaadc941960a88c363b0c58fd9d30a..2165eed23d203d4dd39fb7b0c327e04d604f312a 100644 (file)
@@ -53,6 +53,7 @@ class Screen;
 class AudioProcessor;
 class AudioMapping;
 class Ratio;
+class Job;
 struct isdcf_name_test;
 
 /** @class Film
index c9a530aafeb3569cc7b6d188a55059c5c70a61ec..77d66d07763f967cc436bb14883604f9dd4b2621 100644 (file)
@@ -556,22 +556,6 @@ wrapped_av_malloc (size_t s)
        return p;
 }
 
-FFmpegSubtitlePeriod
-subtitle_period (AVSubtitle const & sub)
-{
-       ContentTime const packet_time = ContentTime::from_seconds (static_cast<double> (sub.pts) / AV_TIME_BASE);
-
-       if (sub.end_display_time == static_cast<uint32_t> (-1)) {
-               /* End time is not known */
-               return FFmpegSubtitlePeriod (packet_time + ContentTime::from_seconds (sub.start_display_time / 1e3));
-       }
-
-       return FFmpegSubtitlePeriod (
-               packet_time + ContentTime::from_seconds (sub.start_display_time / 1e3),
-               packet_time + ContentTime::from_seconds (sub.end_display_time / 1e3)
-               );
-}
-
 map<string, string>
 split_get_request (string url)
 {
index a0218fc39efb95164d3962ca71e4d5e25ad1b0b4..143874c3b9431d804fae72babe070dc692d68bb4 100644 (file)
@@ -50,7 +50,6 @@ namespace dcp {
 
 extern std::string program_name;
 
-class Job;
 struct AVSubtitle;
 
 extern std::string seconds_to_hms (int);
@@ -71,24 +70,6 @@ extern std::string tidy_for_filename (std::string);
 extern dcp::Size fit_ratio_within (float ratio, dcp::Size);
 extern int stride_round_up (int, int const *, int);
 extern void* wrapped_av_malloc (size_t);
-
-class FFmpegSubtitlePeriod
-{
-public:
-       FFmpegSubtitlePeriod (ContentTime f)
-               : from (f)
-       {}
-
-       FFmpegSubtitlePeriod (ContentTime f, ContentTime t)
-               : from (f)
-               , to (t)
-       {}
-
-       ContentTime from;
-       boost::optional<ContentTime> to;
-};
-
-extern FFmpegSubtitlePeriod subtitle_period (AVSubtitle const &);
 extern void set_backtrace_file (boost::filesystem::path);
 extern std::map<std::string, std::string> split_get_request (std::string url);
 extern std::string video_asset_filename (boost::shared_ptr<dcp::PictureAsset> asset);