From patchwork Fri Jan 29 16:12:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: leo60228 X-Patchwork-Id: 25259 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 C220144A26A for ; Fri, 29 Jan 2021 18:36:01 +0200 (EET) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9756668A8A5; Fri, 29 Jan 2021 18:36:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-vs1-f43.google.com (mail-vs1-f43.google.com [209.85.217.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 18989688050 for ; Fri, 29 Jan 2021 18:35:53 +0200 (EET) Received: by mail-vs1-f43.google.com with SMTP id b5so5167598vsh.3 for ; Fri, 29 Jan 2021 08:35:53 -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:mime-version :content-transfer-encoding; bh=PVZp1NVUCk1qI/hgBPlPc6E3rAwgztSjjwh17w6vHkc=; b=hw+tEnoKRZlmbO1iZIzgPz1Q99BXVwYbUm3lFlLmdVmJxVEKFtKvQ7PQx/B+D1ARuN rwc2p2cdvZzg5jrDBGL6E66rbR9I9d2pL6ZK1JUyyP6UeyEWzj3OdglTfr5E/IKvV2Rp Zzp1zhHNIXxjHW83DMYGd82Bhwjjl6x6QC3aratjwMLYr9UfVyoRhFuenfLkd/BGSN7o HaZxsWxF8YBMOsTwzuX5q+5/DRhJTvKPEATXpFIgN9n3TcInbg31wFVxhMAjt3s1IEwX I3F5onlOx+ozX9HyEk2GwOt5fI9IUE9/b/kWtmlnK0Ng6qmdBBNwL7XTqM2GAzvZPmsN NdlA== 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:mime-version :content-transfer-encoding; bh=PVZp1NVUCk1qI/hgBPlPc6E3rAwgztSjjwh17w6vHkc=; b=ihm958yXArIaWzGLvOc+gSeXc3zRXypEbo0g1YWjOwQWRj3Sn2nN+O3FYo0rk9PqPw wkkbcc08whUaMzQmSRdgOF96Er9SZ1Qi2VD5j/oXa4jGk7yE7B7VyAk/abVDqEwkEZpO F3SmwLQTdXX/k0PanwEe9i79d1clKtyt7af3wXT3dCj7uiiGs95kBopBWm63eZ4Cnp55 HQkKHx+JPaXnQUQIJViSdUO4OFqZrxW1zUHNSi44+hTpe1e5qBCiq40cN7B52Dj0BGdY jpEkE+NcrQie8Zp4LuBc2AXEAQfat3lW9zYb1/CJz7BB/K6U5jMSk2sZkmKPM6/KIIIt rMIA== X-Gm-Message-State: AOAM533j/sonl5CcSX9uzVCTPm+6yng6tIlEMUtOuJmjoq1ZAxGgCJEk dDhzkQd3UoqI2uocZNwfosCi3524I/RbGa0y X-Google-Smtp-Source: ABdhPJxxXdqYMaMJjBRUrRlSGsrjXlwP99zxODk2Ka/ZZY9dySFjiS07rifAKQ+n+NSNrB67If2Z3w== X-Received: by 2002:a05:6214:906:: with SMTP id dj6mr4400647qvb.28.1611936750908; Fri, 29 Jan 2021 08:12:30 -0800 (PST) Received: from localhost (098-121-230-017.res.spectrum.com. [98.121.230.17]) by smtp.gmail.com with ESMTPSA id s136sm6038628qka.106.2021.01.29.08.12.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 29 Jan 2021 08:12:30 -0800 (PST) From: leo60228 To: ffmpeg-devel@ffmpeg.org Date: Fri, 29 Jan 2021 11:12:26 -0500 Message-Id: <20210129161226.50087-1-leo@60228.dev> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3] 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. --- This version no longer includes a changelog entry or accidentally adds a newline to existing code in flac_write_picture. This is identical to v2 except for fixing a mistake while submitting, sorry about that. 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);