av_image_fill_max_pixsteps method generates segmentation fault since v4.3.2.1
- **I'm submitting a ... **
- [ x] bug report
Preconditions
FFmpeg 4.4.1 (latest brew installation) OS - OSx .NET 6 (or .NET 5).
Description
The signature of the av_image_fill_max_pixsteps hasn't changed in version v4.3.2.1
By blaming imgutils, it is clear that it stayed the same for the last 9 years.
Even so, after upgrading FFmpeg.Autogen to any version >= v4.3.2.1, the method call fails with a segmentation fault. The previous version 4.3.2 works with no issues. The target FFmpeg is 4.4.1 so since it works with Autogen 4.3.2 I assume it is an Autogen issue.
It may be related to the fact that since the v4.3.2.1 method signature in Autogen changed from
// version up until v4.3.2
public static void av_image_fill_max_pixsteps(
ref int_array4 max_pixsteps,
ref int_array4 max_pixstep_comps,
AVPixFmtDescriptor* pixdesc)
to
// version since v4.3.2.1
public static void av_image_fill_max_pixsteps(
int_array4 max_pixsteps,
ref int_array4 max_pixstep_comps,
AVPixFmtDescriptor* pixdesc)
Notice how the first parameter changed from ref int_array4 to int_array4. Taking into account that the actual imgutils.h does not contain changes in the method signature, why does the generated code provides int_array4 instead of ref int_array4 since v4.3.2.1?
Any help will be greatly appreciated.
I think we already observed similar issue here #140. However, this one looks different. As original declaration:
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4],
const AVPixFmtDescriptor *pixdesc);
It appears to be generation issue - I'll investigate.
@AddictedCS can you compile custom version of v4.3.2.1? With this as a difference:
// version since v4.3.2.1
public static void av_image_fill_max_pixsteps(
int_array4 max_pixsteps,
int_array4 max_pixstep_comps,
AVPixFmtDescriptor* pixdesc)
And test it? As we not supposed to have second parameter by ref .
Will do it later this week.
@AddictedCS do you have or can you create any minimal example how to use this function?
@Ruslan-B it is actually quite easy.
Create a new console app and run the following code:
using System;
using FFmpeg.AutoGen;
unsafe
{
var pixelFormat = ffmpeg.av_pix_fmt_desc_get(AVPixelFormat.AV_PIX_FMT_RGB24);
int_array4 max_step, _;
ffmpeg.av_image_fill_max_pixsteps(max_step, ref _, pixelFormat);
Console.WriteLine("Hello, World!");
}
For Autogen >= 4.3.2.1 it will fail with a segmentation fault. For earlier versions, you will see the Hello World message.
OS: OSx FFmpeg: 4.4.1 dotnet: 5 or 6
I'll close this issue in one week as we don't have any forward moving....
Could you please check/test - ffmpeg_abstractions branch. I do think it should fix the problem as I forced ref for any none const array.
Forming new way of API here https://github.com/Ruslan-B/FFmpeg.AutoGen/issues/210 - all none const array parameters are ref now.
Is there any way you will force ref parameters for the 4.x branch? I could test that.
I'll look into this however can't promise anything as having a capacity of one developer is not enough to support timeline of ffmpeg. If you can update to 5.1 would be easy.
Understand and appreciate your efforts. I'm bundling it with Microsoft Debian Bullseye, which still marks ffmpeg 5.x package as unstable, and frankly saying I don't expect it to become stable anytime soon.
Okay I'll look into this have to understand how to deal with this
Understand and appreciate your efforts. I'm bundling it with Microsoft Debian Bullseye, which still marks ffmpeg 5.x package as unstable, and frankly saying I don't expect it to become stable anytime soon.
So I can assume you stuck with v4.3.2?
The latest I can use is v4.3.0.3
When I'll finish work and newly generated API is going to stable - I'll do it once for 4.3 and 4.4. I don't think it need to so often.
Sorry @Ruslan-B I've misunderstood your question. The version that is marked as stable and used with Microsoft Debian Bullseye is 4.3.4.
ffmpeg version 4.3.4-0+deb11u1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 10 (Debian 10.2.1-6)
configuration: --prefix=/usr --extra-version=0+deb11u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
The latest FFmpeg Autogen that is usable and not crashing is v4.3.0.3, which I'm using.
I think this problem is solved in new API - mostly drop - I'll try to create experimental packages for 4.3 from this point and it would be cool if you can participate in testing
Once a new package is created for 4.3.x, I will give it a run.
Based on https://github.com/Ruslan-B/FFmpeg.AutoGen/tree/ffmpeg_abstractions_4.3
I added all four new nuget packages. However, you need this one:
Install-Package FFmpeg.AutoGen.Bindings.DynamicallyLoaded -Version 4.3.2
Indexing still in progress.
The API namespace is different - FFmpeg.AutoGen.Abstractions
Besides, don't forget to do:
DynamicallyLoadedBindings.LibrariesPath = ...
DynamicallyLoadedBindings.Initialize();
You can check the example project. Before any API call. If any question please let me know.
The fix is working. I could run it with ffmpeg v4.4.1 and FFmpeg.AutoGen.Bindings.DynamicallyLoaded -Version 4.3.2. Thanks for the efforts.
Nice, I'll add packages for 4.4+ a bit later.
closing the issue as fulfilled