diff --git a/configure b/configure
index c3606bd..344d19c 100755
--- a/configure
+++ b/configure
@@ -1006,7 +1006,7 @@ check_pkg_config(){
     shift 3
     check_cmd $pkg_config --exists --print-errors $pkg || return
     pkg_cflags=$($pkg_config --cflags $pkg)
-    pkg_libs=$($pkg_config --libs $pkg)
+    pkg_libs=$($pkg_config --libs --static $pkg)
     check_func_headers "$headers" "$funcs" $pkg_cflags $pkg_libs "$@" &&
         set_safe ${pkg}_cflags $pkg_cflags   &&
         set_safe ${pkg}_libs   $pkg_libs
@@ -4272,7 +4272,7 @@ enabled libgsm            && { for gsm_hdr in "gsm.h" "gsm/gsm.h"; do
                                    check_lib "${gsm_hdr}" gsm_create -lgsm && break;
                                done || die "ERROR: libgsm not found"; }
 enabled libilbc           && require libilbc ilbc.h WebRtcIlbcfix_InitDecode -lilbc
-enabled libmodplug        && require libmodplug libmodplug/modplug.h ModPlug_Load -lmodplug
+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
@@ -4358,7 +4358,7 @@ if check_pkg_config sdl SDL_events.h SDL_PollEvent; 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 &&
@@ -4416,8 +4416,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 b2cebb8..750bfa5 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -1238,12 +1238,14 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
                                           ost->st->time_base, AV_TIME_BASE_Q));
     }
 
-    secs = pts / AV_TIME_BASE;
-    us = pts % AV_TIME_BASE;
-    mins = secs / 60;
-    secs %= 60;
-    hours = mins / 60;
-    mins %= 60;
+    if (progress_avio) {
+        secs = pts / AV_TIME_BASE;
+        us = 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;
 
@@ -1251,9 +1253,13 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
                                  "size=N/A time=");
     else                snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
                                  "size=%8.0fkB time=", total_size / 1024.0);
-    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");
     else             snprintf(buf + strlen(buf), sizeof(buf) - strlen(buf),
@@ -1261,8 +1267,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/jpegls.h b/libavcodec/jpegls.h
index 10ae054..8cbf25c 100644
--- a/libavcodec/jpegls.h
+++ b/libavcodec/jpegls.h
@@ -43,7 +43,7 @@ typedef struct JLSState {
     int run_index[4];
 } JLSState;
 
-extern const uint8_t ff_log2_run[32];
+extern const uint8_t ff_log2_run[41];
 
 /**
  * Calculate initial JPEG-LS parameters
diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c
index 89df55f..93c4653 100644
--- a/libavcodec/libx264.c
+++ b/libavcodec/libx264.c
@@ -365,6 +365,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;
         }
     }
 
@@ -386,6 +391,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)
@@ -431,6 +438,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)
diff --git a/libavcodec/libxvid.c b/libavcodec/libxvid.c
index 40b3bff..9c26cd3 100644
--- a/libavcodec/libxvid.c
+++ b/libavcodec/libxvid.c
@@ -467,6 +467,7 @@ static av_cold int xvid_encode_init(AVCodecContext *avctx)  {
     xvid_enc_create.num_zones = 0;
 
     xvid_enc_create.num_threads = avctx->thread_count;
+    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 04182f2..33854b0 100644
--- a/libavutil/atomic.c
+++ b/libavutil/atomic.c
@@ -18,6 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "common.h"
 #include "atomic.h"
 
 #if !HAVE_ATOMICS_NATIVE
diff --git a/libavutil/common.h b/libavutil/common.h
index e487218..1646951 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -466,3 +466,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/lls2.c b/libavutil/lls2.c
index 8cadacb..f03b71f 100644
--- a/libavutil/lls2.c
+++ b/libavutil/lls2.c
@@ -125,6 +125,7 @@ av_cold void avpriv_init_lls2(LLSModel2 *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 63fc37d..7df5ff1 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/opt.c b/libavutil/opt.c
index 46f60aa..88fa18d 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -235,6 +235,7 @@ static int set_string_number(void *obj, void *target_obj, const AVOption *o, con
             read_number(o, dst, NULL, NULL, &intnum);
             if      (cmd == '+') d = intnum | (int64_t)d;
             else if (cmd == '-') d = intnum &~(int64_t)d;
+            else if (buf[0] == '0' && buf[1] == 'x') d = strtoul(buf, NULL, 16);
         } else {
             read_number(o, dst, &num, &den, &intnum);
             if      (cmd == '+') d = notfirst*num*intnum/den + d;
diff --git a/libavutil/random_seed.c b/libavutil/random_seed.c
index aa89024..68330a2 100644
--- a/libavutil/random_seed.c
+++ b/libavutil/random_seed.c
@@ -31,6 +31,7 @@
 #include <math.h>
 #include <time.h>
 #include <string.h>
+#include "common.h"
 #include "avassert.h"
 #include "internal.h"
 #include "timer.h"
diff --git a/libavutil/time.c b/libavutil/time.c
index 5a00e70..d679b69 100644
--- a/libavutil/time.c
+++ b/libavutil/time.c
@@ -55,15 +55,15 @@ int64_t av_gettime(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
