[FFmpeg-devel] [PATCH] libopenjpegenc: recreate image data buffer after encoding frame

Andreas Cadhalpun andreas.cadhalpun at googlemail.com
Wed Oct 12 18:45:20 EEST 2016

On 12.10.2016 03:42, Michael Bradshaw wrote:
> On Tue, Oct 11, 2016 at 9:57 AM, Andreas Cadhalpun <
> andreas.cadhalpun at googlemail.com> wrote:
>> openjpeg 2 sets the data pointers of the image components to NULL,
>> causing segfaults if the image is reused.
> I've never seen this issue.

That's strange, as it happens practically always here (on Debian testing/sid).

> Is there a particular version of OpenJPEG or

The OpenJPEG version is 2.1.2, i.e. the latest.

> reproduction steps available?

For example:
$ ffmpeg -f lavfi -i testsrc -c:v libopenjpeg -f null /dev/null

> Where are the data pointers being set to NULL here?
>> The relevant openjpeg2 code is:
>> https://sources.debian.net/src/openjpeg2/2.1.2-1/src/lib/openjp2/j2k.c/?hl=10253#L10247

I didn't include this link in the commit message, as it will become invalid,
as soon as the next OpenJPEG version enters Debian.

For future reference, the code is:
        /* TODO_MSD: Find a better way */
        if (p_image->comps) {
                OPJ_UINT32 it_comp;
                for (it_comp = 0 ; it_comp < p_image->numcomps; it_comp++) {
                        if (p_image->comps[it_comp].data) {
                                p_j2k->m_private_image->comps[it_comp].data =p_image->comps[it_comp].data;
                                p_image->comps[it_comp].data = NULL;


Best regards,

More information about the ffmpeg-devel mailing list