[FFmpeg-devel] [PATCH v3] flac: add GIF image support

leo60228 leo at 60228.dev
Mon Feb 1 02:57:08 EET 2021


After some further thought and discussion on the FFmpeg and Xiph.org IRC
channels, the current behavior seems reasonable. To my knowledge, PAL8 is
guaranteed to have exactly 256 colors. This is why, somewhat surprisingly,
GIFs aren't decoded as PAL8, they're decoded as BGRA. This means that they
get a 0 written. In addition, it was suggested that 0 could mean that the
number of colors is unknown, which would be exactly the case in this
scenario.
These fields don't seem to be considered especially important, either. For
example, the reference FLAC encoder always writes 24-bit color for GIF,
despite having a comment acknowledging that this may be incorrect.

On Sun, Jan 31, 2021 at 3:41 PM leo60228 <leo at 60228.dev> wrote:

> That's true, but as far as I can tell FFmpeg assumes that all paletted
> images have 256 colors, and thus there isn't a way to get the exact number
> of colors in a GIF.
> I also doubt that this will cause problems in practice, it's somewhat
> strange that this field is even there.
> If I'm wrong on any of this, please let me know.
>
> On Sun, Jan 31, 2021 at 3:07 PM Derek Buitenhuis <
> derek.buitenhuis at gmail.com> wrote:
>
>> On 29/01/2021 16:12, leo60228 wrote:
>> > +    if (st->codecpar->format == AV_PIX_FMT_PAL8)
>> > +        avio_wb32(pb, AVPALETTE_COUNT);
>> > +    else
>> > +        avio_wb32(pb, 0);
>>
>> Is this correct, though?
>>
>> GIFs encoded by things that are not libavcodec may have less than
>> AVPALETTE_COUNT entries/colors.
>>
>>
>> - Derek
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>
>


More information about the ffmpeg-devel mailing list