commit 2fa097d8c9562e52e9a204492d076b26c0456d2f
Author: Leigh Scott <leigh123linux(a)gmail.com>
Date: Wed Oct 9 00:19:51 2024 +0100
Fix the ffmpeg7 patch
24972.patch | 748 ----------------------------------------------------------
ffmpeg7.patch | 355 ++++++++++++++++++++++++++++
kodi.spec | 2 +-
3 files changed, 356 insertions(+), 749 deletions(-)
---
diff --git a/ffmpeg7.patch b/ffmpeg7.patch
new file mode 100644
index 0000000..6ec3110
--- /dev/null
+++ b/ffmpeg7.patch
@@ -0,0 +1,355 @@
+From 296f238388de29d107ad1534de0057b0794b23be Mon Sep 17 00:00:00 2001
+From: Stephan Sundermann <stephansundermann(a)gmail.com>
+Date: Thu, 11 Apr 2024 17:11:32 +0200
+Subject: [PATCH] [ffmpeg] Update to 7.1
+
+---
+ cmake/modules/FindFFMPEG.cmake | 16 +--
+ tools/buildsteps/windows/ffmpeg_options.txt | 1 -
+ tools/depends/target/ffmpeg/CMakeLists.txt | 6 +-
+ tools/depends/target/ffmpeg/FFMPEG-VERSION | 4 +-
+ xbmc/cdrip/EncoderFFmpeg.cpp | 2 +-
+ xbmc/cdrip/EncoderFFmpeg.h | 2 +-
+ .../ActiveAE/ActiveAEResampleFFMPEG.cpp | 116 +++++++++---------
+ .../DVDDemuxers/DVDDemuxFFmpeg.cpp | 71 +----------
+ 8 files changed, 72 insertions(+), 146 deletions(-)
+
+diff --git a/cmake/modules/FindFFMPEG.cmake b/cmake/modules/FindFFMPEG.cmake
+index 26dd6e8301da1..49f18ca9c2ad3 100644
+--- a/cmake/modules/FindFFMPEG.cmake
++++ b/cmake/modules/FindFFMPEG.cmake
+@@ -168,14 +168,14 @@ if(WITH_FFMPEG)
+ set(REQUIRED_FFMPEG_VERSION undef)
+ else()
+ # required ffmpeg library versions
+- set(REQUIRED_FFMPEG_VERSION 6.0.0)
+- set(_avcodec_ver ">=60.2.100")
+- set(_avfilter_ver ">=9.3.100")
+- set(_avformat_ver ">=60.3.100")
+- set(_avutil_ver ">=58.2.100")
+- set(_postproc_ver ">=57.1.100")
+- set(_swresample_ver ">=4.10.100")
+- set(_swscale_ver ">=7.1.100")
++ set(REQUIRED_FFMPEG_VERSION 7.0.0)
++ set(_avcodec_ver ">=61.3.100")
++ set(_avfilter_ver ">=10.1.100")
++ set(_avformat_ver ">=61.1.100")
++ set(_avutil_ver ">=59.8.100")
++ set(_postproc_ver ">=58.1.100")
++ set(_swresample_ver ">=5.1.100")
++ set(_swscale_ver ">=8.1.100")
+ endif()
+
+ # Allows building with external ffmpeg not found in system paths,
+diff --git a/tools/buildsteps/windows/ffmpeg_options.txt
b/tools/buildsteps/windows/ffmpeg_options.txt
+index 5034ff26c4073..776c0b4b35ac0 100644
+--- a/tools/buildsteps/windows/ffmpeg_options.txt
++++ b/tools/buildsteps/windows/ffmpeg_options.txt
+@@ -1,5 +1,4 @@
+ --disable-avdevice
+---disable-crystalhd
+ --disable-cuda
+ --disable-cuvid
+ --disable-devices
+diff --git a/tools/depends/target/ffmpeg/CMakeLists.txt
b/tools/depends/target/ffmpeg/CMakeLists.txt
+index 5cadafe29485b..8924dc8c7305b 100644
+--- a/tools/depends/target/ffmpeg/CMakeLists.txt
++++ b/tools/depends/target/ffmpeg/CMakeLists.txt
+@@ -92,14 +92,12 @@ elseif(CORE_SYSTEM_NAME STREQUAL android)
+ list(APPEND ffmpeg_conf --extra-cflags=-mno-stackrealign)
+ endif()
+ elseif(CORE_SYSTEM_NAME STREQUAL darwin_embedded)
+- list(APPEND ffmpeg_conf --disable-crystalhd
+- --enable-videotoolbox
++ list(APPEND ffmpeg_conf --enable-videotoolbox
+ --disable-filter=yadif_videotoolbox
+ --target-os=darwin
+ )
+ elseif(CORE_SYSTEM_NAME STREQUAL osx)
+- list(APPEND ffmpeg_conf --disable-crystalhd
+- --enable-videotoolbox
++ list(APPEND ffmpeg_conf --enable-videotoolbox
+ --target-os=darwin
+ --disable-securetransport
+ )
+diff --git a/tools/depends/target/ffmpeg/FFMPEG-VERSION
b/tools/depends/target/ffmpeg/FFMPEG-VERSION
+index f2ba09402e25a..3cb7bc8e0cd9e 100644
+--- a/tools/depends/target/ffmpeg/FFMPEG-VERSION
++++ b/tools/depends/target/ffmpeg/FFMPEG-VERSION
+@@ -1,5 +1,5 @@
+ LIBNAME=ffmpeg
+-VERSION=6.0.1
++VERSION=7.1
+ ARCHIVE=$(LIBNAME)-$(VERSION).tar.gz
+-SHA512=945e34840092dc0fd3824eb1af2be79868af2afb4fe13159b19a9bcfc464cc4d53243c13ff065199290e9393ddbf4b1c5c8abccf83a31a31d6c7490e499fd1fc
++SHA512=b0a82ca1a34fb9fa16ee4b7fa682d7c3fdcc68cd703c72487a2de434c714f2dede68d390e61dbb3669e435e271e4580d6bae00875d71a17ad39f43644c5fdd07
+
+diff --git a/xbmc/cdrip/EncoderFFmpeg.cpp b/xbmc/cdrip/EncoderFFmpeg.cpp
+index 85f5fa412e961..907d2591ddba7 100644
+--- a/xbmc/cdrip/EncoderFFmpeg.cpp
++++ b/xbmc/cdrip/EncoderFFmpeg.cpp
+@@ -235,7 +235,7 @@ void CEncoderFFmpeg::SetTag(const std::string& tag, const
std::string& value)
+ av_dict_set(&m_formatCtx->metadata, tag.c_str(), value.c_str(), 0);
+ }
+
+-int CEncoderFFmpeg::avio_write_callback(void* opaque, uint8_t* buf, int buf_size)
++int CEncoderFFmpeg::avio_write_callback(void* opaque, const uint8_t* buf, int buf_size)
+ {
+ CEncoderFFmpeg* enc = static_cast<CEncoderFFmpeg*>(opaque);
+ if (enc->Write(buf, buf_size) != buf_size)
+diff --git a/xbmc/cdrip/EncoderFFmpeg.h b/xbmc/cdrip/EncoderFFmpeg.h
+index 48471a4b10f70..4e9f0f5bbbad4 100644
+--- a/xbmc/cdrip/EncoderFFmpeg.h
++++ b/xbmc/cdrip/EncoderFFmpeg.h
+@@ -33,7 +33,7 @@ class CEncoderFFmpeg : public CEncoder
+ bool Close() override;
+
+ private:
+- static int avio_write_callback(void* opaque, uint8_t* buf, int buf_size);
++ static int avio_write_callback(void* opaque, const uint8_t* buf, int buf_size);
+ static int64_t avio_seek_callback(void* opaque, int64_t offset, int whence);
+
+ void SetTag(const std::string& tag, const std::string& value);
+diff --git a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp
b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp
+index 70e946a1160ef..a4fc91554f471 100644
+--- a/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp
++++ b/xbmc/cores/AudioEngine/Engines/ActiveAE/ActiveAEResampleFFMPEG.cpp
+@@ -66,51 +66,7 @@
+ AVChannelLayout dstChLayout = {};
+ AVChannelLayout srcChLayout = {};
+
+- av_channel_layout_from_mask(&dstChLayout, m_dst_chan_layout);
+- av_channel_layout_from_mask(&srcChLayout, m_src_chan_layout);
+-
+- int ret = swr_alloc_set_opts2(&m_pContext, &dstChLayout, m_dst_fmt,
m_dst_rate, &srcChLayout,
+- m_src_fmt, m_src_rate, 0, NULL);
+-
+- if (ret)
+- {
+- CLog::Log(LOGERROR, "CActiveAEResampleFFMPEG::Init - create context
failed");
+- return false;
+- }
+-
+- if(quality == AE_QUALITY_HIGH)
+- {
+- av_opt_set_double(m_pContext, "cutoff", 1.0, 0);
+- av_opt_set_int(m_pContext,"filter_size", 256, 0);
+- }
+- else if(quality == AE_QUALITY_MID)
+- {
+- // 0.97 is default cutoff so use (1.0 - 0.97) / 2.0 + 0.97
+- av_opt_set_double(m_pContext, "cutoff", 0.985, 0);
+- av_opt_set_int(m_pContext,"filter_size", 64, 0);
+- }
+- else if(quality == AE_QUALITY_LOW)
+- {
+- av_opt_set_double(m_pContext, "cutoff", 0.97, 0);
+- av_opt_set_int(m_pContext,"filter_size", 32, 0);
+- }
+-
+- if (m_dst_fmt == AV_SAMPLE_FMT_S32 || m_dst_fmt == AV_SAMPLE_FMT_S32P)
+- {
+- av_opt_set_int(m_pContext, "output_sample_bits", m_dst_bits, 0);
+- }
+-
+- // tell resampler to clamp float values
+- // not required for sink stage (remapLayout == true)
+- if ((m_dst_fmt == AV_SAMPLE_FMT_FLT || m_dst_fmt == AV_SAMPLE_FMT_FLTP) &&
+- (m_src_fmt == AV_SAMPLE_FMT_FLT || m_src_fmt == AV_SAMPLE_FMT_FLTP) &&
+- !remapLayout && normalize)
+- {
+- av_opt_set_double(m_pContext, "rematrix_maxval", 1.0, 0);
+- }
+-
+- av_opt_set_double(m_pContext, "center_mix_level", centerMix, 0);
+-
++ bool hasMatrix = false;
+ if (remapLayout)
+ {
+ // one-to-one mapping of channels
+@@ -120,28 +76,19 @@
+ m_dst_chan_layout = 0;
+ for (unsigned int out=0; out<remapLayout->Count(); out++)
+ {
+- m_dst_chan_layout += ((uint64_t)1) << out;
++ m_dst_chan_layout += static_cast<uint64_t>(1) << out;
+ int idx = CAEUtil::GetAVChannelIndex((*remapLayout)[out], m_src_chan_layout);
+ if (idx >= 0)
+ {
+ m_rematrix[out][idx] = 1.0;
+ }
+ }
+-
+- av_opt_set_int(m_pContext, "out_channel_count", m_dst_channels, 0);
+- av_opt_set_int(m_pContext, "out_channel_layout", m_dst_chan_layout, 0);
+-
+- if (swr_set_matrix(m_pContext, (const double*)m_rematrix, AE_CH_MAX) < 0)
+- {
+- CLog::Log(LOGERROR, "CActiveAEResampleFFMPEG::Init - setting channel matrix
failed");
+- return false;
+- }
++ hasMatrix = true;
+ }
+ // stereo upmix
+ else if (upmix && m_src_channels == 2 && m_dst_channels > 2)
+ {
+ memset(m_rematrix, 0, sizeof(m_rematrix));
+- av_channel_layout_uninit(&dstChLayout);
+ av_channel_layout_from_mask(&dstChLayout, m_dst_chan_layout);
+ for (int out=0; out<m_dst_channels; out++)
+ {
+@@ -171,14 +118,63 @@
+ }
+ }
+
++ hasMatrix = true;
+ av_channel_layout_uninit(&dstChLayout);
+-
+- if (swr_set_matrix(m_pContext, (const double*)m_rematrix, AE_CH_MAX) < 0)
++ }
++
++ av_channel_layout_from_mask(&dstChLayout, m_dst_chan_layout);
++ av_channel_layout_from_mask(&srcChLayout, m_src_chan_layout);
++
++ int ret = swr_alloc_set_opts2(&m_pContext, &dstChLayout, m_dst_fmt,
m_dst_rate, &srcChLayout,
++ m_src_fmt, m_src_rate, 0, NULL);
++
++ if (ret)
++ {
++ CLog::Log(LOGERROR, "CActiveAEResampleFFMPEG::Init - create context
failed");
++ return false;
++ }
++
++ if (hasMatrix)
++ {
++ if (swr_set_matrix(m_pContext, reinterpret_cast<const double*>(m_rematrix),
AE_CH_MAX) < 0)
+ {
+ CLog::Log(LOGERROR, "CActiveAEResampleFFMPEG::Init - setting channel matrix
failed");
+ return false;
+ }
+ }
++
++ if (quality == AE_QUALITY_HIGH)
++ {
++ av_opt_set_double(m_pContext, "cutoff", 1.0, 0);
++ av_opt_set_int(m_pContext, "filter_size", 256, 0);
++ }
++ else if (quality == AE_QUALITY_MID)
++ {
++ // 0.97 is default cutoff so use (1.0 - 0.97) / 2.0 + 0.97
++ av_opt_set_double(m_pContext, "cutoff", 0.985, 0);
++ av_opt_set_int(m_pContext, "filter_size", 64, 0);
++ }
++ else if (quality == AE_QUALITY_LOW)
++ {
++ av_opt_set_double(m_pContext, "cutoff", 0.97, 0);
++ av_opt_set_int(m_pContext, "filter_size", 32, 0);
++ }
++
++ if (m_dst_fmt == AV_SAMPLE_FMT_S32 || m_dst_fmt == AV_SAMPLE_FMT_S32P)
++ {
++ av_opt_set_int(m_pContext, "output_sample_bits", m_dst_bits, 0);
++ }
++
++ // tell resampler to clamp float values
++ // not required for sink stage (remapLayout == true)
++ if ((m_dst_fmt == AV_SAMPLE_FMT_FLT || m_dst_fmt == AV_SAMPLE_FMT_FLTP) &&
++ (m_src_fmt == AV_SAMPLE_FMT_FLT || m_src_fmt == AV_SAMPLE_FMT_FLTP) &&
!remapLayout &&
++ normalize)
++ {
++ av_opt_set_double(m_pContext, "rematrix_maxval", 1.0, 0);
++ }
++
++ av_opt_set_double(m_pContext, "center_mix_level", centerMix, 0);
+
+ if(swr_init(m_pContext) < 0)
+ {
+diff --git a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
+index 458b54114df84..3c6fccceb069f 100644
+--- a/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
++++ b/xbmc/cores/VideoPlayer/DVDDemuxers/DVDDemuxFFmpeg.cpp
+@@ -376,74 +376,7 @@ bool CDVDDemuxFFmpeg::Open(const
std::shared_ptr<CDVDInputStream>& pInput, bool
+ if (iformat == nullptr)
+ {
+ // let ffmpeg decide which demuxer we have to open
+- bool trySPDIFonly = (m_pInput->GetContent() ==
"audio/x-spdif-compressed");
+-
+- if (!trySPDIFonly)
+- av_probe_input_buffer(m_ioContext, &iformat, strFile.c_str(), NULL, 0, 0);
+-
+- // Use the more low-level code in case we have been built against an old
+- // FFmpeg without the above av_probe_input_buffer(), or in case we only
+- // want to probe for spdif (DTS or IEC 61937) compressed audio
+- // specifically, or in case the file is a wav which may contain DTS or
+- // IEC 61937 (e.g. ac3-in-wav) and we want to check for those formats.
+- if (trySPDIFonly || (iformat && strcmp(iformat->name, "wav")
== 0))
+- {
+- AVProbeData pd;
+- int probeBufferSize = 32768;
+- std::unique_ptr<uint8_t[]> probe_buffer (new uint8_t[probeBufferSize +
AVPROBE_PADDING_SIZE]);
+-
+- // init probe data
+- pd.buf = probe_buffer.get();
+- pd.filename = strFile.c_str();
+-
+- // read data using avformat's buffers
+- pd.buf_size = avio_read(m_ioContext, pd.buf, probeBufferSize);
+- if (pd.buf_size <= 0)
+- {
+- CLog::Log(LOGERROR, "{} - error reading from input stream, {}",
__FUNCTION__,
+- CURL::GetRedacted(strFile));
+- return false;
+- }
+- memset(pd.buf + pd.buf_size, 0, AVPROBE_PADDING_SIZE);
+-
+- // restore position again
+- avio_seek(m_ioContext , 0, SEEK_SET);
+-
+- // the advancedsetting is for allowing the user to force outputting the
+- // 44.1 kHz DTS wav file as PCM, so that an A/V receiver can decode
+- // it (this is temporary until we handle 44.1 kHz passthrough properly)
+- if (trySPDIFonly || (iformat && strcmp(iformat->name,
"wav") == 0 &&
!CServiceBroker::GetSettingsComponent()->GetAdvancedSettings()->m_VideoPlayerIgnoreDTSinWAV))
+- {
+- // check for spdif and dts
+- // This is used with wav files and audio CDs that may contain
+- // a DTS or AC3 track padded for S/PDIF playback. If neither of those
+- // is present, we assume it is PCM audio.
+- // AC3 is always wrapped in iec61937 (ffmpeg "spdif"), while DTS
+- // may be just padded.
+- const AVInputFormat* iformat2 = av_find_input_format("spdif");
+- if (iformat2 && iformat2->read_probe(&pd) >
AVPROBE_SCORE_MAX / 4)
+- {
+- iformat = iformat2;
+- }
+- else
+- {
+- // not spdif or no spdif demuxer, try dts
+- iformat2 = av_find_input_format("dts");
+-
+- if (iformat2 && iformat2->read_probe(&pd) >
AVPROBE_SCORE_MAX / 4)
+- {
+- iformat = iformat2;
+- }
+- else if (trySPDIFonly)
+- {
+- // not dts either, return false in case we were explicitly
+- // requested to only check for S/PDIF padded compressed audio
+- CLog::Log(LOGDEBUG, "{} - not spdif or dts file, falling back",
__FUNCTION__);
+- return false;
+- }
+- }
+- }
+- }
++ av_probe_input_buffer(m_ioContext, &iformat, strFile.c_str(), NULL, 0, 0);
+
+ if (!iformat)
+ {
+@@ -1353,7 +1286,7 @@ bool CDVDDemuxFFmpeg::SeekTime(double time, bool backwards, double*
startpts)
+
+ if (ret >= 0)
+ {
+- if (m_pFormatContext->iformat->read_seek)
++ if (!(m_pFormatContext->iformat->flags & AVFMT_NOTIMESTAMPS))
+ m_seekToKeyFrame = true;
+ m_currentPts = DVD_NOPTS_VALUE;
+ }
diff --git a/kodi.spec b/kodi.spec
index 074124c..e71084d 100644
--- a/kodi.spec
+++ b/kodi.spec
@@ -82,7 +82,7 @@ Patch1: fix_py313.patch
# ffmpeg-7 fix
#
https://github.com/xbmc/xbmc/pull/24972
-Patch2: 24972.patch
+Patch2: ffmpeg7.patch
%ifarch x86_64
%global _with_crystalhd 1