diff -ur -x.svn ffmpeg.orig/configure ffmpeg/configure
--- ffmpeg.orig/configure	Wed Oct 27 03:19:23 2010
+++ ffmpeg/configure	Wed Jan  5 16:10:15 2011
@@ -2712,6 +2712,8 @@
     elif check_func pthread_create -pthreads; then
         add_cflags -pthreads
         add_extralibs -pthreads
+    elif check_func pthread_create -lpthread; then
+        add_extralibs -lpthread
     elif check_func pthread_create -lpthreadGC2; then
         add_extralibs -lpthreadGC2
     elif ! check_lib pthread.h pthread_create -lpthread; then
@@ -2749,15 +2751,15 @@
                       require  libdirac libdirac_decoder/dirac_parser.h dirac_decoder_init $(pkg-config --libs dirac) &&
                       require  libdirac libdirac_encoder/dirac_encoder.h dirac_encoder_init $(pkg-config --libs dirac)
 enabled libfaac    && require2 libfaac "stdint.h faac.h" faacEncGetVersion -lfaac
-enabled libgsm     && require  libgsm gsm/gsm.h gsm_create -lgsm
+enabled libgsm     && require  libgsm gsm.h gsm_create -lgsm
 enabled libmp3lame && require  "libmp3lame >= 3.98.3" lame/lame.h lame_set_VBR_quality -lmp3lame
 enabled libnut     && require  libnut libnut.h nut_demuxer_init -lnut
 enabled libopencore_amrnb  && require libopencore_amrnb opencore-amrnb/interf_dec.h Decoder_Interface_init -lopencore-amrnb
 enabled libopencore_amrwb  && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb
-enabled libopencv  && { check_lib opencv/cv.h cvCreateImageHeader $(pkg-config --libs opencv) ||
+enabled libopencv  && { check_lib opencv/cv.h cvCreateImageHeader -lcv210 -lcxcore210 -lz -lflann -lopencv_lapack -lstdc++ ||
                         die "ERROR: libopencv not found"; }
 enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
-enabled librtmp    && { check_lib librtmp/rtmp.h RTMP_Socket $(pkg-config --libs librtmp) ||
+enabled librtmp    && { check_lib librtmp/rtmp.h RTMP_Socket -lrtmp -lssl -lcrypto -lwinmm -lws2_32 -lgdi32 -lz ||
                         die "ERROR: librtmp not found or RTMP_Socket() missing, librtmp version must be >= 2.2.f"; }
 enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
                            require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
@@ -2769,11 +2771,11 @@
                                 die "ERROR: libvpx decoder version must be >=0.9.1"; }
     enabled libvpx_encoder && { check_lib2 "vpx/vpx_encoder.h vpx/vp8cx.h" vpx_codec_enc_init_ver -lvpx ||
                                 die "ERROR: libvpx encoder version must be >=0.9.1"; } }
-enabled libx264    && require  libx264 x264.h x264_encoder_encode -lx264 &&
+enabled libx264    && require  libx264 x264.h x264_encoder_encode -lx264 -lpthread &&
                       { check_cpp_condition x264.h "X264_BUILD >= 99" ||
                         die "ERROR: libx264 version must be >= 0.99."; }
 enabled libxavs    && require  libxavs xavs.h xavs_encoder_encode -lxavs
-enabled libxvid    && require  libxvid xvid.h xvid_global -lxvidcore
+enabled libxvid    && require  libxvid xvid.h xvid_global -lxvidcore -lpthread
 enabled mlib       && require  mediaLib mlib_types.h mlib_VectorSub_S16_U8_Mod -lmlib
 
 # libdc1394 check
diff -ur -x.svn ffmpeg.orig/ffmpeg.c ffmpeg/ffmpeg.c
--- ffmpeg.orig/ffmpeg.c	Wed Oct 20 18:45:51 2010
+++ ffmpeg/ffmpeg.c	Wed Jan  5 16:04:00 2011
@@ -1607,7 +1607,7 @@
                             do_audio_out(os, ost, ist, decoded_data_buf, decoded_data_size);
                             break;
                         case AVMEDIA_TYPE_VIDEO:
-#if CONFIG_AVFILTER
+#if CONFIG_AVFILTER && !CONFIG_LIBXVID_ENCODER
                             if (ist->picref->video)
                                 ost->st->codec->sample_aspect_ratio = ist->picref->video->pixel_aspect;
 #endif
@@ -2018,6 +2018,7 @@
                             best_nb_frames= ist->st->codec_info_nb_frames;
                             ost->source_index = j;
                             found = 1;
+                            break;
                         }
                     }
                 }
diff -ur -x.svn ffmpeg.orig/libavcodec/libgsm.c ffmpeg/libavcodec/libgsm.c
--- ffmpeg.orig/libavcodec/libgsm.c	Sun Jul  4 00:35:23 2010
+++ ffmpeg/libavcodec/libgsm.c	Wed Jan  5 16:03:50 2011
@@ -28,7 +28,7 @@
 // The idiosyncrasies of GSM-in-WAV are explained at http://kbs.cs.tu-berlin.de/~jutta/toast.html
 
 #include "avcodec.h"
-#include <gsm/gsm.h>
+#include <gsm.h>
 
 // gsm.h misses some essential constants
 #define GSM_BLOCK_SIZE 33
diff -ur -x.svn ffmpeg.orig/libavcodec/libvpxenc.c ffmpeg/libavcodec/libvpxenc.c
--- ffmpeg.orig/libavcodec/libvpxenc.c	Sat Oct 23 03:09:14 2010
+++ ffmpeg/libavcodec/libvpxenc.c	Wed Jan  5 16:03:51 2011
@@ -30,6 +30,7 @@
 
 #include "avcodec.h"
 #include "libavutil/base64.h"
+#include "libavcodec/opt.h"
 
 /**
  * Portion of struct vpx_codec_cx_pkt from vpx_encoder.h.
@@ -50,10 +51,32 @@
     struct vpx_codec_ctx encoder;
     struct vpx_image rawimg;
     struct vpx_fixed_buf twopass_stats;
-    unsigned long deadline; //i.e., RT/GOOD/BEST
+    int deadline; //i.e., RT/GOOD/BEST
     struct FrameListData *coded_frame_list;
+
+    int cpuused;
+
+    /**
+     * VP8 specific flags, see VP8F_* below.
+     */
+    int flags;
+#define VP8F_ERROR_RESILIENT 0x00000001 ///< Enable measures appropriate for streaming over lossy links
+#define VP8F_AUTO_ALT_REF    0x00000002 ///< Enable automatic alternate reference frame generation
 } VP8Context;
 
+static const AVOption options[]={
+{"speed", "", offsetof(VP8Context, cpuused), FF_OPT_TYPE_INT, 3, -16, 16, AV_OPT_FLAG_ENCODING_PARAM},
+{"quality", "", offsetof(VP8Context, deadline), FF_OPT_TYPE_INT, VPX_DL_GOOD_QUALITY, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "quality"},
+{"best", NULL, 0, FF_OPT_TYPE_CONST, VPX_DL_BEST_QUALITY, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "quality"},
+{"good", NULL, 0, FF_OPT_TYPE_CONST, VPX_DL_GOOD_QUALITY, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "quality"},
+{"realtime", NULL, 0, FF_OPT_TYPE_CONST, VPX_DL_REALTIME, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "quality"},
+{"vp8flags", "", offsetof(VP8Context, flags), FF_OPT_TYPE_FLAGS, 0, 0, UINT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flags"},
+{"error_resilient", "enable error resilience", 0, FF_OPT_TYPE_CONST, VP8F_ERROR_RESILIENT, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flags"},
+{"altref", "enable use of alternate reference frames (VP8/2-pass only)", 0, FF_OPT_TYPE_CONST, VP8F_AUTO_ALT_REF, INT_MIN, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, "flags"},
+{NULL}
+};
+static const AVClass class = { "libvpx", av_default_item_name, options, LIBAVUTIL_VERSION_INT };
+
 /** String mappings for enum vp8e_enc_control_id */
 static const char *ctlidstr[] = {
     [VP8E_UPD_ENTROPY]           = "VP8E_UPD_ENTROPY",
@@ -204,7 +227,6 @@
 {
     VP8Context *ctx = avctx->priv_data;
     const struct vpx_codec_iface *iface = &vpx_codec_vp8_cx_algo;
-    int cpuused = 3;
     struct vpx_codec_enc_cfg enccfg;
     int res;
 
@@ -218,11 +240,21 @@
     }
     dump_enc_cfg(avctx, &enccfg);
 
+    /* With altref set an additional frame at the same pts may be produced.
+       Increasing the time_base gives the library a window to place these frames
+       ensuring strictly increasing timestamps. */
+    if (ctx->flags & VP8F_AUTO_ALT_REF) {
+        avctx->ticks_per_frame = 2;
+        avctx->time_base       = av_mul_q(avctx->time_base,
+                                          (AVRational){1, avctx->ticks_per_frame});
+    }
+
     enccfg.g_w            = avctx->width;
     enccfg.g_h            = avctx->height;
     enccfg.g_timebase.num = avctx->time_base.num;
     enccfg.g_timebase.den = avctx->time_base.den;
     enccfg.g_threads      = avctx->thread_count;
+    enccfg.g_lag_in_frames= FFMIN(avctx->rc_lookahead, 25);  //0-25, avoids init failure
 
     if (avctx->flags & CODEC_FLAG_PASS1)
         enccfg.g_pass = VPX_RC_FIRST_PASS;
@@ -256,6 +288,7 @@
         enccfg.rc_buf_initial_sz =
             avctx->rc_initial_buffer_occupancy * 1000 / avctx->bit_rate;
     enccfg.rc_buf_optimal_sz     = enccfg.rc_buf_sz * 5 / 6;
+    enccfg.rc_undershoot_pct     = round(avctx->rc_buffer_aggressivity * 100);
 
     //_enc_init() will balk if kf_min_dist differs from max w/VPX_KF_AUTO
     if (avctx->keyint_min == avctx->gop_size)
@@ -291,13 +324,14 @@
         enccfg.rc_twopass_stats_in = ctx->twopass_stats;
     }
 
-    ctx->deadline = VPX_DL_GOOD_QUALITY;
     /* 0-3: For non-zero values the encoder increasingly optimizes for reduced
        complexity playback on low powered devices at the expense of encode
        quality. */
    if (avctx->profile != FF_PROFILE_UNKNOWN)
        enccfg.g_profile = avctx->profile;
 
+    enccfg.g_error_resilient = ctx->flags & VP8F_ERROR_RESILIENT;
+
     dump_enc_cfg(avctx, &enccfg);
     /* Construct Encoder Context */
     res = vpx_codec_enc_init(&ctx->encoder, iface, &enccfg, 0);
@@ -308,9 +342,12 @@
 
     //codec control failures are currently treated only as warnings
     av_log(avctx, AV_LOG_DEBUG, "vpx_codec_control\n");
-    codecctl_int(avctx, VP8E_SET_CPUUSED,           cpuused);
+    codecctl_int(avctx, VP8E_SET_CPUUSED,           ctx->cpuused);
     codecctl_int(avctx, VP8E_SET_NOISE_SENSITIVITY, avctx->noise_reduction);
     codecctl_int(avctx, VP8E_SET_TOKEN_PARTITIONS,  av_log2(avctx->slices));
+    codecctl_int(avctx, VP8E_SET_ENABLEAUTOALTREF,  !!(ctx->flags & VP8F_AUTO_ALT_REF));
+
+    av_log(avctx, AV_LOG_DEBUG, "Using deadline: %d\n", ctx->deadline);
 
     //provide dummy value to initialize wrapper, values will be updated each _encode()
     vpx_img_wrap(&ctx->rawimg, VPX_IMG_FMT_I420, avctx->width, avctx->height, 1,
@@ -506,4 +543,5 @@
     CODEC_CAP_DELAY,
     .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
     .long_name = NULL_IF_CONFIG_SMALL("libvpx VP8"),
+    .priv_class = &class,
 };
diff -ur -x.svn ffmpeg.orig/libavformat/rmdec.c ffmpeg/libavformat/rmdec.c
--- ffmpeg.orig/libavformat/rmdec.c	Mon Jun  7 03:48:50 2010
+++ ffmpeg/libavformat/rmdec.c	Wed Jan  5 16:07:45 2011
@@ -305,7 +305,7 @@
             return ret;
 
 //        av_log(s, AV_LOG_DEBUG, "fps= %d fps2= %d\n", fps, fps2);
-        st->codec->time_base.den = fps * st->codec->time_base.num;
+        st->codec->time_base.den = fps2 * st->codec->time_base.num;
         //XXX: do we really need that?
         switch(st->codec->extradata[4]>>4){
         case 1: st->codec->codec_id = CODEC_ID_RV10; break;
diff -ur -x.svn ffmpeg.orig/libavformat/rtsp.c ffmpeg/libavformat/rtsp.c
--- ffmpeg.orig/libavformat/rtsp.c	Sun Oct 24 01:22:36 2010
+++ ffmpeg/libavformat/rtsp.c	Wed Jan  5 16:04:00 2011
@@ -52,6 +52,10 @@
 #define SDP_MAX_SIZE 16384
 #define RECVBUF_SIZE 10 * RTP_MAX_PACKET_LENGTH
 
+#ifdef WIN32
+#define ETIMEDOUT WSAETIMEDOUT
+#endif
+
 static void get_word_until_chars(char *buf, int buf_size,
                                  const char *sep, const char **pp)
 {
diff -ur -x.svn ffmpeg.orig/libavutil/opt.c ffmpeg/libavutil/opt.c
--- ffmpeg.orig/libavutil/opt.c	Thu Sep 30 06:42:03 2010
+++ ffmpeg/libavutil/opt.c	Wed Jan  5 16:03:44 2011
@@ -181,6 +181,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;
