diff --git a/ffmpeg.c b/ffmpeg.c
index 4671167eb6a51bb47f4367a50a6a0475fb0c312b..ba9aa027b44332e954cdbc66b4ffaa9ff6663497 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -3265,6 +3265,7 @@ static void opt_output_file(const char *filename)
                 video_enc->rc_eq = video_rc_eq;
                 video_enc->debug = debug;
                 video_enc->debug_mv = debug_mv;
+                video_enc->workaround_bugs = workaround_bugs;
                 video_enc->thread_count = thread_count;
                 p= video_rc_override_string;
                 for(i=0; p; i++){
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index 41d7e5f6ca1b13b109e8adc15973a02b9ec37469..894d737aad5102c71ea63f3e869f2d3850e98d61 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -17,7 +17,7 @@ extern "C" {
 
 #define FFMPEG_VERSION_INT     0x000409
 #define FFMPEG_VERSION         "0.4.9-pre1"
-#define LIBAVCODEC_BUILD       4747
+#define LIBAVCODEC_BUILD       4748
 
 #define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
 #define LIBAVCODEC_VERSION     FFMPEG_VERSION
@@ -909,7 +909,7 @@ typedef struct AVCodecContext {
     
     /**
      * workaround bugs in encoders which sometimes cannot be detected automatically.
-     * - encoding: unused
+     * - encoding: set by user
      * - decoding: set by user
      */
     int workaround_bugs;
@@ -927,6 +927,7 @@ typedef struct AVCodecContext {
 #define FF_BUG_EDGE             1024
 #define FF_BUG_HPEL_CHROMA      2048
 #define FF_BUG_DC_CLIP          4096
+#define FF_BUG_MS               8192 ///< workaround various bugs in microsofts broken decoders
 //#define FF_BUG_FAKE_SCALABILITY 16 //autodetection should work 100%
         
     /**
diff --git a/libavcodec/h263.c b/libavcodec/h263.c
index 645c9b9dbac8f90532bcba6b13743ece0012e910..32c1b94b341fc28f4dfb65d16c5535871640acf5 100644
--- a/libavcodec/h263.c
+++ b/libavcodec/h263.c
@@ -2021,7 +2021,8 @@ void h263_encode_init(MpegEncContext *s)
             s->avctx->extradata= av_malloc(1024);
             init_put_bits(&s->pb, s->avctx->extradata, 1024);
             
-            mpeg4_encode_visual_object_header(s);
+            if(!(s->workaround_bugs & FF_BUG_MS))
+                mpeg4_encode_visual_object_header(s);
             mpeg4_encode_vol_header(s, 0, 0);
 
 //            ff_mpeg4_stuffing(&s->pb); ?
@@ -2320,9 +2321,13 @@ static void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_n
 
     put_bits(&s->pb, 1, 0);		/* random access vol */
     put_bits(&s->pb, 8, s->vo_type);	/* video obj type indication */
-    put_bits(&s->pb, 1, 1);		/* is obj layer id= yes */
-      put_bits(&s->pb, 4, vo_ver_id);	/* is obj layer ver id */
-      put_bits(&s->pb, 3, 1);		/* is obj layer priority */
+    if(s->workaround_bugs & FF_BUG_MS) {
+        put_bits(&s->pb, 1, 0);        /* is obj layer id= no */
+    } else {
+        put_bits(&s->pb, 1, 1);        /* is obj layer id= yes */
+        put_bits(&s->pb, 4, vo_ver_id);    /* is obj layer ver id */
+        put_bits(&s->pb, 3, 1);        /* is obj layer priority */
+    }
     
     aspect_to_info(s, s->avctx->sample_aspect_ratio);
 
@@ -2332,10 +2337,14 @@ static void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_n
         put_bits(&s->pb, 8, s->avctx->sample_aspect_ratio.den);
     }
 
-    put_bits(&s->pb, 1, 1);		/* vol control parameters= yes */
-    put_bits(&s->pb, 2, 1);		/* chroma format YUV 420/YV12 */
-    put_bits(&s->pb, 1, s->low_delay);
-    put_bits(&s->pb, 1, 0);		/* vbv parameters= no */
+    if(s->workaround_bugs & FF_BUG_MS) { //
+        put_bits(&s->pb, 1, 0);        /* vol control parameters= no @@@ */
+    } else {
+        put_bits(&s->pb, 1, 1);        /* vol control parameters= yes */
+        put_bits(&s->pb, 2, 1);        /* chroma format YUV 420/YV12 */
+        put_bits(&s->pb, 1, s->low_delay);
+        put_bits(&s->pb, 1, 0);        /* vbv parameters= no */
+    }
 
     put_bits(&s->pb, 2, RECT_SHAPE);	/* vol shape= rectangle */
     put_bits(&s->pb, 1, 1);		/* marker bit */
@@ -2405,7 +2414,8 @@ void mpeg4_encode_picture_header(MpegEncContext * s, int picture_number)
             if(s->strict_std_compliance < 2 || picture_number==0) //HACK, the reference sw is buggy
                 mpeg4_encode_vol_header(s, 0, 0);
         }
-        mpeg4_encode_gop_header(s);
+        if(!(s->workaround_bugs & FF_BUG_MS))
+            mpeg4_encode_gop_header(s);
     }
     
     s->partitioned_frame= s->data_partitioning && s->pict_type!=B_TYPE;