--- gst/rtp/gstrtph263pay.c	2009-02-02 13:30:13.000000000 +0100
+++ gst/rtp/gstrtph263pay-garbage.c	2009-04-29 14:55:55.000000000 +0200
@@ -295,6 +295,7 @@ static GstFlowReturn
 gst_rtp_h263_pay_flush (GstRtpH263Pay * rtph263pay)
 {
   guint avail;
+  guint navail;
   GstBuffer *outbuf;
   GstFlowReturn ret = 0;
   gboolean fragmented;
@@ -303,6 +304,7 @@ gst_rtp_h263_pay_flush (GstRtpH263Pay * 
   guint8 *payload;
   guint payload_len, total_len;
   guint curpos, nextgobpos;
+  guint32 *temp;
 
   avail = gst_adapter_available (rtph263pay->adapter);
   if (avail == 0)
@@ -312,6 +314,11 @@ gst_rtp_h263_pay_flush (GstRtpH263Pay * 
 
   /* Get a pointer to all the data for the frame */
   data = (guint8 *) gst_adapter_peek (rtph263pay->adapter, avail);
+  navail = avail;
+  if(avail >= 4){
+    	temp = (guint32*)(data + avail - 4);
+	navail = (*temp)?avail:avail-4;
+  }
 
   /* Start at the begining and loop looking for gobs */
   curpos = 0;
@@ -319,7 +326,7 @@ gst_rtp_h263_pay_flush (GstRtpH263Pay * 
   /* Picture header */
   piclayer = (GstH263PictureLayer *) data;
 
-  while ((nextgobpos = gst_rtp_h263_pay_gobfiner (data, avail, curpos)) > 0) {
+  while ((nextgobpos = gst_rtp_h263_pay_gobfiner (data, navail, curpos)) > 0) {
 
     payload_len = nextgobpos - curpos;
     total_len = payload_len + GST_RFC2190A_HEADER_LEN;
@@ -347,7 +354,7 @@ gst_rtp_h263_pay_flush (GstRtpH263Pay * 
     GST_RFC2190A_HEADER_TR (header) = 0;
 
     /* last fragment gets the marker bit set */
-    gst_rtp_buffer_set_marker (outbuf, nextgobpos < avail ? 0 : 1);
+    gst_rtp_buffer_set_marker (outbuf, nextgobpos < navail ? 0 : 1);
 
     memcpy (payload, data + curpos, payload_len);
 
