]> git.sesse.net Git - ffmpeg/commitdiff
lavu: Adding ARIB STD-B67 (hybrid log-gamma) enum value and transfer function.
authorNeil Birkbeck <neil.birkbeck@gmail.com>
Thu, 21 Apr 2016 19:00:05 +0000 (12:00 -0700)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 1 Jun 2016 14:32:08 +0000 (16:32 +0200)
Adding hybrid log-gamma (https://en.wikipedia.org/wiki/Hybrid_Log-Gamma)
based on the standardization in ARIB STD-B67:
http://www.arib.or.jp/english/html/overview/doc/2-STD-B67v1_0.pdf

The choice of enum value of 18 is consistent with HEVC:
http://phenix.it-sudparis.eu/jct/doc_end_user/current_document.php?id=10481

And also with latest proposal for color format in mkv:
https://mailarchive.ietf.org/arch/search/?email_list=cellar&gbt=1&q=Colour+Format+proposal

The implementation assumes a nominal input range of [0, 1], which is
consistent with HEVC.

Signed-off-by: Neil Birkbeck <neil.birkbeck@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavutil/color_utils.c
libavutil/pixdesc.c
libavutil/pixfmt.h
tests/ref/fate/color_utils

index 63f2230980020aca9ac7045f39ee32f606a2c475..eb8bc7b5fc0df1f9f433280ce17e9cb4f1bffa86 100644 (file)
@@ -155,6 +155,18 @@ static double avpriv_trc_smpte_st428_1(double Lc)
          :              pow(48.0 * Lc / 52.37, 1.0 / 2.6);
 }
 
+
+static double avpriv_trc_arib_std_b67(double Lc) {
+    // The function uses the definition from HEVC, which assumes that the peak
+    // white is input level = 1. (this is equivalent to scaling E = Lc * 12 and
+    // using the definition from the ARIB STD-B67 spec)
+    const double a = 0.17883277;
+    const double b = 0.28466892;
+    const double c = 0.55991073;
+    return (0.0 > Lc) ? 0.0 :
+        (Lc <= 1.0 / 12.0 ? sqrt(3.0 * Lc) : a * log(12.0 * Lc - b) + c);
+}
+
 avpriv_trc_function avpriv_get_trc_function_from_trc(enum AVColorTransferCharacteristic trc)
 {
     avpriv_trc_function func = NULL;
@@ -209,6 +221,10 @@ avpriv_trc_function avpriv_get_trc_function_from_trc(enum AVColorTransferCharact
             func = avpriv_trc_smpte_st428_1;
             break;
 
+        case AVCOL_TRC_ARIB_STD_B67:
+            func = avpriv_trc_arib_std_b67;
+            break;
+
         case AVCOL_TRC_RESERVED0:
         case AVCOL_TRC_UNSPECIFIED:
         case AVCOL_TRC_RESERVED:
index c630d840ce9772ef2773a01643b686268440a155..413698051a025c81c21a97a42f606df5378ebba4 100644 (file)
@@ -2080,6 +2080,7 @@ static const char *color_transfer_names[AVCOL_TRC_NB] = {
     "bt470bg", "smpte170m", "smpte240m", "linear", "log100",
     "log316", "iec61966-2-4", "bt1361e", "iec61966-2-1",
     "bt2020-10", "bt2020-20", "smpte2084", "smpte428-1",
+    "arib-std-b67"
 };
 
 static const char *color_space_names[AVCOL_SPC_NB] = {
index 41e910685f39ccb6d6f3bdf03ef900dc631972c6..bc0cf9e19093a345aa54f148f74d9fd7a492ec52 100644 (file)
@@ -420,6 +420,7 @@ enum AVColorTransferCharacteristic {
     AVCOL_TRC_BT2020_12    = 15, ///< ITU-R BT2020 for 12 bit system
     AVCOL_TRC_SMPTEST2084  = 16, ///< SMPTE ST 2084 for 10, 12, 14 and 16 bit systems
     AVCOL_TRC_SMPTEST428_1 = 17, ///< SMPTE ST 428-1
+    AVCOL_TRC_ARIB_STD_B67 = 18, ///< ARIB STD-B67, known as "Hybrid log-gamma"
     AVCOL_TRC_NB,                ///< Not part of ABI
 };
 
index 6e80ebd97f89113f8eb68144eea817e3badb1359..10f805591609c57035b2d362c4be753dfd56b918 100644 (file)
@@ -283,3 +283,22 @@ AVColorTransferCharacteristic=17 calling func(15123.456700) expected=39.174525
 AVColorTransferCharacteristic=17 calling func(19845.889230) expected=43.490646
 AVColorTransferCharacteristic=17 calling func(98678.423100) expected=80.593559
 AVColorTransferCharacteristic=17 calling func(99999.899998) expected=81.006971
+AVColorTransferCharacteristic=18 calling func(-0.100000) expected=0.000000
+AVColorTransferCharacteristic=18 calling func(-0.018054) expected=0.000000
+AVColorTransferCharacteristic=18 calling func(-0.010000) expected=0.000000
+AVColorTransferCharacteristic=18 calling func(-0.004490) expected=0.000000
+AVColorTransferCharacteristic=18 calling func(0.000000) expected=0.000000
+AVColorTransferCharacteristic=18 calling func(0.003162) expected=0.097400
+AVColorTransferCharacteristic=18 calling func(0.005000) expected=0.122474
+AVColorTransferCharacteristic=18 calling func(0.009000) expected=0.164317
+AVColorTransferCharacteristic=18 calling func(0.015000) expected=0.212132
+AVColorTransferCharacteristic=18 calling func(0.100000) expected=0.544089
+AVColorTransferCharacteristic=18 calling func(1.000000) expected=1.000000
+AVColorTransferCharacteristic=18 calling func(52.370000) expected=1.712092
+AVColorTransferCharacteristic=18 calling func(125.098765) expected=1.867862
+AVColorTransferCharacteristic=18 calling func(1999.111230) expected=2.363502
+AVColorTransferCharacteristic=18 calling func(6945.443000) expected=2.586219
+AVColorTransferCharacteristic=18 calling func(15123.456700) expected=2.725380
+AVColorTransferCharacteristic=18 calling func(19845.889230) expected=2.773978
+AVColorTransferCharacteristic=18 calling func(98678.423100) expected=3.060803
+AVColorTransferCharacteristic=18 calling func(99999.899998) expected=3.063182