From 6b62e9c77b2a45fd1d7084626f2bb2949e832e5f Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 26 Aug 2015 20:27:45 +0100 Subject: [PATCH] Separate FFmpegSubtitlePeriod. --- src/lib/ffmpeg.cc | 16 ++++++++++++++ src/lib/ffmpeg.h | 4 +++- src/lib/ffmpeg_subtitle_period.h | 37 ++++++++++++++++++++++++++++++++ src/lib/film.h | 1 + src/lib/util.cc | 16 -------------- src/lib/util.h | 19 ---------------- 6 files changed, 57 insertions(+), 36 deletions(-) create mode 100644 src/lib/ffmpeg_subtitle_period.h diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index 1620b32b4..bba642484 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -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 (sub.pts) / AV_TIME_BASE); + + if (sub.end_display_time == static_cast (-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) + ); +} diff --git a/src/lib/ffmpeg.h b/src/lib/ffmpeg.h index 9e9d5125a..961f5cbb1 100644 --- a/src/lib/ffmpeg.h +++ b/src/lib/ffmpeg.h @@ -20,10 +20,11 @@ #ifndef DCPOMATIC_FFMPEG_H #define DCPOMATIC_FFMPEG_H +#include "file_group.h" +#include "ffmpeg_subtitle_period.h" extern "C" { #include } -#include "file_group.h" #include #include @@ -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 _ffmpeg_content; diff --git a/src/lib/ffmpeg_subtitle_period.h b/src/lib/ffmpeg_subtitle_period.h new file mode 100644 index 000000000..b6565a2a2 --- /dev/null +++ b/src/lib/ffmpeg_subtitle_period.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 2012-2015 Carl Hetherington + + 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 + +class FFmpegSubtitlePeriod +{ +public: + FFmpegSubtitlePeriod (ContentTime f) + : from (f) + {} + + FFmpegSubtitlePeriod (ContentTime f, ContentTime t) + : from (f) + , to (t) + {} + + ContentTime from; + boost::optional to; +}; diff --git a/src/lib/film.h b/src/lib/film.h index a9a397983..2165eed23 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -53,6 +53,7 @@ class Screen; class AudioProcessor; class AudioMapping; class Ratio; +class Job; struct isdcf_name_test; /** @class Film diff --git a/src/lib/util.cc b/src/lib/util.cc index c9a530aaf..77d66d077 100644 --- a/src/lib/util.cc +++ b/src/lib/util.cc @@ -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 (sub.pts) / AV_TIME_BASE); - - if (sub.end_display_time == static_cast (-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 split_get_request (string url) { diff --git a/src/lib/util.h b/src/lib/util.h index a0218fc39..143874c3b 100644 --- a/src/lib/util.h +++ b/src/lib/util.h @@ -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 to; -}; - -extern FFmpegSubtitlePeriod subtitle_period (AVSubtitle const &); extern void set_backtrace_file (boost::filesystem::path); extern std::map split_get_request (std::string url); extern std::string video_asset_filename (boost::shared_ptr asset); -- 2.30.2