diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-06-27 11:16:37 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-06-27 11:16:37 +0100 |
| commit | 2f99a801dfb1668d7efda4eb8a3f5638d2fe20d2 (patch) | |
| tree | 69117c856701cdfe96206f8cee12b2dd34f070fa /src | |
| parent | 76ce03b70441e2552f2ad62dc116e75b2f6dcf3c (diff) | |
Fix confusion about subtitle codec pointers.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/ffmpeg.cc | 11 | ||||
| -rw-r--r-- | src/lib/ffmpeg.h | 1 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 17 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.h | 3 |
4 files changed, 15 insertions, 17 deletions
diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index 8505626df..f5af239b0 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -26,6 +26,7 @@ extern "C" { #include "ffmpeg.h" #include "ffmpeg_content.h" #include "ffmpeg_audio_stream.h" +#include "ffmpeg_subtitle_stream.h" #include "exceptions.h" #include "util.h" @@ -174,6 +175,16 @@ FFmpeg::audio_codec_context () const return _ffmpeg_content->audio_stream()->stream(_format_context)->codec; } +AVCodecContext * +FFmpeg::subtitle_codec_context () const +{ + if (!_ffmpeg_content->subtitle_stream ()) { + return 0; + } + + return _ffmpeg_content->subtitle_stream()->stream(_format_context)->codec; +} + int FFmpeg::avio_read (uint8_t* buffer, int const amount) { diff --git a/src/lib/ffmpeg.h b/src/lib/ffmpeg.h index 1d2c312e6..8aaa54f84 100644 --- a/src/lib/ffmpeg.h +++ b/src/lib/ffmpeg.h @@ -56,6 +56,7 @@ public: protected: AVCodecContext* video_codec_context () const; AVCodecContext* audio_codec_context () const; + AVCodecContext* subtitle_codec_context () const; boost::shared_ptr<const FFmpegContent> _ffmpeg_content; diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 2041a4d17..42be8227e 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -70,8 +70,6 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const FFmpegContent> c, shared_ptr<Log> , SubtitleDecoder (c) , FFmpeg (c) , _log (log) - , _subtitle_codec_context (0) - , _subtitle_codec (0) { /* Audio and video frame PTS values may not start with 0. We want to fiddle them so that: @@ -106,15 +104,6 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const FFmpegContent> c, shared_ptr<Log> } } -FFmpegDecoder::~FFmpegDecoder () -{ - boost::mutex::scoped_lock lm (_mutex); - - if (_subtitle_codec_context) { - avcodec_close (_subtitle_codec_context); - } -} - void FFmpegDecoder::flush () { @@ -382,8 +371,8 @@ FFmpegDecoder::seek_and_flush (ContentTime t) if (audio_codec_context ()) { avcodec_flush_buffers (audio_codec_context ()); } - if (_subtitle_codec_context) { - avcodec_flush_buffers (_subtitle_codec_context); + if (subtitle_codec_context ()) { + avcodec_flush_buffers (subtitle_codec_context ()); } } @@ -508,7 +497,7 @@ FFmpegDecoder::decode_subtitle_packet () { int got_subtitle; AVSubtitle sub; - if (avcodec_decode_subtitle2 (_subtitle_codec_context, &sub, &got_subtitle, &_packet) < 0 || !got_subtitle) { + if (avcodec_decode_subtitle2 (subtitle_codec_context(), &sub, &got_subtitle, &_packet) < 0 || !got_subtitle) { return; } diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h index 335364d2e..2859e2345 100644 --- a/src/lib/ffmpeg_decoder.h +++ b/src/lib/ffmpeg_decoder.h @@ -48,7 +48,6 @@ class FFmpegDecoder : public VideoDecoder, public AudioDecoder, public SubtitleD { public: FFmpegDecoder (boost::shared_ptr<const FFmpegContent>, boost::shared_ptr<Log>); - ~FFmpegDecoder (); private: friend class ::ffmpeg_pts_offset_test; @@ -75,8 +74,6 @@ private: bool has_subtitle_during (ContentTimePeriod) const; 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 std::list<boost::shared_ptr<FilterGraph> > _filter_graphs; boost::mutex _filter_graphs_mutex; |
