From patchwork Thu Aug 5 08:26:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "J. Dekker" X-Patchwork-Id: 29265 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:6c0f:0:0:0:0:0 with SMTP id a15csp193443ioh; Thu, 5 Aug 2021 01:27:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxfOoon4XIkKwZhiUuLgFHc3IumNCzbPfcJqdx2hW/agq8LbAHS1LG6xfuhCmXfvG5tFvmO X-Received: by 2002:a17:907:2bd0:: with SMTP id gv16mr3754321ejc.49.1628152033839; Thu, 05 Aug 2021 01:27:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628152033; cv=none; d=google.com; s=arc-20160816; b=TeUg1JxqO9QUzzmBDS7STLmMdvUXTpF6LJh/M7oES1ixMENI3tM3kBOSRCyemP4iNt mOlGEEi/rpC3iWLMLIsUMOY6PBEmPAIJqkrUUfcG34VgxALAUpsaVZcg0BpaJvwptOex 9U5TRpy3AGlsHXuuZI9bFnMEdtYuodQrNk7911SUEQ41X/NbuLN9qLwl1I9hfFAuco3n t2dgxFxZ3D8xBLGb2cvtvOrMVqnv04I3edaH61siW6UMHTe9Bek7MFHT3Ob9jZAsQwKd FHmgfL6Q8CXZcUt9pHsorCZ52+RrKZjV/cRXgn6pRXEPMOOw0t+dpxADFTYK3wk44xmK IikQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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:references:in-reply-to:message-id :date:to:from:dkim-signature:dkim-signature:delivered-to; bh=K1XIOPNg5iKy0vBuZoFUqBFpzY0dYFEgYBWRXtO0M9w=; b=nK41KJ9GfdpgOiareXsi7H5tjcUcnBXFfutTKaKF5mQdxvSIiwhjQvAfbHLTT+T5+L BhZHZTED7bf+FNMNpiH1g0kJ8CAUK3QwBNlsxievdjfwzABtJmPbsvgWy9krpZRUnJbQ 4XCWGQSypp1H7sDkMj3TkmRfihEoazO1FZMD4rpiYDY/nvAwUAgzFyHfdtdN7atqnrnl MaCs6oBro5RiCajdosSpr3nENbVHf0oGglHlfnlrD6jppwiZatqon/Pe3kOTL2lDSqmV KQoL/102AtoQd9XDC0AgWAIx3VqairmblAw8zOPYiBYydXNjHKenOBMicmcvV47RS52U qy6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@itanimul.li header.s=fm2 header.b=AwTlrBB1; dkim=neutral (body hash did not verify) header.i=@messagingengine.com header.s=fm3 header.b=CZQPfb7h; 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 dn4si5540586ejc.239.2021.08.05.01.27.13; Thu, 05 Aug 2021 01:27:13 -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=@itanimul.li header.s=fm2 header.b=AwTlrBB1; dkim=neutral (body hash did not verify) header.i=@messagingengine.com header.s=fm3 header.b=CZQPfb7h; 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 9851168A467; Thu, 5 Aug 2021 11:27:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AF23268A314 for ; Thu, 5 Aug 2021 11:26:54 +0300 (EEST) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id CA3435C013A for ; Thu, 5 Aug 2021 04:26:53 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Thu, 05 Aug 2021 04:26:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=itanimul.li; h= from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=OINCedgx9RNH6 Fg5cn62J6wOUTt7cauyi/Z96GTYQ5w=; b=AwTlrBB1J3ap5IcGCZniMVbzd4iEF GW6ODwzNV7rimeyqhzFhW+xvQbfS91XBlPhbWdk9+KOITi9gHGJ7kTHleqhha7FT nWmIuuHDv/fD0kY+CsysRKF4Ru3jLX193Tar9ufQ76eJSbnjy7bPLI6Xg8DPGHBm RtNw9TBcBAqcF/NQc8+BCbc+n9lFyF5dgivW15QuqT9zoI8PkE2jKjQ7DIp63BYK 7Syi82z7uAhWbmRGnWY0UBDFSaECi3taSig5sa4gF/j1uS05KwjYhXMZcOF+UWch hWYN11np4Rtxqs9VcsIIsucRJ7t8U1BCGLUUENC/5SUXtWut5eGK9H2zA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; bh=OINCedgx9RNH6Fg5cn62J6wOUTt7cauyi/Z96GTYQ5w=; b=CZQPfb7h N0Eqo9oRwf1RTKe6T5DSdjiLPcBjobqY4kIqd1cHz4Hp/iADDq1CYEcZOTVH3yff 8weNFvhAimxd4pvEBDA2tADMjE0x2EfB5HlcLdGC7FdzbrBp7Xtf1cLqMs/UareA XqnHLX4U50VQJsIQ1hD0XMu1blWuyDzpPnoC8AzLFZf4ztgAM/T2a8QCz59EKYVY qW5qDLVVpYfhk642ngRiK/GoScmGut+af7MvbMHtRKMohtCcLs4JjP9J1Oc5UrF+ boJ7m/U/p+/zgDcyDv1DHQTUE009y4Q5L9sqW+WRdDliFwaAMjbxNi3unvwr2slD BDIe8V3Ux4Ln1Q== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrieelgddtgecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffojghfggfgsedtkeertd ertddtnecuhfhrohhmpedflfdrucffvghkkhgvrhdfuceojhguvghksehithgrnhhimhhu lhdrlhhiqeenucggtffrrghtthgvrhhnpeegvdfhffduudegheevieekieeffefgveffke dtheekieefhfevueetueefhfetteenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgr mhepmhgrihhlfhhrohhmpehjuggvkhesihhtrghnihhmuhhlrdhlih X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Thu, 5 Aug 2021 04:26:53 -0400 (EDT) From: "J. Dekker" To: ffmpeg-devel@ffmpeg.org Date: Thu, 5 Aug 2021 10:26:49 +0200 Message-Id: <20210805082650.32639-2-jdek@itanimul.li> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20210805082650.32639-1-jdek@itanimul.li> References: <20210805082650.32639-1-jdek@itanimul.li> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/3] checkasm: add h264 chroma test 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: YwIkR4GBbJo/ Signed-off-by: J. Dekker --- tests/checkasm/Makefile | 1 + tests/checkasm/checkasm.c | 3 + tests/checkasm/checkasm.h | 1 + tests/checkasm/h264chroma.c | 109 ++++++++++++++++++++++++++++++++++++ tests/fate/checkasm.mak | 1 + 5 files changed, 115 insertions(+) create mode 100644 tests/checkasm/h264chroma.c What should I do for other codecs here, or just ignore non-h264? diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index 4ef5fa87da..41222c3827 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -6,6 +6,7 @@ AVCODECOBJS-$(CONFIG_BSWAPDSP) += bswapdsp.o AVCODECOBJS-$(CONFIG_FLACDSP) += flacdsp.o AVCODECOBJS-$(CONFIG_FMTCONVERT) += fmtconvert.o AVCODECOBJS-$(CONFIG_G722DSP) += g722dsp.o +AVCODECOBJS-$(CONFIG_H264CHROMA) += h264chroma.o AVCODECOBJS-$(CONFIG_H264DSP) += h264dsp.o AVCODECOBJS-$(CONFIG_H264PRED) += h264pred.o AVCODECOBJS-$(CONFIG_H264QPEL) += h264qpel.o diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index b1353f7cbe..154c4a5c01 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -104,6 +104,9 @@ static const struct { #if CONFIG_G722DSP { "g722dsp", checkasm_check_g722dsp }, #endif + #if CONFIG_H264CHROMA + { "h264chroma", checkasm_check_h264chroma }, + #endif #if CONFIG_H264DSP { "h264dsp", checkasm_check_h264dsp }, #endif diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 68b0697d3e..ac2f22af05 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -56,6 +56,7 @@ void checkasm_check_flacdsp(void); void checkasm_check_float_dsp(void); void checkasm_check_fmtconvert(void); void checkasm_check_g722dsp(void); +void checkasm_check_h264chroma(void); void checkasm_check_h264dsp(void); void checkasm_check_h264pred(void); void checkasm_check_h264qpel(void); diff --git a/tests/checkasm/h264chroma.c b/tests/checkasm/h264chroma.c new file mode 100644 index 0000000000..0bd333327d --- /dev/null +++ b/tests/checkasm/h264chroma.c @@ -0,0 +1,109 @@ +/* + * Copyright (c) 2015 Henrik Gramner + * Copyright (c) 2021 J. Dekker + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with FFmpeg; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include "checkasm.h" +#include "libavcodec/avcodec.h" +#include "libavcodec/h264chroma.h" +#include "libavutil/common.h" +#include "libavutil/internal.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/mem_internal.h" + +// static const int codec_ids[4] = { AV_CODEC_ID_H264, AV_CODEC_ID_VP8, AV_CODEC_ID_RV40, AV_CODEC_ID_SVQ3 }; +static const uint32_t pixel_mask[3] = { 0xffffffff, 0x01ff01ff, 0x03ff03ff }; + +#define SIZEOF_PIXEL ((bit_depth + 7) / 8) +#define BUF_SIZE (3 * 16 * 17) + +#define randomize_buffers() \ + do { \ + uint32_t mask = pixel_mask[bit_depth - 8]; \ + int i; \ + for (i = 0; i < BUF_SIZE; i += 4) { \ + uint32_t r = rnd() & mask; \ + AV_WN32A(buf0 + i, r); \ + AV_WN32A(buf1 + i, r); \ + } \ + } while (0) + +#define src0 (buf0 + 4 * 16) /* Offset to allow room for top and left */ +#define src1 (buf1 + 4 * 16) + +static void check_avg() +{ + int i, bit_depth, x, y; + LOCAL_ALIGNED_16(uint8_t, buf0, [BUF_SIZE]); + LOCAL_ALIGNED_16(uint8_t, buf1, [BUF_SIZE]); + LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE]); + LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE]); + H264ChromaContext h; + + declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h, int x, int y); + for (bit_depth = 8; bit_depth <= 10; bit_depth++) { + ff_h264chroma_init(&h, bit_depth); + for (i = 0; i < 4; i++) { + if (check_func(h.avg_h264_chroma_pixels_tab[i], "avg_chroma_mc%d_%d", 1 << (3 - i), bit_depth)) { + randomize_buffers(); + x = rnd() & 0x7; y = rnd() & 0x7; + call_ref(dst0, src0, 8, 4, x, y); + call_new(dst1, src1, 8, 4, x, y); + if (memcmp(buf0, buf1, BUF_SIZE)) + fail(); + bench_new(dst1, src1, 8, 4, x, y); + } + } + } +} + +static void check_put() +{ + int i, bit_depth, x, y; + LOCAL_ALIGNED_16(uint8_t, buf0, [BUF_SIZE]); + LOCAL_ALIGNED_16(uint8_t, buf1, [BUF_SIZE]); + LOCAL_ALIGNED_16(uint8_t, dst0, [BUF_SIZE]); + LOCAL_ALIGNED_16(uint8_t, dst1, [BUF_SIZE]); + H264ChromaContext h; + + declare_func_emms(AV_CPU_FLAG_MMX, void, uint8_t *dst, uint8_t *src, ptrdiff_t stride, int h, int x, int y); + for (bit_depth = 8; bit_depth <= 10; bit_depth++) { + ff_h264chroma_init(&h, bit_depth); + for (i = 0; i < 4; i++) { + if (check_func(h.put_h264_chroma_pixels_tab[i], "put_chroma_mc%d_%d", 1 << (3 - i), bit_depth)) { + randomize_buffers(); + x = rnd() & 0x7; y = rnd() & 0x7; + call_ref(dst0, src0, 8, 4, x, y); + call_new(dst1, src1, 8, 4, x, y); + if (memcmp(buf0, buf1, BUF_SIZE)) + fail(); + bench_new(dst1, src1, 8, 4, x, y); + } + } + } +} + +void checkasm_check_h264chroma(void) +{ + check_avg(); + report("avg"); + check_put(); + report("put"); +} diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak index cec6d28286..449f8f89f9 100644 --- a/tests/fate/checkasm.mak +++ b/tests/fate/checkasm.mak @@ -11,6 +11,7 @@ FATE_CHECKASM = fate-checkasm-aacpsdsp \ fate-checkasm-float_dsp \ fate-checkasm-fmtconvert \ fate-checkasm-g722dsp \ + fate-checkasm-h264chroma \ fate-checkasm-h264dsp \ fate-checkasm-h264pred \ fate-checkasm-h264qpel \