Remove some FFmpeg-related warnings by using AVStream::codecpar.
authorCarl Hetherington <cth@carlh.net>
Wed, 28 Apr 2021 06:47:43 +0000 (08:47 +0200)
committerCarl Hetherington <cth@carlh.net>
Fri, 30 Apr 2021 23:31:57 +0000 (01:31 +0200)
src/lib/ffmpeg.cc
src/lib/ffmpeg_decoder.cc
src/lib/ffmpeg_file_encoder.cc

index eb131d4..7bb17f9 100644 (file)
@@ -143,10 +143,9 @@ FFmpeg::setup_general ()
 
        optional<int> 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.
index 9d7e155..700e298 100644 (file)
@@ -228,11 +228,9 @@ FFmpegDecoder::deinterleave_audio (shared_ptr<FFmpegAudioStream> 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<FFmpegAudioStream> stream) const
 {
-DCPOMATIC_DISABLE_WARNINGS
-       return stream->stream (_format_context)->codec->sample_fmt;
-DCPOMATIC_ENABLE_WARNINGS
+       return static_cast<AVSampleFormat>(stream->stream(_format_context)->codecpar->format);
 }
 
 
index 782df4d..18b90e0 100644 (file)
@@ -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