From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 47C4C4E38A for ; Mon, 10 Mar 2025 23:03:41 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7D7B768E0C0; Tue, 11 Mar 2025 01:03:38 +0200 (EET) Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F2B6F68E0BA for ; Tue, 11 Mar 2025 01:03:31 +0200 (EET) Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-aaec111762bso954747566b.2 for ; Mon, 10 Mar 2025 16:03:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1741647809; x=1742252609; darn=ffmpeg.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id:from :to:cc:subject:date:message-id:reply-to; bh=LJcW/kDywVhcuvCm4SoXkhcWjeXeOHdHkSzLWm5Hn7c=; b=NhDP41WoYD5CNi2O4nanrYkgzoCGCxvLP0MC6/gpRud4S4kJl6tnjYK60SfCQIVoGV /qqxVEYIugyVp2iMNOBsFNneHG/G16deADLTm0FPm/gowuD6nZf8f9KJrWuuXoNerpCw jC5W/5hCa/5IhFD9PUBO8cLx3sgARlnAPh1jxGPEUlEjiocsU8rIP7pyQAzErx3tOqdo xwa5xEZ2SekLGvjayecup5WzCxznrTwdegb00Kch6rSpqvoeGDESoB9Gnh/xNxh0q8fX L9eHyiZv/GA5IGdIeFV+A7bXGHR2vjCECcJqHMqo00oCEiwD8PQz/OhRcA8gXFmjSOel MV1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1741647809; x=1742252609; h=content-transfer-encoding:in-reply-to:from:content-language :references:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=LJcW/kDywVhcuvCm4SoXkhcWjeXeOHdHkSzLWm5Hn7c=; b=mIlbdLLyzGla00/is6vIs/kxAwz39U71+WlaZNpzYbDfEW0oXgkXuTJVUGFVSblA2E 89iDTqmvpmG/CiJ7mbOqw3VKQVA9XWXqSat+Adfc+CZ4ppGIlLJzZVuj61+1cGViZuL7 L6R+HQ6ixSARZXmK0NhV5C8hvYvzA6l24zRWtViW7HOI7y1cIp2amk1+2KoIaE2svzvQ eAx2RBAXmX+F8MhNWtdNDC726MaEYHnwGluGk7imDZHr074vbGu4DGOdhCqR/GZhnour 2+231jlcdvOvc3r5p3HsVG6DqusvgQRaiPL0lQSUYDEDyBmn1pJnc2qJwmm871A9TVNb I+ug== X-Gm-Message-State: AOJu0YzS1O2OdojJxvCRo15L5nFGXEncvD6XSxLBx4z7kduG03kpgMO4 MYmYv9gvfUfiI2/AXvtU9XF0SQIqHUBaaFqurKh9UcXEDqGOT1WhwSUHNITa X-Gm-Gg: ASbGncviB2ToAVJ0BsNljSCoU06KFtld7JE9tKFaTtZfN8eu/dF1Fj3wwhb7TPUqui0 M08P7mv6g43QC/RhY3L9/vAHrmqaFFMPW01md/ADgq8cJkF7HA7sVsMF0BE+zViueDB7a5bNfj+ zVLsA3wNzxCk+Vxol+BC/RKegC5+yhLdZgcnfM3qnMXvFFbKSehxeo0N56YNkFbQQVbBf9Ck6iy wL4d2LKwGwDc8N6jdfJ7XndIqRiKtnU2PW5Y6WHoZir/uGNSioqFhWewFqQBvzwH3+ASdCpY/eq Cmso5izmzJ3Hu7tVcVvAb/g+A3UL7RYdbBCcdmb/5cyt5Nt9go9TTHbAVC8tKSQRKm551/ReHPM Drw7MOsRslos9UX59 X-Google-Smtp-Source: AGHT+IG5wzxxgDcs+WHr9PGm5iqG3TAyttxINYcAK8wJmDfuWcn+ldK8MnMIIjCsdGcy+9Mwt89+tA== X-Received: by 2002:a17:907:15c1:b0:ac2:a10b:fe3 with SMTP id a640c23a62f3a-ac2a10b1313mr481656566b.56.1741647809347; Mon, 10 Mar 2025 16:03:29 -0700 (PDT) Received: from [192.168.1.42] (20.238-74-193.fia-dyn.isp.proximus.be. [193.74.238.20]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-ac2b8584feesm59217666b.6.2025.03.10.16.03.28 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Mar 2025 16:03:28 -0700 (PDT) Message-ID: Date: Tue, 11 Mar 2025 00:03:28 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: ffmpeg-devel@ffmpeg.org References: <20250310151811.107728-1-ffmpeg@haasn.xyz> Content-Language: en-US From: Ramiro Polla In-Reply-To: <20250310151811.107728-1-ffmpeg@haasn.xyz> Subject: Re: [FFmpeg-devel] [PATCH] swscale/utils: split off format code into new file 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 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 3/10/25 16:18, Niklas Haas wrote: > From: Niklas Haas > > utils.c is getting quite crowded, and I need a new place to dump a lot of > format handling code for the ongoing rewrite. Rather than bloating this file > even more, start splitting format handling helpers off into a new file. > > This also renames the existing utils.h header, which didn't really contain > anything except the SwsFormat definition anyway (the prototypes for what should > have been in utils.h are all still in the legacy swscale_internal.h). > --- > libswscale/Makefile | 1 + > libswscale/cms.c | 2 +- > libswscale/cms.h | 2 +- > libswscale/csputils.c | 2 +- > libswscale/format.c | 583 +++++++++++++++++++++++++++++++ > libswscale/{utils.h => format.h} | 6 +- > libswscale/graph.c | 2 +- > libswscale/graph.h | 2 +- > libswscale/lut3d.h | 2 +- > libswscale/utils.c | 559 ----------------------------- > 10 files changed, 593 insertions(+), 568 deletions(-) > create mode 100644 libswscale/format.c > rename libswscale/{utils.h => format.h} (98%) > > diff --git a/libswscale/format.c b/libswscale/format.c > new file mode 100644 > index 0000000000..89ed4eae6b > --- /dev/null > +++ b/libswscale/format.c > @@ -0,0 +1,583 @@ > +/* > + * Copyright (C) 2024 Niklas Haas > + * > + * This file is part of FFmpeg. > + * > + * FFmpeg is free software; you can redistribute it and/or > + * modify it under the terms of the GNU Lesser General Public > + * License as published by the Free Software Foundation; either > + * version 2.1 of the License, or (at your option) any later version. > + * > + * FFmpeg is distributed in the hope that it will be useful, > + * but WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU > + * Lesser General Public License for more details. > + * > + * You should have received a copy of the GNU Lesser General Public > + * License along with FFmpeg; if not, write to the Free Software > + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA > + */ > + > +#include "libavutil/avassert.h" > +#include "libavutil/hdr_dynamic_metadata.h" > +#include "libavutil/mastering_display_metadata.h" > + > +#include "format.h" > + > +typedef struct FormatEntry { > + uint8_t is_supported_in :1; > + uint8_t is_supported_out :1; > + uint8_t is_supported_endianness :1; > +} FormatEntry; > + > +/* Format support table for legacy swscale */ > +static const FormatEntry format_entries[] = { > + [AV_PIX_FMT_YUV420P] = { 1, 1 }, [...] > + [AV_PIX_FMT_BAYER_RGGB8] = { 1, 0 }, > + [AV_PIX_FMT_BAYER_GBRG8] = { 1, 0 }, > + [AV_PIX_FMT_BAYER_GRBG8] = { 1, 0 }, > + [AV_PIX_FMT_BAYER_BGGR16LE] = { 1, 0 }, Perhaps you could vertically align this array while moving it. [...] > +/** > + * This function also sanitizes and strips the input data, removing irrelevant > + * fields for certain formats. > + */ > +SwsFormat ff_fmt_from_frame(const AVFrame *frame, int field) > +{ > + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format); > + const AVColorPrimariesDesc *primaries; > + AVFrameSideData *sd; > + > + SwsFormat fmt = { > + .width = frame->width, > + .height = frame->height, > + .format = frame->format, > + .range = frame->color_range, > + .csp = frame->colorspace, > + .loc = frame->chroma_location, > + .desc = desc, > + .color = { > + .prim = frame->color_primaries, > + .trc = frame->color_trc, > + }, > + }; > + > + av_assert1(fmt.width > 0); > + av_assert1(fmt.height > 0); > + av_assert1(fmt.format != AV_PIX_FMT_NONE); > + av_assert0(desc); > + if (desc->flags & (AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_PAL | AV_PIX_FMT_FLAG_BAYER)) { > + /* RGB-like family */ > + fmt.csp = AVCOL_SPC_RGB; > + fmt.range = AVCOL_RANGE_JPEG; > + } else if (desc->flags & AV_PIX_FMT_FLAG_XYZ) { > + fmt.csp = AVCOL_SPC_UNSPECIFIED; > + fmt.range = AVCOL_RANGE_UNSPECIFIED; This line above was not in utils.c. Ramiro _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".