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 37D474B44D for ; Wed, 5 Jun 2024 17:35:20 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3F07068D68F; Wed, 5 Jun 2024 20:35:18 +0300 (EEST) Received: from out162-62-57-252.mail.qq.com (out162-62-57-252.mail.qq.com [162.62.57.252]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4207E68D586 for ; Wed, 5 Jun 2024 20:35:09 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foxmail.com; s=s201512; t=1717608899; bh=H0je/i2WosoBQIBE8AVougdSnIrQcByzq6o37o6cvDE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bh2YL5PicSVqopopFgDqpzY6ed8PstW932DAK96OVLRsSHDiGRIHrnZeoKu4lE3NX I1qi/oiBq0ky8S7Ww0ukFSUIflVGK2GTHPFmjtbqGpgsXqaka6QiPPDcA6IjQwHs48 gr9isc3WNV0PH9tG6Z83HxLjosdnK53NQtVgwtuA= Received: from ZHILIZHAO-MB1.tencent.com ([121.34.203.204]) by newxmesmtplogicsvrszc5-2.qq.com (NewEsmtp) with SMTP id 8BA1E83B; Thu, 06 Jun 2024 01:34:58 +0800 X-QQ-mid: xmsmtpt1717608898tyb82polc Message-ID: X-QQ-XMAILINFO: Nd/Exl7W9DK5spwOYGA6GbbzhNLOJWU+pdJp2svaI6nZ44A5jw3H1L+CepAbnR U+UQdrpw3x+Rl/uminKRA7Wwpz8BggexZVn3h41zGJetikC6KQp1uT8BeovYtxFHYkT+EpYtCt9Z rPHKwHcIjlHtkGaB5TgofvF2g7ryYozKpggQ4yYKBmBcoIIRwJxBJuU7IyEHq9z6EdjX9+fpNhQt OFmLUvqm0nMRTuAHv3PZBlGqIM7eV1HjdnN/pUMSmCFPhZAE0cxGBLDDUbMnEsCV0/VNSKALEo7G 6xIWhNWnz0PSTlXin5y3Pj7Nt22AwacQ3CqMTrlbZPBCidirsDfL7z7KPzu1XlqL62HKKqekVkos UX4NdWrZ33WIfnOzsjNkONuHdHCBsI02ByD4g7coSFYeMjbWQPp3qPK5Tvt7D33RTtY54/JJ1NQY hRsy5a1UXUPunSqA8qrj9dwUVWvvv10g3NdypgG83/YVWLpzat31YLLlUnMDf0tOgjqnpXAhIREp AE6BrxniEEG7kAFQbop8gGhZN9+vhIFjq8gor5U1qQwsDSkfXj2AUQ4MPL3CNLbZc7pr7cfsRDja bQfD+JjKO63RMetlMZ6RtGB181OuK/phP2uQLhr42Ghh1KVtUOKtw0uzWNE4/KA829kflF+Frj5x CHYRXQCyTYCO5YgckBBmSBtqWYm7Y8obm+o+NnkDj2pSqD7pdWu+m4RqZzwKhWs83Q/AsLFZGyfp CR5qzvOMTTV09GJk3i/geoQdDrCbP5rxKSNOO7AS8laGEu0N6sB+hLViJdA3R/Dr0A4dBYqDYnGR g6wmwigTEDjWkoKcm0thf+UTSJgDHURg6SAtKCmzgzI7AWWZXo7RMv2ctwlP8FC2vhDiDBxkwz9v saFJeF1PrLnPp1Ur3Bgn6UVPZQ+kXrb7LTQH7Ksu3Zo0ZL7la0aVU2gEZ6VDuddAdMdrr3UhQGof HUfn78liDlN3xgGeadyzwp/w94ucisymelQY8iI2I= X-QQ-XMRINFO: NS+P29fieYNw95Bth2bWPxk= From: Zhao Zhili To: ffmpeg-devel@ffmpeg.org Date: Thu, 6 Jun 2024 01:34:45 +0800 X-OQ-MSGID: <20240605173455.88233-1-quinkblack@foxmail.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <2732152.mvXUDI8C0e@basile.remlab.net> References: <2732152.mvXUDI8C0e@basile.remlab.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/5] checkasm/sw_rgb: test rgb24/bgr24 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: multipart/mixed; boundary="===============0049610374010957452==" Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: --===============0049610374010957452== Content-Type: text/plain; charset=y Content-Transfer-Encoding: 8bit From: Zhao Zhili The line width 8 is supposed to test corner case, while the performance doesn't matter. Width 1080 is also a case of unaligned to 16. Width 1920 meant for benchmark (together with --runs options). --- v2: add bgr24 support Feel free to remove 128 and/or 1280 from input_sizes if you think it's redundant. I'm still working on patch 2-5. Send patch 1/5 because James and RĂ©mi' patches depend on this. tests/checkasm/sw_rgb.c | 113 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/tests/checkasm/sw_rgb.c b/tests/checkasm/sw_rgb.c index 7cd815e5be..06d27f9235 100644 --- a/tests/checkasm/sw_rgb.c +++ b/tests/checkasm/sw_rgb.c @@ -22,8 +22,11 @@ #include "libavutil/common.h" #include "libavutil/intreadwrite.h" #include "libavutil/mem_internal.h" +#include "libavutil/pixdesc.h" #include "libswscale/rgb2rgb.h" +#include "libswscale/swscale.h" +#include "libswscale/swscale_internal.h" #include "checkasm.h" @@ -179,8 +182,104 @@ static void check_interleave_bytes(void) } } +#define MAX_LINE_SIZE 1920 +static const int input_sizes[] = {8, 128, 1280, 1080, MAX_LINE_SIZE}; +static const enum AVPixelFormat rgb_formats[] = { + AV_PIX_FMT_RGB24, + AV_PIX_FMT_BGR24, +}; + +static void check_rgb_to_y(struct SwsContext *ctx) +{ + 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(rgb_formats); i++) { + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(rgb_formats[i]); + + ctx->srcFormat = rgb_formats[i]; + ctx->dstFormat = AV_PIX_FMT_YUV420P; + ff_sws_init_scale(ctx); + + for (int j = 0; j < FF_ARRAY_ELEMS(input_sizes); j++) { + int w = input_sizes[j]; + + if (check_func(ctx->lumToYV12, "%s_to_y_%d", desc->name, 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) +{ + 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 * FF_ARRAY_ELEMS(rgb_formats); i++) { + enum AVPixelFormat src_fmt = rgb_formats[i / 2]; + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(src_fmt); + + ctx->chrSrcHSubSample = (i % 2) ? 0 : 1; + ctx->srcFormat = src_fmt; + ctx->dstFormat = ctx->chrSrcHSubSample ? 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] >> ctx->chrSrcHSubSample; + + if (check_func(ctx->chrToYV12, "%s_to_uv%s_%d", desc->name, + ctx->chrSrcHSubSample ? "_half" : "", + input_sizes[j])) { + 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; + ff_sws_rgb2rgb_init(); check_shuffle_bytes(shuffle_bytes_2103, "shuffle_bytes_2103"); @@ -203,4 +302,18 @@ 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(); + + check_rgb_to_y(ctx); + report("rgb_to_y"); + + check_rgb_to_uv(ctx); + report("rgb_to_uv"); + + sws_freeContext(ctx); } -- 2.42.0 --===============0049610374010957452== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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". --===============0049610374010957452==--