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 B163A4B377 for ; Tue, 4 Jun 2024 13:55:41 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4766D68D70C; Tue, 4 Jun 2024 16:55:30 +0300 (EEST) Received: from out203-205-221-205.mail.qq.com (out203-205-221-205.mail.qq.com [203.205.221.205]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2128E68D6FA for ; Tue, 4 Jun 2024 16:55:20 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1717509307; bh=d4A7o7YdDjpwMK7C4G5HUV34m0i5VLC61FRvHABVSQA=; h=From:To:Cc:Subject:Date; b=KmMzPnsHlbUKuSz2YH8h7OpEzXeEw1lQgEQVX4kPyS20FugCJYt6u/C84+vPU4Fv2 TzS+E0hWOmkgVSiTt4RnTAqa8aY2XRb+2ETwJvsqXwGLpr1E3d/mntdYXkxA9nWgBv y/Ut6GHlRcOb0n1NHCDd/oe7My1oAZVXabomvP9E= Received: from ZHILIZHAO-MB1.tencent.com ([113.108.77.51]) by newxmesmtplogicsvrsza29-0.qq.com (NewEsmtp) with SMTP id DC59C61C; Tue, 04 Jun 2024 21:55:05 +0800 X-QQ-mid: xmsmtpt1717509305th64abx9c Message-ID: X-QQ-XMAILINFO: M/NR0wiIuy70pgZa/WcfiCNKt5oiC+PKJ96DcZrY1zMJW4StYoVq3ufTNBfX/E Rfa3WMRocjERMtEfUmgYNjUUUlZXwpkXOfz97/wd8Hk4fAHS5+lmFQOHkt21gfOr9EFOy0nBCq7c spJLY1F6MEZuQ8rn1HJ7vSvORKVV1U8tPD2ygbsJmaWYiiuTBiAuO8+0YvTBmFyKjAOTbI5WTImz hrUQCjSkypfwESdFWrxDwN5OKWsUk80l3PiO7Cc7yJmTeppeaj6/qgY45ZiMYYV3DdBbTBYGdOm+ RZUeT5ltizwUnOv5PPfBg/APXz6JzWrC5NuYS6tzRX4En2yLjBHL+JkWxQmZZpBOcpfwpNB9MpKf Smb1nIHV/BWppaPSreXnZrCb2l3egNtd3g/SqDt2Eu1MwXqTf+AD0kGBYBrJMxqDpjHOpRYSuJBW Xqj0ZouNFrl27MPsZx+HAVjOt1Ppxr5sGV7uYVi5NRzyquLU0ud4pD2fq34hJirpiowWB8XaPKUY UW1/ocn4FxvyliJCJ2YDh3VHISdm7a2jI4NU5UBWEnxsIlKBIcgZIdw0p6+YwHdhq4QFr9uhRb6n CHpvywHxSXu96Izvk5qv7pbTJqJvETA+akP1bWz0CBo4YPI6cR4QAHn24IfyMK4UiA+8g0fb+u4/ dAO3SRSl+5E3QgsDzcgGsmJNRnyH8w5KU0h/vtf1NeIn6STYoGeCuT9IehnII678+eQYnqFK6E20 bzh3mmJacKe7sSIoQ3q8csDc4fnB8pQAVl/q6yO0epcdfsWRGXcb81f1rvTdILbuvwbK5l93+eC5 73BnGhApytfcus/r8Frx8OvZloQlx+i5CpmjmMrHkZzYIsStTeJruqDj8GBP0O142jP4fbyaP0Xe 9SiQZgaDGg9PMgo8CNZLd4ygsilM01olgCt2y2gy15Re2YfoDasBLvq/TJP8RU812FPxsELOLC1D IZrfXf7/JwL7fPehfJ9h02liS2AaovmsPoAt4hxr81VzvKofgnLA== X-QQ-XMRINFO: MSVp+SPm3vtS1Vd6Y4Mggwc= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Tue, 4 Jun 2024 21:55:00 +0800 X-OQ-MSGID: <20240604135504.83169-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.42.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/5] checkasm/sw_rgb: test rgb24 to yuv 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: Zhao Zhili 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: From: Zhao Zhili --- tests/checkasm/sw_rgb.c | 103 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) diff --git a/tests/checkasm/sw_rgb.c b/tests/checkasm/sw_rgb.c index 7cd815e5be..cc9b957461 100644 --- a/tests/checkasm/sw_rgb.c +++ b/tests/checkasm/sw_rgb.c @@ -24,6 +24,8 @@ #include "libavutil/mem_internal.h" #include "libswscale/rgb2rgb.h" +#include "libswscale/swscale.h" +#include "libswscale/swscale_internal.h" #include "checkasm.h" @@ -179,8 +181,89 @@ static void check_interleave_bytes(void) } } +#define MAX_LINE_SIZE 1920 + +static void check_rgb_to_y(struct SwsContext *ctx) +{ + static const int input_sizes[] = {8, 128, 1280, 1080, MAX_LINE_SIZE}; + + LOCAL_ALIGNED_32(uint8_t, src, [MAX_LINE_SIZE * 3]); + LOCAL_ALIGNED_32(uint8_t, dst0_y, [MAX_LINE_SIZE * 2]); + LOCAL_ALIGNED_32(uint8_t, dst1_y, [MAX_LINE_SIZE * 2]); + + declare_func(void, uint8_t *dst, const uint8_t *src, + const uint8_t *unused1, const uint8_t *unused2, int width, + uint32_t *rgb2yuv, void *opq); + + randomize_buffers(src, MAX_LINE_SIZE * 3); + + for (int i = 0; i < FF_ARRAY_ELEMS(input_sizes); i++) { + int w = input_sizes[i]; + + if (check_func(ctx->lumToYV12, "rgb24_to_y_%d", w)) { + memset(dst0_y, 0xFA, MAX_LINE_SIZE * 2); + memset(dst1_y, 0xFA, MAX_LINE_SIZE * 2); + + call_ref(dst0_y, src, NULL, NULL, w, ctx->input_rgb2yuv_table, NULL); + call_new(dst1_y, src, NULL, NULL, w, ctx->input_rgb2yuv_table, NULL); + + if (memcmp(dst0_y, dst1_y, w * 2)) + fail(); + + bench_new(dst1_y, src, NULL, NULL, w, ctx->input_rgb2yuv_table, NULL); + } + } +} + +static void check_rgb_to_uv(struct SwsContext *ctx) +{ + static const int input_sizes[] = {8, 128, 1280, 1080, MAX_LINE_SIZE}; + + LOCAL_ALIGNED_32(uint8_t, src, [MAX_LINE_SIZE * 3]); + LOCAL_ALIGNED_32(uint8_t, dst0_u, [MAX_LINE_SIZE * 2]); + LOCAL_ALIGNED_32(uint8_t, dst0_v, [MAX_LINE_SIZE * 2]); + LOCAL_ALIGNED_32(uint8_t, dst1_u, [MAX_LINE_SIZE * 2]); + LOCAL_ALIGNED_32(uint8_t, dst1_v, [MAX_LINE_SIZE * 2]); + + declare_func(void, uint8_t *dstU, uint8_t *dstV, + const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, + int width, uint32_t *pal, void *opq); + + randomize_buffers(src, MAX_LINE_SIZE * 3); + + for (int i = 0; i < 2; i++) { + ctx->chrSrcHSubSample = i ? 1 : 0; + ctx->srcFormat = AV_PIX_FMT_RGB24; + ctx->dstFormat = i ? AV_PIX_FMT_YUV420P : AV_PIX_FMT_YUV444P; + ff_sws_init_scale(ctx); + + for (int j = 0; j < FF_ARRAY_ELEMS(input_sizes); j++) { + int w = input_sizes[j] >> i; + + if (check_func(ctx->chrToYV12, "rgb24_to_uv%s_%d", i ? "_half" : "", w)) { + memset(dst0_u, 0xFF, MAX_LINE_SIZE * 2); + memset(dst0_v, 0xFF, MAX_LINE_SIZE * 2); + memset(dst1_u, 0xFF, MAX_LINE_SIZE * 2); + memset(dst1_v, 0xFF, MAX_LINE_SIZE * 2); + + call_ref(dst0_u, dst0_v, NULL, src, src, w, ctx->input_rgb2yuv_table, NULL); + call_new(dst1_u, dst1_v, NULL, src, src, w, ctx->input_rgb2yuv_table, NULL); + + if (memcmp(dst0_u, dst1_u, w * 2) || memcmp(dst0_v, dst1_v, w * 2)) + fail(); + + bench_new(dst1_u, dst1_v, NULL, src, src, w, ctx->input_rgb2yuv_table, NULL); + } + } + } +} + void checkasm_check_sw_rgb(void) { + struct SwsContext *ctx; + int *inv_table, *table; + int in_full, out_full, brightness, contrast, saturation; + ff_sws_rgb2rgb_init(); check_shuffle_bytes(shuffle_bytes_2103, "shuffle_bytes_2103"); @@ -203,4 +286,24 @@ void checkasm_check_sw_rgb(void) check_interleave_bytes(); report("interleave_bytes"); + + ctx = sws_getContext(MAX_LINE_SIZE, MAX_LINE_SIZE, AV_PIX_FMT_RGB24, + MAX_LINE_SIZE, MAX_LINE_SIZE, AV_PIX_FMT_YUV420P, + SWS_ACCURATE_RND | SWS_BITEXACT, NULL, NULL, NULL); + if (!ctx) + fail(); + + sws_getColorspaceDetails(ctx, &inv_table, &in_full, + &table, &out_full, + &brightness, &contrast, &saturation); + sws_setColorspaceDetails(ctx, inv_table, in_full, + table, out_full, + brightness, contrast, saturation); + check_rgb_to_y(ctx); + report("rgb_to_y"); + + check_rgb_to_uv(ctx); + report("rgb_to_uv"); + + sws_freeContext(ctx); } -- 2.42.0 _______________________________________________ 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".