Skip to content

Commit

Permalink
nclx: use default values that match sRGB
Browse files Browse the repository at this point in the history
  • Loading branch information
kleisauke committed Oct 29, 2023
1 parent 673fb03 commit 3bc7572
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions libheif/color-conversion/colorconversion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -520,18 +520,18 @@ std::shared_ptr<HeifPixelImage> convert_colorspace(const std::shared_ptr<HeifPix
input_state.nclx_profile = *input->get_color_profile_nclx();
}

// If some input nclx values are unspecified, use CCIR-601 values as default.
// If some input nclx values are unspecified, use values that match sRGB as default.

if (input_state.nclx_profile.get_matrix_coefficients() == heif_matrix_coefficients_unspecified) {
input_state.nclx_profile.set_matrix_coefficients(heif_matrix_coefficients_ITU_R_BT_601_6);
input_state.nclx_profile.set_matrix_coefficients(heif_matrix_coefficients_ITU_R_BT_709_5);
}

if (input_state.nclx_profile.get_colour_primaries() == heif_color_primaries_unspecified) {
input_state.nclx_profile.set_colour_primaries(heif_color_primaries_ITU_R_BT_601_6);
input_state.nclx_profile.set_colour_primaries(heif_color_primaries_ITU_R_BT_709_5);
}

if (input_state.nclx_profile.get_transfer_characteristics() == heif_color_primaries_unspecified) {
input_state.nclx_profile.set_transfer_characteristics(heif_transfer_characteristic_ITU_R_BT_601_6);
input_state.nclx_profile.set_transfer_characteristics(heif_transfer_characteristic_IEC_61966_2_1);
}

std::set<enum heif_channel> channels = input->get_channel_set();
Expand Down
12 changes: 6 additions & 6 deletions libheif/nclx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -294,9 +294,9 @@ struct heif_color_profile_nclx* color_profile_nclx::alloc_nclx_color_profile()

if (profile) {
profile->version = 1;
profile->color_primaries = heif_color_primaries_unspecified;
profile->transfer_characteristics = heif_transfer_characteristic_unspecified;
profile->matrix_coefficients = heif_matrix_coefficients_ITU_R_BT_601_6;
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;
profile->full_range_flag = true;
}

Expand All @@ -312,9 +312,9 @@ void color_profile_nclx::free_nclx_color_profile(struct heif_color_profile_nclx*

void color_profile_nclx::set_default()
{
m_colour_primaries = 2;
m_transfer_characteristics = 2;
m_matrix_coefficients = 6;
m_colour_primaries = 1;
m_transfer_characteristics = 13;
m_matrix_coefficients = 1;
m_full_range_flag = true;
}

Expand Down

0 comments on commit 3bc7572

Please sign in to comment.