From patchwork Sat Aug 17 08:13:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51053 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:b6ca:0:b0:48e:c0f8:d0de with SMTP id s10csp881696vqj; Sat, 17 Aug 2024 01:14:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXn5ODwmpO+CBRn9hFxBnyGeaHywstanBKwX7Gho2U/yUTt8IHhtZjmFONwZJ3DMUWxI0+7jIcXz9EUxoVc9Jl+dCmFt+q2Ge2BlA== X-Google-Smtp-Source: AGHT+IHD8IEJwwi7Rp7jftvFblkCs8IJGgMQI+OE/8GxQIFdd31GOEWLkeBOEiX+vw74WP8QbyVD X-Received: by 2002:a05:6512:1092:b0:52d:b150:b9b3 with SMTP id 2adb3069b0e04-5331c6b34a3mr3320798e87.32.1723882459004; Sat, 17 Aug 2024 01:14:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1723882458; cv=none; d=google.com; s=arc-20160816; b=ASsiAnPRXIUwHGkz7xDws5FmlfWK6OnPt51nmuJ1QLbW0kiYYgwhr3gl/9U3ZDPDY4 FrNWaIP0bhhLpLEK5QhFyVfzH5/d6eIbSezQ9POVk5X/645KCq+wCVaSegKxRtECmrsI +FY7ct/oDhaDXWghWFEw7oAW406Qt6JurVdIjg6a9dR3E/40FiE3j79w2oNQiUpkiMhZ LKaN8zAwYZithAnJ+zp2WE7pTeFtWH6V42muQ2d1pbmstzTPu1RTORjZ/d6k4M7c/Sq1 mMcffcFKMXZfQUArD+P41uNdrXBV/BwWSuD7l5MI4PQtf8nkQDveLDeJLHhdQwjeXuUu 9Y0w== 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:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=YsizaZQ4FzZTTca3pDnFlGO3Delxs1nckEf4fIlpKNY=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=VQhI6ypbgWZCI7+OwCDNAwdIrFSLFkjco55s/d7jZ17Wl01UI/9iTHaqByDLqfey8s Lg3Bk+H5cxYCKXSsvPTT5+s2XFD2EdQwP5pIRgXkmE2iIwJOyMBZvrYrMVMc/O4ig5qT jZSSsHD3JvvF5X5WFm+k5JgAOSRLbrMElr40pQi7zO4QtWKHxpavm2XGj8E8DugRT5o6 MmVeTw4wmrpsAf+ajI/6P+/oTWQnu9fSYrM149DwvZxtn0m9xY77G+IDOgG40+i8qZQo Aesy2Yo8j5IPimreKhj40M7StpWJcm6biwAUUUJT2DNKiw/0GvgQOOLMQTy24hfMbMRB bXXA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=qTK9uXUl; 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 a640c23a62f3a-a83839489d9si308826266b.511.2024.08.17.01.14.18; Sat, 17 Aug 2024 01:14:18 -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; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=qTK9uXUl; 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 A157B68DCE4; Sat, 17 Aug 2024 11:14:15 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AF48568DC9A for ; Sat, 17 Aug 2024 11:14:08 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=qTK9uXUl; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id ED8C84E05 for ; Sat, 17 Aug 2024 10:14:07 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id PhuRWKAE2Akh for ; Sat, 17 Aug 2024 10:14:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1723882446; bh=+6IJzKJ3WVKshXRLXl51RkJmL8mvh0h7M1+5SHtxXVM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=qTK9uXUlMbYCa630g7z2gV2/hlmQ8hxdREvcM6XmlUPCH767vZr+cCQT8GcEYX29m /Esb8iAAUPSa2L2qqjB/eDpkiqu5VUqRD83R0bAOIKqUVc9BeDpoeXWGhSBVgFsA62 IbUCDiuSKYTsV/OjI/ZPjwQAtRTEFUT23tCA5A+saHVSJmfRyKVKT8XJRSZa+TtcA3 xd77Q+ggjpDxq7ln9cRYLRF2noqE/Vdcyd56t2r0DYlqK9cfEyIb/yFxp51VZIHG/B HddeIDhNxw6nkFZuw8QiA6GX3QVYs6+MA806SHHx7DUurImH0yKIt+v0XbPUwzk0Ch nXHfublBbuA4Q== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 9A06A4DE1 for ; Sat, 17 Aug 2024 10:14:06 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 350813A1676 for ; Sat, 17 Aug 2024 10:14:00 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Sat, 17 Aug 2024 10:13:52 +0200 Message-ID: <20240817081358.2354-2-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240817081358.2354-1-anton@khirnov.net> References: <20240817081358.2354-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/8] lavfi: move ff_parse_pixel_format() to vf_format, its only caller 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: WNhStrZAlGgx The only thing this function does beyond calling av_get_pix_fmt() is falling back onto parsing the argument as a number. No other filters should need to do this. --- libavfilter/formats.c | 15 --------------- libavfilter/internal.h | 11 ----------- libavfilter/vf_format.c | 17 ++++++++++++++++- 3 files changed, 16 insertions(+), 27 deletions(-) diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 15099ac545..18f7b89104 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -939,21 +939,6 @@ int ff_default_query_formats(AVFilterContext *ctx) /* internal functions for parsing audio format arguments */ -int ff_parse_pixel_format(enum AVPixelFormat *ret, const char *arg, void *log_ctx) -{ - char *tail; - int pix_fmt = av_get_pix_fmt(arg); - if (pix_fmt == AV_PIX_FMT_NONE) { - pix_fmt = strtol(arg, &tail, 0); - if (*tail || !av_pix_fmt_desc_get(pix_fmt)) { - av_log(log_ctx, AV_LOG_ERROR, "Invalid pixel format '%s'\n", arg); - return AVERROR(EINVAL); - } - } - *ret = pix_fmt; - return 0; -} - int ff_parse_sample_rate(int *ret, const char *arg, void *log_ctx) { char *tail; diff --git a/libavfilter/internal.h b/libavfilter/internal.h index 4938612593..343bc0b330 100644 --- a/libavfilter/internal.h +++ b/libavfilter/internal.h @@ -35,17 +35,6 @@ int ff_fmt_is_regular_yuv(enum AVPixelFormat fmt); /* Functions to parse audio format arguments */ -/** - * Parse a pixel format. - * - * @param ret pixel format pointer to where the value should be written - * @param arg string to parse - * @param log_ctx log context - * @return >= 0 in case of success, a negative AVERROR code on error - */ -av_warn_unused_result -int ff_parse_pixel_format(enum AVPixelFormat *ret, const char *arg, void *log_ctx); - /** * Parse a sample rate. * diff --git a/libavfilter/vf_format.c b/libavfilter/vf_format.c index 2b88b10f65..83deff7190 100644 --- a/libavfilter/vf_format.c +++ b/libavfilter/vf_format.c @@ -86,6 +86,21 @@ static av_cold int invert_formats(AVFilterFormats **fmts, return 0; } +static int parse_pixel_format(enum AVPixelFormat *ret, const char *arg, void *log_ctx) +{ + char *tail; + int pix_fmt = av_get_pix_fmt(arg); + if (pix_fmt == AV_PIX_FMT_NONE) { + pix_fmt = strtol(arg, &tail, 0); + if (*tail || !av_pix_fmt_desc_get(pix_fmt)) { + av_log(log_ctx, AV_LOG_ERROR, "Invalid pixel format '%s'\n", arg); + return AVERROR(EINVAL); + } + } + *ret = pix_fmt; + return 0; +} + static av_cold int init(AVFilterContext *ctx) { FormatContext *s = ctx->priv; @@ -96,7 +111,7 @@ static av_cold int init(AVFilterContext *ctx) sep = strchr(cur, '|'); if (sep && *sep) *sep++ = 0; - if ((ret = ff_parse_pixel_format(&pix_fmt, cur, ctx)) < 0 || + if ((ret = parse_pixel_format(&pix_fmt, cur, ctx)) < 0 || (ret = ff_add_format(&s->formats, pix_fmt)) < 0) return ret; }