[FFmpeg-devel] libavutil/aes_ctr.c

2016-03-11 Thread NagaChaitanya Vellanki
Need guidance on getting started to write tests for libavutil/aes_ctr.c.

Thank you,
Naga
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add tests for functions in hash.c

2016-03-10 Thread NagaChaitanya Vellanki
Hi Reimar,
Will send in a new patch with the improvements for review :-).

Thank you,
Naga

On Wed, Mar 9, 2016 at 11:05 AM, Reimar Döffinger <reimar.doeffin...@gmx.de>
wrote:

> On Wed, Mar 09, 2016 at 10:27:29AM -0800, NagaChaitanya Vellanki wrote:
> > On Tue, Mar 8, 2016 at 5:33 PM, James Almer <jamr...@gmail.com> wrote:
> >
> > > On 3/8/2016 2:21 AM, NagaChaitanya Vellanki wrote:
> > > > ---
> > > >  libavutil/Makefile   |  1 +
> > > >  libavutil/hash.c | 42
> ++
> > > >  tests/fate/libavutil.mak |  4 
> > > >  tests/ref/fate/hash  | 45
> > > +
> > > >  4 files changed, 92 insertions(+)
> > > >  create mode 100644 tests/ref/fate/hash
> > >
> > > LGTM. I'll let the maintainer give the final ok and push it (CCing him
> as
> > > well).
>
> It looks fine to me, though there are a few things that could
> be improved if wanted.
> For example all-0s for src is a bit boring, just a
> couple of random numbers would be a better test.
> At 64 bytes it is also a bit short, for some hashes that
> would mean the same size as the hash, and thus some
> parts of the algorithm would never ever run.
> A power-of-two size also means the padding special-cases
> are not tested.
> Something like e.g. 133 bytes might be a better test
> (assuming all our hashes support that as input?
> I actually have no idea who is responsible for padding).
> As we are testing things, changing the memset to
> not 0 but e.g. 'a' would ensure that we would notice
> if someone broke then 0-termination of the string,
> and it should then also be run before the av_hash_final_b64.
> But regardless of that it is great to have a test,
> these are just some improvement ideas that also
> can be added later.
> ___
> 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] Add tests for functions in hash.c

2016-03-09 Thread NagaChaitanya Vellanki
Ping Michael to review to patch.


Thank you,
Naga

On Tue, Mar 8, 2016 at 5:33 PM, James Almer <jamr...@gmail.com> wrote:

> On 3/8/2016 2:21 AM, NagaChaitanya Vellanki wrote:
> > ---
> >  libavutil/Makefile   |  1 +
> >  libavutil/hash.c | 42 ++
> >  tests/fate/libavutil.mak |  4 
> >  tests/ref/fate/hash  | 45
> +
> >  4 files changed, 92 insertions(+)
> >  create mode 100644 tests/ref/fate/hash
>
> LGTM. I'll let the maintainer give the final ok and push it (CCing him as
> well).
>
> ___
> 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] Add tests for functions in hash.c

2016-03-09 Thread NagaChaitanya Vellanki
I wont qualify for GSoC because i am full time employed and a part time
student.

Thank you,
Naga

On Sun, Mar 6, 2016 at 3:26 PM, Michael Niedermayer <mich...@niedermayer.cc>
wrote:

> On Sun, Mar 06, 2016 at 11:27:59AM -0800, NagaChaitanya Vellanki wrote:
> > Please review the patch.
> >
> > NagaChaitanya Vellanki (1):
> >   Add tests for functions in hash.c
>
> btw, if this is a qualification task for GSoC or Outreachy then
> please add yourself to
> https://trac.ffmpeg.org/wiki/SponsoringPrograms/GSoC/2016-Qualis
>
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> No snowflake in an avalanche ever feels responsible. -- Voltaire
>
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


Re: [FFmpeg-devel] [PATCH] Add tests for functions in hash.c

2016-03-08 Thread NagaChaitanya Vellanki
Please review the latest patch. the DST_BUF_SIZE is not AV_HASH_MAX_SIZE *
8 since AV_HASH_MAX_SIZE is 64.

Thank you,
Naga

On Sun, Mar 6, 2016 at 9:45 PM, James Almer <jamr...@gmail.com> wrote:

> On 3/7/2016 12:26 AM, NagaChaitanya Vellanki wrote:
> > ---
> >  libavutil/Makefile   |  1 +
> >  libavutil/hash.c | 45
> +
> >  tests/fate/libavutil.mak |  4 
> >  tests/ref/fate/hash  | 45
> +
> >  4 files changed, 95 insertions(+)
> >  create mode 100644 tests/ref/fate/hash
> >
> > diff --git a/libavutil/Makefile b/libavutil/Makefile
> > index 934564f..58df75a 100644
> > --- a/libavutil/Makefile
> > +++ b/libavutil/Makefile
> > @@ -186,6 +186,7 @@ TESTPROGS = adler32
>\
> >  file
> \
> >  fifo
> \
> >  float_dsp
>  \
> > +hash
> \
> >  hmac
> \
> >  lfg
>  \
> >  lls
>  \
> > diff --git a/libavutil/hash.c b/libavutil/hash.c
> > index 7037b0d..ac35e88 100644
> > --- a/libavutil/hash.c
> > +++ b/libavutil/hash.c
> > @@ -237,3 +237,48 @@ void av_hash_freep(AVHashContext **ctx)
> >  av_freep(&(*ctx)->ctx);
> >  av_freep(ctx);
> >  }
> > +
> > +#ifdef TEST
> > +// LCOV_EXCL_START
> > +#define SRC_BUF_SIZE 64
> > +#define DST_BUF_SIZE 512
>
> You should use AV_HASH_MAX_SIZE for dst. If someone goes and adds a new
> algorithm
> with a digest bigger than 64 bytes that value will change and the dst
> buffer here
> may not be enough anymore.
> AV_HASH_MAX_SIZE*4 should do it i think.
>
> > +
> > +int main(void)
> > +{
> > +   struct AVHashContext *ctx = NULL;
> > +   int i, j;
> > +   static const uint8_t src[SRC_BUF_SIZE] = { 0 };
> > +   uint8_t dst[DST_BUF_SIZE];
> > +   for(i = 0; i < NUM_HASHES; i++) {
>
> Nit: Space after for.
>
> > +   if(av_hash_alloc(, av_hash_names(i)) < 0) {
>
> Nit: Space after if, and no need for brackets.
>
> > +   return 1;
> > +   }
> > +
> > +   av_hash_init(ctx);
> > +   av_hash_update(ctx, src, SRC_BUF_SIZE);
> > +   memset(dst, 0, DST_BUF_SIZE);
>
> memset (or even zero initializing dst) is probably not needed at all.
> hash.h doxy says hex and b64 digests are always 0-terminated, and you never
> read more than av_hash_get_size(ctx) for the binary digest.
>
> > +   av_hash_final_hex(ctx, dst, DST_BUF_SIZE);
> > +   printf("%s hex: %s\n", av_hash_get_name(ctx), dst);
> > +
> > +   av_hash_init(ctx);
> > +   av_hash_update(ctx, src, SRC_BUF_SIZE);
> > +   memset(dst, 0, DST_BUF_SIZE);
> > +   av_hash_final_bin(ctx, dst, DST_BUF_SIZE);
> > +   printf("%s bin: ", av_hash_get_name(ctx));
> > +   for(j = 0; j < av_hash_get_size(ctx); j++) {
>
> Nit: Space after for.
>
> > + printf("%#x ", dst[j]);
>
> Indentation should be four spaces.
>
> > +   }
> > +   printf("\n");
> > +
> > +   av_hash_init(ctx);
> > +   av_hash_update(ctx, src, SRC_BUF_SIZE);
> > +   memset(dst, 0, DST_BUF_SIZE);
> > +   av_hash_final_b64(ctx, dst, DST_BUF_SIZE);
> > +   printf("%s b64: %s\n", av_hash_get_name(ctx), dst);
> > +   av_hash_freep();
> > +   }
> > +   return 0;
> > +}
> > +
> > +// LCOV_EXCL_STOP
> > +#endif
>
> ___
> 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] Add tests for functions in hash.c

2016-03-07 Thread NagaChaitanya Vellanki
---
 libavutil/Makefile   |  1 +
 libavutil/hash.c | 42 ++
 tests/fate/libavutil.mak |  4 
 tests/ref/fate/hash  | 45 +
 4 files changed, 92 insertions(+)
 create mode 100644 tests/ref/fate/hash

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 934564f..58df75a 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -186,6 +186,7 @@ TESTPROGS = adler32 
\
 file\
 fifo\
 float_dsp   \
+hash\
 hmac\
 lfg \
 lls \
diff --git a/libavutil/hash.c b/libavutil/hash.c
index 7037b0d..e5452ba 100644
--- a/libavutil/hash.c
+++ b/libavutil/hash.c
@@ -237,3 +237,45 @@ void av_hash_freep(AVHashContext **ctx)
 av_freep(&(*ctx)->ctx);
 av_freep(ctx);
 }
+
+#ifdef TEST
+// LCOV_EXCL_START
+#define SRC_BUF_SIZE 64
+#define DST_BUF_SIZE (AV_HASH_MAX_SIZE * 8)
+
+int main(void)
+{
+   struct AVHashContext *ctx = NULL;
+   int i, j;
+   static const uint8_t src[SRC_BUF_SIZE] = { 0 };
+   uint8_t dst[DST_BUF_SIZE];
+   for (i = 0; i < NUM_HASHES; i++) {
+   if (av_hash_alloc(, av_hash_names(i)) < 0)
+   return 1;
+
+   av_hash_init(ctx);
+   av_hash_update(ctx, src, SRC_BUF_SIZE);
+   memset(dst, 0, DST_BUF_SIZE);
+   av_hash_final_hex(ctx, dst, DST_BUF_SIZE);
+   printf("%s hex: %s\n", av_hash_get_name(ctx), dst);
+
+   av_hash_init(ctx);
+   av_hash_update(ctx, src, SRC_BUF_SIZE);
+   av_hash_final_bin(ctx, dst, DST_BUF_SIZE);
+   printf("%s bin: ", av_hash_get_name(ctx));
+   for (j = 0; j < av_hash_get_size(ctx); j++) {
+   printf("%#x ", dst[j]);
+   }
+   printf("\n");
+
+   av_hash_init(ctx);
+   av_hash_update(ctx, src, SRC_BUF_SIZE);
+   av_hash_final_b64(ctx, dst, DST_BUF_SIZE);
+   printf("%s b64: %s\n", av_hash_get_name(ctx), dst);
+   av_hash_freep();
+   }
+   return 0;
+}
+
+// LCOV_EXCL_STOP
+#endif
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index a89bc1d..5d8e0e2 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -75,6 +75,10 @@ fate-float-dsp: CMD = run libavutil/float_dsp-test 
$(CPUFLAGS:%=-c%)
 fate-float-dsp: CMP = null
 fate-float-dsp: REF = /dev/null
 
+FATE_LIBAVUTIL += fate-hash
+fate-hash: libavutil/hash-test$(EXESUF)
+fate-hash: CMD = run libavutil/hash-test
+
 FATE_LIBAVUTIL += fate-hmac
 fate-hmac: libavutil/hmac-test$(EXESUF)
 fate-hmac: CMD = run libavutil/hmac-test
diff --git a/tests/ref/fate/hash b/tests/ref/fate/hash
new file mode 100644
index 000..6e5a580
--- /dev/null
+++ b/tests/ref/fate/hash
@@ -0,0 +1,45 @@
+MD5 hex: 3b5d3c7d207e37dceeedd301e35e2e58
+MD5 bin: 0x3b 0x5d 0x3c 0x7d 0x20 0x7e 0x37 0xdc 0xee 0xed 0xd3 0x1 0xe3 0x5e 
0x2e 0x58
+MD5 b64: O108fSB+N9zu7dMB414uWA==
+murmur3 hex: 6e484695e1d7b4e37d838791cc263395
+murmur3 bin: 0x6e 0x48 0x46 0x95 0xe1 0xd7 0xb4 0xe3 0x7d 0x83 0x87 0x91 0xcc 
0x26 0x33 0x95
+murmur3 b64: bkhGleHXtON9g4eRzCYzlQ==
+RIPEMD128 hex: 082bfa9b829ef3a9e220dcc54e4c6383
+RIPEMD128 bin: 0x8 0x2b 0xfa 0x9b 0x82 0x9e 0xf3 0xa9 0xe2 0x20 0xdc 0xc5 0x4e 
0x4c 0x63 0x83
+RIPEMD128 b64: CCv6m4Ke86niINzFTkxjgw==
+RIPEMD160 hex: 9b8ccc2f374ae313a914763cc9cdfb47bfe1c229
+RIPEMD160 bin: 0x9b 0x8c 0xcc 0x2f 0x37 0x4a 0xe3 0x13 0xa9 0x14 0x76 0x3c 
0xc9 0xcd 0xfb 0x47 0xbf 0xe1 0xc2 0x29
+RIPEMD160 b64: m4zMLzdK4xOpFHY8yc37R7/hwik=
+RIPEMD256 hex: 26ba693759787f275f47dd5ab16e78c2fcd763b004fd05fc554e354223d6eab5
+RIPEMD256 bin: 0x26 0xba 0x69 0x37 0x59 0x78 0x7f 0x27 0x5f 0x47 0xdd 0x5a 
0xb1 0x6e 0x78 0xc2 0xfc 0xd7 0x63 0xb0 0x4 0xfd 0x5 0xfc 0x55 0x4e 0x35 0x42 
0x23 0xd6 0xea 0xb5
+RIPEMD256 b64: JrppN1l4fydfR91asW54wvzXY7AE/QX8VU41QiPW6rU=
+RIPEMD320 hex: 
409a3111ffd3d4c8058ff5c231401c1d47210a5d22e6c90bf95d45c1c95c528463c69ce4bff3b884
+RIPEMD320 bin: 0x40 0x9a 0x31 0x11 0xff 0xd3 0xd4 0xc8 0x5 0x8f 0xf5 0xc2 0x31 
0x40 0x1c 0x1d 0x47 0x21 0xa 0x5d 0x22 0xe6 0xc9 0xb 0xf9 0x5d 0x45 0xc1 0xc9 
0x5c 0x52 0x84 0x63 0xc6 0x9c 0xe4 0xbf 0xf3 0xb8 0x84
+RIPEMD320 b64: QJoxEf/T1MgFj/XCMUAcHUchCl0i5skL+V1FwclcUoRjxpzkv/O4hA==
+SHA160 hex: c8d7d0ef0eedfa82d2ea1aa592845b9a6d4b02b7
+SHA160 bin: 0xc8 0xd7 0xd0 0xef 0xe 0xed 0xfa 0x82 0xd2 0xea 0x1a 0xa5 0x92 
0x84 0x5b 0x9a 0x6d 0x4b 0x2 0xb7
+SHA160 b64: yNfQ7w7t+oLS6hqlkoRbmm1LArc=
+SHA224 hex: 750d81a39c18d3ce27ff3e5ece30b0088f12d8fd0450fe435326294b
+SHA224 bin: 0x75 0xd 0x81 0xa3 0x9c 0x18 0xd3 0xce 0x27 0xff 0x3e 0x5e 0xce 
0x30 0xb0 0x8 0x8f 0x12 0xd8 0xfd 

[FFmpeg-devel] [PATCH] Add tests for functions in hash.c

2016-03-06 Thread NagaChaitanya Vellanki
---
 libavutil/Makefile   |  1 +
 libavutil/hash.c | 45 +
 tests/fate/libavutil.mak |  4 
 tests/ref/fate/hash  | 45 +
 4 files changed, 95 insertions(+)
 create mode 100644 tests/ref/fate/hash

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 934564f..58df75a 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -186,6 +186,7 @@ TESTPROGS = adler32 
\
 file\
 fifo\
 float_dsp   \
+hash\
 hmac\
 lfg \
 lls \
diff --git a/libavutil/hash.c b/libavutil/hash.c
index 7037b0d..ac35e88 100644
--- a/libavutil/hash.c
+++ b/libavutil/hash.c
@@ -237,3 +237,48 @@ void av_hash_freep(AVHashContext **ctx)
 av_freep(&(*ctx)->ctx);
 av_freep(ctx);
 }
+
+#ifdef TEST
+// LCOV_EXCL_START
+#define SRC_BUF_SIZE 64
+#define DST_BUF_SIZE 512
+
+int main(void)
+{
+   struct AVHashContext *ctx = NULL;
+   int i, j;
+   static const uint8_t src[SRC_BUF_SIZE] = { 0 };
+   uint8_t dst[DST_BUF_SIZE];
+   for(i = 0; i < NUM_HASHES; i++) {
+   if(av_hash_alloc(, av_hash_names(i)) < 0) {
+   return 1;
+   }
+
+   av_hash_init(ctx);
+   av_hash_update(ctx, src, SRC_BUF_SIZE);
+   memset(dst, 0, DST_BUF_SIZE);
+   av_hash_final_hex(ctx, dst, DST_BUF_SIZE);
+   printf("%s hex: %s\n", av_hash_get_name(ctx), dst);
+
+   av_hash_init(ctx);
+   av_hash_update(ctx, src, SRC_BUF_SIZE);
+   memset(dst, 0, DST_BUF_SIZE);
+   av_hash_final_bin(ctx, dst, DST_BUF_SIZE);
+   printf("%s bin: ", av_hash_get_name(ctx));
+   for(j = 0; j < av_hash_get_size(ctx); j++) {
+ printf("%#x ", dst[j]);
+   }
+   printf("\n");
+
+   av_hash_init(ctx);
+   av_hash_update(ctx, src, SRC_BUF_SIZE);
+   memset(dst, 0, DST_BUF_SIZE);
+   av_hash_final_b64(ctx, dst, DST_BUF_SIZE);
+   printf("%s b64: %s\n", av_hash_get_name(ctx), dst);
+   av_hash_freep();
+   }
+   return 0;
+}
+
+// LCOV_EXCL_STOP
+#endif
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index a89bc1d..5d8e0e2 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -75,6 +75,10 @@ fate-float-dsp: CMD = run libavutil/float_dsp-test 
$(CPUFLAGS:%=-c%)
 fate-float-dsp: CMP = null
 fate-float-dsp: REF = /dev/null
 
+FATE_LIBAVUTIL += fate-hash
+fate-hash: libavutil/hash-test$(EXESUF)
+fate-hash: CMD = run libavutil/hash-test
+
 FATE_LIBAVUTIL += fate-hmac
 fate-hmac: libavutil/hmac-test$(EXESUF)
 fate-hmac: CMD = run libavutil/hmac-test
diff --git a/tests/ref/fate/hash b/tests/ref/fate/hash
new file mode 100644
index 000..6e5a580
--- /dev/null
+++ b/tests/ref/fate/hash
@@ -0,0 +1,45 @@
+MD5 hex: 3b5d3c7d207e37dceeedd301e35e2e58
+MD5 bin: 0x3b 0x5d 0x3c 0x7d 0x20 0x7e 0x37 0xdc 0xee 0xed 0xd3 0x1 0xe3 0x5e 
0x2e 0x58
+MD5 b64: O108fSB+N9zu7dMB414uWA==
+murmur3 hex: 6e484695e1d7b4e37d838791cc263395
+murmur3 bin: 0x6e 0x48 0x46 0x95 0xe1 0xd7 0xb4 0xe3 0x7d 0x83 0x87 0x91 0xcc 
0x26 0x33 0x95
+murmur3 b64: bkhGleHXtON9g4eRzCYzlQ==
+RIPEMD128 hex: 082bfa9b829ef3a9e220dcc54e4c6383
+RIPEMD128 bin: 0x8 0x2b 0xfa 0x9b 0x82 0x9e 0xf3 0xa9 0xe2 0x20 0xdc 0xc5 0x4e 
0x4c 0x63 0x83
+RIPEMD128 b64: CCv6m4Ke86niINzFTkxjgw==
+RIPEMD160 hex: 9b8ccc2f374ae313a914763cc9cdfb47bfe1c229
+RIPEMD160 bin: 0x9b 0x8c 0xcc 0x2f 0x37 0x4a 0xe3 0x13 0xa9 0x14 0x76 0x3c 
0xc9 0xcd 0xfb 0x47 0xbf 0xe1 0xc2 0x29
+RIPEMD160 b64: m4zMLzdK4xOpFHY8yc37R7/hwik=
+RIPEMD256 hex: 26ba693759787f275f47dd5ab16e78c2fcd763b004fd05fc554e354223d6eab5
+RIPEMD256 bin: 0x26 0xba 0x69 0x37 0x59 0x78 0x7f 0x27 0x5f 0x47 0xdd 0x5a 
0xb1 0x6e 0x78 0xc2 0xfc 0xd7 0x63 0xb0 0x4 0xfd 0x5 0xfc 0x55 0x4e 0x35 0x42 
0x23 0xd6 0xea 0xb5
+RIPEMD256 b64: JrppN1l4fydfR91asW54wvzXY7AE/QX8VU41QiPW6rU=
+RIPEMD320 hex: 
409a3111ffd3d4c8058ff5c231401c1d47210a5d22e6c90bf95d45c1c95c528463c69ce4bff3b884
+RIPEMD320 bin: 0x40 0x9a 0x31 0x11 0xff 0xd3 0xd4 0xc8 0x5 0x8f 0xf5 0xc2 0x31 
0x40 0x1c 0x1d 0x47 0x21 0xa 0x5d 0x22 0xe6 0xc9 0xb 0xf9 0x5d 0x45 0xc1 0xc9 
0x5c 0x52 0x84 0x63 0xc6 0x9c 0xe4 0xbf 0xf3 0xb8 0x84
+RIPEMD320 b64: QJoxEf/T1MgFj/XCMUAcHUchCl0i5skL+V1FwclcUoRjxpzkv/O4hA==
+SHA160 hex: c8d7d0ef0eedfa82d2ea1aa592845b9a6d4b02b7
+SHA160 bin: 0xc8 0xd7 0xd0 0xef 0xe 0xed 0xfa 0x82 0xd2 0xea 0x1a 0xa5 0x92 
0x84 0x5b 0x9a 0x6d 0x4b 0x2 0xb7
+SHA160 b64: yNfQ7w7t+oLS6hqlkoRbmm1LArc=
+SHA224 hex: 750d81a39c18d3ce27ff3e5ece30b0088f12d8fd0450fe435326294b
+SHA224 bin: 0x75 0xd 0x81 0xa3 0x9c 0x18 

[FFmpeg-devel] [PATCH] Add tests for functions in hash.c

2016-03-06 Thread NagaChaitanya Vellanki
Made changes as suggested by James Almer.

NagaChaitanya Vellanki (1):
  Add tests for functions in hash.c

 libavutil/Makefile   |  1 +
 libavutil/hash.c | 45 +
 tests/fate/libavutil.mak |  4 
 tests/ref/fate/hash  | 45 +
 4 files changed, 95 insertions(+)
 create mode 100644 tests/ref/fate/hash

-- 
2.5.0

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


[FFmpeg-devel] [PATCH] Add tests for functions in hash.c

2016-03-06 Thread NagaChaitanya Vellanki
---
 libavutil/Makefile   |  1 +
 libavutil/hash.c | 41 +
 tests/fate/libavutil.mak |  4 
 tests/ref/fate/hash  | 45 +
 4 files changed, 91 insertions(+)
 create mode 100644 tests/ref/fate/hash

diff --git a/libavutil/Makefile b/libavutil/Makefile
index 934564f..58df75a 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -186,6 +186,7 @@ TESTPROGS = adler32 
\
 file\
 fifo\
 float_dsp   \
+hash\
 hmac\
 lfg \
 lls \
diff --git a/libavutil/hash.c b/libavutil/hash.c
index 7037b0d..3515e7f 100644
--- a/libavutil/hash.c
+++ b/libavutil/hash.c
@@ -237,3 +237,44 @@ void av_hash_freep(AVHashContext **ctx)
 av_freep(&(*ctx)->ctx);
 av_freep(ctx);
 }
+
+#ifdef TEST
+// LCOV_EXCL_START
+
+int main(int argc, char *argv[])
+{
+   struct AVHashContext *ctx = NULL;
+   int i, j;
+   for(i = 0; i < NUM_HASHES; i++) {
+   uint8_t src[64], dst[64];
+   memset(src, 0, 64);
+   memset(dst, 0, 64);
+   if(av_hash_alloc(, av_hash_names(i)) == 0) {
+   av_hash_init(ctx);
+   av_hash_update(ctx, src, 64);
+   av_hash_final_hex(ctx, dst, 64);
+   printf("%s hex: %s\n", av_hash_names(i), dst);
+
+   memset(dst, 0, 64);
+   av_hash_final_bin(ctx, dst, 64);
+   printf("%s bin: ", av_hash_names(i));
+   for(j = 0; j < av_hash_get_size(ctx); j++) {
+   printf("%#x ", dst[j]);
+   }
+   printf("\n");
+
+   memset(dst, 0, 64);
+   av_hash_final_b64(ctx, dst, 64);
+   printf("%s b64: %s\n", av_hash_names(i), dst);
+   av_hash_freep();
+   }
+   }
+
+   if(av_hash_alloc(, "FOO") != AVERROR(EINVAL)) {
+   printf("Invalid hash type 'FOO'\n");
+   }
+   return 0;
+}
+
+// LCOV_EXCL_STOP
+#endif
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index a89bc1d..5d8e0e2 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -75,6 +75,10 @@ fate-float-dsp: CMD = run libavutil/float_dsp-test 
$(CPUFLAGS:%=-c%)
 fate-float-dsp: CMP = null
 fate-float-dsp: REF = /dev/null
 
+FATE_LIBAVUTIL += fate-hash
+fate-hash: libavutil/hash-test$(EXESUF)
+fate-hash: CMD = run libavutil/hash-test
+
 FATE_LIBAVUTIL += fate-hmac
 fate-hmac: libavutil/hmac-test$(EXESUF)
 fate-hmac: CMD = run libavutil/hmac-test
diff --git a/tests/ref/fate/hash b/tests/ref/fate/hash
new file mode 100644
index 000..0a40a6d
--- /dev/null
+++ b/tests/ref/fate/hash
@@ -0,0 +1,45 @@
+MD5 hex: 3b5d3c7d207e37dceeedd301e35e2e58
+MD5 bin: 0x90 0x2c 0xb9 0x4f 0xf1 0x89 0xc5 0x50 0x92 0x30 0xa9 0x67 0xeb 0xd9 
0x2f 0xe2
+MD5 b64: VSrlzoSomOWmBL6fzSKY3w==
+murmur3 hex: 6e484695e1d7b4e37d838791cc263395
+murmur3 bin: 0x6e 0x48 0x46 0x95 0xe1 0xd7 0xb4 0xe3 0x7d 0x83 0x87 0x91 0xcc 
0x26 0x33 0x95
+murmur3 b64: bkhGleHXtON9g4eRzCYzlQ==
+RIPEMD128 hex: 082bfa9b829ef3a9e220dcc54e4c6383
+RIPEMD128 bin: 0x9f 0x6a 0xaf 0xf2 0x15 0x23 0x5e 0x3b 0x1b 0xf3 0x5c 0x27 
0x97 0x8c 0x1c 0xa9
+RIPEMD128 b64: +E5c8OVnvwZuSxwl1dvm1g==
+RIPEMD160 hex: 9b8ccc2f374ae313a914763cc9cdfb47bfe1c229
+RIPEMD160 bin: 0xb5 0x1a 0x86 0x4e 0x27 0x4d 0xd0 0xe1 0x81 0x4d 0x83 0xce 
0xd2 0x87 0x76 0xfc 0x95 0xed 0x8e 0x19
+RIPEMD160 b64: KQ4zIlTgLSLuYI370iB7aPaE7vs=
+RIPEMD256 hex: 26ba693759787f275f47dd5ab16e78c2fcd763b004fd05fc554e354223d6eab
+RIPEMD256 bin: 0x6e 0x9 0xbc 0x95 0xf2 0x4a 0xe 0x47 0xe7 0x2 0x2e 0xf3 0x5e 
0xc1 0x2e 0x92 0xaa 0xfc 0xb6 0x97 0xd9 0xf8 0x1 0xb7 0xdd 0x90 0xde 0x48 0x78 
0xc1 0x70 0xe2
+RIPEMD256 b64: SYuOSwaw29uyTVH17HBmsmHszKbjR/1LkfqRg0kgaZA=
+RIPEMD320 hex: 409a3111ffd3d4c8058ff5c231401c1d47210a5d22e6c90bf95d45c1c95c528
+RIPEMD320 bin: 0x6b 0x2a 0x54 0x88 0x49 0x24 0xf6 0x66 0xc3 0x5c 0xad 0x9c 
0x22 0xd1 0x68 0x9c 0xfc 0x36 0xe6 0x37 0x22 0x53 0x7 0xa 0x1c 0xd9 0x3f 0x67 
0x5 0x91 0xcd 0x49 0x3f 0xed 0x5b 0xda 0x1b 0x2d 0xff 0x9e
+RIPEMD320 b64: DdHUsKRNZwkUcZeoLAUQL5eYXmVA/kWAVJg5m3K6h890A/5qEZA90Q==
+SHA160 hex: c8d7d0ef0eedfa82d2ea1aa592845b9a6d4b02b7
+SHA160 bin: 0xf3 0xce 0x87 0xc9 0x60 0x2e 0xbf 0xcc 0x2b 0x8b 0xf2 0xbd 0x23 
0xff 0x71 0x51 0x5a 0xb4 0xc8 0xeb
+SHA160 b64: Df5J/BOWO6TxCM/jjnilhVr2Rg8=
+SHA224 hex: 750d81a39c18d3ce27ff3e5ece30b0088f12d8fd0450fe435326294b
+SHA224 bin: 0xdb 0x15 0x26 0xe7 0x50 0xa9 0x3a 0x17 0xe3 0x39 0x80 0xd 0x78 
0x1b 0xea 0xdd 0x3a 0xd3 0xad 0xf2 0x21 0xa2 0x93 0x1e 0x5e 0xf0 0xaf 0xeb
+SHA224 b64: eKAYArOrj3lSGq6JuHuz2mA7n/6br5IS4lvbKA==

[FFmpeg-devel] [PATCH] Add tests for functions in hash.c

2016-03-06 Thread NagaChaitanya Vellanki
Please review the patch.

NagaChaitanya Vellanki (1):
  Add tests for functions in hash.c

 libavutil/Makefile   |  1 +
 libavutil/hash.c | 41 +
 tests/fate/libavutil.mak |  4 
 tests/ref/fate/hash  | 45 +
 4 files changed, 91 insertions(+)
 create mode 100644 tests/ref/fate/hash

-- 
2.5.0

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


Re: [FFmpeg-devel] [PATCH] Add test for avpriv_get_trc_function_from_trc function

2016-03-03 Thread NagaChaitanya Vellanki
Derek,
I agree with you, checked this on ubuntu, mac os both x86_32, x86_64.

On Thu, Mar 3, 2016 at 10:11 AM, Derek Buitenhuis <
derek.buitenh...@gmail.com> wrote:

> On 3/3/2016 6:01 PM, NagaChaitanya Vellanki wrote:
> > +  printf("AVColorTransferCharacteristic=%d calling func(%f)
> expected=%f\n",
> > + i, test_data[j], result);
>
> Comparing floats exactly probably isn't a great idea, since
> floating point implementations differ between architectures.
>
> - Derek
> ___
> 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] Add test for avpriv_get_trc_function_from_trc function

2016-03-03 Thread NagaChaitanya Vellanki
---
 libavutil/Makefile |   1 +
 libavutil/color_utils.c|  29 +
 tests/fate/libavutil.mak   |   4 +
 tests/ref/fate/color_utils | 285 +
 4 files changed, 319 insertions(+)
 create mode 100644 tests/ref/fate/color_utils

diff --git a/libavutil/Makefile b/libavutil/Makefile
index a4d79cd..934564f 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -176,6 +176,7 @@ TESTPROGS = adler32 
\
 bprint  \
 cast5   \
 camellia\
+color_utils \
 cpu \
 crc \
 des \
diff --git a/libavutil/color_utils.c b/libavutil/color_utils.c
index b68b402..0bb7e3d 100644
--- a/libavutil/color_utils.c
+++ b/libavutil/color_utils.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 
+#include "common.h"
 #include "libavutil/color_utils.h"
 #include "libavutil/pixfmt.h"
 
@@ -216,3 +217,31 @@ avpriv_trc_function avpriv_get_trc_function_from_trc(enum 
AVColorTransferCharact
 }
 return func;
 }
+
+#ifdef TEST
+// LCOV_EXCL_START
+
+int main(int argc, char *argv[])
+{
+  int i, j;
+  double test_data[] = {
+  -0.1, -0.018053968510807, -0.01, -0.00449, 0.0, 0.00316227760, 0.005,
+  0.009, 0.015, 0.1, 1.0, 52.37, 125.098765, 1999.11123, 6945.443,
+  15123.4567, 19845.88923, 98678.4231, 9.88
+  };
+
+  for(i = 0; i < AVCOL_TRC_NB; i++) {
+  avpriv_trc_function func = avpriv_get_trc_function_from_trc(i);
+  for(j = 0; j < FF_ARRAY_ELEMS(test_data); j++) {
+  if(func != NULL) {
+  double result = func(test_data[j]);
+  printf("AVColorTransferCharacteristic=%d calling func(%f) 
expected=%f\n",
+ i, test_data[j], result);
+  }
+  }
+  }
+
+}
+
+// LCOV_EXCL_STOP
+#endif
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index 022ae6a..a89bc1d 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -48,6 +48,10 @@ FATE_LIBAVUTIL += fate-crc
 fate-crc: libavutil/crc-test$(EXESUF)
 fate-crc: CMD = run libavutil/crc-test
 
+FATE_LIBAVUTIL += fate-color_utils
+fate-color_utils: libavutil/color_utils-test$(EXESUF)
+fate-color_utils: CMD = run libavutil/color_utils-test
+
 FATE_LIBAVUTIL += fate-des
 fate-des: libavutil/des-test$(EXESUF)
 fate-des: CMD = run libavutil/des-test
diff --git a/tests/ref/fate/color_utils b/tests/ref/fate/color_utils
new file mode 100644
index 000..6e80ebd
--- /dev/null
+++ b/tests/ref/fate/color_utils
@@ -0,0 +1,285 @@
+AVColorTransferCharacteristic=1 calling func(-0.10) expected=0.00
+AVColorTransferCharacteristic=1 calling func(-0.018054) expected=0.00
+AVColorTransferCharacteristic=1 calling func(-0.01) expected=0.00
+AVColorTransferCharacteristic=1 calling func(-0.004490) expected=0.00
+AVColorTransferCharacteristic=1 calling func(0.00) expected=0.00
+AVColorTransferCharacteristic=1 calling func(0.003162) expected=0.014230
+AVColorTransferCharacteristic=1 calling func(0.005000) expected=0.022500
+AVColorTransferCharacteristic=1 calling func(0.009000) expected=0.040500
+AVColorTransferCharacteristic=1 calling func(0.015000) expected=0.067500
+AVColorTransferCharacteristic=1 calling func(0.10) expected=0.290748
+AVColorTransferCharacteristic=1 calling func(1.00) expected=1.00
+AVColorTransferCharacteristic=1 calling func(52.37) expected=6.427531
+AVColorTransferCharacteristic=1 calling func(125.098765) expected=9.558517
+AVColorTransferCharacteristic=1 calling func(1999.111230) expected=33.512490
+AVColorTransferCharacteristic=1 calling func(6945.443000) expected=58.768794
+AVColorTransferCharacteristic=1 calling func(15123.456700) expected=83.452916
+AVColorTransferCharacteristic=1 calling func(19845.889230) expected=94.321297
+AVColorTransferCharacteristic=1 calling func(98678.423100) expected=194.219568
+AVColorTransferCharacteristic=1 calling func(9.88) expected=195.386306
+AVColorTransferCharacteristic=4 calling func(-0.10) expected=0.00
+AVColorTransferCharacteristic=4 calling func(-0.018054) expected=0.00
+AVColorTransferCharacteristic=4 calling func(-0.01) expected=0.00
+AVColorTransferCharacteristic=4 calling func(-0.004490) expected=0.00
+AVColorTransferCharacteristic=4 calling func(0.00) expected=0.00
+AVColorTransferCharacteristic=4 calling func(0.003162) expected=0.073053
+AVColorTransferCharacteristic=4 calling func(0.005000) expected=0.089966
+AVColorTransferCharacteristic=4 calling func(0.009000) expected=0.117520

[FFmpeg-devel] [PATCH] Add test for avpriv_get_trc_function_from_trc function

2016-03-03 Thread NagaChaitanya Vellanki
Please ignore my previous patches. 
The commit message was incorrectly formatted. Please consider this patch.

NagaChaitanya Vellanki (1):
  Add test for avpriv_get_trc_function_from_trc function

 libavutil/Makefile |   1 +
 libavutil/color_utils.c|  29 +
 tests/fate/libavutil.mak   |   4 +
 tests/ref/fate/color_utils | 285 +
 4 files changed, 319 insertions(+)
 create mode 100644 tests/ref/fate/color_utils

-- 
2.5.0

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


[FFmpeg-devel] [PATCH] Add test foravpriv_get_trc_function_from_trc function

2016-03-03 Thread NagaChaitanya Vellanki
From: NagaChaitanya Vellanki <m...@chaitanyavellanki.com>

---
 libavutil/Makefile |   1 +
 libavutil/color_utils.c|  29 +
 tests/fate/libavutil.mak   |   4 +
 tests/ref/fate/color_utils | 285 +
 4 files changed, 319 insertions(+)
 create mode 100644 tests/ref/fate/color_utils

diff --git a/libavutil/Makefile b/libavutil/Makefile
index a4d79cd..934564f 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -176,6 +176,7 @@ TESTPROGS = adler32 
\
 bprint  \
 cast5   \
 camellia\
+color_utils \
 cpu \
 crc \
 des \
diff --git a/libavutil/color_utils.c b/libavutil/color_utils.c
index b68b402..0bb7e3d 100644
--- a/libavutil/color_utils.c
+++ b/libavutil/color_utils.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 
+#include "common.h"
 #include "libavutil/color_utils.h"
 #include "libavutil/pixfmt.h"
 
@@ -216,3 +217,31 @@ avpriv_trc_function avpriv_get_trc_function_from_trc(enum 
AVColorTransferCharact
 }
 return func;
 }
+
+#ifdef TEST
+// LCOV_EXCL_START
+
+int main(int argc, char *argv[])
+{
+  int i, j;
+  double test_data[] = {
+  -0.1, -0.018053968510807, -0.01, -0.00449, 0.0, 0.00316227760, 0.005,
+  0.009, 0.015, 0.1, 1.0, 52.37, 125.098765, 1999.11123, 6945.443,
+  15123.4567, 19845.88923, 98678.4231, 9.88
+  };
+
+  for(i = 0; i < AVCOL_TRC_NB; i++) {
+  avpriv_trc_function func = avpriv_get_trc_function_from_trc(i);
+  for(j = 0; j < FF_ARRAY_ELEMS(test_data); j++) {
+  if(func != NULL) {
+  double result = func(test_data[j]);
+  printf("AVColorTransferCharacteristic=%d calling func(%f) 
expected=%f\n",
+ i, test_data[j], result);
+  }
+  }
+  }
+
+}
+
+// LCOV_EXCL_STOP
+#endif
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index 022ae6a..a89bc1d 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -48,6 +48,10 @@ FATE_LIBAVUTIL += fate-crc
 fate-crc: libavutil/crc-test$(EXESUF)
 fate-crc: CMD = run libavutil/crc-test
 
+FATE_LIBAVUTIL += fate-color_utils
+fate-color_utils: libavutil/color_utils-test$(EXESUF)
+fate-color_utils: CMD = run libavutil/color_utils-test
+
 FATE_LIBAVUTIL += fate-des
 fate-des: libavutil/des-test$(EXESUF)
 fate-des: CMD = run libavutil/des-test
diff --git a/tests/ref/fate/color_utils b/tests/ref/fate/color_utils
new file mode 100644
index 000..6e80ebd
--- /dev/null
+++ b/tests/ref/fate/color_utils
@@ -0,0 +1,285 @@
+AVColorTransferCharacteristic=1 calling func(-0.10) expected=0.00
+AVColorTransferCharacteristic=1 calling func(-0.018054) expected=0.00
+AVColorTransferCharacteristic=1 calling func(-0.01) expected=0.00
+AVColorTransferCharacteristic=1 calling func(-0.004490) expected=0.00
+AVColorTransferCharacteristic=1 calling func(0.00) expected=0.00
+AVColorTransferCharacteristic=1 calling func(0.003162) expected=0.014230
+AVColorTransferCharacteristic=1 calling func(0.005000) expected=0.022500
+AVColorTransferCharacteristic=1 calling func(0.009000) expected=0.040500
+AVColorTransferCharacteristic=1 calling func(0.015000) expected=0.067500
+AVColorTransferCharacteristic=1 calling func(0.10) expected=0.290748
+AVColorTransferCharacteristic=1 calling func(1.00) expected=1.00
+AVColorTransferCharacteristic=1 calling func(52.37) expected=6.427531
+AVColorTransferCharacteristic=1 calling func(125.098765) expected=9.558517
+AVColorTransferCharacteristic=1 calling func(1999.111230) expected=33.512490
+AVColorTransferCharacteristic=1 calling func(6945.443000) expected=58.768794
+AVColorTransferCharacteristic=1 calling func(15123.456700) expected=83.452916
+AVColorTransferCharacteristic=1 calling func(19845.889230) expected=94.321297
+AVColorTransferCharacteristic=1 calling func(98678.423100) expected=194.219568
+AVColorTransferCharacteristic=1 calling func(9.88) expected=195.386306
+AVColorTransferCharacteristic=4 calling func(-0.10) expected=0.00
+AVColorTransferCharacteristic=4 calling func(-0.018054) expected=0.00
+AVColorTransferCharacteristic=4 calling func(-0.01) expected=0.00
+AVColorTransferCharacteristic=4 calling func(-0.004490) expected=0.00
+AVColorTransferCharacteristic=4 calling func(0.00) expected=0.00
+AVColorTransferCharacteristic=4 calling func(0.003162) expected=0.073053
+AVColorTransferCharacteristic=4 calling func(0.005000

[FFmpeg-devel] [PATCH] Add test foravpriv_get_trc_function_from_trc function

2016-03-03 Thread NagaChaitanya Vellanki
---
 libavutil/Makefile |   1 +
 libavutil/color_utils.c|  29 +
 tests/fate/libavutil.mak   |   4 +
 tests/ref/fate/color_utils | 285 +
 4 files changed, 319 insertions(+)
 create mode 100644 tests/ref/fate/color_utils

diff --git a/libavutil/Makefile b/libavutil/Makefile
index a4d79cd..934564f 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -176,6 +176,7 @@ TESTPROGS = adler32 
\
 bprint  \
 cast5   \
 camellia\
+color_utils \
 cpu \
 crc \
 des \
diff --git a/libavutil/color_utils.c b/libavutil/color_utils.c
index b68b402..0bb7e3d 100644
--- a/libavutil/color_utils.c
+++ b/libavutil/color_utils.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 
+#include "common.h"
 #include "libavutil/color_utils.h"
 #include "libavutil/pixfmt.h"
 
@@ -216,3 +217,31 @@ avpriv_trc_function avpriv_get_trc_function_from_trc(enum 
AVColorTransferCharact
 }
 return func;
 }
+
+#ifdef TEST
+// LCOV_EXCL_START
+
+int main(int argc, char *argv[])
+{
+  int i, j;
+  double test_data[] = {
+  -0.1, -0.018053968510807, -0.01, -0.00449, 0.0, 0.00316227760, 0.005,
+  0.009, 0.015, 0.1, 1.0, 52.37, 125.098765, 1999.11123, 6945.443,
+  15123.4567, 19845.88923, 98678.4231, 9.88
+  };
+
+  for(i = 0; i < AVCOL_TRC_NB; i++) {
+  avpriv_trc_function func = avpriv_get_trc_function_from_trc(i);
+  for(j = 0; j < FF_ARRAY_ELEMS(test_data); j++) {
+  if(func != NULL) {
+  double result = func(test_data[j]);
+  printf("AVColorTransferCharacteristic=%d calling func(%f) 
expected=%f\n",
+ i, test_data[j], result);
+  }
+  }
+  }
+
+}
+
+// LCOV_EXCL_STOP
+#endif
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index 022ae6a..a89bc1d 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -48,6 +48,10 @@ FATE_LIBAVUTIL += fate-crc
 fate-crc: libavutil/crc-test$(EXESUF)
 fate-crc: CMD = run libavutil/crc-test
 
+FATE_LIBAVUTIL += fate-color_utils
+fate-color_utils: libavutil/color_utils-test$(EXESUF)
+fate-color_utils: CMD = run libavutil/color_utils-test
+
 FATE_LIBAVUTIL += fate-des
 fate-des: libavutil/des-test$(EXESUF)
 fate-des: CMD = run libavutil/des-test
diff --git a/tests/ref/fate/color_utils b/tests/ref/fate/color_utils
new file mode 100644
index 000..6e80ebd
--- /dev/null
+++ b/tests/ref/fate/color_utils
@@ -0,0 +1,285 @@
+AVColorTransferCharacteristic=1 calling func(-0.10) expected=0.00
+AVColorTransferCharacteristic=1 calling func(-0.018054) expected=0.00
+AVColorTransferCharacteristic=1 calling func(-0.01) expected=0.00
+AVColorTransferCharacteristic=1 calling func(-0.004490) expected=0.00
+AVColorTransferCharacteristic=1 calling func(0.00) expected=0.00
+AVColorTransferCharacteristic=1 calling func(0.003162) expected=0.014230
+AVColorTransferCharacteristic=1 calling func(0.005000) expected=0.022500
+AVColorTransferCharacteristic=1 calling func(0.009000) expected=0.040500
+AVColorTransferCharacteristic=1 calling func(0.015000) expected=0.067500
+AVColorTransferCharacteristic=1 calling func(0.10) expected=0.290748
+AVColorTransferCharacteristic=1 calling func(1.00) expected=1.00
+AVColorTransferCharacteristic=1 calling func(52.37) expected=6.427531
+AVColorTransferCharacteristic=1 calling func(125.098765) expected=9.558517
+AVColorTransferCharacteristic=1 calling func(1999.111230) expected=33.512490
+AVColorTransferCharacteristic=1 calling func(6945.443000) expected=58.768794
+AVColorTransferCharacteristic=1 calling func(15123.456700) expected=83.452916
+AVColorTransferCharacteristic=1 calling func(19845.889230) expected=94.321297
+AVColorTransferCharacteristic=1 calling func(98678.423100) expected=194.219568
+AVColorTransferCharacteristic=1 calling func(9.88) expected=195.386306
+AVColorTransferCharacteristic=4 calling func(-0.10) expected=0.00
+AVColorTransferCharacteristic=4 calling func(-0.018054) expected=0.00
+AVColorTransferCharacteristic=4 calling func(-0.01) expected=0.00
+AVColorTransferCharacteristic=4 calling func(-0.004490) expected=0.00
+AVColorTransferCharacteristic=4 calling func(0.00) expected=0.00
+AVColorTransferCharacteristic=4 calling func(0.003162) expected=0.073053
+AVColorTransferCharacteristic=4 calling func(0.005000) expected=0.089966
+AVColorTransferCharacteristic=4 calling func(0.009000) expected=0.117520

Re: [FFmpeg-devel] [PATCH] Add test foravpriv_get_trc_function_from_trc function

2016-03-02 Thread NagaChaitanya Vellanki
Passes on my mac
~/Documents/projects/FFmpeg/libavutil (master ✘)✭ ᐅ file color_utils-test
color_utils-test: Mach-O executable i386
~/Documents/projects/FFmpeg/libavutil (master ✘)✭ ᐅ cd ..
~/Documents/projects/FFmpeg (master ✘)✭ ᐅ make fate-color_utils
TESTcolor_utils

Will test this on my ubuntu machine and make a new patch.



On Wed, Mar 2, 2016 at 7:44 PM, Michael Niedermayer <mich...@niedermayer.cc>
wrote:

> On Wed, Mar 02, 2016 at 06:36:26PM -0800, NagaChaitanya Vellanki wrote:
> > ---
> >  libavutil/Makefile |   1 +
> >  libavutil/color_utils.c|  29 +
> >  tests/fate/libavutil.mak   |   4 +
> >  tests/ref/fate/color_utils | 285
> +
> >  4 files changed, 319 insertions(+)
> >  create mode 100644 tests/ref/fate/color_utils
>
> fails on x86-32
> --- ffmpeg/tests/ref/fate/color_utils  2016-03-03 04:07:54.150126182 +0100
> +++ tests/data/fate/color_utils 2016-03-03 04:43:57.406171756 +0100
> @@ -172,7 +172,7 @@
>  AVColorTransferCharacteristic=12 calling func(-0.10)
> expected=-0.206787
>  AVColorTransferCharacteristic=12 calling func(-0.018054)
> expected=-0.109049
>  AVColorTransferCharacteristic=12 calling func(-0.01)
> expected=-0.089387
> -AVColorTransferCharacteristic=12 calling func(-0.004500)
> expected=-0.069898
> +AVColorTransferCharacteristic=12 calling func(-0.004500)
> expected=-0.020250
>  AVColorTransferCharacteristic=12 calling func(0.00) expected=0.00
>  AVColorTransferCharacteristic=12 calling func(0.003162) expected=0.014230
>  AVColorTransferCharacteristic=12 calling func(0.005000) expected=0.022500
> Test color_utils failed. Look at tests/data/fate/color_utils.err for
> details.
> make: *** [fate-color_utils] Error 1
>
>
> [...]
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> When the tyrant has disposed of foreign enemies by conquest or treaty, and
> there is nothing more to fear from them, then he is always stirring up
> some war or other, in order that the people may require a leader. -- 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


[FFmpeg-devel] [PATCH] Add test foravpriv_get_trc_function_from_trc function

2016-03-02 Thread NagaChaitanya Vellanki
---
 libavutil/Makefile |   1 +
 libavutil/color_utils.c|  29 +
 tests/fate/libavutil.mak   |   4 +
 tests/ref/fate/color_utils | 285 +
 4 files changed, 319 insertions(+)
 create mode 100644 tests/ref/fate/color_utils

diff --git a/libavutil/Makefile b/libavutil/Makefile
index a4d79cd..934564f 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -176,6 +176,7 @@ TESTPROGS = adler32 
\
 bprint  \
 cast5   \
 camellia\
+color_utils \
 cpu \
 crc \
 des \
diff --git a/libavutil/color_utils.c b/libavutil/color_utils.c
index b68b402..0ee1dea 100644
--- a/libavutil/color_utils.c
+++ b/libavutil/color_utils.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 
+#include "common.h"
 #include "libavutil/color_utils.h"
 #include "libavutil/pixfmt.h"
 
@@ -216,3 +217,31 @@ avpriv_trc_function avpriv_get_trc_function_from_trc(enum 
AVColorTransferCharact
 }
 return func;
 }
+
+#ifdef TEST
+// LCOV_EXCL_START
+
+int main(int argc, char *argv[])
+{
+  int i, j;
+  double test_data[] = {
+  -0.1, -0.018053968510807, -0.01, -0.0045, 0.0, 0.00316227760, 0.005,
+  0.009, 0.015, 0.1, 1.0, 52.37, 125.098765, 1999.11123, 6945.443,
+  15123.4567, 19845.88923, 98678.4231, 9.88
+  };
+
+  for(i = 0; i < AVCOL_TRC_NB; i++) {
+  avpriv_trc_function func = avpriv_get_trc_function_from_trc(i);
+  for(j = 0; j < FF_ARRAY_ELEMS(test_data); j++) {
+  if(func != NULL) {
+  double result = func(test_data[j]);
+  printf("AVColorTransferCharacteristic=%d calling func(%f) 
expected=%f\n",
+ i, test_data[j], result);
+  }
+  }
+  }
+
+}
+
+// LCOV_EXCL_STOP
+#endif
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index 022ae6a..a89bc1d 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -48,6 +48,10 @@ FATE_LIBAVUTIL += fate-crc
 fate-crc: libavutil/crc-test$(EXESUF)
 fate-crc: CMD = run libavutil/crc-test
 
+FATE_LIBAVUTIL += fate-color_utils
+fate-color_utils: libavutil/color_utils-test$(EXESUF)
+fate-color_utils: CMD = run libavutil/color_utils-test
+
 FATE_LIBAVUTIL += fate-des
 fate-des: libavutil/des-test$(EXESUF)
 fate-des: CMD = run libavutil/des-test
diff --git a/tests/ref/fate/color_utils b/tests/ref/fate/color_utils
new file mode 100644
index 000..a8933ff
--- /dev/null
+++ b/tests/ref/fate/color_utils
@@ -0,0 +1,285 @@
+AVColorTransferCharacteristic=1 calling func(-0.10) expected=0.00
+AVColorTransferCharacteristic=1 calling func(-0.018054) expected=0.00
+AVColorTransferCharacteristic=1 calling func(-0.01) expected=0.00
+AVColorTransferCharacteristic=1 calling func(-0.004500) expected=0.00
+AVColorTransferCharacteristic=1 calling func(0.00) expected=0.00
+AVColorTransferCharacteristic=1 calling func(0.003162) expected=0.014230
+AVColorTransferCharacteristic=1 calling func(0.005000) expected=0.022500
+AVColorTransferCharacteristic=1 calling func(0.009000) expected=0.040500
+AVColorTransferCharacteristic=1 calling func(0.015000) expected=0.067500
+AVColorTransferCharacteristic=1 calling func(0.10) expected=0.290748
+AVColorTransferCharacteristic=1 calling func(1.00) expected=1.00
+AVColorTransferCharacteristic=1 calling func(52.37) expected=6.427531
+AVColorTransferCharacteristic=1 calling func(125.098765) expected=9.558517
+AVColorTransferCharacteristic=1 calling func(1999.111230) expected=33.512490
+AVColorTransferCharacteristic=1 calling func(6945.443000) expected=58.768794
+AVColorTransferCharacteristic=1 calling func(15123.456700) expected=83.452916
+AVColorTransferCharacteristic=1 calling func(19845.889230) expected=94.321297
+AVColorTransferCharacteristic=1 calling func(98678.423100) expected=194.219568
+AVColorTransferCharacteristic=1 calling func(9.88) expected=195.386306
+AVColorTransferCharacteristic=4 calling func(-0.10) expected=0.00
+AVColorTransferCharacteristic=4 calling func(-0.018054) expected=0.00
+AVColorTransferCharacteristic=4 calling func(-0.01) expected=0.00
+AVColorTransferCharacteristic=4 calling func(-0.004500) expected=0.00
+AVColorTransferCharacteristic=4 calling func(0.00) expected=0.00
+AVColorTransferCharacteristic=4 calling func(0.003162) expected=0.073053
+AVColorTransferCharacteristic=4 calling func(0.005000) expected=0.089966
+AVColorTransferCharacteristic=4 calling func(0.009000) expected=0.117520

Re: [FFmpeg-devel] [PATCH] Add test foravpriv_get_trc_function_from_trc function

2016-03-02 Thread NagaChaitanya Vellanki
Sending in the new patch :-).

On Wed, Mar 2, 2016 at 5:20 PM, Michael Niedermayer <mich...@niedermayer.cc>
wrote:

> On Wed, Mar 02, 2016 at 04:35:08PM -0800, NagaChaitanya Vellanki wrote:
> > ---
> >  libavutil/Makefile |  1 +
> >  libavutil/color_utils.c| 65
> ++
> >  tests/fate/libavutil.mak   |  4 +++
> >  tests/ref/fate/color_utils | 38 +++
> >  4 files changed, 108 insertions(+)
> >  create mode 100644 tests/ref/fate/color_utils
> >
> > diff --git a/libavutil/Makefile b/libavutil/Makefile
> > index a4d79cd..934564f 100644
> > --- a/libavutil/Makefile
> > +++ b/libavutil/Makefile
> > @@ -176,6 +176,7 @@ TESTPROGS = adler32
>\
> >  bprint
> \
> >  cast5
>  \
> >  camellia
> \
> > +color_utils
>  \
> >  cpu
>  \
> >  crc
>  \
> >  des
>  \
> > diff --git a/libavutil/color_utils.c b/libavutil/color_utils.c
> > index b68b402..e53f408 100644
> > --- a/libavutil/color_utils.c
> > +++ b/libavutil/color_utils.c
> > @@ -21,6 +21,7 @@
> >  #include 
> >  #include 
> >
> > +#include "common.h"
> >  #include "libavutil/color_utils.h"
> >  #include "libavutil/pixfmt.h"
> >
> > @@ -216,3 +217,67 @@ avpriv_trc_function
> avpriv_get_trc_function_from_trc(enum AVColorTransferCharact
> >  }
> >  return func;
> >  }
> > +
> > +#ifdef TEST
> > +// LCOV_EXCL_START
> > +
> > +int main(int argc, char *argv[])
> > +{
> > +  int i;
> > +  struct test {
> > +  enum AVColorTransferCharacteristic trc;
> > +  const char* func_name;
> > +  double arg;
> > +  double result;
> > +  }   tests[] = {
> > +  { AVCOL_TRC_BT709, "avpriv_trc_bt709",  -0.01, 0.0 },
> > +  { AVCOL_TRC_SMPTE170M, "avpriv_trc_bt709", 0.005, 0.022500 },
> > +  { AVCOL_TRC_BT2020_10, "avpriv_trc_bt709", 0.015, 0.067500 },
> > +  { AVCOL_TRC_BT2020_12, "avpriv_trc_bt709", 1.0, 1.0 },
> > +  { AVCOL_TRC_BT2020_12, "avpriv_trc_bt709", 15123.4567, 83.452916
> },
> > +  { AVCOL_TRC_GAMMA22, "avpriv_trc_gamma22", -0.01, 0.0 },
> > +  { AVCOL_TRC_GAMMA22, "avpriv_trc_gamma22", 1.0, 1.0 },
> > +  { AVCOL_TRC_GAMMA22, "avpriv_trc_gamma22", 125.098765, 8.980424 },
> > +  { AVCOL_TRC_GAMMA28, "avpriv_trc_gamma28", -0.01, 0.0 },
> > +  { AVCOL_TRC_GAMMA28, "avpriv_trc_gamma28", 1.0, 1.0 },
> > +  { AVCOL_TRC_GAMMA28, "avpriv_trc_gamma28", 9.88,
> 61.054001 },
> > +  { AVCOL_TRC_SMPTE240M, "avpriv_trc_smpte240M", -0.01, 0.0 },
> > +  { AVCOL_TRC_SMPTE240M, "avpriv_trc_smpte240M", 0.015, 0.06 },
> > +  { AVCOL_TRC_LINEAR, "avpriv_trc_linear", 0.0, 0.0 },
> > +  { AVCOL_TRC_LINEAR, "avpriv_trc_linear", 0.1, 0.1 },
> > +  { AVCOL_TRC_LINEAR, "avpriv_trc_linear", -0.1, -0.1 },
> > +  { AVCOL_TRC_LOG, "avpriv_trc_log", 0.009, 0.0 },
> > +  { AVCOL_TRC_LOG, "avpriv_trc_log", 1.0, 1.0 },
> > +  { AVCOL_TRC_LOG, "avpriv_trc_log", 98678.4231, 3.497111 },
> > +  { AVCOL_TRC_LOG_SQRT, "avpriv_trc_log_sqrt", 0.00316227760, 0.0 },
> > +  { AVCOL_TRC_LOG_SQRT, "avpriv_trc_log_sqrt", 1.0, 1.0 },
> > +  { AVCOL_TRC_LOG_SQRT, "avpriv_trc_log_sqrt", 19845.88923,
> 2.719068 },
> > +  { AVCOL_TRC_IEC61966_2_4, "avpriv_trc_iec61966_2_4", 0.0, 0.0 },
> > +  { AVCOL_TRC_IEC61966_2_4, "avpriv_trc_iec61966_2_4",
> -0.018053968510807, -0.081243 },
> > +  { AVCOL_TRC_IEC61966_2_4, "avpriv_trc_iec61966_2_4", 0.015,
> 0.067500 },
> > +  { AVCOL_TRC_IEC61966_2_4, "avpriv_trc_iec61966_2_4", 98245.76983,
> 193.835711 },
> > +  { AVCOL_TRC_BT1361_ECG, "avpriv_trc_bt1361", 0.0, 0.0 },
> > +  { AVCOL_TRC_BT1361_ECG, "avpriv_trc_bt1361", -0.0045, -0.069898 },
> > +  { AVCOL_TRC_BT1361_ECG, "avpriv_trc_bt1361", 0.015, 0.067500 },
> > +  { AVCOL_TRC_BT1361_ECG, "avpriv_trc_bt1361", 1999.11123,
> 33.512490 },
> > +  { AVCOL_TRC_IEC61966_2_1, "avpriv_trc_iec61966_2_1", 0.0, 0.0 },
> > +  { AVCOL_TRC_IEC61966_2_1, "avpriv_trc_iec61966_2_1", 0.015,
> 0.128354 },
> > +  { AVCOL_TRC

[FFmpeg-devel] [PATCH] Add test foravpriv_get_trc_function_from_trc function

2016-03-02 Thread NagaChaitanya Vellanki
---
 libavutil/Makefile |  1 +
 libavutil/color_utils.c| 65 ++
 tests/fate/libavutil.mak   |  4 +++
 tests/ref/fate/color_utils | 38 +++
 4 files changed, 108 insertions(+)
 create mode 100644 tests/ref/fate/color_utils

diff --git a/libavutil/Makefile b/libavutil/Makefile
index a4d79cd..934564f 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -176,6 +176,7 @@ TESTPROGS = adler32 
\
 bprint  \
 cast5   \
 camellia\
+color_utils \
 cpu \
 crc \
 des \
diff --git a/libavutil/color_utils.c b/libavutil/color_utils.c
index b68b402..e53f408 100644
--- a/libavutil/color_utils.c
+++ b/libavutil/color_utils.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 
+#include "common.h"
 #include "libavutil/color_utils.h"
 #include "libavutil/pixfmt.h"
 
@@ -216,3 +217,67 @@ avpriv_trc_function avpriv_get_trc_function_from_trc(enum 
AVColorTransferCharact
 }
 return func;
 }
+
+#ifdef TEST
+// LCOV_EXCL_START
+
+int main(int argc, char *argv[])
+{
+  int i;
+  struct test {
+  enum AVColorTransferCharacteristic trc;
+  const char* func_name;
+  double arg;
+  double result;
+  }   tests[] = {
+  { AVCOL_TRC_BT709, "avpriv_trc_bt709",  -0.01, 0.0 },
+  { AVCOL_TRC_SMPTE170M, "avpriv_trc_bt709", 0.005, 0.022500 },
+  { AVCOL_TRC_BT2020_10, "avpriv_trc_bt709", 0.015, 0.067500 },
+  { AVCOL_TRC_BT2020_12, "avpriv_trc_bt709", 1.0, 1.0 },
+  { AVCOL_TRC_BT2020_12, "avpriv_trc_bt709", 15123.4567, 83.452916 },
+  { AVCOL_TRC_GAMMA22, "avpriv_trc_gamma22", -0.01, 0.0 },
+  { AVCOL_TRC_GAMMA22, "avpriv_trc_gamma22", 1.0, 1.0 },
+  { AVCOL_TRC_GAMMA22, "avpriv_trc_gamma22", 125.098765, 8.980424 },
+  { AVCOL_TRC_GAMMA28, "avpriv_trc_gamma28", -0.01, 0.0 },
+  { AVCOL_TRC_GAMMA28, "avpriv_trc_gamma28", 1.0, 1.0 },
+  { AVCOL_TRC_GAMMA28, "avpriv_trc_gamma28", 9.88, 61.054001 },
+  { AVCOL_TRC_SMPTE240M, "avpriv_trc_smpte240M", -0.01, 0.0 },
+  { AVCOL_TRC_SMPTE240M, "avpriv_trc_smpte240M", 0.015, 0.06 },
+  { AVCOL_TRC_LINEAR, "avpriv_trc_linear", 0.0, 0.0 },
+  { AVCOL_TRC_LINEAR, "avpriv_trc_linear", 0.1, 0.1 },
+  { AVCOL_TRC_LINEAR, "avpriv_trc_linear", -0.1, -0.1 },
+  { AVCOL_TRC_LOG, "avpriv_trc_log", 0.009, 0.0 },
+  { AVCOL_TRC_LOG, "avpriv_trc_log", 1.0, 1.0 },
+  { AVCOL_TRC_LOG, "avpriv_trc_log", 98678.4231, 3.497111 },
+  { AVCOL_TRC_LOG_SQRT, "avpriv_trc_log_sqrt", 0.00316227760, 0.0 },
+  { AVCOL_TRC_LOG_SQRT, "avpriv_trc_log_sqrt", 1.0, 1.0 },
+  { AVCOL_TRC_LOG_SQRT, "avpriv_trc_log_sqrt", 19845.88923, 2.719068 },
+  { AVCOL_TRC_IEC61966_2_4, "avpriv_trc_iec61966_2_4", 0.0, 0.0 },
+  { AVCOL_TRC_IEC61966_2_4, "avpriv_trc_iec61966_2_4", -0.018053968510807, 
-0.081243 },
+  { AVCOL_TRC_IEC61966_2_4, "avpriv_trc_iec61966_2_4", 0.015, 0.067500 },
+  { AVCOL_TRC_IEC61966_2_4, "avpriv_trc_iec61966_2_4", 98245.76983, 
193.835711 },
+  { AVCOL_TRC_BT1361_ECG, "avpriv_trc_bt1361", 0.0, 0.0 },
+  { AVCOL_TRC_BT1361_ECG, "avpriv_trc_bt1361", -0.0045, -0.069898 },
+  { AVCOL_TRC_BT1361_ECG, "avpriv_trc_bt1361", 0.015, 0.067500 },
+  { AVCOL_TRC_BT1361_ECG, "avpriv_trc_bt1361", 1999.11123, 33.512490 },
+  { AVCOL_TRC_IEC61966_2_1, "avpriv_trc_iec61966_2_1", 0.0, 0.0 },
+  { AVCOL_TRC_IEC61966_2_1, "avpriv_trc_iec61966_2_1", 0.015, 0.128354 },
+  { AVCOL_TRC_IEC61966_2_1, "avpriv_trc_iec61966_2_1", 6945.443, 42.013863 
},
+  { AVCOL_TRC_SMPTEST2084, "avpriv_trc_smpte_st2084", -0.01, 0.0 },
+  { AVCOL_TRC_SMPTEST2084, "avpriv_trc_smpte_st2084", 0.0, 0.01 },
+  { AVCOL_TRC_SMPTEST428_1, "avpriv_trc_smpte_st428_1", -0.01, 0.0 },
+  { AVCOL_TRC_SMPTEST428_1, "avpriv_trc_smpte_st428_1", 52.37, 4.432321 },
+  { AVCOL_TRC_SMPTEST428_1, "avpriv_trc_smpte_st428_1", 0.0, 0.0 }
+  };
+
+  for(i = 0; i < FF_ARRAY_ELEMS(tests); i++) {
+  avpriv_trc_function func = 
avpriv_get_trc_function_from_trc(tests[i].trc);
+  double result = func(tests[i].arg);
+  printf("AVColorTransferCharacteristic=%d calling %s(%f) expected=%f 
got=%f\n",
+ tests[i].trc, tests[i].func_name, tests[i].arg,
+ tests[i].result, result);
+  }
+}
+
+// LCOV_EXCL_STOP
+#endif
diff --git a/tests/fate/libavutil.mak b/tests/fate/libavutil.mak
index 022ae6a..a89bc1d 100644
--- a/tests/fate/libavutil.mak
+++ b/tests/fate/libavutil.mak
@@ -48,6 +48,10 @@ FATE_LIBAVUTIL += 

[FFmpeg-devel] Patch: Add test for avpriv_get_trc_function_from_trc function

2016-03-01 Thread NagaChaitanya Vellanki
Hi all,
This is my first patch. git send-mail did not work for me. Sending the
patch via gmail gui. Please review my patch.

Thank you,
NagaChaitanya Vellanki


0001-Add-test-for-avpriv_get_trc_function_from_trc-functi.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel


[FFmpeg-devel] [PATCH] Add test for avpriv_get_trc_function_from_trc function

2016-03-01 Thread NagaChaitanya Vellanki
---
 libavutil/Makefile  |  1 +
 libavutil/color_utils.c | 53 +
 2 files changed, 54 insertions(+)

diff --git a/libavutil/Makefile b/libavutil/Makefile
index a4d79cd..934564f 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -176,6 +176,7 @@ TESTPROGS = adler32 
\
 bprint  \
 cast5   \
 camellia\
+color_utils \
 cpu \
 crc \
 des \
diff --git a/libavutil/color_utils.c b/libavutil/color_utils.c
index b68b402..0881da8 100644
--- a/libavutil/color_utils.c
+++ b/libavutil/color_utils.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 
+#include "common.h"
 #include "libavutil/color_utils.h"
 #include "libavutil/pixfmt.h"
 
@@ -216,3 +217,55 @@ avpriv_trc_function avpriv_get_trc_function_from_trc(enum 
AVColorTransferCharact
 }
 return func;
 }
+
+#ifdef TEST
+// LCOV_EXCL_START
+
+static int test_avpriv_get_trc_function_from_trc(enum 
AVColorTransferCharacteristic trc, avpriv_trc_function func)
+{
+
+if(avpriv_get_trc_function_from_trc(trc) != func) {
+printf("Failed: invalid function returned for %d\n", trc);
+return 1;
+}
+
+printf("Passed!\n");
+return 0;
+}
+
+int main(int argc, char ** argv)
+{
+int i, error_count = 0;
+struct test {
+enum AVColorTransferCharacteristic trc;
+avpriv_trc_function func;
+} tests[] = {
+{ AVCOL_TRC_BT709, avpriv_trc_bt709 },
+{ AVCOL_TRC_SMPTE170M, avpriv_trc_bt709 },
+{ AVCOL_TRC_BT2020_10, avpriv_trc_bt709 },
+{ AVCOL_TRC_BT2020_12, avpriv_trc_bt709 },
+{ AVCOL_TRC_GAMMA22, avpriv_trc_gamma22 },
+{ AVCOL_TRC_GAMMA28, avpriv_trc_gamma28 },
+{ AVCOL_TRC_SMPTE240M, avpriv_trc_smpte240M },
+{ AVCOL_TRC_LINEAR, avpriv_trc_linear },
+{ AVCOL_TRC_LOG, avpriv_trc_log },
+{ AVCOL_TRC_LOG_SQRT, avpriv_trc_log_sqrt },
+{ AVCOL_TRC_IEC61966_2_4, avpriv_trc_iec61966_2_4 },
+{ AVCOL_TRC_BT1361_ECG, avpriv_trc_bt1361 },
+{ AVCOL_TRC_IEC61966_2_1, avpriv_trc_iec61966_2_1 },
+{ AVCOL_TRC_SMPTEST2084, avpriv_trc_smpte_st2084 },
+{ AVCOL_TRC_SMPTEST428_1, avpriv_trc_smpte_st428_1 },
+{ AVCOL_TRC_RESERVED0, NULL },
+{ AVCOL_TRC_UNSPECIFIED, NULL },
+{ AVCOL_TRC_RESERVED, NULL }
+};
+
+for(i = 0; i < FF_ARRAY_ELEMS(tests); i++) {
+if(test_avpriv_get_trc_function_from_trc(tests[i].trc, tests[i].func)) 
{
+error_count++;
+}
+}
+return !!error_count;
+}
+// LCOV_EXCL_STOP
+#endif
-- 
2.7.2

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


[FFmpeg-devel] [PATCH] Add test for avpriv_get_trc_function_from_trc function

2016-03-01 Thread NagaChaitanya Vellanki
---
 libavutil/Makefile  |  1 +
 libavutil/color_utils.c | 52 +
 2 files changed, 53 insertions(+)

diff --git a/libavutil/Makefile b/libavutil/Makefile
index a4d79cd..934564f 100644
--- a/libavutil/Makefile
+++ b/libavutil/Makefile
@@ -176,6 +176,7 @@ TESTPROGS = adler32 
\
 bprint  \
 cast5   \
 camellia\
+color_utils \
 cpu \
 crc \
 des \
diff --git a/libavutil/color_utils.c b/libavutil/color_utils.c
index b68b402..419de31 100644
--- a/libavutil/color_utils.c
+++ b/libavutil/color_utils.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 
+#include "common.h"
 #include "libavutil/color_utils.h"
 #include "libavutil/pixfmt.h"
 
@@ -216,3 +217,54 @@ avpriv_trc_function avpriv_get_trc_function_from_trc(enum 
AVColorTransferCharact
 }
 return func;
 }
+
+#ifdef TEST
+// LCOV_EXCL_START
+
+static int test_avpriv_get_trc_function_from_trc(enum 
AVColorTransferCharacteristic trc, avpriv_trc_function func) {
+
+if(avpriv_get_trc_function_from_trc(trc) != func) {
+printf("Failed: invalid function returned for %d\n", trc);
+return 1;
+}
+
+printf("Passed!\n");
+return 0;
+}
+
+int main(int argc, char ** argv)
+{
+int i, error_count = 0;
+struct test {
+enum AVColorTransferCharacteristic trc;
+avpriv_trc_function func;
+} tests[] = {
+{ AVCOL_TRC_BT709, avpriv_trc_bt709 },
+{ AVCOL_TRC_SMPTE170M, avpriv_trc_bt709 },
+{ AVCOL_TRC_BT2020_10, avpriv_trc_bt709 },
+{ AVCOL_TRC_BT2020_12, avpriv_trc_bt709 },
+{ AVCOL_TRC_GAMMA22, avpriv_trc_gamma22 },
+{ AVCOL_TRC_GAMMA28, avpriv_trc_gamma28 },
+{ AVCOL_TRC_SMPTE240M, avpriv_trc_smpte240M },
+{ AVCOL_TRC_LINEAR, avpriv_trc_linear },
+{ AVCOL_TRC_LOG, avpriv_trc_log },
+{ AVCOL_TRC_LOG_SQRT, avpriv_trc_log_sqrt },
+{ AVCOL_TRC_IEC61966_2_4, avpriv_trc_iec61966_2_4 },
+{ AVCOL_TRC_BT1361_ECG, avpriv_trc_bt1361 },
+{ AVCOL_TRC_IEC61966_2_1, avpriv_trc_iec61966_2_1 },
+{ AVCOL_TRC_SMPTEST2084, avpriv_trc_smpte_st2084 },
+{ AVCOL_TRC_SMPTEST428_1, avpriv_trc_smpte_st428_1 },
+{ AVCOL_TRC_RESERVED0, NULL },
+{ AVCOL_TRC_UNSPECIFIED, NULL },
+{ AVCOL_TRC_RESERVED, NULL }
+};
+
+for(i = 0; i < FF_ARRAY_ELEMS(tests); i++) {
+if(test_avpriv_get_trc_function_from_trc(tests[i].trc, tests[i].func)) 
{
+error_count++;
+}
+}
+return !!error_count;
+}
+// LCOV_EXCL_STOP
+#endif
-- 
2.7.2

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


[FFmpeg-devel] [PATCH] Add test for avpriv_get_trc_function_from_trc function

2016-03-01 Thread NagaChaitanya Vellanki
Improve coverage by adding test.

NagaChaitanya Vellanki (1):
  Add test for avpriv_get_trc_function_from_trc function

 libavutil/Makefile  |  1 +
 libavutil/color_utils.c | 52 +
 2 files changed, 53 insertions(+)

-- 
2.7.2

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


[FFmpeg-devel] Patch: Add test for avpriv_get_trc_function_from_trc function

2016-03-01 Thread NagaChaitanya Vellanki
Hi all,
This is my first patch. git send-mail did not work for me. Sending the
patch via gmail gui. Please review my patch.

Thank you,
NagaChaitanya Vellanki


0001-Add-test-for-avpriv_get_trc_function_from_trc-functi.patch
Description: Binary data
___
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-devel