Fix build against FFmpeg v5.0

It has been released on January 17th. This patch keeps source compatibility
with older versions.
This commit is contained in:
Nicholas Guriev 2022-02-08 18:20:27 +03:00 committed by John Preston
parent f4f7b5b99c
commit 436622ad7c
5 changed files with 9 additions and 5 deletions

View file

@ -154,7 +154,7 @@ void FormatDeleter::operator()(AVFormatContext *value) {
}
}
AVCodec *FindDecoder(not_null<AVCodecContext*> context) {
const AVCodec *FindDecoder(not_null<AVCodecContext*> context) {
// Force libvpx-vp9, because we need alpha channel support.
return (context->codec_id == AV_CODEC_ID_VP9)
? avcodec_find_decoder_by_name("libvpx-vp9")

View file

@ -158,7 +158,7 @@ using SwscalePointer = std::unique_ptr<SwsContext, SwscaleDeleter>;
void LogError(QLatin1String method);
void LogError(QLatin1String method, FFmpeg::AvErrorWrap error);
[[nodiscard]] AVCodec *FindDecoder(not_null<AVCodecContext*> context);
[[nodiscard]] const AVCodec *FindDecoder(not_null<AVCodecContext*> context);
[[nodiscard]] crl::time PtsToTime(int64_t pts, AVRational timeBase);
// Used for full duration conversion.
[[nodiscard]] crl::time PtsToTimeCeil(int64_t pts, AVRational timeBase);

View file

@ -147,7 +147,7 @@ struct Instance::Inner::Private {
AVIOContext *ioContext = nullptr;
AVFormatContext *fmtContext = nullptr;
AVStream *stream = nullptr;
AVCodec *codec = nullptr;
const AVCodec *codec = nullptr;
AVCodecContext *codecContext = nullptr;
bool opened = false;
bool processing = false;

View file

@ -60,7 +60,11 @@ protected:
uchar *ioBuffer = nullptr;
AVIOContext *ioContext = nullptr;
AVFormatContext *fmtContext = nullptr;
#if LIBAVFORMAT_VERSION_MAJOR >= 59
const AVCodec *codec = nullptr;
#else
AVCodec *codec = nullptr;
#endif
int32 streamId = 0;
bool _opened = false;

View file

@ -23,8 +23,8 @@ constexpr auto kMaxQueuedPackets = 1024;
not_null<AVStream*> stream,
Mode mode) {
return (mode == Mode::Video || mode == Mode::Inspection)
&& stream->codec
&& (stream->codec->codec_id == AV_CODEC_ID_VP9)
&& stream->codecpar
&& (stream->codecpar->codec_id == AV_CODEC_ID_VP9)
&& format->iformat
&& format->iformat->name
&& QString::fromLatin1(