diff --git a/cmdutils.c b/cmdutils.c
index dd19bbffaf40b4c58f76fd2dbcc5b1565b7d7cf5..38e152a4ad329af73ce079ff5fffe82f19eb5b47 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -84,6 +84,7 @@ void uninit_opts(void)
     }
     av_freep(&opt_names);
     av_freep(&opt_values);
+    opt_name_count = 0;
 }
 
 void log_callback_help(void* ptr, int level, const char* fmt, va_list vl)
diff --git a/configure b/configure
index 66081f4cada28ee6e3c54903c27f4ff1ed7d40a1..d4e961bb64e0b63f0f28f22c6c0f6a31ff50ba20 100755
--- a/configure
+++ b/configure
@@ -94,7 +94,6 @@ Configuration options:
   --enable-w32threads      use Win32 threads [no]
   --enable-x11grab         enable X11 grabbing [no]
   --disable-network        disable network support [no]
-  --disable-mpegaudio-hp   faster (but less accurate) MPEG audio decoding [no]
   --enable-gray            enable full grayscale support (slower color)
   --disable-swscale-alpha  disable alpha channel support in swscale
   --disable-fastdiv        disable table-based division
@@ -957,7 +956,6 @@ CONFIG_LIST="
     mdct
     memalign_hack
     mlib
-    mpegaudio_hp
     network
     nonfree
     pic
@@ -1667,7 +1665,6 @@ enable ffmpeg
 enable ffplay
 enable ffprobe
 enable ffserver
-enable mpegaudio_hp
 enable network
 enable optimizations
 enable protocols
diff --git a/ffmpeg.c b/ffmpeg.c
index f47e281454a4400d119100beab533c231c31e8a5..aa3c33d709ccade92f7babb9b4af5efd79578d3b 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -316,6 +316,8 @@ typedef struct AVOutputStream {
     char *avfilter;
     AVFilterGraph *graph;
 #endif
+
+   int sws_flags;
 } AVOutputStream;
 
 static AVOutputStream **output_streams_for_file[MAX_FILES] = { NULL };
@@ -393,7 +395,7 @@ static int configure_video_filters(AVInputStream *ist, AVOutputStream *ost)
         snprintf(args, 255, "%d:%d:flags=0x%X",
                  codec->width,
                  codec->height,
-                 (int)av_get_int(sws_opts, "sws_flags", NULL));
+                 ost->sws_flags);
         if ((ret = avfilter_graph_create_filter(&filter, avfilter_get_by_name("scale"),
                                                 NULL, args, NULL, ost->graph)) < 0)
             return ret;
@@ -402,7 +404,7 @@ static int configure_video_filters(AVInputStream *ist, AVOutputStream *ost)
         last_filter = filter;
     }
 
-    snprintf(args, sizeof(args), "flags=0x%X", (int)av_get_int(sws_opts, "sws_flags", NULL));
+    snprintf(args, sizeof(args), "flags=0x%X", ost->sws_flags);
     ost->graph->scale_sws_opts = av_strdup(args);
 
     if (ost->avfilter) {
@@ -690,6 +692,8 @@ static AVOutputStream *new_output_stream(AVFormatContext *oc, int file_idx)
     }
     ost->file_index = file_idx;
     ost->index = idx;
+
+    ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
     return ost;
 }
 
@@ -1227,10 +1231,9 @@ static void do_video_out(AVFormatContext *s,
             }
             /* initialize a new scaler context */
             sws_freeContext(ost->img_resample_ctx);
-            sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
             ost->img_resample_ctx = sws_getContext(dec->width, dec->height, dec->pix_fmt,
                                                    enc->width, enc->height, enc->pix_fmt,
-                                                   sws_flags, NULL, NULL, NULL);
+                                                   ost->sws_flags, NULL, NULL, NULL);
             if (ost->img_resample_ctx == NULL) {
                 fprintf(stderr, "Cannot get resampling context\n");
                 ffmpeg_exit(1);
@@ -3406,6 +3409,8 @@ static void opt_input_file(const char *filename)
     av_freep(&video_codec_name);
     av_freep(&audio_codec_name);
     av_freep(&subtitle_codec_name);
+    uninit_opts();
+    init_opts();
 }
 
 static void check_inputs(int *has_video_ptr,
@@ -3939,6 +3944,8 @@ static void opt_output_file(const char *filename)
     set_context_opts(oc, avformat_opts, AV_OPT_FLAG_ENCODING_PARAM, NULL);
 
     av_freep(&forced_key_frames);
+    uninit_opts();
+    init_opts();
 }
 
 /* same option as mencoder */
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index a4b6f9a406b7dff0e603b0f33329ff4814fa15d8..a4c4d19824531c37b20c4a4add9f2738e50cf5d7 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -694,14 +694,6 @@ $(SUBDIR)cos_fixed_tables.c: $(SUBDIR)costablegen$(HOSTEXESUF)
 $(SUBDIR)sin_tables.c: $(SUBDIR)costablegen$(HOSTEXESUF)
 	$(M)./$< sin > $@
 
-ifdef CONFIG_MPEGAUDIO_HP
-$(SUBDIR)mpegaudio_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DFRAC_BITS=23
-$(SUBDIR)mpegaudio_tablegen.ho: CPPFLAGS += -DFRAC_BITS=23
-else
-$(SUBDIR)mpegaudio_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DFRAC_BITS=15
-$(SUBDIR)mpegaudio_tablegen.ho: CPPFLAGS += -DFRAC_BITS=15
-endif
-
 ifdef CONFIG_SMALL
 $(SUBDIR)%_tablegen$(HOSTEXESUF): HOSTCFLAGS += -DCONFIG_SMALL=1
 else
diff --git a/libavcodec/bfin/mathops.h b/libavcodec/bfin/mathops.h
index a0e808c81a17a390b97d85031e36467b9be738bc..50c03160ed86a98b02147f667c0d7d40e82f4d32 100644
--- a/libavcodec/bfin/mathops.h
+++ b/libavcodec/bfin/mathops.h
@@ -24,7 +24,6 @@
 
 #include "config.h"
 
-#if CONFIG_MPEGAUDIO_HP
 #define MULH(X,Y) ({ int xxo;                           \
     __asm__ (                                               \
         "a1 = %2.L * %1.L (FU);\n\t"                    \
@@ -34,15 +33,6 @@
         "a1 = a1 >>> 16;\n\t"                           \
         "%0 = (a0 += a1);\n\t"                          \
         : "=d" (xxo) : "d" (X), "d" (Y) : "A0","A1"); xxo; })
-#else
-#define MULH(X,Y) ({ int xxo;                           \
-    __asm__ (                                               \
-        "a1 = %2.H * %1.L (IS,M);\n\t"                  \
-        "a0 = %1.H * %2.H, a1+= %1.H * %2.L (IS,M);\n\t"\
-        "a1 = a1 >>> 16;\n\t"                           \
-        "%0 = (a0 += a1);\n\t"                          \
-        : "=d" (xxo) : "d" (X), "d" (Y) : "A0","A1"); xxo; })
-#endif
 
 /* signed 16x16 -> 32 multiply */
 #define MUL16(a, b) ({ int xxo;                         \
diff --git a/libavcodec/mpegaudio.h b/libavcodec/mpegaudio.h
index 4d78566463d07e00f1387a4518da120023f474f5..f84e2d44ee917d6db97535897de02b4c6f8c1c61 100644
--- a/libavcodec/mpegaudio.h
+++ b/libavcodec/mpegaudio.h
@@ -58,12 +58,9 @@
 
 #define MP3_MASK 0xFFFE0CCF
 
-#if CONFIG_MPEGAUDIO_HP
+#ifndef FRAC_BITS
 #define FRAC_BITS   23   /* fractional bits for sb_samples and dct */
 #define WFRAC_BITS  16   /* fractional bits for window */
-#else
-#define FRAC_BITS   15   /* fractional bits for sb_samples and dct */
-#define WFRAC_BITS  14   /* fractional bits for window */
 #endif
 
 #define FRAC_ONE    (1 << FRAC_BITS)
diff --git a/libavcodec/mpegaudio_tablegen.h b/libavcodec/mpegaudio_tablegen.h
index 6b5ff2280ed64f7c9744e9fd160fbfc870a3102a..01c4174a60abce94e308b8e05fbf5913cd1fc031 100644
--- a/libavcodec/mpegaudio_tablegen.h
+++ b/libavcodec/mpegaudio_tablegen.h
@@ -38,6 +38,8 @@ static uint32_t expval_table[512][16];
 static float exp_table_float[512];
 static float expval_table_float[512][16];
 
+#define FRAC_BITS 23
+
 static void mpegaudio_tableinit(void)
 {
     int i, value, exponent;
diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c
index 5d420dca3e93d034c55db34be4b82f6d6e0bd308..d7bc89f8375c0764a51131497736f1705fa64e70 100644
--- a/libavcodec/mpegaudiodec.c
+++ b/libavcodec/mpegaudiodec.c
@@ -28,18 +28,16 @@
 #include "avcodec.h"
 #include "get_bits.h"
 #include "dsputil.h"
+#include "mathops.h"
 
 /*
  * TODO:
- *  - in low precision mode, use more 16 bit multiplies in synth filter
  *  - test lsf / mpeg25 extensively.
  */
 
 #include "mpegaudio.h"
 #include "mpegaudiodecheader.h"
 
-#include "mathops.h"
-
 #if CONFIG_FLOAT
 #   define SHR(a,b)       ((a)*(1.0f/(1<<(b))))
 #   define compute_antialias compute_antialias_float
@@ -248,14 +246,6 @@ static inline int l3_unscale(int value, int exponent)
 
 static int dev_4_3_coefs[DEV_ORDER];
 
-#if 0 /* unused */
-static int pow_mult3[3] = {
-    POW_FIX(1.0),
-    POW_FIX(1.25992104989487316476),
-    POW_FIX(1.58740105196819947474),
-};
-#endif
-
 static av_cold void int_pow_init(void)
 {
     int i, a;
@@ -267,53 +257,6 @@ static av_cold void int_pow_init(void)
     }
 }
 
-#if 0 /* unused, remove? */
-/* return the mantissa and the binary exponent */
-static int int_pow(int i, int *exp_ptr)
-{
-    int e, er, eq, j;
-    int a, a1;
-
-    /* renormalize */
-    a = i;
-    e = POW_FRAC_BITS;
-    while (a < (1 << (POW_FRAC_BITS - 1))) {
-        a = a << 1;
-        e--;
-    }
-    a -= (1 << POW_FRAC_BITS);
-    a1 = 0;
-    for(j = DEV_ORDER - 1; j >= 0; j--)
-        a1 = POW_MULL(a, dev_4_3_coefs[j] + a1);
-    a = (1 << POW_FRAC_BITS) + a1;
-    /* exponent compute (exact) */
-    e = e * 4;
-    er = e % 3;
-    eq = e / 3;
-    a = POW_MULL(a, pow_mult3[er]);
-    while (a >= 2 * POW_FRAC_ONE) {
-        a = a >> 1;
-        eq++;
-    }
-    /* convert to float */
-    while (a < POW_FRAC_ONE) {
-        a = a << 1;
-        eq--;
-    }
-    /* now POW_FRAC_ONE <= a < 2 * POW_FRAC_ONE */
-#if POW_FRAC_BITS > FRAC_BITS
-    a = (a + (1 << (POW_FRAC_BITS - FRAC_BITS - 1))) >> (POW_FRAC_BITS - FRAC_BITS);
-    /* correct overflow */
-    if (a >= 2 * (1 << FRAC_BITS)) {
-        a = a >> 1;
-        eq++;
-    }
-#endif
-    *exp_ptr = eq;
-    return a;
-}
-#endif
-
 static av_cold int decode_init(AVCodecContext * avctx)
 {
     MPADecodeContext *s = avctx->priv_data;
@@ -540,24 +483,6 @@ static inline float round_sample(float *sum)
 
 #define MLSS(rt, ra, rb) rt-=(ra)*(rb)
 
-#elif FRAC_BITS <= 15
-
-static inline int round_sample(int *sum)
-{
-    int sum1;
-    sum1 = (*sum) >> OUT_SHIFT;
-    *sum &= (1<<OUT_SHIFT)-1;
-    return av_clip(sum1, OUT_MIN, OUT_MAX);
-}
-
-/* signed 16x16 -> 32 multiply add accumulate */
-#define MACS(rt, ra, rb) MAC16(rt, ra, rb)
-
-/* signed 16x16 -> 32 multiply */
-#define MULS(ra, rb) MUL16(ra, rb)
-
-#define MLSS(rt, ra, rb) MLS16(rt, ra, rb)
-
 #else
 
 static inline int round_sample(int64_t *sum)
@@ -624,8 +549,6 @@ void av_cold RENAME(ff_mpa_synth_init)(MPA_INT *window)
         v = ff_mpa_enwindow[i];
 #if CONFIG_FLOAT
         v *= 1.0 / (1LL<<(16 + FRAC_BITS));
-#elif WFRAC_BITS < 16
-        v = (v + (1 << (16 - WFRAC_BITS - 1))) >> (16 - WFRAC_BITS);
 #endif
         window[i] = v;
         if ((i & 63) != 0)
@@ -652,8 +575,6 @@ static void apply_window_mp3_c(MPA_INT *synth_buf, MPA_INT *window,
     OUT_INT *samples2;
 #if CONFIG_FLOAT
     float sum, sum2;
-#elif FRAC_BITS <= 15
-    int sum, sum2;
 #else
     int64_t sum, sum2;
 #endif
@@ -710,25 +631,11 @@ void ff_mpa_synth_filter(MPA_INT *synth_buf_ptr, int *synth_buf_offset,
 {
     register MPA_INT *synth_buf;
     int offset;
-#if FRAC_BITS <= 15
-    int32_t tmp[32];
-    int j;
-#endif
 
     offset = *synth_buf_offset;
     synth_buf = synth_buf_ptr + offset;
 
-#if FRAC_BITS <= 15
-    dct32(tmp, sb_samples);
-    for(j=0;j<32;j++) {
-        /* NOTE: can cause a loss in precision if very high amplitude
-           sound */
-        synth_buf[j] = av_clip_int16(tmp[j]);
-    }
-#else
     dct32(synth_buf, sb_samples);
-#endif
-
     apply_window_mp3_c(synth_buf, window, dither_state, samples, incr);
 
     offset = (offset - 32) & 511;
diff --git a/libavcodec/mpegaudioenc.c b/libavcodec/mpegaudioenc.c
index de2a336e34b3a26a2faaf469160dd4c4ed3a0767..515da6f670ea41beadf18bf1ed1e463ba328c54e 100644
--- a/libavcodec/mpegaudioenc.c
+++ b/libavcodec/mpegaudioenc.c
@@ -27,8 +27,9 @@
 #include "avcodec.h"
 #include "put_bits.h"
 
-#undef  CONFIG_MPEGAUDIO_HP
-#define CONFIG_MPEGAUDIO_HP 0
+#define FRAC_BITS   15   /* fractional bits for sb_samples and dct */
+#define WFRAC_BITS  14   /* fractional bits for window */
+
 #include "mpegaudio.h"
 
 /* currently, cannot change these constants (need to modify
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index 9eb87fdc850e5ba35cd83ee355cbb9b6a4f08d49..e7d70015aafc99996851969f9fce1896b7028818 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -588,7 +588,7 @@ static int mpegts_write_header(AVFormatContext *s)
     av_free(pids);
     for(i = 0;i < s->nb_streams; i++) {
         st = s->streams[i];
-        av_free(st->priv_data);
+        av_freep(&st->priv_data);
     }
     return -1;
 }
diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c
index e822ed71d5c2268b72835c10e1c69b43fb216d33..8b23f25c4621d56af2193fbacea1e624c1174d99 100644
--- a/libavformat/rtpproto.c
+++ b/libavformat/rtpproto.c
@@ -138,15 +138,13 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
 {
     RTPContext *s;
     int rtp_port, rtcp_port,
-        is_output, ttl, connect,
+        ttl, connect,
         local_rtp_port, local_rtcp_port, max_packet_size;
     char hostname[256];
     char buf[1024];
     char path[1024];
     const char *p;
 
-    is_output = (flags & AVIO_FLAG_WRITE);
-
     s = av_mallocz(sizeof(RTPContext));
     if (!s)
         return AVERROR(ENOMEM);
diff --git a/libavformat/udp.c b/libavformat/udp.c
index d48d5417c75f1b7093462ea8a657ae202afbd7e4..4491c4b049de44d98a7984cfa9edc737a31413cc 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -315,7 +315,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
     h->is_streamed = 1;
     h->max_packet_size = 1472;
 
-    is_output = (flags & AVIO_FLAG_WRITE);
+    is_output = !(flags & AVIO_FLAG_READ);
 
     s = av_mallocz(sizeof(UDPContext));
     if (!s)
@@ -358,14 +358,14 @@ static int udp_open(URLContext *h, const char *uri, int flags)
     /* XXX: fix av_url_split */
     if (hostname[0] == '\0' || hostname[0] == '?') {
         /* only accepts null hostname if input */
-        if (flags & AVIO_FLAG_WRITE)
+        if (!(flags & AVIO_FLAG_READ))
             goto fail;
     } else {
         if (ff_udp_set_remote_url(h, uri) < 0)
             goto fail;
     }
 
-    if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE))
+    if (s->is_multicast && (h->flags & AVIO_FLAG_READ))
         s->local_port = port;
     udp_fd = udp_socket_create(s, &my_addr, &len);
     if (udp_fd < 0)
@@ -382,7 +382,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
 
     /* the bind is needed to give a port to the socket now */
     /* if multicast, try the multicast address bind first */
-    if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) {
+    if (s->is_multicast && (h->flags & AVIO_FLAG_READ)) {
         bind_ret = bind(udp_fd,(struct sockaddr *)&s->dest_addr, len);
     }
     /* bind to the local address if not multicast or if the multicast
@@ -395,7 +395,7 @@ static int udp_open(URLContext *h, const char *uri, int flags)
     s->local_port = udp_port(&my_addr, len);
 
     if (s->is_multicast) {
-        if (h->flags & AVIO_FLAG_WRITE) {
+        if (!(h->flags & AVIO_FLAG_READ)) {
             /* output */
             if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr) < 0)
                 goto fail;
@@ -478,7 +478,7 @@ static int udp_close(URLContext *h)
 {
     UDPContext *s = h->priv_data;
 
-    if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE))
+    if (s->is_multicast && (h->flags & AVIO_FLAG_READ))
         udp_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr);
     closesocket(s->udp_fd);
     av_free(s);
diff --git a/tests/codec-regression.sh b/tests/codec-regression.sh
index 07be0aeeb6f02a12d6068968f144b7ed19f4a0db..95b99e351a524bc16e249513924a3e32acfc0b4f 100755
--- a/tests/codec-regression.sh
+++ b/tests/codec-regression.sh
@@ -61,7 +61,7 @@ do_video_decoding
 
 # mpeg2 encoding interlaced
 file=${outfile}mpeg2reuse.mpg
-do_ffmpeg $file -sameq -me_threshold 256 -mb_threshold 1024 -i ${target_path}/${outfile}mpeg2thread.mpg -vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -threads 4
+do_ffmpeg $file $DEC_OPTS -me_threshold 256 -i ${target_path}/${outfile}mpeg2thread.mpg $ENC_OPTS -sameq -me_threshold 256 -mb_threshold 1024 -vcodec mpeg2video -f mpeg1video -bf 2 -flags +ildct+ilme -threads 4
 do_video_decoding
 fi
 
@@ -328,12 +328,12 @@ fi
 
 if [ -n "$do_wmav1" ] ; then
 do_audio_encoding wmav1.asf "-acodec wmav1"
-do_ffmpeg_nomd5 $pcm_dst -i $target_path/$file -f wav
+do_ffmpeg_nomd5 $pcm_dst $DEC_OPTS -i $target_path/$file -f wav
 $tiny_psnr $pcm_dst $pcm_ref 2 8192 >> $logfile
 fi
 if [ -n "$do_wmav2" ] ; then
 do_audio_encoding wmav2.asf "-acodec wmav2"
-do_ffmpeg_nomd5 $pcm_dst -i $target_path/$file -f wav
+do_ffmpeg_nomd5 $pcm_dst $DEC_OPTS -i $target_path/$file -f wav
 $tiny_psnr $pcm_dst $pcm_ref 2 8192 >> $logfile
 fi
 
diff --git a/tests/lavf-regression.sh b/tests/lavf-regression.sh
index 7339c4e3c578999c8b24056258afcad891bb9fae..28f53f78b00d685465d1ec65beeb98840a2f9631 100755
--- a/tests/lavf-regression.sh
+++ b/tests/lavf-regression.sh
@@ -14,15 +14,15 @@ eval do_$test=y
 do_lavf()
 {
     file=${outfile}lavf.$1
-    do_ffmpeg $file -t 1 -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src -f s16le -i $pcm_src $2
-    do_ffmpeg_crc $file -i $target_path/$file $3
+    do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 $2
+    do_ffmpeg_crc $file $DEC_OPTS -i $target_path/$file $3
 }
 
 do_streamed_images()
 {
     file=${outfile}${1}pipe.$1
-    do_ffmpeg $file -t 1 -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src -f image2pipe
-    do_ffmpeg_crc $file -f image2pipe -i $target_path/$file
+    do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src -f image2pipe $ENC_OPTS -t 1 -qscale 10
+    do_ffmpeg_crc $file $DEC_OPTS -f image2pipe -i $target_path/$file
 }
 
 do_image_formats()
@@ -30,17 +30,17 @@ do_image_formats()
     outfile="$datadir/images/$1/"
     mkdir -p "$outfile"
     file=${outfile}%02d.$1
-    run_ffmpeg -t 0.5 -y -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src $2 $3 -flags +bitexact -sws_flags +accurate_rnd+bitexact $target_path/$file
+    run_ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $2 $ENC_OPTS $3 -t 0.5 -y -qscale 10 $target_path/$file
     do_md5sum ${outfile}02.$1 >> $logfile
-    do_ffmpeg_crc $file $3 -i $target_path/$file
+    do_ffmpeg_crc $file $DEC_OPTS $3 -i $target_path/$file
     wc -c ${outfile}02.$1 >> $logfile
 }
 
 do_audio_only()
 {
     file=${outfile}lavf.$1
-    do_ffmpeg $file -t 1 -qscale 10 $2 -f s16le -i $pcm_src $3
-    do_ffmpeg_crc $file -i $target_path/$file
+    do_ffmpeg $file $DEC_OPTS $2 -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 $3
+    do_ffmpeg_crc $file $DEC_OPTS -i $target_path/$file
 }
 
 rm -f "$logfile"
@@ -56,7 +56,7 @@ fi
 
 if [ -n "$do_rm" ] ; then
 file=${outfile}lavf.rm
-do_ffmpeg $file -t 1 -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src -f s16le -i $pcm_src -acodec ac3_fixed
+do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $DEC_OPTS -f s16le -i $pcm_src $ENC_OPTS -t 1 -qscale 10 -acodec ac3_fixed
 # broken
 #do_ffmpeg_crc $file -i $target_path/$file
 fi
@@ -127,13 +127,13 @@ fi
 
 if [ -n "$do_gif" ] ; then
 file=${outfile}lavf.gif
-do_ffmpeg $file -t 1 -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src -pix_fmt rgb24
-do_ffmpeg_crc $file -i $target_path/$file -pix_fmt rgb24
+do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $ENC_OPTS -t 1 -qscale 10 -pix_fmt rgb24
+do_ffmpeg_crc $file $DEC_OPTS -i $target_path/$file -pix_fmt rgb24
 fi
 
 if [ -n "$do_yuv4mpeg" ] ; then
 file=${outfile}lavf.y4m
-do_ffmpeg $file -t 1 -qscale 10 -f image2 -vcodec pgmyuv -i $raw_src
+do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $ENC_OPTS -t 1 -qscale 10
 #do_ffmpeg_crc $file -i $target_path/$file
 fi
 
@@ -227,9 +227,9 @@ conversions="yuv420p yuv422p yuv444p yuyv422 yuv410p yuv411p yuvj420p \
              monob yuv440p yuvj440p"
 for pix_fmt in $conversions ; do
     file=${outfile}${pix_fmt}.yuv
-    do_ffmpeg_nocheck $file -r 1 -t 1 -f image2 -vcodec pgmyuv -i $raw_src \
-                            -f rawvideo -s 352x288 -pix_fmt $pix_fmt $target_path/$raw_dst
-    do_ffmpeg $file -f rawvideo -s 352x288 -pix_fmt $pix_fmt -i $target_path/$raw_dst \
-                    -f rawvideo -s 352x288 -pix_fmt yuv444p
+    do_ffmpeg_nocheck $file $DEC_OPTS -r 1 -t 1 -f image2 -vcodec pgmyuv -i $raw_src \
+                            $ENC_OPTS -f rawvideo -s 352x288 -pix_fmt $pix_fmt $target_path/$raw_dst
+    do_ffmpeg $file $DEC_OPTS -f rawvideo -s 352x288 -pix_fmt $pix_fmt -i $target_path/$raw_dst \
+                    $ENC_OPTS -f rawvideo -s 352x288 -pix_fmt yuv444p
 done
 fi
diff --git a/tests/lavfi-regression.sh b/tests/lavfi-regression.sh
index 7a5f239675c3ae46dbe42b49f81b1427fb7845fe..129358090e0412dca46eb45deba669b0e947c513 100755
--- a/tests/lavfi-regression.sh
+++ b/tests/lavfi-regression.sh
@@ -19,8 +19,8 @@ do_video_filter() {
     filters=$2
     shift 2
     printf '%-20s' $label >>$logfile
-    run_ffmpeg -f image2 -vcodec pgmyuv -i $raw_src    \
-        -vf "$filters" -vcodec rawvideo $* -f nut md5: >>$logfile
+    run_ffmpeg $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src    \
+        $ENC_OPTS -vf "$filters" -vcodec rawvideo $* -f nut md5: >>$logfile
 }
 
 do_lavfi() {
diff --git a/tests/regression-funcs.sh b/tests/regression-funcs.sh
index 77ede1d5b7bfa0b3149cfd8a48cf0d25a560fcf6..0e4ea44f462afd48231492a3abc3b75c6a1d6c96 100755
--- a/tests/regression-funcs.sh
+++ b/tests/regression-funcs.sh
@@ -53,7 +53,10 @@ echov(){
 
 . $(dirname $0)/md5.sh
 
-FFMPEG_OPTS="-v 0 -threads $threads -y -flags +bitexact -dct fastint -idct simple -sws_flags +accurate_rnd+bitexact"
+FFMPEG_OPTS="-v 0 -y"
+COMMON_OPTS="-flags +bitexact -idct simple -sws_flags +accurate_rnd+bitexact"
+DEC_OPTS="$COMMON_OPTS -threads $threads"
+ENC_OPTS="$COMMON_OPTS -dct fastint"
 
 run_ffmpeg()
 {
@@ -115,22 +118,22 @@ do_ffmpeg_nocheck()
 
 do_video_decoding()
 {
-    do_ffmpeg $raw_dst $1 -i $target_path/$file -f rawvideo $2
+    do_ffmpeg $raw_dst $DEC_OPTS $1 -i $target_path/$file -f rawvideo $ENC_OPTS $2
 }
 
 do_video_encoding()
 {
     file=${outfile}$1
-    do_ffmpeg $file -f image2 -vcodec pgmyuv -i $raw_src $2
+    do_ffmpeg $file $DEC_OPTS -f image2 -vcodec pgmyuv -i $raw_src $ENC_OPTS $2
 }
 
 do_audio_encoding()
 {
     file=${outfile}$1
-    do_ffmpeg $file -ab 128k -ac 2 -f s16le -i $pcm_src $2
+    do_ffmpeg $file $DEC_OPTS -ac 2 -f s16le -i $pcm_src -ab 128k $ENC_OPTS $2
 }
 
 do_audio_decoding()
 {
-    do_ffmpeg $pcm_dst -i $target_path/$file -sample_fmt s16 -f wav
+    do_ffmpeg $pcm_dst $DEC_OPTS -i $target_path/$file -sample_fmt s16 -f wav
 }