Re: [FFmpeg-devel] [PATCH] Add test for avpriv_get_trc_function_from_trc function
On Thu, Mar 03, 2016 at 10:01:28AM -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 > > 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[] = { should have been static const but ill change that > + -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); > + } > + } > + } tested on mips and arm qemu as well as mingw, seems working everywhere ill apply it if it is later found to fail somewhere (like msvc) reducing the number of digits printed likely should fix it we have thousands of float compares like this in fate already ... [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The greatest way to live with honor in this world is to be what we pretend to be. -- Socrates signature.asc Description: Digital signature ___ 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
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
Re: [FFmpeg-devel] [PATCH] Add test for avpriv_get_trc_function_from_trc function
On Thu, Mar 03, 2016 at 06:11:19PM +, Derek Buitenhuis 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. it should be ok if the number of digits printed after the decimal point are not too many ill try to test if this works on what i have easy access to [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Everything should be made as simple as possible, but not simpler. -- Albert Einstein signature.asc Description: Digital signature ___ 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
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] [PATCH] 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 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
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 for avpriv_get_trc_function_from_trc function
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
Re: [FFmpeg-devel] [PATCH] Add test for avpriv_get_trc_function_from_trc function
On Tue, Mar 01, 2016 at 09:11:21PM +0100, Michael Niedermayer wrote: > On Tue, Mar 01, 2016 at 11:37:37AM -0800, NagaChaitanya Vellanki wrote: > > --- > > libavutil/Makefile | 1 + > > libavutil/color_utils.c | 53 > > + > > 2 files changed, 54 insertions(+) > > to test avpriv_get_trc_function_from_trc(), one could > for each index test the returned function at a few values, print the > values and have "make fate" compare that output against a reference > file also see how other fate tests are done which compare some output to a reference file for example: 28a2107a8d61af7c7a26f9d4af0716ba12c112a7 [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The educated differ from the uneducated as much as the living from the dead. -- Aristotle signature.asc Description: Digital signature ___ 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
On Tue, Mar 01, 2016 at 11:37:37AM -0800, NagaChaitanya Vellanki wrote: > --- > libavutil/Makefile | 1 + > libavutil/color_utils.c | 53 > + > 2 files changed, 54 insertions(+) to test avpriv_get_trc_function_from_trc(), one could for each index test the returned function at a few values, print the values and have "make fate" compare that output against a reference file [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Opposition brings concord. Out of discord comes the fairest harmony. -- Heraclitus signature.asc Description: Digital signature ___ 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
--- 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
Re: [FFmpeg-devel] [PATCH] Add test for avpriv_get_trc_function_from_trc function
On Tue, Mar 01, 2016 at 10:41:32AM -0800, NagaChaitanya Vellanki wrote: > --- > libavutil/Makefile | 1 + > libavutil/color_utils.c | 52 > + > 2 files changed, 53 insertions(+) > I'm afraid testing the result of a switch with an array has absolutely no value whatsoever. Regards, [...] -- Clément B. signature.asc Description: PGP signature ___ 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
--- 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
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
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