diff mbox series

[FFmpeg-devel] flac: add GIF image support

Message ID 20210129155409.42313-2-leo@60228.dev
State Superseded
Headers show
Series [FFmpeg-devel] flac: add GIF image support | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

leo60228 Jan. 29, 2021, 3:54 p.m. UTC
The FLAC specification requires GIF images to contain their number of
colors. While I can't find a specific reference to that effect, I'm
assuming that's why GIF images were previously unsupported. This was
implemented by just writing AVPALETTE_COUNT for paletted images.
---
 libavformat/flacenc.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/flacenc.c b/libavformat/flacenc.c
index 1c983486aa..c9834b7d93 100644
--- a/libavformat/flacenc.c
+++ b/libavformat/flacenc.c
@@ -155,7 +155,10 @@  static int flac_write_picture(struct AVFormatContext *s, AVPacket *pkt)
         avio_wb32(pb, av_get_bits_per_pixel(pixdesc));
     else
         avio_wb32(pb, 0);
-    avio_wb32(pb, 0);
+    if (st->codecpar->format == AV_PIX_FMT_PAL8)
+        avio_wb32(pb, AVPALETTE_COUNT);
+    else
+        avio_wb32(pb, 0);
 
     avio_wb32(pb, pkt->size);
     avio_write(pb, pkt->data, pkt->size);
@@ -218,9 +221,6 @@  static int flac_init(struct AVFormatContext *s)
             if (!(st->disposition & AV_DISPOSITION_ATTACHED_PIC)) {
                 av_log(s, AV_LOG_WARNING, "Video stream #%d is not an attached picture. Ignoring\n", i);
                 continue;
-            } else if (st->codecpar->codec_id == AV_CODEC_ID_GIF) {
-                av_log(s, AV_LOG_ERROR, "GIF image support is not implemented.\n");
-                return AVERROR_PATCHWELCOME;
             } else if (!c->write_header) {
                 av_log(s, AV_LOG_ERROR, "Can't write attached pictures without a header.\n");
                 return AVERROR(EINVAL);