summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWim Taymans <wim.taymans@collabora.co.uk>2009-03-06 19:02:58 +0100
committerWim Taymans <wim.taymans@collabora.co.uk>2009-03-06 19:02:58 +0100
commitfac1d4cc0965f8cc96f900d3ac23365e9b75cd0d (patch)
treedd9705794b360d28582aafb0b31e0542ba3b8734
parentd998f6097bb3820db1eac934501a52830b79ec0b (diff)
theoradec: parse and use codec_data in the caps
Parse the codec_data in the caps and use this as the headers. Fixes #574169.
-rw-r--r--ext/theora/theoradec.c47
1 files changed, 46 insertions, 1 deletions
diff --git a/ext/theora/theoradec.c b/ext/theora/theoradec.c
index baefd2021..d02c64b99 100644
--- a/ext/theora/theoradec.c
+++ b/ext/theora/theoradec.c
@@ -741,6 +741,7 @@ theora_dec_setcaps (GstPad * pad, GstCaps * caps)
{
GstTheoraDec *dec;
GstStructure *s;
+ const GValue *codec_data;
dec = GST_THEORA_DEC (gst_pad_get_parent (pad));
@@ -750,6 +751,49 @@ theora_dec_setcaps (GstPad * pad, GstCaps * caps)
dec->have_par = gst_structure_get_fraction (s, "pixel-aspect-ratio",
&dec->par_num, &dec->par_den);
+ if ((codec_data = gst_structure_get_value (s, "codec_data"))) {
+ if (G_VALUE_TYPE (codec_data) == GST_TYPE_BUFFER) {
+ GstBuffer *buffer;
+ guint8 *data;
+ guint size;
+ guint offset;
+
+ buffer = gst_value_get_buffer (codec_data);
+
+ offset = 0;
+ size = GST_BUFFER_SIZE (buffer);
+ data = GST_BUFFER_DATA (buffer);
+
+ while (size > 2) {
+ guint psize;
+ GstBuffer *buf;
+
+ psize = (data[0] << 8) | data[1];
+ /* skip header */
+ data += 2;
+ size -= 2;
+ offset += 2;
+
+ /* make sure we don't read too much */
+ psize = MIN (psize, size);
+
+ buf = gst_buffer_create_sub (buffer, offset, psize);
+
+ /* first buffer is a discont buffer */
+ if (offset == 2)
+ GST_BUFFER_FLAG_SET (buf, GST_BUFFER_FLAG_DISCONT);
+
+ /* now feed it to the decoder we can ignore the error */
+ theora_dec_chain (pad, buf);
+
+ /* skip the data */
+ size -= psize;
+ data += psize;
+ offset += psize;
+ }
+ }
+ }
+
gst_object_unref (dec);
return TRUE;
@@ -1132,7 +1176,8 @@ theora_handle_data_packet (GstTheoraDec * dec, ogg_packet * packet,
stride_y = GST_ROUND_UP_4 (width);
stride_uv = GST_ROUND_UP_8 (width) / 2;
- out_size = stride_y * GST_ROUND_UP_2 (height) + stride_uv * GST_ROUND_UP_2 (height);
+ out_size =
+ stride_y * GST_ROUND_UP_2 (height) + stride_uv * GST_ROUND_UP_2 (height);
/* now copy over the area contained in offset_x,offset_y,
* frame_width, frame_height */