diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-05-22 15:05:57 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-05-22 15:05:57 +0100 |
| commit | a83e1ca3f9fd1550020054b8e064a8e2048b6410 (patch) | |
| tree | eb4b965c45bf831f0471ad5c2f2b130fbca32b28 /src/lib | |
| parent | d342a1befa88cb3f23c7e3fccfd1edaeea968fed (diff) | |
Set up all FFmpeg decoders in one method.
Diffstat (limited to 'src/lib')
| -rw-r--r-- | src/lib/ffmpeg.cc | 31 | ||||
| -rw-r--r-- | src/lib/ffmpeg.h | 3 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.cc | 28 | ||||
| -rw-r--r-- | src/lib/ffmpeg_decoder.h | 2 |
4 files changed, 5 insertions, 59 deletions
diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index 6f66ebbc0..017960f2a 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -49,8 +49,7 @@ FFmpeg::FFmpeg (boost::shared_ptr<const FFmpegContent> c) , _video_stream (-1) { setup_general (); - setup_video (); - setup_audio (); + setup_decoders (); } FFmpeg::~FFmpeg () @@ -145,46 +144,24 @@ FFmpeg::setup_general () } void -FFmpeg::setup_video () -{ - boost::mutex::scoped_lock lm (_mutex); - - assert (_video_stream >= 0); - AVCodecContext* context = _format_context->streams[_video_stream]->codec; - AVCodec* codec = avcodec_find_decoder (context->codec_id); - - if (codec == 0) { - throw DecodeError (_("could not find video decoder")); - } - - if (avcodec_open2 (context, codec, 0) < 0) { - throw DecodeError (N_("could not open video decoder")); - } -} - -void -FFmpeg::setup_audio () +FFmpeg::setup_decoders () { boost::mutex::scoped_lock lm (_mutex); for (uint32_t i = 0; i < _format_context->nb_streams; ++i) { AVCodecContext* context = _format_context->streams[i]->codec; - if (context->codec_type != AVMEDIA_TYPE_AUDIO) { - continue; - } AVCodec* codec = avcodec_find_decoder (context->codec_id); if (codec == 0) { - throw DecodeError (_("could not find audio decoder")); + throw DecodeError (N_("could not find decoder")); } if (avcodec_open2 (context, codec, 0) < 0) { - throw DecodeError (N_("could not open audio decoder")); + throw DecodeError (N_("could not open decoder")); } } } - AVCodecContext * FFmpeg::video_codec_context () const { diff --git a/src/lib/ffmpeg.h b/src/lib/ffmpeg.h index 760918437..1d2c312e6 100644 --- a/src/lib/ffmpeg.h +++ b/src/lib/ffmpeg.h @@ -79,8 +79,7 @@ protected: private: void setup_general (); - void setup_video (); - void setup_audio (); + void setup_decoders (); }; #endif diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index eec70501a..7d152e490 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -67,8 +67,6 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<const FFmpegContent> c, shared_ptr<Log> , _subtitle_codec_context (0) , _subtitle_codec (0) { - setup_subtitle (); - /* Audio and video frame PTS values may not start with 0. We want to fiddle them so that: @@ -495,34 +493,8 @@ FFmpegDecoder::decode_video_packet () return true; } - void -FFmpegDecoder::setup_subtitle () -{ - boost::mutex::scoped_lock lm (_mutex); - - if (!_ffmpeg_content->subtitle_stream()) { - return; - } - - _subtitle_codec_context = _ffmpeg_content->subtitle_stream()->stream(_format_context)->codec; - if (_subtitle_codec_context == 0) { - throw DecodeError (N_("could not find subtitle stream")); - } - - _subtitle_codec = avcodec_find_decoder (_subtitle_codec_context->codec_id); - - if (_subtitle_codec == 0) { - throw DecodeError (N_("could not find subtitle decoder")); - } - - if (avcodec_open2 (_subtitle_codec_context, _subtitle_codec, 0) < 0) { - throw DecodeError (N_("could not open subtitle decoder")); - } -} - -void FFmpegDecoder::decode_subtitle_packet () { int got_subtitle; diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h index 2cda8f89d..6006fc08d 100644 --- a/src/lib/ffmpeg_decoder.h +++ b/src/lib/ffmpeg_decoder.h @@ -57,8 +57,6 @@ private: bool pass (); void flush (); - void setup_subtitle (); - AVSampleFormat audio_sample_format () const; int bytes_per_audio_sample () const; |
