Commit fac1d4cc authored by Wim Taymans's avatar Wim Taymans

theoradec: parse and use codec_data in the caps

Parse the codec_data in the caps and use this as the headers.
Fixes #574169.
parent d998f609
......@@ -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 */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment