This is an automatic generated email to let you know that the following patch were queued at the http://git.linuxtv.org/cgit.cgi/v4l-utils.git tree:
Subject: edid-decode: transfer characteristics improvements Author: Hans Verkuil <hverk...@xs4all.nl> Date: Tue Jan 28 09:43:39 2025 +0100 The code parsing the DisplayID Transfer Characteristics Data Block was a bit confusing. Reorganize it and improve the comments. Signed-off-by: Maciej Miszczyk <mmiszc...@logitech.com> Signed-off-by: Hans Verkuil <hverk...@xs4all.nl> utils/edid-decode/parse-displayid-block.cpp | 48 ++++++++++++++++------------- 1 file changed, 27 insertions(+), 21 deletions(-) --- http://git.linuxtv.org/cgit.cgi/v4l-utils.git/commit/?id=f29f69d439c9cb03c232b044a797fa3d2861d0ba diff --git a/utils/edid-decode/parse-displayid-block.cpp b/utils/edid-decode/parse-displayid-block.cpp index 2728ffa0ccb1..ca59ee12a059 100644 --- a/utils/edid-decode/parse-displayid-block.cpp +++ b/utils/edid-decode/parse-displayid-block.cpp @@ -733,46 +733,52 @@ void edid_state::parse_displayid_transfer_characteristics(const unsigned char *x unsigned len = x[2] - 1; for (unsigned i = 0; len; i++) { + unsigned samples = x[offset]; + + if (!samples) { + fail("Found a curve with 0 samples.\n"); + samples = 1; + } + + // If not using four_param, then decrement the number of samples + // by one since the last sample isn't stored. + if (!four_param) + samples--; + + if (four_param && samples != 5) { + fail("Expected 5 samples.\n"); + samples = 5; + } + if (samples + 1 > len) { + fail("Length %u is too small to hold %u samples at offset %u.\n", + len, samples, offset + 1); + break; + } + if ((x[3] & 0x80) && !i) printf(" White curve: "); else printf(" Response curve #%u:", i - first_is_white); - unsigned samples = x[offset]; - if (!samples) - break; - if (offset + samples >= len) { - fail("Length %u is too small to hold %u samples at %u offset.\n", - len, samples, offset); - break; - } if (four_param) { - if (samples != 5) - fail("Expected 5 samples.\n"); printf(" A0=%u A1=%u A2=%u A3=%u Gamma=%.2f\n", x[offset + 1], x[offset + 2], x[offset + 3], x[offset + 4], (double)(x[offset + 5] + 100.0) / 100.0); - samples++; } else { double sum = 0; - // The spec is not very clear about the number of samples: - // should this be interpreted as the actual number of - // samples stored in this Data Block, or as the number of - // samples in the curve, but where the last sample is not - // actually stored since it is always 0x3ff. - // - // The ATP Manager interprets this as the latter, so that's - // what we implement here. + // The number of samples is the number of samples in the + // curve, where the last sample is not actually stored + // since it is always 0x3ff. for (unsigned j = offset + 1; j < offset + samples; j++) { sum += x[j]; printf(" %.2f", sum * 100.0 / 1023.0); } printf(" 100.00\n"); } - offset += samples; - len -= samples; + offset += samples + 1; + len -= samples + 1; } }