diff --git a/src/testapp/table.cpp b/src/testapp/table.cpp index 9426c826..0d964e77 100644 --- a/src/testapp/table.cpp +++ b/src/testapp/table.cpp @@ -76,13 +76,14 @@ const zimg::static_string_map g_matrix_table{ { "ictcp", MatrixCoefficients::REC_2100_ICTCP }, }; -const zimg::static_string_map g_transfer_table{ +const zimg::static_string_map g_transfer_table{ { "unspec", TransferCharacteristics::UNSPECIFIED }, { "linear", TransferCharacteristics::LINEAR }, { "log100", TransferCharacteristics::LOG_100 }, { "log316", TransferCharacteristics::LOG_316 }, { "240m", TransferCharacteristics::SMPTE_240M }, { "709", TransferCharacteristics::REC_709 }, + { "470m", TransferCharacteristics::REC_470_M }, { "470bg", TransferCharacteristics::REC_470_BG }, { "xvycc", TransferCharacteristics::XVYCC }, { "srgb", TransferCharacteristics::SRGB }, diff --git a/src/testapp/table.h b/src/testapp/table.h index 65424832..eabc6591 100644 --- a/src/testapp/table.h +++ b/src/testapp/table.h @@ -37,7 +37,7 @@ class Filter; extern const zimg::static_string_map g_cpu_table; extern const zimg::static_string_map g_pixel_table; extern const zimg::static_string_map g_matrix_table; -extern const zimg::static_string_map g_transfer_table; +extern const zimg::static_string_map g_transfer_table; extern const zimg::static_string_map g_primaries_table; extern const zimg::static_string_map g_dither_table; extern const zimg::static_string_map(*)(double, double), 7> g_resize_table; diff --git a/src/zimg/api/zimg.cpp b/src/zimg/api/zimg.cpp index 43b3cae7..9102aa3b 100644 --- a/src/zimg/api/zimg.cpp +++ b/src/zimg/api/zimg.cpp @@ -250,11 +250,12 @@ zimg::colorspace::TransferCharacteristics translate_transfer(zimg_transfer_chara { using zimg::colorspace::TransferCharacteristics; - static SM_CONSTEXPR_14 const zimg::static_map map{ + static SM_CONSTEXPR_14 const zimg::static_map map{ { ZIMG_TRANSFER_709, TransferCharacteristics::REC_709 }, { ZIMG_TRANSFER_UNSPECIFIED, TransferCharacteristics::UNSPECIFIED }, { ZIMG_TRANSFER_240M, TransferCharacteristics::SMPTE_240M }, { ZIMG_TRANSFER_601, TransferCharacteristics::REC_709 }, + { ZIMG_TRANSFER_470_M, TransferCharacteristics::REC_470_M }, { ZIMG_TRANSFER_470_BG, TransferCharacteristics::REC_470_BG }, { ZIMG_TRANSFER_IEC_61966_2_4, TransferCharacteristics::XVYCC }, { ZIMG_TRANSFER_IEC_61966_2_1, TransferCharacteristics::SRGB }, diff --git a/src/zimg/api/zimg.h b/src/zimg/api/zimg.h index 0ff5652b..3dd50869 100644 --- a/src/zimg/api/zimg.h +++ b/src/zimg/api/zimg.h @@ -280,6 +280,7 @@ typedef enum zimg_transfer_characteristics_e { ZIMG_TRANSFER_INTERNAL = -1, /**< Not part of the API. */ ZIMG_TRANSFER_709 = 1, ZIMG_TRANSFER_UNSPECIFIED = 2, + ZIMG_TRANSFER_470_M = 4, ZIMG_TRANSFER_470_BG = 5, ZIMG_TRANSFER_601 = 6, /* Equivalent to 1. */ ZIMG_TRANSFER_240M = 7, diff --git a/src/zimg/colorspace/colorspace.h b/src/zimg/colorspace/colorspace.h index 6afa7ead..08bc1610 100644 --- a/src/zimg/colorspace/colorspace.h +++ b/src/zimg/colorspace/colorspace.h @@ -38,6 +38,7 @@ enum class TransferCharacteristics { LOG_100, LOG_316, REC_709, + REC_470_M, REC_470_BG, SMPTE_240M, XVYCC, diff --git a/src/zimg/colorspace/gamma.cpp b/src/zimg/colorspace/gamma.cpp index c9eef54e..4f9f29cf 100644 --- a/src/zimg/colorspace/gamma.cpp +++ b/src/zimg/colorspace/gamma.cpp @@ -137,6 +137,16 @@ float log316_inverse_oetf(float x) noexcept return x <= 0.0f ? 0.00316227766f : zimg_x_powf(10, 2.5 * (x - 1.0f)); } +float rec_470m_eotf(float x) noexcept +{ + return x < 0.0f ? 0.0f : zimg_x_powf(x, 2.2f); +} + +float rec_470m_inverse_eotf(float x) noexcept +{ + return x < 0.0f ? 0.0f : zimg_x_powf(x, 1.0f / 2.2f); +} + float rec_470bg_eotf(float x) noexcept { return x < 0.0f ? 0.0f : zimg_x_powf(x, 2.8f); @@ -279,6 +289,10 @@ TransferFunction select_transfer_function(TransferCharacteristics transfer, doub func.to_linear = scene_referred ? rec_709_inverse_oetf : rec_1886_eotf; func.to_gamma = scene_referred ? rec_709_oetf : rec_1886_inverse_eotf; break; + case TransferCharacteristics::REC_470_M: + func.to_linear = rec_470m_eotf; + func.to_gamma = rec_470m_inverse_eotf; + break; case TransferCharacteristics::REC_470_BG: func.to_linear = rec_470bg_eotf; func.to_gamma = rec_470bg_inverse_eotf;