From c93d0271dad86dccdbe518dbbe6e2175adce6804 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 28 Apr 2021 08:47:43 +0200 Subject: [PATCH] Remove some FFmpeg-related warnings by using AVStream::codecpar. --- src/lib/ffmpeg.cc | 4 +--- src/lib/ffmpeg_decoder.cc | 8 ++------ src/lib/ffmpeg_file_encoder.cc | 2 +- 3 files changed, 4 insertions(+), 10 deletions(-) diff --git a/src/lib/ffmpeg.cc b/src/lib/ffmpeg.cc index eb131d434..7bb17f9bf 100644 --- a/src/lib/ffmpeg.cc +++ b/src/lib/ffmpeg.cc @@ -143,10 +143,9 @@ FFmpeg::setup_general () optional video_stream_undefined_frame_rate; -DCPOMATIC_DISABLE_WARNINGS for (uint32_t i = 0; i < _format_context->nb_streams; ++i) { auto s = _format_context->streams[i]; - if (s->codec->codec_type == AVMEDIA_TYPE_VIDEO && avcodec_find_decoder(s->codec->codec_id)) { + if (s->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && avcodec_find_decoder(s->codecpar->codec_id)) { if (s->avg_frame_rate.num > 0 && s->avg_frame_rate.den > 0) { /* This is definitely our video stream */ _video_stream = i; @@ -156,7 +155,6 @@ DCPOMATIC_DISABLE_WARNINGS } } } -DCPOMATIC_ENABLE_WARNINGS /* 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. diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc index 9d7e15557..700e29836 100644 --- a/src/lib/ffmpeg_decoder.cc +++ b/src/lib/ffmpeg_decoder.cc @@ -228,11 +228,9 @@ FFmpegDecoder::deinterleave_audio (shared_ptr stream) const { DCPOMATIC_ASSERT (bytes_per_audio_sample (stream)); -DCPOMATIC_DISABLE_WARNINGS int const size = av_samples_get_buffer_size ( - 0, stream->stream(_format_context)->codec->channels, _frame->nb_samples, audio_sample_format (stream), 1 + 0, stream->stream(_format_context)->codecpar->channels, _frame->nb_samples, audio_sample_format (stream), 1 ); -DCPOMATIC_ENABLE_WARNINGS DCPOMATIC_ASSERT (size >= 0); /* XXX: can't we just use _frame->nb_samples directly here? */ @@ -365,9 +363,7 @@ DCPOMATIC_ENABLE_WARNINGS AVSampleFormat FFmpegDecoder::audio_sample_format (shared_ptr stream) const { -DCPOMATIC_DISABLE_WARNINGS - return stream->stream (_format_context)->codec->sample_fmt; -DCPOMATIC_ENABLE_WARNINGS + return static_cast(stream->stream(_format_context)->codecpar->format); } diff --git a/src/lib/ffmpeg_file_encoder.cc b/src/lib/ffmpeg_file_encoder.cc index 782df4d20..18b90e0b5 100644 --- a/src/lib/ffmpeg_file_encoder.cc +++ b/src/lib/ffmpeg_file_encoder.cc @@ -335,8 +335,8 @@ FFmpegFileEncoder::setup_video () throw runtime_error ("could not create FFmpeg output video stream"); } -DCPOMATIC_DISABLE_WARNINGS _video_stream->id = _video_stream_index; +DCPOMATIC_DISABLE_WARNINGS _video_stream->codec = _video_codec_context; DCPOMATIC_ENABLE_WARNINGS -- 2.30.2