summaryrefslogtreecommitdiffstats
path: root/gst
diff options
context:
space:
mode:
authorRonald S. Bultje <rbultje@ronald.bitfreak.net>2005-05-18 10:23:41 +0000
committerRonald S. Bultje <rbultje@ronald.bitfreak.net>2005-05-18 10:23:41 +0000
commit6aa66ac48ddbec842fd2deffe3855239f49a05f7 (patch)
tree2d7f4adc047ac97748f3e301eaed66f6f6dea890 /gst
parent2138866a8a4befed02fe2e7bf8372f848f0e6c67 (diff)
downloadgst-plugins-bad-6aa66ac48ddbec842fd2deffe3855239f49a05f7.tar.gz
gst-plugins-bad-6aa66ac48ddbec842fd2deffe3855239f49a05f7.tar.bz2
gst-plugins-bad-6aa66ac48ddbec842fd2deffe3855239f49a05f7.zip
gst/mpeg1videoparse/gstmp1videoparse.c: Prevent crash, detect keyframes (#303650).
Original commit message from CVS: * gst/mpeg1videoparse/gstmp1videoparse.c: (mp1videoparse_valid_sync), (gst_mp1videoparse_real_chain): Prevent crash, detect keyframes (#303650).
Diffstat (limited to 'gst')
-rw-r--r--gst/mpeg1videoparse/gstmp1videoparse.c26
1 files changed, 19 insertions, 7 deletions
diff --git a/gst/mpeg1videoparse/gstmp1videoparse.c b/gst/mpeg1videoparse/gstmp1videoparse.c
index c1510f0f..34e9ae46 100644
--- a/gst/mpeg1videoparse/gstmp1videoparse.c
+++ b/gst/mpeg1videoparse/gstmp1videoparse.c
@@ -220,14 +220,17 @@ mp1videoparse_valid_sync (Mp1VideoParse * mp1videoparse, guint32 head,
GstBuffer * buf)
{
switch (head) {
- case SEQ_START_CODE:{
- GstBuffer *subbuf = gst_buffer_create_sub (buf, 4,
- GST_BUFFER_SIZE (buf) - 4);
-
- mp1videoparse_parse_seq (mp1videoparse, subbuf);
- gst_buffer_unref (subbuf);
+ case SEQ_START_CODE:
+ /* FIXME: may sometimes not update header (although that'll probably
+ * never happen in practice). */
+ if (GST_BUFFER_SIZE (buf) >= 8) {
+ GstBuffer *subbuf = gst_buffer_create_sub (buf, 4,
+ GST_BUFFER_SIZE (buf) - 4);
+
+ mp1videoparse_parse_seq (mp1videoparse, subbuf);
+ gst_buffer_unref (subbuf);
+ }
return TRUE;
- }
case GOP_START_CODE:
case PICTURE_START_CODE:
case USER_START_CODE:
@@ -505,6 +508,8 @@ gst_mp1videoparse_real_chain (Mp1VideoParse * mp1videoparse, GstBuffer * buf,
}
if (GST_PAD_CAPS (outpad) != NULL) {
+ guint8 *p_ptr;
+
if (mp1videoparse->need_discont &&
GST_BUFFER_TIMESTAMP_IS_VALID (outbuf)) {
GstEvent *event = gst_event_new_discontinuous (FALSE,
@@ -517,6 +522,13 @@ gst_mp1videoparse_real_chain (Mp1VideoParse * mp1videoparse, GstBuffer * buf,
}
GST_DEBUG ("mp1videoparse: pushing %d bytes %" G_GUINT64_FORMAT,
GST_BUFFER_SIZE (outbuf), GST_BUFFER_TIMESTAMP (outbuf));
+ p_ptr = GST_BUFFER_DATA (outbuf);
+ while (p_ptr[0] != 0x0 || p_ptr[1] != 0x0 ||
+ p_ptr[2] != 0x1 || p_ptr[3] != (PICTURE_START_CODE & 0xff))
+ p_ptr++;
+ if (((p_ptr[5] >> 3) & 0x7) == 0x1) {
+ GST_BUFFER_FLAG_SET (outbuf, GST_BUFFER_KEY_UNIT);
+ }
gst_pad_push (outpad, GST_DATA (outbuf));
GST_DEBUG ("mp1videoparse: pushing done");
} else {