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

NagaChaitanya Vellanki nagachaitanya.vellanki at gmail.com
Tue Mar 1 20:37:37 CET 2016


---
 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 <stddef.h>
 #include <math.h>
 
+#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



More information about the ffmpeg-devel mailing list