[FFmpeg-devel] [PATCH] [RFC] lavc, lavfmt: add FLIF decoding support

Anamitra Ghorui aghorui at teknik.io
Thu Jul 30 12:42:08 EEST 2020


July 30, 2020 1:08 AM, "Andreas Rheinhardt" <andreas.rheinhardt at gmail.com> wrote:

> Anamitra Ghorui:
> 
>> This patch implements non interlaced decoding of FLIF16 images with all
>> transforms except for one, FrameLookback which is being tested.
>> 
>> Several test files have been attached. The above mentioned transform
>> and interlaced decoding is being tested and will be implemented shortly.
>> 
>> The main reason of posting this patch now is to ask advice on deflate
>> decompression (or inflate) on the metadata segments of the format.
>> The reference decoder of the format [1] uses lodepng, and by extension,
>> deflate for generating the metadata segments. Therefore these segments
>> should be able to be decoded by zlib's deflate routines. However it does
>> not work and returns saying that the data is invalid.
>> I have tried isolating the metadata using a hex editor, and then using
>> zlib's example program [2] to decode it. However it also says that it's
>> invalid data.
>> Can you please tell me what I am doing wrong in libavformat/flifdec.c?
>> 
>> [1]: https://github.com/FLIF-hub/FLIF
>> [2]: https://zlib.net/zpipe.c
>> 
>> Co-authored-by: Anamitra Ghorui <aghorui at teknik.io>
>> Co-authored-by: Karhtik K. Khullar <kartikkhullar840 at gmail.com>
>> 
>> Signed-off-by: Anamitra Ghorui <aghorui at teknik.io>
>> ---
> 
> [...]
> 
>> +
>> +#if 0
>> +// CONFIG_ZLIB
>> +static int flif_inflate(FLIFDemuxContext *s, unsigned char *buf, int buf_size,
>> + unsigned char *out_buf, int *out_buf_size)
> 
> I did not look thoroughly at it at all, but this is already wrong:
> flif_inflate allocates out_buf and in order to return it, the parameter
> must be of type unsigned char ** (or uint8_t ** (that is preferred here)).
> 

Yes, A pretty bad blunder. Will post a new patch for it soon.

I have tried replacing the metadata segment (after fixing the above 
errors) in the encoded file with dummy data from zpipe.c [1] and the 
function decodes the dummy data properly. So I am guessing that maybe I
am not setting the proper parameters somewhere.
I have tried using different flushes (Z_PARTIAL_FLUSH, Z_NO_FLUSH etc.)
but it did not work.

[1]: https://zlib.net/zpipe.c

Regards,
Anamitra



More information about the ffmpeg-devel mailing list