summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2017-09-09 12:08:25 +0200
committerAdam Jackson <ajax@redhat.com>2017-09-18 10:16:48 -0400
commit331dc5beee3c1fc2a852f9ecc2173a43d4a99bbb (patch)
treeed582567a30b4b374bdca48da12efa6aaa801a01
parent292a98304bc80b979c2c470e2e3fa03b545c8b68 (diff)
edid-decode: support HLG, decode luminance values
Add support for the new CTA-861-G Hybrid Log-Gamma transfer function. Also decode the luminance values in the static metadata block to cd/m^2 values. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
-rw-r--r--Makefile2
-rw-r--r--edid-decode.c15
2 files changed, 11 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index 21b811e..75c436e 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,7 @@ bindir ?= /usr/bin
mandir ?= /usr/share/man
edid-decode: edid-decode.c
- $(CC) $(CFLAGS) -g -Wall -o $@ $<
+ $(CC) $(CFLAGS) -g -Wall -o $@ $< -lm
clean:
rm -f edid-decode
diff --git a/edid-decode.c b/edid-decode.c
index 2727fd1..b2b116f 100644
--- a/edid-decode.c
+++ b/edid-decode.c
@@ -31,6 +31,7 @@
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
+#include <math.h>
#define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x)))
#define min(a, b) ((a) < (b) ? (a) : (b))
@@ -1861,10 +1862,11 @@ static const char *eotf_map[] = {
"Traditional gamma - SDR luminance range",
"Traditional gamma - HDR luminance range",
"SMPTE ST2084",
+ "Hybrid Log-Gamma",
};
static void
-cea_hdr_metadata_block(unsigned char *x)
+cea_hdr_static_metadata_block(unsigned char *x)
{
int length = x[0] & 0x1f;
int i;
@@ -1885,13 +1887,16 @@ cea_hdr_metadata_block(unsigned char *x)
}
if (length >= 4)
- printf(" Desired content max luminance: %d\n", x[4]);
+ printf(" Desired content max luminance: %d (%.3f cd/m^2)\n",
+ x[4], 50.0 * pow(2, x[4] / 32.0));
if (length >= 5)
- printf(" Desired content max frame-average luminance: %d\n", x[5]);
+ printf(" Desired content max frame-average luminance: %d (%.3f cd/m^2)\n",
+ x[5], 50.0 * pow(2, x[5] / 32.0));
if (length >= 6)
- printf(" Desired content min luminance: %d\n", x[6]);
+ printf(" Desired content min luminance: %d (%.3f cd/m^2)\n",
+ x[6], (50.0 * pow(2, x[4] / 32.0)) * pow(x[6] / 255.0, 2) / 100.0);
}
static void
@@ -1958,7 +1963,7 @@ cea_block(unsigned char *x)
break;
case 0x06:
printf("HDR static metadata data block\n");
- cea_hdr_metadata_block(x);
+ cea_hdr_static_metadata_block(x);
break;
case 0x0d:
printf("Video format preference data block\n");