/*
- Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
+ Copyright (C) 2013-2016 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
, _avio_context (0)
, _format_context (0)
, _frame (0)
- , _video_stream (-1)
{
setup_general ();
setup_decoders ();
/* Find video stream */
- int video_stream_undefined_frame_rate = -1;
+ optional<int> video_stream_undefined_frame_rate;
for (uint32_t i = 0; i < _format_context->nb_streams; ++i) {
AVStream* s = _format_context->streams[i];
/* Files from iTunes sometimes have two video streams, one with the avg_frame_rate.num and .den set
to zero. Only use such a stream if there is no alternative.
*/
- if (_video_stream == -1 && video_stream_undefined_frame_rate != -1) {
- _video_stream = video_stream_undefined_frame_rate;
- }
-
- if (_video_stream < 0) {
- throw DecodeError (N_("could not find video stream"));
+ if (!_video_stream && video_stream_undefined_frame_rate) {
+ _video_stream = video_stream_undefined_frame_rate.get();
}
/* Hack: if the AVStreams have duplicate IDs, replace them with our
AVCodecContext *
FFmpeg::video_codec_context () const
{
- return _format_context->streams[_video_stream]->codec;
+ DCPOMATIC_ASSERT (_video_stream);
+ return _format_context->streams[_video_stream.get()]->codec;
}
AVCodecContext *