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 34F0E45DC3 for ; Fri, 7 Jun 2024 14:06:07 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id EBC0868D743; Fri, 7 Jun 2024 17:05:54 +0300 (EEST) Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 26DAD68D534 for ; Fri, 7 Jun 2024 17:05:48 +0300 (EEST) Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-52b992fd796so2291284e87.0 for ; Fri, 07 Jun 2024 07:05:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717769147; x=1718373947; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=HFbcJnXCxUjRtXhXwqVeu4JOX5LA8I0bv5HKm7X/MNY=; b=Jscz1vPBAtfL8Q2i4cAd1hzEz95Lmz5QynmvPwpZswsV3U0QestIKd8iHcEVY60drS ROQts4TKXDRkQ1uYrGR/oWRaS1838JKlaQ7rOYW1t6YcCafh71YefNDwzXnWmc4QipAF jugSIcnAeg3xUdNw719WNkjZbQ0zihsTj5Qr+Rm9oyT4Wu00O1WDSP5SFK/nTbUiBECt PpBYZGbf14obPVkHHCFi9L3ZKLPyBbRAeSqmgQYVwfE/brdaCkKLudehdzocnkJAVjVc FMGhVTv5C2WPH4xhGKs87ECDb7gY1AtoXfXG3oBfCTiJ0A8zttofcS/KmW3MbNzDieA/ Fucg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717769147; x=1718373947; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=HFbcJnXCxUjRtXhXwqVeu4JOX5LA8I0bv5HKm7X/MNY=; b=aaDWBjiUyhflFKpqdIhPs3S8Dg/1JkqNXF2YAOcgEaMYQym9MYBd/iBIBNDfELVrtW 2E8nD09HP0QSepOOwPXjCXh9Ozcj5nv31YNDY4laeWq31pF69iWRzyGSbjogLoB5mcLM YdRsSMo7sS08v1LFFGANrzLY0YcHY2m7HiL7qoSGrIVWpwvYEB4YQwMWHoZVTYJuJoIQ FtoLEA6NDZ1naDNKOM5B8sw83yHy4U53FblsltHJGp2XRN1aBRl1rss0QIJSaLySKEUQ 9bTlAkEkSCV3q34fHR3Smx33e2q6aqDNUp58EEnYSN0B8+FTYsrLUV1nuo+QNZnmGA2r 1yxw== X-Gm-Message-State: AOJu0Yyp4+pVa8I3Xbdw86HKvv5KaYiWFyxCkwf1LpjDjArazbBCnr+6 CbFfpWwsDPLBR9pQ3upvZvSOz36E+VGP2FZ9aSyJYt6oFwHm9l0uJOcNCw== X-Google-Smtp-Source: AGHT+IGMhmbUpoSH1gNCY0BVQNfyaaShC4XxYHmMU55XAXZ1ljL/gkby0wQZg2dpwzLwG5S/vSfX6g== X-Received: by 2002:ac2:5ece:0:b0:51f:6a38:be0c with SMTP id 2adb3069b0e04-52bb9f6ef1emr1610467e87.22.1717769146480; Fri, 07 Jun 2024 07:05:46 -0700 (PDT) Received: from localhost.localdomain (80.164-182-91.adsl-dyn.isp.belgacom.be. [91.182.164.80]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4215814f6c0sm87282795e9.46.2024.06.07.07.05.45 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Jun 2024 07:05:46 -0700 (PDT) From: Ramiro Polla To: ffmpeg-devel@ffmpeg.org Date: Fri, 7 Jun 2024 16:05:41 +0200 Message-Id: <20240607140543.130761-2-ramiro.polla@gmail.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20240607140543.130761-1-ramiro.polla@gmail.com> References: <20240607140543.130761-1-ramiro.polla@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/4] checkasm: add tests for {lum, chr}ConvertRange 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 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: --- tests/checkasm/Makefile | 1 + tests/checkasm/checkasm.c | 1 + tests/checkasm/checkasm.h | 1 + tests/checkasm/sw_range_convert.c | 134 ++++++++++++++++++++++++++++++ 4 files changed, 137 insertions(+) create mode 100644 tests/checkasm/sw_range_convert.c diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile index 3ce152e818..e4ec6a27ec 100644 --- a/tests/checkasm/Makefile +++ b/tests/checkasm/Makefile @@ -64,6 +64,7 @@ CHECKASMOBJS-$(CONFIG_AVFILTER) += $(AVFILTEROBJS-yes) # swscale tests SWSCALEOBJS += sw_gbrp.o +SWSCALEOBJS += sw_range_convert.o SWSCALEOBJS += sw_rgb.o SWSCALEOBJS += sw_scale.o diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c index d7aa2a9c09..d2b50c023a 100644 --- a/tests/checkasm/checkasm.c +++ b/tests/checkasm/checkasm.c @@ -248,6 +248,7 @@ static const struct { #endif #if CONFIG_SWSCALE { "sw_gbrp", checkasm_check_sw_gbrp }, + { "sw_range_convert", checkasm_check_sw_range_convert }, { "sw_rgb", checkasm_check_sw_rgb }, { "sw_scale", checkasm_check_sw_scale }, #endif diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h index 211d7f52e6..e544007b67 100644 --- a/tests/checkasm/checkasm.h +++ b/tests/checkasm/checkasm.h @@ -119,6 +119,7 @@ void checkasm_check_rv40dsp(void); void checkasm_check_svq1enc(void); void checkasm_check_synth_filter(void); void checkasm_check_sw_gbrp(void); +void checkasm_check_sw_range_convert(void); void checkasm_check_sw_rgb(void); void checkasm_check_sw_scale(void); void checkasm_check_takdsp(void); diff --git a/tests/checkasm/sw_range_convert.c b/tests/checkasm/sw_range_convert.c new file mode 100644 index 0000000000..6d7e22ad40 --- /dev/null +++ b/tests/checkasm/sw_range_convert.c @@ -0,0 +1,134 @@ +/* + * 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 "libavutil/common.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/mem.h" +#include "libavutil/mem_internal.h" + +#include "libswscale/swscale.h" +#include "libswscale/swscale_internal.h" + +#include "checkasm.h" + +static void check_lumConvertRange(int from) +{ + const char *func_str = from ? "lumRangeFromJpeg" : "lumRangeToJpeg"; +#define LARGEST_INPUT_SIZE 512 +#define INPUT_SIZES 6 + static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; + struct SwsContext *ctx; + + LOCAL_ALIGNED_32(int16_t, dst0, [LARGEST_INPUT_SIZE]); + LOCAL_ALIGNED_32(int16_t, dst1, [LARGEST_INPUT_SIZE]); + + declare_func(void, int16_t *dst, int width); + + ctx = sws_alloc_context(); + if (sws_init_context(ctx, NULL, NULL) < 0) + fail(); + + ctx->srcFormat = from ? AV_PIX_FMT_YUVJ444P : AV_PIX_FMT_YUV444P; + ctx->dstFormat = from ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P; + ctx->srcRange = from; + ctx->dstRange = !from; + + for (int dstWi = 0; dstWi < INPUT_SIZES; dstWi++) { + int width = input_sizes[dstWi]; + for (int i = 0; i < width; i++) { + uint8_t r = rnd(); + dst0[i] = (int16_t) r << 7; + dst1[i] = (int16_t) r << 7; + } + ff_sws_init_scale(ctx); + if (check_func(ctx->lumConvertRange, "%s_%d", func_str, width)) { + call_ref(dst0, width); + call_new(dst1, width); + if (memcmp(dst0, dst1, width * sizeof(int16_t))) + fail(); + bench_new(dst1, width); + } + } + + sws_freeContext(ctx); +} +#undef LARGEST_INPUT_SIZE +#undef INPUT_SIZES + +static void check_chrConvertRange(int from) +{ + const char *func_str = from ? "chrRangeFromJpeg" : "chrRangeToJpeg"; +#define LARGEST_INPUT_SIZE 512 +#define INPUT_SIZES 6 + static const int input_sizes[] = {8, 24, 128, 144, 256, 512}; + struct SwsContext *ctx; + + LOCAL_ALIGNED_32(int16_t, dstU0, [LARGEST_INPUT_SIZE]); + LOCAL_ALIGNED_32(int16_t, dstV0, [LARGEST_INPUT_SIZE]); + LOCAL_ALIGNED_32(int16_t, dstU1, [LARGEST_INPUT_SIZE]); + LOCAL_ALIGNED_32(int16_t, dstV1, [LARGEST_INPUT_SIZE]); + + declare_func(void, int16_t *dstU, int16_t *dstV, int width); + + ctx = sws_alloc_context(); + if (sws_init_context(ctx, NULL, NULL) < 0) + fail(); + + ctx->srcFormat = from ? AV_PIX_FMT_YUVJ444P : AV_PIX_FMT_YUV444P; + ctx->dstFormat = from ? AV_PIX_FMT_YUV444P : AV_PIX_FMT_YUVJ444P; + ctx->srcRange = from; + ctx->dstRange = !from; + + for (int dstWi = 0; dstWi < INPUT_SIZES; dstWi++) { + int width = input_sizes[dstWi]; + for (int i = 0; i < width; i++) { + uint8_t r = rnd(); + dstU0[i] = (int16_t) r << 7; + dstV0[i] = (int16_t) r << 7; + dstU1[i] = (int16_t) r << 7; + dstV1[i] = (int16_t) r << 7; + } + ff_sws_init_scale(ctx); + if (check_func(ctx->chrConvertRange, "%s_%d", func_str, width)) { + call_ref(dstU0, dstV0, width); + call_new(dstU1, dstV1, width); + if (memcmp(dstU0, dstU1, width * sizeof(int16_t)) + || memcmp(dstV0, dstV1, width * sizeof(int16_t))) + fail(); + bench_new(dstU1, dstV1, width); + } + } + + sws_freeContext(ctx); +} +#undef LARGEST_INPUT_SIZE +#undef INPUT_SIZES + +void checkasm_check_sw_range_convert(void) +{ + check_lumConvertRange(1); + report("lumRangeFromJpeg"); + check_chrConvertRange(1); + report("chrRangeFromJpeg"); + check_lumConvertRange(0); + report("lumRangeToJpeg"); + check_chrConvertRange(0); + report("chrRangeToJpeg"); +} -- 2.30.2 _______________________________________________ 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".