--- gst-libav-1.0.5-original/ext/libav/gstavviddec.c	2012-10-25 16:26:58 +0530
+++ gst-libav-1.0.5-patched/ext/libav/gstavviddec.c	2013-04-08 15:17:21 +0530
@@ -414,8 +414,6 @@
     return TRUE;
   }
 
-  gst_caps_replace (&ffmpegdec->last_caps, state->caps);
-
   GST_DEBUG_OBJECT (ffmpegdec, "setcaps called");
 
   GST_OBJECT_LOCK (ffmpegdec);
@@ -435,6 +433,8 @@
     avcodec_get_context_defaults (ffmpegdec->context);
   }
 
+  gst_caps_replace (&ffmpegdec->last_caps, state->caps);
+  
   /* set buffer functions */
   ffmpegdec->context->get_buffer = gst_ffmpegviddec_get_buffer;
   ffmpegdec->context->reget_buffer = gst_ffmpegviddec_reget_buffer;
