From patchwork Wed Dec 6 08:22:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 44955 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9153:b0:181:818d:5e7f with SMTP id x19csp106556pzc; Wed, 6 Dec 2023 00:23:37 -0800 (PST) X-Google-Smtp-Source: AGHT+IG4pIKZmpmXQl8iZczlyDQ127rW1EQc7vCT35fRNB2wDLPj96uslkfmRdUfbXzZxB24SDlP X-Received: by 2002:a17:906:297:b0:a1c:4c3e:99e2 with SMTP id 23-20020a170906029700b00a1c4c3e99e2mr2884387ejf.22.1701851017014; Wed, 06 Dec 2023 00:23:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701851017; cv=none; d=google.com; s=arc-20160816; b=YngCGUBQvsz83Xgp4XgVwCemHvEG7HGFHsKy5Nno3kNXHBjuf2nVbBdmxf3ORCvXwU 395FbBm23TBAxfepRGTttnE/4tI3mXhQc41JboGPvsTRzZe8vfCosfPsGNqaHPoTyFbl TqZsN7eA2KjVX5wWCHyYTmBT4e8bnxQSJaJfLQioQPs5DOkZn/uRVaW1Z6Kjy/33PR8s 4pAOIU4Hz8OWG81DzqFUbgt8JytgaJTNAozzf4ytMnTzhCWHBmDEPTXZum/pUHpQ7an1 JQv+BxXLZDVHqqqn6qYSSlFyNnIK2Im39AnXLCtegKevq/cVU1RUiZr5PYp0Shj9GjU3 sBvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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:delivered-to; bh=2KiYRKCd3X6R7jwzGp2o5I6d4lc/zBLgAw4mV5u/48A=; fh=s+G8Ss4JbeMFkWPSp2LmIH/LXFyBlALRiww1j3FPjHY=; b=SWkzux1OhL5qszXhDCYem7l7lKUfU0snv9gZOdJCD6HvN07/gcQOh7OV8aLXlVJKHV 52LFZL7RLbG5o95Bl5m8qbKYwIyu4WJfAXy/Pe7znwKUuAMIyWfOa+3yHCKmyM8schm+ g9nGHla9VmLvaU5S6ZPqwep3TxFa1pK/TylQE1UBkMuTTzR3LWsYOsJK57TacJ/8mGwP jDSAnp2tjV58S9iSUdT9JRA2drqQWEmTNjJsrx7Z4zVvG86A/NRx4PuTLRqr/tWt/ido HeK4O1dRW2o/rjgF+zBnYFBnBVY8Qtcsqs4sLQ3Ue+jT3WjpTZjs7bFo1EPmh9AEY/yx ZfMA== 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 r10-20020a170906350a00b009d441527214si6452761eja.1045.2023.12.06.00.23.36; Wed, 06 Dec 2023 00:23:36 -0800 (PST) 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 0951E68CF5C; Wed, 6 Dec 2023 10:22:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (iq.passwd.hu [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AF36568CF57 for ; Wed, 6 Dec 2023 10:22:34 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 97BD1E9A21; Wed, 6 Dec 2023 09:22:34 +0100 (CET) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QJvuZPxKC6ZG; Wed, 6 Dec 2023 09:22:32 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 18184E9A27; Wed, 6 Dec 2023 09:22:31 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Wed, 6 Dec 2023 09:22:19 +0100 Message-Id: <20231206082220.5532-6-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20231206082220.5532-1-cus@passwd.hu> References: <20231206082220.5532-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 6/7] avutil/imgutils: add new function av_image_fill_color() 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 Cc: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: kixXBFlOFNTY Signed-off-by: Marton Balint --- doc/APIchanges | 3 +++ libavutil/imgutils.c | 4 ++-- libavutil/imgutils.h | 30 ++++++++++++++++++++++++++++++ libavutil/version.h | 2 +- 4 files changed, 36 insertions(+), 3 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 4a2dc1c44f..416e2bec5e 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -2,6 +2,9 @@ The last version increases of all libraries were on 2023-02-09 API changes, most recent first: +2023-12-xx - xxxxxxxxxxx - lavu 58.33.100 - imgutils.h + Add av_image_fill_color() + 2023-11-08 - b82957a66a7 - lavu 58.32.100 - channel_layout.h Add AV_CH_LAYOUT_7POINT2POINT3 and AV_CHANNEL_LAYOUT_7POINT2POINT3. Add AV_CH_LAYOUT_9POINT1POINT4_BACK and AV_CHANNEL_LAYOUT_9POINT1POINT4_BACK. diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c index 278e30ee0f..e1eefcdd70 100644 --- a/libavutil/imgutils.c +++ b/libavutil/imgutils.c @@ -579,7 +579,7 @@ static void memset_bytes(uint8_t *dst, size_t dst_size, uint8_t *clear, // if it's a subsampled packed format). #define MAX_BLOCK_SIZE 32 -static int image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4], +int av_image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4], enum AVPixelFormat pix_fmt, const uint32_t color[4], int width, int height) { @@ -713,5 +713,5 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz colors[c] = color; } - return image_fill_color(dst_data, dst_linesize, pix_fmt, colors, width, height); + return av_image_fill_color(dst_data, dst_linesize, pix_fmt, colors, width, height); } diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h index fa3bb101b1..6e744b0cac 100644 --- a/libavutil/imgutils.h +++ b/libavutil/imgutils.h @@ -339,6 +339,36 @@ int av_image_fill_black(uint8_t * const dst_data[4], const ptrdiff_t dst_linesiz enum AVPixelFormat pix_fmt, enum AVColorRange range, int width, int height); +/** + * Overwrite the image data with a color. This is suitable for filling a + * sub-rectangle of an image, meaning the padding between the right most pixel + * and the left most pixel on the next line will not be overwritten. For some + * formats, the image size might be rounded up due to inherent alignment. + * + * If the pixel format has alpha, it is also replaced. Color component values + * are interpreted as native integers (or intfloats) regardless of actual pixel + * format endianness. + * + * This can return an error if the pixel format is not supported. Normally, all + * non-hwaccel pixel formats should be supported. + * + * Passing NULL for dst_data is allowed. Then the function returns whether the + * operation would have succeeded. (It can return an error if the pix_fmt is + * not supported.) + * + * @param dst_data data pointers to destination image + * @param dst_linesize linesizes for the destination image + * @param pix_fmt the pixel format of the image + * @param color the color components to be used for the fill + * @param width the width of the image in pixels + * @param height the height of the image in pixels + * @return 0 if the image data was filled, a negative AVERROR code otherwise + */ +int av_image_fill_color(uint8_t * const dst_data[4], const ptrdiff_t dst_linesize[4], + enum AVPixelFormat pix_fmt, const uint32_t color[4], + int width, int height); + + /** * @} */ diff --git a/libavutil/version.h b/libavutil/version.h index c5fa7c3692..0684996bf2 100644 --- a/libavutil/version.h +++ b/libavutil/version.h @@ -79,7 +79,7 @@ */ #define LIBAVUTIL_VERSION_MAJOR 58 -#define LIBAVUTIL_VERSION_MINOR 32 +#define LIBAVUTIL_VERSION_MINOR 33 #define LIBAVUTIL_VERSION_MICRO 100 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \