blender: backport ffmpeg 7 fixes
one PR was force pushed and merged in the meantime, so the checksum is different pass -Wno-incompatible-pointer-types to work around errors with gcc 14
This commit is contained in:
@@ -12,7 +12,7 @@ _realname=blender
|
||||
pkgbase=mingw-w64-${_realname}
|
||||
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
|
||||
pkgver=4.0.2
|
||||
pkgrel=3
|
||||
pkgrel=4
|
||||
pkgdesc="A fully integrated 3D graphics creation suite (mingw-w64)"
|
||||
arch=('any')
|
||||
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
|
||||
@@ -107,13 +107,15 @@ source=(https://download.blender.org/source/${_realname}-${pkgver}.tar.xz
|
||||
0033-dont-add-fno-rtti-compile-option.patch
|
||||
0034-Fix-ARM64-Build.patch
|
||||
0035-Enable-SSE2NEON-on-Windows-ARM.patch
|
||||
0039-no-WRL-on-mingw-w64.patch)
|
||||
0039-no-WRL-on-mingw-w64.patch
|
||||
ffmpeg-7-1.patch
|
||||
ffmpeg-7-2.patch)
|
||||
sha256sums=('aaa0e729da7591cfbf45772af76345977daaa7b11a0af35d98f9313e246077a3'
|
||||
'ec7e34e7c0d475b08745017952b2c912b2b1dedf5e051141cd9a987e1c3b13b6'
|
||||
'ee9b8f5c191a59960682729d89f7c51e3c9bf50992d6b86f933d05b98e4c5a72'
|
||||
'11fd854c62dc276f3edace85e285764506091e9203abf7c90dcad98005e9cfc7'
|
||||
'891c19119b5cb6ff05b93ed8183841593bc20444dd4070bc5c69a701d857e030'
|
||||
'd510478d3918c866df832db7936fde02cc6267765ab6c8b17770ccf3850dc1db'
|
||||
'8dca82884a01f38b2121eb7ab16f7bb882f35878db57b95ab9d98aec4f80ba8d'
|
||||
'2cd8eea86a67a330d8eadb09ec1bafbe99a4c910654aa65dc1c6389b1e6ae678'
|
||||
'1ccbf571e8dae23d0bff4ac848825788ac0a838261c5b02578c30852061238c8'
|
||||
'94b1299ff8fff061e1387e5ed14b4c1c58ae834c30c3360a0c53aaadf226064f'
|
||||
@@ -136,7 +138,9 @@ sha256sums=('aaa0e729da7591cfbf45772af76345977daaa7b11a0af35d98f9313e246077a3'
|
||||
'16b560363717357a0e69d3b46269cace9bf978126e08b604ad18a532a8dfd0b2'
|
||||
'a48e49b9e6034ccd3b448bc44f4f30a4d64682e8820f68d470069c9cbcf8b6c7'
|
||||
'439c4d0978e3690f42a2c7b84a9fa91ed9b27979f244d4e8edd1461fe20d7011'
|
||||
'70d0cfa0ca9f7a948b248174ab516867f31e76361b7aabb70de05688ee78f92c')
|
||||
'70d0cfa0ca9f7a948b248174ab516867f31e76361b7aabb70de05688ee78f92c'
|
||||
'17d5fb1c4ddb9e95da590d2e43ae3f7ce2b02c3ec698b16ed2752e3b3e7840c0'
|
||||
'499a9ec9a1aa7c5ef26ce5bb26f48576cccf1fc5906e966f92e25506405e9ad0')
|
||||
|
||||
apply_patch_with_msg() {
|
||||
for _patch in "$@"
|
||||
@@ -183,6 +187,12 @@ prepare() {
|
||||
0035-Enable-SSE2NEON-on-Windows-ARM.patch \
|
||||
0039-no-WRL-on-mingw-w64.patch
|
||||
|
||||
# https://projects.blender.org/blender/blender/pulls/121960
|
||||
# https://projects.blender.org/blender/blender/pulls/121947
|
||||
apply_patch_with_msg \
|
||||
ffmpeg-7-1.patch \
|
||||
ffmpeg-7-2.patch
|
||||
|
||||
# Remove *.orig files
|
||||
find . -type f -name "*.orig" -exec rm -f {} \;
|
||||
}
|
||||
@@ -204,6 +214,11 @@ build() {
|
||||
CFLAGS+=" -Wno-unreachable-code-generic-assoc"
|
||||
fi
|
||||
|
||||
if [[ $MINGW_PACKAGE_PREFIX != *-clang-* ]]; then
|
||||
CFLAGS+=" -Wno-incompatible-pointer-types"
|
||||
CXXFLAGS+=" -Wno-incompatible-pointer-types"
|
||||
fi
|
||||
|
||||
if [[ $CARCH == "aarch64" ]]; then
|
||||
_extra_config+=("-DSSE2NEON_ROOT_DIR=${MINGW_PREFIX}/include/sse2neon")
|
||||
fi
|
||||
|
||||
67
mingw-w64-blender/ffmpeg-7-1.patch
Normal file
67
mingw-w64-blender/ffmpeg-7-1.patch
Normal file
@@ -0,0 +1,67 @@
|
||||
From c72dbeafffa5b3262e90023e092bb1f9928d7079 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Robert-Andr=C3=A9=20Mauchin?= <zebob.m@gmail.com>
|
||||
Date: Tue, 14 May 2024 11:03:49 +0200
|
||||
Subject: [PATCH] Add compatibility with FFMPEG 7.0
|
||||
|
||||
key_frame was deprecated then remove, we should use AV_FRAME_FLAG_KEY
|
||||
instead.
|
||||
|
||||
read_seek2 and read_seek were internalized and can't be used anymore, so
|
||||
we check directly the return of av_seek_frame.
|
||||
---
|
||||
intern/ffmpeg/ffmpeg_compat.h | 9 +++++++++
|
||||
source/blender/imbuf/intern/anim_movie.cc | 11 +++++------
|
||||
2 files changed, 14 insertions(+), 6 deletions(-)
|
||||
|
||||
diff --git a/intern/ffmpeg/ffmpeg_compat.h b/intern/ffmpeg/ffmpeg_compat.h
|
||||
index 91ea1701db6..78778482e8d 100644
|
||||
--- a/intern/ffmpeg/ffmpeg_compat.h
|
||||
+++ b/intern/ffmpeg/ffmpeg_compat.h
|
||||
@@ -141,6 +141,15 @@ int64_t av_get_frame_duration_in_pts_units(const AVFrame *picture)
|
||||
#endif
|
||||
}
|
||||
|
||||
+FFMPEG_INLINE
|
||||
+bool av_get_cur_key_frame_pts(const AVFrame *picture) {
|
||||
+#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(58, 29, 100)
|
||||
+ return (picture->flags & AV_FRAME_FLAG_KEY);
|
||||
+#else
|
||||
+ return (picture->key_frame);
|
||||
+#endif
|
||||
+}
|
||||
+
|
||||
/* -------------------------------------------------------------------- */
|
||||
/** \name Deinterlace code block
|
||||
*
|
||||
diff --git a/source/blender/imbuf/intern/anim_movie.cc b/source/blender/imbuf/intern/anim_movie.cc
|
||||
index 3d51969dd46..bb07a8bb14c 100644
|
||||
--- a/source/blender/imbuf/intern/anim_movie.cc
|
||||
+++ b/source/blender/imbuf/intern/anim_movie.cc
|
||||
@@ -653,7 +653,7 @@ static void ffmpeg_decode_store_frame_pts(ImBufAnim *anim)
|
||||
{
|
||||
anim->cur_pts = av_get_pts_from_frame(anim->pFrame);
|
||||
|
||||
- if (anim->pFrame->key_frame) {
|
||||
+ if (av_get_cur_key_frame_pts(anim->pFrame)) {
|
||||
anim->cur_key_frame_pts = anim->cur_pts;
|
||||
}
|
||||
|
||||
@@ -1032,11 +1032,10 @@ static int ffmpeg_seek_to_key_frame(ImBufAnim *anim,
|
||||
|
||||
AVFormatContext *format_ctx = anim->pFormatCtx;
|
||||
|
||||
- if (format_ctx->iformat->read_seek2 || format_ctx->iformat->read_seek) {
|
||||
- ret = av_seek_frame(anim->pFormatCtx, anim->videoStream, seek_pos, AVSEEK_FLAG_BACKWARD);
|
||||
- }
|
||||
- else {
|
||||
- ret = ffmpeg_generic_seek_workaround(anim, &seek_pos, pts_to_search);
|
||||
+ int ret = av_seek_frame(anim->pFormatCtx, anim->videoStream, seek_pos, AVSEEK_FLAG_BACKWARD);
|
||||
+
|
||||
+ if (ret < 0) {
|
||||
+ ret = ffmpeg_generic_seek_workaround(anim, &seek_pos, pts_to_search);\
|
||||
av_log(anim->pFormatCtx,
|
||||
AV_LOG_DEBUG,
|
||||
"Adjusted final seek seek_pos = %" PRId64 "\n",
|
||||
--
|
||||
2.30.2
|
||||
|
||||
184
mingw-w64-blender/ffmpeg-7-2.patch
Normal file
184
mingw-w64-blender/ffmpeg-7-2.patch
Normal file
@@ -0,0 +1,184 @@
|
||||
From fc8955ebbbb5d0afde2722b836dec8b4e07f2232 Mon Sep 17 00:00:00 2001
|
||||
From: =?UTF-8?q?Robert-Andr=C3=A9=20Mauchin?= <zebob.m@gmail.com>
|
||||
Date: Sat, 18 May 2024 22:08:34 +0200
|
||||
Subject: [PATCH] Add compatibility with FFmpeg 7.0 within audaspace plugin
|
||||
|
||||
We backport changes specific to FFmpeg 7.0 in audaspace, behind
|
||||
HAVE_CH_LAYOUT, ensuring compatibility with previous versions.
|
||||
---
|
||||
.../audaspace/plugins/ffmpeg/FFMPEGReader.cpp | 27 +++++++++--
|
||||
.../audaspace/plugins/ffmpeg/FFMPEGWriter.cpp | 46 +++++++++++++++++++
|
||||
2 files changed, 69 insertions(+), 4 deletions(-)
|
||||
|
||||
diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
|
||||
index c0e16d6a887..3257daab442 100644
|
||||
--- a/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
|
||||
+++ b/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
|
||||
@@ -31,6 +31,10 @@ AUD_NAMESPACE_BEGIN
|
||||
#define FFMPEG_OLD_CODE
|
||||
#endif
|
||||
|
||||
+#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 28, 100)
|
||||
+#define HAVE_CH_LAYOUT
|
||||
+#endif
|
||||
+
|
||||
SampleFormat FFMPEGReader::convertSampleFormat(AVSampleFormat format)
|
||||
{
|
||||
switch(av_get_packed_sample_fmt(format))
|
||||
@@ -104,15 +108,22 @@ int FFMPEGReader::decode(AVPacket& packet, Buffer& buffer)
|
||||
packet.size = orig_size;
|
||||
#else
|
||||
avcodec_send_packet(m_codecCtx, &packet);
|
||||
+
|
||||
|
||||
while(true)
|
||||
{
|
||||
auto ret = avcodec_receive_frame(m_codecCtx, m_frame);
|
||||
|
||||
+#ifdef HAVE_CH_LAYOUT
|
||||
+ int nb_channels = m_codecCtx->ch_layout.nb_channels;
|
||||
+#else
|
||||
+ int nb_channels = m_codecCtx->channels;
|
||||
+#endif
|
||||
+
|
||||
if(ret != 0)
|
||||
break;
|
||||
|
||||
- int data_size = av_samples_get_buffer_size(nullptr, m_codecCtx->channels, m_frame->nb_samples, m_codecCtx->sample_fmt, 1);
|
||||
+ int data_size = av_samples_get_buffer_size(nullptr, nb_channels, m_frame->nb_samples, m_codecCtx->sample_fmt, 1);
|
||||
|
||||
if(buf_size - buf_pos < data_size)
|
||||
{
|
||||
@@ -122,12 +133,12 @@ int FFMPEGReader::decode(AVPacket& packet, Buffer& buffer)
|
||||
|
||||
if(m_tointerleave)
|
||||
{
|
||||
- int single_size = data_size / m_codecCtx->channels / m_frame->nb_samples;
|
||||
- for(int channel = 0; channel < m_codecCtx->channels; channel++)
|
||||
+ int single_size = data_size / nb_channels / m_frame->nb_samples;
|
||||
+ for(int channel = 0; channel < nb_channels; channel++)
|
||||
{
|
||||
for(int i = 0; i < m_frame->nb_samples; i++)
|
||||
{
|
||||
- std::memcpy(((data_t*)buffer.getBuffer()) + buf_pos + ((m_codecCtx->channels * i) + channel) * single_size,
|
||||
+ std::memcpy(((data_t*)buffer.getBuffer()) + buf_pos + ((nb_channels * i) + channel) * single_size,
|
||||
m_frame->data[channel] + i * single_size, single_size);
|
||||
}
|
||||
}
|
||||
@@ -207,7 +218,11 @@ void FFMPEGReader::init(int stream)
|
||||
if(avcodec_open2(m_codecCtx, aCodec, nullptr) < 0)
|
||||
AUD_THROW(FileException, "File couldn't be read, ffmpeg codec couldn't be opened.");
|
||||
|
||||
+#ifdef HAVE_CH_LAYOUT
|
||||
+ m_specs.channels = (Channels) m_codecCtx->ch_layout.nb_channels;
|
||||
+#else
|
||||
m_specs.channels = (Channels) m_codecCtx->channels;
|
||||
+#endif
|
||||
m_tointerleave = av_sample_fmt_is_planar(m_codecCtx->sample_fmt);
|
||||
|
||||
switch(av_get_packed_sample_fmt(m_codecCtx->sample_fmt))
|
||||
@@ -344,8 +359,12 @@ std::vector<StreamInfo> FFMPEGReader::queryStreams()
|
||||
info.specs.channels = Channels(m_formatCtx->streams[i]->codec->channels);
|
||||
info.specs.rate = m_formatCtx->streams[i]->codec->sample_rate;
|
||||
info.specs.format = convertSampleFormat(m_formatCtx->streams[i]->codec->sample_fmt);
|
||||
+#else
|
||||
+#ifdef HAVE_CH_LAYOUT
|
||||
+ info.specs.channels = Channels(m_formatCtx->streams[i]->codecpar->ch_layout.nb_channels);
|
||||
#else
|
||||
info.specs.channels = Channels(m_formatCtx->streams[i]->codecpar->channels);
|
||||
+#endif
|
||||
info.specs.rate = m_formatCtx->streams[i]->codecpar->sample_rate;
|
||||
info.specs.format = convertSampleFormat(AVSampleFormat(m_formatCtx->streams[i]->codecpar->format));
|
||||
#endif
|
||||
diff --git a/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp b/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp
|
||||
index 9cadfe9c092..2f435c14b56 100644
|
||||
--- a/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp
|
||||
+++ b/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp
|
||||
@@ -34,6 +34,10 @@ AUD_NAMESPACE_BEGIN
|
||||
#define FFMPEG_OLD_CODE
|
||||
#endif
|
||||
|
||||
+#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(57, 28, 100)
|
||||
+#define HAVE_CH_LAYOUT
|
||||
+#endif
|
||||
+
|
||||
void FFMPEGWriter::encode()
|
||||
{
|
||||
sample_t* data = m_input_buffer.getBuffer();
|
||||
@@ -77,8 +81,12 @@ void FFMPEGWriter::encode()
|
||||
|
||||
m_frame->nb_samples = m_input_samples;
|
||||
m_frame->format = m_codecCtx->sample_fmt;
|
||||
+#ifdef HAVE_CH_LAYOUT
|
||||
+ av_channel_layout_copy(&m_frame->ch_layout, &m_codecCtx->ch_layout);
|
||||
+#else
|
||||
m_frame->channel_layout = m_codecCtx->channel_layout;
|
||||
m_frame->channels = m_specs.channels;
|
||||
+#endif
|
||||
|
||||
if(avcodec_fill_audio_frame(m_frame, m_specs.channels, m_codecCtx->sample_fmt, reinterpret_cast<data_t*>(data), m_input_buffer.getSize(), 0) < 0)
|
||||
AUD_THROW(FileException, "File couldn't be written, filling the audio frame failed with ffmpeg.");
|
||||
@@ -237,6 +245,39 @@ FFMPEGWriter::FFMPEGWriter(const std::string &filename, DeviceSpecs specs, Conta
|
||||
break;
|
||||
}
|
||||
|
||||
+#ifdef HAVE_CH_LAYOUT
|
||||
+ AVChannelLayout channel_layout{};
|
||||
+
|
||||
+ switch(m_specs.channels)
|
||||
+ {
|
||||
+ case CHANNELS_MONO:
|
||||
+ channel_layout = AV_CHANNEL_LAYOUT_MONO;
|
||||
+ break;
|
||||
+ case CHANNELS_STEREO:
|
||||
+ channel_layout = AV_CHANNEL_LAYOUT_STEREO;
|
||||
+ break;
|
||||
+ case CHANNELS_STEREO_LFE:
|
||||
+ channel_layout = AV_CHANNEL_LAYOUT_2POINT1;
|
||||
+ break;
|
||||
+ case CHANNELS_SURROUND4:
|
||||
+ channel_layout = AV_CHANNEL_LAYOUT_QUAD;
|
||||
+ break;
|
||||
+ case CHANNELS_SURROUND5:
|
||||
+ channel_layout = AV_CHANNEL_LAYOUT_5POINT0_BACK;
|
||||
+ break;
|
||||
+ case CHANNELS_SURROUND51:
|
||||
+ channel_layout = AV_CHANNEL_LAYOUT_5POINT1_BACK;
|
||||
+ break;
|
||||
+ case CHANNELS_SURROUND61:
|
||||
+ channel_layout = AV_CHANNEL_LAYOUT_6POINT1_BACK;
|
||||
+ break;
|
||||
+ case CHANNELS_SURROUND71:
|
||||
+ channel_layout = AV_CHANNEL_LAYOUT_7POINT1;
|
||||
+ break;
|
||||
+ default:
|
||||
+ AUD_THROW(FileException, "File couldn't be written, channel layout not supported.");
|
||||
+ }
|
||||
+#else
|
||||
uint64_t channel_layout = 0;
|
||||
|
||||
switch(m_specs.channels)
|
||||
@@ -268,6 +309,7 @@ FFMPEGWriter::FFMPEGWriter(const std::string &filename, DeviceSpecs specs, Conta
|
||||
default:
|
||||
AUD_THROW(FileException, "File couldn't be written, channel layout not supported.");
|
||||
}
|
||||
+#endif
|
||||
|
||||
try
|
||||
{
|
||||
@@ -405,8 +447,12 @@ FFMPEGWriter::FFMPEGWriter(const std::string &filename, DeviceSpecs specs, Conta
|
||||
|
||||
m_codecCtx->codec_type = AVMEDIA_TYPE_AUDIO;
|
||||
m_codecCtx->bit_rate = bitrate;
|
||||
+#ifdef HAVE_CH_LAYOUT
|
||||
+ av_channel_layout_copy(&m_codecCtx->ch_layout, &channel_layout);
|
||||
+#else
|
||||
m_codecCtx->channel_layout = channel_layout;
|
||||
m_codecCtx->channels = m_specs.channels;
|
||||
+#endif
|
||||
m_stream->time_base.num = m_codecCtx->time_base.num = 1;
|
||||
m_stream->time_base.den = m_codecCtx->time_base.den = m_codecCtx->sample_rate;
|
||||
|
||||
--
|
||||
2.30.2
|
||||
|
||||
Reference in New Issue
Block a user