diff -urN -x.svn ffmpeg.orig/configure ffmpeg/configure
--- ffmpeg.orig/configure	Sat Jul 25 00:36:37 2009
+++ ffmpeg/configure	Sat Jul 25 00:36:11 2009
@@ -1672,7 +1672,7 @@
 fi
 
 add_cppflags -D_ISOC99_SOURCE -D_POSIX_C_SOURCE=200112
-check_cflags -std=c99
+check_cflags -std=gnu99
 check_cc -D_FILE_OFFSET_BITS=64 <<EOF && add_cppflags -D_FILE_OFFSET_BITS=64
 #include <stdlib.h>
 EOF
@@ -2161,6 +2161,9 @@
         add_extralibs -pthreads
     elif check_func pthread_create -lpthreadGC2; then
         add_extralibs -lpthreadGC2
+    elif check_func pthread_create -lpthread -lws2_32; then
+        add_cflags -DPTW32_STATIC_LIB
+        add_extralibs -lpthread -lws2_32
     elif ! check_lib pthread.h pthread_create -lpthread; then
         die "ERROR: can't find pthreads library"
     fi
@@ -2203,10 +2206,10 @@
 enabled libspeex   && require  libspeex speex/speex.h speex_decoder_init -lspeex
 enabled libtheora  && require  libtheora theora/theora.h theora_info_init -ltheora -logg
 enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
-enabled libx264    && require  libx264 x264.h x264_encoder_open -lx264 -lm &&
+enabled libx264    && require  libx264 x264.h x264_encoder_open -lx264 -lm -lpthread -lws2_32 &&
                       { check_cpp_condition x264.h "X264_BUILD >= 65" ||
                         die "ERROR: libx264 version must be >= 0.65."; }
-enabled libxvid    && require  libxvid xvid.h xvid_global -lxvidcore
+enabled libxvid    && require  libxvid xvid.h xvid_global -lxvidcore  -lpthread -lws2_32
 enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
 
 # libdc1394 check
diff -urN -x.svn ffmpeg.orig/ffmpeg.c ffmpeg/ffmpeg.c
--- ffmpeg.orig/ffmpeg.c	Sat Jul 25 00:36:37 2009
+++ ffmpeg/ffmpeg.c	Sat Jul 25 00:35:59 2009
@@ -50,6 +50,7 @@
 
 #if HAVE_SYS_SELECT_H
 #include <sys/select.h>
+#define usleep(t) Sleep((t) / 1000)
 #endif
 
 #if HAVE_TERMIOS_H
diff -urN -x.svn ffmpeg.orig/libavcodec/libmp3lame.c ffmpeg/libavcodec/libmp3lame.c
--- ffmpeg.orig/libavcodec/libmp3lame.c	Sat Jul 25 00:36:27 2009
+++ ffmpeg/libavcodec/libmp3lame.c	Sat Jul 25 00:38:55 2009
@@ -34,6 +34,7 @@
     int stereo;
     uint8_t buffer[BUFFER_SIZE];
     int buffer_index;
+    int buffer_flushed;
 } Mp3AudioContext;
 
 static av_cold int MP3lame_encode_init(AVCodecContext *avctx)
@@ -73,6 +74,8 @@
     avctx->coded_frame= avcodec_alloc_frame();
     avctx->coded_frame->key_frame= 1;
 
+    s->buffer_flushed = 0;
+
     return 0;
 
 err_close:
@@ -166,13 +169,15 @@
                 BUFFER_SIZE - s->buffer_index
                 );
         }
-    }else{
+    }else if (data == NULL && s->buffer_flushed == 0){
         lame_result= lame_encode_flush(
                 s->gfp,
                 s->buffer + s->buffer_index,
                 BUFFER_SIZE - s->buffer_index
                 );
-    }
+        s->buffer_flushed = 1;
+    }else
+        lame_result = 0;
 
     if(lame_result < 0){
         if(lame_result==-1) {
diff -urN -x.svn ffmpeg.orig/libavcodec/libx264.c ffmpeg/libavcodec/libx264.c
--- ffmpeg.orig/libavcodec/libx264.c	Sat Jul 25 00:36:26 2009
+++ ffmpeg/libavcodec/libx264.c	Sat Jul 25 00:37:13 2009
@@ -30,8 +30,6 @@
     x264_param_t params;
     x264_t *enc;
     x264_picture_t pic;
-    uint8_t *sei;
-    int sei_size;
     AVFrame out_pic;
 } X264Context;
 
@@ -53,30 +51,13 @@
 
 
 static int
-encode_nals(AVCodecContext *ctx, uint8_t *buf, int size, x264_nal_t *nals, int nnal, int skip_sei)
+encode_nals(uint8_t *buf, int size, x264_nal_t *nals, int nnal)
 {
-    X264Context *x4 = ctx->priv_data;
     uint8_t *p = buf;
-    int i, s;
-
-    /* Write the SEI as part of the first frame. */
-    if(x4->sei_size > 0 && nnal > 0)
-    {
-        memcpy(p, x4->sei, x4->sei_size);
-        p += x4->sei_size;
-        x4->sei_size = 0;
-    }
+    int i;
 
     for(i = 0; i < nnal; i++){
-        /* Don't put the SEI in extradata. */
-        if(skip_sei && nals[i].i_type == NAL_SEI)
-        {
-            x4->sei = av_malloc( 5 + nals[i].i_payload * 4 / 3 );
-            if(x264_nal_encode(x4->sei, &x4->sei_size, 1, nals + i) < 0)
-                return -1;
-            continue;
-        }
-        s = x264_nal_encode(p, &size, 1, nals + i);
+        int s = x264_nal_encode(p, &size, 1, nals + i);
         if(s < 0)
             return -1;
         p += s;
@@ -111,7 +92,7 @@
                            &pic_out))
         return -1;
 
-    bufsize = encode_nals(ctx, buf, bufsize, nal, nnal, 0);
+    bufsize = encode_nals(buf, bufsize, nal, nnal);
     if(bufsize < 0)
         return -1;
 
@@ -144,7 +125,6 @@
     X264Context *x4 = avctx->priv_data;
 
     av_freep(&avctx->extradata);
-    av_free(x4->sei);
 
     if(x4->enc)
         x264_encoder_close(x4->enc);
@@ -157,7 +137,6 @@
 {
     X264Context *x4 = avctx->priv_data;
 
-    x4->sei_size = 0;
     x264_param_default(&x4->params);
 
     x4->params.pf_log = X264_log;
@@ -305,7 +284,7 @@
             s += 5 + nal[i].i_payload * 4 / 3;
 
         avctx->extradata = av_malloc(s);
-        avctx->extradata_size = encode_nals(avctx, avctx->extradata, s, nal, nnal, 1);
+        avctx->extradata_size = encode_nals(avctx->extradata, s, nal, nnal);
     }
 
     return 0;
diff -urN -x.svn ffmpeg.orig/libavcodec/opt.c ffmpeg/libavcodec/opt.c
--- ffmpeg.orig/libavcodec/opt.c	Sat Jul 25 00:36:25 2009
+++ ffmpeg/libavcodec/opt.c	Sat Jul 25 00:36:30 2009
@@ -177,6 +177,7 @@
             if(o->type == FF_OPT_TYPE_FLAGS){
                 if     (cmd=='+') d= av_get_int(obj, name, NULL) | (int64_t)d;
                 else if(cmd=='-') d= av_get_int(obj, name, NULL) &~(int64_t)d;
+                else if(buf[0]=='0' && buf[1]=='x') d= strtoul(buf, NULL, 16);
             }else{
                 if     (cmd=='+') d= notfirst*av_get_double(obj, name, NULL) + d;
                 else if(cmd=='-') d= notfirst*av_get_double(obj, name, NULL) - d;
