package: blender
Version: 4.1.1+dfsg-3

The source code of blender is incompatible with the current version of FFmpeg 
7, leading to a crash when trying to compile against it.
The attached patch fixes the issues, allowing successful compilation.

I am using Ubuntu 24.04 and Debian Unstable.
diff -Nru blender-4.1.1.orig/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp 
blender-4.1.1/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp
--- blender-4.1.1.orig/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp 
2024-02-07 07:53:42
+++ blender-4.1.1/extern/audaspace/plugins/ffmpeg/FFMPEGReader.cpp      
2024-09-06 21:25:53
@@ -112,7 +112,7 @@
                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, 
m_codecCtx->ch_layout.nb_channels, m_frame->nb_samples, m_codecCtx->sample_fmt, 
1);
 
                if(buf_size - buf_pos < data_size)
                {
@@ -122,12 +122,12 @@
 
                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 / 
m_codecCtx->ch_layout.nb_channels / m_frame->nb_samples;
+                       for(int channel = 0; channel < 
m_codecCtx->ch_layout.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 + 
((m_codecCtx->ch_layout.nb_channels * i) + channel) * single_size,
                                                   m_frame->data[channel] + i * 
single_size, single_size);
                                }
                        }
@@ -207,7 +207,7 @@
        if(avcodec_open2(m_codecCtx, aCodec, nullptr) < 0)
                AUD_THROW(FileException, "File couldn't be read, ffmpeg codec 
couldn't be opened.");
 
-       m_specs.channels = (Channels) m_codecCtx->channels;
+       m_specs.channels = (Channels) m_codecCtx->ch_layout.nb_channels;
        m_tointerleave = av_sample_fmt_is_planar(m_codecCtx->sample_fmt);
 
        switch(av_get_packed_sample_fmt(m_codecCtx->sample_fmt))
@@ -345,7 +345,7 @@
                        info.specs.rate = 
m_formatCtx->streams[i]->codec->sample_rate;
                        info.specs.format = 
convertSampleFormat(m_formatCtx->streams[i]->codec->sample_fmt);
 #else
-                       info.specs.channels = 
Channels(m_formatCtx->streams[i]->codecpar->channels);
+                       info.specs.channels = 
Channels(m_formatCtx->streams[i]->codecpar->ch_layout.nb_channels);
                        info.specs.rate = 
m_formatCtx->streams[i]->codecpar->sample_rate;
                        info.specs.format = 
convertSampleFormat(AVSampleFormat(m_formatCtx->streams[i]->codecpar->format));
 #endif
diff -Nru blender-4.1.1.orig/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp 
blender-4.1.1/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp
--- blender-4.1.1.orig/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp 
2024-02-07 07:53:42
+++ blender-4.1.1/extern/audaspace/plugins/ffmpeg/FFMPEGWriter.cpp      
2024-09-07 12:36:42
@@ -77,8 +77,7 @@
 
        m_frame->nb_samples = m_input_samples;
        m_frame->format = m_codecCtx->sample_fmt;
-       m_frame->channel_layout = m_codecCtx->channel_layout;
-       m_frame->channels = m_specs.channels;
+       av_channel_layout_copy(&m_frame->ch_layout, &m_codecCtx->ch_layout);
 
        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,33 +236,33 @@
                break;
        }
 
-       uint64_t channel_layout = 0;
+       AVChannelLayout channel_layout{};
 
        switch(m_specs.channels)
        {
        case CHANNELS_MONO:
-               channel_layout = AV_CH_LAYOUT_MONO;
+               channel_layout = AV_CHANNEL_LAYOUT_MONO;
                break;
        case CHANNELS_STEREO:
-               channel_layout = AV_CH_LAYOUT_STEREO;
+               channel_layout = AV_CHANNEL_LAYOUT_STEREO;
                break;
        case CHANNELS_STEREO_LFE:
-               channel_layout = AV_CH_LAYOUT_2POINT1;
+               channel_layout = AV_CHANNEL_LAYOUT_2POINT1;
                break;
        case CHANNELS_SURROUND4:
-               channel_layout = AV_CH_LAYOUT_QUAD;
+               channel_layout = AV_CHANNEL_LAYOUT_QUAD;
                break;
        case CHANNELS_SURROUND5:
-               channel_layout = AV_CH_LAYOUT_5POINT0_BACK;
+               channel_layout = AV_CHANNEL_LAYOUT_5POINT0_BACK;
                break;
        case CHANNELS_SURROUND51:
-               channel_layout = AV_CH_LAYOUT_5POINT1_BACK;
+               channel_layout = AV_CHANNEL_LAYOUT_5POINT1_BACK;
                break;
        case CHANNELS_SURROUND61:
-               channel_layout = AV_CH_LAYOUT_6POINT1_BACK;
+               channel_layout = AV_CHANNEL_LAYOUT_6POINT1_BACK;
                break;
        case CHANNELS_SURROUND71:
-               channel_layout = AV_CH_LAYOUT_7POINT1;
+               channel_layout = AV_CHANNEL_LAYOUT_7POINT1;
                break;
        default:
                AUD_THROW(FileException, "File couldn't be written, channel 
layout not supported.");
@@ -405,8 +404,7 @@
 
                m_codecCtx->codec_type = AVMEDIA_TYPE_AUDIO;
                m_codecCtx->bit_rate = bitrate;
-               m_codecCtx->channel_layout = channel_layout;
-               m_codecCtx->channels = m_specs.channels;
+               av_channel_layout_copy(&m_codecCtx->ch_layout, &channel_layout);
                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;

diff -Nru blender-4.1.1.orig/source/blender/imbuf/intern/anim_movie.cc 
blender-4.1.1/source/blender/imbuf/intern/anim_movie.cc
--- blender-4.1.1.orig/source/blender/imbuf/intern/anim_movie.cc        
2024-02-19 12:21:37
+++ blender-4.1.1/source/blender/imbuf/intern/anim_movie.cc     2024-09-07 
13:40:11
@@ -1319,7 +1319,8 @@
 
     AVFormatContext *format_ctx = anim->pFormatCtx;
 
-    if (format_ctx->iformat->read_seek2 || format_ctx->iformat->read_seek) {
+    if (!(format_ctx->iformat->flags & AVFMT_NOTIMESTAMPS)) {
+    
       ret = av_seek_frame(anim->pFormatCtx, anim->videoStream, seek_pos, 
AVSEEK_FLAG_BACKWARD);
     }
     else {

Reply via email to