X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fffmpeg_decoder.cc;h=5a1b78762d92e6e30d55108dfae637f8b348e676;hb=98060a4e6f02b418f30b4b736e5880a357454c40;hp=45c242237e6b50f3c504389c3e8a765cec3d522f;hpb=f0d7baf0ce956fe5461caa91868c41d881b5f0dc;p=dcpomatic.git diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 45c242237..5a1b78762 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -171,12 +171,14 @@ FFmpegDecoder::pass () shared_ptr film = _film.lock (); assert (film); + + int const si = _packet.stream_index; - if (_packet.stream_index == _video_stream && _decode_video) { + if (si == _video_stream && _decode_video) { decode_video_packet (); - } else if (_ffmpeg_content->audio_stream() && _packet.stream_index == _ffmpeg_content->audio_stream()->id && _decode_audio) { + } else if (_ffmpeg_content->audio_stream() && si == _ffmpeg_content->audio_stream()->index (_format_context) && _decode_audio) { decode_audio_packet (); - } else if (_ffmpeg_content->subtitle_stream() && _packet.stream_index == _ffmpeg_content->subtitle_stream()->id && film->with_subtitles ()) { + } else if (_ffmpeg_content->subtitle_stream() && si == _ffmpeg_content->subtitle_stream()->index (_format_context) && film->with_subtitles ()) { decode_subtitle_packet (); } @@ -339,6 +341,7 @@ FFmpegDecoder::seek (VideoContent::Frame frame, bool accurate) } if (_packet.stream_index != _video_stream) { + av_free_packet (&_packet); continue; } @@ -510,11 +513,11 @@ FFmpegDecoder::setup_subtitle () { boost::mutex::scoped_lock lm (_mutex); - if (!_ffmpeg_content->subtitle_stream() || _ffmpeg_content->subtitle_stream()->id >= int (_format_context->nb_streams)) { + if (!_ffmpeg_content->subtitle_stream() || _ffmpeg_content->subtitle_stream()->index (_format_context) >= int (_format_context->nb_streams)) { return; } - _subtitle_codec_context = _format_context->streams[_ffmpeg_content->subtitle_stream()->id]->codec; + _subtitle_codec_context = _ffmpeg_content->subtitle_stream()->stream(_format_context)->codec; _subtitle_codec = avcodec_find_decoder (_subtitle_codec_context->codec_id); if (_subtitle_codec == 0) {