diff --git a/examples/heif_enc.cc b/examples/heif_enc.cc index a62f878d18..f98a379138 100644 --- a/examples/heif_enc.cc +++ b/examples/heif_enc.cc @@ -64,9 +64,9 @@ int metadata_compression = 0; const char* encoderId = nullptr; std::string chroma_downsampling; -uint16_t nclx_matrix_coefficients = 1; uint16_t nclx_colour_primaries = 1; uint16_t nclx_transfer_characteristic = 13; +uint16_t nclx_matrix_coefficients = 5; int nclx_full_range = true; std::string property_pitm_description; diff --git a/libheif/color-conversion/colorconversion.cc b/libheif/color-conversion/colorconversion.cc index 3a7b35315b..5a0d6b57a4 100644 --- a/libheif/color-conversion/colorconversion.cc +++ b/libheif/color-conversion/colorconversion.cc @@ -520,7 +520,7 @@ std::shared_ptr convert_colorspace(const std::shared_ptrget_color_profile_nclx(); } - input_state.nclx_profile.replace_undefined_values_with_defaults(); + input_state.nclx_profile.replace_undefined_values_with_sRGB_defaults(); std::set channels = input->get_channel_set(); assert(!channels.empty()); diff --git a/libheif/context.cc b/libheif/context.cc index ec850c8e74..c7e49ea538 100644 --- a/libheif/context.cc +++ b/libheif/context.cc @@ -2446,7 +2446,7 @@ static std::shared_ptr compute_target_nclx_profile(const std target_nclx_profile->set_undefined(); } - target_nclx_profile->replace_undefined_values_with_defaults(); + target_nclx_profile->replace_undefined_values_with_sRGB_defaults(); return target_nclx_profile; } diff --git a/libheif/nclx.cc b/libheif/nclx.cc index ded33d8fe2..3be972d7ca 100644 --- a/libheif/nclx.cc +++ b/libheif/nclx.cc @@ -294,9 +294,11 @@ struct heif_color_profile_nclx* color_profile_nclx::alloc_nclx_color_profile() if (profile) { profile->version = 1; - profile->color_primaries = heif_color_primaries_ITU_R_BT_709_5; - profile->transfer_characteristics = heif_transfer_characteristic_IEC_61966_2_1; - profile->matrix_coefficients = heif_matrix_coefficients_ITU_R_BT_709_5; + + // sRGB defaults + profile->color_primaries = heif_color_primaries_ITU_R_BT_709_5; // 1 + profile->transfer_characteristics = heif_transfer_characteristic_IEC_61966_2_1; // 13 + profile->matrix_coefficients = heif_matrix_coefficients_ITU_R_BT_470_6_System_B_G; // 5 profile->full_range_flag = true; } @@ -312,9 +314,10 @@ void color_profile_nclx::free_nclx_color_profile(struct heif_color_profile_nclx* void color_profile_nclx::set_default() { + // sRGB defaults m_colour_primaries = 1; m_transfer_characteristics = 13; - m_matrix_coefficients = 1; + m_matrix_coefficients = 5; m_full_range_flag = true; } @@ -339,10 +342,10 @@ void color_profile_nclx::set_from_heif_color_profile_nclx(const struct heif_colo } -void color_profile_nclx::replace_undefined_values_with_defaults() +void color_profile_nclx::replace_undefined_values_with_sRGB_defaults() { if (m_matrix_coefficients == heif_matrix_coefficients_unspecified) { - m_matrix_coefficients = heif_matrix_coefficients_ITU_R_BT_709_5; + m_matrix_coefficients = heif_matrix_coefficients_ITU_R_BT_470_6_System_B_G; } if (m_colour_primaries == heif_color_primaries_unspecified) { diff --git a/libheif/nclx.h b/libheif/nclx.h index 12c0448057..ad832752dd 100644 --- a/libheif/nclx.h +++ b/libheif/nclx.h @@ -159,7 +159,7 @@ class color_profile_nclx : public color_profile void set_from_heif_color_profile_nclx(const struct heif_color_profile_nclx* nclx); - void replace_undefined_values_with_defaults(); + void replace_undefined_values_with_sRGB_defaults(); private: uint16_t m_colour_primaries = heif_color_primaries_unspecified;