From: James Almer <jamrial@gmail.com> To: ffmpeg-devel@ffmpeg.org Subject: Re: [FFmpeg-devel] [PATCH] checkasm: add linear least square tests Date: Tue, 28 May 2024 17:03:59 -0300 Message-ID: <1d45614b-8d23-4f45-8f7a-936fa80c45f8@gmail.com> (raw) In-Reply-To: <20240528195736.62519-1-remi@remlab.net> On 5/28/2024 4:57 PM, Rémi Denis-Courmont wrote: > --- > tests/checkasm/Makefile | 1 + > tests/checkasm/checkasm.c | 1 + > tests/checkasm/checkasm.h | 1 + > tests/checkasm/lls.c | 110 ++++++++++++++++++++++++++++++++++++++ > tests/fate/checkasm.mak | 1 + > 5 files changed, 114 insertions(+) > create mode 100644 tests/checkasm/lls.c > > diff --git a/tests/checkasm/Makefile b/tests/checkasm/Makefile > index 1dc770e9da..6eb94d10d5 100644 > --- a/tests/checkasm/Makefile > +++ b/tests/checkasm/Makefile > @@ -71,6 +71,7 @@ CHECKASMOBJS-$(CONFIG_SWSCALE) += $(SWSCALEOBJS) > AVUTILOBJS += av_tx.o > AVUTILOBJS += fixed_dsp.o > AVUTILOBJS += float_dsp.o > +AVUTILOBJS += lls.o > > CHECKASMOBJS-$(CONFIG_AVUTIL) += $(AVUTILOBJS) > > diff --git a/tests/checkasm/checkasm.c b/tests/checkasm/checkasm.c > index 97c9b9fdd4..d7aa2a9c09 100644 > --- a/tests/checkasm/checkasm.c > +++ b/tests/checkasm/checkasm.c > @@ -254,6 +254,7 @@ static const struct { > #if CONFIG_AVUTIL > { "fixed_dsp", checkasm_check_fixed_dsp }, > { "float_dsp", checkasm_check_float_dsp }, > + { "lls", checkasm_check_lls }, > { "av_tx", checkasm_check_av_tx }, > #endif > { NULL } > diff --git a/tests/checkasm/checkasm.h b/tests/checkasm/checkasm.h > index a42645c4ae..211d7f52e6 100644 > --- a/tests/checkasm/checkasm.h > +++ b/tests/checkasm/checkasm.h > @@ -105,6 +105,7 @@ void checkasm_check_huffyuvdsp(void); > void checkasm_check_idctdsp(void); > void checkasm_check_jpeg2000dsp(void); > void checkasm_check_llauddsp(void); > +void checkasm_check_lls(void); > void checkasm_check_llviddsp(void); > void checkasm_check_llviddspenc(void); > void checkasm_check_lpc(void); > diff --git a/tests/checkasm/lls.c b/tests/checkasm/lls.c > new file mode 100644 > index 0000000000..96c97cd7a3 > --- /dev/null > +++ b/tests/checkasm/lls.c > @@ -0,0 +1,110 @@ > +/* > + * 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 <float.h> > +//#include <stdint.h> > + > +#include "libavutil/lls.h" > +//#include "libavutil/internal.h" > +//#include "libavutil/mem.h" > +//#include "libavutil/mem_internal.h" > + > +#include "checkasm.h" > + > +#define LEN 256 > + > +#define randomize_buffer(buf) \ > +do { \ > + int i; \ > + double bmg[2], stddev = 10.0, mean = 0.0; \ > + \ > + for (i = 0; i < LEN; i += 2) { \ MAX_VARS, not LEN. The latter isn't even needed. > + av_bmg_get(&checkasm_lfg, bmg); \ > + buf[i] = bmg[0] * stddev + mean; \ > + buf[i + 1] = bmg[1] * stddev + mean; \ > + } \ > +} while(0); > + > +static void test_update(LLSModel *lls, const double *var) > +{ > + double refcovar[MAX_VARS][MAX_VARS]; > + declare_func(void, LLSModel *, const double *); > + > + call_ref(lls, var); > + > + for (size_t i = 0; i < MAX_VARS; i++) > + for (size_t j = 0; j < MAX_VARS; j++) > + refcovar[i][j] = lls->covariance[i][j]; > + > + memset(lls->covariance, 0, sizeof (lls->covariance)); > + call_new(lls, var); > + > + for (size_t i = 0; i < lls->indep_count; i++) > + for (size_t j = i; j < lls->indep_count; j++) > + if (!double_near_abs_eps(refcovar[i][j], lls->covariance[i][j], > + 2 * DBL_EPSILON)) { > + fprintf(stderr, "%zu, %zu: %- .12f - %- .12f = % .12g\n", i, j, > + refcovar[i][j], lls->covariance[i][j], > + refcovar[i][j] - lls->covariance[i][j]); > + fail(); > + } > + > + bench_new(lls, var); > +} > + > +#define EPS 0.2 > +static void test_evaluate(LLSModel *lls, const double *param, int order) > +{ > + double refprod, newprod; > + declare_func_float(double, LLSModel *, const double *, int); > + > + refprod = call_ref(lls, param, order); > + newprod = call_new(lls, param, order); > + > + if (!double_near_abs_eps(refprod, newprod, EPS)) { > + fprintf(stderr, "%- .12f - %- .12f = % .12g\n", > + refprod, newprod, refprod - newprod); > + fail(); > + } > + > + if (order == lls->indep_count) > + bench_new(lls, param, order); > +} > + > +void checkasm_check_lls(void) > +{ > + static const unsigned char counts[] = { 8, 12, MAX_VARS, }; > + > + for (size_t i = 0; i < FF_ARRAY_ELEMS(counts); i++) { > + LOCAL_ALIGNED_32(double, var, [MAX_VARS]); > + LOCAL_ALIGNED_32(double, param, [MAX_VARS]); > + LLSModel lls; > + > + avpriv_init_lls(&lls, counts[i]); > + randomize_buffer(var); > + randomize_buffer(param); > + > + if (check_func(lls.update_lls, "update_lls_%d", counts[i])) > + test_update(&lls, var); > + for (size_t j = 0; j <= i; j++) > + if (check_func(lls.evaluate_lls, "evaluate_lls_%d_%d", counts[i], > + counts[j])) > + test_evaluate(&lls, param, counts[j]); > + } > + report("lls"); > +} > diff --git a/tests/fate/checkasm.mak b/tests/fate/checkasm.mak > index 8d2705165a..9490aef154 100644 > --- a/tests/fate/checkasm.mak > +++ b/tests/fate/checkasm.mak > @@ -28,6 +28,7 @@ FATE_CHECKASM = fate-checkasm-aacencdsp \ > fate-checkasm-idctdsp \ > fate-checkasm-jpeg2000dsp \ > fate-checkasm-llauddsp \ > + fate-checkasm-lls \ > fate-checkasm-llviddsp \ > fate-checkasm-llviddspenc \ > fate-checkasm-lpc \ _______________________________________________ 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-05-28 20:04 UTC|newest] Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top 2024-05-28 19:57 Rémi Denis-Courmont 2024-05-28 20:03 ` James Almer [this message] 2024-05-29 15:43 Rémi Denis-Courmont
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=1d45614b-8d23-4f45-8f7a-936fa80c45f8@gmail.com \ --to=jamrial@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