From patchwork Wed Aug 28 20:43:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ramiro Polla X-Patchwork-Id: 51216 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a59:c944:0:b0:48e:c0f8:d0de with SMTP id k4csp1124806vqt; Wed, 28 Aug 2024 13:43:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUYBMccuUM+db67LR2lOVS+HoN7py1MUvI3C9kHcsK0L+ZkBiNbI/dVXmq1XUM196yBwglLBHtMbt20cOzsVnOP@gmail.com X-Google-Smtp-Source: AGHT+IGmH9bzsm/Ehbc1nte3dpT7lHmNYoqaFMCi6KPVoBgNyLm+Bqhyp1NLjjcKhO7ELOCck4km X-Received: by 2002:a17:907:7e9c:b0:a86:94cd:97f0 with SMTP id a640c23a62f3a-a89825f320fmr41418166b.19.1724877796822; Wed, 28 Aug 2024 13:43:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724877796; cv=none; d=google.com; s=arc-20240605; b=SZFIWZ3B4Tw2aSZQ0bBrgzFzrKd4PPXhOJ/sqcMuEnV69p+wP5+qVAJY96cltgvsth 4rI1tttDeCnWe0AUEuZ5eeJvOaaA03D8JoBiYIdvjHedrROEIPWffdX7TR05Y1Gh6a7F aa5YyqgcYxqyJkPxAegeUqGZxHBkXC/GF0xMpqnuQRuF7nLydex6PaAjvUU6uGs1Kt8X cv7jjVwrpcwML2NBwIBd9IYNmepv8Pt1Tzt+WwTREzq15mk02I3v26h2JIkTbbfN8PAg 0nJJPiKRG2Gt0PhDrTsFfJE736Up9B5IZfflxRYUMm97Mp4LXBZw/OFaG23vctPAshb7 3uIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=cEKZU+IOTRjLA+iFIcgHDlUm2poKIZpDazEMNDt95+4=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=SZuGrL4a/hO+l64PpEYl6LikY4oFWREadrsJES+uh5cWrsfOUt6zEWcQEzfGEmN5re O2QXn4B5lY7ICVVNxYghaxuOk99vSncZDssCOa52D7SR0iLV7f/4IjndJJXXLcsck0NT fK+QzGco0a68uomiQPNzV60AGkZ6zNGoZvyQVcQ3KCgPT3RescDTVN4MCzyLNcBnoocc fwwLualpxsLOEOfdbk/SbvCc5blrURTRrY7+6ul9+T+SviHkJRxIrX6JXUN+9KF20wAQ iNyGWxBCesiA0fm6MXKQnLXSPWz/W7PoGd84rpBYccZf9eXGEqC/Fk2GW5JSqQ1noX0F BALg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=LYa6YWAx; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id a640c23a62f3a-a86e6a1e6bcsi354719966b.220.2024.08.28.13.43.16; Wed, 28 Aug 2024 13:43:16 -0700 (PDT) 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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20230601 header.b=LYa6YWAx; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com; dara=fail header.i=@gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2FB5368DCBF; Wed, 28 Aug 2024 23:43:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6C90B68DC11 for ; Wed, 28 Aug 2024 23:43:06 +0300 (EEST) Received: by mail-wr1-f49.google.com with SMTP id ffacd0b85a97d-37182eee02dso720742f8f.1 for ; Wed, 28 Aug 2024 13:43:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724877785; x=1725482585; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=it6KQ/gGFYX7BQgJAai9ydYqEC8QKtwaQ7YTcLqYSSA=; b=LYa6YWAxrDUd3b2WnfL3EmUrMyP+LzyEIjypuM9MBDBfbTiqN14UHPcDXKMlMEz7NL aCjkt51q00jRUizmBeajo7i+0vkOyLkewfn5d4TIvA46NbOhkEeTZHNTXCq4ZkzHLfwe 3QX6rQnATe29+04gvGixQvYn7MOInICN7Sj67nat/NPrqVfTOBYDFu11pdWDhwy3e4h5 rmGemUQLFqJDHtNW24LQ1no/mlz29+V8ZPvDcAT0QxmZswHMglSCUcucrYSgZaOVcPDN eqKAUX73FHTz75xklgz8axe665jJZ4yje2rNBoYs4kOmTz1XFxJbHNK9w8GUY5xU0xZ7 P9Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724877785; x=1725482585; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=it6KQ/gGFYX7BQgJAai9ydYqEC8QKtwaQ7YTcLqYSSA=; b=wnzXyHiAVOw0wVO2RUEHODLka//l+MK9z5GKlFyWl5ZdipvveoM3Py/w5laqlePo4w OspY4Jkid77zRjIgTI7k+a0DpEOD/tvkzPyOUfND2LyHUkNoSk1c1KXK7ewpCc84q5Qf 4muD7utdsw2q0tTzca650w9gQpcrsshndyPmAjMciyI9wylLGR6p+VxO5LvVNmtPSUq3 EsvJOuKfNicr/oCjiKTP6WM6F+ykR8+OxfzeznwFHVFDS3fzMTcambmDb9JcGBMypqJN jsXPp2Zjv5AsZpMzXAtVXkk4YvUGZloqVeIrDqgJJ5zyHMIbWC4hY8Ss/sGoWegcbaXW Xbgg== X-Gm-Message-State: AOJu0Yy0cAqTTopKj588p4IF0ooZHpf36SkVpdCWlAR/qqe1nRu/Oy3d jJfb72+ZGMthkUqT24g9nPXtyGmhyc9g8CA9YRCjdCALtU0ObR+2rvzOyA== X-Received: by 2002:a5d:4b50:0:b0:374:8fdf:116 with SMTP id ffacd0b85a97d-3749c2051d7mr133064f8f.35.1724877784764; Wed, 28 Aug 2024 13:43:04 -0700 (PDT) Received: from localhost.localdomain ([109.138.158.185]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3749b240199sm574287f8f.47.2024.08.28.13.43.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Aug 2024 13:43:04 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Aug 2024 22:43:00 +0200 Message-Id: <20240828204303.5801-1-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/4] checkasm/sw_rgb: add rgb24toyv12 tests 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: k6hNNqBQM47u NOTE: currently the tests for rgb24toyv12 fail for x86 since the c and mmxext implementations differ (the mmxext version averages four rgb pixels before performing the chroma calculations). --- tests/checkasm/sw_rgb.c | 89 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/tests/checkasm/sw_rgb.c b/tests/checkasm/sw_rgb.c index f278454d3d..ff84ddf5ef 100644 --- a/tests/checkasm/sw_rgb.c +++ b/tests/checkasm/sw_rgb.c @@ -114,6 +114,92 @@ static void check_uyvy_to_422p(void) } } +#define NUM_LINES 5 +#define MAX_LINE_SIZE 1920 +#define BUFSIZE (NUM_LINES * MAX_LINE_SIZE) + +static int cmp_off_by_n(const uint8_t *ref, const uint8_t *test, size_t n, int accuracy) +{ + for (size_t i = 0; i < n; i++) { + if (abs(ref[i] - test[i]) > accuracy) + return 1; + } + return 0; +} + +static void check_rgb24toyv12(struct SwsContext *ctx) +{ + static const int input_sizes[] = {16, 128, 512, MAX_LINE_SIZE, -MAX_LINE_SIZE}; + + LOCAL_ALIGNED_32(uint8_t, src, [BUFSIZE * 3]); + LOCAL_ALIGNED_32(uint8_t, buf_y_0, [BUFSIZE]); + LOCAL_ALIGNED_32(uint8_t, buf_y_1, [BUFSIZE]); + LOCAL_ALIGNED_32(uint8_t, buf_u_0, [BUFSIZE / 4]); + LOCAL_ALIGNED_32(uint8_t, buf_u_1, [BUFSIZE / 4]); + LOCAL_ALIGNED_32(uint8_t, buf_v_0, [BUFSIZE / 4]); + LOCAL_ALIGNED_32(uint8_t, buf_v_1, [BUFSIZE / 4]); + + declare_func(void, const uint8_t *src, uint8_t *ydst, uint8_t *udst, + uint8_t *vdst, int width, int height, int lumStride, + int chromStride, int srcStride, int32_t *rgb2yuv); + + randomize_buffers(src, BUFSIZE * 3); + + for (int isi = 0; isi < FF_ARRAY_ELEMS(input_sizes); isi++) { + int input_size = input_sizes[isi]; + int negstride = input_size < 0; + const char *negstride_str = negstride ? "_negstride" : ""; + int width = FFABS(input_size); + int linesize = width + 32; + /* calculate height based on specified width to use the entire buffer. */ + int height = (BUFSIZE / linesize) & ~1; + uint8_t *src0 = src; + uint8_t *src1 = src; + uint8_t *dst_y_0 = buf_y_0; + uint8_t *dst_y_1 = buf_y_1; + uint8_t *dst_u_0 = buf_u_0; + uint8_t *dst_u_1 = buf_u_1; + uint8_t *dst_v_0 = buf_v_0; + uint8_t *dst_v_1 = buf_v_1; + + if (negstride) { + src0 += (height - 1) * (linesize * 3); + src1 += (height - 1) * (linesize * 3); + dst_y_0 += (height - 1) * linesize; + dst_y_1 += (height - 1) * linesize; + dst_u_0 += ((height / 2) - 1) * (linesize / 2); + dst_u_1 += ((height / 2) - 1) * (linesize / 2); + dst_v_0 += ((height / 2) - 1) * (linesize / 2); + dst_v_1 += ((height / 2) - 1) * (linesize / 2); + linesize *= -1; + } + + if (check_func(ff_rgb24toyv12, "rgb24toyv12_%d_%d%s", width, height, negstride_str)) { + memset(buf_y_0, 0xFF, BUFSIZE); + memset(buf_y_1, 0xFF, BUFSIZE); + memset(buf_u_0, 0xFF, BUFSIZE / 4); + memset(buf_u_1, 0xFF, BUFSIZE / 4); + memset(buf_v_0, 0xFF, BUFSIZE / 4); + memset(buf_v_1, 0xFF, BUFSIZE / 4); + + call_ref(src0, dst_y_0, dst_u_0, dst_v_0, width, height, + linesize, linesize / 2, linesize * 3, ctx->input_rgb2yuv_table); + call_new(src1, dst_y_1, dst_u_1, dst_v_1, width, height, + linesize, linesize / 2, linesize * 3, ctx->input_rgb2yuv_table); + if (cmp_off_by_n(buf_y_0, buf_y_1, BUFSIZE, 1) || + cmp_off_by_n(buf_u_0, buf_u_1, BUFSIZE / 4, 1) || + cmp_off_by_n(buf_v_0, buf_v_1, BUFSIZE / 4, 1)) + fail(); + bench_new(src1, dst_y_1, dst_u_1, dst_v_1, width, height, + linesize, linesize / 2, linesize * 3, ctx->input_rgb2yuv_table); + } + } +} + +#undef NUM_LINES +#undef MAX_LINE_SIZE +#undef BUFSIZE + static void check_interleave_bytes(void) { LOCAL_ALIGNED_16(uint8_t, src0_buf, [MAX_STRIDE*MAX_HEIGHT+1]); @@ -327,5 +413,8 @@ void checkasm_check_sw_rgb(void) check_rgb_to_uv(ctx); report("rgb_to_uv"); + check_rgb24toyv12(ctx); + report("rgb24toyv12"); + sws_freeContext(ctx); }