mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-05 15:08:48 +00:00
ext/theora/theoradec.c: Don't crash on missing header packets.
Original commit message from CVS: * ext/theora/theoradec.c: (gst_theora_dec_class_init), (theora_get_formats), (theora_dec_src_convert), (theora_dec_sink_convert), (theora_dec_src_query), (theora_dec_src_event), (theora_dec_event), (theora_dec_chain), (theora_dec_change_state): Don't crash on missing header packets.
This commit is contained in:
parent
8491fd9fa5
commit
8d74cc9136
2 changed files with 30 additions and 2 deletions
|
@ -1,3 +1,12 @@
|
||||||
|
2004-08-09 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* ext/theora/theoradec.c: (gst_theora_dec_class_init),
|
||||||
|
(theora_get_formats), (theora_dec_src_convert),
|
||||||
|
(theora_dec_sink_convert), (theora_dec_src_query),
|
||||||
|
(theora_dec_src_event), (theora_dec_event), (theora_dec_chain),
|
||||||
|
(theora_dec_change_state):
|
||||||
|
Don't crash on missing header packets.
|
||||||
|
|
||||||
2004-08-09 Thomas Vander Stichele <thomas at apestaart dot org>
|
2004-08-09 Thomas Vander Stichele <thomas at apestaart dot org>
|
||||||
|
|
||||||
* po/LINGUAS:
|
* po/LINGUAS:
|
||||||
|
|
|
@ -57,6 +57,7 @@ struct _GstTheoraDec
|
||||||
guint packetno;
|
guint packetno;
|
||||||
guint64 granulepos;
|
guint64 granulepos;
|
||||||
|
|
||||||
|
gboolean initialized;
|
||||||
gboolean need_keyframe;
|
gboolean need_keyframe;
|
||||||
gint width, height;
|
gint width, height;
|
||||||
gint offset_x, offset_y;
|
gint offset_x, offset_y;
|
||||||
|
@ -530,10 +531,13 @@ theora_dec_chain (GstPad * pad, GstData * data)
|
||||||
packet.packet = GST_BUFFER_DATA (buf);
|
packet.packet = GST_BUFFER_DATA (buf);
|
||||||
packet.bytes = GST_BUFFER_SIZE (buf);
|
packet.bytes = GST_BUFFER_SIZE (buf);
|
||||||
packet.granulepos = dec->granulepos;
|
packet.granulepos = dec->granulepos;
|
||||||
packet.packetno = dec->packetno++;
|
packet.packetno = dec->packetno;
|
||||||
packet.b_o_s = (packet.packetno == 0) ? 1 : 0;
|
packet.b_o_s = (packet.packetno == 0) ? 1 : 0;
|
||||||
packet.e_o_s = 0;
|
packet.e_o_s = 0;
|
||||||
|
|
||||||
|
GST_DEBUG_OBJECT (dec, "header=%d packetno=%d", packet.packet[0],
|
||||||
|
packet.packetno);
|
||||||
|
|
||||||
/* switch depending on packet type */
|
/* switch depending on packet type */
|
||||||
if (packet.packet[0] & 0x80) {
|
if (packet.packet[0] & 0x80) {
|
||||||
/* header packet */
|
/* header packet */
|
||||||
|
@ -543,7 +547,9 @@ theora_dec_chain (GstPad * pad, GstData * data)
|
||||||
gst_data_unref (data);
|
gst_data_unref (data);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (packet.packetno == 1) {
|
if (packet.packetno == 0) {
|
||||||
|
dec->packetno++;
|
||||||
|
} else if (packet.packetno == 1) {
|
||||||
gchar *encoder = NULL;
|
gchar *encoder = NULL;
|
||||||
GstTagList *list =
|
GstTagList *list =
|
||||||
gst_tag_list_from_vorbiscomment_buffer (buf, "\201theora", 7,
|
gst_tag_list_from_vorbiscomment_buffer (buf, "\201theora", 7,
|
||||||
|
@ -561,6 +567,8 @@ theora_dec_chain (GstPad * pad, GstData * data)
|
||||||
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
|
gst_tag_list_add (list, GST_TAG_MERGE_REPLACE,
|
||||||
GST_TAG_ENCODER_VERSION, dec->info.version_major, NULL);
|
GST_TAG_ENCODER_VERSION, dec->info.version_major, NULL);
|
||||||
gst_element_found_tags_for_pad (GST_ELEMENT (dec), dec->srcpad, 0, list);
|
gst_element_found_tags_for_pad (GST_ELEMENT (dec), dec->srcpad, 0, list);
|
||||||
|
|
||||||
|
dec->packetno++;
|
||||||
} else if (packet.packetno == 2) {
|
} else if (packet.packetno == 2) {
|
||||||
GstCaps *caps;
|
GstCaps *caps;
|
||||||
gint par_num, par_den;
|
gint par_num, par_den;
|
||||||
|
@ -621,6 +629,9 @@ theora_dec_chain (GstPad * pad, GstData * data)
|
||||||
dec->height, NULL);
|
dec->height, NULL);
|
||||||
gst_pad_set_explicit_caps (dec->srcpad, caps);
|
gst_pad_set_explicit_caps (dec->srcpad, caps);
|
||||||
gst_caps_free (caps);
|
gst_caps_free (caps);
|
||||||
|
|
||||||
|
dec->initialized = TRUE;
|
||||||
|
dec->packetno++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* normal data packet */
|
/* normal data packet */
|
||||||
|
@ -633,6 +644,13 @@ theora_dec_chain (GstPad * pad, GstData * data)
|
||||||
gint width, height;
|
gint width, height;
|
||||||
gint cwidth, cheight;
|
gint cwidth, cheight;
|
||||||
|
|
||||||
|
dec->packetno++;
|
||||||
|
|
||||||
|
if (!dec->initialized) {
|
||||||
|
gst_data_unref (data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* the second most significant bit of the first data byte is cleared
|
/* the second most significant bit of the first data byte is cleared
|
||||||
* for keyframes */
|
* for keyframes */
|
||||||
keyframe = (packet.packet[0] & 0x40) == 0;
|
keyframe = (packet.packet[0] & 0x40) == 0;
|
||||||
|
@ -739,6 +757,7 @@ theora_dec_change_state (GstElement * element)
|
||||||
theora_info_init (&dec->info);
|
theora_info_init (&dec->info);
|
||||||
theora_comment_init (&dec->comment);
|
theora_comment_init (&dec->comment);
|
||||||
dec->need_keyframe = TRUE;
|
dec->need_keyframe = TRUE;
|
||||||
|
dec->initialized = FALSE;
|
||||||
break;
|
break;
|
||||||
case GST_STATE_PAUSED_TO_PLAYING:
|
case GST_STATE_PAUSED_TO_PLAYING:
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in a new issue