diff --git a/src/testapp/table.cpp b/src/testapp/table.cpp index 9d0eaf20..164d6435 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 }, { "log10", TransferCharacteristics::LOG_10 }, { "log316", TransferCharacteristics::LOG_SQRT }, { "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/zimg/api/zimg.cpp b/src/zimg/api/zimg.cpp index fb6586af..ebb5afbb 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 3c15ceb2..ebf78dfd 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 424e90c1..2c4d62cf 100644 --- a/src/zimg/colorspace/colorspace.h +++ b/src/zimg/colorspace/colorspace.h @@ -38,6 +38,7 @@ enum class TransferCharacteristics { LOG_10, LOG_SQRT, 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 cafdb06d..e7515cd3 100644 --- a/src/zimg/colorspace/gamma.cpp +++ b/src/zimg/colorspace/gamma.cpp @@ -120,6 +120,16 @@ float rec_1886_inverse_eotf(float x) noexcept return x < 0.0f ? 0.0f : zimg_x_powf(x, 1.0f / 2.4f); } +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); @@ -312,6 +322,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;