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

Michael Niedermayer michael at niedermayer.cc
Thu Mar 3 20:59:36 CET 2016


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 <stddef.h>
>  #include <math.h>
>  
> +#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, 99999.899998
> +  };
> +
> +  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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160303/2332efc1/attachment.sig>


More information about the ffmpeg-devel mailing list