From 7f07d398d1f7cbda0362b8de07642d1ff7a48f73 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 9 Aug 2021 12:48:30 +0200 Subject: [PATCH] Improve prop value pretty-printing in output_log_layers Always print the sign when logging a signed value. Print the full floating point value when logging an fp16 prop. SRC_X amd SRC_Y are fp16 too. --- output.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/output.c b/output.c index 1cd1745..576cd73 100644 --- a/output.c +++ b/output.c @@ -68,6 +68,10 @@ bool liftoff_output_needs_composition(struct liftoff_output *output) return false; } +double fp16_to_double(uint64_t val) { + return (double)(val >> 16) + (double)(val & 0xFFFF) / 0xFFFF; +} + void output_log_layers(struct liftoff_output *output) { struct liftoff_layer *layer; size_t i; @@ -98,12 +102,14 @@ void output_log_layers(struct liftoff_output *output) { if (strcmp(name, "CRTC_X") == 0 || strcmp(name, "CRTC_Y") == 0) { - liftoff_log(LIFTOFF_DEBUG, " %s = %"PRIi32, + liftoff_log(LIFTOFF_DEBUG, " %s = %+"PRIi32, name, (int32_t)value); - } else if (strcmp(name, "SRC_W") == 0 || + } else if (strcmp(name, "SRC_X") == 0 || + strcmp(name, "SRC_Y") == 0 || + strcmp(name, "SRC_W") == 0 || strcmp(name, "SRC_H") == 0) { - liftoff_log(LIFTOFF_DEBUG, " %s = %"PRIu64, - name, value >> 16); + liftoff_log(LIFTOFF_DEBUG, " %s = %f", + name, fp16_to_double(value)); } else { liftoff_log(LIFTOFF_DEBUG, " %s = %"PRIu64, name, value);