From: Ramiro Polla <ramiro.polla@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 2/4] checkasm: add tests for {lum, chr}ConvertRange Date: Fri, 7 Jun 2024 16:05:41 +0200 Message-ID: <20240607140543.130761-2-ramiro.polla@gmail.com> (raw) In-Reply-To: <20240607140543.130761-1-ramiro.polla@gmail.com> --- 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 <string.h> + +#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".
next prev parent reply other threads:[~2024-06-07 14:06 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-06-07 14:05 [FFmpeg-devel] [PATCH 1/4] tests/checkasm: cosmetics, one object per line in Makefile Ramiro Polla 2024-06-07 14:05 ` Ramiro Polla [this message] 2024-06-07 14:05 ` [FFmpeg-devel] [PATCH 3/4] swscale/x86: add sse4 {lum, chr}ConvertRange Ramiro Polla 2024-06-07 17:38 ` Ramiro Polla 2024-06-07 14:05 ` [FFmpeg-devel] [PATCH 4/4] swscale/aarch64: add neon " Ramiro Polla 2024-06-10 11:56 ` Martin Storsjö 2024-06-11 12:33 ` Ramiro Polla 2024-06-07 18:45 ` [FFmpeg-devel] [PATCH 1/4] tests/checkasm: cosmetics, one object per line in Makefile Andreas Rheinhardt 2024-06-07 19:09 ` Ramiro Polla 2024-06-07 19:12 ` Andreas Rheinhardt 2024-06-07 19:47 ` Ramiro Polla
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240607140543.130761-2-ramiro.polla@gmail.com \ --to=ramiro.polla@gmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git