mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-09-29 23:32:33 +00:00
isomp4: Split buffer process functions.
Split the different handling for closed captions, VobSub subpicture and timed text samples into separate simplified process functions. Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1182>
This commit is contained in:
parent
c47c6b4c2b
commit
41d6f47f2b
1 changed files with 65 additions and 38 deletions
|
@ -5669,29 +5669,16 @@ invalid_cdat:
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* the input buffer metadata must be writable,
|
/* Handle Closed Caption sample buffers.
|
||||||
|
* The input buffer metadata must be writable,
|
||||||
* but time/duration etc not yet set and need not be preserved */
|
* but time/duration etc not yet set and need not be preserved */
|
||||||
static GstBuffer *
|
static GstBuffer *
|
||||||
gst_qtdemux_process_buffer (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
gst_qtdemux_process_buffer_clcp (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
||||||
GstBuffer * buf)
|
GstBuffer * buf)
|
||||||
{
|
{
|
||||||
GstMapInfo map;
|
GstMapInfo map;
|
||||||
guint nsize = 0;
|
guint8 *cc;
|
||||||
gchar *str;
|
gsize cclen = 0;
|
||||||
|
|
||||||
/* not many cases for now */
|
|
||||||
if (G_UNLIKELY (CUR_STREAM (stream)->fourcc == FOURCC_mp4s)) {
|
|
||||||
/* send a one time dvd clut event */
|
|
||||||
if (stream->pending_event && stream->pad)
|
|
||||||
gst_pad_push_event (stream->pad, stream->pending_event);
|
|
||||||
stream->pending_event = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (G_UNLIKELY (stream->subtype != FOURCC_text
|
|
||||||
&& stream->subtype != FOURCC_sbtl &&
|
|
||||||
stream->subtype != FOURCC_subp && stream->subtype != FOURCC_clcp)) {
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
gst_buffer_map (buf, &map, GST_MAP_READ);
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
|
|
||||||
|
@ -5701,15 +5688,7 @@ gst_qtdemux_process_buffer (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
||||||
gst_buffer_unref (buf);
|
gst_buffer_unref (buf);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
if (stream->subtype == FOURCC_subp) {
|
|
||||||
/* That's all the processing needed for subpictures */
|
|
||||||
gst_buffer_unmap (buf, &map);
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stream->subtype == FOURCC_clcp) {
|
|
||||||
guint8 *cc;
|
|
||||||
gsize cclen = 0;
|
|
||||||
/* For closed caption, we need to extract the information from the
|
/* For closed caption, we need to extract the information from the
|
||||||
* [cdat],[cdt2] or [ccdp] atom */
|
* [cdat],[cdt2] or [ccdp] atom */
|
||||||
cc = extract_cc_from_data (stream, map.data, map.size, &cclen);
|
cc = extract_cc_from_data (stream, map.data, map.size, &cclen);
|
||||||
|
@ -5722,6 +5701,54 @@ gst_qtdemux_process_buffer (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
||||||
buf = NULL;
|
buf = NULL;
|
||||||
}
|
}
|
||||||
return buf;
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* DVD subpicture specific sample handling.
|
||||||
|
* the input buffer metadata must be writable,
|
||||||
|
* but time/duration etc not yet set and need not be preserved */
|
||||||
|
static GstBuffer *
|
||||||
|
gst_qtdemux_process_buffer_dvd (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
||||||
|
GstBuffer * buf)
|
||||||
|
{
|
||||||
|
/* send a one time dvd clut event */
|
||||||
|
if (stream->pending_event && stream->pad)
|
||||||
|
gst_pad_push_event (stream->pad, stream->pending_event);
|
||||||
|
stream->pending_event = NULL;
|
||||||
|
|
||||||
|
/* empty buffer is sent to terminate previous subtitle */
|
||||||
|
if (gst_buffer_get_size (buf) <= 2) {
|
||||||
|
gst_buffer_unref (buf);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* That's all the processing needed for subpictures */
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Timed text formats
|
||||||
|
* the input buffer metadata must be writable,
|
||||||
|
* but time/duration etc not yet set and need not be preserved */
|
||||||
|
static GstBuffer *
|
||||||
|
gst_qtdemux_process_buffer_text (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
||||||
|
GstBuffer * buf)
|
||||||
|
{
|
||||||
|
GstMapInfo map;
|
||||||
|
guint nsize = 0;
|
||||||
|
gchar *str;
|
||||||
|
|
||||||
|
/* not many cases for now */
|
||||||
|
if (G_UNLIKELY (stream->subtype != FOURCC_text &&
|
||||||
|
stream->subtype != FOURCC_sbtl)) {
|
||||||
|
return buf;
|
||||||
|
}
|
||||||
|
|
||||||
|
gst_buffer_map (buf, &map, GST_MAP_READ);
|
||||||
|
|
||||||
|
/* empty buffer is sent to terminate previous subtitle */
|
||||||
|
if (map.size <= 2) {
|
||||||
|
gst_buffer_unmap (buf, &map);
|
||||||
|
gst_buffer_unref (buf);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsize = GST_READ_UINT16_BE (map.data);
|
nsize = GST_READ_UINT16_BE (map.data);
|
||||||
|
@ -14947,7 +14974,7 @@ qtdemux_sub_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
||||||
case FOURCC_mp4s:
|
case FOURCC_mp4s:
|
||||||
_codec ("DVD subtitle");
|
_codec ("DVD subtitle");
|
||||||
caps = gst_caps_new_empty_simple ("subpicture/x-dvd");
|
caps = gst_caps_new_empty_simple ("subpicture/x-dvd");
|
||||||
stream->process_func = gst_qtdemux_process_buffer;
|
stream->process_func = gst_qtdemux_process_buffer_dvd;
|
||||||
break;
|
break;
|
||||||
case FOURCC_text:
|
case FOURCC_text:
|
||||||
_codec ("Quicktime timed text");
|
_codec ("Quicktime timed text");
|
||||||
|
@ -14958,7 +14985,7 @@ qtdemux_sub_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
||||||
caps = gst_caps_new_simple ("text/x-raw", "format", G_TYPE_STRING,
|
caps = gst_caps_new_simple ("text/x-raw", "format", G_TYPE_STRING,
|
||||||
"utf8", NULL);
|
"utf8", NULL);
|
||||||
/* actual text piece needs to be extracted */
|
/* actual text piece needs to be extracted */
|
||||||
stream->process_func = gst_qtdemux_process_buffer;
|
stream->process_func = gst_qtdemux_process_buffer_text;
|
||||||
break;
|
break;
|
||||||
case FOURCC_stpp:
|
case FOURCC_stpp:
|
||||||
_codec ("XML subtitles");
|
_codec ("XML subtitles");
|
||||||
|
@ -14969,7 +14996,7 @@ qtdemux_sub_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
||||||
caps =
|
caps =
|
||||||
gst_caps_new_simple ("closedcaption/x-cea-608", "format",
|
gst_caps_new_simple ("closedcaption/x-cea-608", "format",
|
||||||
G_TYPE_STRING, "s334-1a", NULL);
|
G_TYPE_STRING, "s334-1a", NULL);
|
||||||
stream->process_func = gst_qtdemux_process_buffer;
|
stream->process_func = gst_qtdemux_process_buffer_clcp;
|
||||||
stream->need_split = TRUE;
|
stream->need_split = TRUE;
|
||||||
break;
|
break;
|
||||||
case FOURCC_c708:
|
case FOURCC_c708:
|
||||||
|
@ -14977,7 +15004,7 @@ qtdemux_sub_caps (GstQTDemux * qtdemux, QtDemuxStream * stream,
|
||||||
caps =
|
caps =
|
||||||
gst_caps_new_simple ("closedcaption/x-cea-708", "format",
|
gst_caps_new_simple ("closedcaption/x-cea-708", "format",
|
||||||
G_TYPE_STRING, "cdp", NULL);
|
G_TYPE_STRING, "cdp", NULL);
|
||||||
stream->process_func = gst_qtdemux_process_buffer;
|
stream->process_func = gst_qtdemux_process_buffer_clcp;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue