From patchwork Wed Dec 6 08:22:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 44950 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:9153:b0:181:818d:5e7f with SMTP id x19csp106193pzc; Wed, 6 Dec 2023 00:22:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IElYvRk2+nUEXHtKfeAVplNYoL6PKng6At1Vpu1KzyzjXnUWRPVNs9stBIqYJiYbu0T5F7A X-Received: by 2002:a17:906:3f5b:b0:a10:8db4:bcf3 with SMTP id f27-20020a1709063f5b00b00a108db4bcf3mr283777ejj.9.1701850959208; Wed, 06 Dec 2023 00:22:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701850959; cv=none; d=google.com; s=arc-20160816; b=gSIC7WrGOJgc2Br1y7z97UFD0P9Funo4/RobWepswMblvpzPurRXd6hdQeuacjRGTx EdH1riX4T36DgcKgbGvuDmOzJLE4whkKqZLywaP4XUh+b7mzDh/3i3XB9itzzeAmiK+q tYwchz2stxuNTlQDgSFcxz6bRNH3CVmv46QSl9gnOwsUs6L5uYEioijMYsJ2Ax89mAHZ iBewy2LgPxxk2vnVjAXf9Wkpko2LO37b8FO+xtwy9Arfk1b/2NX2rSXuhkbHQDzlsnpL DDSAd0KoNuXn31KhWJvxPIXfXF/JLdB6/K6JAgCf/FxiMVDw7UDvkXgACoVG8u1IYlHf /d1Q== 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=jfJ/Ace0okpxIW663V43esUL6hGFr/NXpaWAzCZiajU=; fh=s+G8Ss4JbeMFkWPSp2LmIH/LXFyBlALRiww1j3FPjHY=; b=FIyRlPIL/AFl3N7FFGiktMiXgqhscr1Q8ktp9d4ROcZuLsn5aWqy4o0fUGKXE4Su6n 0Uo/mWr38AsDQR0y+Q0NAr/w6rSnGoFSnMARddpPBnHhG4vbxvhGeKMaTqgpuImK1vnd h1RVPvN301KHkY99c/5Q8XfVjkbRatG9UT8wqkH2pcnczYVrKUvA6d/FDMYaa2gd7RAo pjBrsr/V3XCgc85WioURlXB/mZE6Ih1nVZvDPTA9BFi3YcR7unemCVQDrS0qKqAVeUz9 xLChIr3LXeqiRhJbeLgtXI4g1Y6kFEGFoBPYAabotzkLV6LSzgRJ38d4TodjlCHftWmR Il+Q== 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 qf15-20020a1709077f0f00b00a1b63199eb9si3521625ejc.130.2023.12.06.00.22.38; Wed, 06 Dec 2023 00:22:39 -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 8F57B68CF07; Wed, 6 Dec 2023 10:22:34 +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 9AF9268BAC9 for ; Wed, 6 Dec 2023 10:22:27 +0200 (EET) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 0E77FE9A1E; Wed, 6 Dec 2023 09:22:27 +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 E_kb_o2_ABFn; Wed, 6 Dec 2023 09:22:24 +0100 (CET) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 8B509E9982; Wed, 6 Dec 2023 09:22:24 +0100 (CET) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Wed, 6 Dec 2023 09:22:14 +0100 Message-Id: <20231206082220.5532-1-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: References: MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/7] avutil/tests/imgutils: factorize basic tests to new function 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: AQFVg+I7rHZ1 Signed-off-by: Marton Balint --- libavutil/tests/imgutils.c | 68 ++++++++++++++++++++++---------------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/libavutil/tests/imgutils.c b/libavutil/tests/imgutils.c index 748bd6c9d2..1e2bb3fa01 100644 --- a/libavutil/tests/imgutils.c +++ b/libavutil/tests/imgutils.c @@ -19,6 +19,41 @@ #include "libavutil/imgutils.c" #undef printf +static int check_image_fill(enum AVPixelFormat pix_fmt, int w, int h) { + uint8_t *data[4]; + size_t sizes[4]; + ptrdiff_t linesizes1[4], offsets[3] = { 0 }; + int i, total_size, linesizes[4]; + + if (av_image_fill_linesizes(linesizes, pix_fmt, w) < 0) + return -1; + for (i = 0; i < 4; i++) + linesizes1[i] = linesizes[i]; + if (av_image_fill_plane_sizes(sizes, pix_fmt, h, linesizes1) < 0) + return -1; + total_size = av_image_fill_pointers(data, pix_fmt, h, (void *)1, linesizes); + if (total_size < 0) + return -1; + for (i = 0; i < 4 && data[i]; i++); + printf("planes: %d", i); + // Test the output of av_image_fill_linesizes() + printf(", linesizes:"); + for (i = 0; i < 4; i++) + printf(" %3d", linesizes[i]); + // Test the output of av_image_fill_plane_sizes() + printf(", plane_sizes:"); + for (i = 0; i < 4; i++) + printf(" %5"SIZE_SPECIFIER, sizes[i]); + // Test the output of av_image_fill_pointers() + for (i = 0; i < 3 && data[i + 1]; i++) + offsets[i] = data[i + 1] - data[i]; + printf(", plane_offsets:"); + for (i = 0; i < 3; i++) + printf(" %5"PTRDIFF_SPECIFIER, offsets[i]); + printf(", total_size: %d", total_size); + + return 0; +} int main(void) { @@ -35,39 +70,14 @@ int main(void) printf("\n"); while (desc = av_pix_fmt_desc_next(desc)) { - uint8_t *data[4]; - size_t sizes[4]; - ptrdiff_t linesizes1[4], offsets[3] = { 0 }; - int i, total_size, w = 64, h = 48, linesizes[4]; + int w = 64, h = 48; enum AVPixelFormat pix_fmt = av_pix_fmt_desc_get_id(desc); - if (av_image_fill_linesizes(linesizes, pix_fmt, w) < 0) - continue; - for (i = 0; i < 4; i++) - linesizes1[i] = linesizes[i]; - if (av_image_fill_plane_sizes(sizes, pix_fmt, h, linesizes1) < 0) - continue; - total_size = av_image_fill_pointers(data, pix_fmt, h, (void *)1, linesizes); - if (total_size < 0) + if (desc->flags & AV_PIX_FMT_FLAG_HWACCEL) continue; printf("%-16s", desc->name); - for (i = 0; i < 4 && data[i]; i++); - printf("planes: %d", i); - // Test the output of av_image_fill_linesizes() - printf(", linesizes:"); - for (i = 0; i < 4; i++) - printf(" %3d", linesizes[i]); - // Test the output of av_image_fill_plane_sizes() - printf(", plane_sizes:"); - for (i = 0; i < 4; i++) - printf(" %5"SIZE_SPECIFIER, sizes[i]); - // Test the output of av_image_fill_pointers() - for (i = 0; i < 3 && data[i + 1]; i++) - offsets[i] = data[i + 1] - data[i]; - printf(", plane_offsets:"); - for (i = 0; i < 3; i++) - printf(" %5"PTRDIFF_SPECIFIER, offsets[i]); - printf(", total_size: %d\n", total_size); + check_image_fill(pix_fmt, w, h); + printf("\n"); } return 0;