isomp4: Replace GST_VIDEO_CAPTION_TYPE_CEA608_IN_CEA708_RAW with CEA608_S334_1A

For the demuxer we have to select line offset 0 for the time being as
this information is not passed over MOV.
This commit is contained in:
Sebastian Dröge 2018-12-10 17:34:03 +02:00 committed by Sebastian Dröge
parent 59d398b66c
commit 4f7ef56c53
3 changed files with 17 additions and 16 deletions

View file

@ -882,7 +882,7 @@ gst_qt_mux_prepare_jpc_buffer (GstQTPad * qtpad, GstBuffer * buf,
} }
static gsize static gsize
extract_608_field_from_cc_data (const guint8 * ccdata, gsize ccdata_size, extract_608_field_from_s334_1a (const guint8 * ccdata, gsize ccdata_size,
guint field, guint8 ** res) guint field, guint8 ** res)
{ {
guint8 *storage; guint8 *storage;
@ -894,8 +894,8 @@ extract_608_field_from_cc_data (const guint8 * ccdata, gsize ccdata_size,
/* Iterate over the ccdata and put the corresponding tuples for the given field /* Iterate over the ccdata and put the corresponding tuples for the given field
* in the storage */ * in the storage */
for (i = 0; i < ccdata_size; i += 3) { for (i = 0; i < ccdata_size; i += 3) {
if ((field == 1 && ccdata[i * 3] == 0xfc) || if ((field == 1 && (ccdata[i * 3] & 0x80)) ||
(field == 2 && ccdata[i * 3] == 0xfd)) { (field == 2 && !(ccdata[i * 3] & 0x80))) {
GST_DEBUG ("Storing matching cc for field %d : 0x%02x 0x%02x", field, GST_DEBUG ("Storing matching cc for field %d : 0x%02x 0x%02x", field,
ccdata[i * 3 + 1], ccdata[i * 3 + 2]); ccdata[i * 3 + 1], ccdata[i * 3 + 2]);
if (res_size >= storage_size) { if (res_size >= storage_size) {
@ -948,9 +948,9 @@ gst_qt_mux_prepare_caption_buffer (GstQTPad * qtpad, GstBuffer * buf,
gsize write_offs = 0; gsize write_offs = 0;
cdat_size = cdat_size =
extract_608_field_from_cc_data (inmap.data, inmap.size, 1, &cdat); extract_608_field_from_s334_1a (inmap.data, inmap.size, 1, &cdat);
cdt2_size = cdt2_size =
extract_608_field_from_cc_data (inmap.data, inmap.size, 2, &cdt2); extract_608_field_from_s334_1a (inmap.data, inmap.size, 2, &cdt2);
if (cdat_size) if (cdat_size)
total_size += cdat_size + 8; total_size += cdat_size + 8;
@ -6108,7 +6108,7 @@ gst_qt_mux_caption_sink_set_caps (GstQTPad * qtpad, GstCaps * caps)
structure = gst_caps_get_structure (caps, 0); structure = gst_caps_get_structure (caps, 0);
/* We know we only handle 608,format=cc_data and 708,format=cdp */ /* We know we only handle 608,format=s334-1a and 708,format=cdp */
if (gst_structure_has_name (structure, "closedcaption/x-cea-608")) { if (gst_structure_has_name (structure, "closedcaption/x-cea-608")) {
fourcc_entry = FOURCC_c608; fourcc_entry = FOURCC_c608;
} else if (gst_structure_has_name (structure, "closedcaption/x-cea-708")) { } else if (gst_structure_has_name (structure, "closedcaption/x-cea-708")) {

View file

@ -167,7 +167,7 @@
"format=(string)utf8" "format=(string)utf8"
#define CEA608_CAPS \ #define CEA608_CAPS \
"closedcaption/x-cea-608, format=(string)cc_data" "closedcaption/x-cea-608, format=(string)s334-1a"
#define CEA708_CAPS \ #define CEA708_CAPS \
"closedcaption/x-cea-708, format=(string)cdp" "closedcaption/x-cea-708, format=(string)cdp"

View file

@ -5606,7 +5606,7 @@ gst_qtdemux_align_buffer (GstQTDemux * demux,
} }
static guint8 * static guint8 *
convert_to_ccdata (const guint8 * ccpair, guint8 ccpair_size, guint field, convert_to_s334_1a (const guint8 * ccpair, guint8 ccpair_size, guint field,
gsize * res) gsize * res)
{ {
guint8 *storage; guint8 *storage;
@ -5616,10 +5616,11 @@ convert_to_ccdata (const guint8 * ccpair, guint8 ccpair_size, guint field,
*res = ccpair_size / 2 * 3; *res = ccpair_size / 2 * 3;
storage = g_malloc (*res); storage = g_malloc (*res);
for (i = 0; i * 2 < ccpair_size; i += 1) { for (i = 0; i * 2 < ccpair_size; i += 1) {
/* FIXME: Use line offset 0 as we simply can't know here */
if (field == 1) if (field == 1)
storage[i * 3] = 0xfc; storage[i * 3] = 0x80 | 0x00;
else else
storage[i * 3] = 0xfd; storage[i * 3] = 0x00 | 0x00;
storage[i * 3 + 1] = ccpair[i * 2]; storage[i * 3 + 1] = ccpair[i * 2];
storage[i * 3 + 2] = ccpair[i * 2 + 1]; storage[i * 3 + 2] = ccpair[i * 2 + 1];
} }
@ -5663,11 +5664,11 @@ extract_cc_from_data (QtDemuxStream * stream, const guint8 * data, gsize size,
goto invalid_cdat; goto invalid_cdat;
} }
/* Convert to cc_data triplet */ /* Convert to S334-1 Annex A byte triplet */
if (fourcc == FOURCC_cdat) if (fourcc == FOURCC_cdat)
cdat = convert_to_ccdata (data + 8, atom_length - 8, 1, &cdat_size); cdat = convert_to_s334_1a (data + 8, atom_length - 8, 1, &cdat_size);
else else
cdt2 = convert_to_ccdata (data + 8, atom_length - 8, 2, &cdt2_size); cdt2 = convert_to_s334_1a (data + 8, atom_length - 8, 2, &cdt2_size);
GST_DEBUG_OBJECT (stream->pad, "size:%" G_GSIZE_FORMAT " atom_length:%u", GST_DEBUG_OBJECT (stream->pad, "size:%" G_GSIZE_FORMAT " atom_length:%u",
size, atom_length); size, atom_length);
@ -5679,7 +5680,7 @@ extract_cc_from_data (QtDemuxStream * stream, const guint8 * data, gsize size,
if (fourcc == FOURCC_cdat) { if (fourcc == FOURCC_cdat) {
if (cdat == NULL) if (cdat == NULL)
cdat = cdat =
convert_to_ccdata (data + atom_length + 8, convert_to_s334_1a (data + atom_length + 8,
new_atom_length - 8, 1, &cdat_size); new_atom_length - 8, 1, &cdat_size);
else else
GST_WARNING_OBJECT (stream->pad, GST_WARNING_OBJECT (stream->pad,
@ -5687,7 +5688,7 @@ extract_cc_from_data (QtDemuxStream * stream, const guint8 * data, gsize size,
} else { } else {
if (cdt2 == NULL) if (cdt2 == NULL)
cdt2 = cdt2 =
convert_to_ccdata (data + atom_length + 8, convert_to_s334_1a (data + atom_length + 8,
new_atom_length - 8, 2, &cdt2_size); new_atom_length - 8, 2, &cdt2_size);
else else
GST_WARNING_OBJECT (stream->pad, GST_WARNING_OBJECT (stream->pad,
@ -15329,7 +15330,7 @@ qtdemux_sub_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
_codec ("CEA 608 Closed Caption"); _codec ("CEA 608 Closed Caption");
caps = caps =
gst_caps_new_simple ("closedcaption/x-cea-608", "format", gst_caps_new_simple ("closedcaption/x-cea-608", "format",
G_TYPE_STRING, "cc_data", NULL); G_TYPE_STRING, "s334-1a", NULL);
stream->need_process = TRUE; stream->need_process = TRUE;
break; break;
case FOURCC_c708: case FOURCC_c708: