diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-08-26 20:27:45 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-08-26 20:27:45 +0100 |
| commit | 6b62e9c77b2a45fd1d7084626f2bb2949e832e5f (patch) | |
| tree | 486f58182c8b740a8ba2be20d59e002f2d8c55dd /src/lib | |
| parent | e7e9347cdd1f43e0dd3d1ca35632e9493a010fc6 (diff) | |
Separate FFmpegSubtitlePeriod.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/ffmpeg.cc | 16 | ||||
| -rw-r--r-- | src/lib/ffmpeg.h | 4 | ||||
| -rw-r--r-- | src/lib/ffmpeg_subtitle_period.h | 37 | ||||
| -rw-r--r-- | src/lib/film.h | 1 | ||||
| -rw-r--r-- | src/lib/util.cc | 16 | ||||
| -rw-r--r-- | src/lib/util.h | 19 |
6 files changed, 57 insertions, 36 deletions
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<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) + ); +} 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 <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 index 000000000..b6565a2a2 --- /dev/null +++ b/src/lib/ffmpeg_subtitle_period.h @@ -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; +}; 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<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) { 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<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); |
