[FFmpeg-cvslog] avcodec/tests: added test for celp_math.c

2017-03-24 Thread Thomas Turner
ffmpeg | branch: master | Thomas Turner  | Thu Mar 23 
22:48:28 2017 -0700| [824fe914fee7fb5dc8c8c14940e511cda089c36d] | committer: 
Michael Niedermayer

avcodec/tests: added test for celp_math.c

Signed-off-by: Thomas Turner 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=824fe914fee7fb5dc8c8c14940e511cda089c36d
---

 libavcodec/Makefile  |  1 +
 libavcodec/tests/celp_math.c | 48 
 tests/fate/libavcodec.mak|  5 +
 3 files changed, 54 insertions(+)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 89296cd..05be516 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1024,6 +1024,7 @@ SKIPHEADERS-$(CONFIG_VDPAU)+= vdpau.h 
vdpau_internal.h
 SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vda_vt_internal.h
 
 TESTPROGS = avpacket\
+celp_math   \
 imgconvert  \
 jpeg2000dwt \
 mathops\
diff --git a/libavcodec/tests/celp_math.c b/libavcodec/tests/celp_math.c
new file mode 100644
index 000..4b1c186
--- /dev/null
+++ b/libavcodec/tests/celp_math.c
@@ -0,0 +1,48 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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 "libavutil/libm.h"
+#include "libavcodec/celp_math.c"
+
+int main(void)
+{
+int i;
+const float f1[3]   = {0.0,  1.1,  2.2};
+const float f2[3]   = {3.3,  4.4,  5.5};
+const int16_t i1[3] = {6,  7,  8};
+const int16_t i2[3] = {9, 10, 11};
+float diff, largest, absa, absb;
+
+float   r = ff_dot_productf(f1, f2, FF_ARRAY_ELEMS(f1));
+int64_t d = ff_dot_product(i1, i2, FF_ARRAY_ELEMS(i1));
+
+#   define IsAlmostEqual(A, B, epsilon) \
+diff = fabsf(A - B); \
+absa = fabsf(A); \
+absb = fabsf(B); \
+largest = (absb > absa) ? absb : absa; \
+av_assert0(diff <= largest * epsilon);
+
+IsAlmostEqual(16.94f, r, 0.01f);
+av_assert0(212 == d);
+
+for (i = 1024; i >= 1; i/=2)
+av_assert0(ff_log2_q15(i) == (1<<15)*((int)log2(i))+(1<<2));
+
+return 0;
+}
diff --git a/tests/fate/libavcodec.mak b/tests/fate/libavcodec.mak
index 32b0c1e..07417f0 100644
--- a/tests/fate/libavcodec.mak
+++ b/tests/fate/libavcodec.mak
@@ -8,6 +8,11 @@ fate-cabac: libavcodec/tests/cabac$(EXESUF)
 fate-cabac: CMD = run libavcodec/tests/cabac
 fate-cabac: REF = /dev/null
 
+FATE_LIBAVCODEC-yes += fate-celp_math
+fate-celp_math: libavcodec/tests/celp_math$(EXESUF)
+fate-celp_math: CMD = run libavcodec/tests/celp_math
+fate-celp_math: REF = /dev/null
+
 FATE_LIBAVCODEC-$(CONFIG_GOLOMB) += fate-golomb
 fate-golomb: libavcodec/tests/golomb$(EXESUF)
 fate-golomb: CMD = run libavcodec/tests/golomb

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] tests/fate/filter-video: add owdenoise test

2017-04-03 Thread Thomas Turner
ffmpeg | branch: master | Thomas Turner  | Sun Apr  2 
15:27:57 2017 -0700| [dc1a1b8bd795f5fa6ec3b8f38eb97b8d98ed73fc] | committer: 
Michael Niedermayer

tests/fate/filter-video: add owdenoise test

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=dc1a1b8bd795f5fa6ec3b8f38eb97b8d98ed73fc
---

 tests/fate/filter-video.mak | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index b067cc1..b40422a 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -1,3 +1,10 @@
+FATE_FILTER_SAMPLES-$(call ALLYES, SMJPEG_DEMUXER MJPEG_DECODER PERMS_FILTER 
OWDENOISE_FILTER) += fate-filter-owdenoise-sample
+fate-filter-owdenoise-sample: CMD = ffmpeg -idct simple -i 
$(TARGET_SAMPLES)/smjpeg/scenwin.mjpg -vf 
"trim=duration=0.5,perms=random,owdenoise=10:20:20:enable=not(between(t\,0.2\,1.2))"
 -an -f rawvideo -
+fate-filter-owdenoise-sample: REF = 
$(TARGET_SAMPLES)/filter-reference/owdenoise-scenwin.raw
+fate-filter-owdenoise-sample: CMP_TARGET = 1
+fate-filter-owdenoise-sample: FUZZ = 3539
+fate-filter-owdenoise-sample: CMP = oneoff
+
 FATE_FILTER_SAMPLES-$(call ALLYES, PERMS_FILTER DELOGO_FILTER RM_DEMUXER 
RV30_DECODER) += fate-filter-delogo
 fate-filter-delogo: CMD = framecrc -i $(TARGET_SAMPLES)/real/rv30.rm -vf 
perms=random,delogo=show=0:x=290:y=25:w=26:h=16 -an
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avutil: Improved selftest coverage for libavutil/fifo.c

2016-10-14 Thread Thomas Turner
ffmpeg | branch: master | Thomas Turner  | Thu Oct 13 
15:13:56 2016 -0700| [09d39177dcbea32ef07ce7845511ebafb9cb43fb] | committer: 
Michael Niedermayer

avutil: Improved selftest coverage for libavutil/fifo.c

Tested functions: av_fifo_generic_peek(), av_fifo_grow()

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=09d39177dcbea32ef07ce7845511ebafb9cb43fb
---

 libavutil/tests/fifo.c | 39 +--
 tests/ref/fate/fifo| 43 +++
 2 files changed, 80 insertions(+), 2 deletions(-)

diff --git a/libavutil/tests/fifo.c b/libavutil/tests/fifo.c
index e4d7edf..8a550e0 100644
--- a/libavutil/tests/fifo.c
+++ b/libavutil/tests/fifo.c
@@ -17,14 +17,14 @@
  */
 
 #include 
-
+#include 
 #include "libavutil/fifo.h"
 
 int main(void)
 {
 /* create a FIFO buffer */
 AVFifoBuffer *fifo = av_fifo_alloc(13 * sizeof(int));
-int i, j, n;
+int i, j, n, *p;
 
 /* fill data */
 for (i = 0; av_fifo_space(fifo) >= sizeof(int); i++)
@@ -46,6 +46,24 @@ int main(void)
 }
 printf("\n");
 
+/* generic peek at FIFO */
+
+n = av_fifo_size(fifo);
+p = malloc(n);
+if (p == NULL) {
+fprintf(stderr, "failed to allocate memory.\n");
+exit(1);
+}
+
+(void) av_fifo_generic_peek(fifo, p, n, NULL);
+
+/* read data at p */
+n /= sizeof(int);
+for(i = 0; i < n; ++i)
+printf("%d: %d\n", i, p[i]);
+
+putchar('\n');
+
 /* read data */
 for (i = 0; av_fifo_size(fifo) >= sizeof(int); i++) {
 av_fifo_generic_read(fifo, &j, sizeof(int), NULL);
@@ -67,8 +85,25 @@ int main(void)
 av_fifo_generic_peek_at(fifo, &j, i * sizeof(int), sizeof(j), NULL);
 printf("%d: %d\n", i, j);
 }
+putchar('\n');
+
+/* test fifo_grow */
+(void) av_fifo_grow(fifo, 15 * sizeof(int));
+
+/* fill data */
+n = av_fifo_size(fifo) / sizeof(int);
+for (i = n; av_fifo_space(fifo) >= sizeof(int); ++i)
+av_fifo_generic_write(fifo, &i, sizeof(int), NULL);
+
+/* peek_at at FIFO */
+n = av_fifo_size(fifo) / sizeof(int);
+for (i = 0; i < n; i++) {
+av_fifo_generic_peek_at(fifo, &j, i * sizeof(int), sizeof(j), NULL);
+printf("%d: %d\n", i, j);
+}
 
 av_fifo_free(fifo);
+free(p);
 
 return 0;
 }
diff --git a/tests/ref/fate/fifo b/tests/ref/fate/fifo
index 162d754..2b18ed5 100644
--- a/tests/ref/fate/fifo
+++ b/tests/ref/fate/fifo
@@ -38,6 +38,20 @@
 11: 11
 12: 12
 
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+10: 10
+11: 11
+12: 12
+
 0 1 2 3 4 5 6 7 8 9 10 11 12
 0: 0
 1: 1
@@ -52,3 +66,32 @@
 10: 10
 11: 11
 12: 12
+
+0: 0
+1: 1
+2: 2
+3: 3
+4: 4
+5: 5
+6: 6
+7: 7
+8: 8
+9: 9
+10: 10
+11: 11
+12: 12
+13: 13
+14: 14
+15: 15
+16: 16
+17: 17
+18: 18
+19: 19
+20: 20
+21: 21
+22: 22
+23: 23
+24: 24
+25: 25
+26: 26
+27: 27

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] Added test for libavcodec/avpacket.c

2016-12-06 Thread Thomas Turner
ffmpeg | branch: master | Thomas Turner  | Mon Dec  5 
22:22:41 2016 -0800| [da3c69a5a97d0f8ce6522b9c15f7a2c5027cf572] | committer: 
Michael Niedermayer

Added test for libavcodec/avpacket.c

Signed-off-by: Thomas Turner 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=da3c69a5a97d0f8ce6522b9c15f7a2c5027cf572
---

 libavcodec/Makefile |   3 +-
 libavcodec/tests/avpacket.c | 128 
 tests/fate/libavcodec.mak   |   5 ++
 3 files changed, 135 insertions(+), 1 deletion(-)

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 82f7fa2..6dd294e 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1003,7 +1003,8 @@ SKIPHEADERS-$(CONFIG_VDA)  += vda.h 
vda_vt_internal.h
 SKIPHEADERS-$(CONFIG_VDPAU)+= vdpau.h vdpau_internal.h
 SKIPHEADERS-$(CONFIG_VIDEOTOOLBOX) += videotoolbox.h vda_vt_internal.h
 
-TESTPROGS = imgconvert  \
+TESTPROGS = avpacket\
+imgconvert  \
 jpeg2000dwt \
 mathops\
 options \
diff --git a/libavcodec/tests/avpacket.c b/libavcodec/tests/avpacket.c
new file mode 100644
index 000..90b7234
--- /dev/null
+++ b/libavcodec/tests/avpacket.c
@@ -0,0 +1,128 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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 
+#include 
+#include 
+#include 
+#include "libavcodec/avcodec.h"
+#include "libavutil/error.h"
+
+
+
+static int setup_side_data_entry(AVPacket* avpkt)
+{
+const uint8_t *data_name = NULL;
+int ret = 0, bytes;
+uint8_t *extra_data = NULL;
+
+
+/* get side_data_name string */
+data_name = av_packet_side_data_name(AV_PKT_DATA_NEW_EXTRADATA);
+
+/* Allocate a memory bloc */
+bytes = strlen(data_name);
+
+if(!(extra_data = av_malloc(bytes))){
+ret = AVERROR(ENOMEM);
+fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
+exit(1);
+}
+/* copy side_data_name to extra_data array */
+memcpy(extra_data, data_name, bytes);
+
+/* create side data for AVPacket */
+ret = av_packet_add_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA,
+extra_data, bytes);
+if(ret < 0){
+fprintf(stderr,
+"Error occurred in av_packet_add_side_data: %s\n",
+av_err2str(ret));
+}
+
+return ret;
+}
+
+static int initializations(AVPacket* avpkt)
+{
+const static uint8_t* data = "selftest for av_packet_clone(...)";
+int ret = 0;
+
+/* initialize avpkt */
+av_init_packet(avpkt);
+
+/* set values for avpkt */
+avpkt->pts = 17;
+avpkt->dts = 2;
+avpkt->data = (uint8_t*)data;
+avpkt->size = strlen(data);
+avpkt->flags = AV_PKT_FLAG_DISCARD;
+avpkt->duration = 100;
+avpkt->pos = 3;
+
+ret = setup_side_data_entry(avpkt);
+
+return ret;
+}
+
+int main(void)
+{
+AVPacket avpkt;
+AVPacket *avpkt_clone = NULL;
+int ret = 0;
+
+if(initializations(&avpkt) < 0){
+printf("failed to initialize variables\n");
+return 1;
+}
+/* test av_packet_clone*/
+avpkt_clone = av_packet_clone(&avpkt);
+
+if(!avpkt_clone) {
+av_log(NULL, AV_LOG_ERROR,"av_packet_clone failed to clone 
AVPacket\n");
+return 1;
+}
+/*test av_grow_packet*/
+if(av_grow_packet(avpkt_clone, 20) < 0){
+av_log(NULL, AV_LOG_ERROR, "av_grow_packet failed\n");
+return 1;
+}
+if(av_grow_packet(avpkt_clone, INT_MAX) == 0){
+printf( "av_grow_packet failed to return error "
+"when \"grow_by\" parameter is too large.\n" );
+ret = 1;
+}
+/* test size error check in av_new_packet*/
+if(av_new_packet(avpkt_clone, INT_MAX) == 0){
+printf( "av_new_packet failed 

[FFmpeg-cvslog] avutil: Improved test coverage for avstring.c

2016-12-20 Thread Thomas Turner
ffmpeg | branch: master | Thomas Turner  | Mon Dec 19 
18:44:42 2016 -0800| [e303e3d4b972975640da92cb55b766dad951d90d] | committer: 
Michael Niedermayer

avutil: Improved test coverage for avstring.c

Signed-off-by: Thomas Turner 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e303e3d4b972975640da92cb55b766dad951d90d
---

 libavutil/tests/avstring.c | 26 +-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/libavutil/tests/avstring.c b/libavutil/tests/avstring.c
index 1242b3f..290b170 100644
--- a/libavutil/tests/avstring.c
+++ b/libavutil/tests/avstring.c
@@ -25,7 +25,7 @@
 int main(void)
 {
 int i;
-char *fullpath;
+char *fullpath, *ptr;
 static const char * const strings[] = {
 "''",
 "",
@@ -54,6 +54,8 @@ int main(void)
 "'\\fo\\o:': blahblah",
 "\\'fo\\o\\:':  foo  '  :blahblah"
 };
+const char *haystack = "Education consists mainly in what we have 
unlearned.";
+const char * const needle[] = {"learned.", "unlearned.", "Unlearned"};
 
 printf("Testing av_get_token()\n");
 for (i = 0; i < FF_ARRAY_ELEMS(strings); i++) {
@@ -79,5 +81,27 @@ int main(void)
 TEST_APPEND_PATH_COMPONENT("path", "/comp", "path/comp");
 TEST_APPEND_PATH_COMPONENT("path/", "/comp", "path/comp");
 TEST_APPEND_PATH_COMPONENT("path/path2/", "/comp/comp2", 
"path/path2/comp/comp2");
+
+/*Testing av_strnstr()*/
+#define TEST_STRNSTR(haystack, needle, hay_length, expected) \
+ptr = av_strnstr(haystack, needle, hay_length); \
+if (ptr != expected){ \
+printf("expected: %p, received %p\n", expected, ptr); \
+}
+TEST_STRNSTR(haystack, needle [0], strlen(haystack), haystack+44);
+TEST_STRNSTR(haystack, needle [1], strlen(haystack), haystack+42);
+TEST_STRNSTR(haystack, needle [2], strlen(haystack), NULL   );
+TEST_STRNSTR(haystack, strings[1], strlen(haystack), haystack   );
+
+/*Testing av_d2str()*/
+#define TEST_D2STR(value, expected) \
+if((ptr = av_d2str(value)) == NULL){ \
+printf("error, received null pointer!\n"); \
+} else if(strcmp(ptr, expected) != 0){ \
+printf( "expected: %s, received: %s\n", expected, ptr); \
+}
+TEST_D2STR(0 ,  "0.00");
+TEST_D2STR(-1.2333234, "-1.233323");
+TEST_D2STR(-1.2333237, "-1.233324");
 return 0;
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avutil: Added selftest for libavutil/audio_fifo.c

2016-12-20 Thread Thomas Turner
ffmpeg | branch: master | Thomas Turner  | Tue Dec 20 
16:53:51 2016 -0800| [9f76ad2a46439b93fd74b12cd50af0ea5100358a] | committer: 
Michael Niedermayer

avutil: Added selftest for libavutil/audio_fifo.c

Signed-off-by: Thomas Turner 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9f76ad2a46439b93fd74b12cd50af0ea5100358a
---

 libavutil/Makefile   |   1 +
 libavutil/tests/audio_fifo.c | 196 +
 tests/fate/libavutil.mak |   4 +
 tests/ref/fate/audio_fifo| 228 +++
 4 files changed, 429 insertions(+)

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 9841645..2dd91b8 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -182,6 +182,7 @@ SKIPHEADERS-$(CONFIG_OPENCL)   += opencl.h
 TESTPROGS = adler32 \
 aes \
 atomic  \
+audio_fifo  \
 avstring\
 base64  \
 blowfish\
diff --git a/libavutil/tests/audio_fifo.c b/libavutil/tests/audio_fifo.c
new file mode 100644
index 000..dbadded
--- /dev/null
+++ b/libavutil/tests/audio_fifo.c
@@ -0,0 +1,196 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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 
+#include 
+#include 
+#include "libavutil/audio_fifo.c"
+
+#define MAX_CHANNELS32
+
+
+typedef struct TestStruct {
+const enum AVSampleFormat format;
+const int nb_ch;
+void const *data_planes[MAX_CHANNELS];
+int nb_samples_pch;
+} TestStruct;
+
+static const uint8_t data_U8 [] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
};
+static const int16_t data_S16[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
};
+static const float   data_FLT[] = {0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 
8.0, 9.0, 10.0, 11.0};
+
+static const TestStruct test_struct[] = {
+{.format = AV_SAMPLE_FMT_U8   , .nb_ch = 1, .data_planes = {data_U8 ,  
   }, .nb_samples_pch = 12},
+{.format = AV_SAMPLE_FMT_U8P  , .nb_ch = 2, .data_planes = {data_U8 , 
data_U8 +6, }, .nb_samples_pch = 6 },
+{.format = AV_SAMPLE_FMT_S16  , .nb_ch = 1, .data_planes = {data_S16,  
   }, .nb_samples_pch = 12},
+{.format = AV_SAMPLE_FMT_S16P , .nb_ch = 2, .data_planes = {data_S16, 
data_S16+6, }, .nb_samples_pch = 6 },
+{.format = AV_SAMPLE_FMT_FLT  , .nb_ch = 1, .data_planes = {data_FLT,  
   }, .nb_samples_pch = 12},
+{.format = AV_SAMPLE_FMT_FLTP , .nb_ch = 2, .data_planes = {data_FLT, 
data_FLT+6, }, .nb_samples_pch = 6 }
+};
+
+static void ERROR(const char *str)
+{
+fprintf(stderr, "%s\n", str);
+exit(1);
+}
+
+static void* allocate_memory(size_t size)
+{
+void *ptr = malloc(size);
+if (ptr == NULL){
+ERROR("failed to allocate memory!");
+}
+return ptr;
+}
+
+static void print_audio_bytes(const TestStruct *test_sample, void 
**data_planes, int nb_samples)
+{
+int p, b, f;
+int byte_offset  = av_get_bytes_per_sample(test_sample->format);
+int buffers  = av_sample_fmt_is_planar(test_sample->format)
+ ? test_sample->nb_ch : 1;
+int line_size= (buffers > 1) ? nb_samples * byte_offset
+ : nb_samples * byte_offset * 
test_sample->nb_ch;
+for (p = 0; p < buffers; ++p){
+for(b = 0; b < line_size; b+=byte_offset){
+for (f = 0; f < byte_offset; f++){
+int order = !HAVE_BIGENDIAN ? (byte_offset - f - 1) : f;
+printf("%02x", *((uint8_t*)data_planes[p] + b + order));
+}
+putchar(' ');
+}
+putchar('\n');
+}
+}
+
+static int read_samples_from_audio_fifo(AVAudioFifo* afifo, void ***output, 
int nb_samples)
+{
+

[FFmpeg-cvslog] avutil/tests: Improved code coverage for random_seed

2016-12-22 Thread Thomas Turner
ffmpeg | branch: master | Thomas Turner  | Thu Dec 22 
16:12:36 2016 -0800| [8dcb28cf6dd1c68810e7aa857bb6f2a778bef4de] | committer: 
Michael Niedermayer

avutil/tests: Improved code coverage for random_seed

Signed-off-by: Thomas Turner 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8dcb28cf6dd1c68810e7aa857bb6f2a778bef4de
---

 libavutil/tests/random_seed.c | 34 +-
 tests/ref/fate/random_seed|  1 +
 2 files changed, 22 insertions(+), 13 deletions(-)

diff --git a/libavutil/tests/random_seed.c b/libavutil/tests/random_seed.c
index ebe9b3e..f45e198 100644
--- a/libavutil/tests/random_seed.c
+++ b/libavutil/tests/random_seed.c
@@ -23,24 +23,32 @@
 
 #undef printf
 #define N 256
+#define F 2
 #include 
 
+typedef uint32_t (*random_seed_ptr_t)(void);
+
 int main(void)
 {
-int i, j, retry;
+int i, j, rsf, retry;
 uint32_t seeds[N];
+random_seed_ptr_t random_seed[F] = {av_get_random_seed, get_generic_seed};
 
-for (retry=0; retry<3; retry++){
-for (i=0; ihttp://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avutil/tests/audio_fifo.c: Corrected test error messages

2016-12-28 Thread Thomas Turner
ffmpeg | branch: master | Thomas Turner  | Tue Dec 27 
18:43:20 2016 -0800| [d7a3c7427f95bd1ad7e6aa36e23d6d048596a717] | committer: 
Michael Niedermayer

avutil/tests/audio_fifo.c: Corrected test error messages

Signed-off-by: Thomas Turner 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d7a3c7427f95bd1ad7e6aa36e23d6d048596a717
---

 libavutil/tests/audio_fifo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavutil/tests/audio_fifo.c b/libavutil/tests/audio_fifo.c
index 34c8573..381f709 100644
--- a/libavutil/tests/audio_fifo.c
+++ b/libavutil/tests/audio_fifo.c
@@ -140,7 +140,7 @@ static void test_function(const TestStruct test_sample)
 
 ret = read_samples_from_audio_fifo(afifo, &output_data, 
test_sample.nb_samples_pch);
 if (ret < 0){
-ERROR("ERROR: av_audio_fifo_write failed!");
+ERROR("ERROR: av_audio_fifo_read failed!");
 }
 printf("read: %d\n", ret);
 print_audio_bytes(&test_sample, output_data, ret);
@@ -160,7 +160,7 @@ static void test_function(const TestStruct test_sample)
 for (i = 0; i < afifo->nb_samples; ++i){
 ret = av_audio_fifo_peek_at(afifo, output_data, 1, i);
 if (ret < 0){
-ERROR("ERROR: av_audio_fifo_peek failed!");
+ERROR("ERROR: av_audio_fifo_peek_at failed!");
 }
 printf("%d:\n", i);
 print_audio_bytes(&test_sample, output_data, ret);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avutil/tests/audio_fifo.c: Memory leak and tab space fixes

2016-12-31 Thread Thomas Turner
ffmpeg | branch: master | Thomas Turner  | Tue Dec 27 
18:43:19 2016 -0800| [1bfb4587a2e5b25ed15f742149e555efc8f305ae] | committer: 
Michael Niedermayer

avutil/tests/audio_fifo.c: Memory leak and tab space fixes

Prevents memory leak when read_samples_from_audio_fifo() is
called more than once by deallocating before reallocating
more memory.

Fixes space indentation for contents in ERROR().

Signed-off-by: Thomas Turner 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=1bfb4587a2e5b25ed15f742149e555efc8f305ae
---

 libavutil/tests/audio_fifo.c | 20 ++--
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/libavutil/tests/audio_fifo.c b/libavutil/tests/audio_fifo.c
index 4a82a50..861cebb 100644
--- a/libavutil/tests/audio_fifo.c
+++ b/libavutil/tests/audio_fifo.c
@@ -45,10 +45,19 @@ static const TestStruct test_struct[] = {
 {.format = AV_SAMPLE_FMT_FLTP , .nb_ch = 2, .data_planes = {data_FLT, 
data_FLT+6, }, .nb_samples_pch = 6 }
 };
 
+static void free_data_planes(AVAudioFifo *afifo, void **output_data)
+{
+int i;
+for (i = 0; i < afifo->nb_buffers; ++i){
+av_freep(&output_data[i]);
+}
+av_freep(&output_data);
+}
+
 static void ERROR(const char *str)
 {
-fprintf(stderr, "%s\n", str);
-exit(1);
+fprintf(stderr, "%s\n", str);
+exit(1);
 }
 
 static void print_audio_bytes(const TestStruct *test_sample, void 
**data_planes, int nb_samples)
@@ -80,6 +89,8 @@ static int read_samples_from_audio_fifo(AVAudioFifo* afifo, 
void ***output, int
 void **data_planes = av_malloc_array(afifo->nb_buffers, sizeof(void*));
 if (!data_planes)
 ERROR("failed to allocate memory!");
+if (*output)
+free_data_planes(afifo, *output);
 *output= data_planes;
 
 for (i = 0; i < afifo->nb_buffers; ++i){
@@ -173,10 +184,7 @@ static void test_function(const TestStruct test_sample)
 }
 
 /* deallocate */
-for (i = 0; i < afifo->nb_buffers; ++i){
-av_freep(&output_data[i]);
-}
-av_freep(&output_data);
+free_data_planes(afifo, output_data);
 av_audio_fifo_free(afifo);
 }
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avutil/tests/audio_fifo.c: use av_malloc() family of functions

2016-12-31 Thread Thomas Turner
ffmpeg | branch: master | Thomas Turner  | Tue Dec 27 
18:43:18 2016 -0800| [11b7cad3dc1797ed76725ba3cfba2df1a987eec7] | committer: 
Michael Niedermayer

avutil/tests/audio_fifo.c: use av_malloc() family of functions

Signed-off-by: Thomas Turner 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=11b7cad3dc1797ed76725ba3cfba2df1a987eec7
---

 libavutil/tests/audio_fifo.c | 22 +-
 1 file changed, 9 insertions(+), 13 deletions(-)

diff --git a/libavutil/tests/audio_fifo.c b/libavutil/tests/audio_fifo.c
index 381f709..4a82a50 100644
--- a/libavutil/tests/audio_fifo.c
+++ b/libavutil/tests/audio_fifo.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include "libavutil/mem.h"
 #include "libavutil/audio_fifo.c"
 
 #define MAX_CHANNELS32
@@ -50,15 +51,6 @@ static void ERROR(const char *str)
 exit(1);
 }
 
-static void* allocate_memory(size_t size)
-{
-void *ptr = malloc(size);
-if (ptr == NULL){
-ERROR("failed to allocate memory!");
-}
-return ptr;
-}
-
 static void print_audio_bytes(const TestStruct *test_sample, void 
**data_planes, int nb_samples)
 {
 int p, b, f;
@@ -85,11 +77,15 @@ static int read_samples_from_audio_fifo(AVAudioFifo* afifo, 
void ***output, int
 int samples= FFMIN(nb_samples, afifo->nb_samples);
 int tot_elements   = !av_sample_fmt_is_planar(afifo->sample_fmt)
  ? samples : afifo->channels * samples;
-void **data_planes = allocate_memory(sizeof(void*) * afifo->nb_buffers);
+void **data_planes = av_malloc_array(afifo->nb_buffers, sizeof(void*));
+if (!data_planes)
+ERROR("failed to allocate memory!");
 *output= data_planes;
 
 for (i = 0; i < afifo->nb_buffers; ++i){
-data_planes[i] = allocate_memory(afifo->sample_size * tot_elements);
+data_planes[i] = av_malloc_array(tot_elements, afifo->sample_size);
+if (!data_planes[i])
+ERROR("failed to allocate memory!");
 }
 
 return av_audio_fifo_read(afifo, *output, nb_samples);
@@ -178,9 +174,9 @@ static void test_function(const TestStruct test_sample)
 
 /* deallocate */
 for (i = 0; i < afifo->nb_buffers; ++i){
-free(output_data[i]);
+av_freep(&output_data[i]);
 }
-free(output_data);
+av_freep(&output_data);
 av_audio_fifo_free(afifo);
 }
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avutil/tests: improved code coverage for atomic

2017-01-01 Thread Thomas Turner
ffmpeg | branch: master | Thomas Turner  | Sat Dec 31 
20:42:40 2016 -0800| [b7a6d28e5e7ae4dff7c53a2f24e2017220dd6cc1] | committer: 
Michael Niedermayer

avutil/tests: improved code coverage for atomic

Signed-off-by: Thomas Turner 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b7a6d28e5e7ae4dff7c53a2f24e2017220dd6cc1
---

 libavutil/tests/atomic.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavutil/tests/atomic.c b/libavutil/tests/atomic.c
index c92f220..e41bf5a 100644
--- a/libavutil/tests/atomic.c
+++ b/libavutil/tests/atomic.c
@@ -21,7 +21,9 @@
 
 int main(void)
 {
-volatile int val = 1;
+volatile int val  = 1;
+void *tmp1= (int *)&val;
+void * volatile *tmp2 = &tmp1;
 int res;
 
 res = avpriv_atomic_int_add_and_fetch(&val, 1);
@@ -29,6 +31,8 @@ int main(void)
 avpriv_atomic_int_set(&val, 3);
 res = avpriv_atomic_int_get(&val);
 av_assert0(res == 3);
+avpriv_atomic_ptr_cas(tmp2, tmp1, &res);
+av_assert0(*tmp2 == &res);
 
 return 0;
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avutil/tests: added selftest for aes_ctr.c

2017-01-01 Thread Thomas Turner
ffmpeg | branch: master | Thomas Turner  | Sun Jan  1 
12:17:58 2017 -0800| [3126ca28251538907401918a27e7f2177fc1d4b0] | committer: 
Michael Niedermayer

avutil/tests: added selftest for aes_ctr.c

Signed-off-by: Thomas Turner 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3126ca28251538907401918a27e7f2177fc1d4b0
---

 libavutil/Makefile|  1 +
 libavutil/tests/aes_ctr.c | 65 +++
 tests/fate/libavutil.mak  |  5 
 3 files changed, 71 insertions(+)

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 2dd91b8..15d95de 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -181,6 +181,7 @@ SKIPHEADERS-$(CONFIG_OPENCL)   += opencl.h
 
 TESTPROGS = adler32 \
 aes \
+aes_ctr \
 atomic  \
 audio_fifo  \
 avstring\
diff --git a/libavutil/tests/aes_ctr.c b/libavutil/tests/aes_ctr.c
new file mode 100644
index 000..c5ebeda
--- /dev/null
+++ b/libavutil/tests/aes_ctr.c
@@ -0,0 +1,65 @@
+/*
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser 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 "libavutil/log.h"
+#include "libavutil/mem.h"
+#include "libavutil/aes_ctr.h"
+
+static const DECLARE_ALIGNED(8, uint8_t, plain)[] = {
+0x6d, 0x6f, 0x73, 0x74, 0x20, 0x72, 0x61, 0x6e, 0x64, 0x6f, 0x6d
+};
+static DECLARE_ALIGNED(8, uint8_t, tmp)[11];
+
+int main (void)
+{
+int ret = 1;
+struct AVAESCTR *ae, *ad;
+const uint8_t *iv;
+
+ae = av_aes_ctr_alloc();
+ad = av_aes_ctr_alloc();
+
+if (!ae || !ad)
+goto ERROR;
+
+if (av_aes_ctr_init(ae, (const uint8_t*)"0123456789abcdef") < 0)
+goto ERROR;
+
+if (av_aes_ctr_init(ad, (const uint8_t*)"0123456789abcdef") < 0)
+goto ERROR;
+
+av_aes_ctr_set_random_iv(ae);
+iv =   av_aes_ctr_get_iv(ae);
+av_aes_ctr_set_iv(ad, iv);
+
+av_aes_ctr_crypt(ae, tmp, plain, sizeof(tmp));
+av_aes_ctr_crypt(ad, tmp, tmp,   sizeof(tmp));
+
+if (memcmp(tmp, plain, sizeof(tmp)) != 0){
+av_log(NULL, AV_LOG_ERROR, "test failed\n");
+goto ERROR;
+}
+
+av_log(NULL, AV_LOG_INFO, "test passed\n");
+ret = 0;
+
+ERROR:
+av_aes_ctr_free(ae);
+av_aes_ctr_free(ad);
+return ret;
+}
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index 5987a83..a7bf739 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -8,6 +8,11 @@ fate-aes: libavutil/tests/aes$(EXESUF)
 fate-aes: CMD = run libavutil/tests/aes
 fate-aes: REF = /dev/null
 
+FATE_LIBAVUTIL += fate-aes_ctr
+fate-aes_ctr: libavutil/tests/aes_ctr$(EXESUF)
+fate-aes_ctr: CMD = run libavutil/tests/aes_ctr
+fate-aes_ctr: REF = /dev/null
+
 FATE_LIBAVUTIL += fate-camellia
 fate-camellia: libavutil/tests/camellia$(EXESUF)
 fate-camellia: CMD = run libavutil/tests/camellia

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avutil/tests/audio_fifo.c: pass by reference for efficiency and change datatype to const

2017-01-12 Thread Thomas Turner
ffmpeg | branch: master | Thomas Turner  | Wed Jan 11 
17:20:30 2017 -0800| [08fdf965c9a176d90cae8232d6e3ac54c5d5c7dd] | committer: 
Michael Niedermayer

avutil/tests/audio_fifo.c: pass by reference for efficiency and change datatype 
to const

Signed-off-by: Thomas Turner 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=08fdf965c9a176d90cae8232d6e3ac54c5d5c7dd
---

 libavutil/tests/audio_fifo.c | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/libavutil/tests/audio_fifo.c b/libavutil/tests/audio_fifo.c
index 861cebb..e107166 100644
--- a/libavutil/tests/audio_fifo.c
+++ b/libavutil/tests/audio_fifo.c
@@ -29,7 +29,7 @@ typedef struct TestStruct {
 const enum AVSampleFormat format;
 const int nb_ch;
 void const *data_planes[MAX_CHANNELS];
-int nb_samples_pch;
+const int nb_samples_pch;
 } TestStruct;
 
 static const uint8_t data_U8 [] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11
};
@@ -102,55 +102,55 @@ static int read_samples_from_audio_fifo(AVAudioFifo* 
afifo, void ***output, int
 return av_audio_fifo_read(afifo, *output, nb_samples);
 }
 
-static int write_samples_to_audio_fifo(AVAudioFifo* afifo, const TestStruct 
test_sample,
+static int write_samples_to_audio_fifo(AVAudioFifo* afifo, const TestStruct 
*test_sample,
int nb_samples, int offset)
 {
 int offset_size, i;
 void *data_planes[MAX_CHANNELS];
 
-if(nb_samples > test_sample.nb_samples_pch - offset){
+if(nb_samples > test_sample->nb_samples_pch - offset){
 return 0;
 }
-if(offset >= test_sample.nb_samples_pch){
+if(offset >= test_sample->nb_samples_pch){
 return 0;
 }
 offset_size  = offset * afifo->sample_size;
 
 for (i = 0; i < afifo->nb_buffers ; ++i){
-data_planes[i] = (uint8_t*)test_sample.data_planes[i] + offset_size;
+data_planes[i] = (uint8_t*)test_sample->data_planes[i] + offset_size;
 }
 
 return av_audio_fifo_write(afifo, data_planes, nb_samples);
 }
 
-static void test_function(const TestStruct test_sample)
+static void test_function(const TestStruct *test_sample)
 {
 int ret, i;
 void **output_data  = NULL;
-AVAudioFifo *afifo  = av_audio_fifo_alloc(test_sample.format, 
test_sample.nb_ch,
-test_sample.nb_samples_pch);
+AVAudioFifo *afifo  = av_audio_fifo_alloc(test_sample->format, 
test_sample->nb_ch,
+test_sample->nb_samples_pch);
 if (!afifo) {
 ERROR("ERROR: av_audio_fifo_alloc returned NULL!");
 }
-ret = write_samples_to_audio_fifo(afifo, test_sample, 
test_sample.nb_samples_pch, 0);
+ret = write_samples_to_audio_fifo(afifo, test_sample, 
test_sample->nb_samples_pch, 0);
 if (ret < 0){
 ERROR("ERROR: av_audio_fifo_write failed!");
 }
 printf("written: %d\n", ret);
 
-ret = write_samples_to_audio_fifo(afifo, test_sample, 
test_sample.nb_samples_pch, 0);
+ret = write_samples_to_audio_fifo(afifo, test_sample, 
test_sample->nb_samples_pch, 0);
 if (ret < 0){
 ERROR("ERROR: av_audio_fifo_write failed!");
 }
 printf("written: %d\n", ret);
 printf("remaining samples in audio_fifo: %d\n\n", 
av_audio_fifo_size(afifo));
 
-ret = read_samples_from_audio_fifo(afifo, &output_data, 
test_sample.nb_samples_pch);
+ret = read_samples_from_audio_fifo(afifo, &output_data, 
test_sample->nb_samples_pch);
 if (ret < 0){
 ERROR("ERROR: av_audio_fifo_read failed!");
 }
 printf("read: %d\n", ret);
-print_audio_bytes(&test_sample, output_data, ret);
+print_audio_bytes(test_sample, output_data, ret);
 printf("remaining samples in audio_fifo: %d\n\n", 
av_audio_fifo_size(afifo));
 
 /* test av_audio_fifo_peek */
@@ -159,7 +159,7 @@ static void test_function(const TestStruct test_sample)
 ERROR("ERROR: av_audio_fifo_peek failed!");
 }
 printf("peek:\n");
-print_audio_bytes(&test_sample, output_data, ret);
+print_audio_bytes(test_sample, output_data, ret);
 printf("\n");
 
 /* test av_audio_fifo_peek_at */
@@ -170,7 +170,7 @@ static void test_function(const TestStruct test_sample)
 ERROR("ERROR: av_audio_fifo_peek_at failed!");
 }
 printf("%d:\n", i);
-print_audio_bytes(&test_sample, output_data, ret);
+print_audio_bytes(test_sample, output_data, ret);
 }
 printf("\n");
 
@@ -194,7 +194,7 @@ int main(void)
 
 for (t = 0; t < tests; ++t){
 printf("\nTEST: %d\n\n", t+1);
-test_function(test_struct[t]);
+test_function(&test_struct[t]);
 }
 return 0;
 }

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avutil/tests/lfg.c: added proper normality test

2017-03-08 Thread Thomas Turner
ffmpeg | branch: master | Thomas Turner  | Tue Mar  7 
16:36:15 2017 -0800| [a50ccbd240a958c32078352021b677c5476d734e] | committer: 
Michael Niedermayer

avutil/tests/lfg.c: added proper normality test

The Chen-Shapiro(CS) test was used to test normality for
Lagged Fibonacci PRNG.

Normality Hypothesis Test:

The null hypothesis formally tests if the population
the sample represents is normally-distributed. For
CS, when the normality hypothesis is True, the
distribution of QH will have a mean close to 1.

Information on CS can be found here:

http://www.stata-journal.com/sjpdf.html?articlenum=st0264
http://www.originlab.com/doc/Origin-Help/NormalityTest-Algorithm

Signed-off-by: Thomas Turner 
Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=a50ccbd240a958c32078352021b677c5476d734e
---

 libavutil/tests/lfg.c|  164 +++-
 tests/fate/libavutil.mak |4 +
 tests/ref/fate/lfg   | 1007 ++
 3 files changed, 1153 insertions(+), 22 deletions(-)

diff --git a/libavutil/tests/lfg.c b/libavutil/tests/lfg.c
index 1425e02..9e908d2 100644
--- a/libavutil/tests/lfg.c
+++ b/libavutil/tests/lfg.c
@@ -20,6 +20,85 @@
 #include "libavutil/timer.h"
 #include "libavutil/lfg.h"
 
+static const double Z_TABLE[31][10] = {
+{0.5000,  0.5040,  0.5080,  0.5120,  0.5160,  0.5199,  0.5239,  0.5279,  
0.5319,  0.5359},
+{0.5398,  0.5438,  0.5478,  0.5517,  0.5557,  0.5596,  0.5636,  0.5675,  
0.5714,  0.5753},
+{0.5793,  0.5832,  0.5871,  0.5910,  0.5948,  0.5987,  0.6026,  0.6064,  
0.6103,  0.6141},
+{0.6179,  0.6217,  0.6255,  0.6293,  0.6331,  0.6368,  0.6406,  0.6443,  
0.6480,  0.6517},
+{0.6554,  0.6591,  0.6628,  0.6664,  0.6700,  0.6736,  0.6772,  0.6808,  
0.6844,  0.6879},
+{0.6915,  0.6950,  0.6985,  0.7019,  0.7054,  0.7088,  0.7123,  0.7157,  
0.7190,  0.7224},
+{0.7257,  0.7291,  0.7324,  0.7357,  0.7389,  0.7422,  0.7454,  0.7486,  
0.7517,  0.7549},
+{0.7580,  0.7611,  0.7642,  0.7673,  0.7704,  0.7734,  0.7764,  0.7794,  
0.7823,  0.7852},
+{0.7881,  0.7910,  0.7939,  0.7967,  0.7995,  0.8023,  0.8051,  0.8078,  
0.8106,  0.8133},
+{0.8159,  0.8186,  0.8212,  0.8238,  0.8264,  0.8289,  0.8315,  0.8340,  
0.8365,  0.8389},
+{0.8413,  0.8438,  0.8461,  0.8485,  0.8508,  0.8531,  0.8554,  0.8577,  
0.8599,  0.8621},
+{0.8643,  0.8665,  0.8686,  0.8708,  0.8729,  0.8749,  0.8770,  0.8790,  
0.8810,  0.8830},
+{0.8849,  0.8869,  0.,  0.8907,  0.8925,  0.8944,  0.8962,  0.8980,  
0.8997,  0.9015},
+{0.9032,  0.9049,  0.9066,  0.9082,  0.9099,  0.9115,  0.9131,  0.9147,  
0.9162,  0.9177},
+{0.9192,  0.9207,  0.9222,  0.9236,  0.9251,  0.9265,  0.9279,  0.9292,  
0.9306,  0.9319},
+{0.9332,  0.9345,  0.9357,  0.9370,  0.9382,  0.9394,  0.9406,  0.9418,  
0.9429,  0.9441},
+{0.9452,  0.9463,  0.9474,  0.9484,  0.9495,  0.9505,  0.9515,  0.9525,  
0.9535,  0.9545},
+{0.9554,  0.9564,  0.9573,  0.9582,  0.9591,  0.9599,  0.9608,  0.9616,  
0.9625,  0.9633},
+{0.9641,  0.9649,  0.9656,  0.9664,  0.9671,  0.9678,  0.9686,  0.9693,  
0.9699,  0.9706},
+{0.9713,  0.9719,  0.9726,  0.9732,  0.9738,  0.9744,  0.9750,  0.9756,  
0.9761,  0.9767},
+{0.9772,  0.9778,  0.9783,  0.9788,  0.9793,  0.9798,  0.9803,  0.9808,  
0.9812,  0.9817},
+{0.9821,  0.9826,  0.9830,  0.9834,  0.9838,  0.9842,  0.9846,  0.9850,  
0.9854,  0.9857},
+{0.9861,  0.9864,  0.9868,  0.9871,  0.9875,  0.9878,  0.9881,  0.9884,  
0.9887,  0.9890},
+{0.9893,  0.9896,  0.9898,  0.9901,  0.9904,  0.9906,  0.9909,  0.9911,  
0.9913,  0.9916},
+{0.9918,  0.9920,  0.9922,  0.9925,  0.9927,  0.9929,  0.9931,  0.9932,  
0.9934,  0.9936},
+{0.9938,  0.9940,  0.9941,  0.9943,  0.9945,  0.9946,  0.9948,  0.9949,  
0.9951,  0.9952},
+{0.9953,  0.9955,  0.9956,  0.9957,  0.9959,  0.9960,  0.9961,  0.9962,  
0.9963,  0.9964},
+{0.9965,  0.9966,  0.9967,  0.9968,  0.9969,  0.9970,  0.9971,  0.9972,  
0.9973,  0.9974},
+{0.9974,  0.9975,  0.9976,  0.9977,  0.9977,  0.9978,  0.9979,  0.9979,  
0.9980,  0.9981},
+{0.9981,  0.9982,  0.9982,  0.9983,  0.9984,  0.9984,  0.9985,  0.9985,  
0.9986,  0.9986},
+{0.9987,  0.9987,  0.9987,  0.9988,  0.9988,  0.9989,  0.9989,  0.9989,  
0.9990,  0.9990} };
+
+// Inverse cumulative distribution function
+static double inv_cdf(double u)
+{
+const double a[4] = { 2.50662823884,
+ -18.61500062529,
+  41.39119773534,
+ -25.44106049637};
+
+const double b[4] = {-8.47351093090,
+  23.08336743743,
+ -21.06224101826,
+   3.13082909833};
+
+const double c[9] = {0.3374754822726147,
+  0.9761690190917186,
+  0.1607979714918209,
+  0.0276438810333863,
+