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-boun...@ffmpeg.org> on behalf of Michael 
Niedermayer <mich...@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
From ebefe53b13c878d50f5a388022c894d2b2c5ee96 Mon Sep 17 00:00:00 2001
From: Petru Rares Sincraian <psincra...@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);
+
+}
+
+int main(void)
+{
+    printf("Testing swscale_license()\n");
+    test_swscale_license();
+
+    printf("\nTesting alloc_gamma_tbl()\n");
+    test_alloc_gamma_tbl();
+}
+
+#endif
diff --git a/tests/Makefile b/tests/Makefile
index 6fef0cd..4e82a69 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -140,6 +140,7 @@ include $(SRC_PATH)/tests/fate/libavformat.mak
 include $(SRC_PATH)/tests/fate/libavresample.mak
 include $(SRC_PATH)/tests/fate/libavutil.mak
 include $(SRC_PATH)/tests/fate/libswresample.mak
+include $(SRC_PATH)/tests/fate/libswscale.mak
 include $(SRC_PATH)/tests/fate/lossless-audio.mak
 include $(SRC_PATH)/tests/fate/lossless-video.mak
 include $(SRC_PATH)/tests/fate/microsoft.mak
diff --git a/tests/fate/libswscale.mak b/tests/fate/libswscale.mak
new file mode 100644
index 0000000..2bd7139
--- /dev/null
+++ b/tests/fate/libswscale.mak
@@ -0,0 +1,6 @@
+FATE_LIBAVSWSCALE += fate-utils
+fate-utils: libswscale/utils-test$(EXESUF)
+fate-utils: CMD = run libswscale/utils-test
+
+FATE-$(CONFIG_SWSCALE) += $(FATE_LIBAVSWSCALE)
+fate-libavswscale: $(FATE_LIBAVSWSCALE)
diff --git a/tests/ref/fate/utils b/tests/ref/fate/utils
new file mode 100644
index 0000000..3743b82
--- /dev/null
+++ b/tests/ref/fate/utils
@@ -0,0 +1,105 @@
+Testing swscale_license()
+License OK
+
+Testing alloc_gamma_tbl()
+e = 1.0
+it: 0	 value: 0
+it: 2048	 value: 2048
+it: 4096	 value: 4096
+it: 6144	 value: 6144
+it: 8192	 value: 8192
+it: 10240	 value: 10240
+it: 12288	 value: 12288
+it: 14336	 value: 14336
+it: 16384	 value: 16384
+it: 18432	 value: 18432
+it: 20480	 value: 20480
+it: 22528	 value: 22528
+it: 24576	 value: 24576
+it: 26624	 value: 26624
+it: 28672	 value: 28672
+it: 30720	 value: 30720
+it: 32768	 value: 32768
+it: 34816	 value: 34816
+it: 36864	 value: 36864
+it: 38912	 value: 38912
+it: 40960	 value: 40960
+it: 43008	 value: 43008
+it: 45056	 value: 45056
+it: 47104	 value: 47104
+it: 49152	 value: 49152
+it: 51200	 value: 51200
+it: 53248	 value: 53248
+it: 55296	 value: 55296
+it: 57344	 value: 57344
+it: 59392	 value: 59392
+it: 61440	 value: 61440
+it: 63488	 value: 63488
+
+e = 0.75
+it: 0	 value: 0
+it: 2048	 value: 4870
+it: 4096	 value: 8191
+it: 6144	 value: 11103
+it: 8192	 value: 13777
+it: 10240	 value: 16287
+it: 12288	 value: 18673
+it: 14336	 value: 20962
+it: 16384	 value: 23170
+it: 18432	 value: 25310
+it: 20480	 value: 27391
+it: 22528	 value: 29421
+it: 24576	 value: 31405
+it: 26624	 value: 33348
+it: 28672	 value: 35254
+it: 30720	 value: 37126
+it: 32768	 value: 38967
+it: 34816	 value: 40780
+it: 36864	 value: 42566
+it: 38912	 value: 44328
+it: 40960	 value: 46066
+it: 43008	 value: 47783
+it: 45056	 value: 49480
+it: 47104	 value: 51157
+it: 49152	 value: 52817
+it: 51200	 value: 54459
+it: 53248	 value: 56084
+it: 55296	 value: 57695
+it: 57344	 value: 59290
+it: 59392	 value: 60871
+it: 61440	 value: 62439
+it: 63488	 value: 63993
+
+e = 2.8
+it: 0	 value: 0
+it: 2048	 value: 4
+it: 4096	 value: 27
+it: 6144	 value: 86
+it: 8192	 value: 194
+it: 10240	 value: 362
+it: 12288	 value: 603
+it: 14336	 value: 929
+it: 16384	 value: 1351
+it: 18432	 value: 1879
+it: 20480	 value: 2523
+it: 22528	 value: 3295
+it: 24576	 value: 4205
+it: 26624	 value: 5261
+it: 28672	 value: 6474
+it: 30720	 value: 7854
+it: 32768	 value: 9410
+it: 34816	 value: 11151
+it: 36864	 value: 13086
+it: 38912	 value: 15225
+it: 40960	 value: 17577
+it: 43008	 value: 20150
+it: 45056	 value: 22953
+it: 47104	 value: 25996
+it: 49152	 value: 29286
+it: 51200	 value: 32832
+it: 53248	 value: 36643
+it: 55296	 value: 40727
+it: 57344	 value: 45093
+it: 59392	 value: 49749
+it: 61440	 value: 54703
+it: 63488	 value: 59963
-- 
1.9.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel

Reply via email to