kate: only send decoder output caps once or when the format changes

and not for every single buffer. And  also send a caps
event for spu output.

https://bugzilla.gnome.org/show_bug.cgi?id=697071
This commit is contained in:
Tim-Philipp Müller 2013-04-15 00:48:36 +01:00
parent a3ad6eaf2d
commit 1dd53d64e8
2 changed files with 25 additions and 8 deletions

View file

@ -203,6 +203,7 @@ gst_kate_dec_init (GstKateDec * dec)
gst_kate_util_decode_base_init (&dec->decoder, TRUE); gst_kate_util_decode_base_init (&dec->decoder, TRUE);
dec->src_caps = NULL; dec->src_caps = NULL;
dec->output_format = GST_KATE_FORMAT_UNDEFINED;
dec->remove_markup = FALSE; dec->remove_markup = FALSE;
} }
@ -245,6 +246,7 @@ gst_kate_dec_get_property (GObject * object, guint prop_id,
static GstFlowReturn static GstFlowReturn
gst_kate_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) gst_kate_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
{ {
GstKateFormat format = GST_KATE_FORMAT_UNDEFINED;
GstKateDec *kd = GST_KATE_DEC (parent); GstKateDec *kd = GST_KATE_DEC (parent);
const kate_event *ev = NULL; const kate_event *ev = NULL;
GstFlowReturn rflow = GST_FLOW_OK; GstFlowReturn rflow = GST_FLOW_OK;
@ -294,15 +296,18 @@ gst_kate_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
buffer = gst_buffer_new_and_alloc (len + 1); buffer = gst_buffer_new_and_alloc (len + 1);
if (G_LIKELY (buffer)) { if (G_LIKELY (buffer)) {
GstCaps *caps; GstCaps *caps;
if (plain) { if (plain)
format = GST_KATE_FORMAT_TEXT_UTF8;
else
format = GST_KATE_FORMAT_TEXT_PANGO_MARKUP;
if (format != kd->output_format) {
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); (format == GST_KATE_FORMAT_TEXT_UTF8) ? "utf8" : "pango-markup",
} else { NULL);
caps = gst_caps_new_simple ("text/x-raw", "format", G_TYPE_STRING,
"pango-markup", NULL);
}
gst_pad_push_event (kd->srcpad, gst_event_new_caps (caps)); gst_pad_push_event (kd->srcpad, gst_event_new_caps (caps));
gst_caps_unref (caps); gst_caps_unref (caps);
kd->output_format = format;
}
/* allocate and copy the NULs, but don't include them in passed size */ /* allocate and copy the NULs, but don't include them in passed size */
gst_buffer_fill (buffer, 0, escaped, len + 1); gst_buffer_fill (buffer, 0, escaped, len + 1);
gst_buffer_resize (buffer, 0, len); gst_buffer_resize (buffer, 0, len);
@ -332,13 +337,23 @@ gst_kate_dec_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
rflow = GST_FLOW_ERROR; rflow = GST_FLOW_ERROR;
} }
// if there's a background paletted bitmap, construct a DVD SPU for it /* if there's a background paletted bitmap, construct a DVD SPU for it */
if (ev->bitmap && ev->palette) { if (ev->bitmap && ev->palette) {
GstBuffer *buffer = gst_kate_spu_encode_spu (kd, ev); GstBuffer *buffer = gst_kate_spu_encode_spu (kd, ev);
if (buffer) { if (buffer) {
GstCaps *caps;
GST_BUFFER_TIMESTAMP (buffer) = ev->start_time * GST_SECOND; GST_BUFFER_TIMESTAMP (buffer) = ev->start_time * GST_SECOND;
GST_BUFFER_DURATION (buffer) = GST_BUFFER_DURATION (buffer) =
(ev->end_time - ev->start_time) * GST_SECOND; (ev->end_time - ev->start_time) * GST_SECOND;
if (kd->output_format != GST_KATE_FORMAT_SPU) {
caps = gst_caps_new_empty_simple (GST_KATE_SPU_MIME_TYPE);
gst_pad_push_event (kd->srcpad, gst_event_new_caps (caps));
gst_caps_unref (caps);
kd->output_format = GST_KATE_FORMAT_SPU;
}
rflow = gst_pad_push (kd->srcpad, buffer); rflow = gst_pad_push (kd->srcpad, buffer);
if (rflow == GST_FLOW_NOT_LINKED) { if (rflow == GST_FLOW_NOT_LINKED) {
GST_DEBUG_OBJECT (kd, "source pad not linked, ignored"); GST_DEBUG_OBJECT (kd, "source pad not linked, ignored");

View file

@ -74,6 +74,8 @@ struct _GstKateDec
GstCaps *src_caps; GstCaps *src_caps;
GstKateFormat output_format;
gboolean remove_markup; gboolean remove_markup;
}; };