diff --git a/configure b/configure
index 10d3cf6..97fc01c 100755
--- a/configure
+++ b/configure
@@ -1105,7 +1105,7 @@ check_pkg_config(){
     shift 3
     check_cmd $pkg_config --exists --print-errors $pkgandversion || return
     pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
-    pkg_libs=$($pkg_config --libs $pkg_config_flags $pkg)
+    pkg_libs=$($pkg_config --libs --static $pkg_config_flags $pkg)
     check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
         set_safe ${pkg}_cflags $pkg_cflags   &&
         set_safe ${pkg}_libs   $pkg_libs
@@ -4906,7 +4906,7 @@ enabled libgsm            && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do
                                done || die "ERROR: libgsm not found"; }
 enabled libilbc           && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
 enabled libmfx            && require_pkg_config libmfx "mfx/mfxvideo.h" MFXInit
-enabled libmodplug        && require_pkg_config libmodplug libmodplug/modplug.h ModPlug_Load
+enabled libmodplug        && require libmodplug libmodplug/modplug.h ModPlug_Load -lmodplug -lstdc++
 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
@@ -5009,7 +5009,7 @@ if ! disabled sdl; then
     else
         if "${SDL_CONFIG}" --version > /dev/null 2>&1; then
             sdl_cflags=$("${SDL_CONFIG}" --cflags)
-            sdl_libs=$("${SDL_CONFIG}" --libs)
+            sdl_libs=$("${SDL_CONFIG}" --static-libs)
             check_func_headers SDL_version.h SDL_Linked_Version $sdl_cflags $sdl_libs &&
             check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) >= 0x010201" $sdl_cflags &&
             check_cpp_condition SDL.h "(SDL_MAJOR_VERSION<<16 | SDL_MINOR_VERSION<<8 | SDL_PATCHLEVEL) < 0x010300" $sdl_cflags &&
@@ -5076,8 +5076,8 @@ enabled jack_indev && check_lib2 jack/jack.h jack_client_open -ljack && check_fu
 enabled_any sndio_indev sndio_outdev && check_lib2 sndio.h sio_open -lsndio
 
 if enabled libcdio; then
-    check_lib2 "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
-    check_lib2 "cdio/paranoia/cdda.h cdio/paranoia/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio ||
+    check_lib2 "cdio/cdda.h cdio/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio -lwinmm ||
+    check_lib2 "cdio/paranoia/cdda.h cdio/paranoia/paranoia.h" cdio_cddap_open -lcdio_paranoia -lcdio_cdda -lcdio -lwinmm ||
     die "ERROR: libcdio-paranoia not found"
 fi
 
diff --git a/ffmpeg.c b/ffmpeg.c
index becd5df..358bb27 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1528,12 +1528,14 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
             nb_frames_drop += ost->last_droped;
     }
 
-    secs = FFABS(pts) / AV_TIME_BASE;
-    us = FFABS(pts) % AV_TIME_BASE;
-    mins = secs / 60;
-    secs %= 60;
-    hours = mins / 60;
-    mins %= 60;
+    if (progress_avio) {
+        secs = FFABS(pts) / AV_TIME_BASE;
+        us = FFABS(pts) % AV_TIME_BASE;
+        mins = secs / 60;
+        secs %= 60;
+        hours = mins / 60;
+        mins %= 60;
+    }
 
     bitrate = pts && total_size >= 0 ? total_size * 8 / (pts / 1000.0) : -1;
 
@@ -1543,9 +1545,13 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
                                  "size=%8.0fkB time=", total_size / 1024.0);
     if (pts < 0)
         snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), "-");
-    snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
-             "%02d:%02d:%02d.%02d ", hours, mins, secs,
-             (100 * us) / AV_TIME_BASE);
+    if (progress_avio)
+        snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
+                 "%02d:%02d:%02d.%02d ", hours, mins, secs,
+                 (100 * us) / AV_TIME_BASE);
+    else
+        snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
+                 "%0.2f ", (double)pts / AV_TIME_BASE);
 
     if (bitrate < 0) {
         snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),"bitrate=N/A");
@@ -1558,8 +1564,9 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
     if (total_size < 0) av_bprintf(&buf_script, "total_size=N/A\n");
     else                av_bprintf(&buf_script, "total_size=%"PRId64"\n", total_size);
     av_bprintf(&buf_script, "out_time_ms=%"PRId64"\n", pts);
-    av_bprintf(&buf_script, "out_time=%02d:%02d:%02d.%06d\n",
-               hours, mins, secs, us);
+    if (progress_avio)
+        av_bprintf(&buf_script, "out_time=%02d:%02d:%02d.%06d\n",
+                   hours, mins, secs, us);
 
     if (nb_frames_dup || nb_frames_drop)
         snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf), " dup=%d drop=%d",
diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c
index 9be3a97..3fa7e76 100644
--- a/libavcodec/libopenh264enc.c
+++ b/libavcodec/libopenh264enc.c
@@ -103,7 +103,7 @@ static av_cold int svc_encode_init(AVCodecContext *avctx)
     param.bEnableLongTermReference   = 0;
     param.iLtrMarkPeriod             = 30;
     param.uiIntraPeriod              = avctx->gop_size;
-    param.bEnableSpsPpsIdAddition    = 0;
+    param.eSpsPpsIdStrategy          = 0;
     param.bPrefixNalAddingCtrl       = 0;
     param.iLoopFilterDisableIdc      = !s->loopfilter;
     param.iEntropyCodingModeFlag     = 0;
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 4da0ee0..90f8cc7 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -452,6 +452,8 @@ static av_cold int X264_init(AVCodecContext *avctx)
         x4->params.i_keyint_max         = avctx->gop_size;
     if (avctx->max_b_frames >= 0)
         x4->params.i_bframe             = avctx->max_b_frames;
+    else
+        x4->params.i_bframe             = 0;
     if (avctx->scenechange_threshold >= 0)
         x4->params.i_scenecut_threshold = avctx->scenechange_threshold;
     if (avctx->qmin >= 0)
@@ -519,6 +521,8 @@ static av_cold int X264_init(AVCodecContext *avctx)
         x4->params.rc.i_lookahead = x4->rc_lookahead;
     if (x4->weightp >= 0)
         x4->params.analyse.i_weighted_pred = x4->weightp;
+    else
+        x4->params.analyse.i_weighted_pred = 0;
     if (x4->weightb >= 0)
         x4->params.analyse.b_weighted_bipred = x4->weightb;
     if (x4->cplxblur >= 0)
@@ -658,6 +662,11 @@ static av_cold int X264_init(AVCodecContext *avctx)
                 OPT_STR(param, val);
             p= strchr(p, ':');
             p+=!!p;
+
+            if (strcmp(param, "bframes") == 0)
+                avctx->max_b_frames = x4->params.i_bframe;
+            if (strcmp(param, "weightp") == 0)
+                x4->weightp = x4->params.analyse.i_weighted_pred;
         }
     }
 
diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index b6840ee..48e5809 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -487,6 +487,8 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)
     }
 #endif
 
+    xvid_enc_create.num_slices = avctx->slices;
+
     xvid_enc_create.plugins     = plugins;
     xvid_enc_create.num_plugins = 0;
 
diff --git a/libavutil/atomic.c b/libavutil/atomic.c
index b13725d..76e44eb 100644
--- a/libavutil/atomic.c
+++ b/libavutil/atomic.c
@@ -19,6 +19,7 @@
  */
 
 #include "config.h"
+#include "common.h"
 #include "atomic.h"
 
 #if !HAVE_ATOMICS_NATIVE
diff --git a/libavutil/common.h b/libavutil/common.h
index c82a3a6..39cc2f3 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -467,3 +467,9 @@ static av_always_inline av_const int av_popcount64_c(uint64_t x)
 #ifndef av_popcount64
 #   define av_popcount64    av_popcount64_c
 #endif
+
+#ifdef TEST
+#ifdef __MINGW32__
+#undef main /* We don't want SDL to override our main() */
+#endif
+#endif
diff --git a/libavutil/lls.c b/libavutil/lls.c
index f77043b..5dd9e00 100644
--- a/libavutil/lls.c
+++ b/libavutil/lls.c
@@ -125,6 +125,7 @@ av_cold void avpriv_init_lls(LLSModel *m, int indep_count)
 
 #include <stdio.h>
 #include <limits.h>
+#include "common.h"
 #include "lfg.h"
 
 int main(void)
diff --git a/libavutil/md5.c b/libavutil/md5.c
index 876bd55..ff876ab 100644
--- a/libavutil/md5.c
+++ b/libavutil/md5.c
@@ -31,6 +31,7 @@
  */
 
 #include <stdint.h>
+#include "common.h"
 #include "bswap.h"
 #include "intreadwrite.h"
 #include "md5.h"
diff --git a/libavutil/random_seed.c b/libavutil/random_seed.c
index 8aa8c38..c7a9459 100644
--- a/libavutil/random_seed.c
+++ b/libavutil/random_seed.c
@@ -34,6 +34,7 @@
 #include <math.h>
 #include <time.h>
 #include <string.h>
+#include "common.h"
 #include "avassert.h"
 #include "internal.h"
 #include "intreadwrite.h"
diff --git a/libavutil/time.c b/libavutil/time.c
index dbaee02..0deeca6 100644
--- a/libavutil/time.c
+++ b/libavutil/time.c
@@ -75,15 +75,15 @@ int av_gettime_relative_is_monotonic(void)
 
 int av_usleep(unsigned usec)
 {
-#if HAVE_NANOSLEEP
+#if HAVE_SLEEP
+    Sleep(usec / 1000);
+    return 0;
+#elif HAVE_NANOSLEEP
     struct timespec ts = { usec / 1000000, usec % 1000000 * 1000 };
     while (nanosleep(&ts, &ts) < 0 && errno == EINTR);
     return 0;
 #elif HAVE_USLEEP
     return usleep(usec);
-#elif HAVE_SLEEP
-    Sleep(usec / 1000);
-    return 0;
 #else
     return AVERROR(ENOSYS);
 #endif
