From patchwork Sat Dec 9 19:25:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 44988 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:1225:b0:181:818d:5e7f with SMTP id v37csp2065056pzf; Sat, 9 Dec 2023 11:25:55 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/belOXb44iN+HqqBswpuzZLkCZ+zVDgDqk1AqzllT/wdwP0KNWmSYCw79jXmXgzPXELtO X-Received: by 2002:a05:6402:311c:b0:54c:4fec:104 with SMTP id dc28-20020a056402311c00b0054c4fec0104mr608044edb.147.1702149955331; Sat, 09 Dec 2023 11:25:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702149955; cv=none; d=google.com; s=arc-20160816; b=N+2iShl75IGgETJ8m5UMt8f9HN2t6pLepwXjAAWt41GRrfi55lG1j6Zh1stcAGEBFA GMZkYAUKDtExs/sRqByrq9KdQfAxfaw0JniPjU+vECwelGp+hESZa7D2MUROznIbvMbc ODeFGg9Gfg7qcccWgkIUTHNqQjTjav0sHZIEaUCk+RifCbk5SfxpEVydaZLU6PufWw0G h46pHCh+zXNCSBTnkmNhzOXWV5azWb01eeScheV3+me/dytIS7ZWqMBze27H9hBDReYD iA/xNfWY2bOlZSrKs9lOI0uSdGl4TGJMjqudPo6uPWNFd02bDv60W8s3yRa96jaxNRMD 6K9Q== 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=zcU8db8NFA6F0Efn3i9XptBEZ9Q/lmF7Dmeqio7Sju8=; fh=s+G8Ss4JbeMFkWPSp2LmIH/LXFyBlALRiww1j3FPjHY=; b=Myp3jAHBgqom2c9hP4dW2qPdyM8nd/dcZe67X5hFCckQ/pLysgbeGZ0c6ekEju0yGX mdCT3ibzWMNf+Jv/qmcYUJDrFLTjaUgrgJZXIE9aP/PaT8kgCRB5eYooH0K0KWTsI2yu rNoP02bgAk/zY+uj/61qvnGcpwhi421vA10uvnHrPgrgOGGslkJie5SEzuxQEbyuJd7S U3l90s7q7pIbVnvaIT+BNuIBbXG3iUl500CZ9KBf16CU+nE3nyKpIJSiIey5FhtOxG9f vuMi1l555w6jt5dLZzkJnrd5zjWlQOeYVm4EToN8C5IP3iXZyWXnvzX0sc75+gsiYvxa K8KQ== 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 w21-20020a50d795000000b0054cbc364297si2079352edi.610.2023.12.09.11.25.54; Sat, 09 Dec 2023 11:25:55 -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 8F7A568D041; Sat, 9 Dec 2023 21:25:52 +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 1DBC268CF57 for ; Sat, 9 Dec 2023 21:25:46 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id B74E6E9974; Sat, 9 Dec 2023 20:25:45 +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 O9D5MRuRHmJd; Sat, 9 Dec 2023 20:25:43 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 92F34E804D; Sat, 9 Dec 2023 20:25:43 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sat, 9 Dec 2023 20:25:07 +0100 Message-Id: <20231209192507.11262-1-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <170196572526.8914.10192984260024793492@lain.khirnov.net> References: <170196572526.8914.10192984260024793492@lain.khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v3 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: uo9cpWPe34x7 v3: added flags argument. Signed-off-by: Marton Balint --- doc/APIchanges | 3 +++ libavutil/imgutils.c | 6 +++--- libavutil/imgutils.h | 31 +++++++++++++++++++++++++++++++ libavutil/version.h | 2 +- 4 files changed, 38 insertions(+), 4 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 4a2dc1c44f..2b0326165e 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..aae40ba59a 100644 --- a/libavutil/imgutils.c +++ b/libavutil/imgutils.c @@ -579,9 +579,9 @@ 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) + int width, int height, int flags) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt); int nb_planes = av_pix_fmt_count_planes(pix_fmt); @@ -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, 0); } diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h index fa3bb101b1..a29ed46a39 100644 --- a/libavutil/imgutils.h +++ b/libavutil/imgutils.h @@ -339,6 +339,37 @@ 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 + * @param flags currently unused + * @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, int flags); + + /** * @} */ 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, \