Merge pull request #18670 from Tatsh/ffmpeg

Fix compilation against newer ffmpeg versions
This commit is contained in:
Henrik Rydgård 2024-01-14 14:16:36 +01:00 committed by GitHub
commit 3bd2b1c7a7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 42 additions and 4 deletions

View File

@ -45,6 +45,10 @@ extern "C" {
#define av_frame_free avcodec_free_frame
#endif
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 16, 100)
#define AVCodec const AVCodec
#endif
static AVFormatContext *s_format_context = nullptr;
static AVCodecContext *s_codec_context = nullptr;
static AVStream *s_stream = nullptr;

View File

@ -126,8 +126,14 @@ extern "C" {
#include "libavformat/avformat.h"
#include "libswresample/swresample.h"
#include "libavutil/samplefmt.h"
#include "libavcodec/avcodec.h"
#include "libavutil/version.h"
}
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 16, 100)
#define AVCodec const AVCodec
#endif
#endif // USE_FFMPEG
enum AtracDecodeResult {
@ -1877,7 +1883,7 @@ int __AtracSetContext(Atrac *atrac) {
atrac->ReleaseFFMPEGContext();
}
const AVCodec *codec = avcodec_find_decoder(ff_codec);
AVCodec *codec = avcodec_find_decoder(ff_codec);
atrac->codecCtx_ = avcodec_alloc_context3(codec);
if (atrac->codecType_ == PSP_MODE_AT_3) {

View File

@ -111,7 +111,11 @@ extern "C" {
#include "libavformat/avformat.h"
#include "libavutil/imgutils.h"
#include "libswscale/swscale.h"
#include "libavcodec/avcodec.h"
}
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 16, 100)
#define AVCodec const AVCodec
#endif
static AVPixelFormat pmp_want_pix_fmt;
#endif

View File

@ -54,6 +54,11 @@ extern "C" {
#endif // USE_FFMPEG
#ifdef USE_FFMPEG
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 16, 100)
#define AVCodec const AVCodec
#endif
static AVPixelFormat getSwsFormat(int pspFormat)
{
switch (pspFormat)
@ -406,7 +411,7 @@ bool MediaEngine::addVideoStream(int streamNum, int streamId) {
// no need to add an existing stream.
if ((u32)streamNum < m_pFormatCtx->nb_streams)
return true;
const AVCodec *h264_codec = avcodec_find_decoder(AV_CODEC_ID_H264);
AVCodec *h264_codec = avcodec_find_decoder(AV_CODEC_ID_H264);
if (!h264_codec)
return false;
AVStream *stream = avformat_new_stream(m_pFormatCtx, h264_codec);
@ -421,14 +426,20 @@ bool MediaEngine::addVideoStream(int streamNum, int streamId) {
stream->codecpar->codec_id = AV_CODEC_ID_H264;
#else
stream->request_probe = 0;
#endif
stream->need_parsing = AVSTREAM_PARSE_FULL;
#endif
// We could set the width here, but we don't need to.
if (streamNum >= m_expectedVideoStreams) {
++m_expectedVideoStreams;
}
m_codecsToClose.push_back(stream->codec);
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 16, 100)
AVCodec *codec = avcodec_find_decoder(stream->codecpar->codec_id);
AVCodecContext *codecCtx = avcodec_alloc_context3(codec);
#else
AVCodecContext *codecCtx = stream->codec;
#endif
m_codecsToClose.push_back(codecCtx);
return true;
}
}

View File

@ -31,6 +31,7 @@ extern "C" {
#include "libavformat/avformat.h"
#include "libswresample/swresample.h"
#include "libavutil/samplefmt.h"
#include "libavcodec/avcodec.h"
}
#endif // USE_FFMPEG

View File

@ -27,6 +27,18 @@ struct AVCodec;
struct AVCodecContext;
struct SwrContext;
#ifdef USE_FFMPEG
extern "C" {
#include "libavutil/version.h"
};
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(59, 16, 100)
#define AVCodec const AVCodec
#endif
#endif
// Wraps FFMPEG for audio decoding in a nice interface.
// Decodes packet by packet - does NOT demux.