qtdemux: make empty subtitle buffer recognition more robust

https://bugzilla.gnome.org/show_bug.cgi?id=696244
This commit is contained in:
Matej Knopp 2013-03-23 04:56:36 +01:00 committed by Tim-Philipp Müller
parent 220d341b77
commit f29e62c131

View file

@ -3603,17 +3603,15 @@ gst_qtdemux_process_buffer (GstQTDemux * qtdemux, QtDemuxStream * stream,
gst_buffer_map (buf, &map, GST_MAP_READ); gst_buffer_map (buf, &map, GST_MAP_READ);
/* empty buffer can be send to terminate previous entry */ /* empty buffer is sent to terminate previous subtitle */
if (map.size == 2 && map.data[0] == 0 && map.data[1] == 0) { if (map.size <= 2) {
gst_buffer_unmap (buf, &map); gst_buffer_unmap (buf, &map);
gst_buffer_unref (buf); gst_buffer_unref (buf);
return NULL; return NULL;
} }
if (G_LIKELY (map.size >= 2)) {
nsize = GST_READ_UINT16_BE (map.data); nsize = GST_READ_UINT16_BE (map.data);
nsize = MIN (nsize, map.size - 2); nsize = MIN (nsize, map.size - 2);
}
GST_LOG_OBJECT (qtdemux, "3GPP timed text subtitle: %d/%" G_GSIZE_FORMAT "", GST_LOG_OBJECT (qtdemux, "3GPP timed text subtitle: %d/%" G_GSIZE_FORMAT "",
nsize, map.size); nsize, map.size);
@ -3626,8 +3624,9 @@ gst_qtdemux_process_buffer (GstQTDemux * qtdemux, QtDemuxStream * stream,
gst_buffer_unref (buf); gst_buffer_unref (buf);
buf = _gst_buffer_new_wrapped (str, strlen (str), g_free); buf = _gst_buffer_new_wrapped (str, strlen (str), g_free);
} else { } else {
/* may be 0-size subtitle, which is also sent to keep pipeline going */ /* this should not really happen unless the subtitle is corrupted */
gst_buffer_resize (buf, 2, nsize); gst_buffer_unref (buf);
buf = NULL;
} }
/* FIXME ? convert optional subsequent style info to markup */ /* FIXME ? convert optional subsequent style info to markup */