diff --git a/libavcodec/common.c b/libavcodec/common.c
index cf52d98cca5bc8533664612badd54ffe4b885913..c3bfcfe648effd06992da76a6e1e454a3564d8c9 100644
--- a/libavcodec/common.c
+++ b/libavcodec/common.c
@@ -104,13 +104,14 @@ void flush_put_bits(PutBitContext *s)
 
 #ifdef CONFIG_ENCODERS
 
-void put_string(PutBitContext * pbc, char *s)
+void put_string(PutBitContext * pbc, char *s, int put_zero)
 {
     while(*s){
         put_bits(pbc, 8, *s);
         s++;
     }
-    put_bits(pbc, 8, 0);
+    if(put_zero)
+        put_bits(pbc, 8, 0);
 }
 
 /* bit input functions */
diff --git a/libavcodec/common.h b/libavcodec/common.h
index 2167ebc2b2e6a2c33564f789736e343a483ad863..729ba4615bbc23bc685ebf5d12ef0c315007a8e6 100644
--- a/libavcodec/common.h
+++ b/libavcodec/common.h
@@ -291,7 +291,7 @@ void init_put_bits(PutBitContext *s, uint8_t *buffer, int buffer_size);
 int put_bits_count(PutBitContext *s);
 void align_put_bits(PutBitContext *s);
 void flush_put_bits(PutBitContext *s);
-void put_string(PutBitContext * pbc, char *s);
+void put_string(PutBitContext * pbc, char *s, int put_zero);
 
 /* bit input */
 
@@ -1142,7 +1142,7 @@ uint64_t tstart= rdtsc();\
 
 #define STOP_TIMER(id) \
 tend= rdtsc();\
-if(tcount<2 || tend - tstart < 4*tsum/tcount){\
+if(tcount<2 || tend - tstart < 8*tsum/tcount){\
     tsum+= tend - tstart;\
     tcount++;\
 }else\
diff --git a/libavcodec/h263.c b/libavcodec/h263.c
index f1575fef9455990cc2f1cd57f944c9aa3c5b1f60..6b9e559c1ee849b5455e16539e796a4cd8b9c40b 100644
--- a/libavcodec/h263.c
+++ b/libavcodec/h263.c
@@ -2326,8 +2326,7 @@ static void mpeg4_encode_vol_header(MpegEncContext * s, int vo_number, int vol_n
     if(!(s->flags & CODEC_FLAG_BITEXACT)){
         put_bits(&s->pb, 16, 0);
         put_bits(&s->pb, 16, 0x1B2);	/* user_data */
-	put_string(&s->pb, LIBAVCODEC_IDENT);
-        ff_mpeg4_stuffing(&s->pb);
+	put_string(&s->pb, LIBAVCODEC_IDENT, 0);
     }
 }
 
diff --git a/libavcodec/mjpeg.c b/libavcodec/mjpeg.c
index ca64fb2b13cbe50fcc4c78f660e2193219067b84..7aed3e28acf890724863aec87f63ef5d5b157a1a 100644
--- a/libavcodec/mjpeg.c
+++ b/libavcodec/mjpeg.c
@@ -378,7 +378,7 @@ static void jpeg_put_comments(MpegEncContext *s)
     /* JFIF header */
     put_marker(p, APP0);
     put_bits(p, 16, 16);
-    put_string(p, "JFIF"); /* this puts the trailing zero-byte too */
+    put_string(p, "JFIF", 1); /* this puts the trailing zero-byte too */
     put_bits(p, 16, 0x0201); /* v 1.02 */
     put_bits(p, 8, 0); /* units type: 0 - aspect ratio */
     put_bits(p, 16, s->avctx->sample_aspect_ratio.num);
@@ -393,7 +393,7 @@ static void jpeg_put_comments(MpegEncContext *s)
         flush_put_bits(p);
         ptr = pbBufPtr(p);
         put_bits(p, 16, 0); /* patched later */
-        put_string(p, LIBAVCODEC_IDENT);
+        put_string(p, LIBAVCODEC_IDENT, 1);
         size = strlen(LIBAVCODEC_IDENT)+3;
         ptr[0] = size >> 8;
         ptr[1] = size;