mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-04-26 04:26:14 +00:00
theoradec: parse and use codec_data in the caps
Parse the codec_data in the caps and use this as the headers. Fixes #574169.
This commit is contained in:
parent
d998f6097b
commit
fac1d4cc09
1 changed files with 46 additions and 1 deletions
|
@ -741,6 +741,7 @@ theora_dec_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
{
|
{
|
||||||
GstTheoraDec *dec;
|
GstTheoraDec *dec;
|
||||||
GstStructure *s;
|
GstStructure *s;
|
||||||
|
const GValue *codec_data;
|
||||||
|
|
||||||
dec = GST_THEORA_DEC (gst_pad_get_parent (pad));
|
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->have_par = gst_structure_get_fraction (s, "pixel-aspect-ratio",
|
||||||
&dec->par_num, &dec->par_den);
|
&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);
|
gst_object_unref (dec);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1132,7 +1176,8 @@ theora_handle_data_packet (GstTheoraDec * dec, ogg_packet * packet,
|
||||||
stride_y = GST_ROUND_UP_4 (width);
|
stride_y = GST_ROUND_UP_4 (width);
|
||||||
stride_uv = GST_ROUND_UP_8 (width) / 2;
|
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,
|
/* now copy over the area contained in offset_x,offset_y,
|
||||||
* frame_width, frame_height */
|
* frame_width, frame_height */
|
||||||
|
|
Loading…
Reference in a new issue