[FFmpeg-devel] APNG encoder can work incorrectly

Dmitriy DiZNet at mail.ru
Sun Mar 27 19:48:24 CEST 2016


>> In come cases APNG encoder generate only static video.
>>
>> The errors are located in the apng_encode_frame function (pngenc.c file).
>>
>> The
>> av_frame_copy(diffFrame, s->last_frame);
>> and
>> av_frame_copy(diffFrame, s->last_frame);
>>
>> functions doesn't work if the image size was changed in
>> apng_do_inverse_blend function and return error code.
>>
>> you need insert the following codes
>>
>> diffFrame->width = pict->width;
>> diffFrame->height = pict->height;
>> av_frame_copy(diffFrame, s->last_frame);
>>
>> and
>>
>> diffFrame->width = pict->width;
>> diffFrame->height = pict->height;
>> av_frame_copy(diffFrame, s->last_frame);
>>
>> to restore image size before recovery diffFrame image.

> Could you provide input file so I can reproduce this?

I can't reproduce error at home now but if you look to code you found
that apng_do_inverse_blend function search the window for encoding and
can change the image size of diffFrame (and copy data to diffFrame).

See apng_do_inverse_blend at end:
    output->width = rightmost_x - leftmost_x;
    output->height = bottommost_y - topmost_y;


At the next iteration of for-cycle the image diffFrame will be tried
to restore from s->last_frame or from s->prev_frame that always have coded image size.

That is why if apng_do_inverse_blend change diffFrame image size then
function av_frame_copy return error at the next iteration.
See function
static int frame_copy_video(AVFrame *dst, const AVFrame *src)
{
    const uint8_t *src_data[4];
    int i, planes;

    if (dst->width  < src->width ||
        dst->height < src->height)
        return AVERROR(EINVAL);

So the algorithm don't work properly in all modes.



More information about the ffmpeg-devel mailing list