From patchwork Wed Jul 27 15:24:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 37009 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:1649:b0:8b:613a:194d with SMTP id no9csp426464pzb; Wed, 27 Jul 2022 08:25:05 -0700 (PDT) X-Google-Smtp-Source: AGRyM1t+Gpb0BmTOhf5S5B51jAtyy1kojbhkKblTUKxasg0TRKx1iNMOG/syFvAYk5SOocjB4hsO X-Received: by 2002:a17:907:2e02:b0:72b:7f58:34a7 with SMTP id ig2-20020a1709072e0200b0072b7f5834a7mr18075791ejc.525.1658935505356; Wed, 27 Jul 2022 08:25:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658935505; cv=none; d=google.com; s=arc-20160816; b=do+n1Ob+LZNsQNMjqIs+MAIMvbOHhyk4DLer6SB+aDrYhGcU3v271xWjL5NPVv/h+B pgxCL4CCBwhzMuaoBGdxwktn/ZAgD/S1oQYoc1ZAd4hi5H/Fpmo2gTJsouoM/6wZKkYF suarUge/mMmAxi3aD2NqP3kKZRPBLdwab+39npBND4MDXK23meZnhofvo+Iyg6byMjzn lYJXjfgu1PckSMQYGIegngllLskppSAVRaEODt3kq7OUFS22ULw6acFyNitYKsQ1HzHn GQiT51lggMMfXxbyyhQNxaseleNjQpNSKZpC7B6piEEDl4Hx+1Gg9DtqD806HcKGrOdr pg6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=WkIC0H2E3HRr3FRjU2drC2Ir33oxiFwXiqRPhUCHhU4=; b=Gno0ajucM97z06l56hPE+/cJuaPDnKIPQpwQ3uM09aDVttgDAAPszQtSo7XAgs+d8H WwzhC3SV8EAT66pYRK4dO+MoQn3V2r1K9Rx/NbPuz/1cHDnBA87U4ZooM7FuRVY3iwX/ kO1BlWPQu2KTULSVEvnmj5d+vvtAL6Gom5nwsWG0n1JURNHb4bwR27g/gsXfHW+o+eks JivlykwjSsGxO+/okY+bzurtB7z4phvPJPqy6tw9GvrjfgNFhWQ4jtduDn0L5qR5uslp 6vpoGQLI0wJfqQUflkpr32jCE/pwj757NEZ5m7Z1Ikr9H5hMHcMpeIELFVNme0WodUZ6 4khA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id d21-20020aa7ce15000000b0043b0e7cf010si15843013edv.331.2022.07.27.08.25.03; Wed, 27 Jul 2022 08:25:05 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 27D7A68B8CF; Wed, 27 Jul 2022 18:25:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 54CDF68B8B1 for ; Wed, 27 Jul 2022 18:24:51 +0300 (EEST) X-ENS-nef-client: 129.199.129.80 ( name = phare.normalesup.org ) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 26RFOngp009727 for ; Wed, 27 Jul 2022 17:24:50 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id AB995EB5B9; Wed, 27 Jul 2022 17:24:49 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Wed, 27 Jul 2022 17:24:47 +0200 Message-Id: <20220727152447.30944-1-george@nsup.org> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Wed, 27 Jul 2022 17:24:50 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH] lavu/pixfmt: summarize yuv naming conventions X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: IuCw4iGIlfp9 Signed-off-by: Nicolas George --- libavutil/pixfmt.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) Note: we have log2_chroma_h = 2 for yuv410p, meaning each chroma pixel is 4×4 luma pixels, but everywhere I look on the web, ilcuding: https://en.wikipedia.org/wiki/Chroma_subsampling I find that it is supposed to be 4×2, and we should set log2_chroma_h = 1. Who is right? Regards, diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index 2d3927cc3f..3d0f92ed4d 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -60,6 +60,23 @@ * For all the 8 bits per pixel formats, an RGB32 palette is in data[1] like * for pal8. This palette is filled in automatically by the function * allocating the picture. + * + * @par + * Summary of the naming conventions for YUV formats: + * 444 422 440 420 411 410 + * ╋━╋━╋━╋━╋ ╋━┿━╋━┿━╋ ╋━╋━╋━╋━╋ ╋━┿━╋━┿━╋ ╋━┿━┿━┿━╋ ╋━┿━┿━┿━╋ + * ╋━╋━╋━╋━╋ ╋━┿━╋━┿━╋ ╂─╂─╂─╂─╂ ╂─┼─╂─┼─╂ ╋━┿━┿━┿━╋ ╂─┼─┼─┼─╂ + * ╋━╋━╋━╋━╋ ╋━┿━╋━┿━╋ ╋━╋━╋━╋━╋ ╋━┿━╋━┿━╋ ╋━┿━┿━┿━╋ ╂─┼─┼─┼─╂ + * ╋━╋━╋━╋━╋ ╋━┿━╋━┿━╋ ╂─╂─╂─╂─╂ ╂─┼─╂─┼─╂ ╋━┿━┿━┿━╋ ╂─┼─┼─┼─╂ + * ╋━╋━╋━╋━╋ ╋━┿━╋━┿━╋ ╋━╋━╋━╋━╋ ╋━┿━╋━┿━╋ ╋━┿━┿━┿━╋ ╋━┿━┿━┿━╋ + * where + * ┼─┼ = luma pixel ╋━╋ = chroma pixel + * ┼─┼ ╋━╋ + * + * yuv4ab → + * log2_chroma_w = log₂(4/a) + * log2_chroma_h = b == a ? 0 : b == 0 ? log2_chroma_w : unused + * i.e. a = horizontally, number of luma pixels for four chroma pixels */ enum AVPixelFormat { AV_PIX_FMT_NONE = -1,