* [PATCH] edid-decode: print human-readable CTA infoframe types
@ 2023-01-30 17:22 Simon Ser
2023-01-31 9:02 ` Hans Verkuil
0 siblings, 1 reply; 3+ messages in thread
From: Simon Ser @ 2023-01-30 17:22 UTC (permalink / raw)
To: linux-media
Instead of printing the code, print the human-readable infoframe
type. This is more informative.
Signed-off-by: Simon Ser <contact@emersion.fr>
---
parse-cta-block.cpp | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp
index 02730a9eafb1..3a6be3972e50 100644
--- a/parse-cta-block.cpp
+++ b/parse-cta-block.cpp
@@ -2203,6 +2203,17 @@ static void cta_hdr_dyn_metadata_block(const unsigned char *x, unsigned length)
}
}
+static const char *infoframe_types[] = {
+ NULL,
+ "Vendor-Specific",
+ "Auxiliary Video Information",
+ "Source Product Description",
+ "Audio",
+ "MPEG Source",
+ "NTSC VBI",
+ "Dynamic Range and Mastering",
+};
+
static void cta_ifdb(const unsigned char *x, unsigned length)
{
unsigned len_hdr = x[0] >> 5;
@@ -2218,16 +2229,24 @@ static void cta_ifdb(const unsigned char *x, unsigned length)
x += len_hdr + 2;
while (length > 0) {
int payload_len = x[0] >> 5;
+ unsigned char type = x[0] & 0x1f;
+
+ const char *name = NULL;
+ if (type < ARRAY_SIZE(infoframe_types))
+ name = infoframe_types[type];
+ if (name)
+ printf(" %s InfoFrame", name);
+ else
+ printf(" Unknown InfoFrame (%u)", type);
- if ((x[0] & 0x1f) == 1 && length >= 4) {
+ if (type == 1 && length >= 4) {
unsigned oui = (x[3] << 16) | (x[2] << 8) | x[1];
- printf(" InfoFrame Type Code %u, OUI %s\n",
- x[0] & 0x1f, ouitohex(oui).c_str());
+ printf(", OUI %s\n", ouitohex(oui).c_str());
x += 4;
length -= 4;
} else {
- printf(" InfoFrame Type Code %u\n", x[0] & 0x1f);
+ printf("\n");
x++;
length--;
}
base-commit: e052f5f9fdf74ca11aa1a8edfa62eff8d0aa3d0d
--
2.39.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] edid-decode: print human-readable CTA infoframe types
2023-01-30 17:22 [PATCH] edid-decode: print human-readable CTA infoframe types Simon Ser
@ 2023-01-31 9:02 ` Hans Verkuil
2023-01-31 9:38 ` Simon Ser
0 siblings, 1 reply; 3+ messages in thread
From: Hans Verkuil @ 2023-01-31 9:02 UTC (permalink / raw)
To: Simon Ser, linux-media
On 30/01/2023 18:22, Simon Ser wrote:
> Instead of printing the code, print the human-readable infoframe
> type. This is more informative.
>
> Signed-off-by: Simon Ser <contact@emersion.fr>
> ---
> parse-cta-block.cpp | 27 +++++++++++++++++++++++----
> 1 file changed, 23 insertions(+), 4 deletions(-)
>
> diff --git a/parse-cta-block.cpp b/parse-cta-block.cpp
> index 02730a9eafb1..3a6be3972e50 100644
> --- a/parse-cta-block.cpp
> +++ b/parse-cta-block.cpp
> @@ -2203,6 +2203,17 @@ static void cta_hdr_dyn_metadata_block(const unsigned char *x, unsigned length)
> }
> }
>
> +static const char *infoframe_types[] = {
> + NULL,
> + "Vendor-Specific",
> + "Auxiliary Video Information",
> + "Source Product Description",
> + "Audio",
> + "MPEG Source",
> + "NTSC VBI",
> + "Dynamic Range and Mastering",
> +};
> +
> static void cta_ifdb(const unsigned char *x, unsigned length)
> {
> unsigned len_hdr = x[0] >> 5;
> @@ -2218,16 +2229,24 @@ static void cta_ifdb(const unsigned char *x, unsigned length)
> x += len_hdr + 2;
> while (length > 0) {
> int payload_len = x[0] >> 5;
> + unsigned char type = x[0] & 0x1f;
> +
> + const char *name = NULL;
> + if (type < ARRAY_SIZE(infoframe_types))
> + name = infoframe_types[type];
> + if (name)
> + printf(" %s InfoFrame", name);
Can you show the type as well? E.g.: " %s InfoFrame (%u)", name, type
It can be useful to have the code too.
If you can post a v2 with that change, then I'll take it.
Regards,
Hans
> + else
> + printf(" Unknown InfoFrame (%u)", type);
>
> - if ((x[0] & 0x1f) == 1 && length >= 4) {
> + if (type == 1 && length >= 4) {
> unsigned oui = (x[3] << 16) | (x[2] << 8) | x[1];
>
> - printf(" InfoFrame Type Code %u, OUI %s\n",
> - x[0] & 0x1f, ouitohex(oui).c_str());
> + printf(", OUI %s\n", ouitohex(oui).c_str());
> x += 4;
> length -= 4;
> } else {
> - printf(" InfoFrame Type Code %u\n", x[0] & 0x1f);
> + printf("\n");
> x++;
> length--;
> }
>
> base-commit: e052f5f9fdf74ca11aa1a8edfa62eff8d0aa3d0d
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] edid-decode: print human-readable CTA infoframe types
2023-01-31 9:02 ` Hans Verkuil
@ 2023-01-31 9:38 ` Simon Ser
0 siblings, 0 replies; 3+ messages in thread
From: Simon Ser @ 2023-01-31 9:38 UTC (permalink / raw)
To: Hans Verkuil; +Cc: linux-media
On Tuesday, January 31st, 2023 at 10:02, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> Can you show the type as well? E.g.: " %s InfoFrame (%u)", name, type
>
> It can be useful to have the code too.
Sure. A bit surprising since we never print the raw values for other
fields when we have a human-readable representation, but I'll send a
v2 with that changed.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-01-31 9:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-30 17:22 [PATCH] edid-decode: print human-readable CTA infoframe types Simon Ser
2023-01-31 9:02 ` Hans Verkuil
2023-01-31 9:38 ` Simon Ser
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.