Re: graphics/blender: compatibility with ffmpeg 9.0

Kirill A. Korinsky <[email protected]>
Newsgroups gmane.os.openbsd.ports
Message-ID <[email protected]>
On Tue, 11 Aug 2026 00:13:26 +0200,
Daniel Dickman <[email protected]> wrote:
> 
> Is there a reason not to go with the upstram fix for this?
> 
> See https://github.com/audaspace/audaspace/commit/8841635
> 

Not at all.

Thanks.

I had made that diff a few days ago, and at that time audaspace hadn't got
that commit.

Here updated diff which is based on upstream commit.

Index: Makefile
===================================================================
RCS file: /cvs/ports/graphics/blender/Makefile,v
diff -u -p -r1.151 Makefile
--- Makefile	2 Mar 2026 15:00:23 -0000	1.151
+++ Makefile	10 Aug 2026 22:23:53 -0000
@@ -9,7 +9,7 @@ COMMENT =	3D creation software
 VERSION =	4.5.3
 V =		${VERSION:R}
 DISTNAME =	blender-${VERSION}
-REVISION =	3
+REVISION =	4
 
 CATEGORIES =	graphics
 
Index: patches/patch-extern_audaspace_plugins_ffmpeg_FFMPEGWriter_cpp
===================================================================
RCS file: patches/patch-extern_audaspace_plugins_ffmpeg_FFMPEGWriter_cpp
diff -N patches/patch-extern_audaspace_plugins_ffmpeg_FFMPEGWriter_cpp
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-extern_audaspace_plugins_ffmpeg_FFMPEGWriter_cpp	10 Aug 2026 22:23:53 -0000
@@ -0,0 +1,131 @@
+https://github.com/audaspace/audaspace/commit/8841635656806e388b51d3f4e3696bfc247a3f5a
+
+Index: extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp
+--- extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp.orig
++++ extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp
+@@ -38,6 +38,10 @@ AUD_NAMESPACE_BEGIN
+ #if LIBAVCODEC_VERSION_MAJOR < 59
+ #define FFMPEG_OLD_CH_LAYOUT
+ #endif
++/* FFmpeg >= 8.0 */
++#if LIBAVCODEC_VERSION_MAJOR >= 62
++#define FFMPEG_SUPPORTED_CONFIG
++#endif
+ 
+ void FFMPEGWriter::encode()
+ {
+@@ -330,8 +334,106 @@ FFMPEGWriter::FFMPEGWriter(const std::string &filename
+ 		if(m_formatCtx->oformat->flags & AVFMT_GLOBALHEADER)
+ 			m_codecCtx->flags |= AV_CODEC_FLAG_GLOBAL_HEADER;
+ 
++#ifdef FFMPEG_SUPPORTED_CONFIG
++		const AVSampleFormat* supported_sample_fmts = nullptr;
++		int num_sample_fmts = 0;
++		if(avcodec_get_supported_config(m_codecCtx, codec, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0,
++										reinterpret_cast<const void**>(&supported_sample_fmts), &num_sample_fmts) < 0)
++			AUD_THROW(FileException, "File couldn't be written, couldn't retrieve supported sample formats.");
++
+ 		bool format_supported = false;
+ 
++		if(supported_sample_fmts)
++		{
++			for(int i = 0; i < num_sample_fmts; i++)
++			{
++				if(av_get_alt_sample_fmt(supported_sample_fmts[i], false) == m_codecCtx->sample_fmt)
++				{
++					m_deinterleave = av_sample_fmt_is_planar(supported_sample_fmts[i]);
++					m_codecCtx->sample_fmt = supported_sample_fmts[i];
++					format_supported = true;
++				}
++			}
++
++			if(!format_supported && num_sample_fmts > 0)
++			{
++				int chosen_index = 0;
++				auto chosen = av_get_alt_sample_fmt(supported_sample_fmts[chosen_index], false);
++				for(int i = 1; i < num_sample_fmts; i++)
++				{
++					auto fmt = av_get_alt_sample_fmt(supported_sample_fmts[i], false);
++					if((fmt > chosen && chosen < m_codecCtx->sample_fmt) || (fmt > m_codecCtx->sample_fmt && fmt < chosen))
++					{
++						chosen = fmt;
++						chosen_index = i;
++					}
++				}
++
++				m_codecCtx->sample_fmt = supported_sample_fmts[chosen_index];
++				m_deinterleave = av_sample_fmt_is_planar(m_codecCtx->sample_fmt);
++				switch(av_get_alt_sample_fmt(m_codecCtx->sample_fmt, false))
++				{
++				case AV_SAMPLE_FMT_U8:
++					specs.format = FORMAT_U8;
++					m_convert = convert_float_u8;
++					break;
++				case AV_SAMPLE_FMT_S16:
++					specs.format = FORMAT_S16;
++					m_convert = convert_float_s16;
++					break;
++				case AV_SAMPLE_FMT_S32:
++					specs.format = FORMAT_S32;
++					m_convert = convert_float_s32;
++					break;
++				case AV_SAMPLE_FMT_FLT:
++					specs.format = FORMAT_FLOAT32;
++					m_convert = convert_copy<sample_t>;
++					break;
++				case AV_SAMPLE_FMT_DBL:
++					specs.format = FORMAT_FLOAT64;
++					m_convert = convert_float_double;
++					break;
++				default:
++					AUD_THROW(FileException, "File couldn't be written, sample format not supported with ffmpeg.");
++				}
++			}
++		}
++		else
++		{
++			m_codecCtx->sample_fmt = av_get_alt_sample_fmt(m_codecCtx->sample_fmt, false);
++			m_deinterleave = av_sample_fmt_is_planar(m_codecCtx->sample_fmt);
++		}
++
++		const int* supported_samplerates = nullptr;
++		int num_samplerates = 0;
++		if(avcodec_get_supported_config(m_codecCtx, codec, AV_CODEC_CONFIG_SAMPLE_RATE, 0,
++										reinterpret_cast<const void**>(&supported_samplerates), &num_samplerates) < 0)
++			AUD_THROW(FileException, "File couldn't be written, couldn't retrieve supported sample rates.");
++
++		m_codecCtx->sample_rate = 0;
++
++		if(supported_samplerates)
++		{
++			for(int i = 0; i < num_samplerates; i++)
++			{
++				if(supported_samplerates[i] == m_specs.rate)
++				{
++					m_codecCtx->sample_rate = supported_samplerates[i];
++					break;
++				}
++				else if((supported_samplerates[i] > m_codecCtx->sample_rate && m_specs.rate > m_codecCtx->sample_rate) ||
++						(supported_samplerates[i] < m_codecCtx->sample_rate && m_specs.rate < supported_samplerates[i]))
++				{
++					m_codecCtx->sample_rate = supported_samplerates[i];
++				}
++			}
++		}
++
++		if(m_codecCtx->sample_rate == 0)
++			m_codecCtx->sample_rate = m_specs.rate;
++#else
++		bool format_supported = false;
++
+ 		for(int i = 0; codec->sample_fmts[i] != -1; i++)
+ 		{
+ 			if(av_get_alt_sample_fmt(codec->sample_fmts[i], false) == m_codecCtx->sample_fmt)
+@@ -406,6 +508,7 @@ FFMPEGWriter::FFMPEGWriter(const std::string &filename
+ 
+ 		if(m_codecCtx->sample_rate == 0)
+ 			m_codecCtx->sample_rate = m_specs.rate;
++#endif
+ 
+ 		m_specs.rate = m_codecCtx->sample_rate;
+ 


-- 
wbr, Kirill
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.