edid: Change HDR Static Metadata luminances to be float
They are float in libdisplay-info and our own EDID parsing also returns a float but when then converted both to an integer. Especially the min luminance can be <1. We also don't need a variable for indicating presence of a CTA Static Metadata block. The values are all zero if it is absent. Found by Dor Askayo. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3574>
This commit is contained in:
parent
a06362a001
commit
8677e36c4c
@ -94,6 +94,9 @@ decode_edid_hdr_static_metadata (const struct di_cta_hdr_static_metadata_block *
|
||||
MetaEdidInfo *info)
|
||||
{
|
||||
/* HDR Static Metadata Block */
|
||||
if (hdr->descriptors->type1)
|
||||
info->hdr_static_metadata.sm |= META_EDID_STATIC_METADATA_TYPE1;
|
||||
|
||||
if (hdr->eotfs->traditional_sdr)
|
||||
info->hdr_static_metadata.tf |= META_EDID_TF_TRADITIONAL_GAMMA_SDR;
|
||||
if (hdr->eotfs->traditional_hdr)
|
||||
@ -103,24 +106,12 @@ decode_edid_hdr_static_metadata (const struct di_cta_hdr_static_metadata_block *
|
||||
if (hdr->eotfs->hlg)
|
||||
info->hdr_static_metadata.tf |= META_EDID_TF_HLG;
|
||||
|
||||
if (hdr->descriptors->type1)
|
||||
info->hdr_static_metadata.sm |= META_EDID_STATIC_METADATA_TYPE1;
|
||||
|
||||
if (hdr->desired_content_max_luminance != 0)
|
||||
{
|
||||
info->hdr_static_metadata.max_luminance =
|
||||
hdr->desired_content_max_luminance;
|
||||
}
|
||||
if (hdr->desired_content_max_frame_avg_luminance != 0)
|
||||
{
|
||||
info->hdr_static_metadata.max_fal =
|
||||
hdr->desired_content_max_frame_avg_luminance;
|
||||
}
|
||||
if (hdr->desired_content_min_luminance != 0)
|
||||
{
|
||||
info->hdr_static_metadata.min_luminance =
|
||||
hdr->desired_content_min_luminance;
|
||||
}
|
||||
info->hdr_static_metadata.max_luminance =
|
||||
hdr->desired_content_max_luminance;
|
||||
info->hdr_static_metadata.max_fal =
|
||||
hdr->desired_content_max_frame_avg_luminance;
|
||||
info->hdr_static_metadata.min_luminance =
|
||||
hdr->desired_content_min_luminance;
|
||||
}
|
||||
|
||||
static void
|
||||
@ -437,7 +428,7 @@ static float
|
||||
decode_max_luminance (uint8_t raw)
|
||||
{
|
||||
if (raw == 0)
|
||||
return 0;
|
||||
return 0.f;
|
||||
|
||||
return 50 * powf (2, (float) raw / 32);
|
||||
}
|
||||
@ -447,7 +438,7 @@ decode_min_luminance (uint8_t raw,
|
||||
float max)
|
||||
{
|
||||
if (raw == 0)
|
||||
return 0;
|
||||
return 0.f;
|
||||
|
||||
return max * powf ((float) raw / 255, 2) / 100;
|
||||
}
|
||||
@ -459,7 +450,6 @@ decode_ext_cta_hdr_static_metadata (const uint8_t *data_block,
|
||||
/* CTA-861-H: Table 92 - HDR Static Metadata Data Block (HDR SMDB) */
|
||||
int size;
|
||||
|
||||
info->hdr_static_metadata.available = TRUE;
|
||||
info->hdr_static_metadata.tf = data_block[2];
|
||||
info->hdr_static_metadata.sm = data_block[3];
|
||||
|
||||
|
@ -59,10 +59,9 @@ typedef enum
|
||||
|
||||
struct _MetaEdidHdrStaticMetadata
|
||||
{
|
||||
int available;
|
||||
int max_luminance;
|
||||
int min_luminance;
|
||||
int max_fal;
|
||||
float max_luminance;
|
||||
float min_luminance;
|
||||
float max_fal;
|
||||
MetaEdidTransferFunction tf;
|
||||
MetaEdidStaticMetadataType sm;
|
||||
};
|
||||
|
@ -68,12 +68,14 @@ main (int argc,
|
||||
MetaEdidInfo *edid_info;
|
||||
edid_info = meta_edid_info_new_parse (edid_blob,edid_blob_len);
|
||||
|
||||
g_assert (edid_info != NULL);
|
||||
g_assert (strcmp (edid_info->manufacturer_code, "GSM") == 0);
|
||||
g_assert (edid_info->product_code == 23507);
|
||||
g_assert (edid_info->hdr_static_metadata.max_luminance == 408);
|
||||
g_assert (edid_info->hdr_static_metadata.tf ==
|
||||
(META_EDID_TF_TRADITIONAL_GAMMA_SDR | META_EDID_TF_PQ));
|
||||
g_assert (edid_info->colorimetry ==
|
||||
(META_EDID_COLORIMETRY_BT2020YCC | META_EDID_COLORIMETRY_BT2020RGB));
|
||||
g_assert_nonnull (edid_info);
|
||||
g_assert_cmpstr (edid_info->manufacturer_code, ==, "GSM");
|
||||
g_assert_cmpint (edid_info->product_code, ==, 23507);
|
||||
g_assert_cmpfloat_with_epsilon (edid_info->hdr_static_metadata.max_luminance,
|
||||
408.0f, 1.0f);
|
||||
g_assert_cmpint (edid_info->hdr_static_metadata.tf, ==,
|
||||
(META_EDID_TF_TRADITIONAL_GAMMA_SDR | META_EDID_TF_PQ));
|
||||
g_assert_cmpint (edid_info->colorimetry, ==,
|
||||
(META_EDID_COLORIMETRY_BT2020YCC |
|
||||
META_EDID_COLORIMETRY_BT2020RGB));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user