Re: [FFmpeg-devel] [PATCH] fate: add owdenoise test

2017-04-03 Thread Thomas Turner
On Apr 2, 2017 5:21 PM, "Michael Niedermayer" <mich...@niedermayer.cc>
wrote:

On Sun, Apr 02, 2017 at 03:27:57PM -0700, Thomas Turner wrote:
> Reference found at: http://bit.ly/2ogQygb
>
> Signed-off-by: Thomas Turner <thomas...@googlemail.com>
> ---
>  tests/fate/filter-video.mak | 7 +++
>  1 file changed, 7 insertions(+)

reference file uploaded
test passes on linux 32/64 x86, mingw 32/64, mips qemu

will apply patch in a day (please remind me) so the reference file
has been synced between fate clients

reminder


[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Its not that you shouldnt use gotos but rather that you should write
readable code and code with gotos often but not always is less readable

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


[FFmpeg-devel] [PATCH] fate: add owdenoise test

2017-04-02 Thread Thomas Turner
Reference found at: http://bit.ly/2ogQygb

Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 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
 
-- 
1.9.1

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


Re: [FFmpeg-devel] [PATCH] fate: add owdenoise test

2017-04-02 Thread Thomas Turner
it works, i'll send in patch with smaller reference

On Sun, Apr 2, 2017 at 2:56 PM, Michael Niedermayer <mich...@niedermayer.cc>
wrote:

> On Sun, Apr 02, 2017 at 02:09:20PM -0700, Thomas Turner wrote:
> > On Fri, Mar 31, 2017 at 2:49 AM, Michael Niedermayer
> <mich...@niedermayer.cc
> > > wrote:
> >
> > > On Thu, Mar 30, 2017 at 07:14:42PM -0700, Thomas Turner wrote:
> > > > Reference found at: http://bit.ly/2ogQygb
> > > >
> > > > Signed-off-by: Thomas Turner <thomas...@googlemail.com>
> > > > ---
> > > >  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..a154dd2 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=1,perms=random,
> > > owdenoise=10:20:20:enable=not(between(t\,2\,3))" -an -f rawvideo -
> > >
> > > if i change this to
> > > enable=not(between(t\,4\,5))
> > >
> > it still passes, so this part of the filter is not tested
> > > thats likely because of the duration being 1, the enable part needs
> > > to be within the duration
> > >
> > > Okay, will send in patch with updated reference file. Though, the
> > reference file will be approx. 3MB
>
> you can use values less than 1 in not(between(t\,2\,3))
> like 0.2
>
> That way it should work with a smaller reference
> i didnt try though, please tell me if it does not work
>
> thx
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Complexity theory is the science of finding the exact solution to an
> approximation. Benchmarking OTOH is finding an approximation of the exact
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] fate: add owdenoise test

2017-04-02 Thread Thomas Turner
Reference found at: http://bit.ly/2ogQygb

Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 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..b4661c1 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=3,perms=random,owdenoise=10:20:20:enable=not(between(t\,2\,3))" 
-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
 
-- 
1.9.1

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


Re: [FFmpeg-devel] [PATCH] fate: add owdenoise test

2017-04-02 Thread Thomas Turner
On Fri, Mar 31, 2017 at 2:49 AM, Michael Niedermayer <mich...@niedermayer.cc
> wrote:

> On Thu, Mar 30, 2017 at 07:14:42PM -0700, Thomas Turner wrote:
> > Reference found at: http://bit.ly/2ogQygb
> >
> > Signed-off-by: Thomas Turner <thomas...@googlemail.com>
> > ---
> >  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..a154dd2 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=1,perms=random,
> owdenoise=10:20:20:enable=not(between(t\,2\,3))" -an -f rawvideo -
>
> if i change this to
> enable=not(between(t\,4\,5))
>
it still passes, so this part of the filter is not tested
> thats likely because of the duration being 1, the enable part needs
> to be within the duration
>
> Okay, will send in patch with updated reference file. Though, the
reference file will be approx. 3MB

>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Complexity theory is the science of finding the exact solution to an
> approximation. Benchmarking OTOH is finding an approximation of the exact
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] fate: add owdenoise test

2017-03-30 Thread Thomas Turner
Reference found at: http://bit.ly/2ogQygb

Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 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..a154dd2 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=1,perms=random,owdenoise=10:20:20:enable=not(between(t\,2\,3))" 
-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
 
-- 
1.9.1

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


[FFmpeg-devel] [PATCH] fate: add owdenoise test

2017-03-29 Thread Thomas Turner
Reference file location:

https://www.dropbox.com/s/zeq3wyqbjkvy8ny/filter-owdenoise-sample?dl=0

Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 tests/fate/filter-video.mak | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/tests/fate/filter-video.mak b/tests/fate/filter-video.mak
index b067cc1..db1e9cb 100644
--- a/tests/fate/filter-video.mak
+++ b/tests/fate/filter-video.mak
@@ -1,3 +1,9 @@
+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=1,perms=random,owdenoise=10:20:20:enable=not(between(t\,2\,3))" 
-an -vcodec rawvideo -f nut -
+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
 
-- 
1.9.1

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


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

2017-03-23 Thread Thomas Turner
Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 libavcodec/Makefile  |  1 +
 libavcodec/tests/celp_math.c | 48 
 tests/fate/libavcodec.mak|  5 +
 3 files changed, 54 insertions(+)
 create mode 100644 libavcodec/tests/celp_math.c

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..da7846f
--- /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
-- 
1.9.1

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


Re: [FFmpeg-devel] [PATCH] avcodec/tests: added test for celp_math.c

2017-03-23 Thread Thomas Turner
On Thu, Mar 23, 2017 at 6:34 AM, Michael Niedermayer <mich...@niedermayer.cc
> wrote:

>
> On Thu, Mar 23, 2017 at 02:18:53AM -0700, Thomas Turner wrote:
> > Signed-off-by: Thomas Turner <thomas...@googlemail.com>
> > ---
> >  libavcodec/Makefile  |  1 +
> >  libavcodec/tests/celp_math.c | 22 ++
> >  tests/fate/libavcodec.mak|  5 +
> >  3 files changed, 28 insertions(+)
> >  create mode 100644 libavcodec/tests/celp_math.c
> >
> > diff --git a/libavcodec/Makefile b/libavcodec/Makefile
> > index b8d7a00..eae7b8e 100644
> > --- a/libavcodec/Makefile
> > +++ b/libavcodec/Makefile
> > @@ -1023,6 +1023,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..24cfced
> > --- /dev/null
> > +++ b/libavcodec/tests/celp_math.c
> > @@ -0,0 +1,22 @@
> > +#include "libavutil/libm.h"
>
> missing license header
>
> also fails on x86-32 linux
> can you reproduce it ?
>
yes, was able to reproduce the error after cross-compilation.   Sending in
new patch that fixes the error on 32 bit machines

>
> /home/michael/ffmpeg-git/ffmpeg/tests/fate-run.sh fate-celp_math
> "/home/michael/fatesamples/fate/fate-suite/" "" 
> "/home/michael/ffmpeg-git/ffmpeg/linux32"
> 'run libavcodec/tests/celp_math' '' '/dev/null' '' '1' '' '' '' '' '' '' ''
> ''
>  /home/michael/ffmpeg-git/ffmpeg/linux32/libavcodec/tests/celp_math
> Test celp_math failed. Look at tests/data/fate/celp_math.err for details.
> Assertion 16.94f == r failed at src/libavcodec/tests/celp_math.c:15
> Aborted
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> No great genius has ever existed without some touch of madness. --
> Aristotle
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2017-03-23 Thread Thomas Turner
Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 libavcodec/Makefile  |  1 +
 libavcodec/tests/celp_math.c | 22 ++
 tests/fate/libavcodec.mak|  5 +
 3 files changed, 28 insertions(+)
 create mode 100644 libavcodec/tests/celp_math.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index b8d7a00..eae7b8e 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1023,6 +1023,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..24cfced
--- /dev/null
+++ b/libavcodec/tests/celp_math.c
@@ -0,0 +1,22 @@
+#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   r = ff_dot_productf(f1, f2, FF_ARRAY_ELEMS(f1));
+int64_t d = ff_dot_product(i1, i2, FF_ARRAY_ELEMS(i1));
+
+av_assert0(16.94f == r);
+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
-- 
1.9.1

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


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

2017-03-07 Thread Thomas Turner
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 <thomas...@googlemail.com>
---
 libavutil/tests/lfg.c|  164 +++-
 tests/fate/libavutil.mak |4 +
 tests/ref/fate/lfg   | 1007 ++
 3 files changed, 1153 insertions(+), 22 deletions(-)
 create mode 100644 tests/ref/fate/lfg

diff --git a/libavutil/tests/lfg.c b/libavutil/tests/lfg.c
index 1425e02..ad3b491 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,
+  0.0038405729373609,
+  0.0003951896511919,
+  0.321767881768,
+  0.002888167364,
+  0.003960315187};
+
+double r;
+double x = u - 0.5;
+
+// Beasley

Re: [FFmpeg-devel] [PATCH] avutil/tests/lfg.c: added proper normality test

2017-03-07 Thread Thomas Turner
On Mar 6, 2017 11:47 PM, "Carl Eugen Hoyos" <ceffm...@gmail.com> wrote:

2017-03-07 6:36 GMT+01:00 Thomas Turner <thomas...@googlemail.com>:
> ./configure command worked without ccache:
>
> ./configure --enable-debug=3 --arch=x86_32 --target-os=linux
> --extra-cflags=-m32 --extra-ldflags=-m32  --enable-cross-compile
>
> but after installing the following software packages w/ apt-get:
>
> apt-get install gcc-multilib g++-mult
>
> after recompiling and installing ffmpeg and running lfg selftest again,
the
> test still passes for x86_32 w/ gcc.
> Just to double check the results, i ran the lfg test in a virtual machine
> running 32 bit ubuntu and the test indeed passes.
>
> So i am unable to reproduce the error on x86_32.

The failure is reproducible with gcc 4.3.6 which we supported so far
(and several not-so-supported versions).

Carl Eugen

I see, well I'm running gcc 4.8.4.

Is ffmpeg is there a way to compile w/ a specific version of gcc, without
having to downgrade?

I've tried "./configure --cc='gcc-4.3.6' " which gives an error. However
"./configure --cc='gcc' " doesn't give an error.

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


Re: [FFmpeg-devel] [PATCH] avutil/tests/lfg.c: added proper normality test

2017-03-06 Thread Thomas Turner
./configure command worked without ccache:

./configure --enable-debug=3 --arch=x86_32 --target-os=linux
--extra-cflags=-m32 --extra-ldflags=-m32  --enable-cross-compile

but after installing the following software packages w/ apt-get:

apt-get install gcc-multilib g++-mult

after recompiling and installing ffmpeg and running lfg selftest again, the
test still passes for x86_32 w/ gcc.
Just to double check the results, i ran the lfg test in a virtual machine
running 32 bit ubuntu and the test indeed passes.

So i am unable to reproduce the error on x86_32.



On Fri, Feb 24, 2017 at 7:53 PM, Michael Niedermayer <mich...@niedermayer.cc
> wrote:

> On Fri, Feb 24, 2017 at 07:13:05PM -0800, Thomas Turner wrote:
> [...]
> > ccache gcc -m32 -c -o /tmp/ffconf.2gbznSmZ.o /tmp/ffconf.72hnkFGt.c
> > ./configure: 884: ./configure: ccache: not found
> > C compiler test failed.
>
> try without ccache
>
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Those who are too smart to engage in politics are punished by being
> governed by those who are dumber. -- Plato
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avutil/tests/lfg.c: added proper normality test

2017-02-24 Thread Thomas Turner
On Wed, Feb 22, 2017 at 2:16 PM, Michael Niedermayer <mich...@niedermayer.cc
> wrote:

> oops forgot to reply to all, this one went only to thomas by mistake
>
> On Tue, Feb 21, 2017 at 08:12:57PM -0800, Thomas Turner wrote:
> >
> >
> > On 02/17/2017 02:15 PM, Michael Niedermayer wrote:
> > > On Thu, Feb 16, 2017 at 08:29:38PM -0800, Thomas Turner wrote:
> > >> 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 <thomas...@googlemail.com>
> > >> ---
> > >>  libavutil/tests/lfg.c|  170 ++--
> > >>  tests/fate/libavutil.mak |4 +
> > >>  tests/ref/fate/lfg   | 1007 ++
> 
> > >>  3 files changed, 1157 insertions(+), 24 deletions(-)
> > >>  create mode 100644 tests/ref/fate/lfg
> > >
> > > works on x86_64 linux but fails on x86_32
> >
> > What if we force gcc compiler to use IEEE 754 floating-point
> semantics...Will adding the following gcc compilation flags to ffmpeg
> configuration allow the test to pass? : -msse2 -mfpmath=sse
>
> there is no gurantee that the hardware this runs on supports sse
> nor that the compiler is gcc
>
> C has a somewhat loose definition of floating point operations,
> that allows C compilers to perform more optimizations and run on more
> hardware. There isnt much that can be done about this, short of not
> using floating point
>
> But why does it not work with default options?
>
x86_32 machine produces a negative overflow for double precision value. But
unable to figure out precisely why. my guesstimation would be because of
the difference in floating point arithmetic.

> or is that unknown ?
> did you succeed in reproduring the issue ?
>
trying to compile 32bit on my 64bit machine with:

./configure --enable-debug=3 --cc='cc -m32'
but i get the following error:

cc -m32 is unable to create an executable file.
If cc -m32 is a cross-compiler, use the --enable-cross-compile option.
Only do this if you know what cross compiling means.
C compiler test failed.


> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> There will always be a question for which you do not know the correct
> answer.
>
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] avutil/tests/lfg.c: added proper normality test

2017-02-21 Thread Thomas Turner


On 02/17/2017 02:15 PM, Michael Niedermayer wrote:
> On Thu, Feb 16, 2017 at 08:29:38PM -0800, Thomas Turner wrote:
>> 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 <thomas...@googlemail.com>
>> ---
>>  libavutil/tests/lfg.c|  170 ++--
>>  tests/fate/libavutil.mak |4 +
>>  tests/ref/fate/lfg   | 1007 
>> ++
>>  3 files changed, 1157 insertions(+), 24 deletions(-)
>>  create mode 100644 tests/ref/fate/lfg
> 
> works on x86_64 linux but fails on x86_32

What if we force gcc compiler to use IEEE 754 floating-point semantics...Will 
adding the following gcc compilation flags to ffmpeg configuration allow the 
test to pass? : -msse2 -mfpmath=sse
> 
> --- ffmpeg/tests/ref/fate/lfg  2017-02-17 22:27:05.394644315 +0100
> +++ tests/data/fate/lfg 2017-02-17 22:53:34.978677803 +0100
> @@ -1004,4 +1004,4 @@
>  true stddev  : 53.00
>  z-score  : 0.181279
>  p-value  : 0.428600
> -QH[normality]: 1.015347
> +QH[normality]: 
> -274309382319023864748424681468621758678576399865310792059887853269490762262076171214661036349063168.00
> Test lfg failed. Look at tests/data/fate/lfg.err for details.
> make: *** [fate-lfg] Error 1
> 
> 
> 8...]
> 
> 
> 
> ___
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
> 
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


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

2017-02-16 Thread Thomas Turner
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 <thomas...@googlemail.com>
---
 libavutil/tests/lfg.c|  170 ++--
 tests/fate/libavutil.mak |4 +
 tests/ref/fate/lfg   | 1007 ++
 3 files changed, 1157 insertions(+), 24 deletions(-)
 create mode 100644 tests/ref/fate/lfg

diff --git a/libavutil/tests/lfg.c b/libavutil/tests/lfg.c
index 1425e02..93b102c 100644
--- a/libavutil/tests/lfg.c
+++ b/libavutil/tests/lfg.c
@@ -20,9 +20,88 @@
 #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,
+  0.0038405729373609,
+  0.0003951896511919,
+  0.321767881768,
+  0.002888167364,
+  0.003960315187};
+
+double r;
+double x = u - 0.5;
+
+// Beasley

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

2017-01-31 Thread Thomas Turner
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 <thomas...@googlemail.com>
---
 libavutil/tests/lfg.c| 125 +--
 tests/fate/libavutil.mak |   5 ++
 2 files changed, 104 insertions(+), 26 deletions(-)

diff --git a/libavutil/tests/lfg.c b/libavutil/tests/lfg.c
index 1425e02..645d39d 100644
--- a/libavutil/tests/lfg.c
+++ b/libavutil/tests/lfg.c
@@ -20,6 +20,59 @@
 #include "libavutil/timer.h"
 #include "libavutil/lfg.h"
 
+#define TEST1
+
+// 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,
+  0.0038405729373609,
+  0.0003951896511919,
+  0.321767881768,
+  0.002888167364,
+  0.003960315187};
+
+double r;
+double x = u - 0.5;
+
+// Beasley-Springer
+#if TEST == 0
+if (fabs(x) < 0.42) {
+#endif
+#if TEST == 1
+if (u > 0.08 && u < 0.92) {
+#endif
+double y = x * x;
+r= x * (((a[3]*y+a[2])*y+a[1])*y+a[0]) /
+b[3]*y+b[2])*y+b[1])*y+b[0])*y+1.0);
+}
+else {// Moro
+r = u;
+if (x > 0.0)
+r = 1.0 - u;
+r = log(-log(r));
+r = c[0] + r*(c[1]+r*(c[2]+r*(c[3]+r*(c[4]+r*(c[5]+r*(c[6]+
+r*(c[7]+r*c[8])));
+if (x < 0.0)
+r = -r;
+}
+
+return r;
+}
+
 int main(void)
 {
 int x = 0;
@@ -37,38 +90,58 @@ int main(void)
 }
 av_log(NULL, AV_LOG_ERROR, "final value:%X\n", x);
 
-/* BMG usage example */
+/*  Chen-Shapiro Normality Test */
 {
-double mean   = 1000;
-double stddev = 53;
-double samp_mean = 0.0, samp_stddev = 0.0;
-double samp0, samp1;
+double QH   = 0.0;
+const double stddev = 53.0;
+double samp_stddev  = 0.0;
+const double mean   = 1000;
+double samp_mean= 0.0;
+const int tot_samp  = 2000;
+double *PRN_arr = av_malloc_array(tot_samp, sizeof(double));
 
-av_lfg_init(, 42);
+av_lfg_init(, 0x7a69);
+if (!PRN_arr) {
+fprintf(stderr, "failed to allocate memory!\n");
+return 1;
+}
 
-for (i = 0; i < 1000; i += 2) {
+for (i = 0; i < tot_samp; i += 2) {
 double bmg_out[2];
 av_bmg_get(, bmg_out);
-samp0 = bmg_out[0] * stddev + mean;
-samp1 = bmg_out[1] * stddev + mean;
-samp_mean += samp0 + samp1;
-samp_stddev += samp0 * samp0 + samp1 * samp1;
-av_log(NULL, AV_LOG_INFO,
-   "%f\n%f\n",
-   samp0,
-   samp1);
+PRN_arr[i  ] = bmg_out[0] * stddev + mean;
+PRN_arr[i+1] = bmg_out[1] * stddev + mean;
+samp_mean   += PRN_arr[i] + PRN_arr[i+1];
+av_log(NULL, AV_LOG_INFO, "PRN%d : %f\n"
+  "PRN%d : %f\n",
+   i, PRN_arr[i], i+1, PRN_arr[i+1]);
 }
-/* TODO: add proper normality test */
-samp_mean /= 1000;
-samp_stddev /= 999;
-samp_stddev -= (1000.0/999.0)*samp_mean*samp_mean;
-samp_stddev = sqrt(samp_stddev);
-av_log(NULL, AV_LOG_INFO, "sample mean  : %f\n"
-  "true mean: %f\n"
-  "sample stddev: %f\n"
-  "true stddev  : %f\n",
-   samp_mean, mean, samp_stddev, stddev);
-}
+samp_mean /= tot_samp;
+
+for (i = 0; i < tot_samp; ++i) {
+double temp;
+temp = PRN_arr[i] - samp_mean;
+temp*= temp;
+ 

[FFmpeg-devel] [PATCH] avcodec/alsdec.c: testing MPEG-4 ALS decoder with floating point audio data

2017-01-20 Thread Thomas Turner
If als_07_2ch192k32bF.mp4 isn't already located in fate-suite/lossless-audio/, 
you can download at:


http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_IEC_14496-26_2010_Bitstreams/DVD1/mpeg4audio-conformance/compressedMp4/als_07_2ch192k32bF.mp4

Reference file can be found at:

https://dl.dropboxusercontent.com/u/1519724/als_07_2ch192k32bF.f32

Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 tests/fate/als.mak | 4 
 1 file changed, 4 insertions(+)

diff --git a/tests/fate/als.mak b/tests/fate/als.mak
index ff2badf..1f4c88f 100644
--- a/tests/fate/als.mak
+++ b/tests/fate/als.mak
@@ -7,5 +7,9 @@ endef
 
 $(foreach N,$(ALS_SUITE),$(eval $(call FATE_ALS_SUITE,$(N
 
+FATE_ALS += fate-mpeg4-als-conformance-07
+fate-mpeg4-als-conformance-07: CMD = ffmpeg -i 
$(TARGET_SAMPLES)/lossless-audio/als_07_2ch192k32bF.mp4 -af 
atrim=end_sample=958446 -f f32le -
+fate-mpeg4-als-conformance-07: REF = 
$(TARGET_SAMPLES)/audio-reference/als_07_2ch192k32bF.f32
+
 FATE_SAMPLES_AVCONV-$(call DEMDEC, MOV, ALS) += $(FATE_ALS)
 fate-als: $(FATE_ALS)
-- 
1.9.1

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


[FFmpeg-devel] [PATCH] avcodec/alsdec.c: testing MPEG-4 ALS decoder with floating point audio data

2017-01-13 Thread Thomas Turner
If als_07_2ch192k32bF.mp4 isn't already located in fate-suite/lossless-audio/, 
you can download at:

http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_IEC_14496-26_2010_Bitstreams/DVD1/mpeg4audio-conformance/compressedMp4/als_07_2ch192k32bF.mp4

Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 tests/fate/als.mak  | 3 +++
 tests/ref/fate/mpeg4-als-conformance-07 | 1 +
 2 files changed, 4 insertions(+)
 create mode 100644 tests/ref/fate/mpeg4-als-conformance-07

diff --git a/tests/fate/als.mak b/tests/fate/als.mak
index ff2badf..a67302c 100644
--- a/tests/fate/als.mak
+++ b/tests/fate/als.mak
@@ -7,5 +7,8 @@ endef
 
 $(foreach N,$(ALS_SUITE),$(eval $(call FATE_ALS_SUITE,$(N
 
+FATE_ALS += fate-mpeg4-als-conformance-07
+fate-mpeg4-als-conformance-07: CMD = crc -i 
$(TARGET_SAMPLES)/lossless-audio/als_07_2ch192k32bF.mp4
+
 FATE_SAMPLES_AVCONV-$(call DEMDEC, MOV, ALS) += $(FATE_ALS)
 fate-als: $(FATE_ALS)
diff --git a/tests/ref/fate/mpeg4-als-conformance-07 
b/tests/ref/fate/mpeg4-als-conformance-07
new file mode 100644
index 000..1cc705d
--- /dev/null
+++ b/tests/ref/fate/mpeg4-als-conformance-07
@@ -0,0 +1 @@
+CRC=0x01503df3
-- 
1.9.1

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


[FFmpeg-devel] [PATCH] avformat/flvdec.c: testing for ontextdata packet

2017-01-11 Thread Thomas Turner
file can be found at: 
https://drive.google.com/file/d/0B2asIA9Y3hy4eVEwWEI3WmhJRUk/view?usp=sharing

Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 tests/fate/demux.mak|   3 +
 tests/ref/fate/flv-demux-ontextdata | 559 
 2 files changed, 562 insertions(+)
 create mode 100644 tests/ref/fate/flv-demux-ontextdata

diff --git a/tests/fate/demux.mak b/tests/fate/demux.mak
index cee4bd4..8d4ca01 100644
--- a/tests/fate/demux.mak
+++ b/tests/fate/demux.mak
@@ -38,6 +38,9 @@ fate-d-eavp6-demux: CMD = framecrc -i 
$(TARGET_SAMPLES)/ea-vp6/SmallRing.vp6 -ma
 FATE_SAMPLES_DEMUX-$(CONFIG_FLV_DEMUXER) += fate-flv-demux
 fate-flv-demux: CMD = framecrc -i 
$(TARGET_SAMPLES)/flv/Enigma_Principles_of_Lust-part.flv -codec copy
 
+FATE_SAMPLES_DEMUX-$(CONFIG_FLV_DEMUXER) += fate-flv-demux-ontextdata
+fate-flv-demux-ontextdata: CMD = framecrc -i 
$(TARGET_SAMPLES)/flv/vid_with_ontextdata.flv -codec copy
+
 FATE_SAMPLES_DEMUX-$(CONFIG_GIF_DEMUXER) += fate-gif-demux
 fate-gif-demux: CMD = framecrc -i 
$(TARGET_SAMPLES)/gif/Newtons_cradle_animation_book_2.gif -vcodec copy
 
diff --git a/tests/ref/fate/flv-demux-ontextdata 
b/tests/ref/fate/flv-demux-ontextdata
new file mode 100644
index 000..46e14b4
--- /dev/null
+++ b/tests/ref/fate/flv-demux-ontextdata
@@ -0,0 +1,559 @@
+#extradata 0:1, 0x00080008
+#tb 0: 1/1000
+#media_type 0: video
+#codec_id 0: vp6f
+#dimensions 0: 480x360
+#sar 0: 0/1
+#tb 1: 1/1000
+#media_type 1: audio
+#codec_id 1: mp3
+#sample_rate 1: 44100
+#channel_layout 1: 3
+#channel_layout_name 1: stereo
+0,  0,  0,0,10214, 0xbc31b3ed
+1,  0,  0,   26,  417, 0x5b2302ae
+1, 26, 26,   26,  417, 0x5742c4ba
+0, 33, 33,0,  307, 0xdbaa9e86, F=0x0
+1, 52, 52,   26,  418, 0xcd74c944
+0, 66, 66,0, 1313, 0x9a468700, F=0x0
+1, 78, 78,   26,  418, 0xb683ca07
+0,100,100,0, 1638, 0xa0123705, F=0x0
+1,104,104,   26,  418, 0x52dccf02
+1,130,130,   26,  418, 0x3acacf5e
+0,133,133,0, 1469, 0xb4a1d5df, F=0x0
+1,156,156,   26,  418, 0x4a64c411
+0,166,166,0, 1204, 0x274453b8, F=0x0
+1,182,182,   26,  418, 0x6b1ccd15
+0,200,200,0, 1545, 0x8c370cb6, F=0x0
+1,208,208,   26,  418, 0x0243bf67
+0,233,233,0, 1540, 0xc530f125, F=0x0
+1,235,235,   26,  418, 0x6ef6cf60
+1,261,261,   26,  418, 0xcafccce8
+0,266,266,0, 3194, 0xd61b200a, F=0x0
+1,287,287,   26,  418, 0x40a1d103
+0,300,300,0, 1065, 0x52220e00, F=0x0
+1,313,313,   26,  418, 0xec30ce96
+0,333,333,0, 2248, 0x66646d40, F=0x0
+1,339,339,   26,  418, 0x0d2cccee
+1,365,365,   26,  418, 0x0381da3f
+0,367,367,0, 1639, 0x2b50180d, F=0x0
+1,391,391,   26,  418, 0xe663bfa8
+0,400,400,0, 1994, 0x1bd9edd1, F=0x0
+1,417,417,   26,  418, 0xacc8ce09
+0,433,433,0, 1136, 0x7d0e1e2c, F=0x0
+1,444,444,   26,  418, 0xd94fc6a3
+0,467,467,0, 2904, 0x9cbfad63, F=0x0
+1,470,470,   26,  418, 0x1e2fd379
+1,496,496,   26,  418, 0xca18cbcd
+0,500,500,0, 2111, 0xe3711120, F=0x0
+1,522,522,   26,  418, 0x3289
+0,533,533,0, 2489, 0xb425d41c, F=0x0
+1,548,548,   26,  418, 0x46c2c2d5
+0,567,567,0, 1995, 0x04d8d645, F=0x0
+1,574,574,   26,  418, 0x003bc62d
+0,600,600,0, 1662, 0xe17b3c69, F=0x0
+1,600,600,   26,  418, 0xdf5cc39b
+1,626,626,   26,  418, 0x793acf3d
+0,633,633,0, 1724, 0xba4a5ea6, F=0x0
+1,653,653,   26,  418, 0xece6cfc0
+0,667,667,0, 1899, 0x6e6dac96, F=0x0
+1,679,679,   26,  417, 0xa20ebffb
+0,700,700,0, 1437, 0x2c52c628, F=0x0
+1,705,705,   26,  418, 0x5025dcfd
+1,731,731,   26,  418, 0xc3f8cd9e
+0,734,734,0, 1562, 0x5e171cc1, F=0x0
+1,757,757,   26,  418, 0xada9cd48
+0,767,767,0, 1677, 0x67ce442a, F=0x0
+1,783,783,   26,   

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

2017-01-11 Thread Thomas Turner
Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 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, _data, 
test_sample.nb_samples_pch);
+ret = read_samples_from_audio_fifo(afifo, _data, 
test_sample->nb_samples_pch);
 if (ret < 0){
 ERROR("ERROR: av_audio_fifo_read failed!");
 }
 printf("read: %d\n", ret);
-print_audio_bytes(_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(_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(_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(_struct[t]);
 }
 return 0;
 }
-- 
1.9.1

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


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

2017-01-01 Thread Thomas Turner
Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 libavutil/Makefile|  1 +
 libavutil/tests/aes_ctr.c | 65 +++
 tests/fate/libavutil.mak  |  5 
 3 files changed, 71 insertions(+)
 create mode 100644 libavutil/tests/aes_ctr.c

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..fa0cb79
--- /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;
+}
\ No newline at end of file
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
-- 
1.9.1

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


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

2016-12-31 Thread Thomas Turner
Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 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 *)
+void * volatile *tmp2 = 
 int res;
 
 res = avpriv_atomic_int_add_and_fetch(, 1);
@@ -29,6 +31,8 @@ int main(void)
 avpriv_atomic_int_set(, 3);
 res = avpriv_atomic_int_get();
 av_assert0(res == 3);
+avpriv_atomic_ptr_cas(tmp2, tmp1, );
+av_assert0(*tmp2 == );
 
 return 0;
 }
-- 
1.9.1

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


[FFmpeg-devel] [PATCH] avutil/tests: Added selftest for aes_ctr.c

2016-12-30 Thread Thomas Turner
Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 libavutil/Makefile|  1 +
 libavutil/tests/aes_ctr.c | 70 +++
 tests/fate/libavutil.mak  |  5 
 3 files changed, 76 insertions(+)
 create mode 100644 libavutil/tests/aes_ctr.c

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..8216b20
--- /dev/null
+++ b/libavutil/tests/aes_ctr.c
@@ -0,0 +1,70 @@
+/*
+ * 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 "libavutil/log.h"
+#include "libavutil/mem.h"
+#include "libavutil/aes_ctr.h"
+#include "libavutil/aes.h"
+
+const DECLARE_ALIGNED(8, uint8_t, plain)[] = {
+0x6d, 0x6f, 0x73, 0x74, ' ', 0x72, 0x61, 0x6e, 0x64, 0x6f, 0x6d
+};
+static DECLARE_ALIGNED(8, uint8_t, tmp)[11];
+
+int main (void)
+{
+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");
+#define DEALLOCATE() \
+av_aes_ctr_free(ae); \
+av_aes_ctr_free(ad);
+
+DEALLOCATE();
+return 0;
+
+ERROR:
+DEALLOCATE();
+return 1;
+}
\ No newline at end of file
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
-- 
1.9.1

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


[FFmpeg-devel] [PATCH 3/3] avutil/tests/audio_fifo.c: Corrected test error messages

2016-12-27 Thread Thomas Turner
Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 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 2cef6f0..861cebb 100644
--- a/libavutil/tests/audio_fifo.c
+++ b/libavutil/tests/audio_fifo.c
@@ -147,7 +147,7 @@ static void test_function(const TestStruct test_sample)
 
 ret = read_samples_from_audio_fifo(afifo, _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(_sample, output_data, ret);
@@ -167,7 +167,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(_sample, output_data, ret);
-- 
1.9.1

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


[FFmpeg-devel] [PATCH 1/3] avutil/tests/audio_fifo.c: use av_malloc() family of functions

2016-12-27 Thread Thomas Turner
Signed-off-by: James Almer <jamr...@gmail.com>

Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 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 34c8573..9dc6054 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(_data[i]);
 }
-free(output_data);
+av_freep(_data);
 av_audio_fifo_free(afifo);
 }
 
-- 
1.9.1

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


[FFmpeg-devel] [PATCH 2/3] avutil/tests/audio_fifo.c: Memory leak and tab space fixes

2016-12-27 Thread Thomas Turner
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 <thomas...@googlemail.com>
---
 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 9dc6054..2cef6f0 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(_data[i]);
+}
+av_freep(_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(_data[i]);
-}
-av_freep(_data);
+free_data_planes(afifo, output_data);
 av_audio_fifo_free(afifo);
 }
 
-- 
1.9.1

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


[FFmpeg-devel] [PATCH] avutil/tests: Replacement selftest for audio_fifo.c

2016-12-26 Thread Thomas Turner
Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 libavutil/tests/audio_fifo.c | 181 ---
 tests/ref/fate/audio_fifo|  34 +++-
 2 files changed, 130 insertions(+), 85 deletions(-)

diff --git a/libavutil/tests/audio_fifo.c b/libavutil/tests/audio_fifo.c
index 34c8573..a5c3344 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
@@ -31,12 +32,25 @@ typedef struct TestStruct {
 int nb_samples_pch;
 } TestStruct;
 
+typedef struct Audio_Data {
+uint8_t *data[MAX_CHANNELS];/**< data plane pointers   
*/
+int nb_samples_pch; /**< number of samples per channel 
*/
+int allocated_samples;  /**< number of samples per channel the 
buffer can hold */
+enum AVSampleFormat sample_fmt; /**< sample format 
*/
+int channels;   /**< channel count 
*/
+int is_planar;  /**< sample format is planar   
*/
+int planes; /**< number of data planes 
*/
+int sample_size;/**< bytes per sample  
*/
+int stride; /**< sample byte offset within a plane 
*/
+int line_size;  /**< size of data buffer per plane 
*/
+} Audio_Data;
+
 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_U8   , .nb_ch = 2, .data_planes = {data_U8 ,  
   }, .nb_samples_pch = 6 },
 {.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 },
@@ -44,34 +58,81 @@ 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 ERROR(const char *str)
+static void free_audio(Audio_Data *a)
 {
-fprintf(stderr, "%s\n", str);
-exit(1);
+int i;
+for (i = 0; i < a->planes; ++i){
+av_freep(>data[i]);
+}
+av_freep();
 }
 
-static void* allocate_memory(size_t size)
+static Audio_Data* set_audio_data(const TestStruct test_sample)
 {
-void *ptr = malloc(size);
-if (ptr == NULL){
-ERROR("failed to allocate memory!");
+Audio_Data *a;
+int buf_size, i;
+
+a = av_mallocz(sizeof(*a));
+if (!a)
+return NULL;
+
+a->nb_samples_pch = test_sample.nb_samples_pch;
+a->sample_fmt = test_sample.format;
+a->channels   = test_sample.nb_ch;
+a->is_planar  = av_sample_fmt_is_planar(a->sample_fmt);
+a->planes = a->is_planar ? a->channels : 1;
+a->sample_size= av_get_bytes_per_sample(a->sample_fmt);
+
+if (av_samples_get_buffer_size(_size, a->channels, a->nb_samples_pch, 
a->sample_fmt, 1) < 0)
+goto error;
+
+a->stride = buf_size / a->nb_samples_pch;
+a->line_size  = buf_size;
+
+for (i = 0; i < a->planes; ++i){
+a->data[i] = av_malloc_array(1, buf_size);
+if (!a->data[i])
+goto error;
+memcpy(a->data[i], test_sample.data_planes[i] ,buf_size);
 }
-return ptr;
+
+a->allocated_samples = a->nb_samples_pch;
+
+return a;
+
+error:
+free_audio(a);
+return NULL;
 }
 
-static void print_audio_bytes(const TestStruct *test_sample, void 
**data_planes, int nb_samples)
+static void ERROR(const char *str, AVAudioFifo *afifo, Audio_Data *adata)
 {
-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-&

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

2016-12-22 Thread Thomas Turner
Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 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..fcd68bc 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; i<N; i++){
-seeds[i] = av_get_random_seed();
-for (j=0; j<i; j++)
-if (seeds[j] == seeds[i])
-goto retry;
+for (rsf=0; rsf<F; ++rsf){
+for (retry=0; retry<3; retry++){
+for (i=0; i<N; i++){
+seeds[i] = random_seed[rsf]();
+for (j=0; j<i; j++)
+if (seeds[j] == seeds[i])
+goto retry;
+}
+printf("seeds OK\n");
+goto next;
+retry:;
 }
-printf("seeds OK\n");
-return 0;
-retry:;
+printf("rsf %d: FAIL at %d with %X\n", rsf, j, seeds[j]);
+return 1;
+next:;
 }
-printf("FAIL at %d with %X\n", j, seeds[j]);
-return 1;
-}
+return 0;
+ }
\ No newline at end of file
diff --git a/tests/ref/fate/random_seed b/tests/ref/fate/random_seed
index 2b5b3af..ef0eef2 100644
--- a/tests/ref/fate/random_seed
+++ b/tests/ref/fate/random_seed
@@ -1 +1,2 @@
 seeds OK
+seeds OK
-- 
1.9.1

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


Re: [FFmpeg-devel] [PATCH] avutil: Added selftest for libavutil/audio_fifo.c

2016-12-21 Thread Thomas Turner
Yes, you're correct. I'll look over the test and make sure there isn't
anymore bugs before sending in the patch. Thanks

On Dec 21, 2016 6:28 PM, "James Almer" <jamr...@gmail.com> wrote:

On 12/21/2016 11:22 PM, Thomas Turner wrote:
> yeah, currently taking a look.

int tot_elements   = !(planes = av_sample_fmt_is_planar(afifo->sample_fmt))
 ? samples : afifo->channels * samples;
void **data_planes = allocate_memory(sizeof(void*) * planes);

planes is zero when the sample_fmt is not planar, so you end up
calling malloc(0).
It should be channel count if planar, 1 otherwise. I think you
can just call malloc with afifo->nb_buffers * sizeof(void*) as
size.

This is also a good reason to use av_malloc_array() instead of
a plain malloc().

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


Re: [FFmpeg-devel] [PATCH] avutil: Added selftest for libavutil/audio_fifo.c

2016-12-21 Thread Thomas Turner

yeah, currently taking a look.


On 12/21/2016 06:08 PM, Michael Niedermayer wrote:

On Wed, Dec 21, 2016 at 10:53:36PM -0300, James Almer wrote:

On 12/21/2016 10:49 PM, Michael Niedermayer wrote:

On Wed, Dec 21, 2016 at 09:45:39PM -0300, James Almer wrote:

On 12/20/2016 11:36 PM, Michael Niedermayer wrote:

On Tue, Dec 20, 2016 at 04:53:51PM -0800, Thomas Turner wrote:

Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
  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(+)
  create mode 100644 libavutil/tests/audio_fifo.c
  create mode 100644 tests/ref/fate/audio_fifo

applied

thx

This is crashing on some fate clients.

I noticed it's using malloc and free instead of the av_malloc family,
so maybe it's related to that?
Patch attached in any case, it's proper even if not the reason behind
the crashes.

i saw the malloc/free before applying. It seemed to make sense to
use libc functions in a test of our public API

why is it crashing ?

I don't know, i can't reproduce it. Seems to be OpenBSD FATE clients only
as far as i could see.

no openbsd needed, valgrind shows these errors
Thomas, can you look at this ?

TEST: 1

written: 12
written: 12
remaining samples in audio_fifo: 24

==32011== Invalid write of size 8
==32011==at 0x4016B2: read_samples_from_audio_fifo (audio_fifo.c:92)
==32011==by 0x4018C6: test_function (audio_fifo.c:141)
==32011==by 0x401AE2: main (audio_fifo.c:193)
==32011==  Address 0x540f040 is 0 bytes after a block of size 0 alloc'd
==32011==at 0x4C2C66F: malloc (vg_replace_malloc.c:270)
==32011==by 0x4014E5: allocate_memory (audio_fifo.c:55)
==32011==by 0x401674: read_samples_from_audio_fifo (audio_fifo.c:88)
==32011==by 0x4018C6: test_function (audio_fifo.c:141)
==32011==by 0x401AE2: main (audio_fifo.c:193)
==32011==
==32011== Invalid read of size 8
==32011==at 0x401320: av_audio_fifo_read (audio_fifo.c:193)
==32011==by 0x4016DD: read_samples_from_audio_fifo (audio_fifo.c:95)
==32011==by 0x4018C6: test_function (audio_fifo.c:141)
==32011==by 0x401AE2: main (audio_fifo.c:193)
==32011==  Address 0x540f040 is 0 bytes after a block of size 0 alloc'd
==32011==at 0x4C2C66F: malloc (vg_replace_malloc.c:270)
==32011==by 0x4014E5: allocate_memory (audio_fifo.c:55)
==32011==by 0x401674: read_samples_from_audio_fifo (audio_fifo.c:88)
==32011==by 0x4018C6: test_function (audio_fifo.c:141)
==32011==by 0x401AE2: main (audio_fifo.c:193)
==32011==
read: 12
==32011== Invalid read of size 8
==32011==at 0x4015A8: print_audio_bytes (audio_fifo.c:74)
==32011==by 0x401900: test_function (audio_fifo.c:146)
==32011==by 0x401AE2: main (audio_fifo.c:193)
==32011==  Address 0x540f040 is 0 bytes after a block of size 0 alloc'd
==32011==at 0x4C2C66F: malloc (vg_replace_malloc.c:270)
==32011==by 0x4014E5: allocate_memory (audio_fifo.c:55)
==32011==by 0x401674: read_samples_from_audio_fifo (audio_fifo.c:88)
==32011==by 0x4018C6: test_function (audio_fifo.c:141)
==32011==by 0x401AE2: main (audio_fifo.c:193)
==32011==
00 01 02 03 04 05 06 07 08 09 0a 0b
remaining samples in audio_fifo: 12

==32011== Invalid read of size 8
==32011==at 0x401164: av_audio_fifo_peek (audio_fifo.c:150)
==32011==by 0x401937: test_function (audio_fifo.c:150)
==32011==by 0x401AE2: main (audio_fifo.c:193)
==32011==  Address 0x540f040 is 0 bytes after a block of size 0 alloc'd
==32011==at 0x4C2C66F: malloc (vg_replace_malloc.c:270)
==32011==by 0x4014E5: allocate_memory (audio_fifo.c:55)
==32011==by 0x401674: read_samples_from_audio_fifo (audio_fifo.c:88)
==32011==by 0x4018C6: test_function (audio_fifo.c:141)
==32011==by 0x401AE2: main (audio_fifo.c:193)
==32011==
peek:
==32011== Invalid read of size 8
==32011==at 0x4015A8: print_audio_bytes (audio_fifo.c:74)
==32011==by 0x401967: test_function (audio_fifo.c:155)
==32011==by 0x401AE2: main (audio_fifo.c:193)
==32011==  Address 0x540f040 is 0 bytes after a block of size 0 alloc'd
==32011==at 0x4C2C66F: malloc (vg_replace_malloc.c:270)
==32011==by 0x4014E5: allocate_memory (audio_fifo.c:55)
==32011==by 0x401674: read_samples_from_audio_fifo (audio_fifo.c:88)
==32011==by 0x4018C6: test_function (audio_fifo.c:141)
==32011==by 0x401AE2: main (audio_fifo.c:193)
==32011==
00 01 02 03 04 05 06 07 08 09 0a 0b

peek_at:
==32011== Invalid read of size 8
==32011==at 0x401264: av_audio_fifo_peek_at (audio_fifo.c:174)
==32011==by 0x40199E: test_function (audio_fifo.c:161)
==32011==by 0x401AE2: main (audio_fifo.c:193)
==32011==  Address 0x540f040 is 0 bytes after a block of size 0 alloc'd
==32011==at 0x4C2C66F: malloc (vg_replace_malloc.c:270)
==32011==by 0x4014E5: allocate_memory (audio_fif

[FFmpeg-devel] [PATCH] avutil: Improved code coverage for libavutil/random_seed.c

2016-12-20 Thread Thomas Turner
Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 libavutil/tests/random_seed.c | 40 
 tests/ref/fate/random_seed|  1 +
 2 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/libavutil/tests/random_seed.c b/libavutil/tests/random_seed.c
index ebe9b3e..f00b962 100644
--- a/libavutil/tests/random_seed.c
+++ b/libavutil/tests/random_seed.c
@@ -18,29 +18,37 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#define TEST 1
-#include "libavutil/random_seed.c"
 
+ #include "libavutil/random_seed.c"
+ 
 #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];
-
-for (retry=0; retry<3; retry++){
-for (i=0; i<N; i++){
-seeds[i] = av_get_random_seed();
-for (j=0; j<i; j++)
-if (seeds[j] == seeds[i])
-goto retry;
+random_seed_ptr_t random_seed[F] = {av_get_random_seed, get_generic_seed};
+ 
+for (rsf=0; rsf<F; ++rsf){
+for (retry=0; retry<3; retry++){
+for (i=0; i<N; i++){
+seeds[i] = random_seed[rsf]();
+for (j=0; j<i; j++)
+if (seeds[j] == seeds[i])
+goto retry;
+}
+printf("seeds OK\n");
+goto next;
+retry:;
 }
-printf("seeds OK\n");
-return 0;
-retry:;
+printf("rsf %d: FAIL at %d with %X\n", rsf, j, seeds[j]);
+return 1;
+next:;
 }
-printf("FAIL at %d with %X\n", j, seeds[j]);
-return 1;
-}
+return 0;
+ }
\ No newline at end of file
diff --git a/tests/ref/fate/random_seed b/tests/ref/fate/random_seed
index 2b5b3af..ef0eef2 100644
--- a/tests/ref/fate/random_seed
+++ b/tests/ref/fate/random_seed
@@ -1 +1,2 @@
 seeds OK
+seeds OK
-- 
1.9.1

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


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

2016-12-20 Thread Thomas Turner
Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 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(+)
 create mode 100644 libavutil/tests/audio_fifo.c
 create mode 100644 tests/ref/fate/audio_fifo

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..9846e9e
--- /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)
+{
+int i, planes;
+int samples= FFMIN(nb_samples, afifo->nb_samples);
+int tot_elements   = !(planes = av_sample_fmt_is_planar(afifo->sample_fmt))
+ ? samples : afifo->channels * samples;

[FFmpeg-devel] [PATCH] avutil: Improved code coverage for libavutil/random_seed.c

2016-12-20 Thread Thomas Turner
Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 libavutil/tests/random_seed.c | 36 +---
 tests/ref/fate/random_seed|  1 +
 2 files changed, 22 insertions(+), 15 deletions(-)

diff --git a/libavutil/tests/random_seed.c b/libavutil/tests/random_seed.c
index ebe9b3e..ffcb74d 100644
--- a/libavutil/tests/random_seed.c
+++ b/libavutil/tests/random_seed.c
@@ -1,6 +1,4 @@
 /*
- * Copyright (c) 2009 Baptiste Coudurier <baptiste.coudur...@gmail.com>
- *
  * This file is part of FFmpeg.
  *
  * FFmpeg is free software; you can redistribute it and/or
@@ -18,29 +16,37 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#define TEST 1
+
 #include "libavutil/random_seed.c"
 
 #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; i<N; i++){
-seeds[i] = av_get_random_seed();
-for (j=0; j<i; j++)
-if (seeds[j] == seeds[i])
-goto retry;
+for (rsf=0; rsf<F; ++rsf){
+for (retry=0; retry<3; retry++){
+for (i=0; i<N; i++){
+seeds[i] = random_seed[rsf]();
+for (j=0; j<i; j++)
+if (seeds[j] == seeds[i])
+goto retry;
+}
+printf("seeds OK\n");
+goto next;
+retry:;
 }
-printf("seeds OK\n");
-return 0;
-retry:;
+printf("rsf %d: FAIL at %d with %X\n", rsf, j, seeds[j]);
+return 1;
+next:;
 }
-printf("FAIL at %d with %X\n", j, seeds[j]);
-return 1;
+return 0;
 }
diff --git a/tests/ref/fate/random_seed b/tests/ref/fate/random_seed
index 2b5b3af..ef0eef2 100644
--- a/tests/ref/fate/random_seed
+++ b/tests/ref/fate/random_seed
@@ -1 +1,2 @@
 seeds OK
+seeds OK
-- 
1.9.1

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


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

2016-12-19 Thread Thomas Turner
Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 libavutil/Makefile   |   1 +
 libavutil/tests/audio_fifo.c | 195 
 tests/fate/libavutil.mak |   4 +
 tests/ref/fate/audio_fifo| 228 +++
 4 files changed, 428 insertions(+)
 create mode 100644 libavutil/tests/audio_fifo.c
 create mode 100644 tests/ref/fate/audio_fifo

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..7e166b1
--- /dev/null
+++ b/libavutil/tests/audio_fifo.c
@@ -0,0 +1,195 @@
+/*
+ * 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
+
+#define ERROR(str)\
+fprintf(stderr, "%s\n", str); \
+exit(1);
+
+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* allocate_memory(size_t size)
+{
+void *ptr = malloc(size);
+if (ptr == NULL){
+fprintf(stderr, "failed to allocate memory!\n");
+exit(1);
+}
+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)
+{
+int i, planes;
+int samples= FFMIN(nb_samples, afifo->nb_samples);
+int tot_elements   = !(planes = av_sample_fmt_is_planar(afifo->sample_fmt))
+ ? samples : afifo->chann

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

2016-12-17 Thread Thomas Turner
Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 libavutil/tests/avstring.c | 25 -
 1 file changed, 24 insertions(+), 1 deletion(-)

diff --git a/libavutil/tests/avstring.c b/libavutil/tests/avstring.c
index 1242b3f..1e22b4f 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,26 @@ 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("%s should equal: %s\n", ptr, expected); \
+}
+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) \
+ptr = av_d2str(value); \
+if(strcmp(ptr, expected) != 0){ \
+printf("av_d2str failed to convert: %lf to string: %s", 
(double)value, expected); \
+}
+TEST_D2STR(0 ,  "0.00");
+TEST_D2STR(-1.2333234, "-1.233323");
+TEST_D2STR(-1.2333237, "-1.233324");
 return 0;
 }
-- 
1.9.1

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


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

2016-12-17 Thread Thomas Turner
Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 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(+)
 create mode 100644 libavutil/tests/audio_fifo.c
 create mode 100644 tests/ref/fate/audio_fifo

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..6dffe85
--- /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 "libavutil/audio_fifo.c"
+#include "libavutil/audio_fifo.h"
+#include "libavutil/error.h"
+
+#define MAX_CHANNELS32
+
+#define ERROR(str)\
+fprintf(stderr, "%s\n", str); \
+exit(1);
+
+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* allocate_memory(size_t size)
+{
+void *ptr = malloc(size);
+if (ptr == NULL){
+fprintf(stderr, "failed to allocate memory!\n");
+exit(1);
+}
+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)
+{
+int i, planes;
+int samples= FFMIN(nb_samples, afifo->nb_samples);
+int tot_elements   = !(planes = av_sample_fmt_is_planar(a

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

2016-12-15 Thread Thomas Turner
Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 libavutil/Makefile   |   1 +
 libavutil/tests/audio_fifo.c | 210 +++
 tests/fate/libavutil.mak |   4 +
 tests/ref/fate/audio_fifo| 228 +++
 4 files changed, 443 insertions(+)
 create mode 100644 libavutil/tests/audio_fifo.c
 create mode 100644 tests/ref/fate/audio_fifo

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..e3a3484
--- /dev/null
+++ b/libavutil/tests/audio_fifo.c
@@ -0,0 +1,210 @@
+/*
+ * 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 "libavutil/audio_fifo.c"
+#include "../audio_fifo.c"
+#include "libavutil/audio_fifo.h"
+#include "libavutil/error.h"
+
+#define MAX_CHANNELS32
+
+
+typedef struct TestStruct {
+const char *message;
+const enum AVSampleFormat format;
+const int nb_ch;
+void *data_planes[MAX_CHANNELS];
+int nb_samples_pch;
+} TestStruct;
+
+static uint8_t data_U8 [] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11  
  };
+static int16_t data_S16[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11  
  };
+static 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 int is_little_endian(void)
+{
+const unsigned int i = 1;
+return *(uint8_t*)
+}
+
+static void* allocate_memory(size_t size)
+{
+void *ptr = malloc(size);
+if (ptr == NULL){
+fprintf(stderr, "failed to allocate memory!\n");
+exit(1);
+}
+return ptr;
+}
+
+static void print_audio_bytes(const TestStruct *test_sample, void 
**data_planes, int nb_samples)
+{
+int p, b, f;
+int e= is_little_endian();
+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 = e ? (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)
+{
+int i, planes;
+int samples= FFMIN(nb_samples, afifo-&g

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

2016-12-05 Thread Thomas Turner
Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 libavcodec/Makefile |   3 +-
 libavcodec/tests/avpacket.c | 128 
 tests/fate/libavcodec.mak   |   5 ++
 3 files changed, 135 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/tests/avpacket.c

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() < 0){
+printf("failed to initialize variables\n");
+return 1;
+}
+/* test av_packet_clone*/
+avpkt_clone = av_packet_clone();
+
+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 to return error "
+"when \"size\" parameter is too large.\n" );
+ret = 1;
+}
+/*test size error check in av_packet_from_data*/
+if(av_packet_from_data(avpkt_clone, avpkt_clone->data, INT_MAX) == 0){
+print

[FFmpeg-devel] [PATCH] libavcodec/tests: Added test for libavcodec/avpacket.c

2016-11-07 Thread Thomas Turner
Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 libavcodec/Makefile |   3 +-
 libavcodec/tests/avpacket.c | 134 
 tests/fate/libavcodec.mak   |   5 ++
 3 files changed, 141 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/tests/avpacket.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index f1d5bf1..46e3af7 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1019,7 +1019,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..4826522
--- /dev/null
+++ b/libavcodec/tests/avpacket.c
@@ -0,0 +1,134 @@
+/*
+ * 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));
+return 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 1;
+}
+
+return 0;
+}
+
+static int initializations(AVPacket* avpkt)
+{
+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 = data;
+avpkt->size = strlen(data);
+avpkt->flags = AV_PKT_FLAG_DISCARD;
+avpkt->duration = 100;
+avpkt->pos = 3;
+
+if(setup_side_data_entry(avpkt))
+ret = 1;
+
+return ret;
+}
+
+int main(void)
+{
+AVPacket avpkt;
+AVPacket *avpkt_clone = NULL;
+int ret = 0;
+
+if(initializations()){
+printf("failed to initialize variables\n");
+return 1;
+}
+
+/* test av_packet_clone*/
+avpkt_clone = av_packet_clone();
+
+if(!avpkt_clone) {
+av_log(NULL, AV_LOG_ERROR,"av_packet_clone failed to clone 
AVPacket\n");
+return 1;
+}
+/* test size error check in av_new_packet*/
+if(av_new_packet(avpkt_clone, INT_MAX) == 0){
+printf( "av_new_packet failed to return error "
+"when \"size\" parameter is too large.\n" );
+ret = 1;
+}
+
+/*test av_grow_packet*/
+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;
+}
+if(av_grow_packet(avpkt_clone, 20) < 0){
+av_log(NULL, AV_LOG_ERROR, "av_grow_packet failed\n");
+return 1;
+}
+
+/*test av_packet_from_data*/
+if(av_packet_from_data(avpkt_clone, avpkt_clone->data, INT_MAX) == 0){
+printf(&qu

[FFmpeg-devel] [PATCH] libavcodec/tests: Added test for libavcodec/avpacket.c

2016-11-03 Thread Thomas Turner
Function(s) Tested: av_packet_clone().

This test checks if av_packet_clone() can successfully make a copy of an
AVPacket. Compares all data members in AVPacket EXCEPT for "buf" because "buf" 
is
initialized to NIL in the original AVPacket [to be cloned].

Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 libavcodec/Makefile |   3 +-
 libavcodec/tests/avpacket.c | 205 
 tests/fate/libavcodec.mak   |   5 ++
 3 files changed, 212 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/tests/avpacket.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index f1d5bf1..46e3af7 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1019,7 +1019,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..784a5a4
--- /dev/null
+++ b/libavcodec/tests/avpacket.c
@@ -0,0 +1,205 @@
+/*
+ * 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 const char* str = "Error @";
+
+static int compare_AVPacketsSideData(AVPacketSideData* sdata1,
+ AVPacketSideData* sdata2)
+{
+int ret = 0;
+
+if(!sdata1 || !sdata2)
+return;
+av_log(NULL, AV_LOG_INFO, "Comparing sidedata data memebers...\n");
+
+if(sdata1->size != sdata2->size){
+fprintf(stderr, "%s size\n", str);
+ret = 1;
+}
+if(sdata1->size > 0){
+if(memcmp(sdata1->data, sdata2->data, sdata1->size) != 0){
+fprintf(stderr, "%s data\n", str);
+ret = 1;
+}
+}
+else {
+av_log(NULL, AV_LOG_INFO, "size is <= 0");
+ret = 1;
+}
+if(sdata1->type != sdata2->type){
+fprintf(stderr, "%s type\n", str);
+ret = 1;
+}
+return ret;
+}
+
+static int compare_AVPackets(AVPacket* p1, AVPacket* p2)
+{
+int ret = 0;
+
+if(!p1 || !p2)
+return;
+
+av_log(NULL, AV_LOG_INFO, "Comparing AVPacket data memebers...\n");
+
+if(p1->size != p2->size){
+fprintf(stderr, "%s size\n", str);
+ret = 1;
+}
+if(p1->size > 0){
+if(memcmp(p1->data, p2->data, p1->size) != 0){
+fprintf(stderr, "%s data\n", str);
+ret = 1;
+}
+}
+else {
+av_log(NULL, AV_LOG_INFO, "size is <= 0");
+ret = 1;
+}
+if(p1->pts != p2->pts){
+fprintf(stderr, "%s pts\n", str);
+ret = 1;
+}
+if(p1->dts != p2->dts){
+fprintf(stderr, "%s dts\n", str);
+ret = 1;
+}
+if(p1->stream_index != p2->stream_index){
+fprintf(stderr, "%s stream_index\n", str);
+ret = 1;
+}
+if(p1->flags != p2->flags){
+fprintf(stderr, "%s flags\n", str);
+ret = 1;
+}
+if(p1->side_data_elems != p2->side_data_elems){
+fprintf(stderr, "%s side_data_elems\n", str);
+ret = 1;
+}
+if(p1->duration != p2->duration){
+fprintf(stderr, "%s duration\n", str);
+ret = 1;
+}
+if(p1->pos != p2->pos){
+fprintf(stderr, "%s pos\n", str);
+ret = 1;
+}
+
+if(compare_AVPacketsSideData(p1->side_data, p2->s

[FFmpeg-devel] [PATCH] libavcodec/tests: Added test for libavcodec/avpacket.c

2016-10-23 Thread Thomas Turner
Function(s) Tested: av_packet_clone().

This test checks if av_packet_clone() can successfully make a copy of an 
AVPacket.
Compares all data members in AVPacket EXCEPT for "buf" because "buf" is 
initialized
to NIL in the original AVPacket [to be cloned].

This test also prints out the all the contents of the original and cloned 
AVPackets.

Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 libavcodec/Makefile |   3 +-
 libavcodec/tests/avpacket.c | 303 
 tests/fate/libavcodec.mak   |   5 +
 3 files changed, 310 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/tests/avpacket.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index f1d5bf1..46e3af7 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1019,7 +1019,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..752cf3c
--- /dev/null
+++ b/libavcodec/tests/avpacket.c
@@ -0,0 +1,303 @@
+/*
+ * 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"
+
+
+
+
+#define AVPACKET_FIELDS \
+X(static AVBufferRef*, buf, "%p")   \
+X(static int64_t, pts, "%" PRId64)  \
+X(static int64_t, dts, "%" PRId64)  \
+X(static uint8_t*, data, "%p")  \
+X(static int, size, "%d")   \
+X(static int, stream_index, "%d")   \
+X(static int, flags, "%d")  \
+X(static AVPacketSideData*, side_data, "%p")\
+X(static int, side_data_elems, "%d")\
+X(static int64_t, duration, "%" PRId64) \
+X(static int64_t, pos, "%" PRId64)
+
+#define AVBUFFERREF_FIELDS  \
+Y(static AVBuffer*, buffer, "%p")   \
+Y(static uint8_t*, data, "%p")  \
+Y(static int, size, "%d")
+
+#define AVPACKETSIDEDATA_FIELDS \
+Z(static uint8_t*, data, "%p")  \
+Z(static int, size, "%d")   \
+Z(static enum AVPacketSideDataType, type, "%d")
+
+
+
+
+#define AV_MESSAGE_1(format, name, p1, p2)  \
+do {\
+const char* str = "cloned variable \"%s\" equals " format   \
+" but should be " format "\n";  \
+av_log(NULL, AV_LOG_ERROR, str, #name, p2->name, p1->name );\
+} while (0)
+
+#define AV_MESSAGE_2(name, p1, p2)  \
+do {\
+const char* str = "contents of cloned variable "\
+"%s equals \"%.*s\"\nbut should be \"%.*s\"\n"; \
+av_log(NULL, AV_LOG_ERROR, str, #name, p1->size,\
+p2->data, p1->size, p1->data);  \
+} while(0)
+
+#define AV_MESSAGE_3(name) 

[FFmpeg-devel] [PATCH] libavcodec/tests: Added test for libavcodec/avpacket.c

2016-10-23 Thread Thomas Turner
Function(s) Tested: av_packet_clone().

This test checks if av_packet_clone() can successfully make a copy of an 
AVPacket.
Compares all data members in AVPacket EXCEPT for "buf" because "buf" is 
initialized
to NIL in the original AVPacket [to be cloned].

This test also prints out the all the contents of the original and cloned 
AVPackets.

Signed-off-by: Thomas Turner <thomas...@googlemail.com>
---
 libavcodec/Makefile   |   3 ++-
 libavcodec/tests/avpacket | Bin 0 -> 70467 bytes
 tests/fate/libavcodec.mak |   5 +
 3 files changed, 7 insertions(+), 1 deletion(-)
 create mode 100755 libavcodec/tests/avpacket

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index f1d5bf1..46e3af7 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1019,7 +1019,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 b/libavcodec/tests/avpacket
new file mode 100755
index 
..15773ee8dc801aeb4fac7a84ef13c60247e39164
GIT binary patch
literal 70467
zcmd443w#vS**`v;i!2zOs8NGbS#^=5+!8^}3dj!G4YRnbsetfSDa0jc<Q9`zf(0RT
zcMIdVN?U8It*y1beQmX`wzU*cA)7!Fus{L|2+B>ASypbMNkCzL-{+i}-A#bn-~WC8
z|Ia^4X3m*`&$(oY+gp}lu?Xf*hH#fasek4TDRq>)!5^cI}L4Z`)p
zCCJIfKPUS_PyS{;yNssIr`0HziDwr6m1OXYk_;z%F`xZ-wqQO@2<b`vrGA{oD}TCn
z@}&6`1RKksdIanKk69AW>FmXPwh}=2dBg<Js7K)L6(mr>7r3I_b<)2vQoqkj{P
z?-MheNKx8J55dKLr=C=ne#$>pX3+cWzp^BrPWECx-!clCPqW_lP><mJcYkt?g7+Ey
zT?{Wa1Ag;Kc%+|Uv#TDueZ;WYGltBrnj2U!WI@U8Lv9~2w07RmTiLj=H@k
zp@-nh$3KEO5B~_|^!-@Nig{gs8q)Ic(Zr$ubgz7{y?M%=)NKL_>ycw47_(C
z1EtRYc@`C~JU?4_`6BtpFOq-bMe;92+qMg|f7eCI6Z{u~XTwGE-51HXUL^l77s;;&
zj2G%Rc9Hx&7s;=?Nc-N4<PW__{`W7EKky>?A73Q@p^M}{dJ*_{T%`O!l(*qu~nQ
zQvMwjybwM^7b)NOBKfN>l7HJp@^44Kww^#DJp=zP1ka(1<X2s!{gW3dKOXru{OkGi
z95OD{?}UrA|Hq4z{}sw#A@mg*4oqiVnEF$Iewjn+<aS}2XQFS~jLMqIhpTFp%9@G3
z(%JLoR!*#VXm+JAZQ8?g=FOc}t5nn|)20d2#?PO2pHZ%Kc13M%Wi79M!OAmd~x
z%(gP)*%cE05GvR?MJIiv%MvZB9U`T!7wdm6~~v_sFf9Tcz~Knmx}yt4CH~F3Us*
zem

[FFmpeg-devel] [PATCH] libavcodec/tests: Added test for libavcodec/avpacket.c

2016-10-18 Thread Thomas Turner
Improved code coverage for libavcodec
Function(s) Tested: av_packet_clone()

Signed-off-by: Thomas Turner <thomas...@gmail.com>
---
 libavcodec/Makefile |   3 +-
 libavcodec/tests/avpacket.c | 254 
 tests/fate/libavcodec.mak   |   5 +
 3 files changed, 261 insertions(+), 1 deletion(-)
 create mode 100644 libavcodec/tests/avpacket.c

diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index a1560ba..d64b8df 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -1016,7 +1016,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..67ec71b
--- /dev/null
+++ b/libavcodec/tests/avpacket.c
@@ -0,0 +1,254 @@
+/*
+ * 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 char* getbuffer(AVPacket avpkt, int index)
+{
+uint8_t *buffer;
+int val, buffer_size = 256;
+
+/* Allocate 256 bytes */
+if((buffer = malloc(buffer_size)) == NULL){
+perror("malloc");
+goto EXIT;
+}
+
+if(index == 0){
+val = snprintf(buffer, buffer_size,
+"{buffer: %p,  data: %p, size: %d}",
+avpkt.buf->buffer, avpkt.buf->data, avpkt.buf->size);
+}
+else if(index == 1){
+val = snprintf(buffer, buffer_size, "\"%s\"", avpkt.data);
+}
+else if(index == 2){
+val = snprintf(buffer, buffer_size,
+"{data: %p \"%s\", size: %d, type: %d}",
+avpkt.side_data, avpkt.side_data->data, avpkt.side_data->size,
+avpkt.side_data->type);
+}
+
+/* snprintf fail check */
+if(!(val > -1 && val < buffer_size)){
+perror("snprintf");
+free(buffer);
+goto EXIT;
+}
+
+return buffer;
+
+EXIT:
+exit(-1);
+}
+
+static void log_avpacket(AVPacket avpkt, const char* message)
+{
+uint8_t *buf_info = 0, *data_info = 0, *side_info = 0;
+
+/* get buf information */
+if(avpkt.buf){
+buf_info = getbuffer(avpkt, 0);
+}
+
+/* get data information */
+if(avpkt.data){
+data_info = getbuffer(avpkt, 1);
+}
+
+/* get side data information */
+if(avpkt.side_data){
+side_info = getbuffer(avpkt, 2);
+}
+
+/* log standard packet information */
+av_log(NULL, AV_LOG_INFO,
+   "\n%s:\n\n"
+   "buf\t\t: %p "
+   "%s\n"
+   "pts\t\t: %" PRId64 "\n"
+   "dts\t\t: %" PRId64 "\n"
+   "data\t\t: %p "
+   "%s\n"
+   "size\t\t: %d\n"
+   "stream_index\t: %d\n"
+   "flags\t\t: %d\n"
+   "side_data\t: %p "
+   "%s\n"
+   "side_data_elems\t: %d\n"
+   "duration\t: %" PRId64 "\n"
+   "pos\t\t: %" PRId64 "\n\n",
+   message,
+   avpkt.buf,
+   buf_info ? (char*)buf_info : "",
+   avpkt.pts,
+   avpkt.dts,
+   avpkt.data,
+   data_info,
+   avpkt.size,
+   avpkt.stream_index,
+   avpkt.flags,
+   avpkt.side_data,
+   side_info,
+   avpkt.side_data_elems,
+   avpkt.duration,
+   avpkt.pos
+);
+

[FFmpeg-devel] [PATCH] Improved selftest coverage for libavutil/fifo.c

2016-10-14 Thread Thomas Turner
Tested functions: av_fifo_generic_peek(), av_fifo_grow()

Signed-off-by: Thomas Turner <thomas...@gmail.com>
---
 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..63e25c8 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, , sizeof(int), NULL);
@@ -67,8 +85,25 @@ int main(void)
 av_fifo_generic_peek_at(fifo, , 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, , 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, , 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
-- 
1.9.1

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


[FFmpeg-devel] [PATCH] Improved selftest coverage for libavutil/fifo.c

2016-10-13 Thread Thomas Turner
Tested functions: av_fifo_generic_peek(), av_fifo_grow()
---
 libavutil/tests/fifo.c | 32 +++-
 tests/ref/fate/fifo| 43 +++
 2 files changed, 74 insertions(+), 1 deletion(-)

diff --git a/libavutil/tests/fifo.c b/libavutil/tests/fifo.c
index e4d7edf..4d598d3 100644
--- a/libavutil/tests/fifo.c
+++ b/libavutil/tests/fifo.c
@@ -24,7 +24,7 @@ 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,19 @@ int main(void)
 }
 printf("\n");
 
+/* generic peek at FIFO */
+
+n = av_fifo_size(fifo);
+p = malloc(n);
+(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, , sizeof(int), NULL);
@@ -67,8 +80,25 @@ int main(void)
 av_fifo_generic_peek_at(fifo, , 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, , 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, , 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
-- 
1.9.1

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


[FFmpeg-devel] [PATCH 3/3] Selftest coverage for libavutil/fifo.c

2016-10-12 Thread Thomas Turner
Fixed trailing whitespace in fifo2.c selftest and fifo2 reference file that
prevented the patch from being applied cleanly to git master

---
 libavutil/tests/fifo2.c | 17 +
 tests/ref/fate/fifo2|  6 +++---
 2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/libavutil/tests/fifo2.c b/libavutil/tests/fifo2.c
index e40b8cd..11050c6 100644
--- a/libavutil/tests/fifo2.c
+++ b/libavutil/tests/fifo2.c
@@ -30,12 +30,13 @@ int main(void)
 int32_t elem[] = {0, 2, 4, 6, 8, 10, 12};
 AVFifoBuffer* fifo;
 
-data_size = sizeof(elem[0]);
-fifo = av_fifo_alloc(sizeof(elem));
-
 /*fill fifo buffer*/
 
-if (av_fifo_generic_write(fifo, (void*)elem, av_fifo_space(fifo), NULL) != 
+data_size = sizeof(elem[0]);
+fifo = av_fifo_alloc(sizeof(elem));
+space_size = av_fifo_space(fifo);
+
+if (av_fifo_generic_write(fifo, (void*)elem, space_size, NULL) !=
 sizeof(elem)) {
 
 fprintf(stderr, "written incorrect number of bytes\n");
@@ -50,13 +51,13 @@ int main(void)
 
 (void) av_fifo_generic_peek(fifo, data_arr, fifo_size, NULL);
 
-printf("fifo->buffer: ");
+printf("fifo->buffer\t\t\t:");
 for(offset = 0; offset < fifo_size/data_size; ++offset){
-printf("%" PRId32 ", ", data_arr[offset]);
+printf(" %" PRId32 ",", data_arr[offset]);
 }
 
 space_size = av_fifo_space(fifo);
-printf("\nspace before av_fifo_grow\t:%" PRId16 "\n", space_size);
+printf("\nspace before av_fifo_grow\t: %" PRId16 "\n", space_size);
 
 /* grow AVFifoBuffer */
 
@@ -66,7 +67,7 @@ int main(void)
 
 
 space_size = av_fifo_space(fifo);
-printf("space after av_fifo_grow\t:%" PRId16 "\n", space_size);
+printf("space after av_fifo_grow\t: %" PRId16 "\n", space_size);
 
 
 /* free AVFifoBuffer and data_arr */
diff --git a/tests/ref/fate/fifo2 b/tests/ref/fate/fifo2
index 8df9243..b697c03 100644
--- a/tests/ref/fate/fifo2
+++ b/tests/ref/fate/fifo2
@@ -1,3 +1,3 @@
-fifo->buffer: 0, 2, 4, 6, 8, 10, 12, 
-space before av_fifo_grow  :0
-space after av_fifo_grow   :28
+fifo->buffer: 0, 2, 4, 6, 8, 10, 12,
+space before av_fifo_grow  : 0
+space after av_fifo_grow   : 28
-- 
1.9.1

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


[FFmpeg-devel] [PATCH 1/3] Improve selftest coverage for libavutil library

2016-10-12 Thread Thomas Turner
Code coverage for av_fifo_generic_peek(...) and av_fifo_grow(...) .
---
 libavutil/tests/fifo2.c | 77 +
 1 file changed, 77 insertions(+)
 create mode 100644 libavutil/tests/fifo2.c

diff --git a/libavutil/tests/fifo2.c b/libavutil/tests/fifo2.c
new file mode 100644
index 000..923feee
--- /dev/null
+++ b/libavutil/tests/fifo2.c
@@ -0,0 +1,77 @@
+/*
+ * 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 "libavutil/fifo.h"
+
+
+
+int main(void)
+{
+
+int16_t offset, fifo_size, space_size, data_size;
+int32_t data, *data_arr;
+int32_t elem[] = {0, 2, 4, 6, 8, 10, 12};
+AVFifoBuffer* fifo;
+
+data_size = sizeof(elem[0]);
+fifo = av_fifo_alloc(sizeof(elem));
+
+/*fill fifo buffer*/
+
+if (av_fifo_generic_write(fifo, (void*)elem, av_fifo_space(fifo), NULL) != 
sizeof(elem)) {
+
+fprintf(stderr, "written incorrect number of bytes\n");
+return 1;
+}
+
+
+/* generic peek at fifo */
+
+fifo_size = av_fifo_size(fifo);
+data_arr = (int32_t*)malloc(fifo_size);
+
+(void) av_fifo_generic_peek(fifo, data_arr, fifo_size, NULL);
+
+printf("fifo->buffer: ");
+for(offset = 0; offset < fifo_size/data_size; ++offset){
+printf("%" PRId32 ", ", data_arr[offset]);
+}
+
+space_size = av_fifo_space(fifo);
+printf("\nspace before av_fifo_grow\t:%" PRId16 "\n", space_size);
+
+/* grow AVFifoBuffer */
+
+data = av_fifo_grow(fifo, data_size);
+if(data < 0)
+printf("\n%s\n", "failure growing fifo\n");
+
+
+space_size = av_fifo_space(fifo);
+printf("space after av_fifo_grow\t:%" PRId16 "\n", space_size);
+
+
+/* free AVFifoBuffer and data_arr */
+
+av_fifo_free(fifo);
+free(data_arr);
+
+return 0;
+}
-- 
1.9.1

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


[FFmpeg-devel] [PATCH 2/3] Selftest coverage for libavutil/fifo.c

2016-10-12 Thread Thomas Turner
code coverage for av_fifo_grow(...), av_fifo_generic_peek(...)

Modified the folling files to get the selftest program to compile with:
"make fate-fifo2"
---
 libavutil/Makefile   | 1 +
 libavutil/tests/fifo2.c  | 3 ++-
 tests/fate/libavutil.mak | 4 
 tests/ref/fate/fifo2 | 3 +++
 4 files changed, 10 insertions(+), 1 deletion(-)
 create mode 100644 tests/ref/fate/fifo2

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 0fa90fe..a34171e 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -195,6 +195,7 @@ TESTPROGS = adler32 
\
 eval\
 file\
 fifo\
+fifo2   \
 float_dsp   \
 hash\
 hmac\
diff --git a/libavutil/tests/fifo2.c b/libavutil/tests/fifo2.c
index 923feee..e40b8cd 100644
--- a/libavutil/tests/fifo2.c
+++ b/libavutil/tests/fifo2.c
@@ -35,7 +35,8 @@ int main(void)
 
 /*fill fifo buffer*/
 
-if (av_fifo_generic_write(fifo, (void*)elem, av_fifo_space(fifo), NULL) != 
sizeof(elem)) {
+if (av_fifo_generic_write(fifo, (void*)elem, av_fifo_space(fifo), NULL) != 
+sizeof(elem)) {
 
 fprintf(stderr, "written incorrect number of bytes\n");
 return 1;
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index 6fbad64..fdf9086 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -69,6 +69,10 @@ FATE_LIBAVUTIL += fate-fifo
 fate-fifo: libavutil/tests/fifo$(EXESUF)
 fate-fifo: CMD = run libavutil/tests/fifo
 
+FATE_LIBAVUTIL += fate-fifo2
+fate-fifo2: libavutil/tests/fifo2$(EXESUF)
+fate-fifo2: CMD = run libavutil/tests/fifo2
+
 FATE_LIBAVUTIL += fate-float-dsp
 fate-float-dsp: libavutil/tests/float_dsp$(EXESUF)
 fate-float-dsp: CMD = run libavutil/tests/float_dsp $(CPUFLAGS:%=-c%)
diff --git a/tests/ref/fate/fifo2 b/tests/ref/fate/fifo2
new file mode 100644
index 000..8df9243
--- /dev/null
+++ b/tests/ref/fate/fifo2
@@ -0,0 +1,3 @@
+fifo->buffer: 0, 2, 4, 6, 8, 10, 12, 
+space before av_fifo_grow  :0
+space after av_fifo_grow   :28
-- 
1.9.1

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


[FFmpeg-devel] [PATCH] Selftest coverage for libavutil/fifo.c

2016-10-10 Thread Thomas Turner
code coverage for av_fifo_grow(...), av_fifo_generic_peek(...)
---
 libavutil/Makefile   | 1 +
 libavutil/tests/fifo2.c  | 3 ++-
 tests/fate/libavutil.mak | 4 
 tests/ref/fate/fifo2 | 3 +++
 4 files changed, 10 insertions(+), 1 deletion(-)
 create mode 100644 tests/ref/fate/fifo2

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 0fa90fe..a34171e 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -195,6 +195,7 @@ TESTPROGS = adler32 
\
 eval\
 file\
 fifo\
+fifo2   \
 float_dsp   \
 hash\
 hmac\
diff --git a/libavutil/tests/fifo2.c b/libavutil/tests/fifo2.c
index 923feee..e40b8cd 100644
--- a/libavutil/tests/fifo2.c
+++ b/libavutil/tests/fifo2.c
@@ -35,7 +35,8 @@ int main(void)
 
 /*fill fifo buffer*/
 
-if (av_fifo_generic_write(fifo, (void*)elem, av_fifo_space(fifo), NULL) != 
sizeof(elem)) {
+if (av_fifo_generic_write(fifo, (void*)elem, av_fifo_space(fifo), NULL) != 
+sizeof(elem)) {
 
 fprintf(stderr, "written incorrect number of bytes\n");
 return 1;
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index 6fbad64..fdf9086 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -69,6 +69,10 @@ FATE_LIBAVUTIL += fate-fifo
 fate-fifo: libavutil/tests/fifo$(EXESUF)
 fate-fifo: CMD = run libavutil/tests/fifo
 
+FATE_LIBAVUTIL += fate-fifo2
+fate-fifo2: libavutil/tests/fifo2$(EXESUF)
+fate-fifo2: CMD = run libavutil/tests/fifo2
+
 FATE_LIBAVUTIL += fate-float-dsp
 fate-float-dsp: libavutil/tests/float_dsp$(EXESUF)
 fate-float-dsp: CMD = run libavutil/tests/float_dsp $(CPUFLAGS:%=-c%)
diff --git a/tests/ref/fate/fifo2 b/tests/ref/fate/fifo2
new file mode 100644
index 000..8df9243
--- /dev/null
+++ b/tests/ref/fate/fifo2
@@ -0,0 +1,3 @@
+fifo->buffer: 0, 2, 4, 6, 8, 10, 12, 
+space before av_fifo_grow  :0
+space after av_fifo_grow   :28
-- 
1.9.1

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