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 ESMTP id 8068E46138 for ; Wed, 6 Dec 2023 08:22:37 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 490F568CEF6; Wed, 6 Dec 2023 10:22:34 +0200 (EET) 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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; -- 2.35.3 _______________________________________________ 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".