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 776ad074..3956cf4d 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_470M, TransferCharacteristics::REC_470_M }, { ZIMG_TRANSFER_470BG, 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 62fa73dc..a1d13153 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_470M = 4, ZIMG_TRANSFER_470BG = 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 0239a974..168ec236 100644 --- a/src/zimg/colorspace/gamma.cpp +++ b/src/zimg/colorspace/gamma.cpp @@ -140,6 +140,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_oetf(float x) noexcept +{ + return x < 0.0f ? 0.0f : zimg_x_powf(x, 1.0f / 2.2f); +} + +float rec_470m_inverse_oetf(float x) noexcept +{ + return x < 0.0f ? 0.0f : zimg_x_powf(x, 2.2f); +} + float rec_470bg_oetf(float x) noexcept { return x < 0.0f ? 0.0f : zimg_x_powf(x, 1.0f / 2.8f); @@ -292,6 +302,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 = scene_referred ? rec_470m_inverse_oetf : rec_1886_eotf; + func.to_gamma = scene_referred ? rec_470m_oetf: rec_1886_eotf; + break; case TransferCharacteristics::REC_470_BG: func.to_linear = scene_referred ? rec_470bg_inverse_oetf : rec_1886_eotf; func.to_gamma = scene_referred ? rec_470bg_oetf: rec_1886_eotf;