diff --git a/ext/theora/theoradec.c b/ext/theora/theoradec.c index baefd20214..d02c64b997 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 */