diff --git a/src/backends/edid-parse.c b/src/backends/edid-parse.c index 74e167008..2aeb4a22f 100644 --- a/src/backends/edid-parse.c +++ b/src/backends/edid-parse.c @@ -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]; diff --git a/src/backends/edid.h b/src/backends/edid.h index 4fb510091..38913061b 100644 --- a/src/backends/edid.h +++ b/src/backends/edid.h @@ -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; }; diff --git a/src/tests/edid-tests.c b/src/tests/edid-tests.c index 9fbb5c545..68a9d8d66 100644 --- a/src/tests/edid-tests.c +++ b/src/tests/edid-tests.c @@ -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)); }