From: "Martin Storsjö" <martin@martin.st> To: ffmpeg-devel@ffmpeg.org Cc: rsbultje@gmail.com, "Martin Storsjö" <martin@martin.st>, alankelly@google.com Subject: [FFmpeg-devel] [PATCH v2] checkasm: sw_scale: Produce more realistic test filter coefficients for yuv2yuvX Date: Thu, 18 Aug 2022 11:16:45 +0300 Message-ID: <20220818081645.3352481-1-martin@martin.st> (raw) This avoids triggering overflows in the filters, and avoids stray test failures in the approximate functions on x86; due to rounding differences, one implementation might overflow while another one doesn't. Signed-off-by: Martin Storsjö <martin@martin.st> --- FWIW, this modification runs successfully with over 1000 different seeds in checkasm. --- tests/checkasm/sw_scale.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/checkasm/sw_scale.c b/tests/checkasm/sw_scale.c index d72506ed86..ec06eafebe 100644 --- a/tests/checkasm/sw_scale.c +++ b/tests/checkasm/sw_scale.c @@ -188,7 +188,6 @@ static void check_yuv2yuvX(int accurate) uint8_t d_val = rnd(); memset(dither, d_val, LARGEST_INPUT_SIZE); randomize_buffers((uint8_t*)src_pixels, LARGEST_FILTER * LARGEST_INPUT_SIZE * sizeof(int16_t)); - randomize_buffers((uint8_t*)filter_coeff, LARGEST_FILTER * sizeof(int16_t)); ctx = sws_alloc_context(); if (accurate) ctx->flags |= SWS_ACCURATE_RND; @@ -202,6 +201,21 @@ static void check_yuv2yuvX(int accurate) if (dstW <= osi) continue; for (fsi = 0; fsi < FILTER_SIZES; ++fsi) { + // Generate filter coefficients for the given filter size, + // with some properties: + // - The coefficients add up to the intended sum (4096, 1<<12) + // - The coefficients contain negative values + // - The filter intermediates don't overflow for worst case + // inputs (all positive coefficients are coupled with + // input_max and all negative coefficients with input_min, + // or vice versa). + // Produce a filter with all coefficients set to + // -((1<<12)/(filter_size-1)) except for one (randomly chosen) + // which is set to ((1<<13)-1). + for (i = 0; i < filter_sizes[fsi]; ++i) + filter_coeff[i] = -((1 << 12) / (filter_sizes[fsi] - 1)); + filter_coeff[rnd() % filter_sizes[fsi]] = (1 << 13) - 1; + src = av_malloc(sizeof(int16_t*) * filter_sizes[fsi]); vFilterData = av_malloc((filter_sizes[fsi] + 2) * sizeof(union VFilterData)); memset(vFilterData, 0, (filter_sizes[fsi] + 2) * sizeof(union VFilterData)); -- 2.25.1 _______________________________________________ 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 reply other threads:[~2022-08-18 8:16 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-08-18 8:16 Martin Storsjö [this message] 2022-08-18 9:12 ` Alan Kelly 2022-08-19 10:41 ` Martin Storsjö
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=20220818081645.3352481-1-martin@martin.st \ --to=martin@martin.st \ --cc=alankelly@google.com \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=rsbultje@gmail.com \ /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