diff -ur -x.svn ffmpeg.orig/configure ffmpeg/configure
--- ffmpeg.orig/configure	Fri May 28 00:06:48 2010
+++ ffmpeg/configure	Fri May 28 00:10:13 2010
@@ -2574,6 +2574,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
@@ -2609,23 +2612,23 @@
                       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 libfaad    && require2 libfaad faad.h faacDecOpen -lfaad
-enabled libgsm     && require  libgsm gsm/gsm.h gsm_create -lgsm
+enabled libgsm     && require  libgsm gsm.h gsm_create -lgsm
 enabled libmp3lame && require  libmp3lame lame/lame.h lame_init -lmp3lame -lm
 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 -lm
 enabled libopencore_amrwb  && require libopencore_amrwb opencore-amrwb/dec_if.h D_IF_init -lopencore-amrwb -lm
 enabled libopenjpeg && require libopenjpeg openjpeg.h opj_version -lopenjpeg
-enabled librtmp    && require  librtmp librtmp/rtmp.h RTMP_Init -lrtmp
+enabled librtmp    && require  librtmp librtmp/rtmp.h RTMP_Init -lrtmp -lssl -lcrypto -lwinmm -lws2_32 -lgdi32 -lz
 enabled libschroedinger && add_cflags $(pkg-config --cflags schroedinger-1.0) &&
                            require libschroedinger schroedinger/schro.h schro_init $(pkg-config --libs schroedinger-1.0)
 enabled libspeex   && require  libspeex speex/speex.h speex_decoder_init -lspeex
 enabled libtheora  && require  libtheora theora/theoraenc.h th_info_init -ltheoraenc -ltheoradec -logg
 enabled libvorbis  && require  libvorbis vorbis/vorbisenc.h vorbis_info_init -lvorbisenc -lvorbis -logg
 enabled libvpx     && require2 libvpx "vpx/vpx_decoder.h vpx/vp8dx.h" "vpx_codec_dec_init_ver" -lvpx
-enabled libx264    && require  libx264 x264.h x264_encoder_encode -lx264 -lm &&
+enabled libx264    && require  libx264 x264.h x264_encoder_encode -lx264 -lm -lpthread -lws2_32 &&
                       { check_cpp_condition x264.h "X264_BUILD >= 90" ||
                         die "ERROR: libx264 version must be >= 0.90."; }
-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 -ur -x.svn ffmpeg.orig/ffmpeg.c ffmpeg/ffmpeg.c
--- ffmpeg.orig/ffmpeg.c	Fri May 28 00:06:48 2010
+++ ffmpeg/ffmpeg.c	Fri May 28 00:10:28 2010
@@ -126,6 +126,11 @@
 static float frame_aspect_ratio = 0;
 static enum PixelFormat frame_pix_fmt = PIX_FMT_NONE;
 static enum SampleFormat audio_sample_fmt = SAMPLE_FMT_NONE;
+static int frame_padtop  = 0;
+static int frame_padbottom = 0;
+static int frame_padleft  = 0;
+static int frame_padright = 0;
+static int padcolor[3] = {16,128,128}; /* default to black */
 static int frame_topBand  = 0;
 static int frame_bottomBand = 0;
 static int frame_leftBand  = 0;
@@ -280,6 +285,13 @@
     int original_leftBand;
     int original_rightBand;
 
+    /* padding area sizes */
+    int video_pad;
+    int padtop;
+    int padbottom;
+    int padleft;
+    int padright;
+
     /* audio only */
     int audio_resample;
     ReSampleContext *resample; /* for audio resampling */
@@ -426,8 +438,8 @@
 
     if (ost->video_crop) {
         snprintf(args, 255, "%d:%d:%d:%d", ost->leftBand, ost->topBand,
-                 codec->width,
-                 codec->height);
+                 codec->width -  (frame_padleft + frame_padright),
+                 codec->height - (frame_padtop + frame_padbottom));
         filter = avfilter_open(avfilter_get_by_name("crop"), NULL);
         if (!filter)
             return -1;
@@ -440,11 +452,13 @@
     }
 
     if((codec->width !=
-        icodec->width - (frame_leftBand + frame_rightBand)) ||
-       (codec->height != icodec->height - (frame_topBand  + frame_bottomBand))) {
+        icodec->width - (frame_leftBand + frame_rightBand) +
+        (frame_padleft + frame_padright)) ||
+       (codec->height != icodec->height - (frame_topBand  + frame_bottomBand) +
+        (frame_padtop + frame_padbottom))) {
         snprintf(args, 255, "%d:%d:flags=0x%X",
-                 codec->width,
-                 codec->height,
+                 codec->width  - (frame_padleft + frame_padright),
+                 codec->height - (frame_padtop  + frame_padbottom),
                  (int)av_get_int(sws_opts, "sws_flags", NULL));
         filter = avfilter_open(avfilter_get_by_name("scale"), NULL);
         if (!filter)
@@ -1202,6 +1216,18 @@
     final_picture = formatted_picture;
     padding_src = formatted_picture;
     resampling_dst = &ost->pict_tmp;
+    if (ost->video_pad) {
+        final_picture = &ost->pict_tmp;
+        if (ost->video_resample) {
+            if (av_picture_crop((AVPicture *)&picture_pad_temp, (AVPicture *)final_picture, enc->pix_fmt, ost->padtop, ost->padleft) < 0) {
+                fprintf(stderr, "error padding picture\n");
+                if (exit_on_error)
+                    av_exit(1);
+                return;
+            }
+            resampling_dst = &picture_pad_temp;
+        }
+    }
 
     if(    (ost->resample_height != (ist->st->codec->height - (ost->topBand  + ost->bottomBand)))
         || (ost->resample_width  != (ist->st->codec->width  - (ost->leftBand + ost->rightBand)))
@@ -1248,8 +1274,8 @@
                 ist->st->codec->width  - (ost->leftBand + ost->rightBand),
                 ist->st->codec->height - (ost->topBand  + ost->bottomBand),
                 ist->st->codec->pix_fmt,
-                ost->st->codec->width,
-                ost->st->codec->height,
+                ost->st->codec->width  - (ost->padleft  + ost->padright),
+                ost->st->codec->height - (ost->padtop   + ost->padbottom),
                 ost->st->codec->pix_fmt,
                 sws_flags, NULL, NULL, NULL);
             if (ost->img_resample_ctx == NULL) {
@@ -1262,6 +1288,12 @@
     }
 #endif
 
+    if (ost->video_pad) {
+        av_picture_pad((AVPicture*)final_picture, (AVPicture *)padding_src,
+                enc->height, enc->width, enc->pix_fmt,
+                ost->padtop, ost->padbottom, ost->padleft, ost->padright, padcolor);
+    }
+
     /* duplicates frame if needed */
     for(i=0;i<nb_frames;i++) {
         AVPacket pkt;
@@ -2105,6 +2137,7 @@
                                 ost->source_index = j;
                                 found = 1;
                             }
+                            break;
                         }
                     }
 
@@ -2222,10 +2255,13 @@
                     av_exit(1);
                 }
                 ost->video_crop = ((frame_leftBand + frame_rightBand + frame_topBand + frame_bottomBand) != 0);
+                ost->video_pad = ((frame_padleft + frame_padright + frame_padtop + frame_padbottom) != 0);
                 ost->video_resample = ((codec->width != icodec->width -
-                                (frame_leftBand + frame_rightBand)) ||
+                                (frame_leftBand + frame_rightBand) +
+                                (frame_padleft + frame_padright)) ||
                         (codec->height != icodec->height -
-                                (frame_topBand  + frame_bottomBand)) ||
+                                (frame_topBand  + frame_bottomBand) +
+                                (frame_padtop + frame_padbottom)) ||
                         (codec->pix_fmt != icodec->pix_fmt));
                 if (ost->video_crop) {
                     ost->topBand    = ost->original_topBand    = frame_topBand;
@@ -2233,6 +2269,18 @@
                     ost->leftBand   = ost->original_leftBand   = frame_leftBand;
                     ost->rightBand  = ost->original_rightBand  = frame_rightBand;
                 }
+                if (ost->video_pad) {
+                    ost->padtop = frame_padtop;
+                    ost->padleft = frame_padleft;
+                    ost->padbottom = frame_padbottom;
+                    ost->padright = frame_padright;
+                    if (!ost->video_resample) {
+                        avcodec_get_frame_defaults(&ost->pict_tmp);
+                        if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt,
+                                         codec->width, codec->height))
+                            goto fail;
+                    }
+                }
                 if (ost->video_resample) {
                     avcodec_get_frame_defaults(&ost->pict_tmp);
                     if(avpicture_alloc((AVPicture*)&ost->pict_tmp, codec->pix_fmt,
@@ -2245,8 +2293,8 @@
                             icodec->width - (frame_leftBand + frame_rightBand),
                             icodec->height - (frame_topBand + frame_bottomBand),
                             icodec->pix_fmt,
-                            codec->width,
-                            codec->height,
+                            codec->width - (frame_padleft + frame_padright),
+                            codec->height - (frame_padtop + frame_padbottom),
                             codec->pix_fmt,
                             sws_flags, NULL, NULL, NULL);
                     if (ost->img_resample_ctx == NULL) {
@@ -2818,11 +2866,92 @@
     }
 }
 
-static void opt_pad(const char *arg) {
+#if CONFIG_AVFILTER
+static void opt_pad(const char *arg)
+{
     fprintf(stderr, "Please use vf=pad\n");
     av_exit(1);
 }
 
+static void opt_pad_color(const char *arg)
+{
+    opt_pad(arg);
+}
+
+static void opt_frame_pad_top(const char *arg)
+{
+    opt_pad(arg);
+}
+
+static void opt_frame_pad_bottom(const char *arg)
+{
+    opt_pad(arg);
+}
+
+static void opt_frame_pad_left(const char *arg)
+{
+    opt_pad(arg);
+}
+
+static void opt_frame_pad_right(const char *arg)
+{
+    opt_pad(arg);
+}
+
+#else
+static void opt_pad_color(const char *arg)
+{
+    /* Input is expected to be six hex digits similar to
+       how colors are expressed in html tags (but without the #) */
+    int rgb = strtol(arg, NULL, 16);
+    int r,g,b;
+
+    r = (rgb >> 16);
+    g = ((rgb >> 8) & 255);
+    b = (rgb & 255);
+
+    padcolor[0] = RGB_TO_Y(r,g,b);
+    padcolor[1] = RGB_TO_U(r,g,b,0);
+    padcolor[2] = RGB_TO_V(r,g,b,0);
+}
+
+static void opt_frame_pad_top(const char *arg)
+{
+    frame_padtop = atoi(arg);
+    if (frame_padtop < 0) {
+        fprintf(stderr, "Incorrect top pad size\n");
+        av_exit(1);
+    }
+}
+
+static void opt_frame_pad_bottom(const char *arg)
+{
+    frame_padbottom = atoi(arg);
+    if (frame_padbottom < 0) {
+        fprintf(stderr, "Incorrect bottom pad size\n");
+        av_exit(1);
+    }
+}
+
+static void opt_frame_pad_left(const char *arg)
+{
+    frame_padleft = atoi(arg);
+    if (frame_padleft < 0) {
+        fprintf(stderr, "Incorrect left pad size\n");
+        av_exit(1);
+    }
+}
+
+static void opt_frame_pad_right(const char *arg)
+{
+    frame_padright = atoi(arg);
+    if (frame_padright < 0) {
+        fprintf(stderr, "Incorrect right pad size\n");
+        av_exit(1);
+    }
+}
+#endif /* CONFIG_AVFILTER */
+
 static void opt_frame_pix_fmt(const char *arg)
 {
     if (strcmp(arg, "list")) {
@@ -3124,8 +3253,8 @@
     ap->channels = audio_channels;
     ap->time_base.den = frame_rate.num;
     ap->time_base.num = frame_rate.den;
-    ap->width = frame_width;
-    ap->height = frame_height;
+    ap->width = frame_width + frame_padleft + frame_padright;
+    ap->height = frame_height + frame_padtop + frame_padbottom;
     ap->pix_fmt = frame_pix_fmt;
    // ap->sample_fmt = audio_sample_fmt; //FIXME:not implemented in libavformat
     ap->channel = video_channel;
@@ -3381,8 +3510,8 @@
         video_enc->time_base.den = fps.num;
         video_enc->time_base.num = fps.den;
 
-        video_enc->width = frame_width;
-        video_enc->height = frame_height;
+        video_enc->width = frame_width + frame_padright + frame_padleft;
+        video_enc->height = frame_height + frame_padtop + frame_padbottom;
         video_enc->sample_aspect_ratio = av_d2q(frame_aspect_ratio*video_enc->height/video_enc->width, 255);
         video_enc->pix_fmt = frame_pix_fmt;
         st->sample_aspect_ratio = video_enc->sample_aspect_ratio;
@@ -4175,11 +4304,11 @@
     { "cropbottom", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_bottom}, "set bottom crop band size (in pixels)", "size" },
     { "cropleft", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_left}, "set left crop band size (in pixels)", "size" },
     { "cropright", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_crop_right}, "set right crop band size (in pixels)", "size" },
-    { "padtop", HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "set top pad band size (in pixels)", "size" },
-    { "padbottom", HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "set bottom pad band size (in pixels)", "size" },
-    { "padleft", HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "set left pad band size (in pixels)", "size" },
-    { "padright", HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "set right pad band size (in pixels)", "size" },
-    { "padcolor", HAS_ARG | OPT_VIDEO, {(void*)opt_pad}, "set color of pad bands (Hex 000000 thru FFFFFF)", "color" },
+    { "padtop", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_pad_top}, "set top pad band size (in pixels)", "size" },
+    { "padbottom", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_pad_bottom}, "set bottom pad band size (in pixels)", "size" },
+    { "padleft", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_pad_left}, "set left pad band size (in pixels)", "size" },
+    { "padright", HAS_ARG | OPT_VIDEO, {(void*)opt_frame_pad_right}, "set right pad band size (in pixels)", "size" },
+    { "padcolor", HAS_ARG | OPT_VIDEO, {(void*)opt_pad_color}, "set color of pad bands (Hex 000000 thru FFFFFF)", "color" },
     { "intra", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&intra_only}, "use only intra frames"},
     { "vn", OPT_BOOL | OPT_VIDEO, {(void*)&video_disable}, "disable video" },
     { "vdt", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&video_discard}, "discard threshold", "n" },
diff -ur -x.svn ffmpeg.orig/libavcodec/libgsm.c ffmpeg/libavcodec/libgsm.c
--- ffmpeg.orig/libavcodec/libgsm.c	Fri May 28 00:06:20 2010
+++ ffmpeg/libavcodec/libgsm.c	Fri May 28 00:10:55 2010
@@ -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/opt.c ffmpeg/libavcodec/opt.c
--- ffmpeg.orig/libavcodec/opt.c	Fri May 28 00:06:24 2010
+++ ffmpeg/libavcodec/opt.c	Fri May 28 00:11:29 2010
@@ -175,6 +175,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;
diff -ur -x.svn ffmpeg.orig/libavformat/rmdec.c ffmpeg/libavformat/rmdec.c
--- ffmpeg.orig/libavformat/rmdec.c	Fri May 28 00:06:47 2010
+++ ffmpeg/libavformat/rmdec.c	Fri May 28 00:11:43 2010
@@ -313,14 +313,14 @@
         fps= get_be16(pb);
         st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
         get_be32(pb);
-        fps2= get_be16(pb);
+        fps2 = get_be16(pb);
         get_be16(pb);
 
         if ((ret = rm_read_extradata(pb, st->codec, codec_data_size - (url_ftell(pb) - codec_pos))) < 0)
             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	Fri May 28 00:06:46 2010
+++ ffmpeg/libavformat/rtsp.c	Fri May 28 00:12:02 2010
@@ -1649,6 +1649,10 @@
     return 0;
 }
 
+#ifdef WIN32
+#define ETIMEDOUT WSAETIMEDOUT
+#endif
+
 static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
                            uint8_t *buf, int buf_size)
 {
