[FFmpeg-devel] [PATCH] Added more tests to libswscale/utils.c
Michael Niedermayer
michael at niedermayer.cc
Wed Mar 30 16:18:38 CEST 2016
On Wed, Mar 30, 2016 at 10:12:29AM +0000, Petru Rares Sincraian wrote:
> Hi,
>
> I solved the problems with swscale_license() and alloc_gamma_tbl() functions. I am working to solve alphaless_fmt() function in a different way.
>
> ________________________________________
> From: ffmpeg-devel <ffmpeg-devel-bounces at ffmpeg.org> on behalf of Michael Niedermayer <michael at niedermayer.cc>
> Sent: Sunday, March 27, 2016 9:43 PM
> To: FFmpeg development discussions and patches
> Subject: Re: [FFmpeg-devel] [PATCH] Added more tests to libswscale/utils.c
>
> On Sun, Mar 27, 2016 at 04:39:39PM +0000, Petru Rares Sincraian wrote:
> >
> > - Added test for: swscale_license()
> > - Added test for: alphaless_fmt()
> > - Added test for: alloc_gamma_tbl()
> [...]
>
> > +static void test_alloc_gamma_tbl(void)
> > +{
> > + uint16_t *tbl = alloc_gamma_tbl(1.);
> > + int i;
> > +
> > + // print only 32 elements
> > + printf("e = 1.0\n");
> > + for (i = 0; i < 65536; i += 2048)
> > + printf("it: %d\t value: %d\n", i, tbl[i]);
> > +
> > + tbl = alloc_gamma_tbl(0.75);
> > + printf("\ne = 0.75\n");
> > + for (i = 0; i < 65536; i += 2048)
> > + printf("it: %d\t value: %d\n", i, tbl[i]);
> > +
> > + tbl = alloc_gamma_tbl(2.8);
> > + printf("\ne = 2.8\n");
> > + for (i = 0; i < 65536; i += 2048)
> > + printf("it: %d\t value: %d\n", i, tbl[i]);
>
> this leaks memory
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> In a rich man's house there is no place to spit but his face.
> -- Diogenes of Sinope
> libswscale/Makefile | 1
> libswscale/utils.c | 49 +++++++++++++++++++++
> tests/Makefile | 1
> tests/fate/libswscale.mak | 6 ++
> tests/ref/fate/utils | 105 ++++++++++++++++++++++++++++++++++++++++++++++
> 5 files changed, 162 insertions(+)
> f3e7cf692c31bf2df982eeeb97fc6fef8e3ec736 0001-Added-more-tests-to-libswscale-utils.c.patch
> From ebefe53b13c878d50f5a388022c894d2b2c5ee96 Mon Sep 17 00:00:00 2001
> From: Petru Rares Sincraian <psincraian at outlook.com>
> Date: Thu, 24 Mar 2016 18:46:02 +0100
> Subject: [PATCH] Added more tests to libswscale/utils.c
>
> - Added test for: swscale_license()
> - Added test for: alloc_gamma_tbl()
> ---
> libswscale/Makefile | 1 +
> libswscale/utils.c | 49 ++++++++++++++++++++++
> tests/Makefile | 1 +
> tests/fate/libswscale.mak | 6 +++
> tests/ref/fate/utils | 105 ++++++++++++++++++++++++++++++++++++++++++++++
> 5 files changed, 162 insertions(+)
> create mode 100644 tests/fate/libswscale.mak
> create mode 100644 tests/ref/fate/utils
>
> diff --git a/libswscale/Makefile b/libswscale/Makefile
> index a9f9e03..a6ae81d 100644
> --- a/libswscale/Makefile
> +++ b/libswscale/Makefile
> @@ -27,3 +27,4 @@ SLIBOBJS-$(HAVE_GNU_WINDRES) += swscaleres.o
>
> TESTPROGS = colorspace \
> swscale \
> + utils \
> diff --git a/libswscale/utils.c b/libswscale/utils.c
> index ba409d6..b572a11 100644
> --- a/libswscale/utils.c
> +++ b/libswscale/utils.c
> @@ -2410,3 +2410,52 @@ struct SwsContext *sws_getCachedContext(struct SwsContext *context, int srcW,
> }
> return context;
> }
> +
> +#ifdef TEST
> +
> +static void test_swscale_license(void)
> +{
> + const char *license = swscale_license();
> + if (!strcmp(FFMPEG_LICENSE, license))
> + printf("License OK\n");
> + else
> + printf("License don't match.\nExpect: %s\nGiven: %s\n",
> + FFMPEG_LICENSE, license);
> +}
> +
> +static void test_alloc_gamma_tbl(void)
> +{
> + uint16_t *tbl;
> + int i;
> +
> + // print only 32 elements
> + tbl = alloc_gamma_tbl(1.);
> + printf("e = 1.0\n");
> + for (i = 0; i < 65536; i += 2048)
> + printf("it: %d\t value: %d\n", i, tbl[i]);
> + av_free(tbl);
> +
> + tbl = alloc_gamma_tbl(0.75);
> + printf("\ne = 0.75\n");
> + for (i = 0; i < 65536; i += 2048)
> + printf("it: %d\t value: %d\n", i, tbl[i]);
> + av_free(tbl);
> +
> + tbl = alloc_gamma_tbl(2.8);
> + printf("\ne = 2.8\n");
> + for (i = 0; i < 65536; i += 2048)
> + printf("it: %d\t value: %d\n", i, tbl[i]);
> + av_free(tbl);
> +
> +}
missing malloc failure checks
also a better way to test matematical tables is to check how close
they are to the ideal double precission values
dumping all values to a file would detect changes but not give
any information about if the changes are better or worse so printing
the sum of squared differences or something should be more usefull
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
Observe your enemies, for they first find out your faults. -- Antisthenes
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160330/9eddc935/attachment.sig>
More information about the ffmpeg-devel
mailing list