From patchwork Fri Jan 29 15:54:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: leo60228 X-Patchwork-Id: 25258 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 4CEC244A26A for ; Fri, 29 Jan 2021 18:25:27 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 07D8C68A779; Fri, 29 Jan 2021 18:25:27 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9C01F68A107 for ; Fri, 29 Jan 2021 18:25:20 +0200 (EET) Received: by mail-io1-f53.google.com with SMTP id u7so9847457iol.8 for ; Fri, 29 Jan 2021 08:25:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=60228.dev; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mKEi2lYvWxRURdVC9Cus5b2ASaGorDEbBH5okJ90ZTo=; b=dDnGEkjMgLOLEKauVCJavTFAMHl5bqagqI5egO01GZkhQruJJrm4s7yLyvsr/bsFwx K08QBTthza12LzAfP91oL/spsooTCtch3uqSPz1BaggPUyxaIK6FRHvSv5CLqW0gCZJv 01erVANeSZEQR5Y73RXWTu843QpvUmX0ffidezY65Pt8KsyrzHapd5UBwlvezmnFLOAh J6aUQbP9I1OSvRNwzOzT23Q9lEG4wogiY3tGrlIrQlDlFGZPDRvujUo38Ua0623hNI6B llKzuSWypl6oVHeeTm7MTrsgU10K87xajosGiFyjJmrNsx1UWquAperJRPNUfpiTrPNq m2Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=mKEi2lYvWxRURdVC9Cus5b2ASaGorDEbBH5okJ90ZTo=; b=sx7lDKILyul9gZeJOic6qBfXr8APIXjZXymCh2mZ3GIa9aXRkWJ+8AFwOoa7eWaAuc iRZhVoKWT/ldF91YVAz4JKI5z2k2UX/MhCHX7e7kuABg5utMnpTfucxvms+d1ChNSGW+ liMOAY+LyvZfX/nrJ5zG+t0dCQDvxYrOw/Ue1Mnzuw+821Zs9RVSElU3L8tvMYb2d4M9 jYhZz5FuljSgb1+jRR2emapnAhEnkK+I8Sy8vmCDXouZOMJH6IbIpRHnmg5FWN0jLOF/ tY19iYfQue8yOFCwzAKeiogpf3XgnMUkDxrsHe/gJhGqO14/IMGHKoY52C+uKkQCqYnu yDMw== X-Gm-Message-State: AOAM530352v4J5AxiqyqxhsgUxHTYgv87i0us2UQwRxiRHf2z3iPJMSi rIm+0fzAfCU4ffmUHPxa9GjXoF7R8X6PZgWt X-Google-Smtp-Source: ABdhPJzLVD9pgi1tdPwchvOJPYDRLODzzgJJbBp+RC6k1FmgbSBkO3J2xrSlBxsj+vwUHf/VJTD88A== X-Received: by 2002:aed:2e83:: with SMTP id k3mr4650756qtd.168.1611935658087; Fri, 29 Jan 2021 07:54:18 -0800 (PST) Received: from localhost (098-121-230-017.res.spectrum.com. [98.121.230.17]) by smtp.gmail.com with ESMTPSA id l30sm5236170qtv.54.2021.01.29.07.54.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Jan 2021 07:54:17 -0800 (PST) From: leo60228 To: ffmpeg-devel@ffmpeg.org Date: Fri, 29 Jan 2021 10:54:09 -0500 Message-Id: <20210129155409.42313-2-leo@60228.dev> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20210129155409.42313-1-leo@60228.dev> References: <20210129155409.42313-1-leo@60228.dev> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] flac: add GIF image support X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: leo60228 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" 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 --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);