diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-03-07 20:13:22 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-03-07 20:13:22 +0000 |
| commit | cab9a1d569396065a6e9eb39386736908564d6b4 (patch) | |
| tree | ef698f132e659ab34a8783771ddc522481cbe48b /src/lib | |
| parent | 978be856218cc15f059b7e267811e7302c37b24d (diff) | |
Add primitive subtitle view. Remove unused Film member from Decoder hierarchy.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/audio_decoder.cc | 8 | ||||
| -rw-r--r-- | src/lib/audio_decoder.h | 2 | ||||
| -rw-r--r-- | src/lib/decoder.cc | 9 | ||||
| -rw-r--r-- | src/lib/decoder.h | 6 | ||||
| -rw-r--r-- | src/lib/ffmpeg_content.cc | 6 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 34 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.h | 6 | ||||
| -rw-r--r-- | src/lib/image_decoder.cc | 5 | ||||
| -rw-r--r-- | src/lib/image_decoder.h | 2 | ||||
| -rw-r--r-- | src/lib/player.cc | 8 | ||||
| -rw-r--r-- | src/lib/sndfile_content.cc | 5 | ||||
| -rw-r--r-- | src/lib/sndfile_decoder.cc | 6 | ||||
| -rw-r--r-- | src/lib/sndfile_decoder.h | 2 | ||||
| -rw-r--r-- | src/lib/subrip_decoder.cc | 6 | ||||
| -rw-r--r-- | src/lib/subrip_decoder.h | 5 | ||||
| -rw-r--r-- | src/lib/subtitle_decoder.cc | 3 | ||||
| -rw-r--r-- | src/lib/subtitle_decoder.h | 2 | ||||
| -rw-r--r-- | src/lib/video_decoder.cc | 5 | ||||
| -rw-r--r-- | src/lib/video_decoder.h | 2 |
19 files changed, 45 insertions, 77 deletions
diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc index b0d0cc22f..32453cc13 100644 --- a/src/lib/audio_decoder.cc +++ b/src/lib/audio_decoder.cc @@ -23,7 +23,6 @@ #include "log.h" #include "resampler.h" #include "util.h" -#include "film.h" #include "i18n.h" @@ -34,9 +33,8 @@ using std::cout; using boost::optional; using boost::shared_ptr; -AudioDecoder::AudioDecoder (shared_ptr<const Film> film, shared_ptr<const AudioContent> content) - : Decoder (film) - , _audio_content (content) +AudioDecoder::AudioDecoder (shared_ptr<const AudioContent> content) + : _audio_content (content) { if (content->output_audio_frame_rate() != content->content_audio_frame_rate() && content->audio_channels ()) { _resampler.reset (new Resampler (content->content_audio_frame_rate(), content->output_audio_frame_rate(), content->audio_channels ())); @@ -58,8 +56,6 @@ AudioDecoder::audio (shared_ptr<const AudioBuffers> data, ContentTime time) } if (!_audio_position) { - shared_ptr<const Film> film = _film.lock (); - assert (film); _audio_position = time; } diff --git a/src/lib/audio_decoder.h b/src/lib/audio_decoder.h index 5b68a51a1..35d9f3560 100644 --- a/src/lib/audio_decoder.h +++ b/src/lib/audio_decoder.h @@ -38,7 +38,7 @@ class Resampler; class AudioDecoder : public virtual Decoder { public: - AudioDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const AudioContent>); + AudioDecoder (boost::shared_ptr<const AudioContent>); boost::shared_ptr<const AudioContent> audio_content () const { return _audio_content; diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc index 53a0c31e1..0901f73b0 100644 --- a/src/lib/decoder.cc +++ b/src/lib/decoder.cc @@ -21,7 +21,6 @@ * @brief Parent class for decoders of content. */ -#include "film.h" #include "decoder.h" #include "decoded.h" @@ -30,12 +29,10 @@ using std::cout; using boost::shared_ptr; -/** @param f Film. - * @param o Decode options. +/** @param o Decode options. */ -Decoder::Decoder (shared_ptr<const Film> f) - : _film (f) - , _done (false) +Decoder::Decoder () + : _done (false) { } diff --git a/src/lib/decoder.h b/src/lib/decoder.h index aeb39d0b2..0f14dbba7 100644 --- a/src/lib/decoder.h +++ b/src/lib/decoder.h @@ -30,7 +30,6 @@ #include "types.h" #include "dcpomatic_time.h" -class Film; class Decoded; /** @class Decoder. @@ -39,7 +38,7 @@ class Decoded; class Decoder : public boost::noncopyable { public: - Decoder (boost::shared_ptr<const Film>); + Decoder (); virtual ~Decoder () {} /** Seek so that the next peek() will yield the next thing @@ -67,9 +66,6 @@ protected: virtual bool pass () = 0; virtual void flush () {}; - /** The Film that we are decoding in */ - boost::weak_ptr<const Film> _film; - std::list<boost::shared_ptr<Decoded> > _pending; bool _done; }; diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index e9be3cc46..2b535a2ab 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -158,13 +158,13 @@ FFmpegContent::examine (shared_ptr<Job> job) Content::examine (job); - shared_ptr<const Film> film = _film.lock (); - assert (film); - shared_ptr<FFmpegExaminer> examiner (new FFmpegExaminer (shared_from_this ())); take_from_video_examiner (examiner); ContentTime video_length = examiner->video_length (); + + shared_ptr<const Film> film = _film.lock (); + assert (film); film->log()->log (String::compose ("Video length obtained from header as %1 frames", video_length.frames (video_frame_rate ()))); { diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 8b28a5c13..dc2a5590b 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -33,7 +33,6 @@ extern "C" { #include <libavcodec/avcodec.h> #include <libavformat/avformat.h> } -#include "film.h" #include "filter.h" #include "exceptions.h" #include "image.h" @@ -58,16 +57,16 @@ using boost::optional; using boost::dynamic_pointer_cast; using dcp::Size; -FFmpegDecoder::FFmpegDecoder (shared_ptr<const Film> f, shared_ptr<const FFmpegContent> c, bool video, bool audio) - : Decoder (f) - , VideoDecoder (f, c) - , AudioDecoder (f, c) - , SubtitleDecoder (f) +FFmpegDecoder::FFmpegDecoder (shared_ptr<const FFmpegContent> c, shared_ptr<Log> log, bool video, bool audio, bool subtitles) + : VideoDecoder (c) + , AudioDecoder (c) , FFmpeg (c) + , _log (log) , _subtitle_codec_context (0) , _subtitle_codec (0) , _decode_video (video) , _decode_audio (audio) + , _decode_subtitles (subtitles) , _pts_offset (0) { setup_subtitle (); @@ -144,25 +143,20 @@ FFmpegDecoder::pass () /* Maybe we should fail here, but for now we'll just finish off instead */ char buf[256]; av_strerror (r, buf, sizeof(buf)); - shared_ptr<const Film> film = _film.lock (); - assert (film); - film->log()->log (String::compose (N_("error on av_read_frame (%1) (%2)"), buf, r)); + _log->log (String::compose (N_("error on av_read_frame (%1) (%2)"), buf, r)); } flush (); return true; } - shared_ptr<const Film> film = _film.lock (); - assert (film); - int const si = _packet.stream_index; if (si == _video_stream && _decode_video) { decode_video_packet (); } else if (_ffmpeg_content->audio_stream() && _ffmpeg_content->audio_stream()->uses_index (_format_context, si) && _decode_audio) { decode_audio_packet (); - } else if (_ffmpeg_content->subtitle_stream() && _ffmpeg_content->subtitle_stream()->uses_index (_format_context, si) && film->with_subtitles ()) { + } else if (_ffmpeg_content->subtitle_stream() && _ffmpeg_content->subtitle_stream()->uses_index (_format_context, si) && _decode_subtitles) { decode_subtitle_packet (); } @@ -427,9 +421,7 @@ FFmpegDecoder::decode_audio_packet () int const decode_result = avcodec_decode_audio4 (audio_codec_context(), _frame, &frame_finished, ©_packet); if (decode_result < 0) { - shared_ptr<const Film> film = _film.lock (); - assert (film); - film->log()->log (String::compose ("avcodec_decode_audio4 failed (%1)", decode_result)); + _log->log (String::compose ("avcodec_decode_audio4 failed (%1)", decode_result)); return; } @@ -469,13 +461,9 @@ FFmpegDecoder::decode_video_packet () } if (i == _filter_graphs.end ()) { - shared_ptr<const Film> film = _film.lock (); - assert (film); - graph.reset (new FilterGraph (_ffmpeg_content, dcp::Size (_frame->width, _frame->height), (AVPixelFormat) _frame->format)); _filter_graphs.push_back (graph); - - film->log()->log (String::compose (N_("New graph for %1x%2, pixel format %3"), _frame->width, _frame->height, _frame->format)); + _log->log (String::compose (N_("New graph for %1x%2, pixel format %3"), _frame->width, _frame->height, _frame->format)); } else { graph = *i; } @@ -494,9 +482,7 @@ FFmpegDecoder::decode_video_packet () if (i->second != AV_NOPTS_VALUE) { video (image, false, ContentTime::from_seconds (i->second * av_q2d (_format_context->streams[_video_stream]->time_base)) + _pts_offset); } else { - shared_ptr<const Film> film = _film.lock (); - assert (film); - film->log()->log ("Dropping frame without PTS"); + _log->log ("Dropping frame without PTS"); } } diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h index 8eadb116f..fbf802bb0 100644 --- a/src/lib/ffmpeg_decoder.h +++ b/src/lib/ffmpeg_decoder.h @@ -38,7 +38,7 @@ extern "C" { #include "subtitle_decoder.h" #include "ffmpeg.h" -class Film; +class Log; class FilterGraph; class ffmpeg_pts_offset_test; @@ -48,7 +48,7 @@ class ffmpeg_pts_offset_test; class FFmpegDecoder : public VideoDecoder, public AudioDecoder, public SubtitleDecoder, public FFmpeg { public: - FFmpegDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const FFmpegContent>, bool video, bool audio); + FFmpegDecoder (boost::shared_ptr<const FFmpegContent>, boost::shared_ptr<Log>, bool video, bool audio, bool subtitles); ~FFmpegDecoder (); void seek (ContentTime time, bool); @@ -76,6 +76,7 @@ private: int minimal_run (boost::function<bool (boost::optional<ContentTime>, boost::optional<ContentTime>, int)>); void seek_and_flush (ContentTime); + boost::shared_ptr<Log> _log; AVCodecContext* _subtitle_codec_context; ///< may be 0 if there is no subtitle AVCodec* _subtitle_codec; ///< may be 0 if there is no subtitle @@ -84,6 +85,7 @@ private: bool _decode_video; bool _decode_audio; + bool _decode_subtitles; ContentTime _pts_offset; }; diff --git a/src/lib/image_decoder.cc b/src/lib/image_decoder.cc index c9b17add8..58ba732bb 100644 --- a/src/lib/image_decoder.cc +++ b/src/lib/image_decoder.cc @@ -32,9 +32,8 @@ using std::cout; using boost::shared_ptr; using dcp::Size; -ImageDecoder::ImageDecoder (shared_ptr<const Film> f, shared_ptr<const ImageContent> c) - : Decoder (f) - , VideoDecoder (f, c) +ImageDecoder::ImageDecoder (shared_ptr<const ImageContent> c) + : VideoDecoder (c) , _image_content (c) { diff --git a/src/lib/image_decoder.h b/src/lib/image_decoder.h index f4d81dfb5..13ffea13d 100644 --- a/src/lib/image_decoder.h +++ b/src/lib/image_decoder.h @@ -28,7 +28,7 @@ class ImageContent; class ImageDecoder : public VideoDecoder { public: - ImageDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const ImageContent>); + ImageDecoder (boost::shared_ptr<const ImageContent>); boost::shared_ptr<const ImageContent> content () { return _image_content; diff --git a/src/lib/player.cc b/src/lib/player.cc index e6e1f3753..e89e84aa6 100644 --- a/src/lib/player.cc +++ b/src/lib/player.cc @@ -486,7 +486,7 @@ Player::setup_pieces () /* FFmpeg */ shared_ptr<const FFmpegContent> fc = dynamic_pointer_cast<const FFmpegContent> (*i); if (fc) { - decoder.reset (new FFmpegDecoder (_film, fc, _video, _audio)); + decoder.reset (new FFmpegDecoder (fc, _film->log(), _video, _audio, _film->with_subtitles ())); frc = FrameRateChange (fc->video_frame_rate(), _film->video_frame_rate()); } @@ -502,7 +502,7 @@ Player::setup_pieces () } if (!decoder) { - decoder.reset (new ImageDecoder (_film, ic)); + decoder.reset (new ImageDecoder (ic)); } frc = FrameRateChange (ic->video_frame_rate(), _film->video_frame_rate()); @@ -511,14 +511,14 @@ Player::setup_pieces () /* SndfileContent */ shared_ptr<const SndfileContent> sc = dynamic_pointer_cast<const SndfileContent> (*i); if (sc) { - decoder.reset (new SndfileDecoder (_film, sc)); + decoder.reset (new SndfileDecoder (sc)); frc = best_overlap_frc; } /* SubRipContent */ shared_ptr<const SubRipContent> rc = dynamic_pointer_cast<const SubRipContent> (*i); if (rc) { - decoder.reset (new SubRipDecoder (_film, rc)); + decoder.reset (new SubRipDecoder (rc)); frc = best_overlap_frc; } diff --git a/src/lib/sndfile_content.cc b/src/lib/sndfile_content.cc index 1aa7bde61..71b549d51 100644 --- a/src/lib/sndfile_content.cc +++ b/src/lib/sndfile_content.cc @@ -102,10 +102,7 @@ SndfileContent::examine (shared_ptr<Job> job) job->set_progress_unknown (); Content::examine (job); - shared_ptr<const Film> film = _film.lock (); - assert (film); - - SndfileDecoder dec (film, shared_from_this()); + SndfileDecoder dec (shared_from_this()); { boost::mutex::scoped_lock lm (_mutex); diff --git a/src/lib/sndfile_decoder.cc b/src/lib/sndfile_decoder.cc index 3a71fab52..67bb25e0d 100644 --- a/src/lib/sndfile_decoder.cc +++ b/src/lib/sndfile_decoder.cc @@ -25,7 +25,6 @@ #include <sndfile.h> #include "sndfile_content.h" #include "sndfile_decoder.h" -#include "film.h" #include "exceptions.h" #include "audio_buffers.h" @@ -37,9 +36,8 @@ using std::min; using std::cout; using boost::shared_ptr; -SndfileDecoder::SndfileDecoder (shared_ptr<const Film> f, shared_ptr<const SndfileContent> c) - : Decoder (f) - , AudioDecoder (f, c) +SndfileDecoder::SndfileDecoder (shared_ptr<const SndfileContent> c) + : AudioDecoder (c) , _sndfile_content (c) , _deinterleave_buffer (0) { diff --git a/src/lib/sndfile_decoder.h b/src/lib/sndfile_decoder.h index aaa4c0da8..1de123917 100644 --- a/src/lib/sndfile_decoder.h +++ b/src/lib/sndfile_decoder.h @@ -26,7 +26,7 @@ class SndfileContent; class SndfileDecoder : public AudioDecoder { public: - SndfileDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const SndfileContent>); + SndfileDecoder (boost::shared_ptr<const SndfileContent>); ~SndfileDecoder (); void seek (ContentTime, bool); diff --git a/src/lib/subrip_decoder.cc b/src/lib/subrip_decoder.cc index 6ebb88323..47b6ea044 100644 --- a/src/lib/subrip_decoder.cc +++ b/src/lib/subrip_decoder.cc @@ -23,10 +23,8 @@ using std::list; using boost::shared_ptr; -SubRipDecoder::SubRipDecoder (shared_ptr<const Film> film, shared_ptr<const SubRipContent> content) - : Decoder (film) - , SubtitleDecoder (film) - , SubRip (content) +SubRipDecoder::SubRipDecoder (shared_ptr<const SubRipContent> content) + : SubRip (content) , _next (0) { diff --git a/src/lib/subrip_decoder.h b/src/lib/subrip_decoder.h index 26d5d5010..6025c90e2 100644 --- a/src/lib/subrip_decoder.h +++ b/src/lib/subrip_decoder.h @@ -28,8 +28,9 @@ class SubRipContent; class SubRipDecoder : public SubtitleDecoder, public SubRip { public: - SubRipDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const SubRipContent>); - + SubRipDecoder (boost::shared_ptr<const SubRipContent>); + +protected: bool pass (); private: diff --git a/src/lib/subtitle_decoder.cc b/src/lib/subtitle_decoder.cc index cf5550e42..a9674fe92 100644 --- a/src/lib/subtitle_decoder.cc +++ b/src/lib/subtitle_decoder.cc @@ -24,8 +24,7 @@ using std::list; using boost::shared_ptr; using boost::optional; -SubtitleDecoder::SubtitleDecoder (shared_ptr<const Film> f) - : Decoder (f) +SubtitleDecoder::SubtitleDecoder () { } diff --git a/src/lib/subtitle_decoder.h b/src/lib/subtitle_decoder.h index e2bd9c9d6..78ee6801e 100644 --- a/src/lib/subtitle_decoder.h +++ b/src/lib/subtitle_decoder.h @@ -34,7 +34,7 @@ class Image; class SubtitleDecoder : public virtual Decoder { public: - SubtitleDecoder (boost::shared_ptr<const Film>); + SubtitleDecoder (); protected: void image_subtitle (boost::shared_ptr<Image>, dcpomatic::Rect<double>, ContentTime, ContentTime); diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc index e4d5516a1..15f91b892 100644 --- a/src/lib/video_decoder.cc +++ b/src/lib/video_decoder.cc @@ -26,9 +26,8 @@ using std::cout; using boost::shared_ptr; using boost::optional; -VideoDecoder::VideoDecoder (shared_ptr<const Film> f, shared_ptr<const VideoContent> c) - : Decoder (f) - , _video_content (c) +VideoDecoder::VideoDecoder (shared_ptr<const VideoContent> c) + : _video_content (c) { } diff --git a/src/lib/video_decoder.h b/src/lib/video_decoder.h index d8c362354..c3228e88d 100644 --- a/src/lib/video_decoder.h +++ b/src/lib/video_decoder.h @@ -33,7 +33,7 @@ class Image; class VideoDecoder : public virtual Decoder { public: - VideoDecoder (boost::shared_ptr<const Film>, boost::shared_ptr<const VideoContent>); + VideoDecoder (boost::shared_ptr<const VideoContent>); boost::shared_ptr<const VideoContent> video_content () const { return _video_content; |
