Commit 327a79e9 authored by Matthew Waters's avatar Matthew Waters 🐨 Committed by GStreamer Merge Bot

ccconverter: output warning log if parsing a cdp packet fails

Simplifies figuring out why there may be no output from ccconverter with
a cdp input.

Part-of: <!1400>
parent 6fa4a8c3
......@@ -621,6 +621,10 @@ cc_data_extract_cea608 (guint8 * cc_data, guint cc_data_len,
gboolean cc_valid = (cc_data[i * 3] & 0x04) == 0x04;
guint8 cc_type = cc_data[i * 3] & 0x03;
GST_TRACE ("0x%02x 0x%02x 0x%02x, valid: %u, type: 0b%u%u",
cc_data[i * 3 + 0], cc_data[i * 3 + 1], cc_data[i * 3 + 2], cc_valid,
cc_type & 0x2, cc_type & 0x1);
if (cc_type == 0x00) {
if (!cc_valid)
continue;
......@@ -1081,27 +1085,41 @@ convert_cea708_cdp_cea708_cc_data_internal (GstCCConverter * self,
memset (tc, 0, sizeof (*tc));
/* Header + footer length */
if (cdp_len < 11)
if (cdp_len < 11) {
GST_WARNING_OBJECT (self, "cdp packet too short (%u). expected at "
"least %u", cdp_len, 11);
return 0;
}
gst_byte_reader_init (&br, cdp, cdp_len);
u16 = gst_byte_reader_get_uint16_be_unchecked (&br);
if (u16 != 0x9669)
if (u16 != 0x9669) {
GST_WARNING_OBJECT (self, "cdp packet does not have initial magic bytes "
"of 0x9669");
return 0;
}
u8 = gst_byte_reader_get_uint8_unchecked (&br);
if (u8 != cdp_len)
if (u8 != cdp_len) {
GST_WARNING_OBJECT (self, "cdp packet length (%u) does not match passed "
"in value (%u)", u8, cdp_len);
return 0;
}
u8 = gst_byte_reader_get_uint8_unchecked (&br);
fps_entry = cdp_fps_entry_from_id (u8);
if (!fps_entry || fps_entry->fps_n == 0)
if (!fps_entry || fps_entry->fps_n == 0) {
GST_WARNING_OBJECT (self, "cdp packet does not have a valid framerate "
"id (0x%02x", u8);
return 0;
}
flags = gst_byte_reader_get_uint8_unchecked (&br);
/* No cc_data? */
if ((flags & 0x40) == 0)
if ((flags & 0x40) == 0) {
GST_DEBUG_OBJECT (self, "cdp packet does have any cc_data");
return 0;
}
/* cdp_hdr_sequence_cntr */
gst_byte_reader_skip_unchecked (&br, 2);
......@@ -1111,20 +1129,32 @@ convert_cea708_cdp_cea708_cc_data_internal (GstCCConverter * self,
guint8 hours, minutes, seconds, frames, fields;
gboolean drop_frame;
if (gst_byte_reader_get_remaining (&br) < 5)
if (gst_byte_reader_get_remaining (&br) < 5) {
GST_WARNING_OBJECT (self, "cdp packet does not have enough data to "
"contain a timecode (%u). Need at least 5 bytes",
gst_byte_reader_get_remaining (&br));
return 0;
if (gst_byte_reader_get_uint8_unchecked (&br) != 0x71)
}
u8 = gst_byte_reader_get_uint8_unchecked (&br);
if (u8 != 0x71) {
GST_WARNING_OBJECT (self, "cdp packet does not have timecode start byte "
"of 0x71, found 0x%02x", u8);
return 0;
}
u8 = gst_byte_reader_get_uint8_unchecked (&br);
if ((u8 & 0xc0) != 0xc0)
if ((u8 & 0xc0) != 0xc0) {
GST_WARNING_OBJECT (self, "reserved bits are not 0xc0, found 0x%02x", u8);
return 0;
}
hours = ((u8 >> 4) & 0x3) * 10 + (u8 & 0xf);
u8 = gst_byte_reader_get_uint8_unchecked (&br);
if ((u8 & 0x80) != 0x80)
if ((u8 & 0x80) != 0x80) {
GST_WARNING_OBJECT (self, "reserved bit is not 0x80, found 0x%02x", u8);
return 0;
}
minutes = ((u8 >> 4) & 0x7) * 10 + (u8 & 0xf);
u8 = gst_byte_reader_get_uint8_unchecked (&br);
......@@ -1135,8 +1165,10 @@ convert_cea708_cdp_cea708_cc_data_internal (GstCCConverter * self,
seconds = ((u8 >> 4) & 0x7) * 10 + (u8 & 0xf);
u8 = gst_byte_reader_get_uint8_unchecked (&br);
if (u8 & 0x40)
if (u8 & 0x40) {
GST_WARNING_OBJECT (self, "reserved bit is not 0x0, found 0x%02x", u8);
return 0;
}
drop_frame = ! !(u8 & 0x80);
frames = ((u8 >> 4) & 0x3) * 10 + (u8 & 0xf);
......@@ -1151,14 +1183,22 @@ convert_cea708_cdp_cea708_cc_data_internal (GstCCConverter * self,
if (flags & 0x40) {
guint8 cc_count;
if (gst_byte_reader_get_remaining (&br) < 2)
if (gst_byte_reader_get_remaining (&br) < 2) {
GST_WARNING_OBJECT (self, "not enough data to contain valid cc_data");
return 0;
if (gst_byte_reader_get_uint8_unchecked (&br) != 0x72)
}
u8 = gst_byte_reader_get_uint8_unchecked (&br);
if (u8 != 0x72) {
GST_WARNING_OBJECT (self, "missing cc_data start code of 0x72, "
"found 0x%02x", u8);
return 0;
}
cc_count = gst_byte_reader_get_uint8_unchecked (&br);
if ((cc_count & 0xe0) != 0xe0)
if ((cc_count & 0xe0) != 0xe0) {
GST_WARNING_OBJECT (self, "reserved bits are not 0xe0, found 0x%02x", u8);
return 0;
}
cc_count &= 0x1f;
len = 3 * cc_count;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment