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

Michael Niedermayer michael at niedermayer.cc
Thu Mar 3 02:20:49 CET 2016


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 <stddef.h>
>  #include <math.h>
>  
> +#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", 99999.899998, 61.054001 },
> +      { AVCOL_TRC_SMPTE240M, "avpriv_trc_smpte240M", -0.01, 0.0 },
> +      { AVCOL_TRC_SMPTE240M, "avpriv_trc_smpte240M", 0.015, 0.060000 },
> +      { 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.000001 },
> +      { 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 }

this can be simplified, you dont need to list the results explicitly
nor the functions or enum values and the testpoints can be the same
for all


for (i = 0; i<AVCOL_TRC_NB; i++) {
     avpriv_trc_function func = avpriv_get_trc_function_from_trc(i);
     for (j = 0; FF_ARRAY_ELEMS(testpoints); j++) {
         double result = func(testpoints[j]);
         printf(...
     }
}

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

Old school: Use the lowest level language in which you can solve the problem
            conveniently.
New school: Use the highest level language in which the latest supercomputer
            can solve the problem without the user falling asleep waiting.
-------------- 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/65caf222/attachment.sig>


More information about the ffmpeg-devel mailing list