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/ffmpeg.cc | |
| parent | d342a1befa88cb3f23c7e3fccfd1edaeea968fed (diff) | |
Set up all FFmpeg decoders in one method.
Diffstat (limited to 'src/lib/ffmpeg.cc')
| -rw-r--r-- | src/lib/ffmpeg.cc | 31 |
1 files changed, 4 insertions, 27 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 { |
