1
0
mirror of https://github.com/dguglielmi/sunny-overlay.git synced 2025-12-06 22:32:37 +01:00
Files
sunny-overlay/media-tv/kodi/files/kodi-20.3-ffmpeg6.patch

625 lines
24 KiB
Diff

From c9e25dc15acf1214b079da7021ad89acf85fa77d Mon Sep 17 00:00:00 2001
From: CastagnaIT <gottardo.stefano.83@gmail.com>
Date: Sun, 29 Jan 2023 17:51:51 +0100
Subject: [PATCH] [VideoPlayerVideo] Log an error when codec extradata is
required
---
xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp b/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp
index 20f6b3b1cb51d..38f63f0766718 100644
--- a/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp
+++ b/xbmc/cores/VideoPlayer/VideoPlayerVideo.cpp
@@ -114,8 +114,11 @@ bool CVideoPlayerVideo::OpenStream(CDVDStreamInfo hint)
hint.codec == AV_CODEC_ID_WMV3 ||
hint.codec == AV_CODEC_ID_VC1 ||
hint.codec == AV_CODEC_ID_AV1)
- // clang-format on
+ {
+ CLog::LogF(LOGERROR, "Codec id {} require extradata.", hint.codec);
return false;
+ }
+ // clang-format on
}
CLog::Log(LOGINFO, "Creating video codec with codec id: {}", hint.codec);
From 2559466404d342428d43076bf90fcacc24313af0 Mon Sep 17 00:00:00 2001
From: enen92 <92enen@gmail.com>
Date: Mon, 6 Feb 2023 15:36:11 +0000
Subject: [PATCH] video: remove ffmpeg bsf hack
Manually setting the codecID on the bsf filter is wrong.
avcodec_parameters_copy should be used instead.
---
xbmc/cores/FFmpeg.cpp | 13 ++++++++-----
xbmc/cores/FFmpeg.h | 3 +--
.../VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp | 10 +++++++++-
.../VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp | 3 +--
4 files changed, 19 insertions(+), 10 deletions(-)
diff --git a/xbmc/cores/FFmpeg.cpp b/xbmc/cores/FFmpeg.cpp
index d071f6d8e33a3..73b7ea2ae875c 100644
--- a/xbmc/cores/FFmpeg.cpp
+++ b/xbmc/cores/FFmpeg.cpp
@@ -135,9 +135,7 @@ void ff_avutil_log(void* ptr, int level, const char* format, va_list va)
buffer.erase(0, start);
}
-std::tuple<uint8_t*, int> GetPacketExtradata(const AVPacket* pkt,
- const AVCodecParserContext* parserCtx,
- AVCodecContext* codecCtx)
+std::tuple<uint8_t*, int> GetPacketExtradata(const AVPacket* pkt, const AVCodecParameters* codecPar)
{
constexpr int FF_MAX_EXTRADATA_SIZE = ((1 << 28) - AV_INPUT_BUFFER_PADDING_SIZE);
@@ -151,7 +149,7 @@ std::tuple<uint8_t*, int> GetPacketExtradata(const AVPacket* pkt,
* for certain codecs, as noted in discussion of PR#21248
*/
- AVCodecID codecId = codecCtx->codec_id;
+ AVCodecID codecId = codecPar->codec_id;
// clang-format off
if (
@@ -178,7 +176,12 @@ std::tuple<uint8_t*, int> GetPacketExtradata(const AVPacket* pkt,
if (ret < 0)
return std::make_tuple(nullptr, 0);
- bsf->par_in->codec_id = codecId;
+ ret = avcodec_parameters_copy(bsf->par_in, codecPar);
+ if (ret < 0)
+ {
+ av_bsf_free(&bsf);
+ return std::make_tuple(nullptr, 0);
+ }
ret = av_bsf_init(bsf);
if (ret < 0)
diff --git a/xbmc/cores/FFmpeg.h b/xbmc/cores/FFmpeg.h
index 05547a0ba2b5f..5e35d58c6b0a6 100644
--- a/xbmc/cores/FFmpeg.h
+++ b/xbmc/cores/FFmpeg.h
@@ -73,5 +73,4 @@ class CFFmpegLog
};
std::tuple<uint8_t*, int> GetPacketExtradata(const AVPacket* pkt,
- const AVCodecParserContext* parserCtx,
- AVCodecContext* codecCtx);
+ const AVCodecParameters* codecPar);
diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp
index 052332331702a..9ca07b9a2dd39 100644
--- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp
+++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxClient.cpp
@@ -162,7 +162,15 @@ bool CDVDDemuxClient::ParsePacket(DemuxPacket* pkt)
avpkt->size = pkt->iSize;
avpkt->dts = avpkt->pts = AV_NOPTS_VALUE;
- auto [retExtraData, len] = GetPacketExtradata(avpkt, stream->m_parser, stream->m_context);
+ AVCodecParameters* codecPar = nullptr;
+ int ret = avcodec_parameters_from_context(codecPar, stream->m_context);
+ if (ret < 0)
+ {
+ CLog::LogF(LOGERROR, "avcodec_parameters_from_context failed");
+ return false;
+ }
+
+ auto [retExtraData, len] = GetPacketExtradata(avpkt, codecPar);
if (len > 0)
{
st->changes++;
diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
index 7e6a2e10616d7..bc6b54c87235d 100644
--- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
+++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
@@ -2290,8 +2290,7 @@ void CDVDDemuxFFmpeg::ParsePacket(AVPacket* pkt)
parser->second->m_parserCtx->parser &&
!st->codecpar->extradata)
{
- auto [retExtraData, i] =
- GetPacketExtradata(pkt, parser->second->m_parserCtx, parser->second->m_codecCtx);
+ auto [retExtraData, i] = GetPacketExtradata(pkt, st->codecpar);
if (i > 0)
{
st->codecpar->extradata_size = i;
From f30f1e6418ea60bc7cb081c59f5f1d9431d264e6 Mon Sep 17 00:00:00 2001
From: Lukas Rusak <lorusak@gmail.com>
Date: Sat, 11 Mar 2023 13:28:38 -0800
Subject: [PATCH 01/10] CDVDAudioCodecFFmpeg: ifdef use of
AV_CODEC_FLAG_TRUNCATED for ffmpeg 6.0
Signed-off-by: Lukas Rusak <lorusak@gmail.com>
---
xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp | 2 ++
1 file changed, 2 insertions(+)
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
index b2849c797dbc4..325bb0b7549ab 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
@@ -73,8 +73,10 @@ bool CDVDAudioCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
m_pCodecContext->debug = 0;
m_pCodecContext->workaround_bugs = 1;
+#if LIBAVCODEC_VERSION_MAJOR < 60
if (pCodec->capabilities & AV_CODEC_CAP_TRUNCATED)
m_pCodecContext->flags |= AV_CODEC_FLAG_TRUNCATED;
+#endif
m_matrixEncoding = AV_MATRIX_ENCODING_NONE;
m_channels = 0;
From 3b71910ee0bb650816456ecc9a21251aff650c4d Mon Sep 17 00:00:00 2001
From: Lukas Rusak <lorusak@gmail.com>
Date: Sat, 11 Mar 2023 13:29:18 -0800
Subject: [PATCH 02/10] CDVDAudioCodecFFmpeg: fix setting channel layout mask
when opening codec
Signed-off-by: Lukas Rusak <lorusak@gmail.com>
---
.../DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
index 325bb0b7549ab..d1fb2cfe96afc 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Audio/DVDAudioCodecFFmpeg.cpp
@@ -80,13 +80,21 @@
m_channels = 0;
#if LIBAVCODEC_BUILD >= AV_VERSION_INT(59, 37, 100) && \
LIBAVUTIL_BUILD >= AV_VERSION_INT(57, 28, 100)
- av_channel_layout_uninit(&m_pCodecContext->ch_layout);
- m_pCodecContext->ch_layout.order = AV_CHANNEL_ORDER_NATIVE;
- m_pCodecContext->ch_layout.nb_channels = hints.channels;
+ if (hints.channels > 0 && hints.channellayout > 0)
+ {
+ m_pCodecContext->ch_layout.order = AV_CHANNEL_ORDER_NATIVE;
+ m_pCodecContext->ch_layout.nb_channels = hints.channels;
+ m_pCodecContext->ch_layout.u.mask = hints.channellayout;
+ }
+ else if (hints.channels > 0)
+ {
+ av_channel_layout_default(&m_pCodecContext->ch_layout, hints.channels);
+ }
+
+ m_hint_layout = m_pCodecContext->ch_layout.u.mask;
#else
m_pCodecContext->channels = hints.channels;
#endif
- m_hint_layout = hints.channellayout;
m_pCodecContext->sample_rate = hints.samplerate;
m_pCodecContext->block_align = hints.blockalign;
m_pCodecContext->bit_rate = hints.bitrate;
From f4fadb3ba4583c45fb06908a3eb352be8c29f235 Mon Sep 17 00:00:00 2001
From: Lukas Rusak <lorusak@gmail.com>
Date: Sat, 11 Mar 2023 13:29:34 -0800
Subject: [PATCH 03/10] CDVDAudioCodecFFmpeg: drop unneeded use of
AVFMT_FLAG_PRIV_OPT
Signed-off-by: Lukas Rusak <lorusak@gmail.com>
---
xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp | 2 --
1 file changed, 2 deletions(-)
diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
index bc6b54c87235d..016d198206716 100644
--- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
+++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
@@ -323,7 +323,6 @@ bool CDVDDemuxFFmpeg::Open(const std::shared_ptr<CDVDInputStream>& pInput, bool
}
if (result < 0)
{
- m_pFormatContext->flags |= AVFMT_FLAG_PRIV_OPT;
if (avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, &options) < 0)
{
CLog::Log(LOGDEBUG, "Error, could not open file {}", CURL::GetRedacted(strFile));
@@ -335,7 +334,6 @@ bool CDVDDemuxFFmpeg::Open(const std::shared_ptr<CDVDInputStream>& pInput, bool
avformat_close_input(&m_pFormatContext);
m_pFormatContext = avformat_alloc_context();
m_pFormatContext->interrupt_callback = int_cb;
- m_pFormatContext->flags &= ~AVFMT_FLAG_PRIV_OPT;
AVDictionary* options = GetFFMpegOptionsFromInput();
av_dict_set_int(&options, "load_all_variants", 0, AV_OPT_SEARCH_CHILDREN);
if (avformat_open_input(&m_pFormatContext, strFile.c_str(), iformat, &options) < 0)
From 7d03f33b83e5fb127a7495798a20c3b63ac06795 Mon Sep 17 00:00:00 2001
From: Lukas Rusak <lorusak@gmail.com>
Date: Wed, 15 Mar 2023 19:58:56 -0700
Subject: [PATCH 04/10] CDVDVideoCodecFFmpeg: update filter args to use
key/value pairs
Signed-off-by: Lukas Rusak <lorusak@gmail.com>
---
.../VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
index bb9c20bf9d06e..c080589896ce7 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
@@ -1164,8 +1164,9 @@ int CDVDVideoCodecFFmpeg::FilterOpen(const std::string& filters, bool scale)
const AVFilter* outFilter = avfilter_get_by_name("buffersink"); // should be last filter in the graph for now
std::string args = StringUtils::Format(
- "{}:{}:{}:{}:{}:{}:{}", m_pCodecContext->width, m_pCodecContext->height,
- m_pCodecContext->pix_fmt, m_pCodecContext->time_base.num ? m_pCodecContext->time_base.num : 1,
+ "video_size={}x{}:pix_fmt={}:time_base={}/{}:pixel_aspect={}/{}", m_pCodecContext->width,
+ m_pCodecContext->height, m_pCodecContext->pix_fmt,
+ m_pCodecContext->time_base.num ? m_pCodecContext->time_base.num : 1,
m_pCodecContext->time_base.num ? m_pCodecContext->time_base.den : 1,
m_pCodecContext->sample_aspect_ratio.num != 0 ? m_pCodecContext->sample_aspect_ratio.num : 1,
m_pCodecContext->sample_aspect_ratio.num != 0 ? m_pCodecContext->sample_aspect_ratio.den : 1);
From 30bd7912802cf0f608751c452c48fc1a2eb8d91b Mon Sep 17 00:00:00 2001
From: Lukas Rusak <lorusak@gmail.com>
Date: Wed, 15 Mar 2023 19:59:27 -0700
Subject: [PATCH 05/10] CFFmpegPostproc: update filter args to use key/value
pairs
Signed-off-by: Lukas Rusak <lorusak@gmail.com>
---
xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
index 81b969d119667..6c4f664591a04 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
@@ -2962,10 +2962,11 @@ bool CFFmpegPostproc::Init(EINTERLACEMETHOD method)
const AVFilter* srcFilter = avfilter_get_by_name("buffer");
const AVFilter* outFilter = avfilter_get_by_name("buffersink");
- std::string args = StringUtils::Format("{}:{}:{}:{}:{}:{}:{}", m_config.vidWidth,
- m_config.vidHeight, AV_PIX_FMT_NV12, 1, 1,
- (m_config.aspect.num != 0) ? m_config.aspect.num : 1,
- (m_config.aspect.num != 0) ? m_config.aspect.den : 1);
+ std::string args =
+ StringUtils::Format("video_size={}x{}:pix_fmt={}:time_base={}/{}:pixel_aspect={}/{}",
+ m_config.vidWidth, m_config.vidHeight, AV_PIX_FMT_NV12, 1, 1,
+ (m_config.aspect.num != 0) ? m_config.aspect.num : 1,
+ (m_config.aspect.num != 0) ? m_config.aspect.den : 1);
if (avfilter_graph_create_filter(&m_pFilterIn, srcFilter, "src", args.c_str(), NULL, m_pFilterGraph) < 0)
{
From 54a21151374a2d40a2a452fae2709205ed8e8836 Mon Sep 17 00:00:00 2001
From: Lukas Rusak <lorusak@gmail.com>
Date: Sat, 11 Mar 2023 19:32:09 -0800
Subject: [PATCH 08/10] DXVA: CDecoder: replace removed av_mallocz_array with
av_calloc
ref: https://ffmpeg.org/doxygen/5.0/group__lavu__mem__funcs.html\#ga6627f140c3f70847bc6d9690a2fd001f
Signed-off-by: Lukas Rusak <lorusak@gmail.com>
---
xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp
index a1bc3761c59d1..c06bd1ac0c7e6 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp
@@ -972,7 +972,8 @@ CDecoder::CDecoder(CProcessInfo& processInfo)
m_event.Set();
m_avD3D11Context = av_d3d11va_alloc_context();
m_avD3D11Context->cfg = reinterpret_cast<D3D11_VIDEO_DECODER_CONFIG*>(av_mallocz(sizeof(D3D11_VIDEO_DECODER_CONFIG)));
- m_avD3D11Context->surface = reinterpret_cast<ID3D11VideoDecoderOutputView**>(av_mallocz_array(32, sizeof(ID3D11VideoDecoderOutputView*)));
+ m_avD3D11Context->surface = reinterpret_cast<ID3D11VideoDecoderOutputView**>(
+ av_calloc(32, sizeof(ID3D11VideoDecoderOutputView*)));
m_bufferPool.reset();
DX::Windowing()->Register(this);
From be1247d627cee6561174467094f1e8a46357df79 Mon Sep 17 00:00:00 2001
From: Lukas Rusak <lorusak@gmail.com>
Date: Sat, 11 Mar 2023 19:45:46 -0800
Subject: [PATCH 09/10] CFFmpegImage: remove deprecated use of pkt_duration
ref: https://ffmpeg.org/doxygen/6.0/structAVFrame.html\#a91725a40000e348b0607adf7f577e646
Signed-off-by: Lukas Rusak <lorusak@gmail.com>
---
xbmc/guilib/FFmpegImage.cpp | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/xbmc/guilib/FFmpegImage.cpp b/xbmc/guilib/FFmpegImage.cpp
index e71980998b2e5..7171c046a9ce5 100644
--- a/xbmc/guilib/FFmpegImage.cpp
+++ b/xbmc/guilib/FFmpegImage.cpp
@@ -294,7 +294,15 @@ AVFrame* CFFmpegImage::ExtractFrame()
return nullptr;
}
//we need milliseconds
- frame->pkt_duration = av_rescale_q(frame->pkt_duration, m_fctx->streams[0]->time_base, AVRational{ 1, 1000 });
+
+#if LIBAVCODEC_VERSION_MAJOR < 60
+ frame->pkt_duration =
+ av_rescale_q(frame->pkt_duration, m_fctx->streams[0]->time_base, AVRational{1, 1000});
+#else
+ frame->duration =
+ av_rescale_q(frame->duration, m_fctx->streams[0]->time_base, AVRational{1, 1000});
+#endif
+
m_height = frame->height;
m_width = frame->width;
m_originalWidth = m_width;
@@ -745,7 +753,13 @@ std::shared_ptr<Frame> CFFmpegImage::ReadFrame()
if (avframe == nullptr)
return nullptr;
std::shared_ptr<Frame> frame(new Frame());
+
+#if LIBAVCODEC_VERSION_MAJOR < 60
frame->m_delay = (unsigned int)avframe->pkt_duration;
+#else
+ frame->m_delay = (unsigned int)avframe->duration;
+#endif
+
frame->m_pitch = avframe->width * 4;
frame->m_pImage = (unsigned char*) av_malloc(avframe->height * frame->m_pitch);
DecodeFrame(avframe, avframe->width, avframe->height, frame->m_pitch, frame->m_pImage);
From c12af890b0973f7c86316087e823f8a31c6b2ed3 Mon Sep 17 00:00:00 2001
From: Lukas Rusak <lorusak@gmail.com>
Date: Sat, 11 Mar 2023 19:45:01 -0800
Subject: [PATCH 10/10] CDVDVideoCodecFFmpeg: remove deprecated use of
reordered_opaque
ref: https://ffmpeg.org/doxygen/6.0/structAVFrame.html#a12f572ed19a2cba6be3790393cee76b5
Signed-off-by: Lukas Rusak <lorusak@gmail.com>
---
.../DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp | 11 ++++++++++-
xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp | 6 ++++--
xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp | 3 +++
xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp | 5 ++++-
4 files changed, 21 insertions(+), 4 deletions(-)
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
index c080589896ce7..6a53ade4a7351 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DVDVideoCodecFFmpeg.cpp
@@ -370,6 +370,10 @@ bool CDVDVideoCodecFFmpeg::Open(CDVDStreamInfo &hints, CDVDCodecOptions &options
m_pCodecContext->get_format = GetFormat;
m_pCodecContext->codec_tag = hints.codec_tag;
+#if LIBAVCODEC_VERSION_MAJOR >= 60
+ m_pCodecContext->flags = AV_CODEC_FLAG_COPY_OPAQUE;
+#endif
+
// setup threading model
if (!(hints.codecOptions & CODEC_FORCE_SOFTWARE))
{
@@ -545,9 +549,10 @@ void CDVDVideoCodecFFmpeg::UpdateName()
CLog::Log(LOGDEBUG, "CDVDVideoCodecFFmpeg - Updated codec: {}", m_name);
}
+#if LIBAVCODEC_VERSION_MAJOR < 60
union pts_union
{
- double pts_d;
+ double pts_d;
int64_t pts_i;
};
@@ -557,6 +562,7 @@ static int64_t pts_dtoi(double pts)
u.pts_d = pts;
return u.pts_i;
}
+#endif
bool CDVDVideoCodecFFmpeg::AddData(const DemuxPacket &packet)
{
@@ -575,7 +581,10 @@ bool CDVDVideoCodecFFmpeg::AddData(const DemuxPacket &packet)
m_started = true;
m_dts = packet.dts;
+
+#if LIBAVCODEC_VERSION_MAJOR < 60
m_pCodecContext->reordered_opaque = pts_dtoi(packet.pts);
+#endif
AVPacket* avpkt = av_packet_alloc();
if (!avpkt)
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp
index c06bd1ac0c7e6..81451995ca1db 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/DXVA.cpp
@@ -1538,8 +1538,6 @@ int CDecoder::GetBuffer(AVCodecContext* avctx, AVFrame* pic)
return -1;
}
- pic->reordered_opaque = avctx->reordered_opaque;
-
for (unsigned i = 0; i < 4; i++)
{
pic->data[i] = nullptr;
@@ -1556,6 +1554,10 @@ int CDecoder::GetBuffer(AVCodecContext* avctx, AVFrame* pic)
}
pic->buf[0] = buffer;
+#if LIBAVCODEC_VERSION_MAJOR < 60
+ pic->reordered_opaque = avctx->reordered_opaque;
+#endif
+
Acquire();
return 0;
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
index 6c4f664591a04..447a13495d4e8 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VAAPI.cpp
@@ -867,7 +867,10 @@ int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic, int flags)
}
pic->buf[0] = buffer;
+#if LIBAVCODEC_VERSION_MAJOR < 60
pic->reordered_opaque = avctx->reordered_opaque;
+#endif
+
va->Acquire();
return 0;
}
diff --git a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp
index ec07af79de819..50e16d492ebc7 100644
--- a/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp
+++ b/xbmc/cores/VideoPlayer/DVDCodecs/Video/VDPAU.cpp
@@ -1041,7 +1041,10 @@ int CDecoder::FFGetBuffer(AVCodecContext *avctx, AVFrame *pic, int flags)
}
pic->buf[0] = buffer;
- pic->reordered_opaque= avctx->reordered_opaque;
+#if LIBAVCODEC_VERSION_MAJOR < 60
+ pic->reordered_opaque = avctx->reordered_opaque;
+#endif
+
return 0;
}
From 928a7e4196046154419727a23c734d904e5e1b6c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Markus=20H=C3=A4rer?= <markus.haerer@gmx.net>
Date: Sun, 23 Apr 2023 23:29:28 +0200
Subject: [PATCH] FFmpegImage: Switch back to jpeg_pipe for FFmpeg>=6.0
---
xbmc/guilib/FFmpegImage.cpp | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/xbmc/guilib/FFmpegImage.cpp b/xbmc/guilib/FFmpegImage.cpp
index 7171c046a9ce5..429037740a7d2 100644
--- a/xbmc/guilib/FFmpegImage.cpp
+++ b/xbmc/guilib/FFmpegImage.cpp
@@ -198,9 +198,16 @@ bool CFFmpegImage::Initialize(unsigned char* buffer, size_t bufSize)
bool is_png = (bufSize > 3 && buffer[1] == 'P' && buffer[2] == 'N' && buffer[3] == 'G');
bool is_tiff = (bufSize > 2 && buffer[0] == 'I' && buffer[1] == 'I' && buffer[2] == '*');
+ // See Github #19113
+#if LIBAVCODEC_VERSION_MAJOR < 60
+ constexpr char jpegFormat[] = "image2";
+#else
+ constexpr char jpegFormat[] = "jpeg_pipe";
+#endif
+
FFMPEG_FMT_CONST AVInputFormat* inp = nullptr;
if (is_jpeg)
- inp = av_find_input_format("image2");
+ inp = av_find_input_format(jpegFormat);
else if (m_strMimeType == "image/apng")
inp = av_find_input_format("apng");
else if (is_png)
@@ -213,7 +220,7 @@ bool CFFmpegImage::Initialize(unsigned char* buffer, size_t bufSize)
inp = av_find_input_format("webp_pipe");
// brute force parse if above check already failed
else if (m_strMimeType == "image/jpeg" || m_strMimeType == "image/jpg")
- inp = av_find_input_format("image2");
+ inp = av_find_input_format(jpegFormat);
else if (m_strMimeType == "image/png")
inp = av_find_input_format("png_pipe");
else if (m_strMimeType == "image/tiff")
From 9d7f4dfd00d89d4a5d6d8095ee9b0b746051b30c Mon Sep 17 00:00:00 2001
From: CrystalP <crystalp@kodi.tv>
Date: Mon, 1 May 2023 13:26:56 -0400
Subject: [PATCH] [fix] extern C for ffmpeg includes
---
xbmc/cores/RetroPlayer/process/RPProcessInfo.h | 3 +++
xbmc/cores/RetroPlayer/rendering/RenderTranslator.h | 3 +++
xbmc/cores/VideoPlayer/DVDFileInfo.cpp | 4 ++--
xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererDXVA.h | 4 ++++
.../VideoPlayer/VideoRenderers/windows/RendererShaders.h | 4 ++++
5 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/xbmc/cores/RetroPlayer/process/RPProcessInfo.h b/xbmc/cores/RetroPlayer/process/RPProcessInfo.h
index 9f930e78e9d84..f5ffe670d68aa 100644
--- a/xbmc/cores/RetroPlayer/process/RPProcessInfo.h
+++ b/xbmc/cores/RetroPlayer/process/RPProcessInfo.h
@@ -17,7 +17,10 @@
#include <string>
#include <vector>
+extern "C"
+{
#include <libavutil/pixfmt.h>
+}
class CDataCacheCore;
diff --git a/xbmc/cores/RetroPlayer/rendering/RenderTranslator.h b/xbmc/cores/RetroPlayer/rendering/RenderTranslator.h
index 575ad814fc125..d78e1c25e4070 100644
--- a/xbmc/cores/RetroPlayer/rendering/RenderTranslator.h
+++ b/xbmc/cores/RetroPlayer/rendering/RenderTranslator.h
@@ -10,7 +10,10 @@
#include "cores/GameSettings.h"
+extern "C"
+{
#include <libavutil/pixfmt.h>
+}
namespace KODI
{
diff --git a/xbmc/cores/VideoPlayer/DVDFileInfo.cpp b/xbmc/cores/VideoPlayer/DVDFileInfo.cpp
index 0860b40475b18..c7253bbd5497f 100644
--- a/xbmc/cores/VideoPlayer/DVDFileInfo.cpp
+++ b/xbmc/cores/VideoPlayer/DVDFileInfo.cpp
@@ -32,8 +32,6 @@
#include "DVDDemuxers/DVDDemuxVobsub.h"
#include "Process/ProcessInfo.h"
-#include <libavcodec/avcodec.h>
-#include <libswscale/swscale.h>
#include "filesystem/File.h"
#include "cores/FFmpeg.h"
#include "TextureCache.h"
@@ -44,7 +42,9 @@
#include <memory>
extern "C" {
+#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
+#include <libswscale/swscale.h>
}
bool CDVDFileInfo::GetFileDuration(const std::string &path, int& duration)
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererDXVA.h b/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererDXVA.h
index 9412377157f94..0eed9503dc9ac 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererDXVA.h
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererDXVA.h
@@ -13,7 +13,11 @@
#include <map>
#include <d3d11_4.h>
+
+extern "C"
+{
#include <libavutil/pixfmt.h>
+}
enum RenderMethod;
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererShaders.h b/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererShaders.h
index 945cadda76841..af4d677aae923 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererShaders.h
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/windows/RendererShaders.h
@@ -13,7 +13,11 @@
#include <map>
#include <d3d11_4.h>
+
+extern "C"
+{
#include <libavutil/pixfmt.h>
+}
#define PLANE_Y 0
#define PLANE_U 1