[SCM] libgroove/upstream: update to libav afdf946

andrewrk-guest at users.alioth.debian.org andrewrk-guest at users.alioth.debian.org
Mon Mar 17 02:20:49 UTC 2014


The following commit has been merged in the upstream branch:
commit e0685169b5915b5898a1eb9b01dc71e38e771264
Author: Andrew Kelley <superjoe30 at gmail.com>
Date:   Fri Mar 14 16:59:23 2014 -0700

    update to libav afdf946

diff --git a/deps/libav/.gitignore b/deps/libav/.gitignore
index 01d93b9..07ba485 100644
--- a/deps/libav/.gitignore
+++ b/deps/libav/.gitignore
@@ -32,6 +32,9 @@
 /doc/avoptions_codec.texi
 /doc/avoptions_format.texi
 /doc/doxy/html/
+/doc/examples/avcodec
+/doc/examples/filter_audio
+/doc/examples/metadata
 /doc/examples/output
 /doc/examples/transcode_aac
 /doc/print_options
diff --git a/deps/libav/Changelog b/deps/libav/Changelog
index bed6c31..279c0d8 100644
--- a/deps/libav/Changelog
+++ b/deps/libav/Changelog
@@ -1,6 +1,11 @@
 Entries are sorted chronologically from oldest to youngest within each release,
 releases are sorted from youngest to oldest.
 
+version <next>:
+- compand audio filter
+- shuffleplanes filter
+
+
 version 10:
 - av_strnstr
 - support ID3v2 tags in ASF files
diff --git a/deps/libav/Makefile b/deps/libav/Makefile
index 25c3b32..2453dfd 100644
--- a/deps/libav/Makefile
+++ b/deps/libav/Makefile
@@ -115,8 +115,7 @@ config.h: .config
 SUBDIR_VARS := CLEANFILES EXAMPLES FFLIBS HOSTPROGS TESTPROGS TOOLS      \
                HEADERS ARCH_HEADERS BUILT_HEADERS SKIPHEADERS            \
                ARMV5TE-OBJS ARMV6-OBJS VFP-OBJS NEON-OBJS                \
-               ALTIVEC-OBJS VIS-OBJS                                     \
-               MMX-OBJS YASM-OBJS                                        \
+               ALTIVEC-OBJS MMX-OBJS YASM-OBJS                           \
                OBJS HOSTOBJS TESTOBJS
 
 define RESET
diff --git a/deps/libav/RELEASE b/deps/libav/RELEASE
index b49ddea..086e7dc 100644
--- a/deps/libav/RELEASE
+++ b/deps/libav/RELEASE
@@ -1 +1 @@
-10_alpha2
+11_alpha1
diff --git a/deps/libav/arch.mak b/deps/libav/arch.mak
index 09d24af..b287fce 100644
--- a/deps/libav/arch.mak
+++ b/deps/libav/arch.mak
@@ -5,7 +5,5 @@ OBJS-$(HAVE_NEON)    += $(NEON-OBJS)    $(NEON-OBJS-yes)
 
 OBJS-$(HAVE_ALTIVEC) += $(ALTIVEC-OBJS) $(ALTIVEC-OBJS-yes)
 
-OBJS-$(HAVE_VIS)     += $(VIS-OBJS)     $(VIS-OBJS-yes)
-
 OBJS-$(HAVE_MMX)     += $(MMX-OBJS)     $(MMX-OBJS-yes)
 OBJS-$(HAVE_YASM)    += $(YASM-OBJS)    $(YASM-OBJS-yes)
diff --git a/deps/libav/avconv.c b/deps/libav/avconv.c
index edce1e5..13e6778 100644
--- a/deps/libav/avconv.c
+++ b/deps/libav/avconv.c
@@ -858,14 +858,18 @@ static void print_report(int is_last_report, int64_t timer_start)
     fflush(stderr);
 
     if (is_last_report) {
-        int64_t raw= audio_size + video_size + extra_size;
+        int64_t raw   = audio_size + video_size + extra_size;
+        float percent = 0.0;
+
+        if (raw)
+            percent = 100.0 * (total_size - raw) / raw;
+
         av_log(NULL, AV_LOG_INFO, "\n");
         av_log(NULL, AV_LOG_INFO, "video:%1.0fkB audio:%1.0fkB global headers:%1.0fkB muxing overhead %f%%\n",
                video_size / 1024.0,
                audio_size / 1024.0,
                extra_size / 1024.0,
-               100.0 * (total_size - raw) / raw
-        );
+               percent);
     }
 }
 
@@ -1476,7 +1480,6 @@ static int init_input_stream(int ist_index, char *error, int error_len)
     ist->last_dts = ist->st->avg_frame_rate.num ? - ist->st->codec->has_b_frames * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0;
     ist->next_dts = AV_NOPTS_VALUE;
     init_pts_correction(&ist->pts_ctx);
-    ist->is_start = 1;
 
     return 0;
 }
diff --git a/deps/libav/avconv.h b/deps/libav/avconv.h
index c270401..c912fae 100644
--- a/deps/libav/avconv.h
+++ b/deps/libav/avconv.h
@@ -229,7 +229,6 @@ typedef struct InputStream {
     int64_t       last_dts;
     PtsCorrectionContext pts_ctx;
     double ts_scale;
-    int is_start;            /* is 1 at the start and after a discontinuity */
     int showed_multi_packet_warning;
     AVDictionary *opts;
     AVRational framerate;               /* framerate forced with -r */
diff --git a/deps/libav/avconv_opt.c b/deps/libav/avconv_opt.c
index d62d11f..7bc41c9 100644
--- a/deps/libav/avconv_opt.c
+++ b/deps/libav/avconv_opt.c
@@ -463,6 +463,8 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
         AVCodecContext *dec = st->codec;
         InputStream *ist = av_mallocz(sizeof(*ist));
         char *framerate = NULL, *hwaccel = NULL, *hwaccel_device = NULL;
+        char *codec_tag = NULL;
+        char *next;
 
         if (!ist)
             exit_program(1);
@@ -478,6 +480,14 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
         ist->ts_scale = 1.0;
         MATCH_PER_STREAM_OPT(ts_scale, dbl, ist->ts_scale, ic, st);
 
+        MATCH_PER_STREAM_OPT(codec_tags, str, codec_tag, ic, st);
+        if (codec_tag) {
+            uint32_t tag = strtol(codec_tag, &next, 0);
+            if (*next)
+                tag = AV_RL32(codec_tag);
+            st->codec->codec_tag = tag;
+        }
+
         ist->dec = choose_decoder(o, ic, st);
         ist->opts = filter_codec_opts(o->g->codec_opts, ist->st->codec->codec_id, ic, st, ist->dec);
 
@@ -2238,7 +2248,7 @@ const OptionDef options[] = {
     { "frames",         OPT_INT64 | HAS_ARG | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(max_frames) },
         "set the number of frames to record", "number" },
     { "tag",            OPT_STRING | HAS_ARG | OPT_SPEC |
-                        OPT_EXPERT | OPT_OUTPUT,                     { .off = OFFSET(codec_tags) },
+                        OPT_EXPERT | OPT_OUTPUT | OPT_INPUT,         { .off = OFFSET(codec_tags) },
         "force codec tag/fourcc", "fourcc/tag" },
     { "q",              HAS_ARG | OPT_EXPERT | OPT_DOUBLE |
                         OPT_SPEC | OPT_OUTPUT,                       { .off = OFFSET(qscale) },
diff --git a/deps/libav/cmdutils.c b/deps/libav/cmdutils.c
index a1e5116..69a11bd 100644
--- a/deps/libav/cmdutils.c
+++ b/deps/libav/cmdutils.c
@@ -1530,6 +1530,12 @@ int check_stream_specifier(AVFormatContext *s, AVStream *st, const char *spec)
                     return 1;
         }
         return 0;
+    } else if (*spec == 'i' && *(spec + 1) == ':') {
+        int stream_id;
+        char *endptr;
+        spec += 2;
+        stream_id = strtol(spec, &endptr, 0);
+        return stream_id == st->id;
     } else if (!*spec) /* empty specifier, matches everything */
         return 1;
 
diff --git a/deps/libav/common.mak b/deps/libav/common.mak
index 6836c11..ade9376 100644
--- a/deps/libav/common.mak
+++ b/deps/libav/common.mak
@@ -14,7 +14,6 @@ TESTPROGS += $(TESTPROGS-yes)
 LDLIBS       = $(FFLIBS:%=%$(BUILDSUF))
 FFEXTRALIBS := $(LDLIBS:%=$(LD_LIB)) $(EXTRALIBS)
 
-EXAMPLES  := $(EXAMPLES:%=$(SUBDIR)%-example$(EXESUF))
 OBJS      := $(sort $(OBJS:%=$(SUBDIR)%))
 TESTOBJS  := $(TESTOBJS:%=$(SUBDIR)%) $(TESTPROGS:%=$(SUBDIR)%-test.o)
 TESTPROGS := $(TESTPROGS:%=$(SUBDIR)%-test$(EXESUF))
diff --git a/deps/libav/libavcodec/dct32.h b/deps/libav/compat/float/float.h
similarity index 67%
copy from deps/libav/libavcodec/dct32.h
copy to deps/libav/compat/float/float.h
index 110338d..c69f728 100644
--- a/deps/libav/libavcodec/dct32.h
+++ b/deps/libav/compat/float/float.h
@@ -1,4 +1,6 @@
 /*
+ * Work around broken floating point limits on some systems.
+ *
  * This file is part of Libav.
  *
  * Libav is free software; you can redistribute it and/or
@@ -16,10 +18,18 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef AVCODEC_DCT32_H
-#define AVCODEC_DCT32_H
+#include_next <float.h>
+
+#ifdef FLT_MAX
+#undef  FLT_MAX
+#define FLT_MAX 3.40282346638528859812e+38F
+
+#undef  FLT_MIN
+#define FLT_MIN 1.17549435082228750797e-38F
 
-void ff_dct32_float(float *dst, const float *src);
-void ff_dct32_fixed(int *dst, const int *src);
+#undef  DBL_MAX
+#define DBL_MAX ((double)1.79769313486231570815e+308L)
 
+#undef  DBL_MIN
+#define DBL_MIN ((double)2.22507385850720138309e-308L)
 #endif
diff --git a/deps/libav/libavcodec/fft_fixed.c b/deps/libav/compat/float/limits.h
similarity index 87%
copy from deps/libav/libavcodec/fft_fixed.c
copy to deps/libav/compat/float/limits.h
index bad4821..9150bc8 100644
--- a/deps/libav/libavcodec/fft_fixed.c
+++ b/deps/libav/compat/float/limits.h
@@ -1,4 +1,6 @@
 /*
+ * Work around broken floating point limits on some systems.
+ *
  * This file is part of Libav.
  *
  * Libav is free software; you can redistribute it and/or
@@ -16,5 +18,5 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#define FFT_FLOAT 0
-#include "fft_template.c"
+#include_next <limits.h>
+#include <float.h>
diff --git a/deps/libav/configure b/deps/libav/configure
index 1afba25..7051a76 100755
--- a/deps/libav/configure
+++ b/deps/libav/configure
@@ -212,7 +212,10 @@ External library support:
   --enable-x11grab         enable X11 grabbing [no]
   --enable-zlib            enable zlib [autodetect]
 
-Advanced options (experts only):
+Toolchain options:
+  --arch=ARCH              select architecture [$arch]
+  --cpu=CPU                select the minimum required CPU (affects
+                           instruction selection, may crash on older CPUs)
   --cross-prefix=PREFIX    use PREFIX for compilation tools [$cross_prefix]
   --enable-cross-compile   assume a cross-compiler is used
   --sysroot=PATH           root of cross-build tree
@@ -222,12 +225,15 @@ Advanced options (experts only):
   --target-path=DIR        path to view of build directory on target
   --target-samples=DIR     path to samples directory on target
   --toolchain=NAME         set tool defaults according to NAME
+  --pkg-config=PKGCONFIG   use pkg-config tool PKGCONFIG [$pkg_config_default]
   --nm=NM                  use nm tool
   --ar=AR                  use archive tool AR [$ar_default]
   --as=AS                  use assembler AS [$as_default]
   --cc=CC                  use C compiler CC [$cc_default]
   --dep-cc=DEPCC           use dependency generator DEPCC [$cc_default]
   --ld=LD                  use linker LD
+  --pkg-config=PKGCONF     use pkg-config PKGCONF [$pkg_config_default]
+  --pkg-config-flags=FLAGS pass additional flags to pkgconf []
   --host-cc=HOSTCC         use host C compiler HOSTCC
   --host-cflags=HCFLAGS    use HCFLAGS when compiling for host
   --host-cppflags=HCPPFLAGS use HCPPFLAGS when compiling for host
@@ -241,20 +247,19 @@ Advanced options (experts only):
   --extra-version=STRING   version string suffix []
   --optflags=OPTFLAGS      override optimization-related compiler flags
   --build-suffix=SUFFIX    library name suffix []
-  --malloc-prefix=PREFIX   prefix malloc and related names with PREFIX
-  --arch=ARCH              select architecture [$arch]
-  --cpu=CPU                select the minimum required CPU (affects
-                           instruction selection, may crash on older CPUs)
   --enable-pic             build position-independent code
-  --enable-sram            allow use of on-chip SRAM
   --enable-thumb           compile for Thumb instruction set
+  --enable-lto             use link-time optimization
+
+Advanced options (experts only):
+  --malloc-prefix=PREFIX   prefix malloc and related names with PREFIX
   --disable-symver         disable symbol versioning
   --enable-hardcoded-tables use hardcoded tables instead of runtime generation
   --disable-safe-bitstream-reader
                            disable buffer boundary checking in bitreaders
                            (faster, but may crash)
   --enable-memalign-hack   emulate memalign, interferes with memory debuggers
-  --enable-lto             use link-time optimization
+  --enable-sram            allow use of on-chip SRAM
 
 Optimization options (experts only):
   --disable-asm            disable all assembler optimizations
@@ -270,6 +275,8 @@ Optimization options (experts only):
   --disable-sse4           disable SSE4 optimizations
   --disable-sse42          disable SSE4.2 optimizations
   --disable-avx            disable AVX optimizations
+  --disable-xop            disable XOP optimizations
+  --disable-fma3           disable FMA3 optimizations
   --disable-fma4           disable FMA4 optimizations
   --disable-avx2           disable AVX2 optimizations
   --disable-armv5te        disable armv5te optimizations
@@ -277,7 +284,6 @@ Optimization options (experts only):
   --disable-armv6t2        disable armv6t2 optimizations
   --disable-vfp            disable VFP optimizations
   --disable-neon           disable NEON optimizations
-  --disable-vis            disable VIS optimizations
   --disable-inline-asm     disable use of inline assembler
   --disable-yasm           disable use of yasm assembler
 
@@ -921,8 +927,8 @@ check_pkg_config(){
     funcs="$3"
     shift 3
     check_cmd $pkg_config --exists --print-errors $pkg || return
-    pkg_cflags=$($pkg_config --cflags $pkg)
-    pkg_libs=$($pkg_config --libs $pkg)
+    pkg_cflags=$($pkg_config --cflags $pkg_config_flags $pkg)
+    pkg_libs=$($pkg_config --libs $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
@@ -992,6 +998,16 @@ check_builtin(){
     check_code ld "$headers" "$builtin" "$@" && enable "$name"
 }
 
+check_compile_assert(){
+    log check_compile_assert "$@"
+    name=$1
+    headers=$2
+    condition=$3
+    shift 3
+    disable "$name"
+    check_code cc "$headers" "char c[2 * !!($condition) - 1]" "$@" && enable "$name"
+}
+
 require(){
     name="$1"
     header="$2"
@@ -1095,6 +1111,9 @@ COMPONENT_LIST="
 "
 
 EXAMPLE_LIST="
+    avcodec_example
+    filter_audio_example
+    metadata_example
     output_example
     transcode_aac_example
 "
@@ -1143,6 +1162,7 @@ HWACCEL_LIST="
     vda
     vdpau
 "
+
 LIBRARY_LIST="
     avcodec
     avdevice
@@ -1181,8 +1201,8 @@ CONFIG_LIST="
     neon_clobber_test
     network
     nonfree
-    pod2man
     pic
+    pod2man
     rdft
     runtime_cpudetect
     safe_bitstream_reader
@@ -1197,18 +1217,18 @@ CONFIG_LIST="
     xmm_clobber_test
 "
 
-THREADS_LIST='
+THREADS_LIST="
     pthreads
     w32threads
-'
+"
 
-ATOMICS_LIST='
+ATOMICS_LIST="
     atomics_gcc
     atomics_suncc
     atomics_win32
-'
+"
 
-ARCH_LIST='
+ARCH_LIST="
     aarch64
     alpha
     arm
@@ -1233,24 +1253,24 @@ ARCH_LIST='
     x86
     x86_32
     x86_64
-'
+"
 
-ARCH_EXT_LIST_ARM='
+ARCH_EXT_LIST_ARM="
     armv5te
     armv6
     armv6t2
     neon
     vfp
     vfpv3
-'
+"
 
-ARCH_EXT_LIST_X86='
+ARCH_EXT_LIST_X86_SIMD="
     amd3dnow
     amd3dnowext
     avx
     avx2
+    fma3
     fma4
-    i686
     mmx
     mmxext
     sse
@@ -1259,26 +1279,32 @@ ARCH_EXT_LIST_X86='
     sse4
     sse42
     ssse3
-'
+    xop
+"
+
+ARCH_EXT_LIST_X86="
+    $ARCH_EXT_LIST_X86_SIMD
+    cpunop
+    i686
+"
 
 ARCH_EXT_LIST="
     $ARCH_EXT_LIST_ARM
     $ARCH_EXT_LIST_X86
     altivec
     ppc4xx
-    vis
 "
 
-HAVE_LIST_CMDLINE='
+HAVE_LIST_CMDLINE="
     inline_asm
     symver
     yasm
-'
+"
 
-HAVE_LIST_PUB='
+HAVE_LIST_PUB="
     bigendian
     fast_unaligned
-'
+"
 
 MATH_FUNCS="
     atanf
@@ -1311,18 +1337,17 @@ HAVE_LIST="
     $ARCH_EXT_LIST
     $(add_suffix _external $ARCH_EXT_LIST)
     $(add_suffix _inline   $ARCH_EXT_LIST)
+    $ATOMICS_LIST
     $HAVE_LIST_CMDLINE
     $HAVE_LIST_PUB
-    $THREADS_LIST
-    $ATOMICS_LIST
     $MATH_FUNCS
+    $THREADS_LIST
     aligned_malloc
     aligned_stack
     alsa_asoundlib_h
     altivec_h
     arpa_inet_h
     asm_mod_q
-    asm_mod_y
     atomic_cas_ptr
     atomics_native
     attribute_may_alias
@@ -1331,7 +1356,6 @@ HAVE_LIST="
     cdio_paranoia_paranoia_h
     closesocket
     CommandLineToArgvW
-    cpunop
     CryptGenRandom
     dcbzl
     dev_bktr_ioctl_bt848_h
@@ -1350,6 +1374,7 @@ HAVE_LIST="
     fast_clz
     fast_cmov
     fcntl
+    flt_lim
     fork
     getaddrinfo
     gethrtime
@@ -1357,16 +1382,16 @@ HAVE_LIST="
     GetProcessAffinityMask
     GetProcessMemoryInfo
     GetProcessTimes
-    GetSystemTimeAsFileTime
     getrusage
     getservbyport
+    GetSystemTimeAsFileTime
     gettimeofday
     gnu_as
     gsm_h
     ibm_asm
     inet_aton
-    io_h
     inline_asm_labels
+    io_h
     isatty
     jack_port_get_latency_range
     ldbrx
@@ -1377,6 +1402,8 @@ HAVE_LIST="
     local_aligned_8
     localtime_r
     loongson
+    mach_absolute_time
+    mach_mach_time_h
     machine_ioctl_bt848_h
     machine_ioctl_meteor_h
     machine_rw_barrier
@@ -1404,7 +1431,6 @@ HAVE_LIST="
     soundcard_h
     strerror_r
     strptime
-    strtok_r
     struct_addrinfo
     struct_group_source_req
     struct_ip_mreq_source
@@ -1418,8 +1444,6 @@ HAVE_LIST="
     symver_asm_label
     symver_gnu_asm
     sync_val_compare_and_swap
-    sysconf
-    sysctl
     sys_mman_h
     sys_param_h
     sys_resource_h
@@ -1428,6 +1452,8 @@ HAVE_LIST="
     sys_time_h
     sys_un_h
     sys_videoio_h
+    sysconf
+    sysctl
     threads
     unistd_h
     usleep
@@ -1489,7 +1515,7 @@ CMDLINE_SELECT="
     optimizations
 "
 
-PATHS_LIST='
+PATHS_LIST="
     bindir
     datadir
     docdir
@@ -1498,7 +1524,7 @@ PATHS_LIST='
     mandir
     prefix
     shlibdir
-'
+"
 
 CMDLINE_SET="
     $PATHS_LIST
@@ -1523,6 +1549,7 @@ CMDLINE_SET="
     nm
     optflags
     pkg_config
+    pkg_config_flags
     random_seed
     samples
     sysinclude
@@ -1555,8 +1582,6 @@ map 'eval ${v}_inline_deps=inline_asm' $ARCH_EXT_LIST_ARM
 altivec_deps="ppc"
 ppc4xx_deps="ppc"
 
-vis_deps="sparc"
-
 cpunop_deps="i686"
 x86_64_select="i686"
 x86_64_suggest="fast_cmov"
@@ -1573,6 +1598,8 @@ ssse3_deps="sse3"
 sse4_deps="ssse3"
 sse42_deps="sse4"
 avx_deps="sse42"
+xop_deps="avx"
+fma3_deps="avx"
 fma4_deps="avx"
 avx2_deps="avx"
 
@@ -1580,7 +1607,7 @@ mmx_external_deps="yasm"
 mmx_inline_deps="inline_asm"
 mmx_suggest="mmx_external mmx_inline"
 
-for ext in $(filter_out mmx $ARCH_EXT_LIST_X86); do
+for ext in $(filter_out mmx $ARCH_EXT_LIST_X86_SIMD); do
     eval dep=\$${ext}_deps
     eval ${ext}_external_deps='"${dep}_external"'
     eval ${ext}_inline_deps='"${dep}_inline"'
@@ -1604,18 +1631,18 @@ atomics_gcc_if="sync_val_compare_and_swap"
 atomics_suncc_if="atomic_cas_ptr machine_rw_barrier"
 atomics_win32_if="MemoryBarrier"
 atomics_native_if_any="$ATOMICS_LIST"
+w32threads_deps="atomics_native"
 threads_if_any="$THREADS_LIST"
 
 # subsystems
 dct_select="rdft"
 error_resilience_select="dsputil"
-lpc_select="dsputil"
 mdct_select="fft"
 rdft_select="fft"
 mpegaudio_select="mpegaudiodsp"
 mpegaudiodsp_select="dct"
 mpegvideo_select="dsputil hpeldsp videodsp"
-mpegvideoenc_select="mpegvideo"
+mpegvideoenc_select="dsputil mpegvideo"
 
 # decoders / encoders
 aac_decoder_select="mdct sinewin"
@@ -1629,7 +1656,7 @@ alac_encoder_select="lpc"
 als_decoder_select="dsputil"
 amrnb_decoder_select="lsp"
 amrwb_decoder_select="lsp"
-amv_decoder_select="dsputil hpeldsp"
+amv_decoder_select="sp5x_decoder"
 ape_decoder_select="dsputil"
 asv1_decoder_select="dsputil"
 asv1_encoder_select="dsputil"
@@ -1657,11 +1684,11 @@ eac3_decoder_select="ac3_decoder"
 eac3_encoder_select="ac3_encoder"
 eamad_decoder_select="aandcttables dsputil mpegvideo"
 eatgq_decoder_select="aandcttables dsputil"
-eatqi_decoder_select="aandcttables error_resilience mpegvideo"
-ffv1_decoder_select="dsputil golomb rangecoder"
-ffv1_encoder_select="dsputil rangecoder"
-ffvhuff_decoder_select="dsputil"
-ffvhuff_encoder_select="dsputil huffman"
+eatqi_decoder_select="aandcttables dsputil error_resilience mpegvideo"
+ffv1_decoder_select="golomb rangecoder"
+ffv1_encoder_select="rangecoder"
+ffvhuff_decoder_select="huffyuv_decoder"
+ffvhuff_encoder_select="huffyuv_encoder"
 fic_decoder_select="dsputil golomb"
 flac_decoder_select="golomb"
 flac_encoder_select="dsputil golomb lpc"
@@ -1685,11 +1712,11 @@ h264_decoder_suggest="error_resilience"
 hevc_decoder_select="dsputil golomb videodsp"
 huffyuv_decoder_select="dsputil"
 huffyuv_encoder_select="dsputil huffman"
-iac_decoder_select="dsputil fft mdct sinewin"
+iac_decoder_select="imc_decoder"
 imc_decoder_select="dsputil fft mdct sinewin"
 indeo3_decoder_select="hpeldsp"
 interplay_video_decoder_select="hpeldsp"
-jpegls_decoder_select="dsputil golomb hpeldsp"
+jpegls_decoder_select="golomb mjpeg_decoder"
 jpegls_encoder_select="golomb"
 jv_decoder_select="dsputil"
 lagarith_decoder_select="dsputil"
@@ -1699,9 +1726,9 @@ mdec_decoder_select="dsputil error_resilience mpegvideo"
 metasound_decoder_select="lsp mdct sinewin"
 mimic_decoder_select="dsputil hpeldsp"
 mjpeg_decoder_select="dsputil hpeldsp"
-mjpegb_decoder_select="dsputil hpeldsp"
-mjpeg_encoder_select="aandcttables dsputil mpegvideoenc"
-mlp_decoder_select="dsputil mlp_parser"
+mjpeg_encoder_select="aandcttables mpegvideoenc"
+mjpegb_decoder_select="mjpeg_decoder"
+mlp_decoder_select="mlp_parser"
 motionpixels_decoder_select="dsputil"
 mp1_decoder_select="mpegaudio"
 mp1float_decoder_select="mpegaudio"
@@ -1714,7 +1741,7 @@ mp3float_decoder_select="mpegaudio"
 mp3on4_decoder_select="mpegaudio"
 mp3on4float_decoder_select="mpegaudio"
 mpc7_decoder_select="dsputil mpegaudiodsp"
-mpc8_decoder_select="dsputil mpegaudiodsp"
+mpc8_decoder_select="mpegaudiodsp"
 mpeg_xvmc_decoder_deps="X11_extensions_XvMClib_h"
 mpeg_xvmc_decoder_select="mpeg2video_decoder"
 mpeg1video_decoder_select="error_resilience mpegvideo"
@@ -1729,12 +1756,11 @@ msmpeg4v2_encoder_select="h263_encoder"
 msmpeg4v3_decoder_select="h263_decoder"
 msmpeg4v3_encoder_select="h263_encoder"
 mss2_decoder_select="error_resilience vc1_decoder"
-mxpeg_decoder_select="dsputil hpeldsp"
+mxpeg_decoder_select="mjpeg_decoder"
 nellymoser_decoder_select="mdct sinewin"
 nellymoser_encoder_select="audio_frame_queue mdct sinewin"
 nuv_decoder_select="dsputil lzo"
 png_decoder_deps="zlib"
-png_decoder_select="dsputil"
 png_encoder_deps="zlib"
 png_encoder_select="dsputil"
 prores_decoder_select="dsputil"
@@ -1751,16 +1777,16 @@ rv30_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpegvi
 rv40_decoder_select="error_resilience golomb h264chroma h264pred h264qpel mpegvideo videodsp"
 shorten_decoder_select="golomb"
 sipr_decoder_select="lsp"
-sp5x_decoder_select="dsputil hpeldsp"
+sp5x_decoder_select="mjpeg_decoder"
 svq1_decoder_select="hpeldsp"
 svq1_encoder_select="aandcttables dsputil hpeldsp mpegvideoenc"
-svq3_decoder_select="golomb h264chroma h264dsp h264pred h264qpel hpeldsp mpegvideo videodsp"
-svq3_decoder_suggest="error_resilience zlib"
+svq3_decoder_select="h264_decoder hpeldsp mpegvideo"
+svq3_decoder_suggest="zlib"
 tak_decoder_select="dsputil"
 theora_decoder_select="vp3_decoder"
+thp_decoder_select="mjpeg_decoder"
 tiff_decoder_suggest="zlib"
 tiff_encoder_suggest="zlib"
-thp_decoder_select="dsputil hpeldsp"
 truehd_decoder_select="mlp_decoder"
 truemotion2_decoder_select="dsputil"
 truespeech_decoder_select="dsputil"
@@ -1842,7 +1868,7 @@ wmv3_vdpau_hwaccel_select="vc1_vdpau_hwaccel"
 
 # parsers
 h264_parser_select="golomb h264chroma h264dsp h264pred h264qpel videodsp"
-mpeg4video_parser_select="error_resilience mpegvideo"
+mpeg4video_parser_select="error_resilience h263dsp mpegvideo"
 mpegvideo_parser_select="error_resilience mpegvideo"
 vc1_parser_select="mpegvideo"
 
@@ -1974,8 +2000,8 @@ ffrtmpcrypt_protocol_select="tcp_protocol"
 ffrtmphttp_protocol_deps="!librtmp_protocol"
 ffrtmphttp_protocol_select="http_protocol"
 gopher_protocol_select="network"
-httpproxy_protocol_select="tcp_protocol"
 http_protocol_select="tcp_protocol"
+httpproxy_protocol_select="tcp_protocol"
 https_protocol_select="tls_protocol"
 librtmp_protocol_deps="librtmp"
 librtmpe_protocol_deps="librtmp"
@@ -2009,17 +2035,20 @@ boxblur_filter_deps="gpl"
 cropdetect_filter_deps="gpl"
 delogo_filter_deps="gpl"
 drawtext_filter_deps="libfreetype"
-frei0r_filter_deps="frei0r dlopen strtok_r"
+frei0r_filter_deps="frei0r dlopen"
 frei0r_filter_extralibs='$ldl'
-frei0r_src_filter_deps="frei0r dlopen strtok_r"
+frei0r_src_filter_deps="frei0r dlopen"
 frei0r_src_filter_extralibs='$ldl'
 hqdn3d_filter_deps="gpl"
 interlace_filter_deps="gpl"
-resample_filter_deps="avresample"
 ocv_filter_deps="libopencv"
+resample_filter_deps="avresample"
 scale_filter_deps="swscale"
 
 # examples
+avcodec_example_deps="avcodec avutil"
+filter_audio_example_deps="avfilter avutil"
+metadata_example_deps="avformat avutil"
 output_example_deps="avcodec avformat avutil swscale"
 transcode_aac_example_deps="avcodec avformat avresample"
 
@@ -2037,11 +2066,11 @@ avconv_select="aformat_filter anull_filter asyncts_filter atrim_filter format_fi
                fps_filter null_filter resample_filter scale_filter
                setpts_filter trim_filter"
 avplay_deps="avcodec avformat avresample swscale sdl"
+avplay_libs='$sdl_libs'
 avplay_select="rdft"
 avprobe_deps="avcodec avformat"
 avserver_deps="avformat fork !shared"
 avserver_select="ffm_muxer rtp_protocol rtsp_demuxer"
-avserver_extralibs='$ldl'
 
 # documentation
 pod2man_deps="doc"
@@ -2344,6 +2373,11 @@ case "$toolchain" in
         add_cflags  -fsanitize=thread -pie
         add_ldflags -fsanitize=thread -pie
     ;;
+    clang-usan)
+        cc_default="clang"
+        add_cflags  -fsanitize=undefined
+        add_ldflags -fsanitize=undefined
+    ;;
     gcc-asan)
         cc_default="gcc"
         add_cflags  -fsanitize=address
@@ -2354,6 +2388,11 @@ case "$toolchain" in
         add_cflags  -fsanitize=thread -pie -fPIC
         add_ldflags -fsanitize=thread -pie -fPIC
     ;;
+    gcc-usan)
+        cc_default="gcc"
+        add_cflags  -fsanitize=undefined
+        add_ldflags -fsanitize=undefined
+    ;;
     valgrind-massif)
         target_exec_default="valgrind"
         target_exec_args="--alloc-fn=av_malloc --alloc-fn=av_mallocz"
@@ -2398,7 +2437,7 @@ case "$toolchain" in
         add_ldflags -fprofile-arcs -ftest-coverage
     ;;
     hardened)
-        add_cflags -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all
+        add_cflags  -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all
         add_ldflags -Wl,-z,relro -Wl,-z,now
     ;;
     ?*)
@@ -3108,7 +3147,6 @@ elif enabled sparc; then
     case $cpu in
         cypress|f93[04]|tsc701|sparcl*|supersparc|hypersparc|niagara|v[789])
             cpuflags="-mcpu=$cpu"
-            disable vis
         ;;
         ultrasparc*|niagara[234])
             cpuflags="-mcpu=$cpu"
@@ -3199,6 +3237,10 @@ case "$arch" in
         check_64bit ppc ppc64 'sizeof(void *) > 4'
         spic=$shared
     ;;
+    s390)
+        check_64bit s390 s390x 'sizeof(void *) > 4'
+        spic=$shared
+    ;;
     sparc)
         check_64bit sparc sparc64 'sizeof(void *) > 4'
         spic=$shared
@@ -3505,6 +3547,9 @@ if enabled_all ccc libc_glibc; then
     add_ldflags -Wl,-z,now  # calls to libots crash without this
 fi
 
+check_compile_assert flt_lim "float.h limits.h" "DBL_MAX == (double)DBL_MAX" ||
+    add_cppflags '-I\$(SRC_PATH)/compat/float'
+
 esc(){
     echo "$*" | sed 's/%/%25/g;s/:/%3a/g'
 }
@@ -3645,7 +3690,6 @@ EOF
             $ARCH_EXT_LIST_ARM
 
     check_inline_asm asm_mod_q '"add r0, %Q0, %R0" :: "r"((long long)0)'
-    check_inline_asm asm_mod_y '"vmul.i32 d0, d0, %y0" :: "x"(0)'
 
     [ $target_os != win32 ] && enabled_all armv6t2 shared !pic && enable_weak_pic
 
@@ -3691,10 +3735,6 @@ EOF
         enabled altivec || warn "Altivec disabled, possibly missing --cpu flag"
     fi
 
-elif enabled sparc; then
-
-    enabled vis && check_inline_asm vis '"pdist %f0, %f0, %f0"'
-
 elif enabled x86; then
 
     check_builtin rdtsc    intrin.h   "__rdtsc()"
@@ -3742,8 +3782,10 @@ EOF
 
         check_yasm "movbe ecx, [5]" && enable yasm ||
             die "yasm/nasm not found or too old. Use --disable-yasm for a crippled build."
+        check_yasm "vpmacsdd xmm0, xmm1, xmm2, xmm3" || disable xop_external
+        check_yasm "vfmadd132ps ymm0, ymm1, ymm2"    || disable fma3_external
         check_yasm "vfmaddps ymm0, ymm1, ymm2, ymm3" || disable fma4_external
-        check_yasm "CPU amdnop" && enable cpunop
+        check_yasm "CPU amdnop" || disable cpunop
     fi
 
     case "$cpu" in
@@ -3786,6 +3828,7 @@ if ! disabled network; then
     check_type netinet/sctp.h "struct sctp_event_subscribe"
     check_func getaddrinfo $network_extralibs
     check_func getservbyport $network_extralibs
+    check_func inet_aton $network_extralibs
     # Prefer arpa/inet.h over winsock2
     if check_header arpa/inet.h ; then
         check_func closesocket
@@ -3820,9 +3863,9 @@ check_func  getopt
 check_func  getrusage
 check_struct "sys/time.h sys/resource.h" "struct rusage" ru_maxrss
 check_func  gettimeofday
-check_func  inet_aton $network_extralibs
 check_func  isatty
 check_func  localtime_r
+check_func  mach_absolute_time
 check_func  ${malloc_prefix}memalign            && enable memalign
 check_func  mkstemp
 check_func  mmap
@@ -3832,7 +3875,6 @@ check_func_headers malloc.h _aligned_malloc     && enable aligned_malloc
 check_func  setrlimit
 check_func  strerror_r
 check_func  strptime
-check_func  strtok_r
 check_func  sched_getaffinity
 check_builtin sync_val_compare_and_swap "" "int *ptr; int oldval, newval; __sync_val_compare_and_swap(ptr, oldval, newval)"
 check_builtin machine_rw_barrier mbarrier.h "__machine_rw_barrier()"
@@ -3858,6 +3900,7 @@ check_header dlfcn.h
 check_header dxva.h
 check_header dxva2api.h
 check_header io.h
+check_header mach/mach_time.h
 check_header malloc.h
 check_header poll.h
 check_header sys/mman.h
@@ -3897,14 +3940,6 @@ if ! disabled pthreads && ! enabled w32threads; then
     fi
 fi
 
-for thread in $THREADS_LIST; do
-    if enabled $thread; then
-        test -n "$thread_type" &&
-            die "ERROR: Only one thread type must be selected." ||
-            thread_type="$thread"
-    fi
-done
-
 disabled  zlib || check_lib   zlib.h      zlibVersion -lz   || disable  zlib
 disabled bzlib || check_lib2 bzlib.h BZ2_bzlibVersion -lbz2 || disable bzlib
 
@@ -3936,7 +3971,8 @@ enabled libmp3lame        && require "libmp3lame >= 3.98.3" lame/lame.h lame_set
 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         && require_pkg_config opencv opencv/cv.h cvCreateImageHeader
-enabled libopenjpeg       && require libopenjpeg openjpeg.h opj_version -lopenjpeg
+enabled libopenjpeg       && { { check_header openjpeg.h && check_lib2 openjpeg.h opj_version -lopenjpeg; } ||
+                               { require_pkg_config libopenjpeg1 openjpeg.h opj_version; } }
 enabled libopus           && require_pkg_config opus opus_multistream.h opus_multistream_decoder_create
 enabled libpulse          && require_pkg_config libpulse-simple pulse/simple.h pa_simple_new
 enabled librtmp           && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
@@ -3959,8 +3995,8 @@ enabled libx264           && require libx264 x264.h x264_encoder_encode -lx264 &
                              { check_cpp_condition x264.h "X264_BUILD >= 118" ||
                                die "ERROR: libx264 version must be >= 0.118."; }
 enabled libx265           && require_pkg_config x265 x265.h x265_encoder_encode &&
-                             { check_cpp_condition x265.h "X265_BUILD >= 5" ||
-                               die "ERROR: libx265 version must be >= 5."; }
+                             { check_cpp_condition x265.h "X265_BUILD >= 9" ||
+                               die "ERROR: libx265 version must be >= 9."; }
 enabled libxavs           && require libxavs xavs.h xavs_encoder_encode -lxavs
 enabled libxvid           && require libxvid xvid.h xvid_global -lxvidcore
 enabled openssl           && { check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto ||
@@ -4040,7 +4076,8 @@ enabled vdpau &&
     disable vdpau
 
 enabled vdpau && enabled xlib &&
-    check_lib2 "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau &&
+    check_func_headers "vdpau/vdpau.h vdpau/vdpau_x11.h" vdp_device_create_x11 -lvdpau &&
+    prepend avconv_libs $($ldflags_filter "-lvdpau") &&
     enable vdpau_x11
 
 enabled debug && add_cflags -g"$debuglevel" && add_asflags -g"$debuglevel"
@@ -4247,6 +4284,14 @@ check_deps $CONFIG_LIST       \
 ! enabled_any memalign posix_memalign aligned_malloc &&
     enabled_any $need_memalign && enable memalign_hack
 
+for thread in $THREADS_LIST; do
+    if enabled $thread; then
+        test -n "$thread_type" &&
+            die "ERROR: Only one thread type must be selected." ||
+            thread_type="$thread"
+    fi
+done
+
 echo "install prefix            $prefix"
 echo "source path               $source_path"
 echo "C compiler                $cc"
@@ -4273,6 +4318,8 @@ if enabled x86; then
     echo "SSE enabled               ${sse-no}"
     echo "SSSE3 enabled             ${ssse3-no}"
     echo "AVX enabled               ${avx-no}"
+    echo "XOP enabled               ${xop-no}"
+    echo "FMA3 enabled              ${fma3-no}"
     echo "FMA4 enabled              ${fma4-no}"
     echo "i686 features enabled     ${i686-no}"
     echo "CMOV is fast              ${fast_cmov-no}"
@@ -4295,9 +4342,6 @@ if enabled ppc; then
     echo "PPC 4xx optimizations     ${ppc4xx-no}"
     echo "dcbzl available           ${dcbzl-no}"
 fi
-if enabled sparc; then
-    echo "VIS enabled               ${vis-no}"
-fi
 echo "debug symbols             ${debug-no}"
 echo "optimize for size         ${small-no}"
 echo "optimizations             ${optimizations-no}"
@@ -4420,7 +4464,6 @@ HOSTLD_O=$HOSTLD_O
 TARGET_EXEC=$target_exec $target_exec_args
 TARGET_PATH=$target_path
 TARGET_SAMPLES=${target_samples:-\$(SAMPLES)}
-LIBS-avplay=$sdl_libs
 CFLAGS-avplay=$sdl_cflags
 ZLIB=$($ldflags_filter -lz)
 LIB_INSTALL_EXTRA_CMD=$LIB_INSTALL_EXTRA_CMD
@@ -4454,6 +4497,13 @@ get_version(){
 
 map 'get_version $v' $LIBRARY_LIST
 
+print_program_libs(){
+    eval "program_libs=\$${1}_libs"
+    eval echo "LIBS-${1}=${program_libs}" >> config.mak
+}
+
+map 'print_program_libs $v' $PROGRAM_LIST
+
 cat > $TMPH <<EOF
 /* Automatically generated by configure - do not modify! */
 #ifndef LIBAV_CONFIG_H
diff --git a/deps/libav/doc/APIchanges b/deps/libav/doc/APIchanges
index 41c848f..d6134f9 100644
--- a/deps/libav/doc/APIchanges
+++ b/deps/libav/doc/APIchanges
@@ -13,6 +13,23 @@ libavutil:     2013-12-xx
 
 API changes, most recent first:
 
+2014-xx-xx - xxxxxxx - lavu 53.05.0 - frame.h
+  Add av_frame_copy() for copying the frame data.
+
+2014-02-xx - xxxxxxx - lavr 1.2.0 - avresample.h
+  Add avresample_is_open() for checking whether a resample context is open.
+
+2014-xx-xx - xxxxxxx - lavu 53.04.0  - opt.h
+  Add AV_OPT_FLAG_EXPORT and AV_OPT_FLAG_READONLY to mark options meant (only)
+  for reading.
+
+2014-xx-xx - xxxxxxx - lavu 53.03.01 - opt.h
+  Deprecate unused AV_OPT_FLAG_METADATA.
+
+2014-02-xx - xxxxxxx - lavu 53.3.0 - frame.h
+  Add AV_FRAME_DATA_DOWNMIX_INFO value to the AVFrameSideDataType enum and
+  downmix_info.h API, which identify downmix-related metadata.
+
 2014-02-04 - d9ae103 - lavf 55.11.0 - avformat.h
   Add AVFormatContext.max_interleave_delta for controlling amount of buffering
   when interleaving.
@@ -61,7 +78,7 @@ API changes, most recent first:
   Add ITU-R BT.2020 and other not yet included values to color primaries,
   transfer characteristics and colorspaces.
 
-2013-10-31 - 28096e0 - lavu 52.17.0 - avframe.h
+2013-10-31 - 28096e0 - lavu 52.17.0 - frame.h
   Add AVFrame.flags and AV_FRAME_FLAG_CORRUPT.
 
 2013-09-28 - 0767bfd - lavfi 3.11.0 - avfilter.h
diff --git a/deps/libav/doc/Doxyfile b/deps/libav/doc/Doxyfile
index ae65478..58f7dfb 100644
--- a/deps/libav/doc/Doxyfile
+++ b/deps/libav/doc/Doxyfile
@@ -639,8 +639,7 @@ EXCLUDE_SYMBOLS        =
 # directories that contain example code fragments that are included (see
 # the \include command).
 
-EXAMPLE_PATH           = libavcodec/ \
-                         libavformat/
+EXAMPLE_PATH           =
 
 # If the value of the EXAMPLE_PATH tag contains directories, you can use the
 # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp
@@ -794,13 +793,13 @@ HTML_FILE_EXTENSION    = .html
 # each generated HTML page. If it is left blank doxygen will generate a
 # standard header.
 
-HTML_HEADER            = doc/doxy/header.html
+HTML_HEADER            =
 
 # The HTML_FOOTER tag can be used to specify a personal HTML footer for
 # each generated HTML page. If it is left blank doxygen will generate a
 # standard footer.
 
-HTML_FOOTER            = doc/doxy/footer.html
+HTML_FOOTER            =
 
 # The HTML_STYLESHEET tag can be used to specify a user-defined cascading
 # style sheet that is used by each HTML page. It can be used to
@@ -809,7 +808,7 @@ HTML_FOOTER            = doc/doxy/footer.html
 # the style sheet file to the HTML output directory, so don't put your own
 # stylesheet in the HTML output directory as well, or it will be erased!
 
-HTML_STYLESHEET        = doc/doxy/doxy_stylesheet.css
+HTML_STYLESHEET        =
 
 # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output.
 # Doxygen will adjust the colors in the stylesheet and background images
diff --git a/deps/libav/doc/Makefile b/deps/libav/doc/Makefile
index e92e72f..1c205a5 100644
--- a/deps/libav/doc/Makefile
+++ b/deps/libav/doc/Makefile
@@ -15,9 +15,12 @@ DOCS-$(CONFIG_POD2MAN)                          += $(MANPAGES) $(PODPAGES)
 DOCS-$(CONFIG_TEXI2HTML)                        += $(HTMLPAGES)
 DOCS = $(DOCS-yes)
 
+DOC_EXAMPLES-$(CONFIG_AVCODEC_EXAMPLE)          += avcodec
+DOC_EXAMPLES-$(CONFIG_FILTER_AUDIO_EXAMPLE)     += filter_audio
+DOC_EXAMPLES-$(CONFIG_METADATA_EXAMPLE)         += metadata
 DOC_EXAMPLES-$(CONFIG_OUTPUT_EXAMPLE)           += output
 DOC_EXAMPLES-$(CONFIG_TRANSCODE_AAC_EXAMPLE)    += transcode_aac
-ALL_DOC_EXAMPLES = output transcode_aac
+ALL_DOC_EXAMPLES = avcodec filter_audio metadata output transcode_aac
 
 DOC_EXAMPLES     := $(DOC_EXAMPLES-yes:%=doc/examples/%$(EXESUF))
 ALL_DOC_EXAMPLES := $(ALL_DOC_EXAMPLES:%=doc/examples/%$(EXESUF))
@@ -57,11 +60,12 @@ $(DOCS) doc/doxy/html: | doc/
 $(DOC_EXAMPLES:%$(EXESUF)=%.o): | doc/examples
 OBJDIRS += doc/examples
 
+DOXY_INPUT      = $(addprefix $(SRC_PATH)/, $(INSTHEADERS) $(DOC_EXAMPLES:%$(EXESUF)=%.c) $(LIB_EXAMPLES:%$(EXESUF)=%.c))
 DOXY_TEMPLATES  = doxy_stylesheet.css footer.html header.html
 DOXY_TEMPLATES := $(addprefix $(SRC_PATH)/doc/doxy/, $(DOXY_TEMPLATES))
 
-doc/doxy/html: $(SRC_PATH)/doc/Doxyfile $(DOXY_TEMPLATES) $(INSTHEADERS)
-	$(M)$(SRC_PATH)/doc/doxy-wrapper.sh $(SRC_PATH) $^
+doc/doxy/html: $(SRC_PATH)/doc/Doxyfile $(DOXY_INPUT) $(DOXY_TEMPLATES)
+	$(M)$(SRC_PATH)/doc/doxy-wrapper.sh $(SRC_PATH) $< $(DOXY_INPUT)
 
 install-progs-$(CONFIG_POD2MAN): install-man
 install-progs-$(CONFIG_TEXI2HTML): install-doc
diff --git a/deps/libav/doc/avconv.texi b/deps/libav/doc/avconv.texi
index 7ef415f..0c17eb9 100644
--- a/deps/libav/doc/avconv.texi
+++ b/deps/libav/doc/avconv.texi
@@ -821,7 +821,7 @@ avconv -i h264.mp4 -c:v copy -bsf:v h264_mp4toannexb -an out.h264
 avconv -i file.mov -an -vn -bsf:s mov2textsub -c:s copy -f rawvideo sub.txt
 @end example
 
- at item -tag[:@var{stream_specifier}] @var{codec_tag} (@emph{output,per-stream})
+ at item -tag[:@var{stream_specifier}] @var{codec_tag} (@emph{input/output,per-stream})
 Force a tag/fourcc for matching streams.
 
 @item -filter_complex @var{filtergraph} (@emph{global})
diff --git a/deps/libav/doc/avtools-common-opts.texi b/deps/libav/doc/avtools-common-opts.texi
index 156319e..3bf321f 100644
--- a/deps/libav/doc/avtools-common-opts.texi
+++ b/deps/libav/doc/avtools-common-opts.texi
@@ -42,6 +42,8 @@ streams of this type.
 @item p:@var{program_id}[:@var{stream_index}]
 If @var{stream_index} is given, then matches stream number @var{stream_index} in
 program with id @var{program_id}. Otherwise matches all streams in this program.
+ at item i:@var{stream_id}
+Match the stream by stream id (e.g. PID in MPEG-TS container).
 @end table
 @section Generic options
 
diff --git a/deps/libav/doc/doxy-wrapper.sh b/deps/libav/doc/doxy-wrapper.sh
index 6650e38..d38dd0b 100755
--- a/deps/libav/doc/doxy-wrapper.sh
+++ b/deps/libav/doc/doxy-wrapper.sh
@@ -8,6 +8,7 @@ shift 2
 doxygen - <<EOF
 @INCLUDE        = ${DOXYFILE}
 INPUT           = $@
+EXAMPLE_PATH    = ${SRC_PATH}/doc/examples
 HTML_HEADER     = ${SRC_PATH}/doc/doxy/header.html
 HTML_FOOTER     = ${SRC_PATH}/doc/doxy/footer.html
 HTML_STYLESHEET = ${SRC_PATH}/doc/doxy/doxy_stylesheet.css
diff --git a/deps/libav/libavcodec/api-example.c b/deps/libav/doc/examples/avcodec.c
similarity index 99%
rename from deps/libav/libavcodec/api-example.c
rename to deps/libav/doc/examples/avcodec.c
index 6abbddc..1478881 100644
--- a/deps/libav/libavcodec/api-example.c
+++ b/deps/libav/doc/examples/avcodec.c
@@ -22,7 +22,7 @@
  * @file
  * libavcodec API use example.
  *
- * @example libavcodec/api-example.c
+ * @example avcodec.c
  * Note that this library only handles codecs (mpeg, mpeg4, etc...),
  * not file formats (avi, vob, etc...). See library 'libavformat' for the
  * format handling
diff --git a/deps/libav/doc/examples/filter_audio.c b/deps/libav/doc/examples/filter_audio.c
new file mode 100644
index 0000000..71f985e
--- /dev/null
+++ b/deps/libav/doc/examples/filter_audio.c
@@ -0,0 +1,364 @@
+/*
+ * copyright (c) 2013 Andrew Kelley
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * libavfilter API usage example.
+ *
+ * @example filter_audio.c
+ * This example will generate a sine wave audio,
+ * pass it through a simple filter chain, and then compute the MD5 checksum of
+ * the output data.
+ *
+ * The filter chain it uses is:
+ * (input) -> abuffer -> volume -> aformat -> abuffersink -> (output)
+ *
+ * abuffer: This provides the endpoint where you can feed the decoded samples.
+ * volume: In this example we hardcode it to 0.90.
+ * aformat: This converts the samples to the samplefreq, channel layout,
+ *          and sample format required by the audio device.
+ * abuffersink: This provides the endpoint where you can read the samples after
+ *              they have passed through the filter chain.
+ */
+
+#include <inttypes.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "libavutil/channel_layout.h"
+#include "libavutil/md5.h"
+#include "libavutil/opt.h"
+#include "libavutil/samplefmt.h"
+
+#include "libavfilter/avfilter.h"
+#include "libavfilter/buffersink.h"
+#include "libavfilter/buffersrc.h"
+
+#define INPUT_SAMPLERATE     48000
+#define INPUT_FORMAT         AV_SAMPLE_FMT_FLTP
+#define INPUT_CHANNEL_LAYOUT AV_CH_LAYOUT_5POINT0
+
+#define VOLUME_VAL 0.90
+
+static int init_filter_graph(AVFilterGraph **graph, AVFilterContext **src,
+                             AVFilterContext **sink)
+{
+    AVFilterGraph *filter_graph;
+    AVFilterContext *abuffer_ctx;
+    AVFilter        *abuffer;
+    AVFilterContext *volume_ctx;
+    AVFilter        *volume;
+    AVFilterContext *aformat_ctx;
+    AVFilter        *aformat;
+    AVFilterContext *abuffersink_ctx;
+    AVFilter        *abuffersink;
+
+    AVDictionary *options_dict = NULL;
+    uint8_t options_str[1024];
+    uint8_t ch_layout[64];
+
+    int err;
+
+    /* Create a new filtergraph, which will contain all the filters. */
+    filter_graph = avfilter_graph_alloc();
+    if (!filter_graph) {
+        fprintf(stderr, "Unable to create filter graph.\n");
+        return AVERROR(ENOMEM);
+    }
+
+    /* Create the abuffer filter;
+     * it will be used for feeding the data into the graph. */
+    abuffer = avfilter_get_by_name("abuffer");
+    if (!abuffer) {
+        fprintf(stderr, "Could not find the abuffer filter.\n");
+        return AVERROR_FILTER_NOT_FOUND;
+    }
+
+    abuffer_ctx = avfilter_graph_alloc_filter(filter_graph, abuffer, "src");
+    if (!abuffer_ctx) {
+        fprintf(stderr, "Could not allocate the abuffer instance.\n");
+        return AVERROR(ENOMEM);
+    }
+
+    /* Set the filter options through the AVOptions API. */
+    av_get_channel_layout_string(ch_layout, sizeof(ch_layout), 0, INPUT_CHANNEL_LAYOUT);
+    av_opt_set    (abuffer_ctx, "channel_layout", ch_layout,                            AV_OPT_SEARCH_CHILDREN);
+    av_opt_set    (abuffer_ctx, "sample_fmt",     av_get_sample_fmt_name(INPUT_FORMAT), AV_OPT_SEARCH_CHILDREN);
+    av_opt_set_q  (abuffer_ctx, "time_base",      (AVRational){ 1, INPUT_SAMPLERATE },  AV_OPT_SEARCH_CHILDREN);
+    av_opt_set_int(abuffer_ctx, "sample_rate",    INPUT_SAMPLERATE,                     AV_OPT_SEARCH_CHILDREN);
+
+    /* Now initialize the filter; we pass NULL options, since we have already
+     * set all the options above. */
+    err = avfilter_init_str(abuffer_ctx, NULL);
+    if (err < 0) {
+        fprintf(stderr, "Could not initialize the abuffer filter.\n");
+        return err;
+    }
+
+    /* Create volume filter. */
+    volume = avfilter_get_by_name("volume");
+    if (!volume) {
+        fprintf(stderr, "Could not find the volume filter.\n");
+        return AVERROR_FILTER_NOT_FOUND;
+    }
+
+    volume_ctx = avfilter_graph_alloc_filter(filter_graph, volume, "volume");
+    if (!volume_ctx) {
+        fprintf(stderr, "Could not allocate the volume instance.\n");
+        return AVERROR(ENOMEM);
+    }
+
+    /* A different way of passing the options is as key/value pairs in a
+     * dictionary. */
+    av_dict_set(&options_dict, "volume", AV_STRINGIFY(VOLUME_VAL), 0);
+    err = avfilter_init_dict(volume_ctx, &options_dict);
+    av_dict_free(&options_dict);
+    if (err < 0) {
+        fprintf(stderr, "Could not initialize the volume filter.\n");
+        return err;
+    }
+
+    /* Create the aformat filter;
+     * it ensures that the output is of the format we want. */
+    aformat = avfilter_get_by_name("aformat");
+    if (!aformat) {
+        fprintf(stderr, "Could not find the aformat filter.\n");
+        return AVERROR_FILTER_NOT_FOUND;
+    }
+
+    aformat_ctx = avfilter_graph_alloc_filter(filter_graph, aformat, "aformat");
+    if (!aformat_ctx) {
+        fprintf(stderr, "Could not allocate the aformat instance.\n");
+        return AVERROR(ENOMEM);
+    }
+
+    /* A third way of passing the options is in a string of the form
+     * key1=value1:key2=value2.... */
+    snprintf(options_str, sizeof(options_str),
+             "sample_fmts=%s:sample_rates=%d:channel_layouts=0x%"PRIx64,
+             av_get_sample_fmt_name(AV_SAMPLE_FMT_S16), 44100,
+             (uint64_t)AV_CH_LAYOUT_STEREO);
+    err = avfilter_init_str(aformat_ctx, options_str);
+    if (err < 0) {
+        av_log(NULL, AV_LOG_ERROR, "Could not initialize the aformat filter.\n");
+        return err;
+    }
+
+    /* Finally create the abuffersink filter;
+     * it will be used to get the filtered data out of the graph. */
+    abuffersink = avfilter_get_by_name("abuffersink");
+    if (!abuffersink) {
+        fprintf(stderr, "Could not find the abuffersink filter.\n");
+        return AVERROR_FILTER_NOT_FOUND;
+    }
+
+    abuffersink_ctx = avfilter_graph_alloc_filter(filter_graph, abuffersink, "sink");
+    if (!abuffersink_ctx) {
+        fprintf(stderr, "Could not allocate the abuffersink instance.\n");
+        return AVERROR(ENOMEM);
+    }
+
+    /* This filter takes no options. */
+    err = avfilter_init_str(abuffersink_ctx, NULL);
+    if (err < 0) {
+        fprintf(stderr, "Could not initialize the abuffersink instance.\n");
+        return err;
+    }
+
+    /* Connect the filters;
+     * in this simple case the filters just form a linear chain. */
+    err = avfilter_link(abuffer_ctx, 0, volume_ctx, 0);
+    if (err >= 0)
+        err = avfilter_link(volume_ctx, 0, aformat_ctx, 0);
+    if (err >= 0)
+        err = avfilter_link(aformat_ctx, 0, abuffersink_ctx, 0);
+    if (err < 0) {
+        fprintf(stderr, "Error connecting filters\n");
+        return err;
+    }
+
+    /* Configure the graph. */
+    err = avfilter_graph_config(filter_graph, NULL);
+    if (err < 0) {
+        av_log(NULL, AV_LOG_ERROR, "Error configuring the filter graph\n");
+        return err;
+    }
+
+    *graph = filter_graph;
+    *src   = abuffer_ctx;
+    *sink  = abuffersink_ctx;
+
+    return 0;
+}
+
+/* Do something useful with the filtered data: this simple
+ * example just prints the MD5 checksum of each plane to stdout. */
+static int process_output(struct AVMD5 *md5, AVFrame *frame)
+{
+    int planar     = av_sample_fmt_is_planar(frame->format);
+    int channels   = av_get_channel_layout_nb_channels(frame->channel_layout);
+    int planes     = planar ? channels : 1;
+    int bps        = av_get_bytes_per_sample(frame->format);
+    int plane_size = bps * frame->nb_samples * (planar ? 1 : channels);
+    int i, j;
+
+    for (i = 0; i < planes; i++) {
+        uint8_t checksum[16];
+
+        av_md5_init(md5);
+        av_md5_sum(checksum, frame->extended_data[i], plane_size);
+
+        fprintf(stdout, "plane %d: 0x", i);
+        for (j = 0; j < sizeof(checksum); j++)
+            fprintf(stdout, "%02X", checksum[j]);
+        fprintf(stdout, "\n");
+    }
+    fprintf(stdout, "\n");
+
+    return 0;
+}
+
+/* Construct a frame of audio data to be filtered;
+ * this simple example just synthesizes a sine wave. */
+static int get_input(AVFrame *frame, int frame_num)
+{
+    int err, i, j;
+
+#define FRAME_SIZE 1024
+
+    /* Set up the frame properties and allocate the buffer for the data. */
+    frame->sample_rate    = INPUT_SAMPLERATE;
+    frame->format         = INPUT_FORMAT;
+    frame->channel_layout = INPUT_CHANNEL_LAYOUT;
+    frame->nb_samples     = FRAME_SIZE;
+    frame->pts            = frame_num * FRAME_SIZE;
+
+    err = av_frame_get_buffer(frame, 0);
+    if (err < 0)
+        return err;
+
+    /* Fill the data for each channel. */
+    for (i = 0; i < 5; i++) {
+        float *data = (float*)frame->extended_data[i];
+
+        for (j = 0; j < frame->nb_samples; j++)
+            data[j] = sin(2 * M_PI * (frame_num + j) * (i + 1) / FRAME_SIZE);
+    }
+
+    return 0;
+}
+
+int main(int argc, char *argv[])
+{
+    struct AVMD5 *md5;
+    AVFilterGraph *graph;
+    AVFilterContext *src, *sink;
+    AVFrame *frame;
+    uint8_t errstr[1024];
+    float duration;
+    int err, nb_frames, i;
+
+    if (argc < 2) {
+        fprintf(stderr, "Usage: %s <duration>\n", argv[0]);
+        return 1;
+    }
+
+    duration  = atof(argv[1]);
+    nb_frames = duration * INPUT_SAMPLERATE / FRAME_SIZE;
+    if (nb_frames <= 0) {
+        fprintf(stderr, "Invalid duration: %s\n", argv[1]);
+        return 1;
+    }
+
+    avfilter_register_all();
+
+    /* Allocate the frame we will be using to store the data. */
+    frame  = av_frame_alloc();
+    if (!frame) {
+        fprintf(stderr, "Error allocating the frame\n");
+        return 1;
+    }
+
+    md5 = av_md5_alloc();
+    if (!md5) {
+        fprintf(stderr, "Error allocating the MD5 context\n");
+        return 1;
+    }
+
+    /* Set up the filtergraph. */
+    err = init_filter_graph(&graph, &src, &sink);
+    if (err < 0) {
+        fprintf(stderr, "Unable to init filter graph:");
+        goto fail;
+    }
+
+    /* the main filtering loop */
+    for (i = 0; i < nb_frames; i++) {
+        /* get an input frame to be filtered */
+        err = get_input(frame, i);
+        if (err < 0) {
+            fprintf(stderr, "Error generating input frame:");
+            goto fail;
+        }
+
+        /* Send the frame to the input of the filtergraph. */
+        err = av_buffersrc_add_frame(src, frame);
+        if (err < 0) {
+            av_frame_unref(frame);
+            fprintf(stderr, "Error submitting the frame to the filtergraph:");
+            goto fail;
+        }
+
+        /* Get all the filtered output that is available. */
+        while ((err = av_buffersink_get_frame(sink, frame)) >= 0) {
+            /* now do something with our filtered frame */
+            err = process_output(md5, frame);
+            if (err < 0) {
+                fprintf(stderr, "Error processing the filtered frame:");
+                goto fail;
+            }
+            av_frame_unref(frame);
+        }
+
+        if (err == AVERROR(EAGAIN)) {
+            /* Need to feed more frames in. */
+            continue;
+        } else if (err == AVERROR_EOF) {
+            /* Nothing more to do, finish. */
+            break;
+        } else if (err < 0) {
+            /* An error occurred. */
+            fprintf(stderr, "Error filtering the data:");
+            goto fail;
+        }
+    }
+
+    avfilter_graph_free(&graph);
+    av_frame_free(&frame);
+    av_freep(&md5);
+
+    return 0;
+
+fail:
+    av_strerror(err, errstr, sizeof(errstr));
+    fprintf(stderr, "%s\n", errstr);
+    return 1;
+}
diff --git a/deps/libav/libavformat/metadata-example.c b/deps/libav/doc/examples/metadata.c
similarity index 97%
rename from deps/libav/libavformat/metadata-example.c
rename to deps/libav/doc/examples/metadata.c
index 7bf77e7..f4c6eee 100644
--- a/deps/libav/libavformat/metadata-example.c
+++ b/deps/libav/doc/examples/metadata.c
@@ -22,7 +22,7 @@
 
 /**
  * @file
- * @example libavformat/metadata-example.c
+ * @example metadata.c
  * Shows how the metadata API can be used in application programs.
  */
 
diff --git a/deps/libav/doc/examples/output.c b/deps/libav/doc/examples/output.c
index 06fdf50..dd0e6a2 100644
--- a/deps/libav/doc/examples/output.c
+++ b/deps/libav/doc/examples/output.c
@@ -24,9 +24,9 @@
  * @file
  * libavformat API example.
  *
- * @example doc/examples/output.c
- * Output a media file in any supported libavformat format.
- * The default codecs are used.
+ * @example output.c
+ * Output a media file in any supported libavformat format. The default
+ * codecs are used.
  */
 
 #include <stdlib.h>
diff --git a/deps/libav/doc/examples/transcode_aac.c b/deps/libav/doc/examples/transcode_aac.c
index 46f61d8..6206afe 100644
--- a/deps/libav/doc/examples/transcode_aac.c
+++ b/deps/libav/doc/examples/transcode_aac.c
@@ -17,7 +17,10 @@
  */
 
 /**
- * @file simple audio converter
+ * @file
+ * simple audio converter
+ *
+ * @example transcode_aac.c
  * Convert an input audio file to AAC in an MP4 container using Libav.
  * @author Andreas Unterweger (dustsigns at gmail.com)
  */
diff --git a/deps/libav/doc/filters.texi b/deps/libav/doc/filters.texi
index 8c83b4e..8d46cd1 100644
--- a/deps/libav/doc/filters.texi
+++ b/deps/libav/doc/filters.texi
@@ -467,6 +467,79 @@ To fix a 5.1 WAV improperly encoded in AAC's native channel order
 avconv -i in.wav -filter 'channelmap=1|2|0|5|3|4:channel_layout=5.1' out.wav
 @end example
 
+ at section compand
+Compress or expand audio dynamic range.
+
+A description of the accepted options follows.
+
+ at table @option
+
+ at item attacks
+ at item decays
+Set list of times in seconds for each channel over which the instantaneous level
+of the input signal is averaged to determine its volume. @var{attacks} refers to
+increase of volume and @var{decays} refers to decrease of volume. For most
+situations, the attack time (response to the audio getting louder) should be
+shorter than the decay time because the human ear is more sensitive to sudden
+loud audio than sudden soft audio. A typical value for attack is 0.3 seconds and
+a typical value for decay is 0.8 seconds.
+
+ at item points
+Set list of points for the transfer function, specified in dB relative to the
+maximum possible signal amplitude. Each key points list must be defined using
+the following syntax: @code{x0/y0|x1/y1|x2/y2|....}
+
+The input values must be in strictly increasing order but the transfer function
+does not have to be monotonically rising. The point @code{0/0} is assumed but
+may be overridden (by @code{0/out-dBn}). Typical values for the transfer
+function are @code{-70/-70|-60/-20}.
+
+ at item soft-knee
+Set the curve radius in dB for all joints. Defaults to 0.01.
+
+ at item gain
+Set additional gain in dB to be applied at all points on the transfer function.
+This allows easy adjustment of the overall gain. Defaults to 0.
+
+ at item volume
+Set initial volume in dB to be assumed for each channel when filtering starts.
+This permits the user to supply a nominal level initially, so that, for
+example, a very large gain is not applied to initial signal levels before the
+companding has begun to operate. A typical value for audio which is initially
+quiet is -90 dB. Defaults to 0.
+
+ at item delay
+Set delay in seconds. The input audio is analyzed immediately, but audio is
+delayed before being fed to the volume adjuster. Specifying a delay
+approximately equal to the attack/decay times allows the filter to effectively
+operate in predictive rather than reactive mode. Defaults to 0.
+
+ at end table
+
+ at subsection Examples
+
+ at itemize
+ at item
+Make music with both quiet and loud passages suitable for listening in a noisy
+environment:
+ at example
+compand=.3|.3:1|1:-90/-60|-60/-40|-40/-30|-20/-20:6:0:-90:0.2
+ at end example
+
+ at item
+Noise gate for when the noise is at a lower level than the signal:
+ at example
+compand=.1|.1:.2|.2:-900/-900|-50.1/-900|-50/-50:.01:0:-90:.1
+ at end example
+
+ at item
+Here is another noise gate, this time for when the noise is at a higher level
+than the signal (making it, in some ways, similar to squelch):
+ at example
+compand=.1|.1:.1|.1:-45.1/-45.1|-45/-900|0/-900:.01:45:-90:.1
+ at end example
+ at end itemize
+
 @section join
 Join multiple input streams into one multi-channel stream.
 
@@ -1426,7 +1499,8 @@ a float number which specifies chroma temporal strength, defaults to
 
 Simple interlacing filter from progressive contents. This interleaves upper (or
 lower) lines from odd frames with lower (or upper) lines from even frames,
-halving the frame rate and preserving image height.
+halving the frame rate and preserving image height. A vertical lowpass filter
+is always applied in order to avoid twitter effects and reduce moiré patterns.
 
 @example
    Original        Original             New Frame
@@ -1446,10 +1520,6 @@ It accepts the following optional parameters:
 @item scan
 determines whether the interlaced frame is taken from the even (tff - default)
 or odd (bff) lines of the progressive frame.
-
- at item lowpass
-Enable (default) or disable the vertical lowpass filter to avoid twitter
-interlacing and reduce moire patterns.
 @end table
 
 @section lut, lutrgb, lutyuv
@@ -2383,6 +2453,36 @@ Adler-32 checksum of each plane of the input frame, expressed in the form
 "[@var{c0} @var{c1} @var{c2} @var{c3}]"
 @end table
 
+ at section shuffleplanes
+
+Reorder and/or duplicate video planes.
+
+This filter accepts the following options:
+
+ at table @option
+
+ at item map0
+The index of the input plane to be used as the first output plane.
+
+ at item map1
+The index of the input plane to be used as the second output plane.
+
+ at item map2
+The index of the input plane to be used as the third output plane.
+
+ at item map3
+The index of the input plane to be used as the fourth output plane.
+
+ at end table
+
+The first plane has the index 0. The default is to keep the input unchanged.
+
+E.g.
+ at example
+avconv -i INPUT -vf shuffleplanes=0:2:1:3 OUTPUT
+ at end example
+swaps the second and third planes of the input.
+
 @section split
 
 Split input video into several identical outputs.
diff --git a/deps/libav/doc/general.texi b/deps/libav/doc/general.texi
index bb2fcf3..8c0cb1b 100644
--- a/deps/libav/doc/general.texi
+++ b/deps/libav/doc/general.texi
@@ -112,7 +112,7 @@ to enable it.
 @float note
 x265 is under the GNU Public License Version 2 or later
 (see @url{http://www.gnu.org/licenses/old-licenses/gpl-2.0.html} for
-details), you must upgrade FFmpeg's license to GPL in order to use it.
+details), you must upgrade Libav's license to GPL in order to use it.
 @end float
 
 @section libilbc
@@ -126,7 +126,39 @@ Go to @url{https://github.com/dekkers/libilbc} and follow the instructions for
 installing the library. Then pass @code{--enable-libilbc} to configure to
 enable it.
 
+ at section AviSynth
+
+Libav can read AviSynth scripts as input. To enable support you need a
+suitable @file{avisynth_c.h} header to compile against. The header in
+classic AviSynth's CVS repository is not compatible as it has not been
+updated to support AviSynth 2.6. AviSynth 2.5 is not supported by Libav.
+Once you have the appropriate header, pass @code{--enable-avisynth} to
+configure to enable AviSynth support.
+
+For Windows, supported AviSynth variants are
+ at url{http://avisynth.nl, AviSynth 2.6} for 32-bit builds and
+ at url{http://avs-plus.net, AviSynth+ 0.1} for 32-bit and 64-bit builds.
+The necessary @file{avisynth_c.h} header is the variant in the @file{extras/}
+directory of the @url{https://www.videolan.org/developers/x264.html, x264}
+source tree. For convenience, this header is also available from a
+ at url{https://github.com/qyot27/avisynth_headers, temporary repository}
+along with an installation routine.
+
+For Linux and OS X, the supported AviSynth variant is
+ at url{https://github.com/avxsynth/avxsynth, AvxSynth}.
+ at file{avxsynth_c.h} is installed as part of the normal
+build routine, as illustrated on
+ at url{https://github.com/avxsynth/avxsynth/wiki/System-Setup, AvxSynth's wiki}.
+(the instructions for compiling its prerequisites are outdated, as FFMS 2.18
+or higher is now needed; the list of dependencies to be downloaded from the
+repositories is still the same, though).
 
+ at float NOTE
+AviSynth and AvxSynth are loaded dynamically.  Distributors can build Libav
+with @code{--enable-avisynth}, and the binaries will work regardless of the
+end user having AviSynth or AvxSynth installed - they'll only need to be
+installed to use AviSynth scripts (obviously).
+ at end float
 
 @chapter Supported File Formats and Codecs
 
diff --git a/deps/libav/doc/muxers.texi b/deps/libav/doc/muxers.texi
index cf312c1..143e595 100644
--- a/deps/libav/doc/muxers.texi
+++ b/deps/libav/doc/muxers.texi
@@ -179,7 +179,91 @@ images.
 
 @end table
 
- at section MOV/MP4/ISMV
+ at section matroska
+
+Matroska container muxer.
+
+This muxer implements the matroska and webm container specs.
+
+The recognized metadata settings in this muxer are:
+
+ at table @option
+
+ at item title=@var{title name}
+Name provided to a single track
+ at end table
+
+ at table @option
+
+ at item language=@var{language name}
+Specifies the language of the track in the Matroska languages form
+ at end table
+
+ at table @option
+
+ at item STEREO_MODE=@var{mode}
+Stereo 3D video layout of two views in a single video track
+ at table @option
+ at item mono
+video is not stereo
+ at item left_right
+Both views are arranged side by side, Left-eye view is on the left
+ at item bottom_top
+Both views are arranged in top-bottom orientation, Left-eye view is at bottom
+ at item top_bottom
+Both views are arranged in top-bottom orientation, Left-eye view is on top
+ at item checkerboard_rl
+Each view is arranged in a checkerboard interleaved pattern, Left-eye view being first
+ at item checkerboard_lr
+Each view is arranged in a checkerboard interleaved pattern, Right-eye view being first
+ at item row_interleaved_rl
+Each view is constituted by a row based interleaving, Right-eye view is first row
+ at item row_interleaved_lr
+Each view is constituted by a row based interleaving, Left-eye view is first row
+ at item col_interleaved_rl
+Both views are arranged in a column based interleaving manner, Right-eye view is first column
+ at item col_interleaved_lr
+Both views are arranged in a column based interleaving manner, Left-eye view is first column
+ at item anaglyph_cyan_red
+All frames are in anaglyph format viewable through red-cyan filters
+ at item right_left
+Both views are arranged side by side, Right-eye view is on the left
+ at item anaglyph_green_magenta
+All frames are in anaglyph format viewable through green-magenta filters
+ at item block_lr
+Both eyes laced in one Block, Left-eye view is first
+ at item block_rl
+Both eyes laced in one Block, Right-eye view is first
+ at end table
+ at end table
+
+For example a 3D WebM clip can be created using the following command line:
+ at example
+avconv -i sample_left_right_clip.mpg -an -c:v libvpx -metadata STEREO_MODE=left_right -y stereo_clip.webm
+ at end example
+
+This muxer supports the following options:
+
+ at table @option
+
+ at item reserve_index_space
+By default, this muxer writes the index for seeking (called cues in Matroska
+terms) at the end of the file, because it cannot know in advance how much space
+to leave for the index at the beginning of the file. However for some use cases
+-- e.g.  streaming where seeking is possible but slow -- it is useful to put the
+index at the beginning of the file.
+
+If this option is set to a non-zero value, the muxer will reserve a given amount
+of space in the file header and then try to write the cues there when the muxing
+finishes. If the available space does not suffice, muxing will fail. A safe size
+for most use cases should be about 50kB per hour of video.
+
+Note that cues are only written if the output is seekable and this option will
+have no effect if it is not.
+
+ at end table
+
+ at section mov, mp4, ismv
 
 The mov/mp4/ismv muxer supports fragmentation. Normally, a MOV/MP4
 file has all the metadata about all packets stored in one location
@@ -251,6 +335,49 @@ point on IIS with this muxer. Example:
 avconv -re @var{<normal input/transcoding options>} -movflags isml+frag_keyframe -f ismv http://server/publishingpoint.isml/Streams(Encoder1)
 @end example
 
+ at section mp3
+
+The MP3 muxer writes a raw MP3 stream with an ID3v2 header at the beginning and
+optionally an ID3v1 tag at the end. ID3v2.3 and ID3v2.4 are supported, the
+ at code{id3v2_version} option controls which one is used. Setting
+ at code{id3v2_version} to 0 will disable the ID3v2 header completely. The legacy
+ID3v1 tag is not written by default, but may be enabled with the
+ at code{write_id3v1} option.
+
+The muxer may also write a Xing frame at the beginning, which contains the
+number of frames in the file. It is useful for computing duration of VBR files.
+The Xing frame is written if the output stream is seekable and if the
+ at code{write_xing} option is set to 1 (the default).
+
+The muxer supports writing ID3v2 attached pictures (APIC frames). The pictures
+are supplied to the muxer in form of a video stream with a single packet. There
+can be any number of those streams, each will correspond to a single APIC frame.
+The stream metadata tags @var{title} and @var{comment} map to APIC
+ at var{description} and @var{picture type} respectively. See
+ at url{http://id3.org/id3v2.4.0-frames} for allowed picture types.
+
+Note that the APIC frames must be written at the beginning, so the muxer will
+buffer the audio frames until it gets all the pictures. It is therefore advised
+to provide the pictures as soon as possible to avoid excessive buffering.
+
+Examples:
+
+Write an mp3 with an ID3v2.3 header and an ID3v1 footer:
+ at example
+avconv -i INPUT -id3v2_version 3 -write_id3v1 1 out.mp3
+ at end example
+
+Attach a picture to an mp3:
+ at example
+avconv -i input.mp3 -i cover.png -c copy -metadata:s:v title="Album cover"
+-metadata:s:v comment="Cover (Front)" out.mp3
+ at end example
+
+Write a "clean" MP3 without any extra features:
+ at example
+avconv -i input.wav -write_xing 0 -id3v2_version 0 out.mp3
+ at end example
+
 @section mpegts
 
 MPEG transport stream muxer.
@@ -314,88 +441,19 @@ Alternatively you can write the command as:
 avconv -benchmark -i INPUT -f null -
 @end example
 
- at section matroska
-
-Matroska container muxer.
-
-This muxer implements the matroska and webm container specs.
-
-The recognized metadata settings in this muxer are:
-
- at table @option
-
- at item title=@var{title name}
-Name provided to a single track
- at end table
-
- at table @option
-
- at item language=@var{language name}
-Specifies the language of the track in the Matroska languages form
- at end table
-
- at table @option
-
- at item STEREO_MODE=@var{mode}
-Stereo 3D video layout of two views in a single video track
- at table @option
- at item mono
-video is not stereo
- at item left_right
-Both views are arranged side by side, Left-eye view is on the left
- at item bottom_top
-Both views are arranged in top-bottom orientation, Left-eye view is at bottom
- at item top_bottom
-Both views are arranged in top-bottom orientation, Left-eye view is on top
- at item checkerboard_rl
-Each view is arranged in a checkerboard interleaved pattern, Left-eye view being first
- at item checkerboard_lr
-Each view is arranged in a checkerboard interleaved pattern, Right-eye view being first
- at item row_interleaved_rl
-Each view is constituted by a row based interleaving, Right-eye view is first row
- at item row_interleaved_lr
-Each view is constituted by a row based interleaving, Left-eye view is first row
- at item col_interleaved_rl
-Both views are arranged in a column based interleaving manner, Right-eye view is first column
- at item col_interleaved_lr
-Both views are arranged in a column based interleaving manner, Left-eye view is first column
- at item anaglyph_cyan_red
-All frames are in anaglyph format viewable through red-cyan filters
- at item right_left
-Both views are arranged side by side, Right-eye view is on the left
- at item anaglyph_green_magenta
-All frames are in anaglyph format viewable through green-magenta filters
- at item block_lr
-Both eyes laced in one Block, Left-eye view is first
- at item block_rl
-Both eyes laced in one Block, Right-eye view is first
- at end table
- at end table
-
-For example a 3D WebM clip can be created using the following command line:
- at example
-avconv -i sample_left_right_clip.mpg -an -c:v libvpx -metadata STEREO_MODE=left_right -y stereo_clip.webm
- at end example
+ at section ogg
 
-This muxer supports the following options:
+Ogg container muxer.
 
 @table @option
-
- at item reserve_index_space
-By default, this muxer writes the index for seeking (called cues in Matroska
-terms) at the end of the file, because it cannot know in advance how much space
-to leave for the index at the beginning of the file. However for some use cases
--- e.g.  streaming where seeking is possible but slow -- it is useful to put the
-index at the beginning of the file.
-
-If this option is set to a non-zero value, the muxer will reserve a given amount
-of space in the file header and then try to write the cues there when the muxing
-finishes. If the available space does not suffice, muxing will fail. A safe size
-for most use cases should be about 50kB per hour of video.
-
-Note that cues are only written if the output is seekable and this option will
-have no effect if it is not.
-
+ at item -page_duration @var{duration}
+Preferred page duration, in microseconds. The muxer will attempt to create
+pages that are approximately @var{duration} microseconds long. This allows the
+user to compromise between seek granularity and container overhead. The default
+is 1 second. A value of 0 will fill all segments, making pages as large as
+possible. A value of 1 will effectively use 1 packet-per-page in most
+situations, giving a small seek granularity at the cost of additional container
+overhead.
 @end table
 
 @section segment
@@ -430,62 +488,4 @@ Wrap around segment index once it reaches @var{limit}.
 avconv -i in.mkv -c copy -map 0 -f segment -list out.list out%03d.nut
 @end example
 
- at section mp3
-
-The MP3 muxer writes a raw MP3 stream with an ID3v2 header at the beginning and
-optionally an ID3v1 tag at the end. ID3v2.3 and ID3v2.4 are supported, the
- at code{id3v2_version} option controls which one is used. Setting
- at code{id3v2_version} to 0 will disable the ID3v2 header completely. The legacy
-ID3v1 tag is not written by default, but may be enabled with the
- at code{write_id3v1} option.
-
-The muxer may also write a Xing frame at the beginning, which contains the
-number of frames in the file. It is useful for computing duration of VBR files.
-The Xing frame is written if the output stream is seekable and if the
- at code{write_xing} option is set to 1 (the default).
-
-The muxer supports writing ID3v2 attached pictures (APIC frames). The pictures
-are supplied to the muxer in form of a video stream with a single packet. There
-can be any number of those streams, each will correspond to a single APIC frame.
-The stream metadata tags @var{title} and @var{comment} map to APIC
- at var{description} and @var{picture type} respectively. See
- at url{http://id3.org/id3v2.4.0-frames} for allowed picture types.
-
-Note that the APIC frames must be written at the beginning, so the muxer will
-buffer the audio frames until it gets all the pictures. It is therefore advised
-to provide the pictures as soon as possible to avoid excessive buffering.
-
-Examples:
-
-Write an mp3 with an ID3v2.3 header and an ID3v1 footer:
- at example
-avconv -i INPUT -id3v2_version 3 -write_id3v1 1 out.mp3
- at end example
-
-Attach a picture to an mp3:
- at example
-avconv -i input.mp3 -i cover.png -c copy -metadata:s:v title="Album cover"
--metadata:s:v comment="Cover (Front)" out.mp3
- at end example
-
-Write a "clean" MP3 without any extra features:
- at example
-avconv -i input.wav -write_xing 0 -id3v2_version 0 out.mp3
- at end example
-
- at section ogg
-
-Ogg container muxer.
-
- at table @option
- at item -page_duration @var{duration}
-Preferred page duration, in microseconds. The muxer will attempt to create
-pages that are approximately @var{duration} microseconds long. This allows the
-user to compromise between seek granularity and container overhead. The default
-is 1 second. A value of 0 will fill all segments, making pages as large as
-possible. A value of 1 will effectively use 1 packet-per-page in most
-situations, giving a small seek granularity at the cost of additional container
-overhead.
- at end table
-
 @c man end MUXERS
diff --git a/deps/libav/doc/optimization.txt b/deps/libav/doc/optimization.txt
index 2b8c51b..42ad15e 100644
--- a/deps/libav/doc/optimization.txt
+++ b/deps/libav/doc/optimization.txt
@@ -268,17 +268,6 @@ CELL/SPU:
 http://www-01.ibm.com/chips/techlib/techlib.nsf/techdocs/30B3520C93F437AB87257060006FFE5E/$file/Language_Extensions_for_CBEA_2.4.pdf
 http://www-01.ibm.com/chips/techlib/techlib.nsf/techdocs/9F820A5FFA3ECE8C8725716A0062585F/$file/CBE_Handbook_v1.1_24APR2007_pub.pdf
 
-SPARC-specific:
----------------
-SPARC Joint Programming Specification (JPS1): Commonality
-http://www.fujitsu.com/downloads/PRMPWR/JPS1-R1.0.4-Common-pub.pdf
-
-UltraSPARC III Processor User's Manual (contains instruction timings)
-http://www.sun.com/processors/manuals/USIIIv2.pdf
-
-VIS Whitepaper (contains optimization guidelines)
-http://www.sun.com/processors/vis/download/vis/vis_whitepaper.pdf
-
 GCC asm links:
 --------------
 official doc but quite ugly
diff --git a/deps/libav/doc/platform.texi b/deps/libav/doc/platform.texi
index a9cacfe..45ec275 100644
--- a/deps/libav/doc/platform.texi
+++ b/deps/libav/doc/platform.texi
@@ -51,8 +51,8 @@ The toolchain provided with Xcode is sufficient to build the basic
 unacelerated code.
 
 OS X on PowerPC or ARM (iPhone) requires a preprocessor from
- at url{http://github.com/yuvi/gas-preprocessor} to build the optimized
-assembler functions. Just download the Perl script and put it somewhere
+ at url{git://git.libav.org/gas-preprocessor.git} to build the optimized
+assembler functions. Put the Perl script somewhere
 in your PATH, Libav's configure will pick it up automatically.
 
 OS X on AMD64 and x86 requires @command{yasm} to build most of the
diff --git a/deps/libav/doc/protocols.texi b/deps/libav/doc/protocols.texi
index 1a9f575..1501dab 100644
--- a/deps/libav/doc/protocols.texi
+++ b/deps/libav/doc/protocols.texi
@@ -89,6 +89,55 @@ m3u8 files.
 
 HTTP (Hyper Text Transfer Protocol).
 
+This protocol accepts the following options:
+
+ at table @option
+ at item chunked_post
+If set to 1 use chunked Transfer-Encoding for posts, default is 1.
+
+ at item content_type
+Set a specific content type for the POST messages.
+
+ at item headers
+Set custom HTTP headers, can override built in default headers. The
+value must be a string encoding the headers.
+
+ at item multiple_requests
+Use persistent connections if set to 1, default is 0.
+
+ at item post_data
+Set custom HTTP post data.
+
+ at item user_agent
+Override the User-Agent header. If not specified a string of the form
+"Lavf/<version>" will be used.
+
+ at item mime_type
+Export the MIME type.
+
+ at item icy
+If set to 1 request ICY (SHOUTcast) metadata from the server. If the server
+supports this, the metadata has to be retrieved by the application by reading
+the @option{icy_metadata_headers} and @option{icy_metadata_packet} options.
+The default is 0.
+
+ at item icy_metadata_headers
+If the server supports ICY metadata, this contains the ICY-specific HTTP reply
+headers, separated by newline characters.
+
+ at item icy_metadata_packet
+If the server supports ICY metadata, and @option{icy} was set to 1, this
+contains the last non-empty metadata packet sent by the server. It should be
+polled in regular intervals by applications interested in mid-stream metadata
+updates.
+
+ at item offset
+Set initial byte offset.
+
+ at item end_offset
+Try to limit the request to bytes preceding this offset.
+ at end table
+
 @section mmst
 
 MMS (Microsoft Media Server) protocol over TCP.
diff --git a/deps/libav/doc/texi2pod.pl b/deps/libav/doc/texi2pod.pl
index fb4f7be..609568e 100755
--- a/deps/libav/doc/texi2pod.pl
+++ b/deps/libav/doc/texi2pod.pl
@@ -324,6 +324,8 @@ $sects{FOOTNOTES} .= "=back\n" if exists $sects{FOOTNOTES};
 
 unshift @sects_sequence, "NAME";
 for $sect (@sects_sequence) {
+    # always use utf8
+    print "=encoding utf8\n";
     if(exists $sects{$sect}) {
         $head = $sect;
         $head =~ s/SEEALSO/SEE ALSO/;
diff --git a/deps/libav/libavcodec/Makefile b/deps/libav/libavcodec/Makefile
index 58defc9..bd93a6f 100644
--- a/deps/libav/libavcodec/Makefile
+++ b/deps/libav/libavcodec/Makefile
@@ -96,7 +96,6 @@ OBJS-$(CONFIG_AMRWB_DECODER)           += amrwbdec.o celp_filters.o   \
                                           celp_math.o acelp_filters.o \
                                           acelp_vectors.o             \
                                           acelp_pitch_delay.o
-OBJS-$(CONFIG_AMV_DECODER)             += sp5xdec.o mjpegdec.o mjpeg.o
 OBJS-$(CONFIG_ANM_DECODER)             += anm.o
 OBJS-$(CONFIG_ANSI_DECODER)            += ansi.o cga_data.o
 OBJS-$(CONFIG_APE_DECODER)             += apedec.o
@@ -169,8 +168,6 @@ OBJS-$(CONFIG_ESCAPE124_DECODER)       += escape124.o
 OBJS-$(CONFIG_ESCAPE130_DECODER)       += escape130.o
 OBJS-$(CONFIG_FFV1_DECODER)            += ffv1dec.o ffv1.o
 OBJS-$(CONFIG_FFV1_ENCODER)            += ffv1enc.o ffv1.o
-OBJS-$(CONFIG_FFVHUFF_DECODER)         += huffyuv.o huffyuvdec.o
-OBJS-$(CONFIG_FFVHUFF_ENCODER)         += huffyuv.o huffyuvenc.o
 OBJS-$(CONFIG_FIC_DECODER)             += fic.o
 OBJS-$(CONFIG_FLAC_DECODER)            += flacdec.o flacdata.o flac.o flacdsp.o
 OBJS-$(CONFIG_FLAC_ENCODER)            += flacenc.o flacdata.o flac.o flacdsp.o
@@ -205,7 +202,6 @@ OBJS-$(CONFIG_HEVC_DECODER)            += hevc.o hevc_mvs.o hevc_ps.o hevc_sei.o
 OBJS-$(CONFIG_HNM4_VIDEO_DECODER)      += hnm4video.o
 OBJS-$(CONFIG_HUFFYUV_DECODER)         += huffyuv.o huffyuvdec.o
 OBJS-$(CONFIG_HUFFYUV_ENCODER)         += huffyuv.o huffyuvenc.o
-OBJS-$(CONFIG_IAC_DECODER)             += imc.o
 OBJS-$(CONFIG_IDCIN_DECODER)           += idcinvideo.o
 OBJS-$(CONFIG_IFF_BYTERUN1_DECODER)    += iff.o
 OBJS-$(CONFIG_IFF_ILBM_DECODER)        += iff.o
@@ -218,8 +214,7 @@ OBJS-$(CONFIG_INTERPLAY_DPCM_DECODER)  += dpcm.o
 OBJS-$(CONFIG_INTERPLAY_VIDEO_DECODER) += interplayvideo.o
 OBJS-$(CONFIG_JPEG2000_DECODER)        += jpeg2000dec.o jpeg2000.o      \
                                           jpeg2000dwt.o mqcdec.o mqc.o
-OBJS-$(CONFIG_JPEGLS_DECODER)          += jpeglsdec.o jpegls.o \
-                                          mjpegdec.o mjpeg.o
+OBJS-$(CONFIG_JPEGLS_DECODER)          += jpeglsdec.o jpegls.o
 OBJS-$(CONFIG_JPEGLS_ENCODER)          += jpeglsenc.o jpegls.o
 OBJS-$(CONFIG_JV_DECODER)              += jvdec.o
 OBJS-$(CONFIG_KGV1_DECODER)            += kgv1dec.o
@@ -235,7 +230,7 @@ OBJS-$(CONFIG_METASOUND_DECODER)       += metasound.o metasound_data.o \
 OBJS-$(CONFIG_MIMIC_DECODER)           += mimic.o
 OBJS-$(CONFIG_MJPEG_DECODER)           += mjpegdec.o mjpeg.o
 OBJS-$(CONFIG_MJPEG_ENCODER)           += mjpegenc.o mjpeg.o
-OBJS-$(CONFIG_MJPEGB_DECODER)          += mjpegbdec.o mjpegdec.o mjpeg.o
+OBJS-$(CONFIG_MJPEGB_DECODER)          += mjpegbdec.o
 OBJS-$(CONFIG_MLP_DECODER)             += mlpdec.o mlpdsp.o
 OBJS-$(CONFIG_MMVIDEO_DECODER)         += mmvideo.o
 OBJS-$(CONFIG_MOTIONPIXELS_DECODER)    += motionpixels.o
@@ -259,16 +254,10 @@ OBJS-$(CONFIG_MPEG1VIDEO_ENCODER)      += mpeg12enc.o mpeg12.o
 OBJS-$(CONFIG_MPEG2VIDEO_DECODER)      += mpeg12dec.o mpeg12.o mpeg12data.o
 OBJS-$(CONFIG_MPEG2VIDEO_ENCODER)      += mpeg12enc.o mpeg12.o
 OBJS-$(CONFIG_MSMPEG4V1_DECODER)       += msmpeg4dec.o msmpeg4.o msmpeg4data.o
-OBJS-$(CONFIG_MSMPEG4V2_DECODER)       += msmpeg4dec.o msmpeg4.o msmpeg4data.o \
-                                          h263dec.o h263.o ituh263dec.o \
-                                          mpeg4videodec.o
-OBJS-$(CONFIG_MSMPEG4V2_ENCODER)       += msmpeg4.o msmpeg4enc.o msmpeg4data.o \
-                                          h263.o
-OBJS-$(CONFIG_MSMPEG4V3_DECODER)       += msmpeg4dec.o msmpeg4.o msmpeg4data.o \
-                                          h263dec.o h263.o ituh263dec.o \
-                                          mpeg4videodec.o
-OBJS-$(CONFIG_MSMPEG4V3_ENCODER)       += msmpeg4.o msmpeg4enc.o msmpeg4data.o \
-                                          h263.o
+OBJS-$(CONFIG_MSMPEG4V2_DECODER)       += msmpeg4dec.o msmpeg4.o msmpeg4data.o
+OBJS-$(CONFIG_MSMPEG4V2_ENCODER)       += msmpeg4enc.o msmpeg4.o msmpeg4data.o
+OBJS-$(CONFIG_MSMPEG4V3_DECODER)       += msmpeg4dec.o msmpeg4.o msmpeg4data.o
+OBJS-$(CONFIG_MSMPEG4V3_ENCODER)       += msmpeg4enc.o msmpeg4.o msmpeg4data.o
 OBJS-$(CONFIG_MSRLE_DECODER)           += msrle.o msrledec.o
 OBJS-$(CONFIG_MSA1_DECODER)            += mss3.o mss34dsp.o
 OBJS-$(CONFIG_MSS1_DECODER)            += mss1.o mss12.o
@@ -276,7 +265,7 @@ OBJS-$(CONFIG_MSS2_DECODER)            += mss2.o mss12.o mss2dsp.o
 OBJS-$(CONFIG_MSVIDEO1_DECODER)        += msvideo1.o
 OBJS-$(CONFIG_MSZH_DECODER)            += lcldec.o
 OBJS-$(CONFIG_MTS2_DECODER)            += mss4.o mss34dsp.o
-OBJS-$(CONFIG_MXPEG_DECODER)           += mxpegdec.o mjpegdec.o mjpeg.o
+OBJS-$(CONFIG_MXPEG_DECODER)           += mxpegdec.o
 OBJS-$(CONFIG_NELLYMOSER_DECODER)      += nellymoserdec.o nellymoser.o
 OBJS-$(CONFIG_NELLYMOSER_ENCODER)      += nellymoserenc.o nellymoser.o
 OBJS-$(CONFIG_NUV_DECODER)             += nuv.o rtjpeg.o
@@ -297,7 +286,7 @@ OBJS-$(CONFIG_PNG_ENCODER)             += png.o pngenc.o
 OBJS-$(CONFIG_PPM_DECODER)             += pnmdec.o pnm.o
 OBJS-$(CONFIG_PPM_ENCODER)             += pnmenc.o
 OBJS-$(CONFIG_PRORES_DECODER)          += proresdec.o proresdata.o proresdsp.o
-OBJS-$(CONFIG_PRORES_ENCODER)          += proresenc.o proresdata.o proresdsp.o
+OBJS-$(CONFIG_PRORES_ENCODER)          += proresenc.o proresdata.o
 OBJS-$(CONFIG_PTX_DECODER)             += ptx.o
 OBJS-$(CONFIG_QCELP_DECODER)           += qcelpdec.o                     \
                                           celp_filters.o acelp_vectors.o \
@@ -339,22 +328,18 @@ OBJS-$(CONFIG_SMACKAUD_DECODER)        += smacker.o
 OBJS-$(CONFIG_SMACKER_DECODER)         += smacker.o
 OBJS-$(CONFIG_SMC_DECODER)             += smc.o
 OBJS-$(CONFIG_SOL_DPCM_DECODER)        += dpcm.o
-OBJS-$(CONFIG_SP5X_DECODER)            += sp5xdec.o mjpegdec.o mjpeg.o
+OBJS-$(CONFIG_SP5X_DECODER)            += sp5xdec.o
 OBJS-$(CONFIG_SRT_DECODER)             += srtdec.o ass.o
 OBJS-$(CONFIG_SUNRAST_DECODER)         += sunrast.o
 OBJS-$(CONFIG_SUNRAST_ENCODER)         += sunrastenc.o
 OBJS-$(CONFIG_SVQ1_DECODER)            += svq1dec.o svq1.o svq13.o h263.o
 OBJS-$(CONFIG_SVQ1_ENCODER)            += svq1enc.o svq1.o    \
                                           h263.o ituh263enc.o
-OBJS-$(CONFIG_SVQ3_DECODER)            += svq3.o svq13.o h263.o h264.o        \
-                                          h264_loopfilter.o h264_direct.o     \
-                                          h264_sei.o h264_ps.o h264_refs.o    \
-                                          h264_cavlc.o h264_cabac.o cabac.o
+OBJS-$(CONFIG_SVQ3_DECODER)            += svq3.o svq13.o
 OBJS-$(CONFIG_TAK_DECODER)             += takdec.o tak.o
 OBJS-$(CONFIG_TARGA_DECODER)           += targa.o
 OBJS-$(CONFIG_TARGA_ENCODER)           += targaenc.o rle.o
 OBJS-$(CONFIG_THEORA_DECODER)          += xiph.o
-OBJS-$(CONFIG_THP_DECODER)             += mjpegdec.o mjpeg.o
 OBJS-$(CONFIG_TIERTEXSEQVIDEO_DECODER) += tiertexseqv.o
 OBJS-$(CONFIG_TIFF_DECODER)            += tiff.o lzw.o faxcompr.o
 OBJS-$(CONFIG_TIFF_ENCODER)            += tiffenc.o rle.o lzwenc.o
@@ -697,8 +682,6 @@ SKIPHEADERS-$(CONFIG_VAAPI)            += vaapi_internal.h
 SKIPHEADERS-$(CONFIG_VDA)              += vda.h
 SKIPHEADERS-$(CONFIG_VDPAU)            += vdpau.h vdpau_internal.h
 
-EXAMPLES = api
-
 TESTPROGS = dct                                                         \
             fft                                                         \
             fft-fixed                                                   \
diff --git a/deps/libav/libavcodec/a64multienc.c b/deps/libav/libavcodec/a64multienc.c
index 11d6e2c..786074f 100644
--- a/deps/libav/libavcodec/a64multienc.c
+++ b/deps/libav/libavcodec/a64multienc.c
@@ -174,7 +174,7 @@ static av_cold int a64multi_close_encoder(AVCodecContext *avctx)
     return 0;
 }
 
-static av_cold int a64multi_init_encoder(AVCodecContext *avctx)
+static av_cold int a64multi_encode_init(AVCodecContext *avctx)
 {
     A64Context *c = avctx->priv_data;
     int a;
@@ -382,7 +382,7 @@ AVCodec ff_a64multi_encoder = {
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_A64_MULTI,
     .priv_data_size = sizeof(A64Context),
-    .init           = a64multi_init_encoder,
+    .init           = a64multi_encode_init,
     .encode2        = a64multi_encode_frame,
     .close          = a64multi_close_encoder,
     .pix_fmts       = (const enum AVPixelFormat[]) {AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE},
@@ -395,7 +395,7 @@ AVCodec ff_a64multi5_encoder = {
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_A64_MULTI5,
     .priv_data_size = sizeof(A64Context),
-    .init           = a64multi_init_encoder,
+    .init           = a64multi_encode_init,
     .encode2        = a64multi_encode_frame,
     .close          = a64multi_close_encoder,
     .pix_fmts       = (const enum AVPixelFormat[]) {AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE},
diff --git a/deps/libav/libavcodec/aacdec.c b/deps/libav/libavcodec/aacdec.c
index a365209..4bdf52f 100644
--- a/deps/libav/libavcodec/aacdec.c
+++ b/deps/libav/libavcodec/aacdec.c
@@ -2529,7 +2529,7 @@ static void apply_dependent_coupling(AACContext *ac,
                 const float gain = cce->coup.gain[index][idx];
                 for (group = 0; group < ics->group_len[g]; group++) {
                     for (k = offsets[i]; k < offsets[i + 1]; k++) {
-                        // XXX dsputil-ize
+                        // FIXME: SIMDify
                         dest[group * 128 + k] += gain * src[group * 128 + k];
                     }
                 }
@@ -3030,7 +3030,8 @@ static int latm_decode_audio_specific_config(struct LATMContext *latmctx,
     if (bits_consumed < 0)
         return AVERROR_INVALIDDATA;
 
-    if (ac->oc[1].m4ac.sample_rate != m4ac.sample_rate ||
+    if (!latmctx->initialized ||
+        ac->oc[1].m4ac.sample_rate != m4ac.sample_rate ||
         ac->oc[1].m4ac.chan_config != m4ac.chan_config) {
 
         av_log(avctx, AV_LOG_INFO, "audio config changed\n");
diff --git a/deps/libav/libavcodec/aarch64/cabac.h b/deps/libav/libavcodec/aarch64/cabac.h
new file mode 100644
index 0000000..e12953e
--- /dev/null
+++ b/deps/libav/libavcodec/aarch64/cabac.h
@@ -0,0 +1,104 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_AARCH64_CABAC_H
+#define AVCODEC_AARCH64_CABAC_H
+
+#include "config.h"
+#if HAVE_INLINE_ASM
+
+#include "libavutil/attributes.h"
+#include "libavutil/internal.h"
+#include "libavcodec/cabac.h"
+
+#define get_cabac_inline get_cabac_inline_aarch64
+static av_always_inline int get_cabac_inline_aarch64(CABACContext *c,
+                                                     uint8_t *const state)
+{
+    int bit;
+    void *reg_a, *reg_b, *reg_c, *tmp;
+
+    __asm__ volatile(
+        "ldrb       %w[bit]       , [%[state]]                  \n\t"
+        "add        %[r_b]        , %[tables]   , %[lps_off]    \n\t"
+        "mov        %w[tmp]       , %w[range]                   \n\t"
+        "and        %w[range]     , %w[range]   , #0xC0         \n\t"
+        "lsl        %w[r_c]       , %w[range]   , #1            \n\t"
+        "add        %[r_b]        , %[r_b]      , %w[bit], UXTW \n\t"
+        "ldrb       %w[range]     , [%[r_b], %w[r_c], SXTW]     \n\t"
+        "sub        %w[r_c]       , %w[tmp]     , %w[range]     \n\t"
+        "lsl        %w[tmp]       , %w[r_c]     , #17           \n\t"
+        "cmp        %w[tmp]       , %w[low]                     \n\t"
+        "csel       %w[tmp]       , %w[tmp]     , wzr      , cc \n\t"
+        "csel       %w[range]     , %w[r_c]     , %w[range], gt \n\t"
+        "cinv       %w[bit]       , %w[bit]     , cc            \n\t"
+        "sub        %w[low]       , %w[low]     , %w[tmp]       \n\t"
+        "add        %[r_b]        , %[tables]   , %[norm_off]   \n\t"
+        "add        %[r_a]        , %[tables]   , %[mlps_off]   \n\t"
+        "ldrb       %w[tmp]       , [%[r_b], %w[range], SXTW]   \n\t"
+        "ldrb       %w[r_a]       , [%[r_a], %w[bit], SXTW]     \n\t"
+        "lsl        %w[low]       , %w[low]     , %w[tmp]       \n\t"
+        "lsl        %w[range]     , %w[range]   , %w[tmp]       \n\t"
+        "uxth       %w[r_c]       , %w[low]                     \n\t"
+        "strb       %w[r_a]       , [%[state]]                  \n\t"
+        "cbnz       %w[r_c]       , 2f                          \n\t"
+        "ldr        %[r_c]        , [%[c], %[byte]]             \n\t"
+        "ldr        %[r_a]        , [%[c], %[end]]              \n\t"
+        "ldrh       %w[tmp]       , [%[r_c]]                    \n\t"
+        "cmp        %[r_c]        , %[r_a]                      \n\t"
+        "b.ge       1f                                          \n\t"
+        "add        %[r_a]        , %[r_c]      , #2            \n\t"
+        "str        %[r_a]        , [%[c], %[byte]]             \n\t"
+        "1:                                                     \n\t"
+        "sub        %w[r_c]       , %w[low]     , #1            \n\t"
+        "eor        %w[r_c]       , %w[r_c]     , %w[low]       \n\t"
+        "rev        %w[tmp]       , %w[tmp]                     \n\t"
+        "lsr        %w[r_c]       , %w[r_c]     , #15           \n\t"
+        "lsr        %w[tmp]       , %w[tmp]     , #15           \n\t"
+        "ldrb       %w[r_c]       , [%[r_b], %w[r_c], SXTW]     \n\t"
+        "mov        %w[r_b]       , #0xFFFF                     \n\t"
+        "mov        %w[r_a]       , #7                          \n\t"
+        "sub        %w[tmp]       , %w[tmp]     , %w[r_b]       \n\t"
+        "sub        %w[r_c]       , %w[r_a]     , %w[r_c]       \n\t"
+        "lsl        %w[tmp]       , %w[tmp]     , %w[r_c]       \n\t"
+        "add        %w[low]       , %w[low]     , %w[tmp]       \n\t"
+        "2:                                                     \n\t"
+        :    [bit]"=&r"(bit),
+             [low]"+&r"(c->low),
+           [range]"+&r"(c->range),
+             [r_a]"=&r"(reg_a),
+             [r_b]"=&r"(reg_b),
+             [r_c]"=&r"(reg_c),
+             [tmp]"=&r"(tmp)
+        :        [c]"r"(c),
+             [state]"r"(state),
+            [tables]"r"(ff_h264_cabac_tables),
+              [byte]"i"(offsetof(CABACContext, bytestream)),
+               [end]"i"(offsetof(CABACContext, bytestream_end)),
+          [norm_off]"I"(H264_NORM_SHIFT_OFFSET),
+           [lps_off]"I"(H264_LPS_RANGE_OFFSET),
+          [mlps_off]"I"(H264_MLPS_STATE_OFFSET + 128)
+        : "memory", "cc"
+        );
+
+    return bit & 1;
+}
+
+#endif /* HAVE_INLINE_ASM */
+
+#endif /* AVCODEC_AARCH64_CABAC_H */
diff --git a/deps/libav/libavcodec/aarch64/h264idct_neon.S b/deps/libav/libavcodec/aarch64/h264idct_neon.S
index 1c90c4c..99c2cb5 100644
--- a/deps/libav/libavcodec/aarch64/h264idct_neon.S
+++ b/deps/libav/libavcodec/aarch64/h264idct_neon.S
@@ -106,8 +106,8 @@ function ff_h264_idct_add16_neon, export=1
         mov             w9,  w3         // stride
         movrel          x7,  scan8
         mov             x10, #16
-        movrel          x13, ff_h264_idct_dc_add_neon
-        movrel          x14, ff_h264_idct_add_neon
+        movrel          x13, X(ff_h264_idct_dc_add_neon)
+        movrel          x14, X(ff_h264_idct_add_neon)
 1:      mov             w2,  w9
         ldrb            w3,  [x7], #1
         ldrsw           x0,  [x5], #4
@@ -133,8 +133,8 @@ function ff_h264_idct_add16intra_neon, export=1
         mov             w9,  w3         // stride
         movrel          x7,  scan8
         mov             x10, #16
-        movrel          x13, ff_h264_idct_dc_add_neon
-        movrel          x14, ff_h264_idct_add_neon
+        movrel          x13, X(ff_h264_idct_dc_add_neon)
+        movrel          x14, X(ff_h264_idct_add_neon)
 1:      mov             w2,  w9
         ldrb            w3,  [x7], #1
         ldrsw           x0,  [x5], #4
@@ -160,8 +160,8 @@ function ff_h264_idct_add8_neon, export=1
         add             x5,  x1,  #16*4         // block_offset
         add             x9,  x2,  #16*32        // block
         mov             w19, w3                 // stride
-        movrel          x13, ff_h264_idct_dc_add_neon
-        movrel          x14, ff_h264_idct_add_neon
+        movrel          x13, X(ff_h264_idct_dc_add_neon)
+        movrel          x14, X(ff_h264_idct_add_neon)
         movrel          x7,  scan8+16
         mov             x10, #0
         mov             x11, #16
@@ -374,8 +374,8 @@ function ff_h264_idct8_add4_neon, export=1
         mov             w2,  w3
         movrel          x7,  scan8
         mov             w10, #16
-        movrel          x13, ff_h264_idct8_dc_add_neon
-        movrel          x14, ff_h264_idct8_add_neon
+        movrel          x13, X(ff_h264_idct8_dc_add_neon)
+        movrel          x14, X(ff_h264_idct8_add_neon)
 1:      ldrb            w9,  [x7], #4
         ldrsw           x0,  [x5], #16
         ldrb            w9,  [x4, w9, UXTW]
diff --git a/deps/libav/libavcodec/ac3.h b/deps/libav/libavcodec/ac3.h
index fa290d3..f2cb6c3 100644
--- a/deps/libav/libavcodec/ac3.h
+++ b/deps/libav/libavcodec/ac3.h
@@ -109,7 +109,7 @@ typedef enum AC3PreferredStereoDownmixMode {
     AC3_DMIXMOD_NOTINDICATED = 0,
     AC3_DMIXMOD_LTRT,
     AC3_DMIXMOD_LORO,
-    AC3_DMIXMOD_RESERVED
+    AC3_DMIXMOD_DPLII // reserved value in A/52, but used by encoders to indicate DPL2
 } AC3PreferredStereoDownmixMode;
 
 typedef struct AC3BitAllocParameters {
diff --git a/deps/libav/libavcodec/ac3dec.c b/deps/libav/libavcodec/ac3dec.c
index fcb52e1..0487679 100644
--- a/deps/libav/libavcodec/ac3dec.c
+++ b/deps/libav/libavcodec/ac3dec.c
@@ -31,6 +31,7 @@
 
 #include "libavutil/channel_layout.h"
 #include "libavutil/crc.h"
+#include "libavutil/downmix_info.h"
 #include "libavutil/opt.h"
 #include "internal.h"
 #include "aac_ac3_parser.h"
@@ -77,6 +78,15 @@ static const float gain_levels[9] = {
     LEVEL_MINUS_9DB
 };
 
+/** Adjustments in dB gain (LFE, +10 to -21 dB) */
+static const float gain_levels_lfe[32] = {
+    3.162275, 2.818382, 2.511886, 2.238719, 1.995261, 1.778278, 1.584893,
+    1.412536, 1.258924, 1.122018, 1.000000, 0.891251, 0.794328, 0.707946,
+    0.630957, 0.562341, 0.501187, 0.446683, 0.398107, 0.354813, 0.316227,
+    0.281838, 0.251188, 0.223872, 0.199526, 0.177828, 0.158489, 0.141253,
+    0.125892, 0.112201, 0.100000, 0.089125
+};
+
 /**
  * Table for default stereo downmixing coefficients
  * reference: Section 7.8.2 Downmixing Into Two Channels
@@ -1308,6 +1318,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
     const uint8_t *channel_map;
     const float *output[AC3_MAX_CHANNELS];
     enum AVMatrixEncoding matrix_encoding;
+    AVDownmixInfo *downmix_info;
 
     /* copy input buffer to decoder context to avoid reading past the end
        of the buffer, which can be caused by a damaged input stream. */
@@ -1478,6 +1489,33 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
     if ((ret = ff_side_data_update_matrix_encoding(frame, matrix_encoding)) < 0)
         return ret;
 
+    /* AVDownmixInfo */
+    if ((downmix_info = av_downmix_info_update_side_data(frame))) {
+        switch (s->preferred_downmix) {
+        case AC3_DMIXMOD_LTRT:
+            downmix_info->preferred_downmix_type = AV_DOWNMIX_TYPE_LTRT;
+            break;
+        case AC3_DMIXMOD_LORO:
+            downmix_info->preferred_downmix_type = AV_DOWNMIX_TYPE_LORO;
+            break;
+        case AC3_DMIXMOD_DPLII:
+            downmix_info->preferred_downmix_type = AV_DOWNMIX_TYPE_DPLII;
+            break;
+        default:
+            downmix_info->preferred_downmix_type = AV_DOWNMIX_TYPE_UNKNOWN;
+            break;
+        }
+        downmix_info->center_mix_level        = gain_levels[s->       center_mix_level];
+        downmix_info->center_mix_level_ltrt   = gain_levels[s->  center_mix_level_ltrt];
+        downmix_info->surround_mix_level      = gain_levels[s->     surround_mix_level];
+        downmix_info->surround_mix_level_ltrt = gain_levels[s->surround_mix_level_ltrt];
+        if (s->lfe_mix_level_exists)
+            downmix_info->lfe_mix_level       = gain_levels_lfe[s->lfe_mix_level];
+        else
+            downmix_info->lfe_mix_level       = 0.0; // -inf dB
+    } else
+        return AVERROR(ENOMEM);
+
     *got_frame_ptr = 1;
 
     return FFMIN(buf_size, s->frame_size);
diff --git a/deps/libav/libavcodec/ac3dsp.c b/deps/libav/libavcodec/ac3dsp.c
index e792bcf..25bd6e3 100644
--- a/deps/libav/libavcodec/ac3dsp.c
+++ b/deps/libav/libavcodec/ac3dsp.c
@@ -1,5 +1,5 @@
 /*
- * AC-3 DSP utils
+ * AC-3 DSP functions
  * Copyright (c) 2011 Justin Ruggles
  *
  * This file is part of Libav.
diff --git a/deps/libav/libavcodec/ac3dsp.h b/deps/libav/libavcodec/ac3dsp.h
index e350c88..6ca0c5b 100644
--- a/deps/libav/libavcodec/ac3dsp.h
+++ b/deps/libav/libavcodec/ac3dsp.h
@@ -1,5 +1,5 @@
 /*
- * AC-3 DSP utils
+ * AC-3 DSP functions
  * Copyright (c) 2011 Justin Ruggles
  *
  * This file is part of Libav.
diff --git a/deps/libav/libavcodec/ac3enc.h b/deps/libav/libavcodec/ac3enc.h
index be9dcf2..a533536 100644
--- a/deps/libav/libavcodec/ac3enc.h
+++ b/deps/libav/libavcodec/ac3enc.h
@@ -31,12 +31,14 @@
 #include <stdint.h>
 
 #include "libavutil/float_dsp.h"
+
 #include "ac3.h"
 #include "ac3dsp.h"
 #include "avcodec.h"
 #include "dsputil.h"
-#include "put_bits.h"
 #include "fft.h"
+#include "mathops.h"
+#include "put_bits.h"
 
 #ifndef CONFIG_AC3ENC_FLOAT
 #define CONFIG_AC3ENC_FLOAT 0
diff --git a/deps/libav/libavcodec/arm/cabac.h b/deps/libav/libavcodec/arm/cabac.h
new file mode 100644
index 0000000..6ff5f1a
--- /dev/null
+++ b/deps/libav/libavcodec/arm/cabac.h
@@ -0,0 +1,102 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_ARM_CABAC_H
+#define AVCODEC_ARM_CABAC_H
+
+#include "config.h"
+#if HAVE_ARMV6T2_INLINE
+
+#include "libavutil/attributes.h"
+#include "libavutil/internal.h"
+#include "libavcodec/cabac.h"
+
+#define get_cabac_inline get_cabac_inline_arm
+static av_always_inline int get_cabac_inline_arm(CABACContext *c,
+                                                 uint8_t *const state)
+{
+    int bit;
+    void *reg_b, *reg_c, *tmp;
+
+    __asm__ volatile(
+        "ldrb       %[bit]        , [%[state]]                  \n\t"
+        "add        %[r_b]        , %[tables]   , %[lps_off]    \n\t"
+        "mov        %[tmp]        , %[range]                    \n\t"
+        "and        %[range]      , %[range]    , #0xC0         \n\t"
+        "add        %[r_b]        , %[r_b]      , %[bit]        \n\t"
+        "ldrb       %[range]      , [%[r_b], %[range], lsl #1]  \n\t"
+        "add        %[r_b]        , %[tables]   , %[norm_off]   \n\t"
+        "sub        %[r_c]        , %[tmp]      , %[range]      \n\t"
+        "lsl        %[tmp]        , %[r_c]      , #17           \n\t"
+        "cmp        %[tmp]        , %[low]                      \n\t"
+        "it         gt                                          \n\t"
+        "movgt      %[range]      , %[r_c]                      \n\t"
+        "itt        cc                                          \n\t"
+        "mvncc      %[bit]        , %[bit]                      \n\t"
+        "subcc      %[low]        , %[low]      , %[tmp]        \n\t"
+        "add        %[r_c]        , %[tables]   , %[mlps_off]   \n\t"
+        "ldrb       %[tmp]        , [%[r_b], %[range]]          \n\t"
+        "ldrb       %[r_b]        , [%[r_c], %[bit]]            \n\t"
+        "lsl        %[low]        , %[low]      , %[tmp]        \n\t"
+        "lsl        %[range]      , %[range]    , %[tmp]        \n\t"
+        "uxth       %[r_c]        , %[low]                      \n\t"
+        "strb       %[r_b]        , [%[state]]                  \n\t"
+        "tst        %[r_c]        , %[r_c]                      \n\t"
+        "bne        2f                                          \n\t"
+        "ldr        %[r_c]        , [%[c], %[byte]]             \n\t"
+        "ldr        %[r_b]        , [%[c], %[end]]              \n\t"
+        "ldrh       %[tmp]        , [%[r_c]]                    \n\t"
+        "cmp        %[r_c]        , %[r_b]                      \n\t"
+        "itt        lt                                          \n\t"
+        "addlt      %[r_c]        , %[r_c]      , #2            \n\t"
+        "strlt      %[r_c]        , [%[c], %[byte]]             \n\t"
+        "sub        %[r_c]        , %[low]      , #1            \n\t"
+        "add        %[r_b]        , %[tables]   , %[norm_off]   \n\t"
+        "eor        %[r_c]        , %[low]      , %[r_c]        \n\t"
+        "rev        %[tmp]        , %[tmp]                      \n\t"
+        "lsr        %[r_c]        , %[r_c]      , #15           \n\t"
+        "lsr        %[tmp]        , %[tmp]      , #15           \n\t"
+        "ldrb       %[r_c]        , [%[r_b], %[r_c]]            \n\t"
+        "movw       %[r_b]        , #0xFFFF                     \n\t"
+        "sub        %[tmp]        , %[tmp]      , %[r_b]        \n\t"
+        "rsb        %[r_c]        , %[r_c]      , #7            \n\t"
+        "lsl        %[tmp]        , %[tmp]      , %[r_c]        \n\t"
+        "add        %[low]        , %[low]      , %[tmp]        \n\t"
+        "2:                                                     \n\t"
+        :    [bit]"=&r"(bit),
+             [low]"+&r"(c->low),
+           [range]"+&r"(c->range),
+             [r_b]"=&r"(reg_b),
+             [r_c]"=&r"(reg_c),
+             [tmp]"=&r"(tmp)
+        :        [c]"r"(c),
+             [state]"r"(state),
+            [tables]"r"(ff_h264_cabac_tables),
+              [byte]"M"(offsetof(CABACContext, bytestream)),
+               [end]"M"(offsetof(CABACContext, bytestream_end)),
+          [norm_off]"I"(H264_NORM_SHIFT_OFFSET),
+           [lps_off]"I"(H264_LPS_RANGE_OFFSET),
+          [mlps_off]"I"(H264_MLPS_STATE_OFFSET + 128)
+        : "memory", "cc"
+        );
+
+    return bit & 1;
+}
+#endif /* HAVE_ARMV6T2_INLINE */
+
+#endif /* AVCODEC_ARM_CABAC_H */
diff --git a/deps/libav/libavcodec/arm/dca.h b/deps/libav/libavcodec/arm/dca.h
index 580bd75..4aed576 100644
--- a/deps/libav/libavcodec/arm/dca.h
+++ b/deps/libav/libavcodec/arm/dca.h
@@ -81,27 +81,4 @@ static inline int decode_blockcodes(int code1, int code2, int levels,
 
 #endif
 
-#if HAVE_NEON_INLINE && HAVE_ASM_MOD_Y
-
-#define int8x8_fmul_int32 int8x8_fmul_int32
-static inline void int8x8_fmul_int32(av_unused DCADSPContext *dsp,
-                                     float *dst, const int8_t *src, int scale)
-{
-    __asm__ ("vcvt.f32.s32 %2,  %2,  #4         \n"
-             "vld1.8       {d0},     [%1,:64]   \n"
-             "vmovl.s8     q0,  d0              \n"
-             "vmovl.s16    q1,  d1              \n"
-             "vmovl.s16    q0,  d0              \n"
-             "vcvt.f32.s32 q0,  q0              \n"
-             "vcvt.f32.s32 q1,  q1              \n"
-             "vmul.f32     q0,  q0,  %y2        \n"
-             "vmul.f32     q1,  q1,  %y2        \n"
-             "vst1.32      {q0-q1},  [%m0,:128] \n"
-             : "=Um"(*(float (*)[8])dst)
-             : "r"(src), "x"(scale)
-             : "d0", "d1", "d2", "d3");
-}
-
-#endif
-
 #endif /* AVCODEC_ARM_DCA_H */
diff --git a/deps/libav/libavcodec/arm/dcadsp_init_arm.c b/deps/libav/libavcodec/arm/dcadsp_init_arm.c
index 2ea1289..5400484 100644
--- a/deps/libav/libavcodec/arm/dcadsp_init_arm.c
+++ b/deps/libav/libavcodec/arm/dcadsp_init_arm.c
@@ -24,15 +24,11 @@
 #include "libavutil/attributes.h"
 #include "libavcodec/dcadsp.h"
 
-void ff_dca_lfe_fir0_neon(float *out, const float *in, const float *coefs,
-                          float scale);
-void ff_dca_lfe_fir1_neon(float *out, const float *in, const float *coefs,
-                          float scale);
+void ff_dca_lfe_fir0_neon(float *out, const float *in, const float *coefs);
+void ff_dca_lfe_fir1_neon(float *out, const float *in, const float *coefs);
 
-void ff_dca_lfe_fir32_vfp(float *out, const float *in, const float *coefs,
-                          float scale);
-void ff_dca_lfe_fir64_vfp(float *out, const float *in, const float *coefs,
-                          float scale);
+void ff_dca_lfe_fir32_vfp(float *out, const float *in, const float *coefs);
+void ff_dca_lfe_fir64_vfp(float *out, const float *in, const float *coefs);
 
 void ff_dca_qmf_32_subbands_vfp(float samples_in[32][8], int sb_act,
                                 SynthFilterContext *synth, FFTContext *imdct,
@@ -53,6 +49,12 @@ void ff_synth_filter_float_neon(FFTContext *imdct,
                                 float out[32], const float in[32],
                                 float scale);
 
+void ff_decode_hf_neon(float dst[DCA_SUBBANDS][8],
+                       const int32_t vq_num[DCA_SUBBANDS],
+                       const int8_t hf_vq[1024][32], intptr_t vq_offset,
+                       int32_t scale[DCA_SUBBANDS][2],
+                       intptr_t start, intptr_t end);
+
 av_cold void ff_dcadsp_init_arm(DCADSPContext *s)
 {
     int cpu_flags = av_get_cpu_flags();
@@ -65,6 +67,7 @@ av_cold void ff_dcadsp_init_arm(DCADSPContext *s)
     if (have_neon(cpu_flags)) {
         s->lfe_fir[0] = ff_dca_lfe_fir0_neon;
         s->lfe_fir[1] = ff_dca_lfe_fir1_neon;
+        s->decode_hf  = ff_decode_hf_neon;
     }
 }
 
diff --git a/deps/libav/libavcodec/arm/dcadsp_neon.S b/deps/libav/libavcodec/arm/dcadsp_neon.S
index c798fea..70580cd 100644
--- a/deps/libav/libavcodec/arm/dcadsp_neon.S
+++ b/deps/libav/libavcodec/arm/dcadsp_neon.S
@@ -20,9 +20,37 @@
 
 #include "libavutil/arm/asm.S"
 
+function ff_decode_hf_neon, export=1
+        push            {r4-r5,lr}
+        add             r2,  r2,  r3
+        ldr             r3,       [sp, #12]
+        ldrd            r4,  r5,  [sp, #16]
+        add             r3,  r3,  r4, lsl #3
+        add             r1,  r1,  r4, lsl #2
+        add             r0,  r0,  r4, lsl #5
+
+1:      ldr_post        lr,  r1,  #4
+        add             r4,  r4,  #1
+        add             lr,  r2,  lr, lsl #5
+        cmp             r4,  r5
+        vld1.32         {d7},     [r3]!
+        vld1.8          {d0},     [lr,:64]
+        vcvt.f32.s32    d7,  d7,  #4
+        vmovl.s8        q1,  d0
+        vmovl.s16       q0,  d2
+        vmovl.s16       q1,  d3
+        vcvt.f32.s32    q0,  q0
+        vcvt.f32.s32    q1,  q1
+        vmul.f32        q0,  q0,  d7[0]
+        vmul.f32        q1,  q1,  d7[0]
+        vst1.32         {q0-q1},  [r0,:128]!
+        bne             1b
+
+        pop             {r4-r5,pc}
+endfunc
+
 function ff_dca_lfe_fir0_neon, export=1
         push            {r4-r6,lr}
-NOVFP   vmov            s0,  r3                 @ scale
         mov             r3,  #32                @ decifactor
         mov             r6,  #256/32
         b               dca_lfe_fir
@@ -30,7 +58,6 @@ endfunc
 
 function ff_dca_lfe_fir1_neon, export=1
         push            {r4-r6,lr}
-NOVFP   vmov            s0,  r3                 @ scale
         mov             r3,  #64                @ decifactor
         mov             r6,  #256/64
 dca_lfe_fir:
@@ -57,8 +84,7 @@ dca_lfe_fir:
         subs            r3,  r3,  #1
         vadd.f32        d4,  d4,  d5
         vadd.f32        d6,  d6,  d7
-        vpadd.f32       d4,  d4,  d6
-        vmul.f32        d5,  d4,  d0[0]
+        vpadd.f32       d5,  d4,  d6
         vst1.32         {d5[0]},  [r0,:32]!
         vst1.32         {d5[1]},  [r4,:32]!
         bne             1b
diff --git a/deps/libav/libavcodec/arm/dcadsp_vfp.S b/deps/libav/libavcodec/arm/dcadsp_vfp.S
index edabc29..c9114d4 100644
--- a/deps/libav/libavcodec/arm/dcadsp_vfp.S
+++ b/deps/libav/libavcodec/arm/dcadsp_vfp.S
@@ -27,8 +27,6 @@ PCOEF         .req    a3
 OLDFPSCR      .req    a4
 COUNTER       .req    ip
 
-SCALE32       .req    s28  @ use vector of 4 in place of 9th scalar when decifactor=32 / JMAX=8
-SCALE64       .req    s0   @ spare register in scalar bank when decifactor=64 / JMAX=4
 IN0           .req    s4
 IN1           .req    s5
 IN2           .req    s6
@@ -76,9 +74,6 @@ POST3         .req    s27
         vldr    COEF5, [PCOEF, #X + (1*JMAX + 1) * Y]
         vldr    COEF6, [PCOEF, #X + (2*JMAX + 1) * Y]
  .endif
- .ifnc "\tail",""
-        vmul.f  POST0, POST0, SCALE\decifactor  @ vector operation (SCALE may be scalar)
- .endif
  .ifnc "\head",""
         vldr    COEF7, [PCOEF, #X + (3*JMAX + 1) * Y]
    .ifc "\tail",""
@@ -129,7 +124,6 @@ POST3         .req    s27
 
 .macro dca_lfe_fir  decifactor
 function ff_dca_lfe_fir\decifactor\()_vfp, export=1
-NOVFP   vmov    s0, r3
         fmrx    OLDFPSCR, FPSCR
         ldr     ip, =0x03030000         @ RunFast mode, short vectors of length 4, stride 1
         fmxr    FPSCR, ip
@@ -140,7 +134,6 @@ NOVFP   vmov    s0, r3
  .if \decifactor == 32
   .set JMAX, 8
         vpush   {s16-s31}
-        vmov    SCALE32, s0             @ duplicate scalar across vector
         vldr    IN4, [PIN, #-4*4]
         vldr    IN5, [PIN, #-5*4]
         vldr    IN6, [PIN, #-6*4]
@@ -186,8 +179,6 @@ endfunc
         .unreq  OLDFPSCR
         .unreq  COUNTER
 
-        .unreq  SCALE32
-        .unreq  SCALE64
         .unreq  IN0
         .unreq  IN1
         .unreq  IN2
diff --git a/deps/libav/libavcodec/arm/dsputil_arm.h b/deps/libav/libavcodec/arm/dsputil_arm.h
index cd074df..4ac8019 100644
--- a/deps/libav/libavcodec/arm/dsputil_arm.h
+++ b/deps/libav/libavcodec/arm/dsputil_arm.h
@@ -26,7 +26,6 @@
 
 void ff_dsputil_init_armv5te(DSPContext* c, AVCodecContext *avctx);
 void ff_dsputil_init_armv6(DSPContext* c, AVCodecContext *avctx);
-void ff_dsputil_init_vfp(DSPContext* c, AVCodecContext *avctx);
 void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx);
 
 #endif /* AVCODEC_ARM_DSPUTIL_ARM_H */
diff --git a/deps/libav/libavcodec/arm/dsputil_init_arm.c b/deps/libav/libavcodec/arm/dsputil_init_arm.c
index bb68eb6..358734b 100644
--- a/deps/libav/libavcodec/arm/dsputil_init_arm.c
+++ b/deps/libav/libavcodec/arm/dsputil_init_arm.c
@@ -19,8 +19,13 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stdint.h>
+
 #include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
 #include "libavutil/arm/cpu.h"
+#include "libavcodec/avcodec.h"
+#include "libavcodec/dsputil.h"
 #include "dsputil_arm.h"
 
 void ff_j_rev_dct_arm(int16_t *data);
diff --git a/deps/libav/libavcodec/arm/dsputil_init_armv5te.c b/deps/libav/libavcodec/arm/dsputil_init_armv5te.c
index 302a655..ac6f1cb 100644
--- a/deps/libav/libavcodec/arm/dsputil_init_armv5te.c
+++ b/deps/libav/libavcodec/arm/dsputil_init_armv5te.c
@@ -18,6 +18,11 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stdint.h>
+
+#include "libavutil/attributes.h"
+#include "libavcodec/avcodec.h"
+#include "libavcodec/dsputil.h"
 #include "dsputil_arm.h"
 
 void ff_simple_idct_armv5te(int16_t *data);
diff --git a/deps/libav/libavcodec/arm/dsputil_init_armv6.c b/deps/libav/libavcodec/arm/dsputil_init_armv6.c
index 4c8ba47..357ae1e 100644
--- a/deps/libav/libavcodec/arm/dsputil_init_armv6.c
+++ b/deps/libav/libavcodec/arm/dsputil_init_armv6.c
@@ -20,7 +20,9 @@
 
 #include <stdint.h>
 
+#include "libavutil/attributes.h"
 #include "libavcodec/avcodec.h"
+#include "libavcodec/dsputil.h"
 #include "dsputil_arm.h"
 
 void ff_simple_idct_armv6(int16_t *data);
diff --git a/deps/libav/libavcodec/arm/dsputil_init_neon.c b/deps/libav/libavcodec/arm/dsputil_init_neon.c
index 0926c84..f30be97 100644
--- a/deps/libav/libavcodec/arm/dsputil_init_neon.c
+++ b/deps/libav/libavcodec/arm/dsputil_init_neon.c
@@ -23,6 +23,7 @@
 
 #include "libavutil/attributes.h"
 #include "libavcodec/avcodec.h"
+#include "libavcodec/dsputil.h"
 #include "dsputil_arm.h"
 
 void ff_simple_idct_neon(int16_t *data);
diff --git a/deps/libav/libavcodec/arm/hpeldsp_arm.S b/deps/libav/libavcodec/arm/hpeldsp_arm.S
index 5bacd8e..0f8092e 100644
--- a/deps/libav/libavcodec/arm/hpeldsp_arm.S
+++ b/deps/libav/libavcodec/arm/hpeldsp_arm.S
@@ -1,5 +1,5 @@
 @
-@ ARMv4 optimized DSP utils
+@ ARMv4-optimized halfpel functions
 @ Copyright (c) 2004 AGAWA Koji <i (AT) atty (DOT) jp>
 @
 @ This file is part of Libav.
diff --git a/deps/libav/libavcodec/arm/hpeldsp_armv6.S b/deps/libav/libavcodec/arm/hpeldsp_armv6.S
index f85c8cb..f1abc32 100644
--- a/deps/libav/libavcodec/arm/hpeldsp_armv6.S
+++ b/deps/libav/libavcodec/arm/hpeldsp_armv6.S
@@ -144,10 +144,11 @@ function ff_put_pixels8_y2_armv6, export=1
         eor             r7,  r5,  r7
         uadd8           r10, r10, r6
         and             r7,  r7,  r12
-        ldr_pre         r6,  r1,  r2
+        ldrc_pre        ne,  r6,  r1,  r2
         uadd8           r11, r11, r7
         strd_post       r8,  r9,  r0,  r2
-        ldr             r7,  [r1, #4]
+        it              ne
+        ldrne           r7,  [r1, #4]
         strd_post       r10, r11, r0,  r2
         bne             1b
 
@@ -196,9 +197,10 @@ function ff_put_pixels8_y2_no_rnd_armv6, export=1
         uhadd8          r9,  r5,  r7
         ldr             r5,  [r1, #4]
         uhadd8          r12, r4,  r6
-        ldr_pre         r6,  r1,  r2
+        ldrc_pre        ne,  r6,  r1,  r2
         uhadd8          r14, r5,  r7
-        ldr             r7,  [r1, #4]
+        it              ne
+        ldrne           r7,  [r1, #4]
         stm             r0,  {r8,r9}
         add             r0,  r0,  r2
         stm             r0,  {r12,r14}
diff --git a/deps/libav/libavcodec/arm/hpeldsp_init_arm.c b/deps/libav/libavcodec/arm/hpeldsp_init_arm.c
index 8176afe..c675166 100644
--- a/deps/libav/libavcodec/arm/hpeldsp_init_arm.c
+++ b/deps/libav/libavcodec/arm/hpeldsp_init_arm.c
@@ -1,5 +1,5 @@
 /*
- * ARM optimized DSP utils
+ * ARM-optimized halfpel functions
  * Copyright (c) 2001 Lionel Ulmer
  *
  * This file is part of Libav.
diff --git a/deps/libav/libavcodec/arm/videodsp_armv5te.S b/deps/libav/libavcodec/arm/videodsp_armv5te.S
index 055736d..bbd0a61 100644
--- a/deps/libav/libavcodec/arm/videodsp_armv5te.S
+++ b/deps/libav/libavcodec/arm/videodsp_armv5te.S
@@ -1,5 +1,5 @@
 @
-@ ARMv5te optimized DSP utils
+@ ARMv5te-optimized core video DSP functions
 @ Copyright (c) 2004 AGAWA Koji <i (AT) atty (DOT) jp>
 @
 @ This file is part of Libav.
diff --git a/deps/libav/libavcodec/arm/vp3dsp_init_arm.c b/deps/libav/libavcodec/arm/vp3dsp_init_arm.c
index dfd6078..1ab0852 100644
--- a/deps/libav/libavcodec/arm/vp3dsp_init_arm.c
+++ b/deps/libav/libavcodec/arm/vp3dsp_init_arm.c
@@ -26,7 +26,7 @@
 
 void ff_vp3_idct_put_neon(uint8_t *dest, int line_size, int16_t *data);
 void ff_vp3_idct_add_neon(uint8_t *dest, int line_size, int16_t *data);
-void ff_vp3_idct_dc_add_neon(uint8_t *dest, int line_size, const int16_t *data);
+void ff_vp3_idct_dc_add_neon(uint8_t *dest, int line_size, int16_t *data);
 
 void ff_vp3_v_loop_filter_neon(uint8_t *, int, int *);
 void ff_vp3_h_loop_filter_neon(uint8_t *, int, int *);
diff --git a/deps/libav/libavcodec/arm/vp8dsp_armv6.S b/deps/libav/libavcodec/arm/vp8dsp_armv6.S
index 19d454b..03100cd 100644
--- a/deps/libav/libavcodec/arm/vp8dsp_armv6.S
+++ b/deps/libav/libavcodec/arm/vp8dsp_armv6.S
@@ -1204,7 +1204,7 @@ function ff_put_vp8_\name\size\()_\hv\()_armv6, export=1
         mov             r4,  #\size
         stm             r12, {r4, r5}
         orr             r12, r6,  r7
-        b               vp8_put_\name\()_\hv\()_armv6 + 4
+        b               bl_put_\name\()_\hv\()_armv6
 endfunc
 .endm
 
@@ -1300,6 +1300,7 @@ vp8_mc_hv               bilin,  4, h,  v,  2
 
 function vp8_put_epel_h6_armv6
         push            {r1, r4-r11, lr}
+bl_put_epel_h6_armv6:
         sub             r2,  r2,  #2
         movrel          lr,  sixtap_filters_13245600 - 16
         add             lr,  lr,  r12, lsl #3
@@ -1358,6 +1359,7 @@ endfunc
 
 function vp8_put_epel_v6_armv6
         push            {r1, r4-r11, lr}
+bl_put_epel_v6_armv6:
         movrel          lr,  sixtap_filters_13245600 - 16
         add             lr,  lr,  r12, lsl #3
         str             r3,  [sp, #48]
@@ -1437,6 +1439,7 @@ endfunc
 
 function vp8_put_epel_h4_armv6
         push            {r1, r4-r11, lr}
+bl_put_epel_h4_armv6:
         subs            r2,  r2,  #1
         movrel          lr,  fourtap_filters_1324 - 4
         add             lr,  lr,  r12, lsl #2
@@ -1483,6 +1486,7 @@ endfunc
 
 function vp8_put_epel_v4_armv6
         push            {r1, r4-r11, lr}
+bl_put_epel_v4_armv6:
         movrel          lr,  fourtap_filters_1324 - 4
         add             lr,  lr,  r12, lsl #2
         ldm             lr,  {r5, r6}
@@ -1544,6 +1548,7 @@ endfunc
 
 function vp8_put_bilin_h_armv6
         push            {r1, r4-r11, lr}
+bl_put_bilin_h_armv6:
         rsb             r5,  r12, r12, lsl #16
         ldr             r12, [sp, #44]
         sub             r3,  r3,  r4
@@ -1589,6 +1594,7 @@ endfunc
 
 function vp8_put_bilin_v_armv6
         push            {r1, r4-r11, lr}
+bl_put_bilin_v_armv6:
         rsb             r5,  r12, r12, lsl #16
         ldr             r12, [sp, #44]
         add             r5,  r5,  #8
diff --git a/deps/libav/libavcodec/avcodec.h b/deps/libav/libavcodec/avcodec.h
index 54c60a9..7beb277 100644
--- a/deps/libav/libavcodec/avcodec.h
+++ b/deps/libav/libavcodec/avcodec.h
@@ -2460,13 +2460,17 @@ typedef struct AVCodecContext {
 #define FF_IDCT_SIMPLEMMX     3
 #define FF_IDCT_ARM           7
 #define FF_IDCT_ALTIVEC       8
+#if FF_API_ARCH_SH4
 #define FF_IDCT_SH4           9
+#endif
 #define FF_IDCT_SIMPLEARM     10
 #define FF_IDCT_IPP           13
 #define FF_IDCT_XVIDMMX       14
 #define FF_IDCT_SIMPLEARMV5TE 16
 #define FF_IDCT_SIMPLEARMV6   17
+#if FF_API_ARCH_SPARC
 #define FF_IDCT_SIMPLEVIS     18
+#endif
 #define FF_IDCT_FAAN          20
 #define FF_IDCT_SIMPLENEON    22
 #if FF_API_ARCH_ALPHA
@@ -4108,7 +4112,9 @@ void avcodec_set_dimensions(AVCodecContext *s, int width, int height);
 /**
  * Put a string representing the codec tag codec_tag in buf.
  *
+ * @param buf       buffer to place codec tag in
  * @param buf_size size in bytes of buf
+ * @param codec_tag codec tag to assign
  * @return the length of the string that would have been generated if
  * enough space had been available, excluding the trailing null
  */
diff --git a/deps/libav/libavcodec/avfft.h b/deps/libav/libavcodec/avfft.h
index b896182..e2e727d 100644
--- a/deps/libav/libavcodec/avfft.h
+++ b/deps/libav/libavcodec/avfft.h
@@ -99,9 +99,11 @@ enum DCTTransformType {
 
 /**
  * Set up DCT.
+ *
  * @param nbits           size of the input array:
  *                        (1 << nbits)     for DCT-II, DCT-III and DST-I
  *                        (1 << nbits) + 1 for DCT-I
+ * @param type            the type of transform
  *
  * @note the first element of the input of DST-I is ignored
  */
diff --git a/deps/libav/libavcodec/bfin/Makefile b/deps/libav/libavcodec/bfin/Makefile
index fc5f506..193f8e6 100644
--- a/deps/libav/libavcodec/bfin/Makefile
+++ b/deps/libav/libavcodec/bfin/Makefile
@@ -1,9 +1,10 @@
-OBJS += bfin/dsputil_bfin.o                                             \
+OBJS += bfin/dsputil_init.o                                             \
+        bfin/dsputil.o                                                  \
         bfin/fdct_bfin.o                                                \
+        bfin/hpel_pixels_no_rnd.o                                       \
         bfin/idct_bfin.o                                                \
-        bfin/pixels_bfin.o                                              \
+        bfin/pixels.o                                                   \
 
-OBJS-$(CONFIG_HPELDSP)                  += bfin/hpeldsp_bfin.o          \
-                                           bfin/hpel_pixels_bfin.o
-OBJS-$(CONFIG_VP3DSP)                   += bfin/vp3_bfin.o              \
-                                           bfin/vp3_idct_bfin.o
+OBJS-$(CONFIG_HPELDSP)                  += bfin/hpeldsp_init.o
+OBJS-$(CONFIG_VP3DSP)                   += bfin/vp3dsp_init.o           \
+                                           bfin/vp3dsp.o
diff --git a/deps/libav/libavcodec/bfin/pixels_bfin.S b/deps/libav/libavcodec/bfin/dsputil.S
similarity index 99%
rename from deps/libav/libavcodec/bfin/pixels_bfin.S
rename to deps/libav/libavcodec/bfin/dsputil.S
index 70d9de5..e19455b 100644
--- a/deps/libav/libavcodec/bfin/pixels_bfin.S
+++ b/deps/libav/libavcodec/bfin/dsputil.S
@@ -18,7 +18,8 @@
  * License along with Libav; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
-#include "config_bfin.h"
+
+#include "libavutil/bfin/asm.h"
 
 DEFUN(put_pixels_clamped,mL1,
         (int16_t *block, uint8_t *dest, int line_size)):
diff --git a/deps/libav/libavcodec/bfin/dsputil_bfin.c b/deps/libav/libavcodec/bfin/dsputil_bfin.c
deleted file mode 100644
index 3ce2941..0000000
--- a/deps/libav/libavcodec/bfin/dsputil_bfin.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * BlackFin DSPUTILS
- *
- * Copyright (C) 2007 Marc Hoffman <marc.hoffman at analog.com>
- * Copyright (c) 2006 Michael Benjamin <michael.benjamin at analog.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/attributes.h"
-#include "libavcodec/avcodec.h"
-#include "libavcodec/dsputil.h"
-#include "dsputil_bfin.h"
-
-int off;
-
-static void bfin_idct_add (uint8_t *dest, int line_size, int16_t *block)
-{
-    ff_bfin_idct (block);
-    ff_bfin_add_pixels_clamped (block, dest, line_size);
-}
-
-static void bfin_idct_put (uint8_t *dest, int line_size, int16_t *block)
-{
-    ff_bfin_idct (block);
-    ff_bfin_put_pixels_clamped (block, dest, line_size);
-}
-
-
-static void bfin_clear_blocks (int16_t *blocks)
-{
-    // This is just a simple memset.
-    //
-    __asm__("P0=192; "
-        "I0=%0;  "
-        "R0=0;   "
-        "LSETUP(clear_blocks_blkfn_lab,clear_blocks_blkfn_lab)LC0=P0;"
-        "clear_blocks_blkfn_lab:"
-        "[I0++]=R0;"
-        ::"a" (blocks):"P0","I0","R0");
-}
-
-static int bfin_pix_abs16 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
-{
-    return ff_bfin_z_sad16x16 (blk1,blk2,line_size,line_size,h);
-}
-
-static int bfin_vsad_intra16 (void *c, uint8_t *blk1, uint8_t *dummy, int stride, int h) {
-    return ff_bfin_z_sad16x16 (blk1,blk1+stride,stride<<1,stride<<1,h);
-}
-
-static int bfin_vsad (void *c, uint8_t *blk1, uint8_t *blk2, int stride, int h) {
-    return ff_bfin_z_sad16x16 (blk1,blk1+stride,stride<<1,stride<<1,h)
-        + ff_bfin_z_sad16x16 (blk2,blk2+stride,stride<<1,stride<<1,h);
-}
-
-static uint8_t vtmp_blk[256] attribute_l1_data_b;
-
-static int bfin_pix_abs16_x2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
-{
-    ff_bfin_put_pixels16uc (vtmp_blk, blk2, blk2+1, 16, line_size, h);
-    return ff_bfin_z_sad16x16 (blk1, vtmp_blk, line_size, 16, h);
-}
-
-static int bfin_pix_abs16_y2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
-{
-    ff_bfin_put_pixels16uc (vtmp_blk, blk2, blk2+line_size, 16, line_size, h);
-    return ff_bfin_z_sad16x16 (blk1, vtmp_blk, line_size, 16, h);
-}
-
-static int bfin_pix_abs16_xy2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
-{
-    ff_bfin_z_put_pixels16_xy2 (vtmp_blk, blk2, 16, line_size, h);
-    return ff_bfin_z_sad16x16 (blk1, vtmp_blk, line_size, 16, h);
-}
-
-static int bfin_pix_abs8 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
-{
-    return ff_bfin_z_sad8x8 (blk1,blk2,line_size,line_size, h);
-}
-
-static int bfin_pix_abs8_x2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
-{
-    ff_bfin_put_pixels8uc (vtmp_blk, blk2, blk2+1, 8, line_size, h);
-    return ff_bfin_z_sad8x8 (blk1, vtmp_blk, line_size, 8, h);
-}
-
-static int bfin_pix_abs8_y2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
-{
-    ff_bfin_put_pixels8uc (vtmp_blk, blk2, blk2+line_size, 8, line_size, h);
-    return ff_bfin_z_sad8x8 (blk1, vtmp_blk, line_size, 8, h);
-}
-
-static int bfin_pix_abs8_xy2 (void *c, uint8_t *blk1, uint8_t *blk2, int line_size, int h)
-{
-    ff_bfin_z_put_pixels8_xy2 (vtmp_blk, blk2, 8, line_size, h);
-    return ff_bfin_z_sad8x8 (blk1, vtmp_blk, line_size, 8, h);
-}
-
-
-/*
-  decoder optimization
-  start on 2/11 100 frames of 352x240 at 25 compiled with no optimization -g debugging
-  9.824s ~ 2.44x off
-  6.360s ~ 1.58x off with -O2
-  5.740s ~ 1.43x off with idcts
-
-  2.64s    2/20 same sman.mp4 decode only
-
-*/
-
-av_cold void ff_dsputil_init_bfin(DSPContext *c, AVCodecContext *avctx)
-{
-    const int high_bit_depth = avctx->bits_per_raw_sample > 8;
-
-    c->diff_pixels        = ff_bfin_diff_pixels;
-    c->put_pixels_clamped = ff_bfin_put_pixels_clamped;
-    c->add_pixels_clamped = ff_bfin_add_pixels_clamped;
-
-    if (!high_bit_depth)
-        c->get_pixels     = ff_bfin_get_pixels;
-    c->clear_blocks       = bfin_clear_blocks;
-    c->pix_sum            = ff_bfin_pix_sum;
-    c->pix_norm1          = ff_bfin_pix_norm1;
-
-    c->sad[0]             = bfin_pix_abs16;
-    c->sad[1]             = bfin_pix_abs8;
-
-/*     c->vsad[0]            = bfin_vsad; */
-/*     c->vsad[4]            = bfin_vsad_intra16; */
-
-    /* TODO [0] 16  [1] 8 */
-    c->pix_abs[0][0] = bfin_pix_abs16;
-    c->pix_abs[0][1] = bfin_pix_abs16_x2;
-    c->pix_abs[0][2] = bfin_pix_abs16_y2;
-    c->pix_abs[0][3] = bfin_pix_abs16_xy2;
-
-    c->pix_abs[1][0] = bfin_pix_abs8;
-    c->pix_abs[1][1] = bfin_pix_abs8_x2;
-    c->pix_abs[1][2] = bfin_pix_abs8_y2;
-    c->pix_abs[1][3] = bfin_pix_abs8_xy2;
-
-
-    c->sse[0] = ff_bfin_sse16;
-    c->sse[1] = ff_bfin_sse8;
-    c->sse[2] = ff_bfin_sse4;
-
-    if (avctx->bits_per_raw_sample <= 8) {
-        if (avctx->dct_algo == FF_DCT_AUTO)
-            c->fdct                  = ff_bfin_fdct;
-
-        if (avctx->idct_algo == FF_IDCT_AUTO) {
-            c->idct_permutation_type = FF_NO_IDCT_PERM;
-            c->idct                  = ff_bfin_idct;
-            c->idct_add              = bfin_idct_add;
-            c->idct_put              = bfin_idct_put;
-        }
-    }
-}
diff --git a/deps/libav/libavcodec/bfin/dsputil_bfin.h b/deps/libav/libavcodec/bfin/dsputil_bfin.h
deleted file mode 100644
index a082cd7..0000000
--- a/deps/libav/libavcodec/bfin/dsputil_bfin.h
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * BlackFin DSPUTILS COMMON OPTIMIZATIONS HEADER
- *
- * Copyright (C) 2007 Marc Hoffman <mmh at pleasantst.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-#ifndef AVCODEC_BFIN_DSPUTIL_BFIN_H
-#define AVCODEC_BFIN_DSPUTIL_BFIN_H
-
-#include <stdint.h>
-
-#include "config.h"
-
-#if defined(__FDPIC__) && CONFIG_SRAM
-#define attribute_l1_text  __attribute__ ((l1_text))
-#define attribute_l1_data_b __attribute__((l1_data_B))
-#else
-#define attribute_l1_text
-#define attribute_l1_data_b
-#endif
-
-void ff_bfin_idct (int16_t *block) attribute_l1_text;
-void ff_bfin_fdct (int16_t *block) attribute_l1_text;
-void ff_bfin_add_pixels_clamped (const int16_t *block, uint8_t *dest, int line_size) attribute_l1_text;
-void ff_bfin_put_pixels_clamped (const int16_t *block, uint8_t *dest, int line_size) attribute_l1_text;
-void ff_bfin_diff_pixels (int16_t *block, const uint8_t *s1, const uint8_t *s2, int stride)  attribute_l1_text;
-void ff_bfin_get_pixels  (int16_t *restrict block, const uint8_t *pixels, int line_size) attribute_l1_text;
-int  ff_bfin_pix_norm1  (uint8_t * pix, int line_size) attribute_l1_text;
-int  ff_bfin_z_sad8x8   (uint8_t *blk1, uint8_t *blk2, int dsz, int line_size, int h) attribute_l1_text;
-int  ff_bfin_z_sad16x16 (uint8_t *blk1, uint8_t *blk2, int dsz, int line_size, int h) attribute_l1_text;
-
-int  ff_bfin_pix_sum (uint8_t *p, int stride) attribute_l1_text;
-
-int ff_bfin_sse4  (void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) attribute_l1_text;
-int ff_bfin_sse8  (void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) attribute_l1_text;
-int ff_bfin_sse16 (void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h) attribute_l1_text;
-
-
-#ifdef BFIN_PROFILE
-
-static double Telem[16];
-static char  *TelemNames[16];
-static int    TelemCnt;
-
-#define PROF(lab,e) { int xx_e = e; char*xx_lab = lab; uint64_t xx_t0 = read_time();
-#define EPROF()       xx_t0 = read_time()-xx_t0; Telem[xx_e] = Telem[xx_e] + xx_t0; TelemNames[xx_e] = xx_lab; }
-
-static void prof_report (void)
-{
-    int i;
-    double s = 0;
-    for (i=0;i<16;i++) {
-        double v;
-        if (TelemNames[i]) {
-            v = Telem[i]/TelemCnt;
-            av_log (NULL,AV_LOG_DEBUG,"%-20s: %12.4f\t%12.4f\n", TelemNames[i],v,v/64);
-            s = s + Telem[i];
-        }
-    }
-    av_log (NULL,AV_LOG_DEBUG,"%-20s: %12.4f\t%12.4f\n%20.4f\t%d\n",
-            "total",s/TelemCnt,s/TelemCnt/64,s,TelemCnt);
-}
-
-static void bfprof (void)
-{
-    static int init;
-    if (!init) atexit (prof_report);
-    init=1;
-    TelemCnt++;
-}
-
-#else
-#define PROF(a,b)
-#define EPROF()
-#define bfprof()
-#endif
-
-#endif /* AVCODEC_BFIN_DSPUTIL_BFIN_H */
diff --git a/deps/libav/libavcodec/bfin/dsputil_init.c b/deps/libav/libavcodec/bfin/dsputil_init.c
new file mode 100644
index 0000000..7a214a3
--- /dev/null
+++ b/deps/libav/libavcodec/bfin/dsputil_init.c
@@ -0,0 +1,196 @@
+/*
+ * BlackFin DSPUTILS
+ *
+ * Copyright (C) 2007 Marc Hoffman <marc.hoffman at analog.com>
+ * Copyright (c) 2006 Michael Benjamin <michael.benjamin at analog.com>
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stdint.h>
+
+#include "config.h"
+#include "libavutil/attributes.h"
+#include "libavutil/bfin/attributes.h"
+#include "libavcodec/avcodec.h"
+#include "libavcodec/dsputil.h"
+
+void ff_bfin_idct(int16_t *block) attribute_l1_text;
+void ff_bfin_fdct(int16_t *block) attribute_l1_text;
+
+void ff_bfin_add_pixels_clamped(const int16_t *block, uint8_t *dest,
+                                int line_size) attribute_l1_text;
+void ff_bfin_put_pixels_clamped(const int16_t *block, uint8_t *dest,
+                                int line_size) attribute_l1_text;
+
+void ff_bfin_diff_pixels(int16_t *block, const uint8_t *s1, const uint8_t *s2,
+                         int stride)  attribute_l1_text;
+void ff_bfin_get_pixels(int16_t *restrict block, const uint8_t *pixels,
+                        int line_size) attribute_l1_text;
+
+int ff_bfin_pix_norm1(uint8_t *pix, int line_size) attribute_l1_text;
+int ff_bfin_pix_sum(uint8_t *p, int stride) attribute_l1_text;
+
+int ff_bfin_z_sad8x8(uint8_t *blk1, uint8_t *blk2, int dsz,
+                     int line_size, int h) attribute_l1_text;
+int ff_bfin_z_sad16x16(uint8_t *blk1, uint8_t *blk2, int dsz,
+                       int line_size, int h) attribute_l1_text;
+
+int ff_bfin_sse4(void *v, uint8_t *pix1, uint8_t *pix2,
+                 int line_size, int h) attribute_l1_text;
+int ff_bfin_sse8(void *v, uint8_t *pix1, uint8_t *pix2,
+                 int line_size, int h) attribute_l1_text;
+int ff_bfin_sse16(void *v, uint8_t *pix1, uint8_t *pix2,
+                  int line_size, int h) attribute_l1_text;
+
+static void bfin_idct_add(uint8_t *dest, int line_size, int16_t *block)
+{
+    ff_bfin_idct(block);
+    ff_bfin_add_pixels_clamped(block, dest, line_size);
+}
+
+static void bfin_idct_put(uint8_t *dest, int line_size, int16_t *block)
+{
+    ff_bfin_idct(block);
+    ff_bfin_put_pixels_clamped(block, dest, line_size);
+}
+
+static void bfin_clear_blocks(int16_t *blocks)
+{
+    // This is just a simple memset.
+    __asm__ ("P0=192; "
+             "I0=%0;  "
+             "R0=0;   "
+             "LSETUP(clear_blocks_blkfn_lab,clear_blocks_blkfn_lab)LC0=P0;"
+             "clear_blocks_blkfn_lab:"
+             "[I0++]=R0;"
+             ::"a" (blocks) : "P0", "I0", "R0");
+}
+
+static int bfin_pix_abs16(void *c, uint8_t *blk1, uint8_t *blk2,
+                          int line_size, int h)
+{
+    return ff_bfin_z_sad16x16(blk1, blk2, line_size, line_size, h);
+}
+
+static uint8_t vtmp_blk[256] attribute_l1_data_b;
+
+static int bfin_pix_abs16_x2(void *c, uint8_t *blk1, uint8_t *blk2,
+                             int line_size, int h)
+{
+    ff_bfin_put_pixels16uc(vtmp_blk, blk2, blk2 + 1, 16, line_size, h);
+    return ff_bfin_z_sad16x16(blk1, vtmp_blk, line_size, 16, h);
+}
+
+static int bfin_pix_abs16_y2(void *c, uint8_t *blk1, uint8_t *blk2,
+                             int line_size, int h)
+{
+    ff_bfin_put_pixels16uc(vtmp_blk, blk2, blk2 + line_size, 16, line_size, h);
+    return ff_bfin_z_sad16x16(blk1, vtmp_blk, line_size, 16, h);
+}
+
+static int bfin_pix_abs16_xy2(void *c, uint8_t *blk1, uint8_t *blk2,
+                              int line_size, int h)
+{
+    ff_bfin_z_put_pixels16_xy2(vtmp_blk, blk2, 16, line_size, h);
+    return ff_bfin_z_sad16x16(blk1, vtmp_blk, line_size, 16, h);
+}
+
+static int bfin_pix_abs8(void *c, uint8_t *blk1, uint8_t *blk2,
+                         int line_size, int h)
+{
+    return ff_bfin_z_sad8x8(blk1, blk2, line_size, line_size, h);
+}
+
+static int bfin_pix_abs8_x2(void *c, uint8_t *blk1, uint8_t *blk2,
+                            int line_size, int h)
+{
+    ff_bfin_put_pixels8uc(vtmp_blk, blk2, blk2 + 1, 8, line_size, h);
+    return ff_bfin_z_sad8x8(blk1, vtmp_blk, line_size, 8, h);
+}
+
+static int bfin_pix_abs8_y2(void *c, uint8_t *blk1, uint8_t *blk2,
+                            int line_size, int h)
+{
+    ff_bfin_put_pixels8uc(vtmp_blk, blk2, blk2 + line_size, 8, line_size, h);
+    return ff_bfin_z_sad8x8(blk1, vtmp_blk, line_size, 8, h);
+}
+
+static int bfin_pix_abs8_xy2(void *c, uint8_t *blk1, uint8_t *blk2,
+                             int line_size, int h)
+{
+    ff_bfin_z_put_pixels8_xy2(vtmp_blk, blk2, 8, line_size, h);
+    return ff_bfin_z_sad8x8(blk1, vtmp_blk, line_size, 8, h);
+}
+
+/*
+ * decoder optimization
+ * start on 2/11 100 frames of 352x240 at 25 compiled with no optimization -g debugging
+ * 9.824s ~ 2.44x off
+ * 6.360s ~ 1.58x off with -O2
+ * 5.740s ~ 1.43x off with idcts
+ *
+ * 2.64s    2/20 same sman.mp4 decode only
+ */
+
+av_cold void ff_dsputil_init_bfin(DSPContext *c, AVCodecContext *avctx)
+{
+    const int high_bit_depth = avctx->bits_per_raw_sample > 8;
+
+    c->diff_pixels = ff_bfin_diff_pixels;
+
+    c->put_pixels_clamped = ff_bfin_put_pixels_clamped;
+    c->add_pixels_clamped = ff_bfin_add_pixels_clamped;
+
+    if (!high_bit_depth)
+        c->get_pixels = ff_bfin_get_pixels;
+
+    c->clear_blocks = bfin_clear_blocks;
+
+    c->pix_sum   = ff_bfin_pix_sum;
+    c->pix_norm1 = ff_bfin_pix_norm1;
+
+    c->sad[0] = bfin_pix_abs16;
+    c->sad[1] = bfin_pix_abs8;
+
+    /* TODO [0] 16  [1] 8 */
+    c->pix_abs[0][0] = bfin_pix_abs16;
+    c->pix_abs[0][1] = bfin_pix_abs16_x2;
+    c->pix_abs[0][2] = bfin_pix_abs16_y2;
+    c->pix_abs[0][3] = bfin_pix_abs16_xy2;
+
+    c->pix_abs[1][0] = bfin_pix_abs8;
+    c->pix_abs[1][1] = bfin_pix_abs8_x2;
+    c->pix_abs[1][2] = bfin_pix_abs8_y2;
+    c->pix_abs[1][3] = bfin_pix_abs8_xy2;
+
+    c->sse[0] = ff_bfin_sse16;
+    c->sse[1] = ff_bfin_sse8;
+    c->sse[2] = ff_bfin_sse4;
+
+    if (avctx->bits_per_raw_sample <= 8) {
+        if (avctx->dct_algo == FF_DCT_AUTO)
+            c->fdct = ff_bfin_fdct;
+
+        if (avctx->idct_algo == FF_IDCT_AUTO) {
+            c->idct_permutation_type = FF_NO_IDCT_PERM;
+            c->idct                  = ff_bfin_idct;
+            c->idct_add              = bfin_idct_add;
+            c->idct_put              = bfin_idct_put;
+        }
+    }
+}
diff --git a/deps/libav/libavcodec/bfin/fdct_bfin.S b/deps/libav/libavcodec/bfin/fdct_bfin.S
index c923d76..2525e0d 100644
--- a/deps/libav/libavcodec/bfin/fdct_bfin.S
+++ b/deps/libav/libavcodec/bfin/fdct_bfin.S
@@ -125,21 +125,16 @@ DCT BFINfdct: err_inf=2 err2=0.16425938 syserr=0.00795000 maxout=2098 blockSumEr
 DCT BFINfdct: 92.1 kdct/s
 */
 
-#include "config.h"
-#include "config_bfin.h"
-
-#if defined(__FDPIC__) && CONFIG_SRAM
-.section .l1.data.B,"aw", at progbits
-#else
-.data
-#endif
+#include "libavutil/bfin/asm.h"
+
+SECTION_L1_DATA_B
+
 .align 4;
 dct_coeff:
 .short 0x5a82, 0x2d41, 0x187e, 0x3b21, 0x0c7c, 0x3ec5, 0x238e, 0x3537;
 
-#if defined(__FDPIC__) && CONFIG_SRAM
-.section .l1.data.A,"aw", at progbits
-#endif
+SECTION_L1_DATA_A
+
 .align 4
 vtmp:   .space 128
 
diff --git a/deps/libav/libavcodec/bfin/hpel_pixels_no_rnd.S b/deps/libav/libavcodec/bfin/hpel_pixels_no_rnd.S
new file mode 100644
index 0000000..0d838ea
--- /dev/null
+++ b/deps/libav/libavcodec/bfin/hpel_pixels_no_rnd.S
@@ -0,0 +1,81 @@
+/*
+ * Blackfin Pixel Operations
+ * Copyright (C) 2007 Marc Hoffman <marc.hoffman at analog.com>
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/bfin/asm.h"
+
+DEFUN(put_pixels8uc_no_rnd,mL1,
+        (uint8_t *block, const uint8_t *s0, const uint8_t *s1,
+                 int line_size, int h)):
+        i3=r0;        // dest
+        i0=r1;        // src0
+        i1=r2;        // src1
+        r2=[sp+12];   // line_size
+        p0=[sp+16];   // h
+        [--sp] = (r7:6);
+        r2+=-4;
+        m3=r2;
+        r2+=-4;
+        m0=r2;
+        LSETUP(pp8$2,pp8$3) LC0=P0;
+        DISALGNEXCPT                || R0 = [I0++]  || R2  =[I1++];
+
+pp8$2:  DISALGNEXCPT                || R1 = [I0++]  || R3  =[I1++];
+        R6 = BYTEOP1P(R1:0,R3:2)(T)  || R0 = [I0++M0]|| R2  =[I1++M0];
+        R7 = BYTEOP1P(R1:0,R3:2)(T,R) || R0 = [I0++]  || [I3++] = R6 ;
+pp8$3:  DISALGNEXCPT                || R2 = [I1++]  || [I3++M3] = R7;
+
+        (r7:6) = [sp++];
+        RTS;
+DEFUN_END(put_pixels8uc_no_rnd)
+
+DEFUN(put_pixels16uc_no_rnd,mL1,
+        (uint8_t *block, const uint8_t *s0, const uint8_t *s1,
+                 int line_size, int h)):
+        i3=r0;        // dest
+        i0=r1;        // src0
+        i1=r2;        // src1
+        r2=[sp+12];   // line_size
+        p0=[sp+16];   // h
+
+        [--sp] = (r7:6);
+        r2+=-12;
+        m3=r2;        // line_size
+        r2+=-4;
+        m0=r2;
+
+        LSETUP(pp16$2,pp16$3) LC0=P0;
+        DISALGNEXCPT                || R0 = [I0++]   || R2  =[I1++];
+
+pp16$2:
+        DISALGNEXCPT                || R1 = [I0++]   || R3  =[I1++];
+        R6 = BYTEOP1P(R1:0,R3:2)(T)    || R0 = [I0++]   || R2  =[I1++];
+        R7 = BYTEOP1P(R1:0,R3:2)(T,R) || R1 = [I0++]   || R3  =[I1++];
+        [I3++] = R6;
+
+        R6 = BYTEOP1P(R1:0,R3:2)(T)    || R0 = [I0++M0] || R2  =[I1++M0];
+        R7 = BYTEOP1P(R1:0,R3:2)(T,R) || R0 = [I0++]   || [I3++] = R7 ;
+        [I3++] = R6;
+pp16$3: DISALGNEXCPT                || R2 = [I1++]   || [I3++M3] = R7;
+
+        (r7:6) = [sp++];
+
+        RTS;
+DEFUN_END(put_pixels16uc_no_rnd)
diff --git a/deps/libav/libavcodec/bfin/hpeldsp_bfin.c b/deps/libav/libavcodec/bfin/hpeldsp_bfin.c
deleted file mode 100644
index cecb1db..0000000
--- a/deps/libav/libavcodec/bfin/hpeldsp_bfin.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * BlackFin DSPUTILS
- *
- * Copyright (C) 2007 Marc Hoffman <marc.hoffman at analog.com>
- * Copyright (c) 2006 Michael Benjamin <michael.benjamin at analog.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include "libavutil/attributes.h"
-#include "libavcodec/hpeldsp.h"
-#include "hpeldsp_bfin.h"
-
-static void bfin_put_pixels8 (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
-    ff_bfin_put_pixels8uc (block, pixels, pixels, line_size, line_size, h);
-}
-
-static void bfin_put_pixels8_x2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
-    ff_bfin_put_pixels8uc (block, pixels, pixels+1, line_size, line_size, h);
-}
-
-static void bfin_put_pixels8_y2 (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
-    ff_bfin_put_pixels8uc (block, pixels, pixels+line_size, line_size, line_size, h);
-}
-
-static void bfin_put_pixels8_xy2 (uint8_t *block, const uint8_t *s0, ptrdiff_t line_size, int h)
-{
-    ff_bfin_z_put_pixels8_xy2 (block,s0,line_size, line_size, h);
-}
-
-static void bfin_put_pixels16 (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
-    ff_bfin_put_pixels16uc (block, pixels, pixels, line_size, line_size, h);
-}
-
-static void bfin_put_pixels16_x2 (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
-    ff_bfin_put_pixels16uc (block, pixels, pixels+1, line_size, line_size, h);
-}
-
-static void bfin_put_pixels16_y2 (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
-    ff_bfin_put_pixels16uc (block, pixels, pixels+line_size, line_size, line_size, h);
-}
-
-static void bfin_put_pixels16_xy2 (uint8_t *block, const uint8_t *s0, ptrdiff_t line_size, int h)
-{
-    ff_bfin_z_put_pixels16_xy2 (block,s0,line_size, line_size, h);
-}
-
-static void bfin_put_pixels8_nornd (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
-    ff_bfin_put_pixels8uc_nornd (block, pixels, pixels, line_size, h);
-}
-
-static void bfin_put_pixels8_x2_nornd (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
-    ff_bfin_put_pixels8uc_nornd (block, pixels, pixels+1, line_size, h);
-}
-
-static void bfin_put_pixels8_y2_nornd (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
-    ff_bfin_put_pixels8uc_nornd (block, pixels, pixels+line_size, line_size, h);
-}
-
-
-static void bfin_put_pixels16_nornd (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
-    ff_bfin_put_pixels16uc_nornd (block, pixels, pixels, line_size, h);
-}
-
-static void bfin_put_pixels16_x2_nornd (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
-    ff_bfin_put_pixels16uc_nornd (block, pixels, pixels+1, line_size, h);
-}
-
-static void bfin_put_pixels16_y2_nornd (uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
-{
-    ff_bfin_put_pixels16uc_nornd (block, pixels, pixels+line_size, line_size, h);
-}
-
-av_cold void ff_hpeldsp_init_bfin(HpelDSPContext *c, int flags)
-{
-    c->put_pixels_tab[0][0] = bfin_put_pixels16;
-    c->put_pixels_tab[0][1] = bfin_put_pixels16_x2;
-    c->put_pixels_tab[0][2] = bfin_put_pixels16_y2;
-    c->put_pixels_tab[0][3] = bfin_put_pixels16_xy2;
-
-    c->put_pixels_tab[1][0] = bfin_put_pixels8;
-    c->put_pixels_tab[1][1] = bfin_put_pixels8_x2;
-    c->put_pixels_tab[1][2] = bfin_put_pixels8_y2;
-    c->put_pixels_tab[1][3] = bfin_put_pixels8_xy2;
-
-    c->put_no_rnd_pixels_tab[1][0] = bfin_put_pixels8_nornd;
-    c->put_no_rnd_pixels_tab[1][1] = bfin_put_pixels8_x2_nornd;
-    c->put_no_rnd_pixels_tab[1][2] = bfin_put_pixels8_y2_nornd;
-/*     c->put_no_rnd_pixels_tab[1][3] = ff_bfin_put_pixels8_xy2_nornd; */
-
-    c->put_no_rnd_pixels_tab[0][0] = bfin_put_pixels16_nornd;
-    c->put_no_rnd_pixels_tab[0][1] = bfin_put_pixels16_x2_nornd;
-    c->put_no_rnd_pixels_tab[0][2] = bfin_put_pixels16_y2_nornd;
-/*     c->put_no_rnd_pixels_tab[0][3] = ff_bfin_put_pixels16_xy2_nornd; */
-}
diff --git a/deps/libav/libavcodec/bfin/hpeldsp_bfin.h b/deps/libav/libavcodec/bfin/hpeldsp_bfin.h
deleted file mode 100644
index 2de16f7..0000000
--- a/deps/libav/libavcodec/bfin/hpeldsp_bfin.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Copyright (C) 2007 Marc Hoffman <mmh at pleasantst.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_BFIN_HPELDSP_BFIN_H
-#define AVCODEC_BFIN_HPELDSP_BFIN_H
-
-#include <stdint.h>
-
-#include "config.h"
-
-#if defined(__FDPIC__) && CONFIG_SRAM
-#define attribute_l1_text  __attribute__ ((l1_text))
-#define attribute_l1_data_b __attribute__((l1_data_B))
-#else
-#define attribute_l1_text
-#define attribute_l1_data_b
-#endif
-
-void ff_bfin_z_put_pixels16_xy2     (uint8_t *block, const uint8_t *s0, int dest_size, int line_size, int h) attribute_l1_text;
-void ff_bfin_z_put_pixels8_xy2      (uint8_t *block, const uint8_t *s0, int dest_size, int line_size, int h) attribute_l1_text;
-void ff_bfin_put_pixels16_xy2_nornd (uint8_t *block, const uint8_t *s0, int line_size, int h) attribute_l1_text;
-void ff_bfin_put_pixels8_xy2_nornd  (uint8_t *block, const uint8_t *s0, int line_size, int h) attribute_l1_text;
-
-
-void ff_bfin_put_pixels8uc        (uint8_t *block, const uint8_t *s0, const uint8_t *s1, int dest_size, int line_size, int h) attribute_l1_text;
-void ff_bfin_put_pixels16uc       (uint8_t *block, const uint8_t *s0, const uint8_t *s1, int dest_size, int line_size, int h) attribute_l1_text;
-void ff_bfin_put_pixels8uc_nornd  (uint8_t *block, const uint8_t *s0, const uint8_t *s1, int line_size, int h) attribute_l1_text;
-void ff_bfin_put_pixels16uc_nornd (uint8_t *block, const uint8_t *s0, const uint8_t *s1, int line_size, int h) attribute_l1_text;
-
-#endif /* AVCODEC_BFIN_HPELDSP_BFIN_H */
diff --git a/deps/libav/libavcodec/bfin/hpeldsp_init.c b/deps/libav/libavcodec/bfin/hpeldsp_init.c
new file mode 100644
index 0000000..9eb45e0
--- /dev/null
+++ b/deps/libav/libavcodec/bfin/hpeldsp_init.c
@@ -0,0 +1,146 @@
+/*
+ * BlackFin halfpel functions
+ *
+ * Copyright (C) 2007 Marc Hoffman <marc.hoffman at analog.com>
+ * Copyright (c) 2006 Michael Benjamin <michael.benjamin at analog.com>
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include "libavutil/attributes.h"
+#include "libavutil/bfin/attributes.h"
+#include "libavcodec/hpeldsp.h"
+#include "pixels.h"
+
+void ff_bfin_put_pixels8uc_no_rnd(uint8_t *block, const uint8_t *s0,
+                                  const uint8_t *s1, int line_size,
+                                  int h) attribute_l1_text;
+void ff_bfin_put_pixels16uc_no_rnd(uint8_t *block, const uint8_t *s0,
+                                   const uint8_t *s1, int line_size,
+                                   int h) attribute_l1_text;
+
+static void bfin_put_pixels8(uint8_t *block, const uint8_t *pixels,
+                             ptrdiff_t line_size, int h)
+{
+    ff_bfin_put_pixels8uc(block, pixels, pixels, line_size, line_size, h);
+}
+
+static void bfin_put_pixels8_x2(uint8_t *block, const uint8_t *pixels,
+                                ptrdiff_t line_size, int h)
+{
+    ff_bfin_put_pixels8uc(block, pixels, pixels + 1, line_size, line_size, h);
+}
+
+static void bfin_put_pixels8_y2(uint8_t *block, const uint8_t *pixels,
+                                ptrdiff_t line_size, int h)
+{
+    ff_bfin_put_pixels8uc(block, pixels, pixels + line_size,
+                          line_size, line_size, h);
+}
+
+static void bfin_put_pixels8_xy2(uint8_t *block, const uint8_t *s0,
+                                 ptrdiff_t line_size, int h)
+{
+    ff_bfin_z_put_pixels8_xy2(block, s0, line_size, line_size, h);
+}
+
+static void bfin_put_pixels16(uint8_t *block, const uint8_t *pixels,
+                              ptrdiff_t line_size, int h)
+{
+    ff_bfin_put_pixels16uc(block, pixels, pixels, line_size, line_size, h);
+}
+
+static void bfin_put_pixels16_x2(uint8_t *block, const uint8_t *pixels,
+                                 ptrdiff_t line_size, int h)
+{
+    ff_bfin_put_pixels16uc(block, pixels, pixels + 1, line_size, line_size, h);
+}
+
+static void bfin_put_pixels16_y2(uint8_t *block, const uint8_t *pixels,
+                                 ptrdiff_t line_size, int h)
+{
+    ff_bfin_put_pixels16uc(block, pixels, pixels + line_size,
+                           line_size, line_size, h);
+}
+
+static void bfin_put_pixels16_xy2(uint8_t *block, const uint8_t *s0,
+                                  ptrdiff_t line_size, int h)
+{
+    ff_bfin_z_put_pixels16_xy2(block, s0, line_size, line_size, h);
+}
+
+static void bfin_put_pixels8_no_rnd(uint8_t *block, const uint8_t *pixels,
+                                    ptrdiff_t line_size, int h)
+{
+    ff_bfin_put_pixels8uc_no_rnd(block, pixels, pixels, line_size, h);
+}
+
+static void bfin_put_pixels8_x2_no_rnd(uint8_t *block, const uint8_t *pixels,
+                                       ptrdiff_t line_size, int h)
+{
+    ff_bfin_put_pixels8uc_no_rnd(block, pixels, pixels + 1, line_size, h);
+}
+
+static void bfin_put_pixels8_y2_no_rnd(uint8_t *block, const uint8_t *pixels,
+                                       ptrdiff_t line_size, int h)
+{
+    ff_bfin_put_pixels8uc_no_rnd(block, pixels, pixels + line_size,
+                                 line_size, h);
+}
+
+static void bfin_put_pixels16_no_rnd(uint8_t *block, const uint8_t *pixels,
+                                     ptrdiff_t line_size, int h)
+{
+    ff_bfin_put_pixels16uc_no_rnd(block, pixels, pixels, line_size, h);
+}
+
+static void bfin_put_pixels16_x2_no_rnd(uint8_t *block, const uint8_t *pixels,
+                                        ptrdiff_t line_size, int h)
+{
+    ff_bfin_put_pixels16uc_no_rnd(block, pixels, pixels + 1, line_size, h);
+}
+
+static void bfin_put_pixels16_y2_no_rnd(uint8_t *block, const uint8_t *pixels,
+                                        ptrdiff_t line_size, int h)
+{
+    ff_bfin_put_pixels16uc_no_rnd(block, pixels, pixels + line_size,
+                                  line_size, h);
+}
+
+av_cold void ff_hpeldsp_init_bfin(HpelDSPContext *c, int flags)
+{
+    c->put_pixels_tab[0][0] = bfin_put_pixels16;
+    c->put_pixels_tab[0][1] = bfin_put_pixels16_x2;
+    c->put_pixels_tab[0][2] = bfin_put_pixels16_y2;
+    c->put_pixels_tab[0][3] = bfin_put_pixels16_xy2;
+
+    c->put_pixels_tab[1][0] = bfin_put_pixels8;
+    c->put_pixels_tab[1][1] = bfin_put_pixels8_x2;
+    c->put_pixels_tab[1][2] = bfin_put_pixels8_y2;
+    c->put_pixels_tab[1][3] = bfin_put_pixels8_xy2;
+
+    c->put_no_rnd_pixels_tab[1][0] = bfin_put_pixels8_no_rnd;
+    c->put_no_rnd_pixels_tab[1][1] = bfin_put_pixels8_x2_no_rnd;
+    c->put_no_rnd_pixels_tab[1][2] = bfin_put_pixels8_y2_no_rnd;
+
+    c->put_no_rnd_pixels_tab[0][0] = bfin_put_pixels16_no_rnd;
+    c->put_no_rnd_pixels_tab[0][1] = bfin_put_pixels16_x2_no_rnd;
+    c->put_no_rnd_pixels_tab[0][2] = bfin_put_pixels16_y2_no_rnd;
+}
diff --git a/deps/libav/libavcodec/bfin/idct_bfin.S b/deps/libav/libavcodec/bfin/idct_bfin.S
index 0eeffc2..dd427e7 100644
--- a/deps/libav/libavcodec/bfin/idct_bfin.S
+++ b/deps/libav/libavcodec/bfin/idct_bfin.S
@@ -55,14 +55,9 @@ IDCT BFINidct: 88.3 kdct/s
 
 */
 
-#include "config.h"
-#include "config_bfin.h"
+#include "libavutil/bfin/asm.h"
 
-#if defined(__FDPIC__) && CONFIG_SRAM
-.section .l1.data.B,"aw", at progbits
-#else
-.data
-#endif
+SECTION_L1_DATA_B
 
 .align 4;
 coefs:
@@ -77,9 +72,7 @@ coefs:
 .short 0x18F9;           //cos(7pi/16)
 .short 0x7D8A;           //cos(pi/16)
 
-#if defined(__FDPIC__) && CONFIG_SRAM
-.section .l1.data.A,"aw", at progbits
-#endif
+SECTION_L1_DATA_A
 
 vtmp: .space 256
 
diff --git a/deps/libav/libavcodec/bfin/hpel_pixels_bfin.S b/deps/libav/libavcodec/bfin/pixels.S
similarity index 55%
rename from deps/libav/libavcodec/bfin/hpel_pixels_bfin.S
rename to deps/libav/libavcodec/bfin/pixels.S
index 9b927b0..289aa2c 100644
--- a/deps/libav/libavcodec/bfin/hpel_pixels_bfin.S
+++ b/deps/libav/libavcodec/bfin/pixels.S
@@ -19,7 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "config_bfin.h"
+#include "libavutil/bfin/asm.h"
 
 /*
   motion compensation
@@ -97,70 +97,6 @@ pp16$1:  DISALGNEXCPT                || R2 = [I1++]   || [I3++M3] = R7;
         RTS;
 DEFUN_END(put_pixels16uc)
 
-
-
-
-
-
-DEFUN(put_pixels8uc_nornd,mL1,
-        (uint8_t *block, const uint8_t *s0, const uint8_t *s1,
-                 int line_size, int h)):
-        i3=r0;        // dest
-        i0=r1;        // src0
-        i1=r2;        // src1
-        r2=[sp+12];   // line_size
-        p0=[sp+16];   // h
-        [--sp] = (r7:6);
-        r2+=-4;
-        m3=r2;
-        r2+=-4;
-        m0=r2;
-        LSETUP(pp8$2,pp8$3) LC0=P0;
-        DISALGNEXCPT                || R0 = [I0++]  || R2  =[I1++];
-
-pp8$2:  DISALGNEXCPT                || R1 = [I0++]  || R3  =[I1++];
-        R6 = BYTEOP1P(R1:0,R3:2)(T)  || R0 = [I0++M0]|| R2  =[I1++M0];
-        R7 = BYTEOP1P(R1:0,R3:2)(T,R) || R0 = [I0++]  || [I3++] = R6 ;
-pp8$3:  DISALGNEXCPT                || R2 = [I1++]  || [I3++M3] = R7;
-
-        (r7:6) = [sp++];
-        RTS;
-DEFUN_END(put_pixels8uc_nornd)
-
-DEFUN(put_pixels16uc_nornd,mL1,
-        (uint8_t *block, const uint8_t *s0, const uint8_t *s1,
-                 int line_size, int h)):
-        i3=r0;        // dest
-        i0=r1;        // src0
-        i1=r2;        // src1
-        r2=[sp+12];   // line_size
-        p0=[sp+16];   // h
-
-        [--sp] = (r7:6);
-        r2+=-12;
-        m3=r2;        // line_size
-        r2+=-4;
-        m0=r2;
-
-        LSETUP(pp16$2,pp16$3) LC0=P0;
-        DISALGNEXCPT                || R0 = [I0++]   || R2  =[I1++];
-
-pp16$2:
-        DISALGNEXCPT                || R1 = [I0++]   || R3  =[I1++];
-        R6 = BYTEOP1P(R1:0,R3:2)(T)    || R0 = [I0++]   || R2  =[I1++];
-        R7 = BYTEOP1P(R1:0,R3:2)(T,R) || R1 = [I0++]   || R3  =[I1++];
-        [I3++] = R6;
-
-        R6 = BYTEOP1P(R1:0,R3:2)(T)    || R0 = [I0++M0] || R2  =[I1++M0];
-        R7 = BYTEOP1P(R1:0,R3:2)(T,R) || R0 = [I0++]   || [I3++] = R7 ;
-        [I3++] = R6;
-pp16$3: DISALGNEXCPT                || R2 = [I1++]   || [I3++M3] = R7;
-
-        (r7:6) = [sp++];
-
-        RTS;
-DEFUN_END(put_pixels16uc_nornd)
-
 DEFUN(z_put_pixels16_xy2,mL1,
         (uint8_t *block, const uint8_t *s0,
                  int dest_size, int line_size, int h)):
@@ -220,64 +156,6 @@ LE$16O: DISALGNEXCPT                       || R2 = [I1++] || [I3++M2] = R5;
         rts;
 DEFUN_END(z_put_pixels16_xy2)
 
-DEFUN(put_pixels16_xy2_nornd,mL1,
-        (uint8_t *block, const uint8_t *s0,
-                 int line_size, int h)):
-        link 0;
-        [--sp] = (r7:4);
-        i3=r0;        // dest
-        i0=r1;        // src0--> pixels
-        i1=r1;        // src1--> pixels + line_size
-        m3=r2;
-        r2+=-12;
-        m2=r2;
-        r2+=-4;
-        i1+=m3;       /* src1 + line_size */
-        m0=r2;        /* line-size - 20 */
-        p0=[fp+20];   // h
-
-        B0=I0;
-        B1=I1;
-        B3=I3;
-
-        DISALGNEXCPT                       || R0 = [I0++] || R2  =[I1++];
-
-        LSETUP(LS$16ET,LE$16ET) LC0=P0;
-LS$16ET:DISALGNEXCPT                       || R1 = [I0++] || R3  =[I1++];
-        R4 = BYTEOP2P (R3:2,R1:0) (TL)     || R0 = [I0++] || R2  =[I1++];
-        R5 = BYTEOP2P (R3:2,R1:0) (TL,R)   || R1 = [I0++] || [I3++] = R4 ;
-        DISALGNEXCPT                       || R3 = [I1++] || [I3++] = R5;
-        R4 = BYTEOP2P (R3:2,R1:0) (TL)     || R0 = [I0++M0]|| R2  = [I1++M0];
-        R5 = BYTEOP2P (R3:2,R1:0) (TL,R)   || R0 = [I0++] || [I3++] = R4 ;
-LE$16ET:DISALGNEXCPT                       || R2 = [I1++] || [I3++M2] = R5;
-
-        M1 = 1;
-        I3=B3;
-        I1=B1;
-        I0=B0;
-
-        I0 += M1;
-        I1 += M1;
-
-        DISALGNEXCPT                       || R0 = [I0++] || R2  =[I1++];
-        LSETUP(LS$16OT,LE$16OT) LC0=P0;
-LS$16OT:DISALGNEXCPT                       || R1 = [I0++] || R3  =[I1++];
-        R4 = BYTEOP2P (R3:2,R1:0) (TH)     || R0 = [I0++] || R2  =[I1++];
-        R5 = BYTEOP2P (R3:2,R1:0) (TH,R)   || R1 = [I0++] || R6  =[I3++];
-        R4 = R4 +|+ R6                                    || R7 = [I3--];
-        R5 = R5 +|+ R7                                    || [I3++] = R4;
-        DISALGNEXCPT                       || R3  =[I1++] || [I3++] = R5;
-        R4 = BYTEOP2P (R3:2,R1:0) (TH)     || R0 = [I0++M0]|| R2  = [I1++M0];
-        R5 = BYTEOP2P (R3:2,R1:0) (TH,R)   || R0 = [I0++] || R6 = [I3++];
-        R4 = R4 +|+ R6                                    || R7 = [I3--];
-        R5 = R5 +|+ R7                                    || [I3++] = R4;
-LE$16OT:DISALGNEXCPT                       || R2 = [I1++] || [I3++M2] = R5;
-
-        (r7:4) = [sp++];
-        unlink;
-        rts;
-DEFUN_END(put_pixels16_xy2_nornd)
-
 DEFUN(z_put_pixels8_xy2,mL1,
         (uint8_t *block, const uint8_t *s0,
                  int dest_size, int line_size, int h)):
@@ -327,54 +205,3 @@ LE$8O:  DISALGNEXCPT                       || R2  =[I1++]   || [I3++M2] = R5;
         unlink;
         rts;
 DEFUN_END(z_put_pixels8_xy2)
-
-DEFUN(put_pixels8_xy2_nornd,mL1,
-        (uint8_t *block, const uint8_t *s0, int line_size, int h)):
-        link 0;
-        [--sp] = (r7:4);
-        i3=r0;        // dest
-        i0=r1;        // src0--> pixels
-        i1=r1;        // src1--> pixels + line_size
-        m3=r2;
-        r2+=-4;
-        m2=r2;
-        r2+=-4;
-        i1+=m3;       /* src1 + line_size */
-        m0=r2;        /* line-size - 20 */
-        p0=[fp+20];   // h
-
-
-        b0 = I0;
-        b1 = I1;
-        b3 = I3;
-
-        LSETUP(LS$8ET,LE$8ET) LC0=P0;
-        DISALGNEXCPT                       || R0 = [I0++]   || R2  =[I1++];
-
-LS$8ET: DISALGNEXCPT                       || R1 = [I0++]   || R3 = [I1++];
-        R4 = BYTEOP2P (R3:2,R1:0) (TL)     || R0 = [I0++M0] || R2 = [I1++M0];
-        R5 = BYTEOP2P (R3:2,R1:0) (TL,R)   || R0 = [I0++]   || [I3++] = R4 ;
-LE$8ET: DISALGNEXCPT                       || R2 = [I1++]   || [I3++M2] = R5;
-
-        M1 = 1;
-        I3 = b3;
-        I1 = b1;
-        I0 = b0;
-
-        I0 += M1;
-        I1 += M1;
-
-        LSETUP(LS$8OT,LE$8OT) LC0=P0;
-        DISALGNEXCPT                       || R0 = [I0++]   || R2 = [I1++];
-
-LS$8OT: DISALGNEXCPT                       || R1 = [I0++]   || R3 = [I1++];
-        R4 = BYTEOP2P (R3:2,R1:0) (TH)     || R0 = [I0++M0] || R2 = [I1++M0];
-        R5 = BYTEOP2P (R3:2,R1:0) (TH,R)   || R0 = [I0++]   || R6 = [I3++];
-        R4 = R4 +|+ R6                                      || R7 = [I3--];
-        R5 = R5 +|+ R7                                      || [I3++] = R4;
-LE$8OT: DISALGNEXCPT                       || R2  =[I1++]   || [I3++M2] = R5;
-
-        (r7:4) = [sp++];
-        unlink;
-        rts;
-DEFUN_END(put_pixels8_xy2_nornd)
diff --git a/deps/libav/libavcodec/bfin/pixels.h b/deps/libav/libavcodec/bfin/pixels.h
new file mode 100644
index 0000000..0934429
--- /dev/null
+++ b/deps/libav/libavcodec/bfin/pixels.h
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2007 Marc Hoffman <mmh at pleasantst.com>
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVCODEC_BFIN_PIXELS_H
+#define AVCODEC_BFIN_PIXELS_H
+
+#include <stdint.h>
+
+#include "libavutil/bfin/attributes.h"
+
+void ff_bfin_z_put_pixels16_xy2(uint8_t *block, const uint8_t *s0,
+                                int dest_size, int line_size, int h) attribute_l1_text;
+void ff_bfin_z_put_pixels8_xy2(uint8_t *block, const uint8_t *s0,
+                               int dest_size, int line_size, int h) attribute_l1_text;
+
+void ff_bfin_put_pixels8uc(uint8_t *block, const uint8_t *s0,
+                           const uint8_t *s1, int dest_size, int line_size,
+                           int h) attribute_l1_text;
+void ff_bfin_put_pixels16uc(uint8_t *block, const uint8_t *s0,
+                            const uint8_t *s1, int dest_size, int line_size,
+                            int h) attribute_l1_text;
+
+#endif /* AVCODEC_BFIN_PIXELS_H */
diff --git a/deps/libav/libavcodec/bfin/vp3_bfin.h b/deps/libav/libavcodec/bfin/vp3_bfin.h
deleted file mode 100644
index 5a2c5a4..0000000
--- a/deps/libav/libavcodec/bfin/vp3_bfin.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-#ifndef AVCODEC_BFIN_VP3_BFIN_H
-#define AVCODEC_BFIN_VP3_BFIN_H
-
-#include <stdint.h>
-
-void ff_bfin_vp3_idct(int16_t *block);
-
-#endif /* AVCODEC_BFIN_VP3_BFIN_H */
diff --git a/deps/libav/libavcodec/bfin/vp3_idct_bfin.S b/deps/libav/libavcodec/bfin/vp3dsp.S
similarity index 97%
rename from deps/libav/libavcodec/bfin/vp3_idct_bfin.S
rename to deps/libav/libavcodec/bfin/vp3dsp.S
index fec8d78..615cae9 100644
--- a/deps/libav/libavcodec/bfin/vp3_idct_bfin.S
+++ b/deps/libav/libavcodec/bfin/vp3dsp.S
@@ -28,14 +28,9 @@ Registers Used  : A0, A1, R0-R7, I0-I3, B0, B2, B3, M0-M2, L0-L3, P0-P5, LC0.
 
 */
 
-#include "config.h"
-#include "config_bfin.h"
+#include "libavutil/bfin/asm.h"
 
-#if defined(__FDPIC__) && CONFIG_SRAM
-.section .l1.data.B,"aw", at progbits
-#else
-.data
-#endif
+SECTION_L1_DATA_B
 
 .align 4;
 coefs:
@@ -50,9 +45,7 @@ coefs:
 .short 0x18F9;           //cos(7pi/16)
 .short 0x7D8A;           //cos(pi/16)
 
-#if defined(__FDPIC__) && CONFIG_SRAM
-.section .l1.data.A,"aw", at progbits
-#endif
+SECTION_L1_DATA_A
 
 vtmp: .space 256
 
diff --git a/deps/libav/libavcodec/bfin/vp3_bfin.c b/deps/libav/libavcodec/bfin/vp3dsp_init.c
similarity index 91%
rename from deps/libav/libavcodec/bfin/vp3_bfin.c
rename to deps/libav/libavcodec/bfin/vp3dsp_init.c
index a8cdcb6..ae7ce93 100644
--- a/deps/libav/libavcodec/bfin/vp3_bfin.c
+++ b/deps/libav/libavcodec/bfin/vp3dsp_init.c
@@ -18,19 +18,20 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <stdint.h>
 #include <string.h>
 
 #include "libavutil/attributes.h"
 #include "libavcodec/avcodec.h"
 #include "libavcodec/vp3dsp.h"
 #include "libavcodec/dsputil.h"
-#include "dsputil_bfin.h"
-#include "vp3_bfin.h"
+
+void ff_bfin_vp3_idct(int16_t *block);
 
 /* Intra iDCT offset 128 */
 static void bfin_vp3_idct_put(uint8_t *dest, int line_size, int16_t *block)
 {
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP + 128;
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP + 128;
     int i,j;
 
     ff_bfin_vp3_idct (block);
@@ -45,7 +46,7 @@ static void bfin_vp3_idct_put(uint8_t *dest, int line_size, int16_t *block)
 /* Inter iDCT */
 static void bfin_vp3_idct_add(uint8_t *dest, int line_size, int16_t *block)
 {
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
     int i, j;
 
     ff_bfin_vp3_idct (block);
diff --git a/deps/libav/libavcodec/bit_depth_template.c b/deps/libav/libavcodec/bit_depth_template.c
index 37d02ad..79bbbbb 100644
--- a/deps/libav/libavcodec/bit_depth_template.c
+++ b/deps/libav/libavcodec/bit_depth_template.c
@@ -22,7 +22,7 @@
 #define BIT_DEPTH 8
 #endif
 
-#ifdef AVCODEC_H264_HIGH_DEPTH_H
+#ifdef AVCODEC_BIT_DEPTH_TEMPLATE_C
 #   undef pixel
 #   undef pixel2
 #   undef pixel4
@@ -42,7 +42,7 @@
 #   undef av_clip_pixel
 #   undef PIXEL_SPLAT_X4
 #else
-#   define AVCODEC_H264_HIGH_DEPTH_H
+#   define AVCODEC_BIT_DEPTH_TEMPLATE_C
 #endif
 
 #if BIT_DEPTH > 8
@@ -70,7 +70,7 @@
 #   define pixel4 uint32_t
 #   define dctcoef int16_t
 
-#   define INIT_CLIP const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+#   define INIT_CLIP const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
 #   define no_rnd_avg_pixel4 no_rnd_avg32
 #   define    rnd_avg_pixel4    rnd_avg32
 #   define AV_RN2P  AV_RN16
diff --git a/deps/libav/libavcodec/cabac.h b/deps/libav/libavcodec/cabac.h
index 7401bc9..426f338 100644
--- a/deps/libav/libavcodec/cabac.h
+++ b/deps/libav/libavcodec/cabac.h
@@ -31,6 +31,7 @@
 
 #include "put_bits.h"
 
+extern uint8_t ff_h264_cabac_tables[512 + 4*2*64 + 4*64 + 63];
 #define H264_NORM_SHIFT_OFFSET 0
 #define H264_LPS_RANGE_OFFSET 512
 #define H264_MLPS_STATE_OFFSET 1024
diff --git a/deps/libav/libavcodec/cabac_functions.h b/deps/libav/libavcodec/cabac_functions.h
index 11c9646..4b8f1bc 100644
--- a/deps/libav/libavcodec/cabac_functions.h
+++ b/deps/libav/libavcodec/cabac_functions.h
@@ -32,11 +32,16 @@
 #include "cabac.h"
 #include "config.h"
 
+#if ARCH_AARCH64
+#   include "aarch64/cabac.h"
+#endif
+#if ARCH_ARM
+#   include "arm/cabac.h"
+#endif
 #if ARCH_X86
 #   include "x86/cabac.h"
 #endif
 
-extern uint8_t ff_h264_cabac_tables[512 + 4*2*64 + 4*64 + 63];
 static uint8_t * const ff_h264_norm_shift = ff_h264_cabac_tables + H264_NORM_SHIFT_OFFSET;
 static uint8_t * const ff_h264_lps_range = ff_h264_cabac_tables + H264_LPS_RANGE_OFFSET;
 static uint8_t * const ff_h264_mlps_state = ff_h264_cabac_tables + H264_MLPS_STATE_OFFSET;
diff --git a/deps/libav/libavcodec/cavs.c b/deps/libav/libavcodec/cavs.c
index 5a81089..4166b9e 100644
--- a/deps/libav/libavcodec/cavs.c
+++ b/deps/libav/libavcodec/cavs.c
@@ -275,7 +275,7 @@ static void intra_pred_plane(uint8_t *d, uint8_t *top, uint8_t *left, int stride
     int x, y, ia;
     int ih = 0;
     int iv = 0;
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
 
     for (x = 0; x < 4; x++) {
         ih += (x + 1) *  (top[5 + x] -  top[3 - x]);
diff --git a/deps/libav/libavcodec/cavsdsp.c b/deps/libav/libavcodec/cavsdsp.c
index 2716e33..bc90546 100644
--- a/deps/libav/libavcodec/cavsdsp.c
+++ b/deps/libav/libavcodec/cavsdsp.c
@@ -186,7 +186,7 @@ static void cavs_filter_ch_c(uint8_t *d, int stride, int alpha, int beta, int tc
 static void cavs_idct8_add_c(uint8_t *dst, int16_t *block, int stride) {
     int i;
     int16_t (*src)[8] = (int16_t(*)[8])block;
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
 
     src[0][0] += 8;
 
@@ -261,7 +261,7 @@ static void cavs_idct8_add_c(uint8_t *dst, int16_t *block, int stride) {
 #define CAVS_SUBPIX(OPNAME, OP, NAME, A, B, C, D, E, F) \
 static void OPNAME ## cavs_filt8_h_ ## NAME(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
     const int h=8;\
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
     int i;\
     for(i=0; i<h; i++)\
     {\
@@ -280,7 +280,7 @@ static void OPNAME ## cavs_filt8_h_ ## NAME(uint8_t *dst, uint8_t *src, int dstS
 \
 static void OPNAME ## cavs_filt8_v_  ## NAME(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
     const int w=8;\
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
     int i;\
     for(i=0; i<w; i++)\
     {\
@@ -334,7 +334,7 @@ static void OPNAME ## cavs_filt8_hv_ ## NAME(uint8_t *dst, uint8_t *src1, uint8_
     int16_t *tmp = temp;\
     const int h=8;\
     const int w=8;\
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
     int i;\
     src1 -= 2*srcStride;\
     for(i=0; i<h+5; i++)\
diff --git a/deps/libav/libavcodec/copy_block.h b/deps/libav/libavcodec/copy_block.h
index ec465db..5dfdabc 100644
--- a/deps/libav/libavcodec/copy_block.h
+++ b/deps/libav/libavcodec/copy_block.h
@@ -26,35 +26,32 @@
 static inline void copy_block8(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
 {
     int i;
-    for(i=0; i<h; i++)
-    {
+    for (i = 0; i < h; i++) {
         AV_COPY64U(dst, src);
-        dst+=dstStride;
-        src+=srcStride;
+        dst += dstStride;
+        src += srcStride;
     }
 }
 
 static inline void copy_block9(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
 {
     int i;
-    for(i=0; i<h; i++)
-    {
+    for (i = 0; i < h; i++) {
         AV_COPY64U(dst, src);
-        dst[8]= src[8];
-        dst+=dstStride;
-        src+=srcStride;
+        dst[8] = src[8];
+        dst   += dstStride;
+        src   += srcStride;
     }
 }
 
 static inline void copy_block17(uint8_t *dst, const uint8_t *src, int dstStride, int srcStride, int h)
 {
     int i;
-    for(i=0; i<h; i++)
-    {
+    for (i = 0; i < h; i++) {
         AV_COPY128U(dst, src);
-        dst[16]= src[16];
-        dst+=dstStride;
-        src+=srcStride;
+        dst[16] = src[16];
+        dst    += dstStride;
+        src    += srcStride;
     }
 }
 
diff --git a/deps/libav/libavcodec/dca.c b/deps/libav/libavcodec/dca.c
index 308211f..3fab173 100644
--- a/deps/libav/libavcodec/dca.c
+++ b/deps/libav/libavcodec/dca.c
@@ -21,8 +21,10 @@
 #include <stdint.h>
 #include <string.h>
 
-#include "put_bits.h"
+#include "libavutil/error.h"
+
 #include "dca.h"
+#include "put_bits.h"
 
 const uint32_t avpriv_dca_sample_rates[16] =
 {
diff --git a/deps/libav/libavcodec/dcadata.h b/deps/libav/libavcodec/dcadata.h
index dc4e8b9..da3422e 100644
--- a/deps/libav/libavcodec/dcadata.h
+++ b/deps/libav/libavcodec/dcadata.h
@@ -7305,205 +7305,208 @@ DECLARE_ALIGNED(16, static const float, fir_32bands_nonperfect)[] =
 +1.390191784E-007
 };
 
+/* pre-scale lfe fir coefficients */
+#define SCALE(c) ((c) / (256.0f * 32768.0f))
 DECLARE_ALIGNED(16, static const float, lfe_fir_64)[] =
 {
-    2.658434386830777e-4, 9.029330685734748e-3,
-    7.939263433218002e-2, 2.425158768892288e-1,
-    3.430179357528686e-1, 2.398228943347931e-1,
-    7.746443897485733e-2, 8.622321300208569e-3,
-    8.179365249816328e-5, 9.450953453779220e-3,
-    8.134882897138596e-2, 2.451938837766648e-1,
-    3.429597318172455e-1, 2.371159791946411e-1,
-    7.556436210870743e-2, 8.229630999267101e-3,
-    9.439323912374676e-5, 9.887560270726680e-3,
-    8.333285897970200e-2, 2.478559017181396e-1,
-    3.428434133529663e-1, 2.343961596488952e-1,
-    7.369252294301987e-2, 7.850865833461285e-3,
-    1.082170274457894e-4, 1.033949479460716e-2,
-    8.534456789493561e-2, 2.505008876323700e-1,
-    3.426689505577088e-1, 2.316644787788391e-1,
-    7.184901088476181e-2, 7.485736627131701e-3,
-    1.233371440321207e-4, 1.080708485096693e-2,
-    8.738376945257187e-2, 2.531278133392334e-1,
-    3.424364924430847e-1, 2.289219647645950e-1,
-    7.003392279148102e-2, 7.133882027119398e-3,
-    1.397485757479444e-4, 1.129068247973919e-2,
-    8.945026248693466e-2, 2.557355761528015e-1,
-    3.421461284160614e-1, 2.261696159839630e-1,
-    6.824731826782227e-2, 6.794991903007030e-3,
-    1.575958012836054e-4, 1.179065089672804e-2,
-    9.154383838176728e-2, 2.583232223987580e-1,
-    3.417979776859284e-1, 2.234084606170654e-1,
-    6.648923456668854e-2, 6.468691397458315e-3,
-    1.769922382663936e-4, 1.230732165277004e-2,
-    9.366425126791000e-2, 2.608896791934967e-1,
-    3.413922190666198e-1, 2.206395119428635e-1,
-    6.475970894098282e-2, 6.154712289571762e-3,
-    1.981738605536520e-4, 1.284105982631445e-2,
-    9.581124037504196e-2, 2.634339034557342e-1,
-    3.409290313720703e-1, 2.178637981414795e-1,
-    6.305878609418869e-2, 5.852684378623962e-3,
-    2.211847313446924e-4, 1.339218579232693e-2,
-    9.798453748226166e-2, 2.659549415111542e-1,
-    3.404086530208588e-1, 2.150822728872299e-1,
-    6.138643622398376e-2, 5.562345497310162e-3,
-    2.460231189616024e-4, 1.396108977496624e-2,
-    1.001838669180870e-1, 2.684516608715058e-1,
-    3.398312926292420e-1, 2.122959494590759e-1,
-    5.974265560507774e-2, 5.283284001052380e-3,
-    2.726115926634520e-4, 1.454808749258518e-2,
-    1.024089083075523e-1, 2.709231376647949e-1,
-    3.391972482204438e-1, 2.095058411359787e-1,
-    5.812742188572884e-2, 5.015311297029257e-3,
-    3.013863170053810e-4, 1.515355054289102e-2,
-    1.046593263745308e-1, 2.733682692050934e-1,
-    3.385068178176880e-1, 2.067128717899322e-1,
-    5.654069408774376e-2, 4.758012015372515e-3,
-    3.328395541757345e-4, 1.577781140804291e-2,
-    1.069347932934761e-1, 2.757860720157624e-1,
-    3.377602994441986e-1, 2.039180546998978e-1,
-    5.498242005705833e-2, 4.511159844696522e-3,
-    3.658991190604866e-4, 1.642123050987720e-2,
-    1.092349365353584e-1, 2.781755328178406e-1,
-    3.369580209255218e-1, 2.011223286390304e-1,
-    5.345252528786659e-2, 4.274417180567980e-3,
-    4.018281470052898e-4, 1.708412915468216e-2,
-    1.115593686699867e-1, 2.805356979370117e-1,
-    3.361004292964936e-1, 1.983266174793244e-1,
-    5.195093154907227e-2, 4.047499038279056e-3,
-    4.401875485200435e-4, 1.776690222322941e-2,
-    1.139076948165894e-1, 2.828655838966370e-1,
-    3.351879119873047e-1, 1.955319195985794e-1,
-    5.047753453254700e-2, 3.830091329291463e-3,
-    4.812776169274002e-4, 1.846982724964619e-2,
-    1.162794977426529e-1, 2.851640880107880e-1,
-    3.342207968235016e-1, 1.927391141653061e-1,
-    4.903224110603333e-2, 3.621967276558280e-3,
-    5.252459668554366e-4, 1.919330470263958e-2,
-    1.186743453145027e-1, 2.874303460121155e-1,
-    3.331996202468872e-1, 1.899491697549820e-1,
-    4.761491715908051e-2, 3.422776935622096e-3,
-    5.721592460758984e-4, 1.993762329220772e-2,
-    1.210917681455612e-1, 2.896633744239807e-1,
-    3.321248590946198e-1, 1.871629506349564e-1,
-    4.622544348239899e-2, 3.232272574678064e-3,
-    6.222130032256246e-4, 2.070316113531590e-2,
-    1.235313042998314e-1, 2.918621897697448e-1,
-    3.309969604015350e-1, 1.843813359737396e-1,
-    4.486365616321564e-2, 3.050152910873294e-3,
-    6.755515350960195e-4, 2.149021252989769e-2,
-    1.259924471378326e-1, 2.940258979797364e-1,
-    3.298164308071136e-1, 1.816052496433258e-1,
-    4.352942481637001e-2, 2.876190468668938e-3,
-    7.324148900806904e-4, 2.229913882911205e-2,
-    1.284746825695038e-1, 2.961534857749939e-1,
-    3.285838961601258e-1, 1.788355410099030e-1,
-    4.222255200147629e-2, 2.710093278437853e-3,
-    7.928516715764999e-4, 2.313023805618286e-2,
-    1.309774816036224e-1, 2.982441186904907e-1,
-    3.272998929023742e-1, 1.760730892419815e-1,
-    4.094288870692253e-2, 2.551567042246461e-3,
-    8.570110658183694e-4, 2.398385666310787e-2,
-    1.335003077983856e-1, 3.002967536449432e-1,
-    3.259649574756622e-1, 1.733186990022659e-1,
-    3.969023004174232e-2, 2.400433411821723e-3,
-    9.251192095689476e-4, 2.486028522253036e-2,
-    1.360425949096680e-1, 3.023106753826142e-1,
-    3.245797157287598e-1, 1.705732345581055e-1,
-    3.846437484025955e-2, 2.256359672173858e-3,
-    9.974770946428180e-4, 2.575986087322235e-2,
-    1.386037617921829e-1, 3.042849004268646e-1,
-    3.231448531150818e-1, 1.678375005722046e-1,
-    3.726511076092720e-2, 2.119151875376701e-3,
-    1.073930296115577e-3, 2.668286114931106e-2,
-    1.411831974983215e-1, 3.062185347080230e-1,
-    3.216609656810760e-1, 1.651122719049454e-1,
-    3.609224036335945e-2, 1.988604199141264e-3,
-    1.155023579485714e-3, 2.762960828840732e-2,
-    1.437802612781525e-1, 3.081108033657074e-1,
-    3.201287388801574e-1, 1.623983532190323e-1,
-    3.494550660252571e-2, 1.864377525635064e-3,
-    1.240676851011813e-3, 2.860039286315441e-2,
-    1.463943719863892e-1, 3.099608123302460e-1,
-    3.185488879680634e-1, 1.596965193748474e-1,
-    3.382468968629837e-2, 1.746327499859035e-3,
-    1.331258914433420e-3, 2.959549613296986e-2,
-    1.490248143672943e-1, 3.117676973342896e-1,
-    3.169221282005310e-1, 1.570075154304504e-1,
-    3.272953629493714e-2, 1.634211512282491e-3,
-    1.426893868483603e-3, 3.061520494520664e-2,
-    1.516709625720978e-1, 3.135308027267456e-1,
-    3.152491748332978e-1, 1.543320864439010e-1,
-    3.165979683399200e-2, 1.527829794213176e-3,
+    SCALE(2.658434386830777e-4), SCALE(9.029330685734748e-3),
+    SCALE(7.939263433218002e-2), SCALE(2.425158768892288e-1),
+    SCALE(3.430179357528686e-1), SCALE(2.398228943347931e-1),
+    SCALE(7.746443897485733e-2), SCALE(8.622321300208569e-3),
+    SCALE(8.179365249816328e-5), SCALE(9.450953453779220e-3),
+    SCALE(8.134882897138596e-2), SCALE(2.451938837766648e-1),
+    SCALE(3.429597318172455e-1), SCALE(2.371159791946411e-1),
+    SCALE(7.556436210870743e-2), SCALE(8.229630999267101e-3),
+    SCALE(9.439323912374676e-5), SCALE(9.887560270726680e-3),
+    SCALE(8.333285897970200e-2), SCALE(2.478559017181396e-1),
+    SCALE(3.428434133529663e-1), SCALE(2.343961596488952e-1),
+    SCALE(7.369252294301987e-2), SCALE(7.850865833461285e-3),
+    SCALE(1.082170274457894e-4), SCALE(1.033949479460716e-2),
+    SCALE(8.534456789493561e-2), SCALE(2.505008876323700e-1),
+    SCALE(3.426689505577088e-1), SCALE(2.316644787788391e-1),
+    SCALE(7.184901088476181e-2), SCALE(7.485736627131701e-3),
+    SCALE(1.233371440321207e-4), SCALE(1.080708485096693e-2),
+    SCALE(8.738376945257187e-2), SCALE(2.531278133392334e-1),
+    SCALE(3.424364924430847e-1), SCALE(2.289219647645950e-1),
+    SCALE(7.003392279148102e-2), SCALE(7.133882027119398e-3),
+    SCALE(1.397485757479444e-4), SCALE(1.129068247973919e-2),
+    SCALE(8.945026248693466e-2), SCALE(2.557355761528015e-1),
+    SCALE(3.421461284160614e-1), SCALE(2.261696159839630e-1),
+    SCALE(6.824731826782227e-2), SCALE(6.794991903007030e-3),
+    SCALE(1.575958012836054e-4), SCALE(1.179065089672804e-2),
+    SCALE(9.154383838176728e-2), SCALE(2.583232223987580e-1),
+    SCALE(3.417979776859284e-1), SCALE(2.234084606170654e-1),
+    SCALE(6.648923456668854e-2), SCALE(6.468691397458315e-3),
+    SCALE(1.769922382663936e-4), SCALE(1.230732165277004e-2),
+    SCALE(9.366425126791000e-2), SCALE(2.608896791934967e-1),
+    SCALE(3.413922190666198e-1), SCALE(2.206395119428635e-1),
+    SCALE(6.475970894098282e-2), SCALE(6.154712289571762e-3),
+    SCALE(1.981738605536520e-4), SCALE(1.284105982631445e-2),
+    SCALE(9.581124037504196e-2), SCALE(2.634339034557342e-1),
+    SCALE(3.409290313720703e-1), SCALE(2.178637981414795e-1),
+    SCALE(6.305878609418869e-2), SCALE(5.852684378623962e-3),
+    SCALE(2.211847313446924e-4), SCALE(1.339218579232693e-2),
+    SCALE(9.798453748226166e-2), SCALE(2.659549415111542e-1),
+    SCALE(3.404086530208588e-1), SCALE(2.150822728872299e-1),
+    SCALE(6.138643622398376e-2), SCALE(5.562345497310162e-3),
+    SCALE(2.460231189616024e-4), SCALE(1.396108977496624e-2),
+    SCALE(1.001838669180870e-1), SCALE(2.684516608715058e-1),
+    SCALE(3.398312926292420e-1), SCALE(2.122959494590759e-1),
+    SCALE(5.974265560507774e-2), SCALE(5.283284001052380e-3),
+    SCALE(2.726115926634520e-4), SCALE(1.454808749258518e-2),
+    SCALE(1.024089083075523e-1), SCALE(2.709231376647949e-1),
+    SCALE(3.391972482204438e-1), SCALE(2.095058411359787e-1),
+    SCALE(5.812742188572884e-2), SCALE(5.015311297029257e-3),
+    SCALE(3.013863170053810e-4), SCALE(1.515355054289102e-2),
+    SCALE(1.046593263745308e-1), SCALE(2.733682692050934e-1),
+    SCALE(3.385068178176880e-1), SCALE(2.067128717899322e-1),
+    SCALE(5.654069408774376e-2), SCALE(4.758012015372515e-3),
+    SCALE(3.328395541757345e-4), SCALE(1.577781140804291e-2),
+    SCALE(1.069347932934761e-1), SCALE(2.757860720157624e-1),
+    SCALE(3.377602994441986e-1), SCALE(2.039180546998978e-1),
+    SCALE(5.498242005705833e-2), SCALE(4.511159844696522e-3),
+    SCALE(3.658991190604866e-4), SCALE(1.642123050987720e-2),
+    SCALE(1.092349365353584e-1), SCALE(2.781755328178406e-1),
+    SCALE(3.369580209255218e-1), SCALE(2.011223286390304e-1),
+    SCALE(5.345252528786659e-2), SCALE(4.274417180567980e-3),
+    SCALE(4.018281470052898e-4), SCALE(1.708412915468216e-2),
+    SCALE(1.115593686699867e-1), SCALE(2.805356979370117e-1),
+    SCALE(3.361004292964936e-1), SCALE(1.983266174793244e-1),
+    SCALE(5.195093154907227e-2), SCALE(4.047499038279056e-3),
+    SCALE(4.401875485200435e-4), SCALE(1.776690222322941e-2),
+    SCALE(1.139076948165894e-1), SCALE(2.828655838966370e-1),
+    SCALE(3.351879119873047e-1), SCALE(1.955319195985794e-1),
+    SCALE(5.047753453254700e-2), SCALE(3.830091329291463e-3),
+    SCALE(4.812776169274002e-4), SCALE(1.846982724964619e-2),
+    SCALE(1.162794977426529e-1), SCALE(2.851640880107880e-1),
+    SCALE(3.342207968235016e-1), SCALE(1.927391141653061e-1),
+    SCALE(4.903224110603333e-2), SCALE(3.621967276558280e-3),
+    SCALE(5.252459668554366e-4), SCALE(1.919330470263958e-2),
+    SCALE(1.186743453145027e-1), SCALE(2.874303460121155e-1),
+    SCALE(3.331996202468872e-1), SCALE(1.899491697549820e-1),
+    SCALE(4.761491715908051e-2), SCALE(3.422776935622096e-3),
+    SCALE(5.721592460758984e-4), SCALE(1.993762329220772e-2),
+    SCALE(1.210917681455612e-1), SCALE(2.896633744239807e-1),
+    SCALE(3.321248590946198e-1), SCALE(1.871629506349564e-1),
+    SCALE(4.622544348239899e-2), SCALE(3.232272574678064e-3),
+    SCALE(6.222130032256246e-4), SCALE(2.070316113531590e-2),
+    SCALE(1.235313042998314e-1), SCALE(2.918621897697448e-1),
+    SCALE(3.309969604015350e-1), SCALE(1.843813359737396e-1),
+    SCALE(4.486365616321564e-2), SCALE(3.050152910873294e-3),
+    SCALE(6.755515350960195e-4), SCALE(2.149021252989769e-2),
+    SCALE(1.259924471378326e-1), SCALE(2.940258979797364e-1),
+    SCALE(3.298164308071136e-1), SCALE(1.816052496433258e-1),
+    SCALE(4.352942481637001e-2), SCALE(2.876190468668938e-3),
+    SCALE(7.324148900806904e-4), SCALE(2.229913882911205e-2),
+    SCALE(1.284746825695038e-1), SCALE(2.961534857749939e-1),
+    SCALE(3.285838961601258e-1), SCALE(1.788355410099030e-1),
+    SCALE(4.222255200147629e-2), SCALE(2.710093278437853e-3),
+    SCALE(7.928516715764999e-4), SCALE(2.313023805618286e-2),
+    SCALE(1.309774816036224e-1), SCALE(2.982441186904907e-1),
+    SCALE(3.272998929023742e-1), SCALE(1.760730892419815e-1),
+    SCALE(4.094288870692253e-2), SCALE(2.551567042246461e-3),
+    SCALE(8.570110658183694e-4), SCALE(2.398385666310787e-2),
+    SCALE(1.335003077983856e-1), SCALE(3.002967536449432e-1),
+    SCALE(3.259649574756622e-1), SCALE(1.733186990022659e-1),
+    SCALE(3.969023004174232e-2), SCALE(2.400433411821723e-3),
+    SCALE(9.251192095689476e-4), SCALE(2.486028522253036e-2),
+    SCALE(1.360425949096680e-1), SCALE(3.023106753826142e-1),
+    SCALE(3.245797157287598e-1), SCALE(1.705732345581055e-1),
+    SCALE(3.846437484025955e-2), SCALE(2.256359672173858e-3),
+    SCALE(9.974770946428180e-4), SCALE(2.575986087322235e-2),
+    SCALE(1.386037617921829e-1), SCALE(3.042849004268646e-1),
+    SCALE(3.231448531150818e-1), SCALE(1.678375005722046e-1),
+    SCALE(3.726511076092720e-2), SCALE(2.119151875376701e-3),
+    SCALE(1.073930296115577e-3), SCALE(2.668286114931106e-2),
+    SCALE(1.411831974983215e-1), SCALE(3.062185347080230e-1),
+    SCALE(3.216609656810760e-1), SCALE(1.651122719049454e-1),
+    SCALE(3.609224036335945e-2), SCALE(1.988604199141264e-3),
+    SCALE(1.155023579485714e-3), SCALE(2.762960828840732e-2),
+    SCALE(1.437802612781525e-1), SCALE(3.081108033657074e-1),
+    SCALE(3.201287388801574e-1), SCALE(1.623983532190323e-1),
+    SCALE(3.494550660252571e-2), SCALE(1.864377525635064e-3),
+    SCALE(1.240676851011813e-3), SCALE(2.860039286315441e-2),
+    SCALE(1.463943719863892e-1), SCALE(3.099608123302460e-1),
+    SCALE(3.185488879680634e-1), SCALE(1.596965193748474e-1),
+    SCALE(3.382468968629837e-2), SCALE(1.746327499859035e-3),
+    SCALE(1.331258914433420e-3), SCALE(2.959549613296986e-2),
+    SCALE(1.490248143672943e-1), SCALE(3.117676973342896e-1),
+    SCALE(3.169221282005310e-1), SCALE(1.570075154304504e-1),
+    SCALE(3.272953629493714e-2), SCALE(1.634211512282491e-3),
+    SCALE(1.426893868483603e-3), SCALE(3.061520494520664e-2),
+    SCALE(1.516709625720978e-1), SCALE(3.135308027267456e-1),
+    SCALE(3.152491748332978e-1), SCALE(1.543320864439010e-1),
+    SCALE(3.165979683399200e-2), SCALE(1.527829794213176e-3),
 };
 
 DECLARE_ALIGNED(16, static const float, lfe_fir_128)[] =
 {
-    0.00053168571, 0.15878495574, 0.68603444099, 0.15492856503,
-    0.00016358691, 0.16269733012, 0.68591803312, 0.15112841129,
-    0.00018878609, 0.16666537523, 0.68568539619, 0.14738474786,
-    0.00021643363, 0.17068879306, 0.68533653021, 0.14369773865,
-    0.00024667382, 0.17476719618, 0.68487155437, 0.14006754756,
-    0.00027949660, 0.17890018225, 0.68429082632, 0.13649433851,
-    0.00031519096, 0.18308731914, 0.68359452486, 0.13297818601,
-    0.00035398375, 0.18732811511, 0.68278300762, 0.12951917946,
-    0.00039634691, 0.19162209332, 0.68185669184, 0.12611730397,
-    0.00044236859, 0.19596865773, 0.68081587553, 0.12277261168,
-    0.00049204525, 0.20036731660, 0.67966115475, 0.11948505789,
-    0.00054522208, 0.20481738448, 0.67839306593, 0.11625462025,
-    0.00060277141, 0.20931822062, 0.67701220512, 0.11308115721,
-    0.00066567765, 0.21386915445, 0.67551922798, 0.10996460915,
-    0.00073179678, 0.21846942604, 0.67391467094, 0.10690483451,
-    0.00080365466, 0.22311829031, 0.67219948769, 0.10390164703,
-    0.00088037323, 0.22781492770, 0.67037439346, 0.10095486045,
-    0.00096255314, 0.23255851865, 0.66844022274, 0.09806428105,
-    0.00105048984, 0.23734821379, 0.66639786959, 0.09522963315,
-    0.00114431616, 0.24218304455, 0.66424828768, 0.09245070815,
-    0.00124442333, 0.24706205726, 0.66199249029, 0.08972713351,
-    0.00135110028, 0.25198432803, 0.65963155031, 0.08705867827,
-    0.00146482687, 0.25694879889, 0.65716648102, 0.08444493264,
-    0.00158570008, 0.26195442677, 0.65459835529, 0.08188561350,
-    0.00171401864, 0.26700007915, 0.65192854404, 0.07938029617,
-    0.00185023469, 0.27208462358, 0.64915806055, 0.07692859322,
-    0.00199495023, 0.27720692754, 0.64628833532, 0.07453006506,
-    0.00214785640, 0.28236576915, 0.64332056046, 0.07218432426,
-    0.00231004250, 0.28755992651, 0.64025616646, 0.06989086419,
-    0.00248134881, 0.29278811812, 0.63709646463, 0.06764923781,
-    0.00266251224, 0.29804900289, 0.63384294510, 0.06545893103,
-    0.00285378192, 0.30334126949, 0.63049703836, 0.06331945211,
-    0.00305565330, 0.30866351724, 0.62706029415, 0.06123027951,
-    0.00326841651, 0.31401440501, 0.62353414297, 0.05919086933,
-    0.00349264755, 0.31939238310, 0.61992025375, 0.05720067024,
-    0.00372874714, 0.32479602098, 0.61622029543, 0.05525910854,
-    0.00397720048, 0.33022382855, 0.61243581772, 0.05336561054,
-    0.00423829490, 0.33567428589, 0.60856848955, 0.05151961371,
-    0.00451271003, 0.34114575386, 0.60462015867, 0.04972046614,
-    0.00480085658, 0.34663668275, 0.60059231520, 0.04796761274,
-    0.00510312291, 0.35214546323, 0.59648692608, 0.04626038298,
-    0.00542017492, 0.35767036676, 0.59230577946, 0.04459818453,
-    0.00575236930, 0.36320972443, 0.58805054426, 0.04298033938,
-    0.00610029325, 0.36876192689, 0.58372318745, 0.04140623659,
-    0.00646453211, 0.37432509661, 0.57932555676, 0.03987516090,
-    0.00684553990, 0.37989753485, 0.57485944033, 0.03838652745,
-    0.00724391919, 0.38547745347, 0.57032698393, 0.03693958372,
-    0.00766016589, 0.39106300473, 0.56572991610, 0.03553372994,
-    0.00809498038, 0.39665243030, 0.56107026339, 0.03416819125,
-    0.00854881573, 0.40224379301, 0.55634999275, 0.03284239396,
-    0.00902230106, 0.40783521533, 0.55157101154, 0.03155555204,
-    0.00951600447, 0.41342487931, 0.54673534632, 0.03030703776,
-    0.01003060210, 0.41901078820, 0.54184508324, 0.02909611352,
-    0.01056654565, 0.42459106445, 0.53690224886, 0.02792212367,
-    0.01112466771, 0.43016362190, 0.53190881014, 0.02678431384,
-    0.01170534454, 0.43572667241, 0.52686679363, 0.02568206564,
-    0.01230939943, 0.44127810001, 0.52177828550, 0.02461459488,
-    0.01293735672, 0.44681602716, 0.51664537191, 0.02358125709,
-    0.01358995494, 0.45233830810, 0.51147013903, 0.02258131653,
-    0.01426773332, 0.45784294605, 0.50625455379, 0.02161412500,
-    0.01497144438, 0.46332800388, 0.50100076199, 0.02067894675,
-    0.01570170000, 0.46879136562, 0.49571081996, 0.01977507770,
-    0.01645922661, 0.47423094511, 0.49038675427, 0.01890186779,
-    0.01724460535, 0.47964480519, 0.48503074050, 0.01805862412,
+    SCALE(0.00053168571), SCALE(0.15878495574), SCALE(0.68603444099), SCALE(0.15492856503),
+    SCALE(0.00016358691), SCALE(0.16269733012), SCALE(0.68591803312), SCALE(0.15112841129),
+    SCALE(0.00018878609), SCALE(0.16666537523), SCALE(0.68568539619), SCALE(0.14738474786),
+    SCALE(0.00021643363), SCALE(0.17068879306), SCALE(0.68533653021), SCALE(0.14369773865),
+    SCALE(0.00024667382), SCALE(0.17476719618), SCALE(0.68487155437), SCALE(0.14006754756),
+    SCALE(0.00027949660), SCALE(0.17890018225), SCALE(0.68429082632), SCALE(0.13649433851),
+    SCALE(0.00031519096), SCALE(0.18308731914), SCALE(0.68359452486), SCALE(0.13297818601),
+    SCALE(0.00035398375), SCALE(0.18732811511), SCALE(0.68278300762), SCALE(0.12951917946),
+    SCALE(0.00039634691), SCALE(0.19162209332), SCALE(0.68185669184), SCALE(0.12611730397),
+    SCALE(0.00044236859), SCALE(0.19596865773), SCALE(0.68081587553), SCALE(0.12277261168),
+    SCALE(0.00049204525), SCALE(0.20036731660), SCALE(0.67966115475), SCALE(0.11948505789),
+    SCALE(0.00054522208), SCALE(0.20481738448), SCALE(0.67839306593), SCALE(0.11625462025),
+    SCALE(0.00060277141), SCALE(0.20931822062), SCALE(0.67701220512), SCALE(0.11308115721),
+    SCALE(0.00066567765), SCALE(0.21386915445), SCALE(0.67551922798), SCALE(0.10996460915),
+    SCALE(0.00073179678), SCALE(0.21846942604), SCALE(0.67391467094), SCALE(0.10690483451),
+    SCALE(0.00080365466), SCALE(0.22311829031), SCALE(0.67219948769), SCALE(0.10390164703),
+    SCALE(0.00088037323), SCALE(0.22781492770), SCALE(0.67037439346), SCALE(0.10095486045),
+    SCALE(0.00096255314), SCALE(0.23255851865), SCALE(0.66844022274), SCALE(0.09806428105),
+    SCALE(0.00105048984), SCALE(0.23734821379), SCALE(0.66639786959), SCALE(0.09522963315),
+    SCALE(0.00114431616), SCALE(0.24218304455), SCALE(0.66424828768), SCALE(0.09245070815),
+    SCALE(0.00124442333), SCALE(0.24706205726), SCALE(0.66199249029), SCALE(0.08972713351),
+    SCALE(0.00135110028), SCALE(0.25198432803), SCALE(0.65963155031), SCALE(0.08705867827),
+    SCALE(0.00146482687), SCALE(0.25694879889), SCALE(0.65716648102), SCALE(0.08444493264),
+    SCALE(0.00158570008), SCALE(0.26195442677), SCALE(0.65459835529), SCALE(0.08188561350),
+    SCALE(0.00171401864), SCALE(0.26700007915), SCALE(0.65192854404), SCALE(0.07938029617),
+    SCALE(0.00185023469), SCALE(0.27208462358), SCALE(0.64915806055), SCALE(0.07692859322),
+    SCALE(0.00199495023), SCALE(0.27720692754), SCALE(0.64628833532), SCALE(0.07453006506),
+    SCALE(0.00214785640), SCALE(0.28236576915), SCALE(0.64332056046), SCALE(0.07218432426),
+    SCALE(0.00231004250), SCALE(0.28755992651), SCALE(0.64025616646), SCALE(0.06989086419),
+    SCALE(0.00248134881), SCALE(0.29278811812), SCALE(0.63709646463), SCALE(0.06764923781),
+    SCALE(0.00266251224), SCALE(0.29804900289), SCALE(0.63384294510), SCALE(0.06545893103),
+    SCALE(0.00285378192), SCALE(0.30334126949), SCALE(0.63049703836), SCALE(0.06331945211),
+    SCALE(0.00305565330), SCALE(0.30866351724), SCALE(0.62706029415), SCALE(0.06123027951),
+    SCALE(0.00326841651), SCALE(0.31401440501), SCALE(0.62353414297), SCALE(0.05919086933),
+    SCALE(0.00349264755), SCALE(0.31939238310), SCALE(0.61992025375), SCALE(0.05720067024),
+    SCALE(0.00372874714), SCALE(0.32479602098), SCALE(0.61622029543), SCALE(0.05525910854),
+    SCALE(0.00397720048), SCALE(0.33022382855), SCALE(0.61243581772), SCALE(0.05336561054),
+    SCALE(0.00423829490), SCALE(0.33567428589), SCALE(0.60856848955), SCALE(0.05151961371),
+    SCALE(0.00451271003), SCALE(0.34114575386), SCALE(0.60462015867), SCALE(0.04972046614),
+    SCALE(0.00480085658), SCALE(0.34663668275), SCALE(0.60059231520), SCALE(0.04796761274),
+    SCALE(0.00510312291), SCALE(0.35214546323), SCALE(0.59648692608), SCALE(0.04626038298),
+    SCALE(0.00542017492), SCALE(0.35767036676), SCALE(0.59230577946), SCALE(0.04459818453),
+    SCALE(0.00575236930), SCALE(0.36320972443), SCALE(0.58805054426), SCALE(0.04298033938),
+    SCALE(0.00610029325), SCALE(0.36876192689), SCALE(0.58372318745), SCALE(0.04140623659),
+    SCALE(0.00646453211), SCALE(0.37432509661), SCALE(0.57932555676), SCALE(0.03987516090),
+    SCALE(0.00684553990), SCALE(0.37989753485), SCALE(0.57485944033), SCALE(0.03838652745),
+    SCALE(0.00724391919), SCALE(0.38547745347), SCALE(0.57032698393), SCALE(0.03693958372),
+    SCALE(0.00766016589), SCALE(0.39106300473), SCALE(0.56572991610), SCALE(0.03553372994),
+    SCALE(0.00809498038), SCALE(0.39665243030), SCALE(0.56107026339), SCALE(0.03416819125),
+    SCALE(0.00854881573), SCALE(0.40224379301), SCALE(0.55634999275), SCALE(0.03284239396),
+    SCALE(0.00902230106), SCALE(0.40783521533), SCALE(0.55157101154), SCALE(0.03155555204),
+    SCALE(0.00951600447), SCALE(0.41342487931), SCALE(0.54673534632), SCALE(0.03030703776),
+    SCALE(0.01003060210), SCALE(0.41901078820), SCALE(0.54184508324), SCALE(0.02909611352),
+    SCALE(0.01056654565), SCALE(0.42459106445), SCALE(0.53690224886), SCALE(0.02792212367),
+    SCALE(0.01112466771), SCALE(0.43016362190), SCALE(0.53190881014), SCALE(0.02678431384),
+    SCALE(0.01170534454), SCALE(0.43572667241), SCALE(0.52686679363), SCALE(0.02568206564),
+    SCALE(0.01230939943), SCALE(0.44127810001), SCALE(0.52177828550), SCALE(0.02461459488),
+    SCALE(0.01293735672), SCALE(0.44681602716), SCALE(0.51664537191), SCALE(0.02358125709),
+    SCALE(0.01358995494), SCALE(0.45233830810), SCALE(0.51147013903), SCALE(0.02258131653),
+    SCALE(0.01426773332), SCALE(0.45784294605), SCALE(0.50625455379), SCALE(0.02161412500),
+    SCALE(0.01497144438), SCALE(0.46332800388), SCALE(0.50100076199), SCALE(0.02067894675),
+    SCALE(0.01570170000), SCALE(0.46879136562), SCALE(0.49571081996), SCALE(0.01977507770),
+    SCALE(0.01645922661), SCALE(0.47423094511), SCALE(0.49038675427), SCALE(0.01890186779),
+    SCALE(0.01724460535), SCALE(0.47964480519), SCALE(0.48503074050), SCALE(0.01805862412),
 };
+#undef SCALE
 
 /*
  * D.11 Look-up Table for Downmix Scale Factors
diff --git a/deps/libav/libavcodec/dcadec.c b/deps/libav/libavcodec/dcadec.c
index 723ed19..92edce7 100644
--- a/deps/libav/libavcodec/dcadec.c
+++ b/deps/libav/libavcodec/dcadec.c
@@ -50,14 +50,10 @@
 #if ARCH_ARM
 #   include "arm/dca.h"
 #endif
-#if ARCH_X86
-#   include "x86/dca.h"
-#endif
 
 //#define TRACE
 
 #define DCA_PRIM_CHANNELS_MAX  (7)
-#define DCA_SUBBANDS          (32)
 #define DCA_ABITS_MAX         (32)      /* Should be 28 */
 #define DCA_SUBSUBFRAMES_MAX   (4)
 #define DCA_SUBFRAMES_MAX     (16)
@@ -340,7 +336,7 @@ typedef struct {
     int prediction_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS];      ///< prediction VQ coefs
     int bitalloc[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS];           ///< bit allocation index
     int transition_mode[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS];    ///< transition mode (transients)
-    int scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][2];    ///< scale factors (2 if transient)
+    int32_t scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS][2];///< scale factors (2 if transient)
     int joint_huff[DCA_PRIM_CHANNELS_MAX];                       ///< joint subband scale factors codebook
     int joint_scale_factor[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS]; ///< joint subband scale factors
     float downmix_coef[DCA_PRIM_CHANNELS_MAX + 1][2];            ///< stereo downmix coefficients
@@ -353,7 +349,7 @@ typedef struct {
     uint8_t  core_downmix_amode;                                 ///< audio channel arrangement of embedded downmix
     uint16_t core_downmix_codes[DCA_PRIM_CHANNELS_MAX + 1][4];   ///< embedded downmix coefficients (9-bit codes)
 
-    int high_freq_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS];       ///< VQ encoded high frequency subbands
+    int32_t  high_freq_vq[DCA_PRIM_CHANNELS_MAX][DCA_SUBBANDS];  ///< VQ encoded high frequency subbands
 
     float lfe_data[2 * DCA_LFE_MAX * (DCA_BLOCKS_MAX + 4)];      ///< Low frequency effect data
     int lfe_scale_factor;
@@ -947,7 +943,7 @@ static void qmf_32_subbands(DCAContext *s, int chans,
 
 static void lfe_interpolation_fir(DCAContext *s, int decimation_select,
                                   int num_deci_sample, float *samples_in,
-                                  float *samples_out, float scale)
+                                  float *samples_out)
 {
     /* samples_in: An array holding decimated samples.
      *   Samples in current subframe starts from samples_in[0],
@@ -971,7 +967,7 @@ static void lfe_interpolation_fir(DCAContext *s, int decimation_select,
     }
     /* Interpolation */
     for (deciindex = 0; deciindex < num_deci_sample; deciindex++) {
-        s->dcadsp.lfe_fir[idx](samples_out, samples_in, prCoeff, scale);
+        s->dcadsp.lfe_fir[idx](samples_out, samples_in, prCoeff);
         samples_in++;
         samples_out += 2 * 32 * (1 + idx);
     }
@@ -1088,14 +1084,6 @@ static int decode_blockcodes(int code1, int code2, int levels, int32_t *values)
 static const uint8_t abits_sizes[7]  = { 7, 10, 12, 13, 15, 17, 19 };
 static const uint8_t abits_levels[7] = { 3,  5,  7,  9, 13, 17, 25 };
 
-#ifndef int8x8_fmul_int32
-static inline void int8x8_fmul_int32(DCADSPContext *dsp, float *dst,
-                                     const int8_t *src, int scale)
-{
-    dsp->int8x8_fmul_int32(dst, src, scale);
-}
-#endif
-
 static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
 {
     int k, l;
@@ -1192,16 +1180,27 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
              */
             if (s->prediction_mode[k][l]) {
                 int n;
-                for (m = 0; m < 8; m++) {
-                    for (n = 1; n <= 4; n++)
+                if (s->predictor_history)
+                    subband_samples[k][l][0] += (adpcm_vb[s->prediction_vq[k][l]][0] *
+                                                 s->subband_samples_hist[k][l][3] +
+                                                 adpcm_vb[s->prediction_vq[k][l]][1] *
+                                                 s->subband_samples_hist[k][l][2] +
+                                                 adpcm_vb[s->prediction_vq[k][l]][2] *
+                                                 s->subband_samples_hist[k][l][1] +
+                                                 adpcm_vb[s->prediction_vq[k][l]][3] *
+                                                 s->subband_samples_hist[k][l][0]) *
+                                                (1.0f / 8192);
+                for (m = 1; m < 8; m++) {
+                    float sum = adpcm_vb[s->prediction_vq[k][l]][0] *
+                                subband_samples[k][l][m - 1];
+                    for (n = 2; n <= 4; n++)
                         if (m >= n)
-                            subband_samples[k][l][m] +=
-                                (adpcm_vb[s->prediction_vq[k][l]][n - 1] *
-                                 subband_samples[k][l][m - n] / 8192);
+                            sum += adpcm_vb[s->prediction_vq[k][l]][n - 1] *
+                                   subband_samples[k][l][m - n];
                         else if (s->predictor_history)
-                            subband_samples[k][l][m] +=
-                                (adpcm_vb[s->prediction_vq[k][l]][n - 1] *
-                                 s->subband_samples_hist[k][l][m - n + 4] / 8192);
+                            sum += adpcm_vb[s->prediction_vq[k][l]][n - 1] *
+                                   s->subband_samples_hist[k][l][m - n + 4];
+                    subband_samples[k][l][m] += sum * 1.0f / 8192;
                 }
             }
         }
@@ -1209,20 +1208,16 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
         /*
          * Decode VQ encoded high frequencies
          */
-        for (l = s->vq_start_subband[k]; l < s->subband_activity[k]; l++) {
-            /* 1 vector -> 32 samples but we only need the 8 samples
-             * for this subsubframe. */
-            int hfvq = s->high_freq_vq[k][l];
-
+        if (s->subband_activity[k] > s->vq_start_subband[k]) {
             if (!s->debug_flag & 0x01) {
                 av_log(s->avctx, AV_LOG_DEBUG,
                        "Stream with high frequencies VQ coding\n");
                 s->debug_flag |= 0x01;
             }
-
-            int8x8_fmul_int32(&s->dcadsp, subband_samples[k][l],
-                              &high_freq_vq[hfvq][subsubframe * 8],
-                              s->scale_factor[k][l][0]);
+            s->dcadsp.decode_hf(subband_samples[k], s->high_freq_vq[k],
+                                high_freq_vq, subsubframe * 8,
+                                s->scale_factor[k], s->vq_start_subband[k],
+                                s->subband_activity[k]);
         }
     }
 
@@ -1241,9 +1236,7 @@ static int dca_subsubframe(DCAContext *s, int base_channel, int block_index)
     /* Backup predictor history for adpcm */
     for (k = base_channel; k < s->prim_channels; k++)
         for (l = 0; l < s->vq_start_subband[k]; l++)
-            memcpy(s->subband_samples_hist[k][l],
-                   &subband_samples[k][l][4],
-                   4 * sizeof(subband_samples[0][0][0]));
+            AV_COPY128(s->subband_samples_hist[k][l], &subband_samples[k][l][4]);
 
     return 0;
 }
@@ -1267,8 +1260,7 @@ static int dca_filter_channels(DCAContext *s, int block_index)
     if (s->lfe) {
         lfe_interpolation_fir(s, s->lfe, 2 * s->lfe,
                               s->lfe_data + 2 * s->lfe * (block_index + 4),
-                              s->samples_chanptr[dca_lfe_index[s->amode]],
-                              1.0 / (256.0 * 32768.0));
+                              s->samples_chanptr[dca_lfe_index[s->amode]]);
         /* Outputs 20bits pcm samples */
     }
 
diff --git a/deps/libav/libavcodec/dcadsp.c b/deps/libav/libavcodec/dcadsp.c
index 8d242c5..18732dc 100644
--- a/deps/libav/libavcodec/dcadsp.c
+++ b/deps/libav/libavcodec/dcadsp.c
@@ -24,34 +24,42 @@
 #include "libavutil/intreadwrite.h"
 #include "dcadsp.h"
 
-static void int8x8_fmul_int32_c(float *dst, const int8_t *src, int scale)
+static void decode_hf_c(float dst[DCA_SUBBANDS][8],
+                        const int32_t vq_num[DCA_SUBBANDS],
+                        const int8_t hf_vq[1024][32], intptr_t vq_offset,
+                        int32_t scale[DCA_SUBBANDS][2],
+                        intptr_t start, intptr_t end)
 {
-    float fscale = scale / 16.0;
-    int i;
-    for (i = 0; i < 8; i++)
-        dst[i] = src[i] * fscale;
+    int i, l;
+
+    for (l = start; l < end; l++) {
+        /* 1 vector -> 32 samples but we only need the 8 samples
+         * for this subsubframe. */
+        const int8_t *ptr = &hf_vq[vq_num[l]][vq_offset];
+        float fscale = scale[l][0] * (1 / 16.0);
+        for (i = 0; i < 8; i++)
+            dst[l][i] = ptr[i] * fscale;
+    }
 }
 
 static inline void
 dca_lfe_fir(float *out, const float *in, const float *coefs,
-            int decifactor, float scale)
+            int decifactor)
 {
-    float *out2 = out + decifactor;
-    const float *cf0 = coefs;
-    const float *cf1 = coefs + 256;
+    float *out2    = out + 2 * decifactor - 1;
+    int num_coeffs = 256 / decifactor;
     int j, k;
 
     /* One decimated sample generates 2*decifactor interpolated ones */
     for (k = 0; k < decifactor; k++) {
         float v0 = 0.0;
         float v1 = 0.0;
-        for (j = 0; j < 256 / decifactor; j++) {
-            float s = in[-j];
-            v0 += s * *cf0++;
-            v1 += s * *--cf1;
+        for (j = 0; j < num_coeffs; j++, coefs++) {
+            v0 += in[-j] * *coefs;
+            v1 += in[j + 1 - num_coeffs] * *coefs;
         }
-        *out++  = v0 * scale;
-        *out2++ = v1 * scale;
+        *out++  = v0;
+        *out2-- = v1;
     }
 }
 
@@ -83,16 +91,14 @@ static void dca_qmf_32_subbands(float samples_in[32][8], int sb_act,
     }
 }
 
-static void dca_lfe_fir0_c(float *out, const float *in, const float *coefs,
-                           float scale)
+static void dca_lfe_fir0_c(float *out, const float *in, const float *coefs)
 {
-    dca_lfe_fir(out, in, coefs, 32, scale);
+    dca_lfe_fir(out, in, coefs, 32);
 }
 
-static void dca_lfe_fir1_c(float *out, const float *in, const float *coefs,
-                           float scale)
+static void dca_lfe_fir1_c(float *out, const float *in, const float *coefs)
 {
-    dca_lfe_fir(out, in, coefs, 64, scale);
+    dca_lfe_fir(out, in, coefs, 64);
 }
 
 av_cold void ff_dcadsp_init(DCADSPContext *s)
@@ -100,7 +106,7 @@ av_cold void ff_dcadsp_init(DCADSPContext *s)
     s->lfe_fir[0] = dca_lfe_fir0_c;
     s->lfe_fir[1] = dca_lfe_fir1_c;
     s->qmf_32_subbands = dca_qmf_32_subbands;
-    s->int8x8_fmul_int32 = int8x8_fmul_int32_c;
+    s->decode_hf = decode_hf_c;
     if (ARCH_ARM) ff_dcadsp_init_arm(s);
     if (ARCH_X86) ff_dcadsp_init_x86(s);
 }
diff --git a/deps/libav/libavcodec/dcadsp.h b/deps/libav/libavcodec/dcadsp.h
index 3e04426..0fa75a5 100644
--- a/deps/libav/libavcodec/dcadsp.h
+++ b/deps/libav/libavcodec/dcadsp.h
@@ -22,16 +22,21 @@
 #include "avfft.h"
 #include "synth_filter.h"
 
+#define DCA_SUBBANDS 32
+
 typedef struct DCADSPContext {
-    void (*lfe_fir[2])(float *out, const float *in, const float *coefs,
-                       float scale);
+    void (*lfe_fir[2])(float *out, const float *in, const float *coefs);
     void (*qmf_32_subbands)(float samples_in[32][8], int sb_act,
                             SynthFilterContext *synth, FFTContext *imdct,
                             float synth_buf_ptr[512],
                             int *synth_buf_offset, float synth_buf2[32],
                             const float window[512], float *samples_out,
                             float raXin[32], float scale);
-    void (*int8x8_fmul_int32)(float *dst, const int8_t *src, int scale);
+    void (*decode_hf)(float dst[DCA_SUBBANDS][8],
+                      const int32_t vq_num[DCA_SUBBANDS],
+                      const int8_t hf_vq[1024][32], intptr_t vq_offset,
+                      int32_t scale[DCA_SUBBANDS][2],
+                      intptr_t start, intptr_t end);
 } DCADSPContext;
 
 void ff_dcadsp_init(DCADSPContext *s);
diff --git a/deps/libav/libavcodec/dsputil.c b/deps/libav/libavcodec/dsputil.c
index 56207e8..a3b795d 100644
--- a/deps/libav/libavcodec/dsputil.c
+++ b/deps/libav/libavcodec/dsputil.c
@@ -29,7 +29,6 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/imgutils.h"
-#include "libavutil/internal.h"
 #include "avcodec.h"
 #include "copy_block.h"
 #include "dct.h"
@@ -42,7 +41,7 @@
 #include "mpegvideo.h"
 #include "config.h"
 
-uint32_t ff_squareTbl[512] = {0, };
+uint32_t ff_square_tab[512] = { 0, };
 
 #define BIT_DEPTH 16
 #include "dsputil_template.c"
@@ -52,11 +51,11 @@ uint32_t ff_squareTbl[512] = {0, };
 #include "dsputil_template.c"
 
 // 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size
-#define pb_7f (~0UL/255 * 0x7f)
-#define pb_80 (~0UL/255 * 0x80)
+#define pb_7f (~0UL / 255 * 0x7f)
+#define pb_80 (~0UL / 255 * 0x80)
 
 /* Specific zigzag scan for 248 idct. NOTE that unlike the
-   specification, we interleave the fields */
+ * specification, we interleave the fields */
 const uint8_t ff_zigzag248_direct[64] = {
      0,  8,  1,  9, 16, 24,  2, 10,
     17, 25, 32, 40, 48, 56, 33, 41,
@@ -69,7 +68,7 @@ const uint8_t ff_zigzag248_direct[64] = {
 };
 
 const uint8_t ff_alternate_horizontal_scan[64] = {
-    0,  1,   2,  3,  8,  9, 16, 17,
+     0,  1,  2,  3,  8,  9, 16, 17,
     10, 11,  4,  5,  6,  7, 15, 14,
     13, 12, 19, 18, 24, 25, 32, 33,
     26, 27, 20, 21, 22, 23, 28, 29,
@@ -80,7 +79,7 @@ const uint8_t ff_alternate_horizontal_scan[64] = {
 };
 
 const uint8_t ff_alternate_vertical_scan[64] = {
-    0,  8,  16, 24,  1,  9,  2, 10,
+     0,  8, 16, 24,  1,  9,  2, 10,
     17, 25, 32, 40, 48, 56, 57, 49,
     41, 33, 26, 18,  3, 11,  4, 12,
     19, 27, 34, 42, 50, 58, 35, 43,
@@ -91,39 +90,37 @@ const uint8_t ff_alternate_vertical_scan[64] = {
 };
 
 /* Input permutation for the simple_idct_mmx */
-static const uint8_t simple_mmx_permutation[64]={
-        0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
-        0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D,
-        0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D,
-        0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F,
-        0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F,
-        0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D,
-        0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F,
-        0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
+static const uint8_t simple_mmx_permutation[64] = {
+    0x00, 0x08, 0x04, 0x09, 0x01, 0x0C, 0x05, 0x0D,
+    0x10, 0x18, 0x14, 0x19, 0x11, 0x1C, 0x15, 0x1D,
+    0x20, 0x28, 0x24, 0x29, 0x21, 0x2C, 0x25, 0x2D,
+    0x12, 0x1A, 0x16, 0x1B, 0x13, 0x1E, 0x17, 0x1F,
+    0x02, 0x0A, 0x06, 0x0B, 0x03, 0x0E, 0x07, 0x0F,
+    0x30, 0x38, 0x34, 0x39, 0x31, 0x3C, 0x35, 0x3D,
+    0x22, 0x2A, 0x26, 0x2B, 0x23, 0x2E, 0x27, 0x2F,
+    0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
 };
 
-static const uint8_t idct_sse2_row_perm[8] = {0, 4, 1, 5, 2, 6, 3, 7};
+static const uint8_t idct_sse2_row_perm[8] = { 0, 4, 1, 5, 2, 6, 3, 7 };
 
 av_cold void ff_init_scantable(uint8_t *permutation, ScanTable *st,
                                const uint8_t *src_scantable)
 {
-    int i;
-    int end;
+    int i, end;
 
-    st->scantable= src_scantable;
+    st->scantable = src_scantable;
 
-    for(i=0; i<64; i++){
-        int j;
-        j = src_scantable[i];
+    for (i = 0; i < 64; i++) {
+        int j = src_scantable[i];
         st->permutated[i] = permutation[j];
     }
 
-    end=-1;
-    for(i=0; i<64; i++){
-        int j;
-        j = st->permutated[i];
-        if(j>end) end=j;
-        st->raster_end[i]= end;
+    end = -1;
+    for (i = 0; i < 64; i++) {
+        int j = st->permutated[i];
+        if (j > end)
+            end = j;
+        st->raster_end[i] = end;
     }
 }
 
@@ -132,51 +129,51 @@ av_cold void ff_init_scantable_permutation(uint8_t *idct_permutation,
 {
     int i;
 
-    switch(idct_permutation_type){
+    switch (idct_permutation_type) {
     case FF_NO_IDCT_PERM:
-        for(i=0; i<64; i++)
-            idct_permutation[i]= i;
+        for (i = 0; i < 64; i++)
+            idct_permutation[i] = i;
         break;
     case FF_LIBMPEG2_IDCT_PERM:
-        for(i=0; i<64; i++)
-            idct_permutation[i]= (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
+        for (i = 0; i < 64; i++)
+            idct_permutation[i] = (i & 0x38) | ((i & 6) >> 1) | ((i & 1) << 2);
         break;
     case FF_SIMPLE_IDCT_PERM:
-        for(i=0; i<64; i++)
-            idct_permutation[i]= simple_mmx_permutation[i];
+        for (i = 0; i < 64; i++)
+            idct_permutation[i] = simple_mmx_permutation[i];
         break;
     case FF_TRANSPOSE_IDCT_PERM:
-        for(i=0; i<64; i++)
-            idct_permutation[i]= ((i&7)<<3) | (i>>3);
+        for (i = 0; i < 64; i++)
+            idct_permutation[i] = ((i & 7) << 3) | (i >> 3);
         break;
     case FF_PARTTRANS_IDCT_PERM:
-        for(i=0; i<64; i++)
-            idct_permutation[i]= (i&0x24) | ((i&3)<<3) | ((i>>3)&3);
+        for (i = 0; i < 64; i++)
+            idct_permutation[i] = (i & 0x24) | ((i & 3) << 3) | ((i >> 3) & 3);
         break;
     case FF_SSE2_IDCT_PERM:
-        for(i=0; i<64; i++)
-            idct_permutation[i]= (i&0x38) | idct_sse2_row_perm[i&7];
+        for (i = 0; i < 64; i++)
+            idct_permutation[i] = (i & 0x38) | idct_sse2_row_perm[i & 7];
         break;
     default:
-        av_log(NULL, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n");
+        av_log(NULL, AV_LOG_ERROR,
+               "Internal error, IDCT permutation not set\n");
     }
 }
 
-static int pix_sum_c(uint8_t * pix, int line_size)
+static int pix_sum_c(uint8_t *pix, int line_size)
 {
-    int s, i, j;
+    int s = 0, i, j;
 
-    s = 0;
     for (i = 0; i < 16; i++) {
         for (j = 0; j < 16; j += 8) {
-            s += pix[0];
-            s += pix[1];
-            s += pix[2];
-            s += pix[3];
-            s += pix[4];
-            s += pix[5];
-            s += pix[6];
-            s += pix[7];
+            s   += pix[0];
+            s   += pix[1];
+            s   += pix[2];
+            s   += pix[3];
+            s   += pix[4];
+            s   += pix[5];
+            s   += pix[6];
+            s   += pix[7];
             pix += 8;
         }
         pix += line_size - 16;
@@ -184,12 +181,11 @@ static int pix_sum_c(uint8_t * pix, int line_size)
     return s;
 }
 
-static int pix_norm1_c(uint8_t * pix, int line_size)
+static int pix_norm1_c(uint8_t *pix, int line_size)
 {
-    int s, i, j;
-    uint32_t *sq = ff_squareTbl + 256;
+    int s = 0, i, j;
+    uint32_t *sq = ff_square_tab + 256;
 
-    s = 0;
     for (i = 0; i < 16; i++) {
         for (j = 0; j < 16; j += 8) {
 #if 0
@@ -203,26 +199,26 @@ static int pix_norm1_c(uint8_t * pix, int line_size)
             s += sq[pix[7]];
 #else
 #if HAVE_FAST_64BIT
-            register uint64_t x=*(uint64_t*)pix;
-            s += sq[x&0xff];
-            s += sq[(x>>8)&0xff];
-            s += sq[(x>>16)&0xff];
-            s += sq[(x>>24)&0xff];
-            s += sq[(x>>32)&0xff];
-            s += sq[(x>>40)&0xff];
-            s += sq[(x>>48)&0xff];
-            s += sq[(x>>56)&0xff];
+            register uint64_t x = *(uint64_t *) pix;
+            s += sq[x         & 0xff];
+            s += sq[(x >>  8) & 0xff];
+            s += sq[(x >> 16) & 0xff];
+            s += sq[(x >> 24) & 0xff];
+            s += sq[(x >> 32) & 0xff];
+            s += sq[(x >> 40) & 0xff];
+            s += sq[(x >> 48) & 0xff];
+            s += sq[(x >> 56) & 0xff];
 #else
-            register uint32_t x=*(uint32_t*)pix;
-            s += sq[x&0xff];
-            s += sq[(x>>8)&0xff];
-            s += sq[(x>>16)&0xff];
-            s += sq[(x>>24)&0xff];
-            x=*(uint32_t*)(pix+4);
-            s += sq[x&0xff];
-            s += sq[(x>>8)&0xff];
-            s += sq[(x>>16)&0xff];
-            s += sq[(x>>24)&0xff];
+            register uint32_t x = *(uint32_t *) pix;
+            s += sq[x         & 0xff];
+            s += sq[(x >>  8) & 0xff];
+            s += sq[(x >> 16) & 0xff];
+            s += sq[(x >> 24) & 0xff];
+            x  = *(uint32_t *) (pix + 4);
+            s += sq[x         & 0xff];
+            s += sq[(x >>  8) & 0xff];
+            s += sq[(x >> 16) & 0xff];
+            s += sq[(x >> 24) & 0xff];
 #endif
 #endif
             pix += 8;
@@ -232,22 +228,22 @@ static int pix_norm1_c(uint8_t * pix, int line_size)
     return s;
 }
 
-static void bswap_buf(uint32_t *dst, const uint32_t *src, int w){
+static void bswap_buf(uint32_t *dst, const uint32_t *src, int w)
+{
     int i;
 
-    for(i=0; i+8<=w; i+=8){
-        dst[i+0]= av_bswap32(src[i+0]);
-        dst[i+1]= av_bswap32(src[i+1]);
-        dst[i+2]= av_bswap32(src[i+2]);
-        dst[i+3]= av_bswap32(src[i+3]);
-        dst[i+4]= av_bswap32(src[i+4]);
-        dst[i+5]= av_bswap32(src[i+5]);
-        dst[i+6]= av_bswap32(src[i+6]);
-        dst[i+7]= av_bswap32(src[i+7]);
-    }
-    for(;i<w; i++){
-        dst[i+0]= av_bswap32(src[i+0]);
+    for (i = 0; i + 8 <= w; i += 8) {
+        dst[i + 0] = av_bswap32(src[i + 0]);
+        dst[i + 1] = av_bswap32(src[i + 1]);
+        dst[i + 2] = av_bswap32(src[i + 2]);
+        dst[i + 3] = av_bswap32(src[i + 3]);
+        dst[i + 4] = av_bswap32(src[i + 4]);
+        dst[i + 5] = av_bswap32(src[i + 5]);
+        dst[i + 6] = av_bswap32(src[i + 6]);
+        dst[i + 7] = av_bswap32(src[i + 7]);
     }
+    for (; i < w; i++)
+        dst[i + 0] = av_bswap32(src[i + 0]);
 }
 
 static void bswap16_buf(uint16_t *dst, const uint16_t *src, int len)
@@ -256,38 +252,36 @@ static void bswap16_buf(uint16_t *dst, const uint16_t *src, int len)
         *dst++ = av_bswap16(*src++);
 }
 
-static int sse4_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h)
+static int sse4_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
 {
-    int s, i;
-    uint32_t *sq = ff_squareTbl + 256;
+    int s = 0, i;
+    uint32_t *sq = ff_square_tab + 256;
 
-    s = 0;
     for (i = 0; i < h; i++) {
-        s += sq[pix1[0] - pix2[0]];
-        s += sq[pix1[1] - pix2[1]];
-        s += sq[pix1[2] - pix2[2]];
-        s += sq[pix1[3] - pix2[3]];
+        s    += sq[pix1[0] - pix2[0]];
+        s    += sq[pix1[1] - pix2[1]];
+        s    += sq[pix1[2] - pix2[2]];
+        s    += sq[pix1[3] - pix2[3]];
         pix1 += line_size;
         pix2 += line_size;
     }
     return s;
 }
 
-static int sse8_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h)
+static int sse8_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
 {
-    int s, i;
-    uint32_t *sq = ff_squareTbl + 256;
+    int s = 0, i;
+    uint32_t *sq = ff_square_tab + 256;
 
-    s = 0;
     for (i = 0; i < h; i++) {
-        s += sq[pix1[0] - pix2[0]];
-        s += sq[pix1[1] - pix2[1]];
-        s += sq[pix1[2] - pix2[2]];
-        s += sq[pix1[3] - pix2[3]];
-        s += sq[pix1[4] - pix2[4]];
-        s += sq[pix1[5] - pix2[5]];
-        s += sq[pix1[6] - pix2[6]];
-        s += sq[pix1[7] - pix2[7]];
+        s    += sq[pix1[0] - pix2[0]];
+        s    += sq[pix1[1] - pix2[1]];
+        s    += sq[pix1[2] - pix2[2]];
+        s    += sq[pix1[3] - pix2[3]];
+        s    += sq[pix1[4] - pix2[4]];
+        s    += sq[pix1[5] - pix2[5]];
+        s    += sq[pix1[6] - pix2[6]];
+        s    += sq[pix1[7] - pix2[7]];
         pix1 += line_size;
         pix2 += line_size;
     }
@@ -296,21 +290,20 @@ static int sse8_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h)
 
 static int sse16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
 {
-    int s, i;
-    uint32_t *sq = ff_squareTbl + 256;
+    int s = 0, i;
+    uint32_t *sq = ff_square_tab + 256;
 
-    s = 0;
     for (i = 0; i < h; i++) {
-        s += sq[pix1[ 0] - pix2[ 0]];
-        s += sq[pix1[ 1] - pix2[ 1]];
-        s += sq[pix1[ 2] - pix2[ 2]];
-        s += sq[pix1[ 3] - pix2[ 3]];
-        s += sq[pix1[ 4] - pix2[ 4]];
-        s += sq[pix1[ 5] - pix2[ 5]];
-        s += sq[pix1[ 6] - pix2[ 6]];
-        s += sq[pix1[ 7] - pix2[ 7]];
-        s += sq[pix1[ 8] - pix2[ 8]];
-        s += sq[pix1[ 9] - pix2[ 9]];
+        s += sq[pix1[0]  - pix2[0]];
+        s += sq[pix1[1]  - pix2[1]];
+        s += sq[pix1[2]  - pix2[2]];
+        s += sq[pix1[3]  - pix2[3]];
+        s += sq[pix1[4]  - pix2[4]];
+        s += sq[pix1[5]  - pix2[5]];
+        s += sq[pix1[6]  - pix2[6]];
+        s += sq[pix1[7]  - pix2[7]];
+        s += sq[pix1[8]  - pix2[8]];
+        s += sq[pix1[9]  - pix2[9]];
         s += sq[pix1[10] - pix2[10]];
         s += sq[pix1[11] - pix2[11]];
         s += sq[pix1[12] - pix2[12]];
@@ -325,11 +318,12 @@ static int sse16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
 }
 
 static void diff_pixels_c(int16_t *restrict block, const uint8_t *s1,
-                          const uint8_t *s2, int stride){
+                          const uint8_t *s2, int stride)
+{
     int i;
 
     /* read the pixels */
-    for(i=0;i<8;i++) {
+    for (i = 0; i < 8; i++) {
         block[0] = s1[0] - s2[0];
         block[1] = s1[1] - s2[1];
         block[2] = s1[2] - s2[2];
@@ -338,20 +332,19 @@ static void diff_pixels_c(int16_t *restrict block, const uint8_t *s1,
         block[5] = s1[5] - s2[5];
         block[6] = s1[6] - s2[6];
         block[7] = s1[7] - s2[7];
-        s1 += stride;
-        s2 += stride;
-        block += 8;
+        s1      += stride;
+        s2      += stride;
+        block   += 8;
     }
 }
 
-
 static void put_pixels_clamped_c(const int16_t *block, uint8_t *restrict pixels,
                                  int line_size)
 {
     int i;
 
     /* read the pixels */
-    for(i=0;i<8;i++) {
+    for (i = 0; i < 8; i++) {
         pixels[0] = av_clip_uint8(block[0]);
         pixels[1] = av_clip_uint8(block[1]);
         pixels[2] = av_clip_uint8(block[2]);
@@ -362,7 +355,7 @@ static void put_pixels_clamped_c(const int16_t *block, uint8_t *restrict pixels,
         pixels[7] = av_clip_uint8(block[7]);
 
         pixels += line_size;
-        block += 8;
+        block  += 8;
     }
 }
 
@@ -379,7 +372,7 @@ static void put_signed_pixels_clamped_c(const int16_t *block,
             else if (*block > 127)
                 *pixels = 255;
             else
-                *pixels = (uint8_t)(*block + 128);
+                *pixels = (uint8_t) (*block + 128);
             block++;
             pixels++;
         }
@@ -387,13 +380,12 @@ static void put_signed_pixels_clamped_c(const int16_t *block,
     }
 }
 
-static void add_pixels8_c(uint8_t *restrict pixels,
-                          int16_t *block,
+static void add_pixels8_c(uint8_t *restrict pixels, int16_t *block,
                           int line_size)
 {
     int i;
 
-    for(i=0;i<8;i++) {
+    for (i = 0; i < 8; i++) {
         pixels[0] += block[0];
         pixels[1] += block[1];
         pixels[2] += block[2];
@@ -402,8 +394,8 @@ static void add_pixels8_c(uint8_t *restrict pixels,
         pixels[5] += block[5];
         pixels[6] += block[6];
         pixels[7] += block[7];
-        pixels += line_size;
-        block += 8;
+        pixels    += line_size;
+        block     += 8;
     }
 }
 
@@ -413,7 +405,7 @@ static void add_pixels_clamped_c(const int16_t *block, uint8_t *restrict pixels,
     int i;
 
     /* read the pixels */
-    for(i=0;i<8;i++) {
+    for (i = 0; i < 8; i++) {
         pixels[0] = av_clip_uint8(pixels[0] + block[0]);
         pixels[1] = av_clip_uint8(pixels[1] + block[1]);
         pixels[2] = av_clip_uint8(pixels[2] + block[2]);
@@ -422,16 +414,17 @@ static void add_pixels_clamped_c(const int16_t *block, uint8_t *restrict pixels,
         pixels[5] = av_clip_uint8(pixels[5] + block[5]);
         pixels[6] = av_clip_uint8(pixels[6] + block[6]);
         pixels[7] = av_clip_uint8(pixels[7] + block[7]);
-        pixels += line_size;
-        block += 8;
+        pixels   += line_size;
+        block    += 8;
     }
 }
 
 static int sum_abs_dctelem_c(int16_t *block)
 {
-    int sum=0, i;
-    for(i=0; i<64; i++)
-        sum+= FFABS(block[i]);
+    int sum = 0, i;
+
+    for (i = 0; i < 64; i++)
+        sum += FFABS(block[i]);
     return sum;
 }
 
@@ -455,813 +448,1030 @@ static void fill_block8_c(uint8_t *block, uint8_t value, int line_size, int h)
     }
 }
 
-#define avg2(a,b) ((a+b+1)>>1)
-#define avg4(a,b,c,d) ((a+b+c+d+2)>>2)
+#define avg2(a, b) ((a + b + 1) >> 1)
+#define avg4(a, b, c, d) ((a + b + c + d + 2) >> 2)
 
-static void gmc1_c(uint8_t *dst, uint8_t *src, int stride, int h, int x16, int y16, int rounder)
+static void gmc1_c(uint8_t *dst, uint8_t *src, int stride, int h,
+                   int x16, int y16, int rounder)
 {
-    const int A=(16-x16)*(16-y16);
-    const int B=(   x16)*(16-y16);
-    const int C=(16-x16)*(   y16);
-    const int D=(   x16)*(   y16);
+    const int A = (16 - x16) * (16 - y16);
+    const int B = (x16)      * (16 - y16);
+    const int C = (16 - x16) * (y16);
+    const int D = (x16)      * (y16);
     int i;
 
-    for(i=0; i<h; i++)
-    {
-        dst[0]= (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1] + rounder)>>8;
-        dst[1]= (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2] + rounder)>>8;
-        dst[2]= (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3] + rounder)>>8;
-        dst[3]= (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4] + rounder)>>8;
-        dst[4]= (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5] + rounder)>>8;
-        dst[5]= (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6] + rounder)>>8;
-        dst[6]= (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7] + rounder)>>8;
-        dst[7]= (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8] + rounder)>>8;
-        dst+= stride;
-        src+= stride;
+    for (i = 0; i < h; i++) {
+        dst[0] = (A * src[0] + B * src[1] + C * src[stride + 0] + D * src[stride + 1] + rounder) >> 8;
+        dst[1] = (A * src[1] + B * src[2] + C * src[stride + 1] + D * src[stride + 2] + rounder) >> 8;
+        dst[2] = (A * src[2] + B * src[3] + C * src[stride + 2] + D * src[stride + 3] + rounder) >> 8;
+        dst[3] = (A * src[3] + B * src[4] + C * src[stride + 3] + D * src[stride + 4] + rounder) >> 8;
+        dst[4] = (A * src[4] + B * src[5] + C * src[stride + 4] + D * src[stride + 5] + rounder) >> 8;
+        dst[5] = (A * src[5] + B * src[6] + C * src[stride + 5] + D * src[stride + 6] + rounder) >> 8;
+        dst[6] = (A * src[6] + B * src[7] + C * src[stride + 6] + D * src[stride + 7] + rounder) >> 8;
+        dst[7] = (A * src[7] + B * src[8] + C * src[stride + 7] + D * src[stride + 8] + rounder) >> 8;
+        dst   += stride;
+        src   += stride;
     }
 }
 
 void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
-                  int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height)
+              int dxx, int dxy, int dyx, int dyy, int shift, int r,
+              int width, int height)
 {
     int y, vx, vy;
-    const int s= 1<<shift;
+    const int s = 1 << shift;
 
     width--;
     height--;
 
-    for(y=0; y<h; y++){
+    for (y = 0; y < h; y++) {
         int x;
 
-        vx= ox;
-        vy= oy;
-        for(x=0; x<8; x++){ //XXX FIXME optimize
-            int src_x, src_y, frac_x, frac_y, index;
-
-            src_x= vx>>16;
-            src_y= vy>>16;
-            frac_x= src_x&(s-1);
-            frac_y= src_y&(s-1);
-            src_x>>=shift;
-            src_y>>=shift;
-
-            if((unsigned)src_x < width){
-                if((unsigned)src_y < height){
-                    index= src_x + src_y*stride;
-                    dst[y*stride + x]= (  (  src[index         ]*(s-frac_x)
-                                           + src[index       +1]*   frac_x )*(s-frac_y)
-                                        + (  src[index+stride  ]*(s-frac_x)
-                                           + src[index+stride+1]*   frac_x )*   frac_y
-                                        + r)>>(shift*2);
-                }else{
-                    index= src_x + av_clip(src_y, 0, height)*stride;
-                    dst[y*stride + x]= ( (  src[index         ]*(s-frac_x)
-                                          + src[index       +1]*   frac_x )*s
-                                        + r)>>(shift*2);
+        vx = ox;
+        vy = oy;
+        for (x = 0; x < 8; x++) { // FIXME: optimize
+            int index;
+            int src_x  = vx >> 16;
+            int src_y  = vy >> 16;
+            int frac_x = src_x & (s - 1);
+            int frac_y = src_y & (s - 1);
+
+            src_x >>= shift;
+            src_y >>= shift;
+
+            if ((unsigned) src_x < width) {
+                if ((unsigned) src_y < height) {
+                    index = src_x + src_y * stride;
+                    dst[y * stride + x] =
+                        ((src[index]                        * (s - frac_x) +
+                          src[index + 1]          * frac_x) * (s - frac_y) +
+                         (src[index + stride]               * (s - frac_x) +
+                          src[index + stride + 1] * frac_x) *      frac_y  +
+                         r) >> (shift * 2);
+                } else {
+                    index = src_x + av_clip(src_y, 0, height) * stride;
+                    dst[y * stride + x] =
+                        ((src[index]               * (s - frac_x) +
+                          src[index + 1] * frac_x) *  s           +
+                         r) >> (shift * 2);
                 }
-            }else{
-                if((unsigned)src_y < height){
-                    index= av_clip(src_x, 0, width) + src_y*stride;
-                    dst[y*stride + x]= (  (  src[index         ]*(s-frac_y)
-                                           + src[index+stride  ]*   frac_y )*s
-                                        + r)>>(shift*2);
-                }else{
-                    index= av_clip(src_x, 0, width) + av_clip(src_y, 0, height)*stride;
-                    dst[y*stride + x]=    src[index         ];
+            } else {
+                if ((unsigned) src_y < height) {
+                    index = av_clip(src_x, 0, width) + src_y * stride;
+                    dst[y * stride + x] =
+                        ((src[index]                    * (s - frac_y) +
+                          src[index + stride] * frac_y) *  s           +
+                         r) >> (shift * 2);
+                } else {
+                    index = av_clip(src_x, 0, width) +
+                            av_clip(src_y, 0, height) * stride;
+                    dst[y * stride + x] = src[index];
                 }
             }
 
-            vx+= dxx;
-            vy+= dyx;
+            vx += dxx;
+            vy += dyx;
         }
         ox += dxy;
         oy += dyy;
     }
 }
 
-static inline void put_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    switch(width){
-    case 2: put_pixels2_8_c (dst, src, stride, height); break;
-    case 4: put_pixels4_8_c (dst, src, stride, height); break;
-    case 8: put_pixels8_8_c (dst, src, stride, height); break;
-    case 16:put_pixels16_8_c(dst, src, stride, height); break;
+static inline void put_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src,
+                                          int stride, int width, int height)
+{
+    switch (width) {
+    case 2:
+        put_pixels2_8_c(dst, src, stride, height);
+        break;
+    case 4:
+        put_pixels4_8_c(dst, src, stride, height);
+        break;
+    case 8:
+        put_pixels8_8_c(dst, src, stride, height);
+        break;
+    case 16:
+        put_pixels16_8_c(dst, src, stride, height);
+        break;
+    }
+}
+
+static inline void put_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src,
+                                          int stride, int width, int height)
+{
+    int i, j;
+
+    for (i = 0; i < height; i++) {
+        for (j = 0; j < width; j++)
+            dst[j] = ((2 * src[j] + src[j + 1] + 1) *
+                      683) >> 11;
+        src += stride;
+        dst += stride;
+    }
+}
+
+static inline void put_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src,
+                                          int stride, int width, int height)
+{
+    int i, j;
+
+    for (i = 0; i < height; i++) {
+        for (j = 0; j < width; j++)
+            dst[j] = ((src[j] + 2 * src[j + 1] + 1) *
+                      683) >> 11;
+        src += stride;
+        dst += stride;
+    }
+}
+
+static inline void put_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src,
+                                          int stride, int width, int height)
+{
+    int i, j;
+
+    for (i = 0; i < height; i++) {
+        for (j = 0; j < width; j++)
+            dst[j] = ((2 * src[j] + src[j + stride] + 1) *
+                      683) >> 11;
+        src += stride;
+        dst += stride;
+    }
+}
+
+static inline void put_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src,
+                                          int stride, int width, int height)
+{
+    int i, j;
+
+    for (i = 0; i < height; i++) {
+        for (j = 0; j < width; j++)
+            dst[j] = ((4 * src[j]          + 3 * src[j + 1] +
+                       3 * src[j + stride] + 2 * src[j + stride + 1] + 6) *
+                      2731) >> 15;
+        src += stride;
+        dst += stride;
+    }
+}
+
+static inline void put_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src,
+                                          int stride, int width, int height)
+{
+    int i, j;
+
+    for (i = 0; i < height; i++) {
+        for (j = 0; j < width; j++)
+            dst[j] = ((3 * src[j]          + 2 * src[j + 1] +
+                       4 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
+                      2731) >> 15;
+        src += stride;
+        dst += stride;
+    }
+}
+
+static inline void put_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src,
+                                          int stride, int width, int height)
+{
+    int i, j;
+
+    for (i = 0; i < height; i++) {
+        for (j = 0; j < width; j++)
+            dst[j] = ((src[j] + 2 * src[j + stride] + 1) *
+                      683) >> 11;
+        src += stride;
+        dst += stride;
     }
 }
 
-static inline void put_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-        dst[j] = (683*(2*src[j] + src[j+1] + 1)) >> 11;
-      }
-      src += stride;
-      dst += stride;
+static inline void put_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src,
+                                          int stride, int width, int height)
+{
+    int i, j;
+
+    for (i = 0; i < height; i++) {
+        for (j = 0; j < width; j++)
+            dst[j] = ((3 * src[j]          + 4 * src[j + 1] +
+                       2 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
+                      2731) >> 15;
+        src += stride;
+        dst += stride;
     }
 }
 
-static inline void put_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-        dst[j] = (683*(src[j] + 2*src[j+1] + 1)) >> 11;
-      }
-      src += stride;
-      dst += stride;
+static inline void put_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src,
+                                          int stride, int width, int height)
+{
+    int i, j;
+
+    for (i = 0; i < height; i++) {
+        for (j = 0; j < width; j++)
+            dst[j] = ((2 * src[j]          + 3 * src[j + 1] +
+                       3 * src[j + stride] + 4 * src[j + stride + 1] + 6) *
+                      2731) >> 15;
+        src += stride;
+        dst += stride;
     }
 }
 
-static inline void put_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-        dst[j] = (683*(2*src[j] + src[j+stride] + 1)) >> 11;
-      }
-      src += stride;
-      dst += stride;
+static inline void avg_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src,
+                                          int stride, int width, int height)
+{
+    switch (width) {
+    case 2:
+        avg_pixels2_8_c(dst, src, stride, height);
+        break;
+    case 4:
+        avg_pixels4_8_c(dst, src, stride, height);
+        break;
+    case 8:
+        avg_pixels8_8_c(dst, src, stride, height);
+        break;
+    case 16:
+        avg_pixels16_8_c(dst, src, stride, height);
+        break;
     }
 }
 
-static inline void put_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-        dst[j] = (2731*(4*src[j] + 3*src[j+1] + 3*src[j+stride] + 2*src[j+stride+1] + 6)) >> 15;
-      }
-      src += stride;
-      dst += stride;
+static inline void avg_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src,
+                                          int stride, int width, int height)
+{
+    int i, j;
+
+    for (i = 0; i < height; i++) {
+        for (j = 0; j < width; j++)
+            dst[j] = (dst[j] +
+                      (((2 * src[j] + src[j + 1] + 1) *
+                        683) >> 11) + 1) >> 1;
+        src += stride;
+        dst += stride;
     }
 }
 
-static inline void put_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-        dst[j] = (2731*(3*src[j] + 2*src[j+1] + 4*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15;
-      }
-      src += stride;
-      dst += stride;
+static inline void avg_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src,
+                                          int stride, int width, int height)
+{
+    int i, j;
+
+    for (i = 0; i < height; i++) {
+        for (j = 0; j < width; j++)
+            dst[j] = (dst[j] +
+                      (((src[j] + 2 * src[j + 1] + 1) *
+                        683) >> 11) + 1) >> 1;
+        src += stride;
+        dst += stride;
     }
 }
 
-static inline void put_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-        dst[j] = (683*(src[j] + 2*src[j+stride] + 1)) >> 11;
-      }
-      src += stride;
-      dst += stride;
+static inline void avg_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src,
+                                          int stride, int width, int height)
+{
+    int i, j;
+
+    for (i = 0; i < height; i++) {
+        for (j = 0; j < width; j++)
+            dst[j] = (dst[j] +
+                      (((2 * src[j] + src[j + stride] + 1) *
+                        683) >> 11) + 1) >> 1;
+        src += stride;
+        dst += stride;
     }
 }
 
-static inline void put_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-        dst[j] = (2731*(3*src[j] + 4*src[j+1] + 2*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15;
-      }
-      src += stride;
-      dst += stride;
+static inline void avg_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src,
+                                          int stride, int width, int height)
+{
+    int i, j;
+
+    for (i = 0; i < height; i++) {
+        for (j = 0; j < width; j++)
+            dst[j] = (dst[j] +
+                      (((4 * src[j]          + 3 * src[j + 1] +
+                         3 * src[j + stride] + 2 * src[j + stride + 1] + 6) *
+                        2731) >> 15) + 1) >> 1;
+        src += stride;
+        dst += stride;
     }
 }
 
-static inline void put_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-        dst[j] = (2731*(2*src[j] + 3*src[j+1] + 3*src[j+stride] + 4*src[j+stride+1] + 6)) >> 15;
-      }
-      src += stride;
-      dst += stride;
+static inline void avg_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src,
+                                          int stride, int width, int height)
+{
+    int i, j;
+
+    for (i = 0; i < height; i++) {
+        for (j = 0; j < width; j++)
+            dst[j] = (dst[j] +
+                      (((3 * src[j]          + 2 * src[j + 1] +
+                         4 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
+                        2731) >> 15) + 1) >> 1;
+        src += stride;
+        dst += stride;
     }
 }
 
-static inline void avg_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    switch(width){
-    case 2: avg_pixels2_8_c (dst, src, stride, height); break;
-    case 4: avg_pixels4_8_c (dst, src, stride, height); break;
-    case 8: avg_pixels8_8_c (dst, src, stride, height); break;
-    case 16:avg_pixels16_8_c(dst, src, stride, height); break;
+static inline void avg_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src,
+                                          int stride, int width, int height)
+{
+    int i, j;
+
+    for (i = 0; i < height; i++) {
+        for (j = 0; j < width; j++)
+            dst[j] = (dst[j] +
+                      (((src[j] + 2 * src[j + stride] + 1) *
+                        683) >> 11) + 1) >> 1;
+        src += stride;
+        dst += stride;
     }
 }
 
-static inline void avg_tpel_pixels_mc10_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-        dst[j] = (dst[j] + ((683*(2*src[j] + src[j+1] + 1)) >> 11) + 1) >> 1;
-      }
-      src += stride;
-      dst += stride;
+static inline void avg_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src,
+                                          int stride, int width, int height)
+{
+    int i, j;
+
+    for (i = 0; i < height; i++) {
+        for (j = 0; j < width; j++)
+            dst[j] = (dst[j] +
+                      (((3 * src[j]          + 4 * src[j + 1] +
+                         2 * src[j + stride] + 3 * src[j + stride + 1] + 6) *
+                        2731) >> 15) + 1) >> 1;
+        src += stride;
+        dst += stride;
     }
 }
 
-static inline void avg_tpel_pixels_mc20_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-        dst[j] = (dst[j] + ((683*(src[j] + 2*src[j+1] + 1)) >> 11) + 1) >> 1;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-
-static inline void avg_tpel_pixels_mc01_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-        dst[j] = (dst[j] + ((683*(2*src[j] + src[j+stride] + 1)) >> 11) + 1) >> 1;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-
-static inline void avg_tpel_pixels_mc11_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-        dst[j] = (dst[j] + ((2731*(4*src[j] + 3*src[j+1] + 3*src[j+stride] + 2*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-
-static inline void avg_tpel_pixels_mc12_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-        dst[j] = (dst[j] + ((2731*(3*src[j] + 2*src[j+1] + 4*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-
-static inline void avg_tpel_pixels_mc02_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-        dst[j] = (dst[j] + ((683*(src[j] + 2*src[j+stride] + 1)) >> 11) + 1) >> 1;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-
-static inline void avg_tpel_pixels_mc21_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-        dst[j] = (dst[j] + ((2731*(3*src[j] + 4*src[j+1] + 2*src[j+stride] + 3*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-
-static inline void avg_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
-    int i,j;
-    for (i=0; i < height; i++) {
-      for (j=0; j < width; j++) {
-        dst[j] = (dst[j] + ((2731*(2*src[j] + 3*src[j+1] + 3*src[j+stride] + 4*src[j+stride+1] + 6)) >> 15) + 1) >> 1;
-      }
-      src += stride;
-      dst += stride;
-    }
-}
-
-#define QPEL_MC(r, OPNAME, RND, OP) \
-static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
-    int i;\
-    for(i=0; i<h; i++)\
-    {\
-        OP(dst[0], (src[0]+src[1])*20 - (src[0]+src[2])*6 + (src[1]+src[3])*3 - (src[2]+src[4]));\
-        OP(dst[1], (src[1]+src[2])*20 - (src[0]+src[3])*6 + (src[0]+src[4])*3 - (src[1]+src[5]));\
-        OP(dst[2], (src[2]+src[3])*20 - (src[1]+src[4])*6 + (src[0]+src[5])*3 - (src[0]+src[6]));\
-        OP(dst[3], (src[3]+src[4])*20 - (src[2]+src[5])*6 + (src[1]+src[6])*3 - (src[0]+src[7]));\
-        OP(dst[4], (src[4]+src[5])*20 - (src[3]+src[6])*6 + (src[2]+src[7])*3 - (src[1]+src[8]));\
-        OP(dst[5], (src[5]+src[6])*20 - (src[4]+src[7])*6 + (src[3]+src[8])*3 - (src[2]+src[8]));\
-        OP(dst[6], (src[6]+src[7])*20 - (src[5]+src[8])*6 + (src[4]+src[8])*3 - (src[3]+src[7]));\
-        OP(dst[7], (src[7]+src[8])*20 - (src[6]+src[8])*6 + (src[5]+src[7])*3 - (src[4]+src[6]));\
-        dst+=dstStride;\
-        src+=srcStride;\
-    }\
-}\
-\
-static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    const int w=8;\
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
-    int i;\
-    for(i=0; i<w; i++)\
-    {\
-        const int src0= src[0*srcStride];\
-        const int src1= src[1*srcStride];\
-        const int src2= src[2*srcStride];\
-        const int src3= src[3*srcStride];\
-        const int src4= src[4*srcStride];\
-        const int src5= src[5*srcStride];\
-        const int src6= src[6*srcStride];\
-        const int src7= src[7*srcStride];\
-        const int src8= src[8*srcStride];\
-        OP(dst[0*dstStride], (src0+src1)*20 - (src0+src2)*6 + (src1+src3)*3 - (src2+src4));\
-        OP(dst[1*dstStride], (src1+src2)*20 - (src0+src3)*6 + (src0+src4)*3 - (src1+src5));\
-        OP(dst[2*dstStride], (src2+src3)*20 - (src1+src4)*6 + (src0+src5)*3 - (src0+src6));\
-        OP(dst[3*dstStride], (src3+src4)*20 - (src2+src5)*6 + (src1+src6)*3 - (src0+src7));\
-        OP(dst[4*dstStride], (src4+src5)*20 - (src3+src6)*6 + (src2+src7)*3 - (src1+src8));\
-        OP(dst[5*dstStride], (src5+src6)*20 - (src4+src7)*6 + (src3+src8)*3 - (src2+src8));\
-        OP(dst[6*dstStride], (src6+src7)*20 - (src5+src8)*6 + (src4+src8)*3 - (src3+src7));\
-        OP(dst[7*dstStride], (src7+src8)*20 - (src6+src8)*6 + (src5+src7)*3 - (src4+src6));\
-        dst++;\
-        src++;\
-    }\
-}\
-\
-static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){\
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
-    int i;\
-    \
-    for(i=0; i<h; i++)\
-    {\
-        OP(dst[ 0], (src[ 0]+src[ 1])*20 - (src[ 0]+src[ 2])*6 + (src[ 1]+src[ 3])*3 - (src[ 2]+src[ 4]));\
-        OP(dst[ 1], (src[ 1]+src[ 2])*20 - (src[ 0]+src[ 3])*6 + (src[ 0]+src[ 4])*3 - (src[ 1]+src[ 5]));\
-        OP(dst[ 2], (src[ 2]+src[ 3])*20 - (src[ 1]+src[ 4])*6 + (src[ 0]+src[ 5])*3 - (src[ 0]+src[ 6]));\
-        OP(dst[ 3], (src[ 3]+src[ 4])*20 - (src[ 2]+src[ 5])*6 + (src[ 1]+src[ 6])*3 - (src[ 0]+src[ 7]));\
-        OP(dst[ 4], (src[ 4]+src[ 5])*20 - (src[ 3]+src[ 6])*6 + (src[ 2]+src[ 7])*3 - (src[ 1]+src[ 8]));\
-        OP(dst[ 5], (src[ 5]+src[ 6])*20 - (src[ 4]+src[ 7])*6 + (src[ 3]+src[ 8])*3 - (src[ 2]+src[ 9]));\
-        OP(dst[ 6], (src[ 6]+src[ 7])*20 - (src[ 5]+src[ 8])*6 + (src[ 4]+src[ 9])*3 - (src[ 3]+src[10]));\
-        OP(dst[ 7], (src[ 7]+src[ 8])*20 - (src[ 6]+src[ 9])*6 + (src[ 5]+src[10])*3 - (src[ 4]+src[11]));\
-        OP(dst[ 8], (src[ 8]+src[ 9])*20 - (src[ 7]+src[10])*6 + (src[ 6]+src[11])*3 - (src[ 5]+src[12]));\
-        OP(dst[ 9], (src[ 9]+src[10])*20 - (src[ 8]+src[11])*6 + (src[ 7]+src[12])*3 - (src[ 6]+src[13]));\
-        OP(dst[10], (src[10]+src[11])*20 - (src[ 9]+src[12])*6 + (src[ 8]+src[13])*3 - (src[ 7]+src[14]));\
-        OP(dst[11], (src[11]+src[12])*20 - (src[10]+src[13])*6 + (src[ 9]+src[14])*3 - (src[ 8]+src[15]));\
-        OP(dst[12], (src[12]+src[13])*20 - (src[11]+src[14])*6 + (src[10]+src[15])*3 - (src[ 9]+src[16]));\
-        OP(dst[13], (src[13]+src[14])*20 - (src[12]+src[15])*6 + (src[11]+src[16])*3 - (src[10]+src[16]));\
-        OP(dst[14], (src[14]+src[15])*20 - (src[13]+src[16])*6 + (src[12]+src[16])*3 - (src[11]+src[15]));\
-        OP(dst[15], (src[15]+src[16])*20 - (src[14]+src[16])*6 + (src[13]+src[15])*3 - (src[12]+src[14]));\
-        dst+=dstStride;\
-        src+=srcStride;\
-    }\
-}\
-\
-static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
-    int i;\
-    const int w=16;\
-    for(i=0; i<w; i++)\
-    {\
-        const int src0= src[0*srcStride];\
-        const int src1= src[1*srcStride];\
-        const int src2= src[2*srcStride];\
-        const int src3= src[3*srcStride];\
-        const int src4= src[4*srcStride];\
-        const int src5= src[5*srcStride];\
-        const int src6= src[6*srcStride];\
-        const int src7= src[7*srcStride];\
-        const int src8= src[8*srcStride];\
-        const int src9= src[9*srcStride];\
-        const int src10= src[10*srcStride];\
-        const int src11= src[11*srcStride];\
-        const int src12= src[12*srcStride];\
-        const int src13= src[13*srcStride];\
-        const int src14= src[14*srcStride];\
-        const int src15= src[15*srcStride];\
-        const int src16= src[16*srcStride];\
-        OP(dst[ 0*dstStride], (src0 +src1 )*20 - (src0 +src2 )*6 + (src1 +src3 )*3 - (src2 +src4 ));\
-        OP(dst[ 1*dstStride], (src1 +src2 )*20 - (src0 +src3 )*6 + (src0 +src4 )*3 - (src1 +src5 ));\
-        OP(dst[ 2*dstStride], (src2 +src3 )*20 - (src1 +src4 )*6 + (src0 +src5 )*3 - (src0 +src6 ));\
-        OP(dst[ 3*dstStride], (src3 +src4 )*20 - (src2 +src5 )*6 + (src1 +src6 )*3 - (src0 +src7 ));\
-        OP(dst[ 4*dstStride], (src4 +src5 )*20 - (src3 +src6 )*6 + (src2 +src7 )*3 - (src1 +src8 ));\
-        OP(dst[ 5*dstStride], (src5 +src6 )*20 - (src4 +src7 )*6 + (src3 +src8 )*3 - (src2 +src9 ));\
-        OP(dst[ 6*dstStride], (src6 +src7 )*20 - (src5 +src8 )*6 + (src4 +src9 )*3 - (src3 +src10));\
-        OP(dst[ 7*dstStride], (src7 +src8 )*20 - (src6 +src9 )*6 + (src5 +src10)*3 - (src4 +src11));\
-        OP(dst[ 8*dstStride], (src8 +src9 )*20 - (src7 +src10)*6 + (src6 +src11)*3 - (src5 +src12));\
-        OP(dst[ 9*dstStride], (src9 +src10)*20 - (src8 +src11)*6 + (src7 +src12)*3 - (src6 +src13));\
-        OP(dst[10*dstStride], (src10+src11)*20 - (src9 +src12)*6 + (src8 +src13)*3 - (src7 +src14));\
-        OP(dst[11*dstStride], (src11+src12)*20 - (src10+src13)*6 + (src9 +src14)*3 - (src8 +src15));\
-        OP(dst[12*dstStride], (src12+src13)*20 - (src11+src14)*6 + (src10+src15)*3 - (src9 +src16));\
-        OP(dst[13*dstStride], (src13+src14)*20 - (src12+src15)*6 + (src11+src16)*3 - (src10+src16));\
-        OP(dst[14*dstStride], (src14+src15)*20 - (src13+src16)*6 + (src12+src16)*3 - (src11+src15));\
-        OP(dst[15*dstStride], (src15+src16)*20 - (src14+src16)*6 + (src13+src15)*3 - (src12+src14));\
-        dst++;\
-        src++;\
-    }\
-}\
-\
-static void OPNAME ## qpel8_mc10_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t half[64];\
-    put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\
-    OPNAME ## pixels8_l2_8(dst, src, half, stride, stride, 8, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc20_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    OPNAME ## mpeg4_qpel8_h_lowpass(dst, src, stride, stride, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc30_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t half[64];\
-    put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);\
-    OPNAME ## pixels8_l2_8(dst, src+1, half, stride, stride, 8, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc01_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[16*9];\
-    uint8_t half[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\
-    OPNAME ## pixels8_l2_8(dst, full, half, stride, 16, 8, 8);\
-}\
-\
-static void OPNAME ## qpel8_mc02_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[16*9];\
-    copy_block9(full, src, 16, stride, 9);\
-    OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16);\
-}\
-\
-static void OPNAME ## qpel8_mc03_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[16*9];\
-    uint8_t half[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);\
-    OPNAME ## pixels8_l2_8(dst, full+16, half, stride, 16, 8, 8);\
-}\
-void ff_ ## OPNAME ## qpel8_mc11_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfV[64];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l4_8(dst, full, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc11_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8);\
-}\
-void ff_ ## OPNAME ## qpel8_mc31_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfV[64];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l4_8(dst, full+1, halfH, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc31_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## pixels8_l2_8(halfH, halfH, full+1, 8, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8);\
-}\
-void ff_ ## OPNAME ## qpel8_mc13_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfV[64];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l4_8(dst, full+16, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc13_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_8(dst, halfH+8, halfHV, stride, 8, 8, 8);\
-}\
-void ff_ ## OPNAME ## qpel8_mc33_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfV[64];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full  , 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l4_8(dst, full+17, halfH+8, halfV, halfHV, stride, 16, 8, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## pixels8_l2_8(halfH, halfH, full+1, 8, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_8(dst, halfH+8, halfHV, stride, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc21_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t halfH[72];\
-    uint8_t halfHV[64];\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc23_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t halfH[72];\
-    uint8_t halfHV[64];\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_8(dst, halfH+8, halfHV, stride, 8, 8, 8);\
-}\
-void ff_ ## OPNAME ## qpel8_mc12_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfV[64];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc12_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9);\
-    OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
-}\
-void ff_ ## OPNAME ## qpel8_mc32_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    uint8_t halfV[64];\
-    uint8_t halfHV[64];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full+1, 8, 16);\
-    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);\
-    OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);\
-}\
-static void OPNAME ## qpel8_mc32_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[16*9];\
-    uint8_t halfH[72];\
-    copy_block9(full, src, 16, stride, 9);\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);\
-    put ## RND ## pixels8_l2_8(halfH, halfH, full+1, 8, 8, 16, 9);\
-    OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
-}\
-static void OPNAME ## qpel8_mc22_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t halfH[72];\
-    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);\
-    OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);\
-}\
-\
-static void OPNAME ## qpel16_mc10_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t half[256];\
-    put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\
-    OPNAME ## pixels16_l2_8(dst, src, half, stride, stride, 16, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc20_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    OPNAME ## mpeg4_qpel16_h_lowpass(dst, src, stride, stride, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc30_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t half[256];\
-    put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);\
-    OPNAME ## pixels16_l2_8(dst, src+1, half, stride, stride, 16, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc01_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[24*17];\
-    uint8_t half[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\
-    OPNAME ## pixels16_l2_8(dst, full, half, stride, 24, 16, 16);\
-}\
-\
-static void OPNAME ## qpel16_mc02_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[24*17];\
-    copy_block17(full, src, 24, stride, 17);\
-    OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24);\
-}\
-\
-static void OPNAME ## qpel16_mc03_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[24*17];\
-    uint8_t half[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);\
-    OPNAME ## pixels16_l2_8(dst, full+24, half, stride, 24, 16, 16);\
-}\
-void ff_ ## OPNAME ## qpel16_mc11_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfV[256];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l4_8(dst, full, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc11_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16);\
-}\
-void ff_ ## OPNAME ## qpel16_mc31_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfV[256];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l4_8(dst, full+1, halfH, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc31_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## pixels16_l2_8(halfH, halfH, full+1, 16, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16);\
-}\
-void ff_ ## OPNAME ## qpel16_mc13_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfV[256];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l4_8(dst, full+24, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc13_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_8(dst, halfH+16, halfHV, stride, 16, 16, 16);\
-}\
-void ff_ ## OPNAME ## qpel16_mc33_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfV[256];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full  , 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l4_8(dst, full+25, halfH+16, halfV, halfHV, stride, 24, 16, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## pixels16_l2_8(halfH, halfH, full+1, 16, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_8(dst, halfH+16, halfHV, stride, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc21_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t halfH[272];\
-    uint8_t halfHV[256];\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc23_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t halfH[272];\
-    uint8_t halfHV[256];\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_8(dst, halfH+16, halfHV, stride, 16, 16, 16);\
-}\
-void ff_ ## OPNAME ## qpel16_mc12_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfV[256];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc12_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17);\
-    OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
-}\
-void ff_ ## OPNAME ## qpel16_mc32_old_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    uint8_t halfV[256];\
-    uint8_t halfHV[256];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full+1, 16, 24);\
-    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);\
-    OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16);\
-}\
-static void OPNAME ## qpel16_mc32_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t full[24*17];\
-    uint8_t halfH[272];\
-    copy_block17(full, src, 24, stride, 17);\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);\
-    put ## RND ## pixels16_l2_8(halfH, halfH, full+1, 16, 16, 24, 17);\
-    OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
-}\
-static void OPNAME ## qpel16_mc22_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)\
-{\
-    uint8_t halfH[272];\
-    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);\
-    OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);\
-}
-
-#define op_avg(a, b) a = (((a)+cm[((b) + 16)>>5]+1)>>1)
-#define op_avg_no_rnd(a, b) a = (((a)+cm[((b) + 15)>>5])>>1)
-#define op_put(a, b) a = cm[((b) + 16)>>5]
-#define op_put_no_rnd(a, b) a = cm[((b) + 15)>>5]
-
-QPEL_MC(0, put_       , _       , op_put)
+static inline void avg_tpel_pixels_mc22_c(uint8_t *dst, const uint8_t *src,
+                                          int stride, int width, int height)
+{
+    int i, j;
+
+    for (i = 0; i < height; i++) {
+        for (j = 0; j < width; j++)
+            dst[j] = (dst[j] +
+                      (((2 * src[j]          + 3 * src[j + 1] +
+                         3 * src[j + stride] + 4 * src[j + stride + 1] + 6) *
+                        2731) >> 15) + 1) >> 1;
+        src += stride;
+        dst += stride;
+    }
+}
+
+#define QPEL_MC(r, OPNAME, RND, OP)                                           \
+static void OPNAME ## mpeg4_qpel8_h_lowpass(uint8_t *dst, uint8_t *src,       \
+                                            int dstStride, int srcStride,     \
+                                            int h)                            \
+{                                                                             \
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;                           \
+    int i;                                                                    \
+                                                                              \
+    for (i = 0; i < h; i++) {                                                 \
+        OP(dst[0], (src[0] + src[1]) * 20 - (src[0] + src[2]) * 6 + (src[1] + src[3]) * 3 - (src[2] + src[4])); \
+        OP(dst[1], (src[1] + src[2]) * 20 - (src[0] + src[3]) * 6 + (src[0] + src[4]) * 3 - (src[1] + src[5])); \
+        OP(dst[2], (src[2] + src[3]) * 20 - (src[1] + src[4]) * 6 + (src[0] + src[5]) * 3 - (src[0] + src[6])); \
+        OP(dst[3], (src[3] + src[4]) * 20 - (src[2] + src[5]) * 6 + (src[1] + src[6]) * 3 - (src[0] + src[7])); \
+        OP(dst[4], (src[4] + src[5]) * 20 - (src[3] + src[6]) * 6 + (src[2] + src[7]) * 3 - (src[1] + src[8])); \
+        OP(dst[5], (src[5] + src[6]) * 20 - (src[4] + src[7]) * 6 + (src[3] + src[8]) * 3 - (src[2] + src[8])); \
+        OP(dst[6], (src[6] + src[7]) * 20 - (src[5] + src[8]) * 6 + (src[4] + src[8]) * 3 - (src[3] + src[7])); \
+        OP(dst[7], (src[7] + src[8]) * 20 - (src[6] + src[8]) * 6 + (src[5] + src[7]) * 3 - (src[4] + src[6])); \
+        dst += dstStride;                                                     \
+        src += srcStride;                                                     \
+    }                                                                         \
+}                                                                             \
+                                                                              \
+static void OPNAME ## mpeg4_qpel8_v_lowpass(uint8_t *dst, uint8_t *src,       \
+                                            int dstStride, int srcStride)     \
+{                                                                             \
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;                           \
+    const int w = 8;                                                          \
+    int i;                                                                    \
+                                                                              \
+    for (i = 0; i < w; i++) {                                                 \
+        const int src0 = src[0 * srcStride];                                  \
+        const int src1 = src[1 * srcStride];                                  \
+        const int src2 = src[2 * srcStride];                                  \
+        const int src3 = src[3 * srcStride];                                  \
+        const int src4 = src[4 * srcStride];                                  \
+        const int src5 = src[5 * srcStride];                                  \
+        const int src6 = src[6 * srcStride];                                  \
+        const int src7 = src[7 * srcStride];                                  \
+        const int src8 = src[8 * srcStride];                                  \
+        OP(dst[0 * dstStride], (src0 + src1) * 20 - (src0 + src2) * 6 + (src1 + src3) * 3 - (src2 + src4)); \
+        OP(dst[1 * dstStride], (src1 + src2) * 20 - (src0 + src3) * 6 + (src0 + src4) * 3 - (src1 + src5)); \
+        OP(dst[2 * dstStride], (src2 + src3) * 20 - (src1 + src4) * 6 + (src0 + src5) * 3 - (src0 + src6)); \
+        OP(dst[3 * dstStride], (src3 + src4) * 20 - (src2 + src5) * 6 + (src1 + src6) * 3 - (src0 + src7)); \
+        OP(dst[4 * dstStride], (src4 + src5) * 20 - (src3 + src6) * 6 + (src2 + src7) * 3 - (src1 + src8)); \
+        OP(dst[5 * dstStride], (src5 + src6) * 20 - (src4 + src7) * 6 + (src3 + src8) * 3 - (src2 + src8)); \
+        OP(dst[6 * dstStride], (src6 + src7) * 20 - (src5 + src8) * 6 + (src4 + src8) * 3 - (src3 + src7)); \
+        OP(dst[7 * dstStride], (src7 + src8) * 20 - (src6 + src8) * 6 + (src5 + src7) * 3 - (src4 + src6)); \
+        dst++;                                                                \
+        src++;                                                                \
+    }                                                                         \
+}                                                                             \
+                                                                              \
+static void OPNAME ## mpeg4_qpel16_h_lowpass(uint8_t *dst, uint8_t *src,      \
+                                             int dstStride, int srcStride,    \
+                                             int h)                           \
+{                                                                             \
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;                           \
+    int i;                                                                    \
+                                                                              \
+    for (i = 0; i < h; i++) {                                                 \
+        OP(dst[0],  (src[0]  + src[1])  * 20 - (src[0]  + src[2])  * 6 + (src[1]  + src[3])  * 3 - (src[2]  + src[4]));  \
+        OP(dst[1],  (src[1]  + src[2])  * 20 - (src[0]  + src[3])  * 6 + (src[0]  + src[4])  * 3 - (src[1]  + src[5]));  \
+        OP(dst[2],  (src[2]  + src[3])  * 20 - (src[1]  + src[4])  * 6 + (src[0]  + src[5])  * 3 - (src[0]  + src[6]));  \
+        OP(dst[3],  (src[3]  + src[4])  * 20 - (src[2]  + src[5])  * 6 + (src[1]  + src[6])  * 3 - (src[0]  + src[7]));  \
+        OP(dst[4],  (src[4]  + src[5])  * 20 - (src[3]  + src[6])  * 6 + (src[2]  + src[7])  * 3 - (src[1]  + src[8]));  \
+        OP(dst[5],  (src[5]  + src[6])  * 20 - (src[4]  + src[7])  * 6 + (src[3]  + src[8])  * 3 - (src[2]  + src[9]));  \
+        OP(dst[6],  (src[6]  + src[7])  * 20 - (src[5]  + src[8])  * 6 + (src[4]  + src[9])  * 3 - (src[3]  + src[10])); \
+        OP(dst[7],  (src[7]  + src[8])  * 20 - (src[6]  + src[9])  * 6 + (src[5]  + src[10]) * 3 - (src[4]  + src[11])); \
+        OP(dst[8],  (src[8]  + src[9])  * 20 - (src[7]  + src[10]) * 6 + (src[6]  + src[11]) * 3 - (src[5]  + src[12])); \
+        OP(dst[9],  (src[9]  + src[10]) * 20 - (src[8]  + src[11]) * 6 + (src[7]  + src[12]) * 3 - (src[6]  + src[13])); \
+        OP(dst[10], (src[10] + src[11]) * 20 - (src[9]  + src[12]) * 6 + (src[8]  + src[13]) * 3 - (src[7]  + src[14])); \
+        OP(dst[11], (src[11] + src[12]) * 20 - (src[10] + src[13]) * 6 + (src[9]  + src[14]) * 3 - (src[8]  + src[15])); \
+        OP(dst[12], (src[12] + src[13]) * 20 - (src[11] + src[14]) * 6 + (src[10] + src[15]) * 3 - (src[9]  + src[16])); \
+        OP(dst[13], (src[13] + src[14]) * 20 - (src[12] + src[15]) * 6 + (src[11] + src[16]) * 3 - (src[10] + src[16])); \
+        OP(dst[14], (src[14] + src[15]) * 20 - (src[13] + src[16]) * 6 + (src[12] + src[16]) * 3 - (src[11] + src[15])); \
+        OP(dst[15], (src[15] + src[16]) * 20 - (src[14] + src[16]) * 6 + (src[13] + src[15]) * 3 - (src[12] + src[14])); \
+        dst += dstStride;                                                     \
+        src += srcStride;                                                     \
+    }                                                                         \
+}                                                                             \
+                                                                              \
+static void OPNAME ## mpeg4_qpel16_v_lowpass(uint8_t *dst, uint8_t *src,      \
+                                             int dstStride, int srcStride)    \
+{                                                                             \
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;                           \
+    const int w = 16;                                                         \
+    int i;                                                                    \
+                                                                              \
+    for (i = 0; i < w; i++) {                                                 \
+        const int src0  = src[0  * srcStride];                                \
+        const int src1  = src[1  * srcStride];                                \
+        const int src2  = src[2  * srcStride];                                \
+        const int src3  = src[3  * srcStride];                                \
+        const int src4  = src[4  * srcStride];                                \
+        const int src5  = src[5  * srcStride];                                \
+        const int src6  = src[6  * srcStride];                                \
+        const int src7  = src[7  * srcStride];                                \
+        const int src8  = src[8  * srcStride];                                \
+        const int src9  = src[9  * srcStride];                                \
+        const int src10 = src[10 * srcStride];                                \
+        const int src11 = src[11 * srcStride];                                \
+        const int src12 = src[12 * srcStride];                                \
+        const int src13 = src[13 * srcStride];                                \
+        const int src14 = src[14 * srcStride];                                \
+        const int src15 = src[15 * srcStride];                                \
+        const int src16 = src[16 * srcStride];                                \
+        OP(dst[0  * dstStride], (src0  + src1)  * 20 - (src0  + src2)  * 6 + (src1  + src3)  * 3 - (src2  + src4));  \
+        OP(dst[1  * dstStride], (src1  + src2)  * 20 - (src0  + src3)  * 6 + (src0  + src4)  * 3 - (src1  + src5));  \
+        OP(dst[2  * dstStride], (src2  + src3)  * 20 - (src1  + src4)  * 6 + (src0  + src5)  * 3 - (src0  + src6));  \
+        OP(dst[3  * dstStride], (src3  + src4)  * 20 - (src2  + src5)  * 6 + (src1  + src6)  * 3 - (src0  + src7));  \
+        OP(dst[4  * dstStride], (src4  + src5)  * 20 - (src3  + src6)  * 6 + (src2  + src7)  * 3 - (src1  + src8));  \
+        OP(dst[5  * dstStride], (src5  + src6)  * 20 - (src4  + src7)  * 6 + (src3  + src8)  * 3 - (src2  + src9));  \
+        OP(dst[6  * dstStride], (src6  + src7)  * 20 - (src5  + src8)  * 6 + (src4  + src9)  * 3 - (src3  + src10)); \
+        OP(dst[7  * dstStride], (src7  + src8)  * 20 - (src6  + src9)  * 6 + (src5  + src10) * 3 - (src4  + src11)); \
+        OP(dst[8  * dstStride], (src8  + src9)  * 20 - (src7  + src10) * 6 + (src6  + src11) * 3 - (src5  + src12)); \
+        OP(dst[9  * dstStride], (src9  + src10) * 20 - (src8  + src11) * 6 + (src7  + src12) * 3 - (src6  + src13)); \
+        OP(dst[10 * dstStride], (src10 + src11) * 20 - (src9  + src12) * 6 + (src8  + src13) * 3 - (src7  + src14)); \
+        OP(dst[11 * dstStride], (src11 + src12) * 20 - (src10 + src13) * 6 + (src9  + src14) * 3 - (src8  + src15)); \
+        OP(dst[12 * dstStride], (src12 + src13) * 20 - (src11 + src14) * 6 + (src10 + src15) * 3 - (src9  + src16)); \
+        OP(dst[13 * dstStride], (src13 + src14) * 20 - (src12 + src15) * 6 + (src11 + src16) * 3 - (src10 + src16)); \
+        OP(dst[14 * dstStride], (src14 + src15) * 20 - (src13 + src16) * 6 + (src12 + src16) * 3 - (src11 + src15)); \
+        OP(dst[15 * dstStride], (src15 + src16) * 20 - (src14 + src16) * 6 + (src13 + src15) * 3 - (src12 + src14)); \
+        dst++;                                                                \
+        src++;                                                                \
+    }                                                                         \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel8_mc10_c(uint8_t *dst, uint8_t *src,                \
+                                   ptrdiff_t stride)                          \
+{                                                                             \
+    uint8_t half[64];                                                         \
+                                                                              \
+    put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);             \
+    OPNAME ## pixels8_l2_8(dst, src, half, stride, stride, 8, 8);             \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel8_mc20_c(uint8_t *dst, uint8_t *src,                \
+                                   ptrdiff_t stride)                          \
+{                                                                             \
+    OPNAME ## mpeg4_qpel8_h_lowpass(dst, src, stride, stride, 8);             \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel8_mc30_c(uint8_t *dst, uint8_t *src,                \
+                                   ptrdiff_t stride)                          \
+{                                                                             \
+    uint8_t half[64];                                                         \
+                                                                              \
+    put ## RND ## mpeg4_qpel8_h_lowpass(half, src, 8, stride, 8);             \
+    OPNAME ## pixels8_l2_8(dst, src + 1, half, stride, stride, 8, 8);         \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel8_mc01_c(uint8_t *dst, uint8_t *src,                \
+                                   ptrdiff_t stride)                          \
+{                                                                             \
+    uint8_t full[16 * 9];                                                     \
+    uint8_t half[64];                                                         \
+                                                                              \
+    copy_block9(full, src, 16, stride, 9);                                    \
+    put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);                   \
+    OPNAME ## pixels8_l2_8(dst, full, half, stride, 16, 8, 8);                \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel8_mc02_c(uint8_t *dst, uint8_t *src,                \
+                                   ptrdiff_t stride)                          \
+{                                                                             \
+    uint8_t full[16 * 9];                                                     \
+                                                                              \
+    copy_block9(full, src, 16, stride, 9);                                    \
+    OPNAME ## mpeg4_qpel8_v_lowpass(dst, full, stride, 16);                   \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel8_mc03_c(uint8_t *dst, uint8_t *src,                \
+                                   ptrdiff_t stride)                          \
+{                                                                             \
+    uint8_t full[16 * 9];                                                     \
+    uint8_t half[64];                                                         \
+                                                                              \
+    copy_block9(full, src, 16, stride, 9);                                    \
+    put ## RND ## mpeg4_qpel8_v_lowpass(half, full, 8, 16);                   \
+    OPNAME ## pixels8_l2_8(dst, full + 16, half, stride, 16, 8, 8);           \
+}                                                                             \
+                                                                              \
+void ff_ ## OPNAME ## qpel8_mc11_old_c(uint8_t *dst, uint8_t *src,            \
+                                       ptrdiff_t stride)                      \
+{                                                                             \
+    uint8_t full[16 * 9];                                                     \
+    uint8_t halfH[72];                                                        \
+    uint8_t halfV[64];                                                        \
+    uint8_t halfHV[64];                                                       \
+                                                                              \
+    copy_block9(full, src, 16, stride, 9);                                    \
+    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
+    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);                  \
+    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
+    OPNAME ## pixels8_l4_8(dst, full, halfH, halfV, halfHV,                   \
+                           stride, 16, 8, 8, 8, 8);                           \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel8_mc11_c(uint8_t *dst, uint8_t *src,                \
+                                   ptrdiff_t stride)                          \
+{                                                                             \
+    uint8_t full[16 * 9];                                                     \
+    uint8_t halfH[72];                                                        \
+    uint8_t halfHV[64];                                                       \
+                                                                              \
+    copy_block9(full, src, 16, stride, 9);                                    \
+    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
+    put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9);              \
+    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
+    OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8);              \
+}                                                                             \
+                                                                              \
+void ff_ ## OPNAME ## qpel8_mc31_old_c(uint8_t *dst, uint8_t *src,            \
+                                       ptrdiff_t stride)                      \
+{                                                                             \
+    uint8_t full[16 * 9];                                                     \
+    uint8_t halfH[72];                                                        \
+    uint8_t halfV[64];                                                        \
+    uint8_t halfHV[64];                                                       \
+                                                                              \
+    copy_block9(full, src, 16, stride, 9);                                    \
+    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
+    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full + 1, 8, 16);              \
+    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
+    OPNAME ## pixels8_l4_8(dst, full + 1, halfH, halfV, halfHV,               \
+                           stride, 16, 8, 8, 8, 8);                           \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel8_mc31_c(uint8_t *dst, uint8_t *src,                \
+                                   ptrdiff_t stride)                          \
+{                                                                             \
+    uint8_t full[16 * 9];                                                     \
+    uint8_t halfH[72];                                                        \
+    uint8_t halfHV[64];                                                       \
+                                                                              \
+    copy_block9(full, src, 16, stride, 9);                                    \
+    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
+    put ## RND ## pixels8_l2_8(halfH, halfH, full + 1, 8, 8, 16, 9);          \
+    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
+    OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8);              \
+}                                                                             \
+                                                                              \
+void ff_ ## OPNAME ## qpel8_mc13_old_c(uint8_t *dst, uint8_t *src,            \
+                                       ptrdiff_t stride)                      \
+{                                                                             \
+    uint8_t full[16 * 9];                                                     \
+    uint8_t halfH[72];                                                        \
+    uint8_t halfV[64];                                                        \
+    uint8_t halfHV[64];                                                       \
+                                                                              \
+    copy_block9(full, src, 16, stride, 9);                                    \
+    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
+    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);                  \
+    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
+    OPNAME ## pixels8_l4_8(dst, full + 16, halfH + 8, halfV, halfHV,          \
+                           stride, 16, 8, 8, 8, 8);                           \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel8_mc13_c(uint8_t *dst, uint8_t *src,                \
+                                   ptrdiff_t stride)                          \
+{                                                                             \
+    uint8_t full[16 * 9];                                                     \
+    uint8_t halfH[72];                                                        \
+    uint8_t halfHV[64];                                                       \
+                                                                              \
+    copy_block9(full, src, 16, stride, 9);                                    \
+    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
+    put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9);              \
+    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
+    OPNAME ## pixels8_l2_8(dst, halfH + 8, halfHV, stride, 8, 8, 8);          \
+}                                                                             \
+                                                                              \
+void ff_ ## OPNAME ## qpel8_mc33_old_c(uint8_t *dst, uint8_t *src,            \
+                                       ptrdiff_t stride)                      \
+{                                                                             \
+    uint8_t full[16 * 9];                                                     \
+    uint8_t halfH[72];                                                        \
+    uint8_t halfV[64];                                                        \
+    uint8_t halfHV[64];                                                       \
+                                                                              \
+    copy_block9(full, src, 16, stride, 9);                                    \
+    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
+    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full + 1, 8, 16);              \
+    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
+    OPNAME ## pixels8_l4_8(dst, full + 17, halfH + 8, halfV, halfHV,          \
+                           stride, 16, 8, 8, 8, 8);                           \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel8_mc33_c(uint8_t *dst, uint8_t *src,                \
+                                   ptrdiff_t stride)                          \
+{                                                                             \
+    uint8_t full[16 * 9];                                                     \
+    uint8_t halfH[72];                                                        \
+    uint8_t halfHV[64];                                                       \
+                                                                              \
+    copy_block9(full, src, 16, stride, 9);                                    \
+    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
+    put ## RND ## pixels8_l2_8(halfH, halfH, full + 1, 8, 8, 16, 9);          \
+    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
+    OPNAME ## pixels8_l2_8(dst, halfH + 8, halfHV, stride, 8, 8, 8);          \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel8_mc21_c(uint8_t *dst, uint8_t *src,                \
+                                   ptrdiff_t stride)                          \
+{                                                                             \
+    uint8_t halfH[72];                                                        \
+    uint8_t halfHV[64];                                                       \
+                                                                              \
+    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);            \
+    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
+    OPNAME ## pixels8_l2_8(dst, halfH, halfHV, stride, 8, 8, 8);              \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel8_mc23_c(uint8_t *dst, uint8_t *src,                \
+                                   ptrdiff_t stride)                          \
+{                                                                             \
+    uint8_t halfH[72];                                                        \
+    uint8_t halfHV[64];                                                       \
+                                                                              \
+    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);            \
+    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
+    OPNAME ## pixels8_l2_8(dst, halfH + 8, halfHV, stride, 8, 8, 8);          \
+}                                                                             \
+                                                                              \
+void ff_ ## OPNAME ## qpel8_mc12_old_c(uint8_t *dst, uint8_t *src,            \
+                                       ptrdiff_t stride)                      \
+{                                                                             \
+    uint8_t full[16 * 9];                                                     \
+    uint8_t halfH[72];                                                        \
+    uint8_t halfV[64];                                                        \
+    uint8_t halfHV[64];                                                       \
+                                                                              \
+    copy_block9(full, src, 16, stride, 9);                                    \
+    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
+    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full, 8, 16);                  \
+    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
+    OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);              \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel8_mc12_c(uint8_t *dst, uint8_t *src,                \
+                                   ptrdiff_t stride)                          \
+{                                                                             \
+    uint8_t full[16 * 9];                                                     \
+    uint8_t halfH[72];                                                        \
+                                                                              \
+    copy_block9(full, src, 16, stride, 9);                                    \
+    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
+    put ## RND ## pixels8_l2_8(halfH, halfH, full, 8, 8, 16, 9);              \
+    OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);                   \
+}                                                                             \
+                                                                              \
+void ff_ ## OPNAME ## qpel8_mc32_old_c(uint8_t *dst, uint8_t *src,            \
+                                       ptrdiff_t stride)                      \
+{                                                                             \
+    uint8_t full[16 * 9];                                                     \
+    uint8_t halfH[72];                                                        \
+    uint8_t halfV[64];                                                        \
+    uint8_t halfHV[64];                                                       \
+                                                                              \
+    copy_block9(full, src, 16, stride, 9);                                    \
+    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
+    put ## RND ## mpeg4_qpel8_v_lowpass(halfV, full + 1, 8, 16);              \
+    put ## RND ## mpeg4_qpel8_v_lowpass(halfHV, halfH, 8, 8);                 \
+    OPNAME ## pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);              \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel8_mc32_c(uint8_t *dst, uint8_t *src,                \
+                                   ptrdiff_t stride)                          \
+{                                                                             \
+    uint8_t full[16 * 9];                                                     \
+    uint8_t halfH[72];                                                        \
+                                                                              \
+    copy_block9(full, src, 16, stride, 9);                                    \
+    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, full, 8, 16, 9);               \
+    put ## RND ## pixels8_l2_8(halfH, halfH, full + 1, 8, 8, 16, 9);          \
+    OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);                   \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel8_mc22_c(uint8_t *dst, uint8_t *src,                \
+                                   ptrdiff_t stride)                          \
+{                                                                             \
+    uint8_t halfH[72];                                                        \
+                                                                              \
+    put ## RND ## mpeg4_qpel8_h_lowpass(halfH, src, 8, stride, 9);            \
+    OPNAME ## mpeg4_qpel8_v_lowpass(dst, halfH, stride, 8);                   \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel16_mc10_c(uint8_t *dst, uint8_t *src,               \
+                                    ptrdiff_t stride)                         \
+{                                                                             \
+    uint8_t half[256];                                                        \
+                                                                              \
+    put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);          \
+    OPNAME ## pixels16_l2_8(dst, src, half, stride, stride, 16, 16);          \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel16_mc20_c(uint8_t *dst, uint8_t *src,               \
+                                    ptrdiff_t stride)                         \
+{                                                                             \
+    OPNAME ## mpeg4_qpel16_h_lowpass(dst, src, stride, stride, 16);           \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel16_mc30_c(uint8_t *dst, uint8_t *src,               \
+                                    ptrdiff_t stride)                         \
+{                                                                             \
+    uint8_t half[256];                                                        \
+                                                                              \
+    put ## RND ## mpeg4_qpel16_h_lowpass(half, src, 16, stride, 16);          \
+    OPNAME ## pixels16_l2_8(dst, src + 1, half, stride, stride, 16, 16);      \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel16_mc01_c(uint8_t *dst, uint8_t *src,               \
+                                    ptrdiff_t stride)                         \
+{                                                                             \
+    uint8_t full[24 * 17];                                                    \
+    uint8_t half[256];                                                        \
+                                                                              \
+    copy_block17(full, src, 24, stride, 17);                                  \
+    put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);                 \
+    OPNAME ## pixels16_l2_8(dst, full, half, stride, 24, 16, 16);             \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel16_mc02_c(uint8_t *dst, uint8_t *src,               \
+                                    ptrdiff_t stride)                         \
+{                                                                             \
+    uint8_t full[24 * 17];                                                    \
+                                                                              \
+    copy_block17(full, src, 24, stride, 17);                                  \
+    OPNAME ## mpeg4_qpel16_v_lowpass(dst, full, stride, 24);                  \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel16_mc03_c(uint8_t *dst, uint8_t *src,               \
+                                    ptrdiff_t stride)                         \
+{                                                                             \
+    uint8_t full[24 * 17];                                                    \
+    uint8_t half[256];                                                        \
+                                                                              \
+    copy_block17(full, src, 24, stride, 17);                                  \
+    put ## RND ## mpeg4_qpel16_v_lowpass(half, full, 16, 24);                 \
+    OPNAME ## pixels16_l2_8(dst, full + 24, half, stride, 24, 16, 16);        \
+}                                                                             \
+                                                                              \
+void ff_ ## OPNAME ## qpel16_mc11_old_c(uint8_t *dst, uint8_t *src,           \
+                                        ptrdiff_t stride)                     \
+{                                                                             \
+    uint8_t full[24 * 17];                                                    \
+    uint8_t halfH[272];                                                       \
+    uint8_t halfV[256];                                                       \
+    uint8_t halfHV[256];                                                      \
+                                                                              \
+    copy_block17(full, src, 24, stride, 17);                                  \
+    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
+    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);                \
+    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
+    OPNAME ## pixels16_l4_8(dst, full, halfH, halfV, halfHV,                  \
+                            stride, 24, 16, 16, 16, 16);                      \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel16_mc11_c(uint8_t *dst, uint8_t *src,               \
+                                    ptrdiff_t stride)                         \
+{                                                                             \
+    uint8_t full[24 * 17];                                                    \
+    uint8_t halfH[272];                                                       \
+    uint8_t halfHV[256];                                                      \
+                                                                              \
+    copy_block17(full, src, 24, stride, 17);                                  \
+    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
+    put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17);          \
+    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
+    OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16);          \
+}                                                                             \
+                                                                              \
+void ff_ ## OPNAME ## qpel16_mc31_old_c(uint8_t *dst, uint8_t *src,           \
+                                        ptrdiff_t stride)                     \
+{                                                                             \
+    uint8_t full[24 * 17];                                                    \
+    uint8_t halfH[272];                                                       \
+    uint8_t halfV[256];                                                       \
+    uint8_t halfHV[256];                                                      \
+                                                                              \
+    copy_block17(full, src, 24, stride, 17);                                  \
+    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
+    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full + 1, 16, 24);            \
+    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
+    OPNAME ## pixels16_l4_8(dst, full + 1, halfH, halfV, halfHV,              \
+                            stride, 24, 16, 16, 16, 16);                      \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel16_mc31_c(uint8_t *dst, uint8_t *src,               \
+                                    ptrdiff_t stride)                         \
+{                                                                             \
+    uint8_t full[24 * 17];                                                    \
+    uint8_t halfH[272];                                                       \
+    uint8_t halfHV[256];                                                      \
+                                                                              \
+    copy_block17(full, src, 24, stride, 17);                                  \
+    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
+    put ## RND ## pixels16_l2_8(halfH, halfH, full + 1, 16, 16, 24, 17);      \
+    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
+    OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16);          \
+}                                                                             \
+                                                                              \
+void ff_ ## OPNAME ## qpel16_mc13_old_c(uint8_t *dst, uint8_t *src,           \
+                                        ptrdiff_t stride)                     \
+{                                                                             \
+    uint8_t full[24 * 17];                                                    \
+    uint8_t halfH[272];                                                       \
+    uint8_t halfV[256];                                                       \
+    uint8_t halfHV[256];                                                      \
+                                                                              \
+    copy_block17(full, src, 24, stride, 17);                                  \
+    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
+    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);                \
+    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
+    OPNAME ## pixels16_l4_8(dst, full + 24, halfH + 16, halfV, halfHV,        \
+                            stride, 24, 16, 16, 16, 16);                      \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel16_mc13_c(uint8_t *dst, uint8_t *src,               \
+                                    ptrdiff_t stride)                         \
+{                                                                             \
+    uint8_t full[24 * 17];                                                    \
+    uint8_t halfH[272];                                                       \
+    uint8_t halfHV[256];                                                      \
+                                                                              \
+    copy_block17(full, src, 24, stride, 17);                                  \
+    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
+    put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17);          \
+    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
+    OPNAME ## pixels16_l2_8(dst, halfH + 16, halfHV, stride, 16, 16, 16);     \
+}                                                                             \
+                                                                              \
+void ff_ ## OPNAME ## qpel16_mc33_old_c(uint8_t *dst, uint8_t *src,           \
+                                        ptrdiff_t stride)                     \
+{                                                                             \
+    uint8_t full[24 * 17];                                                    \
+    uint8_t halfH[272];                                                       \
+    uint8_t halfV[256];                                                       \
+    uint8_t halfHV[256];                                                      \
+                                                                              \
+    copy_block17(full, src, 24, stride, 17);                                  \
+    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
+    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full + 1, 16, 24);            \
+    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
+    OPNAME ## pixels16_l4_8(dst, full + 25, halfH + 16, halfV, halfHV,        \
+                            stride, 24, 16, 16, 16, 16);                      \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel16_mc33_c(uint8_t *dst, uint8_t *src,               \
+                                    ptrdiff_t stride)                         \
+{                                                                             \
+    uint8_t full[24 * 17];                                                    \
+    uint8_t halfH[272];                                                       \
+    uint8_t halfHV[256];                                                      \
+                                                                              \
+    copy_block17(full, src, 24, stride, 17);                                  \
+    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
+    put ## RND ## pixels16_l2_8(halfH, halfH, full + 1, 16, 16, 24, 17);      \
+    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
+    OPNAME ## pixels16_l2_8(dst, halfH + 16, halfHV, stride, 16, 16, 16);     \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel16_mc21_c(uint8_t *dst, uint8_t *src,               \
+                                    ptrdiff_t stride)                         \
+{                                                                             \
+    uint8_t halfH[272];                                                       \
+    uint8_t halfHV[256];                                                      \
+                                                                              \
+    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);         \
+    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
+    OPNAME ## pixels16_l2_8(dst, halfH, halfHV, stride, 16, 16, 16);          \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel16_mc23_c(uint8_t *dst, uint8_t *src,               \
+                                    ptrdiff_t stride)                         \
+{                                                                             \
+    uint8_t halfH[272];                                                       \
+    uint8_t halfHV[256];                                                      \
+                                                                              \
+    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);         \
+    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
+    OPNAME ## pixels16_l2_8(dst, halfH + 16, halfHV, stride, 16, 16, 16);     \
+}                                                                             \
+                                                                              \
+void ff_ ## OPNAME ## qpel16_mc12_old_c(uint8_t *dst, uint8_t *src,           \
+                                        ptrdiff_t stride)                     \
+{                                                                             \
+    uint8_t full[24 * 17];                                                    \
+    uint8_t halfH[272];                                                       \
+    uint8_t halfV[256];                                                       \
+    uint8_t halfHV[256];                                                      \
+                                                                              \
+    copy_block17(full, src, 24, stride, 17);                                  \
+    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
+    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full, 16, 24);                \
+    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
+    OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16);          \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel16_mc12_c(uint8_t *dst, uint8_t *src,               \
+                                    ptrdiff_t stride)                         \
+{                                                                             \
+    uint8_t full[24 * 17];                                                    \
+    uint8_t halfH[272];                                                       \
+                                                                              \
+    copy_block17(full, src, 24, stride, 17);                                  \
+    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
+    put ## RND ## pixels16_l2_8(halfH, halfH, full, 16, 16, 24, 17);          \
+    OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);                 \
+}                                                                             \
+                                                                              \
+void ff_ ## OPNAME ## qpel16_mc32_old_c(uint8_t *dst, uint8_t *src,           \
+                                        ptrdiff_t stride)                     \
+{                                                                             \
+    uint8_t full[24 * 17];                                                    \
+    uint8_t halfH[272];                                                       \
+    uint8_t halfV[256];                                                       \
+    uint8_t halfHV[256];                                                      \
+                                                                              \
+    copy_block17(full, src, 24, stride, 17);                                  \
+    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
+    put ## RND ## mpeg4_qpel16_v_lowpass(halfV, full + 1, 16, 24);            \
+    put ## RND ## mpeg4_qpel16_v_lowpass(halfHV, halfH, 16, 16);              \
+    OPNAME ## pixels16_l2_8(dst, halfV, halfHV, stride, 16, 16, 16);          \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel16_mc32_c(uint8_t *dst, uint8_t *src,               \
+                                    ptrdiff_t stride)                         \
+{                                                                             \
+    uint8_t full[24 * 17];                                                    \
+    uint8_t halfH[272];                                                       \
+                                                                              \
+    copy_block17(full, src, 24, stride, 17);                                  \
+    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, full, 16, 24, 17);            \
+    put ## RND ## pixels16_l2_8(halfH, halfH, full + 1, 16, 16, 24, 17);      \
+    OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);                 \
+}                                                                             \
+                                                                              \
+static void OPNAME ## qpel16_mc22_c(uint8_t *dst, uint8_t *src,               \
+                                    ptrdiff_t stride)                         \
+{                                                                             \
+    uint8_t halfH[272];                                                       \
+                                                                              \
+    put ## RND ## mpeg4_qpel16_h_lowpass(halfH, src, 16, stride, 17);         \
+    OPNAME ## mpeg4_qpel16_v_lowpass(dst, halfH, stride, 16);                 \
+}
+
+#define op_avg(a, b)        a = (((a) + cm[((b) + 16) >> 5] + 1) >> 1)
+#define op_avg_no_rnd(a, b) a = (((a) + cm[((b) + 15) >> 5])     >> 1)
+#define op_put(a, b)        a = cm[((b) + 16) >> 5]
+#define op_put_no_rnd(a, b) a = cm[((b) + 15) >> 5]
+
+QPEL_MC(0, put_, _, op_put)
 QPEL_MC(1, put_no_rnd_, _no_rnd_, op_put_no_rnd)
-QPEL_MC(0, avg_       , _       , op_avg)
-//QPEL_MC(1, avg_no_rnd , _       , op_avg)
+QPEL_MC(0, avg_, _, op_avg)
+
 #undef op_avg
-#undef op_avg_no_rnd
 #undef op_put
 #undef op_put_no_rnd
 
@@ -1269,41 +1479,46 @@ void ff_put_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
 {
     put_pixels8_8_c(dst, src, stride, 8);
 }
+
 void ff_avg_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
 {
     avg_pixels8_8_c(dst, src, stride, 8);
 }
+
 void ff_put_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
 {
     put_pixels16_8_c(dst, src, stride, 16);
 }
+
 void ff_avg_pixels16x16_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
 {
     avg_pixels16_8_c(dst, src, stride, 16);
 }
 
-#define put_qpel8_mc00_c  ff_put_pixels8x8_c
-#define avg_qpel8_mc00_c  ff_avg_pixels8x8_c
-#define put_qpel16_mc00_c ff_put_pixels16x16_c
-#define avg_qpel16_mc00_c ff_avg_pixels16x16_c
+#define put_qpel8_mc00_c         ff_put_pixels8x8_c
+#define avg_qpel8_mc00_c         ff_avg_pixels8x8_c
+#define put_qpel16_mc00_c        ff_put_pixels16x16_c
+#define avg_qpel16_mc00_c        ff_avg_pixels16x16_c
 #define put_no_rnd_qpel8_mc00_c  ff_put_pixels8x8_c
 #define put_no_rnd_qpel16_mc00_c ff_put_pixels16x16_c
 
-static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int h){
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+static void wmv2_mspel8_h_lowpass(uint8_t *dst, uint8_t *src,
+                                  int dstStride, int srcStride, int h)
+{
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
     int i;
 
-    for(i=0; i<h; i++){
-        dst[0]= cm[(9*(src[0] + src[1]) - (src[-1] + src[2]) + 8)>>4];
-        dst[1]= cm[(9*(src[1] + src[2]) - (src[ 0] + src[3]) + 8)>>4];
-        dst[2]= cm[(9*(src[2] + src[3]) - (src[ 1] + src[4]) + 8)>>4];
-        dst[3]= cm[(9*(src[3] + src[4]) - (src[ 2] + src[5]) + 8)>>4];
-        dst[4]= cm[(9*(src[4] + src[5]) - (src[ 3] + src[6]) + 8)>>4];
-        dst[5]= cm[(9*(src[5] + src[6]) - (src[ 4] + src[7]) + 8)>>4];
-        dst[6]= cm[(9*(src[6] + src[7]) - (src[ 5] + src[8]) + 8)>>4];
-        dst[7]= cm[(9*(src[7] + src[8]) - (src[ 6] + src[9]) + 8)>>4];
-        dst+=dstStride;
-        src+=srcStride;
+    for (i = 0; i < h; i++) {
+        dst[0] = cm[(9 * (src[0] + src[1]) - (src[-1] + src[2]) + 8) >> 4];
+        dst[1] = cm[(9 * (src[1] + src[2]) - (src[0]  + src[3]) + 8) >> 4];
+        dst[2] = cm[(9 * (src[2] + src[3]) - (src[1]  + src[4]) + 8) >> 4];
+        dst[3] = cm[(9 * (src[3] + src[4]) - (src[2]  + src[5]) + 8) >> 4];
+        dst[4] = cm[(9 * (src[4] + src[5]) - (src[3]  + src[6]) + 8) >> 4];
+        dst[5] = cm[(9 * (src[5] + src[6]) - (src[4]  + src[7]) + 8) >> 4];
+        dst[6] = cm[(9 * (src[6] + src[7]) - (src[5]  + src[8]) + 8) >> 4];
+        dst[7] = cm[(9 * (src[7] + src[8]) - (src[6]  + src[9]) + 8) >> 4];
+        dst   += dstStride;
+        src   += srcStride;
     }
 }
 
@@ -1312,44 +1527,49 @@ void ff_put_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
 {
     put_pixels16_xy2_8_c(dst, src, stride, 16);
 }
+
 void ff_avg_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
 {
     avg_pixels16_xy2_8_c(dst, src, stride, 16);
 }
+
 void ff_put_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
 {
     put_pixels8_xy2_8_c(dst, src, stride, 8);
 }
+
 void ff_avg_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
 {
     avg_pixels8_xy2_8_c(dst, src, stride, 8);
 }
 #endif /* CONFIG_RV40_DECODER */
 
-static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int w){
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src,
+                                  int dstStride, int srcStride, int w)
+{
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
     int i;
 
-    for(i=0; i<w; i++){
-        const int src_1= src[ -srcStride];
-        const int src0 = src[0          ];
-        const int src1 = src[  srcStride];
-        const int src2 = src[2*srcStride];
-        const int src3 = src[3*srcStride];
-        const int src4 = src[4*srcStride];
-        const int src5 = src[5*srcStride];
-        const int src6 = src[6*srcStride];
-        const int src7 = src[7*srcStride];
-        const int src8 = src[8*srcStride];
-        const int src9 = src[9*srcStride];
-        dst[0*dstStride]= cm[(9*(src0 + src1) - (src_1 + src2) + 8)>>4];
-        dst[1*dstStride]= cm[(9*(src1 + src2) - (src0  + src3) + 8)>>4];
-        dst[2*dstStride]= cm[(9*(src2 + src3) - (src1  + src4) + 8)>>4];
-        dst[3*dstStride]= cm[(9*(src3 + src4) - (src2  + src5) + 8)>>4];
-        dst[4*dstStride]= cm[(9*(src4 + src5) - (src3  + src6) + 8)>>4];
-        dst[5*dstStride]= cm[(9*(src5 + src6) - (src4  + src7) + 8)>>4];
-        dst[6*dstStride]= cm[(9*(src6 + src7) - (src5  + src8) + 8)>>4];
-        dst[7*dstStride]= cm[(9*(src7 + src8) - (src6  + src9) + 8)>>4];
+    for (i = 0; i < w; i++) {
+        const int src_1 = src[-srcStride];
+        const int src0  = src[0];
+        const int src1  = src[srcStride];
+        const int src2  = src[2 * srcStride];
+        const int src3  = src[3 * srcStride];
+        const int src4  = src[4 * srcStride];
+        const int src5  = src[5 * srcStride];
+        const int src6  = src[6 * srcStride];
+        const int src7  = src[7 * srcStride];
+        const int src8  = src[8 * srcStride];
+        const int src9  = src[9 * srcStride];
+        dst[0 * dstStride] = cm[(9 * (src0 + src1) - (src_1 + src2) + 8) >> 4];
+        dst[1 * dstStride] = cm[(9 * (src1 + src2) - (src0  + src3) + 8) >> 4];
+        dst[2 * dstStride] = cm[(9 * (src2 + src3) - (src1  + src4) + 8) >> 4];
+        dst[3 * dstStride] = cm[(9 * (src3 + src4) - (src2  + src5) + 8) >> 4];
+        dst[4 * dstStride] = cm[(9 * (src4 + src5) - (src3  + src6) + 8) >> 4];
+        dst[5 * dstStride] = cm[(9 * (src5 + src6) - (src4  + src7) + 8) >> 4];
+        dst[6 * dstStride] = cm[(9 * (src6 + src7) - (src5  + src8) + 8) >> 4];
+        dst[7 * dstStride] = cm[(9 * (src7 + src8) - (src6  + src9) + 8) >> 4];
         src++;
         dst++;
     }
@@ -1358,6 +1578,7 @@ static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int
 static void put_mspel8_mc10_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
 {
     uint8_t half[64];
+
     wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
     put_pixels8_l2_8(dst, src, half, stride, stride, 8, 8);
 }
@@ -1370,8 +1591,9 @@ static void put_mspel8_mc20_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
 static void put_mspel8_mc30_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
 {
     uint8_t half[64];
+
     wmv2_mspel8_h_lowpass(half, src, 8, stride, 8);
-    put_pixels8_l2_8(dst, src+1, half, stride, stride, 8, 8);
+    put_pixels8_l2_8(dst, src + 1, half, stride, stride, 8, 8);
 }
 
 static void put_mspel8_mc02_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
@@ -1384,107 +1606,112 @@ static void put_mspel8_mc12_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
     uint8_t halfH[88];
     uint8_t halfV[64];
     uint8_t halfHV[64];
-    wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
+
+    wmv2_mspel8_h_lowpass(halfH, src - stride, 8, stride, 11);
     wmv2_mspel8_v_lowpass(halfV, src, 8, stride, 8);
-    wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8);
+    wmv2_mspel8_v_lowpass(halfHV, halfH + 8, 8, 8, 8);
     put_pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);
 }
+
 static void put_mspel8_mc32_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
 {
     uint8_t halfH[88];
     uint8_t halfV[64];
     uint8_t halfHV[64];
-    wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
-    wmv2_mspel8_v_lowpass(halfV, src+1, 8, stride, 8);
-    wmv2_mspel8_v_lowpass(halfHV, halfH+8, 8, 8, 8);
+
+    wmv2_mspel8_h_lowpass(halfH, src - stride, 8, stride, 11);
+    wmv2_mspel8_v_lowpass(halfV, src + 1, 8, stride, 8);
+    wmv2_mspel8_v_lowpass(halfHV, halfH + 8, 8, 8, 8);
     put_pixels8_l2_8(dst, halfV, halfHV, stride, 8, 8, 8);
 }
+
 static void put_mspel8_mc22_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride)
 {
     uint8_t halfH[88];
-    wmv2_mspel8_h_lowpass(halfH, src-stride, 8, stride, 11);
-    wmv2_mspel8_v_lowpass(dst, halfH+8, stride, 8, 8);
-}
-
-static inline int pix_abs16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int s, i;
-
-    s = 0;
-    for(i=0;i<h;i++) {
-        s += abs(pix1[0] - pix2[0]);
-        s += abs(pix1[1] - pix2[1]);
-        s += abs(pix1[2] - pix2[2]);
-        s += abs(pix1[3] - pix2[3]);
-        s += abs(pix1[4] - pix2[4]);
-        s += abs(pix1[5] - pix2[5]);
-        s += abs(pix1[6] - pix2[6]);
-        s += abs(pix1[7] - pix2[7]);
-        s += abs(pix1[8] - pix2[8]);
-        s += abs(pix1[9] - pix2[9]);
-        s += abs(pix1[10] - pix2[10]);
-        s += abs(pix1[11] - pix2[11]);
-        s += abs(pix1[12] - pix2[12]);
-        s += abs(pix1[13] - pix2[13]);
-        s += abs(pix1[14] - pix2[14]);
-        s += abs(pix1[15] - pix2[15]);
+
+    wmv2_mspel8_h_lowpass(halfH, src - stride, 8, stride, 11);
+    wmv2_mspel8_v_lowpass(dst, halfH + 8, stride, 8, 8);
+}
+
+static inline int pix_abs16_c(void *v, uint8_t *pix1, uint8_t *pix2,
+                              int line_size, int h)
+{
+    int s = 0, i;
+
+    for (i = 0; i < h; i++) {
+        s    += abs(pix1[0]  - pix2[0]);
+        s    += abs(pix1[1]  - pix2[1]);
+        s    += abs(pix1[2]  - pix2[2]);
+        s    += abs(pix1[3]  - pix2[3]);
+        s    += abs(pix1[4]  - pix2[4]);
+        s    += abs(pix1[5]  - pix2[5]);
+        s    += abs(pix1[6]  - pix2[6]);
+        s    += abs(pix1[7]  - pix2[7]);
+        s    += abs(pix1[8]  - pix2[8]);
+        s    += abs(pix1[9]  - pix2[9]);
+        s    += abs(pix1[10] - pix2[10]);
+        s    += abs(pix1[11] - pix2[11]);
+        s    += abs(pix1[12] - pix2[12]);
+        s    += abs(pix1[13] - pix2[13]);
+        s    += abs(pix1[14] - pix2[14]);
+        s    += abs(pix1[15] - pix2[15]);
         pix1 += line_size;
         pix2 += line_size;
     }
     return s;
 }
 
-static int pix_abs16_x2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
-{
-    int s, i;
-
-    s = 0;
-    for(i=0;i<h;i++) {
-        s += abs(pix1[0] - avg2(pix2[0], pix2[1]));
-        s += abs(pix1[1] - avg2(pix2[1], pix2[2]));
-        s += abs(pix1[2] - avg2(pix2[2], pix2[3]));
-        s += abs(pix1[3] - avg2(pix2[3], pix2[4]));
-        s += abs(pix1[4] - avg2(pix2[4], pix2[5]));
-        s += abs(pix1[5] - avg2(pix2[5], pix2[6]));
-        s += abs(pix1[6] - avg2(pix2[6], pix2[7]));
-        s += abs(pix1[7] - avg2(pix2[7], pix2[8]));
-        s += abs(pix1[8] - avg2(pix2[8], pix2[9]));
-        s += abs(pix1[9] - avg2(pix2[9], pix2[10]));
-        s += abs(pix1[10] - avg2(pix2[10], pix2[11]));
-        s += abs(pix1[11] - avg2(pix2[11], pix2[12]));
-        s += abs(pix1[12] - avg2(pix2[12], pix2[13]));
-        s += abs(pix1[13] - avg2(pix2[13], pix2[14]));
-        s += abs(pix1[14] - avg2(pix2[14], pix2[15]));
-        s += abs(pix1[15] - avg2(pix2[15], pix2[16]));
+static int pix_abs16_x2_c(void *v, uint8_t *pix1, uint8_t *pix2,
+                          int line_size, int h)
+{
+    int s = 0, i;
+
+    for (i = 0; i < h; i++) {
+        s    += abs(pix1[0]  - avg2(pix2[0],  pix2[1]));
+        s    += abs(pix1[1]  - avg2(pix2[1],  pix2[2]));
+        s    += abs(pix1[2]  - avg2(pix2[2],  pix2[3]));
+        s    += abs(pix1[3]  - avg2(pix2[3],  pix2[4]));
+        s    += abs(pix1[4]  - avg2(pix2[4],  pix2[5]));
+        s    += abs(pix1[5]  - avg2(pix2[5],  pix2[6]));
+        s    += abs(pix1[6]  - avg2(pix2[6],  pix2[7]));
+        s    += abs(pix1[7]  - avg2(pix2[7],  pix2[8]));
+        s    += abs(pix1[8]  - avg2(pix2[8],  pix2[9]));
+        s    += abs(pix1[9]  - avg2(pix2[9],  pix2[10]));
+        s    += abs(pix1[10] - avg2(pix2[10], pix2[11]));
+        s    += abs(pix1[11] - avg2(pix2[11], pix2[12]));
+        s    += abs(pix1[12] - avg2(pix2[12], pix2[13]));
+        s    += abs(pix1[13] - avg2(pix2[13], pix2[14]));
+        s    += abs(pix1[14] - avg2(pix2[14], pix2[15]));
+        s    += abs(pix1[15] - avg2(pix2[15], pix2[16]));
         pix1 += line_size;
         pix2 += line_size;
     }
     return s;
 }
 
-static int pix_abs16_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int pix_abs16_y2_c(void *v, uint8_t *pix1, uint8_t *pix2,
+                          int line_size, int h)
 {
-    int s, i;
+    int s = 0, i;
     uint8_t *pix3 = pix2 + line_size;
 
-    s = 0;
-    for(i=0;i<h;i++) {
-        s += abs(pix1[0] - avg2(pix2[0], pix3[0]));
-        s += abs(pix1[1] - avg2(pix2[1], pix3[1]));
-        s += abs(pix1[2] - avg2(pix2[2], pix3[2]));
-        s += abs(pix1[3] - avg2(pix2[3], pix3[3]));
-        s += abs(pix1[4] - avg2(pix2[4], pix3[4]));
-        s += abs(pix1[5] - avg2(pix2[5], pix3[5]));
-        s += abs(pix1[6] - avg2(pix2[6], pix3[6]));
-        s += abs(pix1[7] - avg2(pix2[7], pix3[7]));
-        s += abs(pix1[8] - avg2(pix2[8], pix3[8]));
-        s += abs(pix1[9] - avg2(pix2[9], pix3[9]));
-        s += abs(pix1[10] - avg2(pix2[10], pix3[10]));
-        s += abs(pix1[11] - avg2(pix2[11], pix3[11]));
-        s += abs(pix1[12] - avg2(pix2[12], pix3[12]));
-        s += abs(pix1[13] - avg2(pix2[13], pix3[13]));
-        s += abs(pix1[14] - avg2(pix2[14], pix3[14]));
-        s += abs(pix1[15] - avg2(pix2[15], pix3[15]));
+    for (i = 0; i < h; i++) {
+        s    += abs(pix1[0]  - avg2(pix2[0],  pix3[0]));
+        s    += abs(pix1[1]  - avg2(pix2[1],  pix3[1]));
+        s    += abs(pix1[2]  - avg2(pix2[2],  pix3[2]));
+        s    += abs(pix1[3]  - avg2(pix2[3],  pix3[3]));
+        s    += abs(pix1[4]  - avg2(pix2[4],  pix3[4]));
+        s    += abs(pix1[5]  - avg2(pix2[5],  pix3[5]));
+        s    += abs(pix1[6]  - avg2(pix2[6],  pix3[6]));
+        s    += abs(pix1[7]  - avg2(pix2[7],  pix3[7]));
+        s    += abs(pix1[8]  - avg2(pix2[8],  pix3[8]));
+        s    += abs(pix1[9]  - avg2(pix2[9],  pix3[9]));
+        s    += abs(pix1[10] - avg2(pix2[10], pix3[10]));
+        s    += abs(pix1[11] - avg2(pix2[11], pix3[11]));
+        s    += abs(pix1[12] - avg2(pix2[12], pix3[12]));
+        s    += abs(pix1[13] - avg2(pix2[13], pix3[13]));
+        s    += abs(pix1[14] - avg2(pix2[14], pix3[14]));
+        s    += abs(pix1[15] - avg2(pix2[15], pix3[15]));
         pix1 += line_size;
         pix2 += line_size;
         pix3 += line_size;
@@ -1492,29 +1719,29 @@ static int pix_abs16_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size,
     return s;
 }
 
-static int pix_abs16_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int pix_abs16_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2,
+                           int line_size, int h)
 {
-    int s, i;
+    int s = 0, i;
     uint8_t *pix3 = pix2 + line_size;
 
-    s = 0;
-    for(i=0;i<h;i++) {
-        s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
-        s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
-        s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
-        s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
-        s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
-        s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
-        s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
-        s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
-        s += abs(pix1[8] - avg4(pix2[8], pix2[9], pix3[8], pix3[9]));
-        s += abs(pix1[9] - avg4(pix2[9], pix2[10], pix3[9], pix3[10]));
-        s += abs(pix1[10] - avg4(pix2[10], pix2[11], pix3[10], pix3[11]));
-        s += abs(pix1[11] - avg4(pix2[11], pix2[12], pix3[11], pix3[12]));
-        s += abs(pix1[12] - avg4(pix2[12], pix2[13], pix3[12], pix3[13]));
-        s += abs(pix1[13] - avg4(pix2[13], pix2[14], pix3[13], pix3[14]));
-        s += abs(pix1[14] - avg4(pix2[14], pix2[15], pix3[14], pix3[15]));
-        s += abs(pix1[15] - avg4(pix2[15], pix2[16], pix3[15], pix3[16]));
+    for (i = 0; i < h; i++) {
+        s    += abs(pix1[0]  - avg4(pix2[0],  pix2[1],  pix3[0],  pix3[1]));
+        s    += abs(pix1[1]  - avg4(pix2[1],  pix2[2],  pix3[1],  pix3[2]));
+        s    += abs(pix1[2]  - avg4(pix2[2],  pix2[3],  pix3[2],  pix3[3]));
+        s    += abs(pix1[3]  - avg4(pix2[3],  pix2[4],  pix3[3],  pix3[4]));
+        s    += abs(pix1[4]  - avg4(pix2[4],  pix2[5],  pix3[4],  pix3[5]));
+        s    += abs(pix1[5]  - avg4(pix2[5],  pix2[6],  pix3[5],  pix3[6]));
+        s    += abs(pix1[6]  - avg4(pix2[6],  pix2[7],  pix3[6],  pix3[7]));
+        s    += abs(pix1[7]  - avg4(pix2[7],  pix2[8],  pix3[7],  pix3[8]));
+        s    += abs(pix1[8]  - avg4(pix2[8],  pix2[9],  pix3[8],  pix3[9]));
+        s    += abs(pix1[9]  - avg4(pix2[9],  pix2[10], pix3[9],  pix3[10]));
+        s    += abs(pix1[10] - avg4(pix2[10], pix2[11], pix3[10], pix3[11]));
+        s    += abs(pix1[11] - avg4(pix2[11], pix2[12], pix3[11], pix3[12]));
+        s    += abs(pix1[12] - avg4(pix2[12], pix2[13], pix3[12], pix3[13]));
+        s    += abs(pix1[13] - avg4(pix2[13], pix2[14], pix3[13], pix3[14]));
+        s    += abs(pix1[14] - avg4(pix2[14], pix2[15], pix3[14], pix3[15]));
+        s    += abs(pix1[15] - avg4(pix2[15], pix2[16], pix3[15], pix3[16]));
         pix1 += line_size;
         pix2 += line_size;
         pix3 += line_size;
@@ -1522,61 +1749,61 @@ static int pix_abs16_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size,
     return s;
 }
 
-static inline int pix_abs8_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static inline int pix_abs8_c(void *v, uint8_t *pix1, uint8_t *pix2,
+                             int line_size, int h)
 {
-    int s, i;
+    int s = 0, i;
 
-    s = 0;
-    for(i=0;i<h;i++) {
-        s += abs(pix1[0] - pix2[0]);
-        s += abs(pix1[1] - pix2[1]);
-        s += abs(pix1[2] - pix2[2]);
-        s += abs(pix1[3] - pix2[3]);
-        s += abs(pix1[4] - pix2[4]);
-        s += abs(pix1[5] - pix2[5]);
-        s += abs(pix1[6] - pix2[6]);
-        s += abs(pix1[7] - pix2[7]);
+    for (i = 0; i < h; i++) {
+        s    += abs(pix1[0] - pix2[0]);
+        s    += abs(pix1[1] - pix2[1]);
+        s    += abs(pix1[2] - pix2[2]);
+        s    += abs(pix1[3] - pix2[3]);
+        s    += abs(pix1[4] - pix2[4]);
+        s    += abs(pix1[5] - pix2[5]);
+        s    += abs(pix1[6] - pix2[6]);
+        s    += abs(pix1[7] - pix2[7]);
         pix1 += line_size;
         pix2 += line_size;
     }
     return s;
 }
 
-static int pix_abs8_x2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int pix_abs8_x2_c(void *v, uint8_t *pix1, uint8_t *pix2,
+                         int line_size, int h)
 {
-    int s, i;
+    int s = 0, i;
 
-    s = 0;
-    for(i=0;i<h;i++) {
-        s += abs(pix1[0] - avg2(pix2[0], pix2[1]));
-        s += abs(pix1[1] - avg2(pix2[1], pix2[2]));
-        s += abs(pix1[2] - avg2(pix2[2], pix2[3]));
-        s += abs(pix1[3] - avg2(pix2[3], pix2[4]));
-        s += abs(pix1[4] - avg2(pix2[4], pix2[5]));
-        s += abs(pix1[5] - avg2(pix2[5], pix2[6]));
-        s += abs(pix1[6] - avg2(pix2[6], pix2[7]));
-        s += abs(pix1[7] - avg2(pix2[7], pix2[8]));
+    for (i = 0; i < h; i++) {
+        s    += abs(pix1[0] - avg2(pix2[0], pix2[1]));
+        s    += abs(pix1[1] - avg2(pix2[1], pix2[2]));
+        s    += abs(pix1[2] - avg2(pix2[2], pix2[3]));
+        s    += abs(pix1[3] - avg2(pix2[3], pix2[4]));
+        s    += abs(pix1[4] - avg2(pix2[4], pix2[5]));
+        s    += abs(pix1[5] - avg2(pix2[5], pix2[6]));
+        s    += abs(pix1[6] - avg2(pix2[6], pix2[7]));
+        s    += abs(pix1[7] - avg2(pix2[7], pix2[8]));
         pix1 += line_size;
         pix2 += line_size;
     }
     return s;
 }
 
-static int pix_abs8_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int pix_abs8_y2_c(void *v, uint8_t *pix1, uint8_t *pix2,
+                         int line_size, int h)
 {
-    int s, i;
+    int s = 0, i;
     uint8_t *pix3 = pix2 + line_size;
 
-    s = 0;
-    for(i=0;i<h;i++) {
-        s += abs(pix1[0] - avg2(pix2[0], pix3[0]));
-        s += abs(pix1[1] - avg2(pix2[1], pix3[1]));
-        s += abs(pix1[2] - avg2(pix2[2], pix3[2]));
-        s += abs(pix1[3] - avg2(pix2[3], pix3[3]));
-        s += abs(pix1[4] - avg2(pix2[4], pix3[4]));
-        s += abs(pix1[5] - avg2(pix2[5], pix3[5]));
-        s += abs(pix1[6] - avg2(pix2[6], pix3[6]));
-        s += abs(pix1[7] - avg2(pix2[7], pix3[7]));
+    for (i = 0; i < h; i++) {
+        s    += abs(pix1[0] - avg2(pix2[0], pix3[0]));
+        s    += abs(pix1[1] - avg2(pix2[1], pix3[1]));
+        s    += abs(pix1[2] - avg2(pix2[2], pix3[2]));
+        s    += abs(pix1[3] - avg2(pix2[3], pix3[3]));
+        s    += abs(pix1[4] - avg2(pix2[4], pix3[4]));
+        s    += abs(pix1[5] - avg2(pix2[5], pix3[5]));
+        s    += abs(pix1[6] - avg2(pix2[6], pix3[6]));
+        s    += abs(pix1[7] - avg2(pix2[7], pix3[7]));
         pix1 += line_size;
         pix2 += line_size;
         pix3 += line_size;
@@ -1584,21 +1811,21 @@ static int pix_abs8_y2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, i
     return s;
 }
 
-static int pix_abs8_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+static int pix_abs8_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2,
+                          int line_size, int h)
 {
-    int s, i;
+    int s = 0, i;
     uint8_t *pix3 = pix2 + line_size;
 
-    s = 0;
-    for(i=0;i<h;i++) {
-        s += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
-        s += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
-        s += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
-        s += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
-        s += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
-        s += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
-        s += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
-        s += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
+    for (i = 0; i < h; i++) {
+        s    += abs(pix1[0] - avg4(pix2[0], pix2[1], pix3[0], pix3[1]));
+        s    += abs(pix1[1] - avg4(pix2[1], pix2[2], pix3[1], pix3[2]));
+        s    += abs(pix1[2] - avg4(pix2[2], pix2[3], pix3[2], pix3[3]));
+        s    += abs(pix1[3] - avg4(pix2[3], pix2[4], pix3[3], pix3[4]));
+        s    += abs(pix1[4] - avg4(pix2[4], pix2[5], pix3[4], pix3[5]));
+        s    += abs(pix1[5] - avg4(pix2[5], pix2[6], pix3[5], pix3[6]));
+        s    += abs(pix1[6] - avg4(pix2[6], pix2[7], pix3[6], pix3[7]));
+        s    += abs(pix1[7] - avg4(pix2[7], pix2[8], pix3[7], pix3[8]));
         pix1 += line_size;
         pix2 += line_size;
         pix3 += line_size;
@@ -1606,222 +1833,242 @@ static int pix_abs8_xy2_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size,
     return s;
 }
 
-static int nsse16_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h){
+static int nsse16_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h)
+{
     MpegEncContext *c = v;
-    int score1=0;
-    int score2=0;
-    int x,y;
-
-    for(y=0; y<h; y++){
-        for(x=0; x<16; x++){
-            score1+= (s1[x  ] - s2[x ])*(s1[x  ] - s2[x ]);
-        }
-        if(y+1<h){
-            for(x=0; x<15; x++){
-                score2+= FFABS(  s1[x  ] - s1[x  +stride]
-                             - s1[x+1] + s1[x+1+stride])
-                        -FFABS(  s2[x  ] - s2[x  +stride]
-                             - s2[x+1] + s2[x+1+stride]);
-            }
+    int score1 = 0, score2 = 0, x, y;
+
+    for (y = 0; y < h; y++) {
+        for (x = 0; x < 16; x++)
+            score1 += (s1[x] - s2[x]) * (s1[x] - s2[x]);
+        if (y + 1 < h) {
+            for (x = 0; x < 15; x++)
+                score2 += FFABS(s1[x]     - s1[x + stride] -
+                                s1[x + 1] + s1[x + stride + 1]) -
+                          FFABS(s2[x]     - s2[x + stride] -
+                                s2[x + 1] + s2[x + stride + 1]);
         }
-        s1+= stride;
-        s2+= stride;
+        s1 += stride;
+        s2 += stride;
     }
 
-    if(c) return score1 + FFABS(score2)*c->avctx->nsse_weight;
-    else  return score1 + FFABS(score2)*8;
+    if (c)
+        return score1 + FFABS(score2) * c->avctx->nsse_weight;
+    else
+        return score1 + FFABS(score2) * 8;
 }
 
-static int nsse8_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h){
+static int nsse8_c(void *v, uint8_t *s1, uint8_t *s2, int stride, int h)
+{
     MpegEncContext *c = v;
-    int score1=0;
-    int score2=0;
-    int x,y;
-
-    for(y=0; y<h; y++){
-        for(x=0; x<8; x++){
-            score1+= (s1[x  ] - s2[x ])*(s1[x  ] - s2[x ]);
+    int score1 = 0, score2 = 0, x, y;
+
+    for (y = 0; y < h; y++) {
+        for (x = 0; x < 8; x++)
+            score1 += (s1[x] - s2[x]) * (s1[x] - s2[x]);
+        if (y + 1 < h) {
+            for (x = 0; x < 7; x++)
+                score2 += FFABS(s1[x]     - s1[x + stride] -
+                                s1[x + 1] + s1[x + stride + 1]) -
+                          FFABS(s2[x]     - s2[x + stride] -
+                                s2[x + 1] + s2[x + stride + 1]);
         }
-        if(y+1<h){
-            for(x=0; x<7; x++){
-                score2+= FFABS(  s1[x  ] - s1[x  +stride]
-                             - s1[x+1] + s1[x+1+stride])
-                        -FFABS(  s2[x  ] - s2[x  +stride]
-                             - s2[x+1] + s2[x+1+stride]);
-            }
-        }
-        s1+= stride;
-        s2+= stride;
+        s1 += stride;
+        s2 += stride;
     }
 
-    if(c) return score1 + FFABS(score2)*c->avctx->nsse_weight;
-    else  return score1 + FFABS(score2)*8;
+    if (c)
+        return score1 + FFABS(score2) * c->avctx->nsse_weight;
+    else
+        return score1 + FFABS(score2) * 8;
 }
 
-static int try_8x8basis_c(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale){
+static int try_8x8basis_c(int16_t rem[64], int16_t weight[64],
+                          int16_t basis[64], int scale)
+{
     int i;
-    unsigned int sum=0;
+    unsigned int sum = 0;
 
-    for(i=0; i<8*8; i++){
-        int b= rem[i] + ((basis[i]*scale + (1<<(BASIS_SHIFT - RECON_SHIFT-1)))>>(BASIS_SHIFT - RECON_SHIFT));
-        int w= weight[i];
-        b>>= RECON_SHIFT;
-        assert(-512<b && b<512);
+    for (i = 0; i < 8 * 8; i++) {
+        int b = rem[i] + ((basis[i] * scale +
+                           (1 << (BASIS_SHIFT - RECON_SHIFT - 1))) >>
+                          (BASIS_SHIFT - RECON_SHIFT));
+        int w = weight[i];
+        b >>= RECON_SHIFT;
+        assert(-512 < b && b < 512);
 
-        sum += (w*b)*(w*b)>>4;
+        sum += (w * b) * (w * b) >> 4;
     }
-    return sum>>2;
+    return sum >> 2;
 }
 
-static void add_8x8basis_c(int16_t rem[64], int16_t basis[64], int scale){
+static void add_8x8basis_c(int16_t rem[64], int16_t basis[64], int scale)
+{
     int i;
 
-    for(i=0; i<8*8; i++){
-        rem[i] += (basis[i]*scale + (1<<(BASIS_SHIFT - RECON_SHIFT-1)))>>(BASIS_SHIFT - RECON_SHIFT);
-    }
+    for (i = 0; i < 8 * 8; i++)
+        rem[i] += (basis[i] * scale +
+                   (1 << (BASIS_SHIFT - RECON_SHIFT - 1))) >>
+                  (BASIS_SHIFT - RECON_SHIFT);
 }
 
-static int zero_cmp(void *s, uint8_t *a, uint8_t *b, int stride, int h){
+static int zero_cmp(void *s, uint8_t *a, uint8_t *b, int stride, int h)
+{
     return 0;
 }
 
-void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
+void ff_set_cmp(DSPContext *c, me_cmp_func *cmp, int type)
+{
     int i;
 
-    memset(cmp, 0, sizeof(void*)*6);
+    memset(cmp, 0, sizeof(void *) * 6);
 
-    for(i=0; i<6; i++){
-        switch(type&0xFF){
+    for (i = 0; i < 6; i++) {
+        switch (type & 0xFF) {
         case FF_CMP_SAD:
-            cmp[i]= c->sad[i];
+            cmp[i] = c->sad[i];
             break;
         case FF_CMP_SATD:
-            cmp[i]= c->hadamard8_diff[i];
+            cmp[i] = c->hadamard8_diff[i];
             break;
         case FF_CMP_SSE:
-            cmp[i]= c->sse[i];
+            cmp[i] = c->sse[i];
             break;
         case FF_CMP_DCT:
-            cmp[i]= c->dct_sad[i];
+            cmp[i] = c->dct_sad[i];
             break;
         case FF_CMP_DCT264:
-            cmp[i]= c->dct264_sad[i];
+            cmp[i] = c->dct264_sad[i];
             break;
         case FF_CMP_DCTMAX:
-            cmp[i]= c->dct_max[i];
+            cmp[i] = c->dct_max[i];
             break;
         case FF_CMP_PSNR:
-            cmp[i]= c->quant_psnr[i];
+            cmp[i] = c->quant_psnr[i];
             break;
         case FF_CMP_BIT:
-            cmp[i]= c->bit[i];
+            cmp[i] = c->bit[i];
             break;
         case FF_CMP_RD:
-            cmp[i]= c->rd[i];
+            cmp[i] = c->rd[i];
             break;
         case FF_CMP_VSAD:
-            cmp[i]= c->vsad[i];
+            cmp[i] = c->vsad[i];
             break;
         case FF_CMP_VSSE:
-            cmp[i]= c->vsse[i];
+            cmp[i] = c->vsse[i];
             break;
         case FF_CMP_ZERO:
-            cmp[i]= zero_cmp;
+            cmp[i] = zero_cmp;
             break;
         case FF_CMP_NSSE:
-            cmp[i]= c->nsse[i];
+            cmp[i] = c->nsse[i];
             break;
         default:
-            av_log(NULL, AV_LOG_ERROR,"internal error in cmp function selection\n");
+            av_log(NULL, AV_LOG_ERROR,
+                   "internal error in cmp function selection\n");
         }
     }
 }
 
-static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
+static void add_bytes_c(uint8_t *dst, uint8_t *src, int w)
+{
     long i;
+
     for (i = 0; i <= w - (int) sizeof(long); i += sizeof(long)) {
-        long a = *(long*)(src+i);
-        long b = *(long*)(dst+i);
-        *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
+        long a = *(long *) (src + i);
+        long b = *(long *) (dst + i);
+        *(long *) (dst + i) = ((a & pb_7f) + (b & pb_7f)) ^ ((a ^ b) & pb_80);
     }
-    for(; i<w; i++)
-        dst[i+0] += src[i+0];
+    for (; i < w; i++)
+        dst[i + 0] += src[i + 0];
 }
 
-static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
+static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w)
+{
     long i;
+
 #if !HAVE_FAST_UNALIGNED
-    if((long)src2 & (sizeof(long)-1)){
-        for(i=0; i+7<w; i+=8){
-            dst[i+0] = src1[i+0]-src2[i+0];
-            dst[i+1] = src1[i+1]-src2[i+1];
-            dst[i+2] = src1[i+2]-src2[i+2];
-            dst[i+3] = src1[i+3]-src2[i+3];
-            dst[i+4] = src1[i+4]-src2[i+4];
-            dst[i+5] = src1[i+5]-src2[i+5];
-            dst[i+6] = src1[i+6]-src2[i+6];
-            dst[i+7] = src1[i+7]-src2[i+7];
+    if ((long) src2 & (sizeof(long) - 1)) {
+        for (i = 0; i + 7 < w; i += 8) {
+            dst[i + 0] = src1[i + 0] - src2[i + 0];
+            dst[i + 1] = src1[i + 1] - src2[i + 1];
+            dst[i + 2] = src1[i + 2] - src2[i + 2];
+            dst[i + 3] = src1[i + 3] - src2[i + 3];
+            dst[i + 4] = src1[i + 4] - src2[i + 4];
+            dst[i + 5] = src1[i + 5] - src2[i + 5];
+            dst[i + 6] = src1[i + 6] - src2[i + 6];
+            dst[i + 7] = src1[i + 7] - src2[i + 7];
         }
-    }else
+    } else
 #endif
     for (i = 0; i <= w - (int) sizeof(long); i += sizeof(long)) {
-        long a = *(long*)(src1+i);
-        long b = *(long*)(src2+i);
-        *(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80);
+        long a = *(long *) (src1 + i);
+        long b = *(long *) (src2 + i);
+        *(long *) (dst + i) = ((a | pb_80) - (b & pb_7f)) ^
+                              ((a ^ b ^ pb_80) & pb_80);
     }
-    for(; i<w; i++)
-        dst[i+0] = src1[i+0]-src2[i+0];
+    for (; i < w; i++)
+        dst[i + 0] = src1[i + 0] - src2[i + 0];
 }
 
-static void add_hfyu_median_prediction_c(uint8_t *dst, const uint8_t *src1, const uint8_t *diff, int w, int *left, int *left_top){
+static void add_hfyu_median_prediction_c(uint8_t *dst, const uint8_t *src1,
+                                         const uint8_t *diff, int w,
+                                         int *left, int *left_top)
+{
     int i;
     uint8_t l, lt;
 
-    l= *left;
-    lt= *left_top;
+    l  = *left;
+    lt = *left_top;
 
-    for(i=0; i<w; i++){
-        l= mid_pred(l, src1[i], (l + src1[i] - lt)&0xFF) + diff[i];
-        lt= src1[i];
-        dst[i]= l;
+    for (i = 0; i < w; i++) {
+        l      = mid_pred(l, src1[i], (l + src1[i] - lt) & 0xFF) + diff[i];
+        lt     = src1[i];
+        dst[i] = l;
     }
 
-    *left= l;
-    *left_top= lt;
+    *left     = l;
+    *left_top = lt;
 }
 
-static void sub_hfyu_median_prediction_c(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w, int *left, int *left_top){
+static void sub_hfyu_median_prediction_c(uint8_t *dst, const uint8_t *src1,
+                                         const uint8_t *src2, int w,
+                                         int *left, int *left_top)
+{
     int i;
     uint8_t l, lt;
 
-    l= *left;
-    lt= *left_top;
+    l  = *left;
+    lt = *left_top;
 
-    for(i=0; i<w; i++){
-        const int pred= mid_pred(l, src1[i], (l + src1[i] - lt)&0xFF);
-        lt= src1[i];
-        l= src2[i];
-        dst[i]= l - pred;
+    for (i = 0; i < w; i++) {
+        const int pred = mid_pred(l, src1[i], (l + src1[i] - lt) & 0xFF);
+        lt     = src1[i];
+        l      = src2[i];
+        dst[i] = l - pred;
     }
 
-    *left= l;
-    *left_top= lt;
+    *left     = l;
+    *left_top = lt;
 }
 
-static int add_hfyu_left_prediction_c(uint8_t *dst, const uint8_t *src, int w, int acc){
+static int add_hfyu_left_prediction_c(uint8_t *dst, const uint8_t *src,
+                                      int w, int acc)
+{
     int i;
 
-    for(i=0; i<w-1; i++){
-        acc+= src[i];
-        dst[i]= acc;
+    for (i = 0; i < w - 1; i++) {
+        acc   += src[i];
+        dst[i] = acc;
         i++;
-        acc+= src[i];
-        dst[i]= acc;
+        acc   += src[i];
+        dst[i] = acc;
     }
 
-    for(; i<w; i++){
-        acc+= src[i];
-        dst[i]= acc;
+    for (; i < w; i++) {
+        acc   += src[i];
+        dst[i] = acc;
     }
 
     return acc;
@@ -1838,149 +2085,160 @@ static int add_hfyu_left_prediction_c(uint8_t *dst, const uint8_t *src, int w, i
 #define R 2
 #define A 3
 #endif
-static void add_hfyu_left_prediction_bgr32_c(uint8_t *dst, const uint8_t *src, int w, int *red, int *green, int *blue, int *alpha){
-    int i;
-    int r,g,b,a;
-    r= *red;
-    g= *green;
-    b= *blue;
-    a= *alpha;
+static void add_hfyu_left_prediction_bgr32_c(uint8_t *dst, const uint8_t *src,
+                                             int w, int *red, int *green,
+                                             int *blue, int *alpha)
+{
+    int i, r = *red, g = *green, b = *blue, a = *alpha;
 
-    for(i=0; i<w; i++){
-        b+= src[4*i+B];
-        g+= src[4*i+G];
-        r+= src[4*i+R];
-        a+= src[4*i+A];
+    for (i = 0; i < w; i++) {
+        b += src[4 * i + B];
+        g += src[4 * i + G];
+        r += src[4 * i + R];
+        a += src[4 * i + A];
 
-        dst[4*i+B]= b;
-        dst[4*i+G]= g;
-        dst[4*i+R]= r;
-        dst[4*i+A]= a;
+        dst[4 * i + B] = b;
+        dst[4 * i + G] = g;
+        dst[4 * i + R] = r;
+        dst[4 * i + A] = a;
     }
 
-    *red= r;
-    *green= g;
-    *blue= b;
-    *alpha= a;
+    *red   = r;
+    *green = g;
+    *blue  = b;
+    *alpha = a;
 }
 #undef B
 #undef G
 #undef R
 #undef A
 
-#define BUTTERFLY2(o1,o2,i1,i2) \
-o1= (i1)+(i2);\
-o2= (i1)-(i2);
-
-#define BUTTERFLY1(x,y) \
-{\
-    int a,b;\
-    a= x;\
-    b= y;\
-    x= a+b;\
-    y= a-b;\
-}
+#define BUTTERFLY2(o1, o2, i1, i2)              \
+    o1 = (i1) + (i2);                           \
+    o2 = (i1) - (i2);
 
-#define BUTTERFLYA(x,y) (FFABS((x)+(y)) + FFABS((x)-(y)))
-
-static int hadamard8_diff8x8_c(/*MpegEncContext*/ void *s, uint8_t *dst, uint8_t *src, int stride, int h){
-    int i;
-    int temp[64];
-    int sum=0;
+#define BUTTERFLY1(x, y)                        \
+    {                                           \
+        int a, b;                               \
+        a = x;                                  \
+        b = y;                                  \
+        x = a + b;                              \
+        y = a - b;                              \
+    }
 
-    assert(h==8);
+#define BUTTERFLYA(x, y) (FFABS((x) + (y)) + FFABS((x) - (y)))
 
-    for(i=0; i<8; i++){
-        //FIXME try pointer walks
-        BUTTERFLY2(temp[8*i+0], temp[8*i+1], src[stride*i+0]-dst[stride*i+0],src[stride*i+1]-dst[stride*i+1]);
-        BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2]-dst[stride*i+2],src[stride*i+3]-dst[stride*i+3]);
-        BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4]-dst[stride*i+4],src[stride*i+5]-dst[stride*i+5]);
-        BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6]-dst[stride*i+6],src[stride*i+7]-dst[stride*i+7]);
+static int hadamard8_diff8x8_c(/* MpegEncContext */ void *s, uint8_t *dst,
+                               uint8_t *src, int stride, int h)
+{
+    int i, temp[64], sum = 0;
 
-        BUTTERFLY1(temp[8*i+0], temp[8*i+2]);
-        BUTTERFLY1(temp[8*i+1], temp[8*i+3]);
-        BUTTERFLY1(temp[8*i+4], temp[8*i+6]);
-        BUTTERFLY1(temp[8*i+5], temp[8*i+7]);
+    assert(h == 8);
 
-        BUTTERFLY1(temp[8*i+0], temp[8*i+4]);
-        BUTTERFLY1(temp[8*i+1], temp[8*i+5]);
-        BUTTERFLY1(temp[8*i+2], temp[8*i+6]);
-        BUTTERFLY1(temp[8*i+3], temp[8*i+7]);
+    for (i = 0; i < 8; i++) {
+        // FIXME: try pointer walks
+        BUTTERFLY2(temp[8 * i + 0], temp[8 * i + 1],
+                   src[stride * i + 0] - dst[stride * i + 0],
+                   src[stride * i + 1] - dst[stride * i + 1]);
+        BUTTERFLY2(temp[8 * i + 2], temp[8 * i + 3],
+                   src[stride * i + 2] - dst[stride * i + 2],
+                   src[stride * i + 3] - dst[stride * i + 3]);
+        BUTTERFLY2(temp[8 * i + 4], temp[8 * i + 5],
+                   src[stride * i + 4] - dst[stride * i + 4],
+                   src[stride * i + 5] - dst[stride * i + 5]);
+        BUTTERFLY2(temp[8 * i + 6], temp[8 * i + 7],
+                   src[stride * i + 6] - dst[stride * i + 6],
+                   src[stride * i + 7] - dst[stride * i + 7]);
+
+        BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 2]);
+        BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 3]);
+        BUTTERFLY1(temp[8 * i + 4], temp[8 * i + 6]);
+        BUTTERFLY1(temp[8 * i + 5], temp[8 * i + 7]);
+
+        BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 4]);
+        BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 5]);
+        BUTTERFLY1(temp[8 * i + 2], temp[8 * i + 6]);
+        BUTTERFLY1(temp[8 * i + 3], temp[8 * i + 7]);
     }
 
-    for(i=0; i<8; i++){
-        BUTTERFLY1(temp[8*0+i], temp[8*1+i]);
-        BUTTERFLY1(temp[8*2+i], temp[8*3+i]);
-        BUTTERFLY1(temp[8*4+i], temp[8*5+i]);
-        BUTTERFLY1(temp[8*6+i], temp[8*7+i]);
+    for (i = 0; i < 8; i++) {
+        BUTTERFLY1(temp[8 * 0 + i], temp[8 * 1 + i]);
+        BUTTERFLY1(temp[8 * 2 + i], temp[8 * 3 + i]);
+        BUTTERFLY1(temp[8 * 4 + i], temp[8 * 5 + i]);
+        BUTTERFLY1(temp[8 * 6 + i], temp[8 * 7 + i]);
 
-        BUTTERFLY1(temp[8*0+i], temp[8*2+i]);
-        BUTTERFLY1(temp[8*1+i], temp[8*3+i]);
-        BUTTERFLY1(temp[8*4+i], temp[8*6+i]);
-        BUTTERFLY1(temp[8*5+i], temp[8*7+i]);
+        BUTTERFLY1(temp[8 * 0 + i], temp[8 * 2 + i]);
+        BUTTERFLY1(temp[8 * 1 + i], temp[8 * 3 + i]);
+        BUTTERFLY1(temp[8 * 4 + i], temp[8 * 6 + i]);
+        BUTTERFLY1(temp[8 * 5 + i], temp[8 * 7 + i]);
 
-        sum +=
-             BUTTERFLYA(temp[8*0+i], temp[8*4+i])
-            +BUTTERFLYA(temp[8*1+i], temp[8*5+i])
-            +BUTTERFLYA(temp[8*2+i], temp[8*6+i])
-            +BUTTERFLYA(temp[8*3+i], temp[8*7+i]);
+        sum += BUTTERFLYA(temp[8 * 0 + i], temp[8 * 4 + i]) +
+               BUTTERFLYA(temp[8 * 1 + i], temp[8 * 5 + i]) +
+               BUTTERFLYA(temp[8 * 2 + i], temp[8 * 6 + i]) +
+               BUTTERFLYA(temp[8 * 3 + i], temp[8 * 7 + i]);
     }
     return sum;
 }
 
-static int hadamard8_intra8x8_c(/*MpegEncContext*/ void *s, uint8_t *src, uint8_t *dummy, int stride, int h){
-    int i;
-    int temp[64];
-    int sum=0;
-
-    assert(h==8);
-
-    for(i=0; i<8; i++){
-        //FIXME try pointer walks
-        BUTTERFLY2(temp[8*i+0], temp[8*i+1], src[stride*i+0],src[stride*i+1]);
-        BUTTERFLY2(temp[8*i+2], temp[8*i+3], src[stride*i+2],src[stride*i+3]);
-        BUTTERFLY2(temp[8*i+4], temp[8*i+5], src[stride*i+4],src[stride*i+5]);
-        BUTTERFLY2(temp[8*i+6], temp[8*i+7], src[stride*i+6],src[stride*i+7]);
+static int hadamard8_intra8x8_c(/* MpegEncContext */ void *s, uint8_t *src,
+                                uint8_t *dummy, int stride, int h)
+{
+    int i, temp[64], sum = 0;
 
-        BUTTERFLY1(temp[8*i+0], temp[8*i+2]);
-        BUTTERFLY1(temp[8*i+1], temp[8*i+3]);
-        BUTTERFLY1(temp[8*i+4], temp[8*i+6]);
-        BUTTERFLY1(temp[8*i+5], temp[8*i+7]);
+    assert(h == 8);
 
-        BUTTERFLY1(temp[8*i+0], temp[8*i+4]);
-        BUTTERFLY1(temp[8*i+1], temp[8*i+5]);
-        BUTTERFLY1(temp[8*i+2], temp[8*i+6]);
-        BUTTERFLY1(temp[8*i+3], temp[8*i+7]);
+    for (i = 0; i < 8; i++) {
+        // FIXME: try pointer walks
+        BUTTERFLY2(temp[8 * i + 0], temp[8 * i + 1],
+                   src[stride * i + 0], src[stride * i + 1]);
+        BUTTERFLY2(temp[8 * i + 2], temp[8 * i + 3],
+                   src[stride * i + 2], src[stride * i + 3]);
+        BUTTERFLY2(temp[8 * i + 4], temp[8 * i + 5],
+                   src[stride * i + 4], src[stride * i + 5]);
+        BUTTERFLY2(temp[8 * i + 6], temp[8 * i + 7],
+                   src[stride * i + 6], src[stride * i + 7]);
+
+        BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 2]);
+        BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 3]);
+        BUTTERFLY1(temp[8 * i + 4], temp[8 * i + 6]);
+        BUTTERFLY1(temp[8 * i + 5], temp[8 * i + 7]);
+
+        BUTTERFLY1(temp[8 * i + 0], temp[8 * i + 4]);
+        BUTTERFLY1(temp[8 * i + 1], temp[8 * i + 5]);
+        BUTTERFLY1(temp[8 * i + 2], temp[8 * i + 6]);
+        BUTTERFLY1(temp[8 * i + 3], temp[8 * i + 7]);
     }
 
-    for(i=0; i<8; i++){
-        BUTTERFLY1(temp[8*0+i], temp[8*1+i]);
-        BUTTERFLY1(temp[8*2+i], temp[8*3+i]);
-        BUTTERFLY1(temp[8*4+i], temp[8*5+i]);
-        BUTTERFLY1(temp[8*6+i], temp[8*7+i]);
+    for (i = 0; i < 8; i++) {
+        BUTTERFLY1(temp[8 * 0 + i], temp[8 * 1 + i]);
+        BUTTERFLY1(temp[8 * 2 + i], temp[8 * 3 + i]);
+        BUTTERFLY1(temp[8 * 4 + i], temp[8 * 5 + i]);
+        BUTTERFLY1(temp[8 * 6 + i], temp[8 * 7 + i]);
 
-        BUTTERFLY1(temp[8*0+i], temp[8*2+i]);
-        BUTTERFLY1(temp[8*1+i], temp[8*3+i]);
-        BUTTERFLY1(temp[8*4+i], temp[8*6+i]);
-        BUTTERFLY1(temp[8*5+i], temp[8*7+i]);
+        BUTTERFLY1(temp[8 * 0 + i], temp[8 * 2 + i]);
+        BUTTERFLY1(temp[8 * 1 + i], temp[8 * 3 + i]);
+        BUTTERFLY1(temp[8 * 4 + i], temp[8 * 6 + i]);
+        BUTTERFLY1(temp[8 * 5 + i], temp[8 * 7 + i]);
 
         sum +=
-             BUTTERFLYA(temp[8*0+i], temp[8*4+i])
-            +BUTTERFLYA(temp[8*1+i], temp[8*5+i])
-            +BUTTERFLYA(temp[8*2+i], temp[8*6+i])
-            +BUTTERFLYA(temp[8*3+i], temp[8*7+i]);
+            BUTTERFLYA(temp[8 * 0 + i], temp[8 * 4 + i])
+            + BUTTERFLYA(temp[8 * 1 + i], temp[8 * 5 + i])
+            + BUTTERFLYA(temp[8 * 2 + i], temp[8 * 6 + i])
+            + BUTTERFLYA(temp[8 * 3 + i], temp[8 * 7 + i]);
     }
 
-    sum -= FFABS(temp[8*0] + temp[8*4]); // -mean
+    sum -= FFABS(temp[8 * 0] + temp[8 * 4]); // -mean
 
     return sum;
 }
 
-static int dct_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
-    MpegEncContext * const s= (MpegEncContext *)c;
+static int dct_sad8x8_c(/* MpegEncContext */ void *c, uint8_t *src1,
+                        uint8_t *src2, int stride, int h)
+{
+    MpegEncContext *const s = (MpegEncContext *) c;
     LOCAL_ALIGNED_16(int16_t, temp, [64]);
 
-    assert(h==8);
+    assert(h == 8);
 
     s->dsp.diff_pixels(temp, src1, src2, stride);
     s->dsp.fdct(temp);
@@ -1988,161 +2246,170 @@ static int dct_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2
 }
 
 #if CONFIG_GPL
-#define DCT8_1D {\
-    const int s07 = SRC(0) + SRC(7);\
-    const int s16 = SRC(1) + SRC(6);\
-    const int s25 = SRC(2) + SRC(5);\
-    const int s34 = SRC(3) + SRC(4);\
-    const int a0 = s07 + s34;\
-    const int a1 = s16 + s25;\
-    const int a2 = s07 - s34;\
-    const int a3 = s16 - s25;\
-    const int d07 = SRC(0) - SRC(7);\
-    const int d16 = SRC(1) - SRC(6);\
-    const int d25 = SRC(2) - SRC(5);\
-    const int d34 = SRC(3) - SRC(4);\
-    const int a4 = d16 + d25 + (d07 + (d07>>1));\
-    const int a5 = d07 - d34 - (d25 + (d25>>1));\
-    const int a6 = d07 + d34 - (d16 + (d16>>1));\
-    const int a7 = d16 - d25 + (d34 + (d34>>1));\
-    DST(0,  a0 + a1     ) ;\
-    DST(1,  a4 + (a7>>2)) ;\
-    DST(2,  a2 + (a3>>1)) ;\
-    DST(3,  a5 + (a6>>2)) ;\
-    DST(4,  a0 - a1     ) ;\
-    DST(5,  a6 - (a5>>2)) ;\
-    DST(6, (a2>>1) - a3 ) ;\
-    DST(7, (a4>>2) - a7 ) ;\
-}
-
-static int dct264_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
-    MpegEncContext * const s= (MpegEncContext *)c;
+#define DCT8_1D                                         \
+    {                                                   \
+        const int s07 = SRC(0) + SRC(7);                \
+        const int s16 = SRC(1) + SRC(6);                \
+        const int s25 = SRC(2) + SRC(5);                \
+        const int s34 = SRC(3) + SRC(4);                \
+        const int a0  = s07 + s34;                      \
+        const int a1  = s16 + s25;                      \
+        const int a2  = s07 - s34;                      \
+        const int a3  = s16 - s25;                      \
+        const int d07 = SRC(0) - SRC(7);                \
+        const int d16 = SRC(1) - SRC(6);                \
+        const int d25 = SRC(2) - SRC(5);                \
+        const int d34 = SRC(3) - SRC(4);                \
+        const int a4  = d16 + d25 + (d07 + (d07 >> 1)); \
+        const int a5  = d07 - d34 - (d25 + (d25 >> 1)); \
+        const int a6  = d07 + d34 - (d16 + (d16 >> 1)); \
+        const int a7  = d16 - d25 + (d34 + (d34 >> 1)); \
+        DST(0, a0 + a1);                                \
+        DST(1, a4 + (a7 >> 2));                         \
+        DST(2, a2 + (a3 >> 1));                         \
+        DST(3, a5 + (a6 >> 2));                         \
+        DST(4, a0 - a1);                                \
+        DST(5, a6 - (a5 >> 2));                         \
+        DST(6, (a2 >> 1) - a3);                         \
+        DST(7, (a4 >> 2) - a7);                         \
+    }
+
+static int dct264_sad8x8_c(/* MpegEncContext */ void *c, uint8_t *src1,
+                           uint8_t *src2, int stride, int h)
+{
+    MpegEncContext *const s = (MpegEncContext *) c;
     int16_t dct[8][8];
-    int i;
-    int sum=0;
+    int i, sum = 0;
 
     s->dsp.diff_pixels(dct[0], src1, src2, stride);
 
 #define SRC(x) dct[i][x]
-#define DST(x,v) dct[i][x]= v
-    for( i = 0; i < 8; i++ )
+#define DST(x, v) dct[i][x] = v
+    for (i = 0; i < 8; i++)
         DCT8_1D
 #undef SRC
 #undef DST
 
 #define SRC(x) dct[x][i]
-#define DST(x,v) sum += FFABS(v)
-    for( i = 0; i < 8; i++ )
-        DCT8_1D
+#define DST(x, v) sum += FFABS(v)
+        for (i = 0; i < 8; i++)
+            DCT8_1D
 #undef SRC
 #undef DST
-    return sum;
+            return sum;
 }
 #endif
 
-static int dct_max8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
-    MpegEncContext * const s= (MpegEncContext *)c;
+static int dct_max8x8_c(/* MpegEncContext */ void *c, uint8_t *src1,
+                        uint8_t *src2, int stride, int h)
+{
+    MpegEncContext *const s = (MpegEncContext *) c;
     LOCAL_ALIGNED_16(int16_t, temp, [64]);
-    int sum=0, i;
+    int sum = 0, i;
 
-    assert(h==8);
+    assert(h == 8);
 
     s->dsp.diff_pixels(temp, src1, src2, stride);
     s->dsp.fdct(temp);
 
-    for(i=0; i<64; i++)
-        sum= FFMAX(sum, FFABS(temp[i]));
+    for (i = 0; i < 64; i++)
+        sum = FFMAX(sum, FFABS(temp[i]));
 
     return sum;
 }
 
-static int quant_psnr8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
-    MpegEncContext * const s= (MpegEncContext *)c;
-    LOCAL_ALIGNED_16(int16_t, temp, [64*2]);
-    int16_t * const bak = temp+64;
-    int sum=0, i;
+static int quant_psnr8x8_c(/* MpegEncContext */ void *c, uint8_t *src1,
+                           uint8_t *src2, int stride, int h)
+{
+    MpegEncContext *const s = c;
+    LOCAL_ALIGNED_16(int16_t, temp, [64 * 2]);
+    int16_t *const bak = temp + 64;
+    int sum = 0, i;
 
-    assert(h==8);
-    s->mb_intra=0;
+    assert(h == 8);
+    s->mb_intra = 0;
 
     s->dsp.diff_pixels(temp, src1, src2, stride);
 
-    memcpy(bak, temp, 64*sizeof(int16_t));
+    memcpy(bak, temp, 64 * sizeof(int16_t));
 
-    s->block_last_index[0/*FIXME*/]= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
+    s->block_last_index[0 /* FIXME */] =
+        s->fast_dct_quantize(s, temp, 0 /* FIXME */, s->qscale, &i);
     s->dct_unquantize_inter(s, temp, 0, s->qscale);
-    ff_simple_idct_8(temp); //FIXME
+    ff_simple_idct_8(temp); // FIXME
 
-    for(i=0; i<64; i++)
-        sum+= (temp[i]-bak[i])*(temp[i]-bak[i]);
+    for (i = 0; i < 64; i++)
+        sum += (temp[i] - bak[i]) * (temp[i] - bak[i]);
 
     return sum;
 }
 
-static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
-    MpegEncContext * const s= (MpegEncContext *)c;
-    const uint8_t *scantable= s->intra_scantable.permutated;
+static int rd8x8_c(/* MpegEncContext */ void *c, uint8_t *src1, uint8_t *src2,
+                   int stride, int h)
+{
+    MpegEncContext *const s  = (MpegEncContext *) c;
+    const uint8_t *scantable = s->intra_scantable.permutated;
     LOCAL_ALIGNED_16(int16_t, temp, [64]);
     LOCAL_ALIGNED_16(uint8_t, lsrc1, [64]);
     LOCAL_ALIGNED_16(uint8_t, lsrc2, [64]);
     int i, last, run, bits, level, distortion, start_i;
-    const int esc_length= s->ac_esc_length;
-    uint8_t * length;
-    uint8_t * last_length;
+    const int esc_length = s->ac_esc_length;
+    uint8_t *length, *last_length;
 
-    assert(h==8);
+    assert(h == 8);
 
     copy_block8(lsrc1, src1, 8, stride, 8);
     copy_block8(lsrc2, src2, 8, stride, 8);
 
     s->dsp.diff_pixels(temp, lsrc1, lsrc2, 8);
 
-    s->block_last_index[0/*FIXME*/]= last= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
+    s->block_last_index[0 /* FIXME */] =
+    last                               =
+        s->fast_dct_quantize(s, temp, 0 /* FIXME */, s->qscale, &i);
 
-    bits=0;
+    bits = 0;
 
     if (s->mb_intra) {
-        start_i = 1;
-        length     = s->intra_ac_vlc_length;
-        last_length= s->intra_ac_vlc_last_length;
-        bits+= s->luma_dc_vlc_length[temp[0] + 256]; //FIXME chroma
+        start_i     = 1;
+        length      = s->intra_ac_vlc_length;
+        last_length = s->intra_ac_vlc_last_length;
+        bits       += s->luma_dc_vlc_length[temp[0] + 256]; // FIXME: chroma
     } else {
-        start_i = 0;
-        length     = s->inter_ac_vlc_length;
-        last_length= s->inter_ac_vlc_last_length;
-    }
-
-    if(last>=start_i){
-        run=0;
-        for(i=start_i; i<last; i++){
-            int j= scantable[i];
-            level= temp[j];
-
-            if(level){
-                level+=64;
-                if((level&(~127)) == 0){
-                    bits+= length[UNI_AC_ENC_INDEX(run, level)];
-                }else
-                    bits+= esc_length;
-                run=0;
-            }else
+        start_i     = 0;
+        length      = s->inter_ac_vlc_length;
+        last_length = s->inter_ac_vlc_last_length;
+    }
+
+    if (last >= start_i) {
+        run = 0;
+        for (i = start_i; i < last; i++) {
+            int j = scantable[i];
+            level = temp[j];
+
+            if (level) {
+                level += 64;
+                if ((level & (~127)) == 0)
+                    bits += length[UNI_AC_ENC_INDEX(run, level)];
+                else
+                    bits += esc_length;
+                run = 0;
+            } else
                 run++;
         }
-        i= scantable[last];
+        i = scantable[last];
 
-        level= temp[i] + 64;
+        level = temp[i] + 64;
 
         assert(level - 64);
 
-        if((level&(~127)) == 0){
-            bits+= last_length[UNI_AC_ENC_INDEX(run, level)];
-        }else
-            bits+= esc_length;
-
+        if ((level & (~127)) == 0) {
+            bits += last_length[UNI_AC_ENC_INDEX(run, level)];
+        } else
+            bits += esc_length;
     }
 
-    if(last>=0){
-        if(s->mb_intra)
+    if (last >= 0) {
+        if (s->mb_intra)
             s->dct_unquantize_intra(s, temp, 0, s->qscale);
         else
             s->dct_unquantize_inter(s, temp, 0, s->qscale);
@@ -2150,158 +2417,174 @@ static int rd8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int
 
     s->dsp.idct_add(lsrc2, 8, temp);
 
-    distortion= s->dsp.sse[1](NULL, lsrc2, lsrc1, 8, 8);
+    distortion = s->dsp.sse[1](NULL, lsrc2, lsrc1, 8, 8);
 
-    return distortion + ((bits*s->qscale*s->qscale*109 + 64)>>7);
+    return distortion + ((bits * s->qscale * s->qscale * 109 + 64) >> 7);
 }
 
-static int bit8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
-    MpegEncContext * const s= (MpegEncContext *)c;
-    const uint8_t *scantable= s->intra_scantable.permutated;
+static int bit8x8_c(/* MpegEncContext */ void *c, uint8_t *src1, uint8_t *src2,
+                    int stride, int h)
+{
+    MpegEncContext *const s  = (MpegEncContext *) c;
+    const uint8_t *scantable = s->intra_scantable.permutated;
     LOCAL_ALIGNED_16(int16_t, temp, [64]);
     int i, last, run, bits, level, start_i;
-    const int esc_length= s->ac_esc_length;
-    uint8_t * length;
-    uint8_t * last_length;
+    const int esc_length = s->ac_esc_length;
+    uint8_t *length, *last_length;
 
-    assert(h==8);
+    assert(h == 8);
 
     s->dsp.diff_pixels(temp, src1, src2, stride);
 
-    s->block_last_index[0/*FIXME*/]= last= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
+    s->block_last_index[0 /* FIXME */] =
+    last                               =
+        s->fast_dct_quantize(s, temp, 0 /* FIXME */, s->qscale, &i);
 
-    bits=0;
+    bits = 0;
 
     if (s->mb_intra) {
-        start_i = 1;
-        length     = s->intra_ac_vlc_length;
-        last_length= s->intra_ac_vlc_last_length;
-        bits+= s->luma_dc_vlc_length[temp[0] + 256]; //FIXME chroma
+        start_i     = 1;
+        length      = s->intra_ac_vlc_length;
+        last_length = s->intra_ac_vlc_last_length;
+        bits       += s->luma_dc_vlc_length[temp[0] + 256]; // FIXME: chroma
     } else {
-        start_i = 0;
-        length     = s->inter_ac_vlc_length;
-        last_length= s->inter_ac_vlc_last_length;
-    }
-
-    if(last>=start_i){
-        run=0;
-        for(i=start_i; i<last; i++){
-            int j= scantable[i];
-            level= temp[j];
-
-            if(level){
-                level+=64;
-                if((level&(~127)) == 0){
-                    bits+= length[UNI_AC_ENC_INDEX(run, level)];
-                }else
-                    bits+= esc_length;
-                run=0;
-            }else
+        start_i     = 0;
+        length      = s->inter_ac_vlc_length;
+        last_length = s->inter_ac_vlc_last_length;
+    }
+
+    if (last >= start_i) {
+        run = 0;
+        for (i = start_i; i < last; i++) {
+            int j = scantable[i];
+            level = temp[j];
+
+            if (level) {
+                level += 64;
+                if ((level & (~127)) == 0)
+                    bits += length[UNI_AC_ENC_INDEX(run, level)];
+                else
+                    bits += esc_length;
+                run = 0;
+            } else
                 run++;
         }
-        i= scantable[last];
+        i = scantable[last];
 
-        level= temp[i] + 64;
+        level = temp[i] + 64;
 
         assert(level - 64);
 
-        if((level&(~127)) == 0){
-            bits+= last_length[UNI_AC_ENC_INDEX(run, level)];
-        }else
-            bits+= esc_length;
+        if ((level & (~127)) == 0)
+            bits += last_length[UNI_AC_ENC_INDEX(run, level)];
+        else
+            bits += esc_length;
     }
 
     return bits;
 }
 
-#define VSAD_INTRA(size) \
-static int vsad_intra##size##_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){ \
-    int score=0;                                                                                            \
-    int x,y;                                                                                                \
-                                                                                                            \
-    for(y=1; y<h; y++){                                                                                     \
-        for(x=0; x<size; x+=4){                                                                             \
-            score+= FFABS(s[x  ] - s[x  +stride]) + FFABS(s[x+1] - s[x+1+stride])                           \
-                   +FFABS(s[x+2] - s[x+2+stride]) + FFABS(s[x+3] - s[x+3+stride]);                          \
-        }                                                                                                   \
-        s+= stride;                                                                                         \
-    }                                                                                                       \
-                                                                                                            \
-    return score;                                                                                           \
+#define VSAD_INTRA(size)                                                \
+static int vsad_intra ## size ## _c(/* MpegEncContext */ void *c,       \
+                                    uint8_t *s, uint8_t *dummy,         \
+                                    int stride, int h)                  \
+{                                                                       \
+    int score = 0, x, y;                                                \
+                                                                        \
+    for (y = 1; y < h; y++) {                                           \
+        for (x = 0; x < size; x += 4) {                                 \
+            score += FFABS(s[x]     - s[x + stride])     +              \
+                     FFABS(s[x + 1] - s[x + stride + 1]) +              \
+                     FFABS(s[x + 2] - s[x + 2 + stride]) +              \
+                     FFABS(s[x + 3] - s[x + 3 + stride]);               \
+        }                                                               \
+        s += stride;                                                    \
+    }                                                                   \
+                                                                        \
+    return score;                                                       \
 }
 VSAD_INTRA(8)
 VSAD_INTRA(16)
 
-static int vsad16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){
-    int score=0;
-    int x,y;
+static int vsad16_c(/* MpegEncContext */ void *c, uint8_t *s1, uint8_t *s2,
+                    int stride, int h)
+{
+    int score = 0, x, y;
 
-    for(y=1; y<h; y++){
-        for(x=0; x<16; x++){
-            score+= FFABS(s1[x  ] - s2[x ] - s1[x  +stride] + s2[x +stride]);
-        }
-        s1+= stride;
-        s2+= stride;
+    for (y = 1; y < h; y++) {
+        for (x = 0; x < 16; x++)
+            score += FFABS(s1[x] - s2[x] - s1[x + stride] + s2[x + stride]);
+        s1 += stride;
+        s2 += stride;
     }
 
     return score;
 }
 
-#define SQ(a) ((a)*(a))
-#define VSSE_INTRA(size) \
-static int vsse_intra##size##_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){ \
-    int score=0;                                                                                            \
-    int x,y;                                                                                                \
-                                                                                                            \
-    for(y=1; y<h; y++){                                                                                     \
-        for(x=0; x<size; x+=4){                                                                               \
-            score+= SQ(s[x  ] - s[x  +stride]) + SQ(s[x+1] - s[x+1+stride])                                 \
-                   +SQ(s[x+2] - s[x+2+stride]) + SQ(s[x+3] - s[x+3+stride]);                                \
-        }                                                                                                   \
-        s+= stride;                                                                                         \
-    }                                                                                                       \
-                                                                                                            \
-    return score;                                                                                           \
+#define SQ(a) ((a) * (a))
+#define VSSE_INTRA(size)                                                \
+static int vsse_intra ## size ## _c(/* MpegEncContext */ void *c,       \
+                                    uint8_t *s, uint8_t *dummy,         \
+                                    int stride, int h)                  \
+{                                                                       \
+    int score = 0, x, y;                                                \
+                                                                        \
+    for (y = 1; y < h; y++) {                                           \
+        for (x = 0; x < size; x += 4) {                                 \
+            score += SQ(s[x]     - s[x + stride]) +                     \
+                     SQ(s[x + 1] - s[x + stride + 1]) +                 \
+                     SQ(s[x + 2] - s[x + stride + 2]) +                 \
+                     SQ(s[x + 3] - s[x + stride + 3]);                  \
+        }                                                               \
+        s += stride;                                                    \
+    }                                                                   \
+                                                                        \
+    return score;                                                       \
 }
 VSSE_INTRA(8)
 VSSE_INTRA(16)
 
-static int vsse16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){
-    int score=0;
-    int x,y;
+static int vsse16_c(/* MpegEncContext */ void *c, uint8_t *s1, uint8_t *s2,
+                    int stride, int h)
+{
+    int score = 0, x, y;
 
-    for(y=1; y<h; y++){
-        for(x=0; x<16; x++){
-            score+= SQ(s1[x  ] - s2[x ] - s1[x  +stride] + s2[x +stride]);
-        }
-        s1+= stride;
-        s2+= stride;
+    for (y = 1; y < h; y++) {
+        for (x = 0; x < 16; x++)
+            score += SQ(s1[x] - s2[x] - s1[x + stride] + s2[x + stride]);
+        s1 += stride;
+        s2 += stride;
     }
 
     return score;
 }
 
 static int ssd_int8_vs_int16_c(const int8_t *pix1, const int16_t *pix2,
-                               int size){
-    int score=0;
-    int i;
-    for(i=0; i<size; i++)
-        score += (pix1[i]-pix2[i])*(pix1[i]-pix2[i]);
+                               int size)
+{
+    int score = 0, i;
+
+    for (i = 0; i < size; i++)
+        score += (pix1[i] - pix2[i]) * (pix1[i] - pix2[i]);
     return score;
 }
 
-#define WRAPPER8_16_SQ(name8, name16)\
-static int name16(void /*MpegEncContext*/ *s, uint8_t *dst, uint8_t *src, int stride, int h){\
-    int score=0;\
-    score +=name8(s, dst           , src           , stride, 8);\
-    score +=name8(s, dst+8         , src+8         , stride, 8);\
-    if(h==16){\
-        dst += 8*stride;\
-        src += 8*stride;\
-        score +=name8(s, dst           , src           , stride, 8);\
-        score +=name8(s, dst+8         , src+8         , stride, 8);\
-    }\
-    return score;\
+#define WRAPPER8_16_SQ(name8, name16)                                   \
+static int name16(void /*MpegEncContext*/ *s,                           \
+                  uint8_t *dst, uint8_t *src,                           \
+                  int stride, int h)                                    \
+{                                                                       \
+    int score = 0;                                                      \
+                                                                        \
+    score += name8(s, dst, src, stride, 8);                             \
+    score += name8(s, dst + 8, src + 8, stride, 8);                     \
+    if (h == 16) {                                                      \
+        dst   += 8 * stride;                                            \
+        src   += 8 * stride;                                            \
+        score += name8(s, dst, src, stride, 8);                         \
+        score += name8(s, dst + 8, src + 8, stride, 8);                 \
+    }                                                                   \
+    return score;                                                       \
 }
 
 WRAPPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c)
@@ -2316,22 +2599,27 @@ WRAPPER8_16_SQ(rd8x8_c, rd16_c)
 WRAPPER8_16_SQ(bit8x8_c, bit16_c)
 
 static inline uint32_t clipf_c_one(uint32_t a, uint32_t mini,
-                   uint32_t maxi, uint32_t maxisign)
+                                   uint32_t maxi, uint32_t maxisign)
 {
-
-    if(a > mini) return mini;
-    else if((a^(1U<<31)) > maxisign) return maxi;
-    else return a;
+    if (a > mini)
+        return mini;
+    else if ((a ^ (1U << 31)) > maxisign)
+        return maxi;
+    else
+        return a;
 }
 
-static void vector_clipf_c_opposite_sign(float *dst, const float *src, float *min, float *max, int len){
+static void vector_clipf_c_opposite_sign(float *dst, const float *src,
+                                         float *min, float *max, int len)
+{
     int i;
-    uint32_t mini = *(uint32_t*)min;
-    uint32_t maxi = *(uint32_t*)max;
-    uint32_t maxisign = maxi ^ (1U<<31);
-    uint32_t *dsti = (uint32_t*)dst;
-    const uint32_t *srci = (const uint32_t*)src;
-    for(i=0; i<len; i+=8) {
+    uint32_t mini        = *(uint32_t *) min;
+    uint32_t maxi        = *(uint32_t *) max;
+    uint32_t maxisign    = maxi ^ (1U << 31);
+    uint32_t *dsti       = (uint32_t *) dst;
+    const uint32_t *srci = (const uint32_t *) src;
+
+    for (i = 0; i < len; i += 8) {
         dsti[i + 0] = clipf_c_one(srci[i + 0], mini, maxi, maxisign);
         dsti[i + 1] = clipf_c_one(srci[i + 1], mini, maxi, maxisign);
         dsti[i + 2] = clipf_c_one(srci[i + 2], mini, maxi, maxisign);
@@ -2342,13 +2630,17 @@ static void vector_clipf_c_opposite_sign(float *dst, const float *src, float *mi
         dsti[i + 7] = clipf_c_one(srci[i + 7], mini, maxi, maxisign);
     }
 }
-static void vector_clipf_c(float *dst, const float *src, float min, float max, int len){
+
+static void vector_clipf_c(float *dst, const float *src,
+                           float min, float max, int len)
+{
     int i;
-    if(min < 0 && max > 0) {
+
+    if (min < 0 && max > 0) {
         vector_clipf_c_opposite_sign(dst, src, &min, &max, len);
     } else {
-        for(i=0; i < len; i+=8) {
-            dst[i    ] = av_clipf(src[i    ], min, max);
+        for (i = 0; i < len; i += 8) {
+            dst[i]     = av_clipf(src[i], min, max);
             dst[i + 1] = av_clipf(src[i + 1], min, max);
             dst[i + 2] = av_clipf(src[i + 2], min, max);
             dst[i + 3] = av_clipf(src[i + 3], min, max);
@@ -2360,19 +2652,23 @@ static void vector_clipf_c(float *dst, const float *src, float min, float max, i
     }
 }
 
-static int32_t scalarproduct_int16_c(const int16_t * v1, const int16_t * v2, int order)
+static int32_t scalarproduct_int16_c(const int16_t *v1, const int16_t *v2,
+                                     int order)
 {
     int res = 0;
 
     while (order--)
-        res += *v1++ * *v2++;
+        res += *v1++ **v2++;
 
     return res;
 }
 
-static int32_t scalarproduct_and_madd_int16_c(int16_t *v1, const int16_t *v2, const int16_t *v3, int order, int mul)
+static int32_t scalarproduct_and_madd_int16_c(int16_t *v1, const int16_t *v2,
+                                              const int16_t *v3,
+                                              int order, int mul)
 {
     int res = 0;
+
     while (order--) {
         res   += *v1 * *v2++;
         *v1++ += mul * *v3++;
@@ -2392,18 +2688,19 @@ static void vector_clip_int32_c(int32_t *dst, const int32_t *src, int32_t min,
         *dst++ = av_clip(*src++, min, max);
         *dst++ = av_clip(*src++, min, max);
         *dst++ = av_clip(*src++, min, max);
-        len -= 8;
+        len   -= 8;
     } while (len > 0);
 }
 
 static void jref_idct_put(uint8_t *dest, int line_size, int16_t *block)
 {
-    ff_j_rev_dct (block);
+    ff_j_rev_dct(block);
     put_pixels_clamped_c(block, dest, line_size);
 }
+
 static void jref_idct_add(uint8_t *dest, int line_size, int16_t *block)
 {
-    ff_j_rev_dct (block);
+    ff_j_rev_dct(block);
     add_pixels_clamped_c(block, dest, line_size);
 }
 
@@ -2412,54 +2709,29 @@ av_cold void ff_dsputil_static_init(void)
 {
     int i;
 
-    for(i=0;i<512;i++) {
-        ff_squareTbl[i] = (i - 256) * (i - 256);
-    }
-}
-
-int ff_check_alignment(void){
-    static int did_fail=0;
-    LOCAL_ALIGNED_16(int, aligned, [4]);
-
-    if((intptr_t)aligned & 15){
-        if(!did_fail){
-#if HAVE_MMX || HAVE_ALTIVEC
-            av_log(NULL, AV_LOG_ERROR,
-                "Compiler did not align stack variables. Libavcodec has been miscompiled\n"
-                "and may be very slow or crash. This is not a bug in libavcodec,\n"
-                "but in the compiler. You may try recompiling using gcc >= 4.2.\n"
-                "Do not report crashes to Libav developers.\n");
-#endif
-            did_fail=1;
-        }
-        return -1;
-    }
-    return 0;
+    for (i = 0; i < 512; i++)
+        ff_square_tab[i] = (i - 256) * (i - 256);
 }
 
-av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
+av_cold void ff_dsputil_init(DSPContext *c, AVCodecContext *avctx)
 {
-    ff_check_alignment();
-
 #if CONFIG_ENCODERS
     if (avctx->bits_per_raw_sample == 10) {
         c->fdct    = ff_jpeg_fdct_islow_10;
         c->fdct248 = ff_fdct248_islow_10;
     } else {
-        if(avctx->dct_algo==FF_DCT_FASTINT) {
+        if (avctx->dct_algo == FF_DCT_FASTINT) {
             c->fdct    = ff_fdct_ifast;
             c->fdct248 = ff_fdct_ifast248;
-        }
-        else if(avctx->dct_algo==FF_DCT_FAAN) {
+        } else if (avctx->dct_algo == FF_DCT_FAAN) {
             c->fdct    = ff_faandct;
             c->fdct248 = ff_faandct248;
-        }
-        else {
-            c->fdct    = ff_jpeg_fdct_islow_8; //slow/accurate/default
+        } else {
+            c->fdct    = ff_jpeg_fdct_islow_8; // slow/accurate/default
             c->fdct248 = ff_fdct248_islow_8;
         }
     }
-#endif //CONFIG_ENCODERS
+#endif /* CONFIG_ENCODERS */
 
     if (avctx->bits_per_raw_sample == 10) {
         c->idct_put              = ff_simple_idct_put_10;
@@ -2467,32 +2739,36 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
         c->idct                  = ff_simple_idct_10;
         c->idct_permutation_type = FF_NO_IDCT_PERM;
     } else {
-        if(avctx->idct_algo==FF_IDCT_INT){
-            c->idct_put= jref_idct_put;
-            c->idct_add= jref_idct_add;
-            c->idct    = ff_j_rev_dct;
-            c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
-        }else if(avctx->idct_algo==FF_IDCT_FAAN){
-            c->idct_put= ff_faanidct_put;
-            c->idct_add= ff_faanidct_add;
-            c->idct    = ff_faanidct;
-            c->idct_permutation_type= FF_NO_IDCT_PERM;
-        }else{ //accurate/default
-            c->idct_put = ff_simple_idct_put_8;
-            c->idct_add = ff_simple_idct_add_8;
-            c->idct     = ff_simple_idct_8;
-            c->idct_permutation_type= FF_NO_IDCT_PERM;
+        if (avctx->idct_algo == FF_IDCT_INT) {
+            c->idct_put              = jref_idct_put;
+            c->idct_add              = jref_idct_add;
+            c->idct                  = ff_j_rev_dct;
+            c->idct_permutation_type = FF_LIBMPEG2_IDCT_PERM;
+        } else if (avctx->idct_algo == FF_IDCT_FAAN) {
+            c->idct_put              = ff_faanidct_put;
+            c->idct_add              = ff_faanidct_add;
+            c->idct                  = ff_faanidct;
+            c->idct_permutation_type = FF_NO_IDCT_PERM;
+        } else { // accurate/default
+            c->idct_put              = ff_simple_idct_put_8;
+            c->idct_add              = ff_simple_idct_add_8;
+            c->idct                  = ff_simple_idct_8;
+            c->idct_permutation_type = FF_NO_IDCT_PERM;
         }
     }
 
     c->diff_pixels = diff_pixels_c;
-    c->put_pixels_clamped = put_pixels_clamped_c;
+
+    c->put_pixels_clamped        = put_pixels_clamped_c;
     c->put_signed_pixels_clamped = put_signed_pixels_clamped_c;
-    c->add_pixels_clamped = add_pixels_clamped_c;
+    c->add_pixels_clamped        = add_pixels_clamped_c;
+
     c->sum_abs_dctelem = sum_abs_dctelem_c;
+
     c->gmc1 = gmc1_c;
-    c->gmc = ff_gmc_c;
-    c->pix_sum = pix_sum_c;
+    c->gmc  = ff_gmc_c;
+
+    c->pix_sum   = pix_sum_c;
     c->pix_norm1 = pix_norm1_c;
 
     c->fill_block_tab[0] = fill_block16_c;
@@ -2508,37 +2784,37 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
     c->pix_abs[1][2] = pix_abs8_y2_c;
     c->pix_abs[1][3] = pix_abs8_xy2_c;
 
-    c->put_tpel_pixels_tab[ 0] = put_tpel_pixels_mc00_c;
-    c->put_tpel_pixels_tab[ 1] = put_tpel_pixels_mc10_c;
-    c->put_tpel_pixels_tab[ 2] = put_tpel_pixels_mc20_c;
-    c->put_tpel_pixels_tab[ 4] = put_tpel_pixels_mc01_c;
-    c->put_tpel_pixels_tab[ 5] = put_tpel_pixels_mc11_c;
-    c->put_tpel_pixels_tab[ 6] = put_tpel_pixels_mc21_c;
-    c->put_tpel_pixels_tab[ 8] = put_tpel_pixels_mc02_c;
-    c->put_tpel_pixels_tab[ 9] = put_tpel_pixels_mc12_c;
+    c->put_tpel_pixels_tab[0]  = put_tpel_pixels_mc00_c;
+    c->put_tpel_pixels_tab[1]  = put_tpel_pixels_mc10_c;
+    c->put_tpel_pixels_tab[2]  = put_tpel_pixels_mc20_c;
+    c->put_tpel_pixels_tab[4]  = put_tpel_pixels_mc01_c;
+    c->put_tpel_pixels_tab[5]  = put_tpel_pixels_mc11_c;
+    c->put_tpel_pixels_tab[6]  = put_tpel_pixels_mc21_c;
+    c->put_tpel_pixels_tab[8]  = put_tpel_pixels_mc02_c;
+    c->put_tpel_pixels_tab[9]  = put_tpel_pixels_mc12_c;
     c->put_tpel_pixels_tab[10] = put_tpel_pixels_mc22_c;
 
-    c->avg_tpel_pixels_tab[ 0] = avg_tpel_pixels_mc00_c;
-    c->avg_tpel_pixels_tab[ 1] = avg_tpel_pixels_mc10_c;
-    c->avg_tpel_pixels_tab[ 2] = avg_tpel_pixels_mc20_c;
-    c->avg_tpel_pixels_tab[ 4] = avg_tpel_pixels_mc01_c;
-    c->avg_tpel_pixels_tab[ 5] = avg_tpel_pixels_mc11_c;
-    c->avg_tpel_pixels_tab[ 6] = avg_tpel_pixels_mc21_c;
-    c->avg_tpel_pixels_tab[ 8] = avg_tpel_pixels_mc02_c;
-    c->avg_tpel_pixels_tab[ 9] = avg_tpel_pixels_mc12_c;
+    c->avg_tpel_pixels_tab[0]  = avg_tpel_pixels_mc00_c;
+    c->avg_tpel_pixels_tab[1]  = avg_tpel_pixels_mc10_c;
+    c->avg_tpel_pixels_tab[2]  = avg_tpel_pixels_mc20_c;
+    c->avg_tpel_pixels_tab[4]  = avg_tpel_pixels_mc01_c;
+    c->avg_tpel_pixels_tab[5]  = avg_tpel_pixels_mc11_c;
+    c->avg_tpel_pixels_tab[6]  = avg_tpel_pixels_mc21_c;
+    c->avg_tpel_pixels_tab[8]  = avg_tpel_pixels_mc02_c;
+    c->avg_tpel_pixels_tab[9]  = avg_tpel_pixels_mc12_c;
     c->avg_tpel_pixels_tab[10] = avg_tpel_pixels_mc22_c;
 
-#define dspfunc(PFX, IDX, NUM) \
-    c->PFX ## _pixels_tab[IDX][ 0] = PFX ## NUM ## _mc00_c; \
-    c->PFX ## _pixels_tab[IDX][ 1] = PFX ## NUM ## _mc10_c; \
-    c->PFX ## _pixels_tab[IDX][ 2] = PFX ## NUM ## _mc20_c; \
-    c->PFX ## _pixels_tab[IDX][ 3] = PFX ## NUM ## _mc30_c; \
-    c->PFX ## _pixels_tab[IDX][ 4] = PFX ## NUM ## _mc01_c; \
-    c->PFX ## _pixels_tab[IDX][ 5] = PFX ## NUM ## _mc11_c; \
-    c->PFX ## _pixels_tab[IDX][ 6] = PFX ## NUM ## _mc21_c; \
-    c->PFX ## _pixels_tab[IDX][ 7] = PFX ## NUM ## _mc31_c; \
-    c->PFX ## _pixels_tab[IDX][ 8] = PFX ## NUM ## _mc02_c; \
-    c->PFX ## _pixels_tab[IDX][ 9] = PFX ## NUM ## _mc12_c; \
+#define dspfunc(PFX, IDX, NUM)                              \
+    c->PFX ## _pixels_tab[IDX][0]  = PFX ## NUM ## _mc00_c; \
+    c->PFX ## _pixels_tab[IDX][1]  = PFX ## NUM ## _mc10_c; \
+    c->PFX ## _pixels_tab[IDX][2]  = PFX ## NUM ## _mc20_c; \
+    c->PFX ## _pixels_tab[IDX][3]  = PFX ## NUM ## _mc30_c; \
+    c->PFX ## _pixels_tab[IDX][4]  = PFX ## NUM ## _mc01_c; \
+    c->PFX ## _pixels_tab[IDX][5]  = PFX ## NUM ## _mc11_c; \
+    c->PFX ## _pixels_tab[IDX][6]  = PFX ## NUM ## _mc21_c; \
+    c->PFX ## _pixels_tab[IDX][7]  = PFX ## NUM ## _mc31_c; \
+    c->PFX ## _pixels_tab[IDX][8]  = PFX ## NUM ## _mc02_c; \
+    c->PFX ## _pixels_tab[IDX][9]  = PFX ## NUM ## _mc12_c; \
     c->PFX ## _pixels_tab[IDX][10] = PFX ## NUM ## _mc22_c; \
     c->PFX ## _pixels_tab[IDX][11] = PFX ## NUM ## _mc32_c; \
     c->PFX ## _pixels_tab[IDX][12] = PFX ## NUM ## _mc03_c; \
@@ -2547,94 +2823,95 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
     c->PFX ## _pixels_tab[IDX][15] = PFX ## NUM ## _mc33_c
 
     dspfunc(put_qpel, 0, 16);
-    dspfunc(put_no_rnd_qpel, 0, 16);
-
-    dspfunc(avg_qpel, 0, 16);
-    /* dspfunc(avg_no_rnd_qpel, 0, 16); */
-
     dspfunc(put_qpel, 1, 8);
+
+    dspfunc(put_no_rnd_qpel, 0, 16);
     dspfunc(put_no_rnd_qpel, 1, 8);
 
+    dspfunc(avg_qpel, 0, 16);
     dspfunc(avg_qpel, 1, 8);
-    /* dspfunc(avg_no_rnd_qpel, 1, 8); */
 
 #undef dspfunc
 
-    c->put_mspel_pixels_tab[0]= ff_put_pixels8x8_c;
-    c->put_mspel_pixels_tab[1]= put_mspel8_mc10_c;
-    c->put_mspel_pixels_tab[2]= put_mspel8_mc20_c;
-    c->put_mspel_pixels_tab[3]= put_mspel8_mc30_c;
-    c->put_mspel_pixels_tab[4]= put_mspel8_mc02_c;
-    c->put_mspel_pixels_tab[5]= put_mspel8_mc12_c;
-    c->put_mspel_pixels_tab[6]= put_mspel8_mc22_c;
-    c->put_mspel_pixels_tab[7]= put_mspel8_mc32_c;
+    c->put_mspel_pixels_tab[0] = ff_put_pixels8x8_c;
+    c->put_mspel_pixels_tab[1] = put_mspel8_mc10_c;
+    c->put_mspel_pixels_tab[2] = put_mspel8_mc20_c;
+    c->put_mspel_pixels_tab[3] = put_mspel8_mc30_c;
+    c->put_mspel_pixels_tab[4] = put_mspel8_mc02_c;
+    c->put_mspel_pixels_tab[5] = put_mspel8_mc12_c;
+    c->put_mspel_pixels_tab[6] = put_mspel8_mc22_c;
+    c->put_mspel_pixels_tab[7] = put_mspel8_mc32_c;
 
-#define SET_CMP_FUNC(name) \
-    c->name[0]= name ## 16_c;\
-    c->name[1]= name ## 8x8_c;
+#define SET_CMP_FUNC(name)                      \
+    c->name[0] = name ## 16_c;                  \
+    c->name[1] = name ## 8x8_c;
 
     SET_CMP_FUNC(hadamard8_diff)
-    c->hadamard8_diff[4]= hadamard8_intra16_c;
-    c->hadamard8_diff[5]= hadamard8_intra8x8_c;
+    c->hadamard8_diff[4] = hadamard8_intra16_c;
+    c->hadamard8_diff[5] = hadamard8_intra8x8_c;
     SET_CMP_FUNC(dct_sad)
     SET_CMP_FUNC(dct_max)
 #if CONFIG_GPL
     SET_CMP_FUNC(dct264_sad)
 #endif
-    c->sad[0]= pix_abs16_c;
-    c->sad[1]= pix_abs8_c;
-    c->sse[0]= sse16_c;
-    c->sse[1]= sse8_c;
-    c->sse[2]= sse4_c;
+    c->sad[0] = pix_abs16_c;
+    c->sad[1] = pix_abs8_c;
+    c->sse[0] = sse16_c;
+    c->sse[1] = sse8_c;
+    c->sse[2] = sse4_c;
     SET_CMP_FUNC(quant_psnr)
     SET_CMP_FUNC(rd)
     SET_CMP_FUNC(bit)
-    c->vsad[0]= vsad16_c;
-    c->vsad[4]= vsad_intra16_c;
-    c->vsad[5]= vsad_intra8_c;
-    c->vsse[0]= vsse16_c;
-    c->vsse[4]= vsse_intra16_c;
-    c->vsse[5]= vsse_intra8_c;
-    c->nsse[0]= nsse16_c;
-    c->nsse[1]= nsse8_c;
+    c->vsad[0] = vsad16_c;
+    c->vsad[4] = vsad_intra16_c;
+    c->vsad[5] = vsad_intra8_c;
+    c->vsse[0] = vsse16_c;
+    c->vsse[4] = vsse_intra16_c;
+    c->vsse[5] = vsse_intra8_c;
+    c->nsse[0] = nsse16_c;
+    c->nsse[1] = nsse8_c;
 
     c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
 
-    c->add_bytes= add_bytes_c;
-    c->diff_bytes= diff_bytes_c;
-    c->add_hfyu_median_prediction= add_hfyu_median_prediction_c;
-    c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c;
-    c->add_hfyu_left_prediction  = add_hfyu_left_prediction_c;
+    c->add_bytes                      = add_bytes_c;
+    c->add_hfyu_median_prediction     = add_hfyu_median_prediction_c;
+    c->add_hfyu_left_prediction       = add_hfyu_left_prediction_c;
     c->add_hfyu_left_prediction_bgr32 = add_hfyu_left_prediction_bgr32_c;
-    c->bswap_buf= bswap_buf;
+
+    c->diff_bytes                 = diff_bytes_c;
+    c->sub_hfyu_median_prediction = sub_hfyu_median_prediction_c;
+
+    c->bswap_buf   = bswap_buf;
     c->bswap16_buf = bswap16_buf;
 
-    c->try_8x8basis= try_8x8basis_c;
-    c->add_8x8basis= add_8x8basis_c;
+    c->try_8x8basis = try_8x8basis_c;
+    c->add_8x8basis = add_8x8basis_c;
 
-    c->vector_clipf = vector_clipf_c;
-    c->scalarproduct_int16 = scalarproduct_int16_c;
     c->scalarproduct_and_madd_int16 = scalarproduct_and_madd_int16_c;
-    c->vector_clip_int32 = vector_clip_int32_c;
 
-    c->shrink[0]= av_image_copy_plane;
-    c->shrink[1]= ff_shrink22;
-    c->shrink[2]= ff_shrink44;
-    c->shrink[3]= ff_shrink88;
+    c->scalarproduct_int16 = scalarproduct_int16_c;
+    c->vector_clip_int32   = vector_clip_int32_c;
+    c->vector_clipf        = vector_clipf_c;
+
+    c->shrink[0] = av_image_copy_plane;
+    c->shrink[1] = ff_shrink22;
+    c->shrink[2] = ff_shrink44;
+    c->shrink[3] = ff_shrink88;
 
     c->add_pixels8 = add_pixels8_c;
 
 #undef FUNC
 #undef FUNCC
-#define FUNC(f, depth) f ## _ ## depth
+#define FUNC(f,  depth) f ## _ ## depth
 #define FUNCC(f, depth) f ## _ ## depth ## _c
 
-    c->draw_edges                    = FUNCC(draw_edges, 8);
-    c->clear_block                   = FUNCC(clear_block, 8);
-    c->clear_blocks                  = FUNCC(clear_blocks, 8);
+    c->draw_edges = FUNCC(draw_edges, 8);
+
+    c->clear_block  = FUNCC(clear_block, 8);
+    c->clear_blocks = FUNCC(clear_blocks, 8);
 
-#define BIT_DEPTH_FUNCS(depth) \
-    c->get_pixels                    = FUNCC(get_pixels,   depth);
+#define BIT_DEPTH_FUNCS(depth)                  \
+    c->get_pixels = FUNCC(get_pixels, depth);
 
     switch (avctx->bits_per_raw_sample) {
     case 9:
@@ -2646,17 +2923,12 @@ av_cold void ff_dsputil_init(DSPContext* c, AVCodecContext *avctx)
         break;
     }
 
-
     if (ARCH_ARM)
         ff_dsputil_init_arm(c, avctx);
     if (ARCH_BFIN)
         ff_dsputil_init_bfin(c, avctx);
     if (ARCH_PPC)
         ff_dsputil_init_ppc(c, avctx);
-    if (ARCH_SH4)
-        ff_dsputil_init_sh4(c, avctx);
-    if (HAVE_VIS)
-        ff_dsputil_init_vis(c, avctx);
     if (ARCH_X86)
         ff_dsputil_init_x86(c, avctx);
 
diff --git a/deps/libav/libavcodec/dsputil.h b/deps/libav/libavcodec/dsputil.h
index 7bd92e5..2e258ac 100644
--- a/deps/libav/libavcodec/dsputil.h
+++ b/deps/libav/libavcodec/dsputil.h
@@ -23,14 +23,13 @@
 /**
  * @file
  * DSP utils.
- * note, many functions in here may use MMX which trashes the FPU state, it is
- * absolutely necessary to call emms_c() between dsp & float/double code
+ * Note, many functions in here may use MMX which trashes the FPU state, it is
+ * absolutely necessary to call emms_c() between DSP & float/double code.
  */
 
 #ifndef AVCODEC_DSPUTIL_H
 #define AVCODEC_DSPUTIL_H
 
-#include "libavutil/intreadwrite.h"
 #include "avcodec.h"
 #include "rnd_avg.h"
 
@@ -44,8 +43,8 @@ extern const uint8_t ff_zigzag248_direct[64];
 #define MAX_NEG_CROP 1024
 
 /* temporary */
-extern uint32_t ff_squareTbl[512];
-extern const uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP];
+extern uint32_t ff_square_tab[512];
+extern const uint8_t ff_crop_tab[256 + 2 * MAX_NEG_CROP];
 
 void ff_put_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
 void ff_avg_pixels8x8_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
@@ -59,33 +58,42 @@ void ff_put_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
 void ff_avg_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, ptrdiff_t stride);
 
 void ff_gmc_c(uint8_t *dst, uint8_t *src, int stride, int h, int ox, int oy,
-              int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height);
+              int dxx, int dxy, int dyx, int dyy, int shift, int r,
+              int width, int height);
 
 /* minimum alignment rules ;)
-If you notice errors in the align stuff, need more alignment for some ASM code
-for some CPU or need to use a function with less aligned data then send a mail
-to the libav-devel mailing list, ...
-
-!warning These alignments might not match reality, (missing attribute((align))
-stuff somewhere possible).
-I (Michael) did not check them, these are just the alignments which I think
-could be reached easily ...
-
-!future video codecs might need functions with less strict alignment
-*/
-
-/* add and put pixel (decoding) */
-// blocksizes for op_pixels_func are 8x4,8x8 16x8 16x16
-//h for op_pixels_func is limited to {width/2, width} but never larger than 16 and never smaller than 4
-typedef void (*tpel_mc_func)(uint8_t *block/*align width (8 or 16)*/, const uint8_t *pixels/*align 1*/, int line_size, int w, int h);
-typedef void (*qpel_mc_func)(uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, ptrdiff_t stride);
-
-typedef void (*op_fill_func)(uint8_t *block/*align width (8 or 16)*/, uint8_t value, int line_size, int h);
+ * If you notice errors in the align stuff, need more alignment for some ASM code
+ * for some CPU or need to use a function with less aligned data then send a mail
+ * to the libav-devel mailing list, ...
+ *
+ * !warning These alignments might not match reality, (missing attribute((align))
+ * stuff somewhere possible).
+ * I (Michael) did not check them, these are just the alignments which I think
+ * could be reached easily ...
+ *
+ * !future video codecs might need functions with less strict alignment
+ */
 
-#define DEF_OLD_QPEL(name)\
-void ff_put_        ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, ptrdiff_t stride);\
-void ff_put_no_rnd_ ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, ptrdiff_t stride);\
-void ff_avg_        ## name (uint8_t *dst/*align width (8 or 16)*/, uint8_t *src/*align 1*/, ptrdiff_t stride);
+/* add and put pixel (decoding)
+ * Block sizes for op_pixels_func are 8x4,8x8 16x8 16x16.
+ * h for op_pixels_func is limited to { width / 2, width },
+ * but never larger than 16 and never smaller than 4. */
+typedef void (*tpel_mc_func)(uint8_t *block /* align width (8 or 16) */,
+                             const uint8_t *pixels /* align 1 */,
+                             int line_size, int w, int h);
+typedef void (*qpel_mc_func)(uint8_t *dst /* align width (8 or 16) */,
+                             uint8_t *src /* align 1 */, ptrdiff_t stride);
+
+typedef void (*op_fill_func)(uint8_t *block /* align width (8 or 16) */,
+                             uint8_t value, int line_size, int h);
+
+#define DEF_OLD_QPEL(name)                                                     \
+    void ff_put_        ## name(uint8_t *dst /* align width (8 or 16) */,      \
+                                uint8_t *src /* align 1 */, ptrdiff_t stride); \
+    void ff_put_no_rnd_ ## name(uint8_t *dst /* align width (8 or 16) */,      \
+                                uint8_t *src /* align 1 */, ptrdiff_t stride); \
+    void ff_avg_        ## name(uint8_t *dst /* align width (8 or 16) */,      \
+                                uint8_t *src /* align 1 */, ptrdiff_t stride);
 
 DEF_OLD_QPEL(qpel16_mc11_old_c)
 DEF_OLD_QPEL(qpel16_mc31_old_c)
@@ -100,21 +108,26 @@ DEF_OLD_QPEL(qpel8_mc32_old_c)
 DEF_OLD_QPEL(qpel8_mc13_old_c)
 DEF_OLD_QPEL(qpel8_mc33_old_c)
 
-/* motion estimation */
-// h is limited to {width/2, width, 2*width} but never larger than 16 and never smaller than 2
-// although currently h<4 is not used as functions with width <8 are neither used nor implemented
-typedef int (*me_cmp_func)(void /*MpegEncContext*/ *s, uint8_t *blk1/*align width (8 or 16)*/, uint8_t *blk2/*align 1*/, int line_size, int h)/* __attribute__ ((const))*/;
+/* Motion estimation:
+ * h is limited to { width / 2, width, 2 * width },
+ * but never larger than 16 and never smaller than 2.
+ * Although currently h < 4 is not used as functions with
+ * width < 8 are neither used nor implemented. */
+typedef int (*me_cmp_func)(void /* MpegEncContext */ *s,
+                           uint8_t *blk1 /* align width (8 or 16) */,
+                           uint8_t *blk2 /* align 1 */, int line_size, int h);
 
 /**
  * Scantable.
  */
-typedef struct ScanTable{
+typedef struct ScanTable {
     const uint8_t *scantable;
     uint8_t permutated[64];
     uint8_t raster_end[64];
 } ScanTable;
 
-void ff_init_scantable(uint8_t *, ScanTable *st, const uint8_t *src_scantable);
+void ff_init_scantable(uint8_t *permutation, ScanTable *st,
+                       const uint8_t *src_scantable);
 void ff_init_scantable_permutation(uint8_t *idct_permutation,
                                    int idct_permutation_type);
 
@@ -123,27 +136,40 @@ void ff_init_scantable_permutation(uint8_t *idct_permutation,
  */
 typedef struct DSPContext {
     /* pixel ops : interface with DCT */
-    void (*get_pixels)(int16_t *block/*align 16*/, const uint8_t *pixels/*align 8*/, int line_size);
-    void (*diff_pixels)(int16_t *block/*align 16*/, const uint8_t *s1/*align 8*/, const uint8_t *s2/*align 8*/, int stride);
-    void (*put_pixels_clamped)(const int16_t *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
-    void (*put_signed_pixels_clamped)(const int16_t *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
-    void (*add_pixels_clamped)(const int16_t *block/*align 16*/, uint8_t *pixels/*align 8*/, int line_size);
+    void (*get_pixels)(int16_t *block /* align 16 */,
+                       const uint8_t *pixels /* align 8 */,
+                       int line_size);
+    void (*diff_pixels)(int16_t *block /* align 16 */,
+                        const uint8_t *s1 /* align 8 */,
+                        const uint8_t *s2 /* align 8 */,
+                        int stride);
+    void (*put_pixels_clamped)(const int16_t *block /* align 16 */,
+                               uint8_t *pixels /* align 8 */,
+                               int line_size);
+    void (*put_signed_pixels_clamped)(const int16_t *block /* align 16 */,
+                                      uint8_t *pixels /* align 8 */,
+                                      int line_size);
+    void (*add_pixels_clamped)(const int16_t *block /* align 16 */,
+                               uint8_t *pixels /* align 8 */,
+                               int line_size);
     void (*add_pixels8)(uint8_t *pixels, int16_t *block, int line_size);
-    int (*sum_abs_dctelem)(int16_t *block/*align 16*/);
+    int (*sum_abs_dctelem)(int16_t *block /* align 16 */);
     /**
      * translational global motion compensation.
      */
-    void (*gmc1)(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int srcStride, int h, int x16, int y16, int rounder);
+    void (*gmc1)(uint8_t *dst /* align 8 */, uint8_t *src /* align 1 */,
+                 int srcStride, int h, int x16, int y16, int rounder);
     /**
      * global motion compensation.
      */
-    void (*gmc )(uint8_t *dst/*align 8*/, uint8_t *src/*align 1*/, int stride, int h, int ox, int oy,
-                    int dxx, int dxy, int dyx, int dyy, int shift, int r, int width, int height);
-    void (*clear_block)(int16_t *block/*align 16*/);
-    void (*clear_blocks)(int16_t *blocks/*align 16*/);
-    int (*pix_sum)(uint8_t * pix, int line_size);
-    int (*pix_norm1)(uint8_t * pix, int line_size);
-// 16x16 8x8 4x4 2x2 16x8 8x4 4x2 8x16 4x8 2x4
+    void (*gmc)(uint8_t *dst /* align 8 */, uint8_t *src /* align 1 */,
+                int stride, int h, int ox, int oy,
+                int dxx, int dxy, int dyx, int dyy,
+                int shift, int r, int width, int height);
+    void (*clear_block)(int16_t *block /* align 16 */);
+    void (*clear_blocks)(int16_t *blocks /* align 16 */);
+    int (*pix_sum)(uint8_t *pix, int line_size);
+    int (*pix_norm1)(uint8_t *pix, int line_size);
 
     me_cmp_func sad[6]; /* identical to pix_absAxA except additional void * */
     me_cmp_func sse[6];
@@ -162,24 +188,24 @@ typedef struct DSPContext {
     me_cmp_func me_cmp[6];
     me_cmp_func me_sub_cmp[6];
     me_cmp_func mb_cmp[6];
-    me_cmp_func ildct_cmp[6]; //only width 16 used
-    me_cmp_func frame_skip_cmp[6]; //only width 8 used
+    me_cmp_func ildct_cmp[6]; // only width 16 used
+    me_cmp_func frame_skip_cmp[6]; // only width 8 used
 
     int (*ssd_int8_vs_int16)(const int8_t *pix1, const int16_t *pix2,
                              int size);
 
     /**
-     * Thirdpel motion compensation with rounding (a+b+1)>>1.
-     * this is an array[12] of motion compensation functions for the 9 thirdpe
-     * positions<br>
-     * *pixels_tab[ xthirdpel + 4*ythirdpel ]
+     * Thirdpel motion compensation with rounding (a + b + 1) >> 1.
+     * this is an array[12] of motion compensation functions for the
+     * 9 thirdpel positions<br>
+     * *pixels_tab[xthirdpel + 4 * ythirdpel]
      * @param block destination where the result is stored
      * @param pixels source
      * @param line_size number of bytes in a horizontal line of block
      * @param h height
      */
-    tpel_mc_func put_tpel_pixels_tab[11]; //FIXME individual func ptr per width?
-    tpel_mc_func avg_tpel_pixels_tab[11]; //FIXME individual func ptr per width?
+    tpel_mc_func put_tpel_pixels_tab[11]; // FIXME individual func ptr per width?
+    tpel_mc_func avg_tpel_pixels_tab[11]; // FIXME individual func ptr per width?
 
     qpel_mc_func put_qpel_pixels_tab[2][16];
     qpel_mc_func avg_qpel_pixels_tab[2][16];
@@ -188,54 +214,72 @@ typedef struct DSPContext {
 
     me_cmp_func pix_abs[2][4];
 
-    /* huffyuv specific */
-    void (*add_bytes)(uint8_t *dst/*align 16*/, uint8_t *src/*align 16*/, int w);
-    void (*diff_bytes)(uint8_t *dst/*align 16*/, uint8_t *src1/*align 16*/, uint8_t *src2/*align 1*/,int w);
+    /* HuffYUV specific */
+    void (*add_bytes)(uint8_t *dst /* align 16 */,
+                      uint8_t *src /* align 16 */,
+                      int w);
+    void (*diff_bytes)(uint8_t *dst /* align 16 */,
+                       uint8_t *src1 /* align 16 */,
+                       uint8_t *src2 /* align 1 */,
+                       int w);
     /**
-     * subtract huffyuv's variant of median prediction
-     * note, this might read from src1[-1], src2[-1]
+     * Subtract HuffYUV's variant of median prediction.
+     * Note, this might read from src1[-1], src2[-1].
      */
-    void (*sub_hfyu_median_prediction)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int w, int *left, int *left_top);
-    void (*add_hfyu_median_prediction)(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top);
-    int  (*add_hfyu_left_prediction)(uint8_t *dst, const uint8_t *src, int w, int left);
-    void (*add_hfyu_left_prediction_bgr32)(uint8_t *dst, const uint8_t *src, int w, int *red, int *green, int *blue, int *alpha);
+    void (*sub_hfyu_median_prediction)(uint8_t *dst, const uint8_t *src1,
+                                       const uint8_t *src2, int w,
+                                       int *left, int *left_top);
+    void (*add_hfyu_median_prediction)(uint8_t *dst, const uint8_t *top,
+                                       const uint8_t *diff, int w,
+                                       int *left, int *left_top);
+    int (*add_hfyu_left_prediction)(uint8_t *dst, const uint8_t *src,
+                                    int w, int left);
+    void (*add_hfyu_left_prediction_bgr32)(uint8_t *dst, const uint8_t *src,
+                                           int w, int *red, int *green,
+                                           int *blue, int *alpha);
     void (*bswap_buf)(uint32_t *dst, const uint32_t *src, int w);
     void (*bswap16_buf)(uint16_t *dst, const uint16_t *src, int len);
 
     /* assume len is a multiple of 8, and arrays are 16-byte aligned */
-    void (*vector_clipf)(float *dst /* align 16 */, const float *src /* align 16 */, float min, float max, int len /* align 16 */);
+    void (*vector_clipf)(float *dst /* align 16 */,
+                         const float *src /* align 16 */,
+                         float min, float max, int len /* align 16 */);
 
     /* (I)DCT */
-    void (*fdct)(int16_t *block/* align 16*/);
-    void (*fdct248)(int16_t *block/* align 16*/);
+    void (*fdct)(int16_t *block /* align 16 */);
+    void (*fdct248)(int16_t *block /* align 16 */);
 
-    /* IDCT really*/
-    void (*idct)(int16_t *block/* align 16*/);
+    /* IDCT really */
+    void (*idct)(int16_t *block /* align 16 */);
 
     /**
      * block -> idct -> clip to unsigned 8 bit -> dest.
      * (-1392, 0, 0, ...) -> idct -> (-174, -174, ...) -> put -> (0, 0, ...)
      * @param line_size size in bytes of a horizontal line of dest
      */
-    void (*idct_put)(uint8_t *dest/*align 8*/, int line_size, int16_t *block/*align 16*/);
+    void (*idct_put)(uint8_t *dest /* align 8 */,
+                     int line_size, int16_t *block /* align 16 */);
 
     /**
      * block -> idct -> add dest -> clip to unsigned 8 bit -> dest.
      * @param line_size size in bytes of a horizontal line of dest
      */
-    void (*idct_add)(uint8_t *dest/*align 8*/, int line_size, int16_t *block/*align 16*/);
+    void (*idct_add)(uint8_t *dest /* align 8 */,
+                     int line_size, int16_t *block /* align 16 */);
 
     /**
-     * idct input permutation.
-     * several optimized IDCTs need a permutated input (relative to the normal order of the reference
-     * IDCT)
-     * this permutation must be performed before the idct_put/add, note, normally this can be merged
-     * with the zigzag/alternate scan<br>
-     * an example to avoid confusion:
-     * - (->decode coeffs -> zigzag reorder -> dequant -> reference idct ->...)
-     * - (x -> reference dct -> reference idct -> x)
-     * - (x -> reference dct -> simple_mmx_perm = idct_permutation -> simple_idct_mmx -> x)
-     * - (->decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant -> simple_idct_mmx ->...)
+     * IDCT input permutation.
+     * Several optimized IDCTs need a permutated input (relative to the
+     * normal order of the reference IDCT).
+     * This permutation must be performed before the idct_put/add.
+     * Note, normally this can be merged with the zigzag/alternate scan<br>
+     * An example to avoid confusion:
+     * - (->decode coeffs -> zigzag reorder -> dequant -> reference IDCT -> ...)
+     * - (x -> reference DCT -> reference IDCT -> x)
+     * - (x -> reference DCT -> simple_mmx_perm = idct_permutation
+     *    -> simple_idct_mmx -> x)
+     * - (-> decode coeffs -> zigzag reorder -> simple_mmx_perm -> dequant
+     *    -> simple_idct_mmx -> ...)
      */
     uint8_t idct_permutation[64];
     int idct_permutation_type;
@@ -246,33 +290,41 @@ typedef struct DSPContext {
 #define FF_PARTTRANS_IDCT_PERM 5
 #define FF_SSE2_IDCT_PERM 6
 
-    int (*try_8x8basis)(int16_t rem[64], int16_t weight[64], int16_t basis[64], int scale);
+    int (*try_8x8basis)(int16_t rem[64], int16_t weight[64],
+                        int16_t basis[64], int scale);
     void (*add_8x8basis)(int16_t rem[64], int16_t basis[64], int scale);
 #define BASIS_SHIFT 16
 #define RECON_SHIFT 6
 
-    void (*draw_edges)(uint8_t *buf, int wrap, int width, int height, int w, int h, int sides);
+    void (*draw_edges)(uint8_t *buf, int wrap, int width, int height,
+                       int w, int h, int sides);
 #define EDGE_WIDTH 16
 #define EDGE_TOP    1
 #define EDGE_BOTTOM 2
 
-    void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src, int src_wrap, int width, int height);
+    void (*shrink[4])(uint8_t *dst, int dst_wrap, const uint8_t *src,
+                      int src_wrap, int width, int height);
 
     /**
      * Calculate scalar product of two vectors.
      * @param len length of vectors, should be multiple of 16
      */
-    int32_t (*scalarproduct_int16)(const int16_t *v1, const int16_t *v2/*align 16*/, int len);
+    int32_t (*scalarproduct_int16)(const int16_t *v1,
+                                   const int16_t *v2 /* align 16 */, int len);
     /* ape functions */
     /**
      * Calculate scalar product of v1 and v2,
      * and v1[i] += v3[i] * mul
      * @param len length of vectors, should be multiple of 16
      */
-    int32_t (*scalarproduct_and_madd_int16)(int16_t *v1/*align 16*/, const int16_t *v2, const int16_t *v3, int len, int mul);
+    int32_t (*scalarproduct_and_madd_int16)(int16_t *v1 /* align 16 */,
+                                            const int16_t *v2,
+                                            const int16_t *v3,
+                                            int len, int mul);
 
     /**
-     * Clip each element in an array of int32_t to a given minimum and maximum value.
+     * Clip each element in an array of int32_t to a given minimum and
+     * maximum value.
      * @param dst  destination array
      *             constraints: 16-byte aligned
      * @param src  source array
@@ -291,17 +343,13 @@ typedef struct DSPContext {
 } DSPContext;
 
 void ff_dsputil_static_init(void);
-void ff_dsputil_init(DSPContext* p, AVCodecContext *avctx);
-
-int ff_check_alignment(void);
+void ff_dsputil_init(DSPContext *p, AVCodecContext *avctx);
 
-void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type);
+void ff_set_cmp(DSPContext *c, me_cmp_func *cmp, int type);
 
-void ff_dsputil_init_arm(DSPContext* c, AVCodecContext *avctx);
-void ff_dsputil_init_bfin(DSPContext* c, AVCodecContext *avctx);
-void ff_dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx);
-void ff_dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx);
-void ff_dsputil_init_vis(DSPContext* c, AVCodecContext *avctx);
-void ff_dsputil_init_x86(DSPContext* c, AVCodecContext *avctx);
+void ff_dsputil_init_arm(DSPContext *c, AVCodecContext *avctx);
+void ff_dsputil_init_bfin(DSPContext *c, AVCodecContext *avctx);
+void ff_dsputil_init_ppc(DSPContext *c, AVCodecContext *avctx);
+void ff_dsputil_init_x86(DSPContext *c, AVCodecContext *avctx);
 
 #endif /* AVCODEC_DSPUTIL_H */
diff --git a/deps/libav/libavcodec/dsputil_template.c b/deps/libav/libavcodec/dsputil_template.c
index 3a6d27f..f6e03ec 100644
--- a/deps/libav/libavcodec/dsputil_template.c
+++ b/deps/libav/libavcodec/dsputil_template.c
@@ -31,19 +31,19 @@
 
 #if BIT_DEPTH == 8
 /* draw the edges of width 'w' of an image of size width, height */
-//FIXME check that this is ok for mpeg4 interlaced
-static void FUNCC(draw_edges)(uint8_t *_buf, int _wrap, int width, int height, int w, int h, int sides)
+// FIXME: Check that this is OK for MPEG-4 interlaced.
+static void FUNCC(draw_edges)(uint8_t *_buf, int _wrap, int width, int height,
+                              int w, int h, int sides)
 {
-    pixel *buf = (pixel*)_buf;
-    int wrap = _wrap / sizeof(pixel);
-    pixel *ptr, *last_line;
+    pixel *buf = (pixel *) _buf;
+    int wrap   = _wrap / sizeof(pixel);
+    pixel *ptr = buf, *last_line;
     int i;
 
     /* left and right */
-    ptr = buf;
-    for(i=0;i<height;i++) {
+    for (i = 0; i < height; i++) {
         memset(ptr - w, ptr[0], w);
-        memset(ptr + width, ptr[width-1], w);
+        memset(ptr + width, ptr[width - 1], w);
         ptr += wrap;
     }
 
@@ -51,23 +51,25 @@ static void FUNCC(draw_edges)(uint8_t *_buf, int _wrap, int width, int height, i
     buf -= w;
     last_line = buf + (height - 1) * wrap;
     if (sides & EDGE_TOP)
-        for(i = 0; i < h; i++)
-            memcpy(buf - (i + 1) * wrap, buf, (width + w + w) * sizeof(pixel)); // top
+        for (i = 0; i < h; i++)
+            // top
+            memcpy(buf - (i + 1) * wrap, buf, (width + w + w) * sizeof(pixel));
     if (sides & EDGE_BOTTOM)
         for (i = 0; i < h; i++)
-            memcpy(last_line + (i + 1) * wrap, last_line, (width + w + w) * sizeof(pixel)); // bottom
+            // bottom
+            memcpy(last_line + (i + 1) * wrap, last_line,
+                   (width + w + w) * sizeof(pixel));
 }
 #endif
 
-static void FUNCC(get_pixels)(int16_t *restrict block,
-                              const uint8_t *_pixels,
+static void FUNCC(get_pixels)(int16_t *restrict block, const uint8_t *_pixels,
                               int line_size)
 {
     const pixel *pixels = (const pixel *) _pixels;
     int i;
 
     /* read the pixels */
-    for(i=0;i<8;i++) {
+    for (i = 0; i < 8; i++) {
         block[0] = pixels[0];
         block[1] = pixels[1];
         block[2] = pixels[2];
@@ -76,20 +78,20 @@ static void FUNCC(get_pixels)(int16_t *restrict block,
         block[5] = pixels[5];
         block[6] = pixels[6];
         block[7] = pixels[7];
-        pixels += line_size / sizeof(pixel);
-        block += 8;
+        pixels  += line_size / sizeof(pixel);
+        block   += 8;
     }
 }
 
 #if BIT_DEPTH == 8
 static void FUNCC(clear_block)(int16_t *block)
 {
-    memset(block, 0, sizeof(int16_t)*64);
+    memset(block, 0, sizeof(int16_t) * 64);
 }
 
 static void FUNCC(clear_blocks)(int16_t *blocks)
 {
-    memset(blocks, 0, sizeof(int16_t)*6*64);
+    memset(blocks, 0, sizeof(int16_t) * 6 * 64);
 }
 #endif
 
@@ -97,154 +99,244 @@ static void FUNCC(clear_blocks)(int16_t *blocks)
 #include "hpel_template.c"
 #endif
 
-#define PIXOP2(OPNAME, OP) \
-static inline void FUNC(OPNAME ## _no_rnd_pixels8_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
-                                                int src_stride1, int src_stride2, int h){\
-    int i;\
-    for(i=0; i<h; i++){\
-        pixel4 a,b;\
-        a= AV_RN4P(&src1[i*src_stride1  ]);\
-        b= AV_RN4P(&src2[i*src_stride2  ]);\
-        OP(*((pixel4*)&dst[i*dst_stride  ]), no_rnd_avg_pixel4(a, b));\
-        a= AV_RN4P(&src1[i*src_stride1+4*sizeof(pixel)]);\
-        b= AV_RN4P(&src2[i*src_stride2+4*sizeof(pixel)]);\
-        OP(*((pixel4*)&dst[i*dst_stride+4*sizeof(pixel)]), no_rnd_avg_pixel4(a, b));\
-    }\
-}\
-\
-static inline void FUNC(OPNAME ## _no_rnd_pixels16_l2)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, int dst_stride, \
-                                                int src_stride1, int src_stride2, int h){\
-    FUNC(OPNAME ## _no_rnd_pixels8_l2)(dst  , src1  , src2  , dst_stride, src_stride1, src_stride2, h);\
-    FUNC(OPNAME ## _no_rnd_pixels8_l2)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, h);\
-}\
-\
-static inline void FUNC(OPNAME ## _pixels8_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
-                 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
-    /* FIXME HIGH BIT DEPTH */\
-    int i;\
-    for(i=0; i<h; i++){\
-        uint32_t a, b, c, d, l0, l1, h0, h1;\
-        a= AV_RN32(&src1[i*src_stride1]);\
-        b= AV_RN32(&src2[i*src_stride2]);\
-        c= AV_RN32(&src3[i*src_stride3]);\
-        d= AV_RN32(&src4[i*src_stride4]);\
-        l0=  (a&0x03030303UL)\
-           + (b&0x03030303UL)\
-           + 0x02020202UL;\
-        h0= ((a&0xFCFCFCFCUL)>>2)\
-          + ((b&0xFCFCFCFCUL)>>2);\
-        l1=  (c&0x03030303UL)\
-           + (d&0x03030303UL);\
-        h1= ((c&0xFCFCFCFCUL)>>2)\
-          + ((d&0xFCFCFCFCUL)>>2);\
-        OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
-        a= AV_RN32(&src1[i*src_stride1+4]);\
-        b= AV_RN32(&src2[i*src_stride2+4]);\
-        c= AV_RN32(&src3[i*src_stride3+4]);\
-        d= AV_RN32(&src4[i*src_stride4+4]);\
-        l0=  (a&0x03030303UL)\
-           + (b&0x03030303UL)\
-           + 0x02020202UL;\
-        h0= ((a&0xFCFCFCFCUL)>>2)\
-          + ((b&0xFCFCFCFCUL)>>2);\
-        l1=  (c&0x03030303UL)\
-           + (d&0x03030303UL);\
-        h1= ((c&0xFCFCFCFCUL)>>2)\
-          + ((d&0xFCFCFCFCUL)>>2);\
-        OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
-    }\
-}\
-\
-static inline void FUNC(OPNAME ## _no_rnd_pixels8_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
-                 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
-    /* FIXME HIGH BIT DEPTH*/\
-    int i;\
-    for(i=0; i<h; i++){\
-        uint32_t a, b, c, d, l0, l1, h0, h1;\
-        a= AV_RN32(&src1[i*src_stride1]);\
-        b= AV_RN32(&src2[i*src_stride2]);\
-        c= AV_RN32(&src3[i*src_stride3]);\
-        d= AV_RN32(&src4[i*src_stride4]);\
-        l0=  (a&0x03030303UL)\
-           + (b&0x03030303UL)\
-           + 0x01010101UL;\
-        h0= ((a&0xFCFCFCFCUL)>>2)\
-          + ((b&0xFCFCFCFCUL)>>2);\
-        l1=  (c&0x03030303UL)\
-           + (d&0x03030303UL);\
-        h1= ((c&0xFCFCFCFCUL)>>2)\
-          + ((d&0xFCFCFCFCUL)>>2);\
-        OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
-        a= AV_RN32(&src1[i*src_stride1+4]);\
-        b= AV_RN32(&src2[i*src_stride2+4]);\
-        c= AV_RN32(&src3[i*src_stride3+4]);\
-        d= AV_RN32(&src4[i*src_stride4+4]);\
-        l0=  (a&0x03030303UL)\
-           + (b&0x03030303UL)\
-           + 0x01010101UL;\
-        h0= ((a&0xFCFCFCFCUL)>>2)\
-          + ((b&0xFCFCFCFCUL)>>2);\
-        l1=  (c&0x03030303UL)\
-           + (d&0x03030303UL);\
-        h1= ((c&0xFCFCFCFCUL)>>2)\
-          + ((d&0xFCFCFCFCUL)>>2);\
-        OP(*((uint32_t*)&dst[i*dst_stride+4]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
-    }\
-}\
-static inline void FUNC(OPNAME ## _pixels16_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
-                 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
-    FUNC(OPNAME ## _pixels8_l4)(dst  , src1  , src2  , src3  , src4  , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
-    FUNC(OPNAME ## _pixels8_l4)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), src3+8*sizeof(pixel), src4+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
-}\
-static inline void FUNC(OPNAME ## _no_rnd_pixels16_l4)(uint8_t *dst, const uint8_t *src1, const uint8_t *src2, const uint8_t *src3, const uint8_t *src4,\
-                 int dst_stride, int src_stride1, int src_stride2,int src_stride3,int src_stride4, int h){\
-    FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst  , src1  , src2  , src3  , src4  , dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
-    FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst+8*sizeof(pixel), src1+8*sizeof(pixel), src2+8*sizeof(pixel), src3+8*sizeof(pixel), src4+8*sizeof(pixel), dst_stride, src_stride1, src_stride2, src_stride3, src_stride4, h);\
-}\
-\
-static inline void FUNCC(OPNAME ## _pixels8_xy2)(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)\
-{\
-    /* FIXME HIGH BIT DEPTH */\
-    int j;\
-    for(j=0; j<2; j++){\
-        int i;\
-        const uint32_t a= AV_RN32(pixels  );\
-        const uint32_t b= AV_RN32(pixels+1);\
-        uint32_t l0=  (a&0x03030303UL)\
-                    + (b&0x03030303UL)\
-                    + 0x02020202UL;\
-        uint32_t h0= ((a&0xFCFCFCFCUL)>>2)\
-                   + ((b&0xFCFCFCFCUL)>>2);\
-        uint32_t l1,h1;\
-\
-        pixels+=line_size;\
-        for(i=0; i<h; i+=2){\
-            uint32_t a= AV_RN32(pixels  );\
-            uint32_t b= AV_RN32(pixels+1);\
-            l1=  (a&0x03030303UL)\
-               + (b&0x03030303UL);\
-            h1= ((a&0xFCFCFCFCUL)>>2)\
-              + ((b&0xFCFCFCFCUL)>>2);\
-            OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
-            pixels+=line_size;\
-            block +=line_size;\
-            a= AV_RN32(pixels  );\
-            b= AV_RN32(pixels+1);\
-            l0=  (a&0x03030303UL)\
-               + (b&0x03030303UL)\
-               + 0x02020202UL;\
-            h0= ((a&0xFCFCFCFCUL)>>2)\
-              + ((b&0xFCFCFCFCUL)>>2);\
-            OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
-            pixels+=line_size;\
-            block +=line_size;\
-        }\
-        pixels+=4-line_size*(h+1);\
-        block +=4-line_size*h;\
-    }\
-}\
-\
-CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_xy2), FUNCC(OPNAME ## _pixels8_xy2), 8*sizeof(pixel))\
+#define PIXOP2(OPNAME, OP)                                              \
+static inline void FUNC(OPNAME ## _no_rnd_pixels8_l2)(uint8_t *dst,     \
+                                                      const uint8_t *src1, \
+                                                      const uint8_t *src2, \
+                                                      int dst_stride,   \
+                                                      int src_stride1,  \
+                                                      int src_stride2,  \
+                                                      int h)            \
+{                                                                       \
+    int i;                                                              \
+                                                                        \
+    for (i = 0; i < h; i++) {                                           \
+        pixel4 a, b;                                                    \
+        a = AV_RN4P(&src1[i * src_stride1]);                            \
+        b = AV_RN4P(&src2[i * src_stride2]);                            \
+        OP(*((pixel4 *) &dst[i * dst_stride]),                          \
+           no_rnd_avg_pixel4(a, b));                                    \
+        a = AV_RN4P(&src1[i * src_stride1 + 4 * sizeof(pixel)]);        \
+        b = AV_RN4P(&src2[i * src_stride2 + 4 * sizeof(pixel)]);        \
+        OP(*((pixel4 *) &dst[i * dst_stride + 4 * sizeof(pixel)]),      \
+           no_rnd_avg_pixel4(a, b));                                    \
+    }                                                                   \
+}                                                                       \
+                                                                        \
+static inline void FUNC(OPNAME ## _no_rnd_pixels16_l2)(uint8_t *dst,    \
+                                                       const uint8_t *src1, \
+                                                       const uint8_t *src2, \
+                                                       int dst_stride,  \
+                                                       int src_stride1, \
+                                                       int src_stride2, \
+                                                       int h)           \
+{                                                                       \
+    FUNC(OPNAME ## _no_rnd_pixels8_l2)(dst, src1, src2, dst_stride,     \
+                                       src_stride1, src_stride2, h);    \
+    FUNC(OPNAME ## _no_rnd_pixels8_l2)(dst  + 8 * sizeof(pixel),        \
+                                       src1 + 8 * sizeof(pixel),        \
+                                       src2 + 8 * sizeof(pixel),        \
+                                       dst_stride, src_stride1,         \
+                                       src_stride2, h);                 \
+}                                                                       \
+                                                                        \
+static inline void FUNC(OPNAME ## _pixels8_l4)(uint8_t *dst,            \
+                                               const uint8_t *src1,     \
+                                               const uint8_t *src2,     \
+                                               const uint8_t *src3,     \
+                                               const uint8_t *src4,     \
+                                               int dst_stride,          \
+                                               int src_stride1,         \
+                                               int src_stride2,         \
+                                               int src_stride3,         \
+                                               int src_stride4,         \
+                                               int h)                   \
+{                                                                       \
+    /* FIXME HIGH BIT DEPTH */                                          \
+    int i;                                                              \
+                                                                        \
+    for (i = 0; i < h; i++) {                                           \
+        uint32_t a, b, c, d, l0, l1, h0, h1;                            \
+        a  = AV_RN32(&src1[i * src_stride1]);                           \
+        b  = AV_RN32(&src2[i * src_stride2]);                           \
+        c  = AV_RN32(&src3[i * src_stride3]);                           \
+        d  = AV_RN32(&src4[i * src_stride4]);                           \
+        l0 = (a & 0x03030303UL) +                                       \
+             (b & 0x03030303UL) +                                       \
+                  0x02020202UL;                                         \
+        h0 = ((a & 0xFCFCFCFCUL) >> 2) +                                \
+             ((b & 0xFCFCFCFCUL) >> 2);                                 \
+        l1 = (c & 0x03030303UL) +                                       \
+             (d & 0x03030303UL);                                        \
+        h1 = ((c & 0xFCFCFCFCUL) >> 2) +                                \
+             ((d & 0xFCFCFCFCUL) >> 2);                                 \
+        OP(*((uint32_t *) &dst[i * dst_stride]),                        \
+           h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL));                \
+        a  = AV_RN32(&src1[i * src_stride1 + 4]);                       \
+        b  = AV_RN32(&src2[i * src_stride2 + 4]);                       \
+        c  = AV_RN32(&src3[i * src_stride3 + 4]);                       \
+        d  = AV_RN32(&src4[i * src_stride4 + 4]);                       \
+        l0 = (a & 0x03030303UL) +                                       \
+             (b & 0x03030303UL) +                                       \
+                  0x02020202UL;                                         \
+        h0 = ((a & 0xFCFCFCFCUL) >> 2) +                                \
+             ((b & 0xFCFCFCFCUL) >> 2);                                 \
+        l1 = (c & 0x03030303UL) +                                       \
+             (d & 0x03030303UL);                                        \
+        h1 = ((c & 0xFCFCFCFCUL) >> 2) +                                \
+             ((d & 0xFCFCFCFCUL) >> 2);                                 \
+        OP(*((uint32_t *) &dst[i * dst_stride + 4]),                    \
+           h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL));                \
+    }                                                                   \
+}                                                                       \
+                                                                        \
+static inline void FUNC(OPNAME ## _no_rnd_pixels8_l4)(uint8_t *dst,     \
+                                                      const uint8_t *src1, \
+                                                      const uint8_t *src2, \
+                                                      const uint8_t *src3, \
+                                                      const uint8_t *src4, \
+                                                      int dst_stride,   \
+                                                      int src_stride1,  \
+                                                      int src_stride2,  \
+                                                      int src_stride3,  \
+                                                      int src_stride4,  \
+                                                      int h)            \
+{                                                                       \
+    /* FIXME HIGH BIT DEPTH */                                          \
+    int i;                                                              \
+                                                                        \
+    for (i = 0; i < h; i++) {                                           \
+        uint32_t a, b, c, d, l0, l1, h0, h1;                            \
+        a  = AV_RN32(&src1[i * src_stride1]);                           \
+        b  = AV_RN32(&src2[i * src_stride2]);                           \
+        c  = AV_RN32(&src3[i * src_stride3]);                           \
+        d  = AV_RN32(&src4[i * src_stride4]);                           \
+        l0 = (a & 0x03030303UL) +                                       \
+             (b & 0x03030303UL) +                                       \
+                  0x01010101UL;                                         \
+        h0 = ((a & 0xFCFCFCFCUL) >> 2) +                                \
+             ((b & 0xFCFCFCFCUL) >> 2);                                 \
+        l1 = (c & 0x03030303UL) +                                       \
+             (d & 0x03030303UL);                                        \
+        h1 = ((c & 0xFCFCFCFCUL) >> 2) +                                \
+             ((d & 0xFCFCFCFCUL) >> 2);                                 \
+        OP(*((uint32_t *) &dst[i * dst_stride]),                        \
+           h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL));                \
+        a  = AV_RN32(&src1[i * src_stride1 + 4]);                       \
+        b  = AV_RN32(&src2[i * src_stride2 + 4]);                       \
+        c  = AV_RN32(&src3[i * src_stride3 + 4]);                       \
+        d  = AV_RN32(&src4[i * src_stride4 + 4]);                       \
+        l0 = (a & 0x03030303UL) +                                       \
+             (b & 0x03030303UL) +                                       \
+                  0x01010101UL;                                         \
+        h0 = ((a & 0xFCFCFCFCUL) >> 2) +                                \
+             ((b & 0xFCFCFCFCUL) >> 2);                                 \
+        l1 = (c & 0x03030303UL) +                                       \
+             (d & 0x03030303UL);                                        \
+        h1 = ((c & 0xFCFCFCFCUL) >> 2) +                                \
+             ((d & 0xFCFCFCFCUL) >> 2);                                 \
+        OP(*((uint32_t *) &dst[i * dst_stride + 4]),                    \
+           h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL));                \
+    }                                                                   \
+}                                                                       \
+static inline void FUNC(OPNAME ## _pixels16_l4)(uint8_t *dst,           \
+                                                const uint8_t *src1,    \
+                                                const uint8_t *src2,    \
+                                                const uint8_t *src3,    \
+                                                const uint8_t *src4,    \
+                                                int dst_stride,         \
+                                                int src_stride1,        \
+                                                int src_stride2,        \
+                                                int src_stride3,        \
+                                                int src_stride4,        \
+                                                int h)                  \
+{                                                                       \
+    FUNC(OPNAME ## _pixels8_l4)(dst, src1, src2, src3, src4, dst_stride, \
+                                src_stride1, src_stride2, src_stride3,  \
+                                src_stride4, h);                        \
+    FUNC(OPNAME ## _pixels8_l4)(dst  + 8 * sizeof(pixel),               \
+                                src1 + 8 * sizeof(pixel),               \
+                                src2 + 8 * sizeof(pixel),               \
+                                src3 + 8 * sizeof(pixel),               \
+                                src4 + 8 * sizeof(pixel),               \
+                                dst_stride, src_stride1, src_stride2,   \
+                                src_stride3, src_stride4, h);           \
+}                                                                       \
+static inline void FUNC(OPNAME ## _no_rnd_pixels16_l4)(uint8_t *dst,    \
+                                                       const uint8_t *src1, \
+                                                       const uint8_t *src2, \
+                                                       const uint8_t *src3, \
+                                                       const uint8_t *src4, \
+                                                       int dst_stride,  \
+                                                       int src_stride1, \
+                                                       int src_stride2, \
+                                                       int src_stride3, \
+                                                       int src_stride4, \
+                                                       int h)           \
+{                                                                       \
+    FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst, src1, src2, src3, src4,     \
+                                       dst_stride, src_stride1, src_stride2, \
+                                       src_stride3, src_stride4, h);    \
+    FUNC(OPNAME ## _no_rnd_pixels8_l4)(dst  + 8 * sizeof(pixel),        \
+                                       src1 + 8 * sizeof(pixel),        \
+                                       src2 + 8 * sizeof(pixel),        \
+                                       src3 + 8 * sizeof(pixel),        \
+                                       src4 + 8 * sizeof(pixel),        \
+                                       dst_stride, src_stride1, src_stride2, \
+                                       src_stride3, src_stride4, h);    \
+}                                                                       \
+                                                                        \
+static inline void FUNCC(OPNAME ## _pixels8_xy2)(uint8_t *block,        \
+                                                 const uint8_t *pixels, \
+                                                 ptrdiff_t line_size,   \
+                                                 int h)                 \
+{                                                                       \
+    /* FIXME HIGH BIT DEPTH */                                          \
+    int j;                                                              \
+                                                                        \
+    for (j = 0; j < 2; j++) {                                           \
+        int i;                                                          \
+        const uint32_t a = AV_RN32(pixels);                             \
+        const uint32_t b = AV_RN32(pixels + 1);                         \
+        uint32_t l0 = (a & 0x03030303UL) +                              \
+                      (b & 0x03030303UL) +                              \
+                           0x02020202UL;                                \
+        uint32_t h0 = ((a & 0xFCFCFCFCUL) >> 2) +                       \
+                      ((b & 0xFCFCFCFCUL) >> 2);                        \
+        uint32_t l1, h1;                                                \
+                                                                        \
+        pixels += line_size;                                            \
+        for (i = 0; i < h; i += 2) {                                    \
+            uint32_t a = AV_RN32(pixels);                               \
+            uint32_t b = AV_RN32(pixels + 1);                           \
+            l1 = (a & 0x03030303UL) +                                   \
+                 (b & 0x03030303UL);                                    \
+            h1 = ((a & 0xFCFCFCFCUL) >> 2) +                            \
+                 ((b & 0xFCFCFCFCUL) >> 2);                             \
+            OP(*((uint32_t *) block),                                   \
+               h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL));            \
+            pixels += line_size;                                        \
+            block  += line_size;                                        \
+            a = AV_RN32(pixels);                                        \
+            b = AV_RN32(pixels + 1);                                    \
+            l0 = (a & 0x03030303UL) +                                   \
+                 (b & 0x03030303UL) +                                   \
+                      0x02020202UL;                                     \
+            h0 = ((a & 0xFCFCFCFCUL) >> 2) +                            \
+                 ((b & 0xFCFCFCFCUL) >> 2);                             \
+            OP(*((uint32_t *) block),                                   \
+               h0 + h1 + (((l0 + l1) >> 2) & 0x0F0F0F0FUL));            \
+            pixels += line_size;                                        \
+            block  += line_size;                                        \
+        }                                                               \
+        pixels += 4 - line_size * (h + 1);                              \
+        block  += 4 - line_size * h;                                    \
+    }                                                                   \
+}                                                                       \
+                                                                        \
+CALL_2X_PIXELS(FUNCC(OPNAME ## _pixels16_xy2),                          \
+               FUNCC(OPNAME ## _pixels8_xy2),                           \
+               8 * sizeof(pixel))                                       \
 
 #define op_avg(a, b) a = rnd_avg_pixel4(a, b)
 #define op_put(a, b) a = b
diff --git a/deps/libav/libavcodec/dvbsubdec.c b/deps/libav/libavcodec/dvbsubdec.c
index 6ce187f..4782022 100644
--- a/deps/libav/libavcodec/dvbsubdec.c
+++ b/deps/libav/libavcodec/dvbsubdec.c
@@ -31,7 +31,7 @@
 #define DVBSUB_DISPLAYDEFINITION_SEGMENT 0x14
 #define DVBSUB_DISPLAY_SEGMENT  0x80
 
-#define cm (ff_cropTbl + MAX_NEG_CROP)
+#define cm (ff_crop_tab + MAX_NEG_CROP)
 
 #ifdef DEBUG
 #if 0
diff --git a/deps/libav/libavcodec/dvdsubdec.c b/deps/libav/libavcodec/dvdsubdec.c
index 6b168cb..b4cb30d 100644
--- a/deps/libav/libavcodec/dvdsubdec.c
+++ b/deps/libav/libavcodec/dvdsubdec.c
@@ -35,7 +35,7 @@ typedef struct DVDSubContext {
 
 static void yuv_a_to_rgba(const uint8_t *ycbcr, const uint8_t *alpha, uint32_t *rgba, int num_values)
 {
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
     uint8_t r, g, b;
     int i, y, cb, cr;
     int r_add, g_add, b_add;
diff --git a/deps/libav/libavcodec/dvenc.c b/deps/libav/libavcodec/dvenc.c
index 73c07f2..590a2a9 100644
--- a/deps/libav/libavcodec/dvenc.c
+++ b/deps/libav/libavcodec/dvenc.c
@@ -33,7 +33,7 @@
 #include "dv.h"
 #include "dv_tablegen.h"
 
-static av_cold int dvvideo_init_encoder(AVCodecContext *avctx)
+static av_cold int dvvideo_encode_init(AVCodecContext *avctx)
 {
     if (!avpriv_dv_codec_profile(avctx)) {
         av_log(avctx, AV_LOG_ERROR, "Found no DV profile for %ix%i %s video. "
@@ -699,7 +699,7 @@ AVCodec ff_dvvideo_encoder = {
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_DVVIDEO,
     .priv_data_size = sizeof(DVVideoContext),
-    .init           = dvvideo_init_encoder,
+    .init           = dvvideo_encode_init,
     .encode2        = dvvideo_encode_frame,
     .close          = dvvideo_encode_close,
     .capabilities   = CODEC_CAP_SLICE_THREADS,
diff --git a/deps/libav/libavcodec/dxva2_mpeg2.c b/deps/libav/libavcodec/dxva2_mpeg2.c
index 049fa48..e0b2efa 100644
--- a/deps/libav/libavcodec/dxva2_mpeg2.c
+++ b/deps/libav/libavcodec/dxva2_mpeg2.c
@@ -20,9 +20,10 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "libavutil/log.h"
 #include "dxva2_internal.h"
 
-#define MAX_SLICES (SLICE_MAX_START_CODE - SLICE_MIN_START_CODE + 1)
+#define MAX_SLICES 1024
 struct dxva2_picture_context {
     DXVA_PictureParameters pp;
     DXVA_QmatrixData       qm;
@@ -233,9 +234,11 @@ static int dxva2_mpeg2_decode_slice(AVCodecContext *avctx,
         s->current_picture_ptr->hwaccel_picture_private;
     unsigned position;
 
-    if (ctx_pic->slice_count >= MAX_SLICES)
+    if (ctx_pic->slice_count >= MAX_SLICES) {
+        avpriv_request_sample(avctx, "%d slices in dxva2",
+                              ctx_pic->slice_count);
         return -1;
-
+    }
     if (!ctx_pic->bitstream)
         ctx_pic->bitstream = buffer;
     ctx_pic->bitstream_size += size;
diff --git a/deps/libav/libavcodec/eac3dec.c b/deps/libav/libavcodec/eac3dec.c
index 9ca9a3c..b9d079c 100644
--- a/deps/libav/libavcodec/eac3dec.c
+++ b/deps/libav/libavcodec/eac3dec.c
@@ -360,7 +360,6 @@ int ff_eac3_parse_header(AC3DecodeContext *s)
 
         /* lfe mix level */
         if (s->lfe_on && (s->lfe_mix_level_exists = get_bits1(gbc))) {
-            // TODO: use LFE mix level
             s->lfe_mix_level = get_bits(gbc, 5);
         }
 
diff --git a/deps/libav/libavcodec/error_resilience.c b/deps/libav/libavcodec/error_resilience.c
index 51ebc04..1217135 100644
--- a/deps/libav/libavcodec/error_resilience.c
+++ b/deps/libav/libavcodec/error_resilience.c
@@ -221,7 +221,7 @@ static void h_block_filter(ERContext *s, uint8_t *dst, int w,
                            int h, int stride, int is_luma)
 {
     int b_x, b_y, mvx_stride, mvy_stride;
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
     set_mv_strides(s, &mvx_stride, &mvy_stride);
     mvx_stride >>= is_luma;
     mvy_stride *= mvx_stride;
@@ -289,7 +289,7 @@ static void v_block_filter(ERContext *s, uint8_t *dst, int w, int h,
                            int stride, int is_luma)
 {
     int b_x, b_y, mvx_stride, mvy_stride;
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
     set_mv_strides(s, &mvx_stride, &mvy_stride);
     mvx_stride >>= is_luma;
     mvy_stride *= mvx_stride;
diff --git a/deps/libav/libavcodec/ffv1.c b/deps/libav/libavcodec/ffv1.c
index 9e7ba2e..d1a6a83 100644
--- a/deps/libav/libavcodec/ffv1.c
+++ b/deps/libav/libavcodec/ffv1.c
@@ -141,8 +141,6 @@ av_cold int ffv1_common_init(AVCodecContext *avctx)
     if (!avctx->width || !avctx->height)
         return AVERROR_INVALIDDATA;
 
-    ff_dsputil_init(&s->dsp, avctx);
-
     s->width  = avctx->width;
     s->height = avctx->height;
 
diff --git a/deps/libav/libavcodec/ffv1.h b/deps/libav/libavcodec/ffv1.h
index 40fc393..5c3bdc1 100644
--- a/deps/libav/libavcodec/ffv1.h
+++ b/deps/libav/libavcodec/ffv1.h
@@ -26,7 +26,6 @@
 #include <stdint.h>
 
 #include "avcodec.h"
-#include "dsputil.h"
 #include "get_bits.h"
 #include "put_bits.h"
 #include "rangecoder.h"
@@ -106,8 +105,6 @@ typedef struct FFV1Context {
     int gob_count;
     int quant_table_count;
 
-    DSPContext dsp;
-
     struct FFV1Context *slice_context[MAX_SLICES];
     int slice_count;
     int num_v_slices;
diff --git a/deps/libav/libavcodec/fic.c b/deps/libav/libavcodec/fic.c
index 9a3bc3e..df03437 100644
--- a/deps/libav/libavcodec/fic.c
+++ b/deps/libav/libavcodec/fic.c
@@ -166,6 +166,10 @@ static int fic_decode_frame(AVCodecContext *avctx, void *data,
     if (memcmp(src, fic_header, 7))
         av_log(avctx, AV_LOG_WARNING, "Invalid FIC Header.\n");
 
+    /* Is it a skip frame? */
+    if (src[17])
+        goto skip;
+
     nslices = src[13];
     if (!nslices) {
         av_log(avctx, AV_LOG_ERROR, "Zero slices found.\n");
@@ -245,6 +249,7 @@ static int fic_decode_frame(AVCodecContext *avctx, void *data,
                              NULL, nslices, sizeof(ctx->slice_data[0])) < 0)
         return ret;
 
+skip:
     *got_frame = 1;
     if ((ret = av_frame_ref(data, ctx->frame)) < 0)
         return ret;
diff --git a/deps/libav/libavcodec/g2meet.c b/deps/libav/libavcodec/g2meet.c
index 045c2a5..6d773ba 100644
--- a/deps/libav/libavcodec/g2meet.c
+++ b/deps/libav/libavcodec/g2meet.c
@@ -198,8 +198,8 @@ static int jpg_decode_block(JPGContext *c, GetBitContext *gb,
         return AVERROR_INVALIDDATA;
     if (dc)
         dc = get_xbits(gb, dc);
-    dc = dc * qmat[0] + c->prev_dc[plane];
-    block[0] = dc;
+    dc                = dc * qmat[0] + c->prev_dc[plane];
+    block[0]          = dc;
     c->prev_dc[plane] = dc;
 
     pos = 0;
@@ -214,8 +214,8 @@ static int jpg_decode_block(JPGContext *c, GetBitContext *gb,
         if (val) {
             int nbits = val;
 
-            val = get_xbits(gb, nbits);
-            val *= qmat[ff_zigzag_direct[pos]];
+            val                                 = get_xbits(gb, nbits);
+            val                                *= qmat[ff_zigzag_direct[pos]];
             block[c->scantable.permutated[pos]] = val;
         }
     }
@@ -359,7 +359,7 @@ static int kempf_decode_tile(G2MContext *c, int tile_x, int tile_y,
     width  = FFMIN(c->width  - tile_x * c->tile_width,  c->tile_width);
     height = FFMIN(c->height - tile_y * c->tile_height, c->tile_height);
 
-    hdr = *src++;
+    hdr      = *src++;
     sub_type = hdr >> 5;
     if (sub_type == 0) {
         int j;
@@ -379,19 +379,21 @@ static int kempf_decode_tile(G2MContext *c, int tile_x, int tile_y,
         src += 3;
     }
     npal = *src++ + 1;
-    memcpy(pal, src, npal * 3); src += npal * 3;
+    memcpy(pal, src, npal * 3);
+    src += npal * 3;
     if (sub_type != 2) {
         for (i = 0; i < npal; i++) {
             if (!memcmp(pal + i * 3, transp, 3)) {
-               tidx = i;
-               break;
+                tidx = i;
+                break;
             }
         }
     }
 
     if (src_end - src < 2)
         return 0;
-    zsize = (src[0] << 8) | src[1]; src += 2;
+    zsize = (src[0] << 8) | src[1];
+    src  += 2;
 
     if (src_end - src < zsize)
         return AVERROR_INVALIDDATA;
@@ -487,12 +489,12 @@ static int g2m_load_cursor(AVCodecContext *avctx, G2MContext *c,
     uint32_t cursor_hot_x, cursor_hot_y;
     int cursor_fmt, err;
 
-    cur_size      = bytestream2_get_be32(gb);
-    cursor_w      = bytestream2_get_byte(gb);
-    cursor_h      = bytestream2_get_byte(gb);
-    cursor_hot_x  = bytestream2_get_byte(gb);
-    cursor_hot_y  = bytestream2_get_byte(gb);
-    cursor_fmt    = bytestream2_get_byte(gb);
+    cur_size     = bytestream2_get_be32(gb);
+    cursor_w     = bytestream2_get_byte(gb);
+    cursor_h     = bytestream2_get_byte(gb);
+    cursor_hot_x = bytestream2_get_byte(gb);
+    cursor_hot_y = bytestream2_get_byte(gb);
+    cursor_fmt   = bytestream2_get_byte(gb);
 
     cursor_stride = FFALIGN(cursor_w, 32) * 4;
 
@@ -540,7 +542,7 @@ static int g2m_load_cursor(AVCodecContext *avctx, G2MContext *c,
                 bits = bytestream2_get_be32(gb);
                 for (k = 0; k < 32; k++) {
                     dst[0] = !!(bits & 0x80000000);
-                    dst += 4;
+                    dst   += 4;
                     bits <<= 1;
                 }
             }
@@ -555,18 +557,24 @@ static int g2m_load_cursor(AVCodecContext *avctx, G2MContext *c,
                     int mask_bit = !!(bits & 0x80000000);
                     switch (dst[0] * 2 + mask_bit) {
                     case 0:
-                        dst[0] = 0xFF; dst[1] = 0x00;
-                        dst[2] = 0x00; dst[3] = 0x00;
+                        dst[0] = 0xFF;
+                        dst[1] = 0x00;
+                        dst[2] = 0x00;
+                        dst[3] = 0x00;
                         break;
                     case 1:
-                        dst[0] = 0xFF; dst[1] = 0xFF;
-                        dst[2] = 0xFF; dst[3] = 0xFF;
+                        dst[0] = 0xFF;
+                        dst[1] = 0xFF;
+                        dst[2] = 0xFF;
+                        dst[3] = 0xFF;
                         break;
                     default:
-                        dst[0] = 0x00; dst[1] = 0x00;
-                        dst[2] = 0x00; dst[3] = 0x00;
+                        dst[0] = 0x00;
+                        dst[1] = 0x00;
+                        dst[2] = 0x00;
+                        dst[3] = 0x00;
                     }
-                    dst += 4;
+                    dst   += 4;
                     bits <<= 1;
                 }
             }
@@ -653,7 +661,7 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
     GetByteContext bc, tbc;
     int magic;
     int got_header = 0;
-    uint32_t chunk_size;
+    uint32_t chunk_size, r_mask, g_mask, b_mask;
     int chunk_type, chunk_start;
     int i;
     int ret;
@@ -727,7 +735,27 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
             }
             c->tiles_x = (c->width  + c->tile_width  - 1) / c->tile_width;
             c->tiles_y = (c->height + c->tile_height - 1) / c->tile_height;
-            c->bpp = bytestream2_get_byte(&bc);
+            c->bpp     = bytestream2_get_byte(&bc);
+            if (c->bpp == 32) {
+                if (bytestream2_get_bytes_left(&bc) < 16 ||
+                    (chunk_size - 21) < 16) {
+                    av_log(avctx, AV_LOG_ERROR,
+                           "Display info: missing bitmasks!\n");
+                    return AVERROR_INVALIDDATA;
+                }
+                r_mask = bytestream2_get_be32(&bc);
+                g_mask = bytestream2_get_be32(&bc);
+                b_mask = bytestream2_get_be32(&bc);
+                if (r_mask != 0xFF0000 || g_mask != 0xFF00 || b_mask != 0xFF) {
+                    av_log(avctx, AV_LOG_ERROR,
+                           "Invalid or unsupported bitmasks: R=%X, G=%X, B=%X\n",
+                           r_mask, g_mask, b_mask);
+                    return AVERROR_PATCHWELCOME;
+                }
+            } else {
+                avpriv_request_sample(avctx, "bpp=%d", c->bpp);
+                return AVERROR_PATCHWELCOME;
+            }
             if (g2m_init_buffers(c)) {
                 ret = AVERROR(ENOMEM);
                 goto header_fail;
@@ -813,7 +841,7 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
 
         for (i = 0; i < avctx->height; i++)
             memcpy(pic->data[0] + i * pic->linesize[0],
-                   c->framebuf  + i * c->framebuf_stride,
+                   c->framebuf + i * c->framebuf_stride,
                    c->width * 3);
         g2m_paint_cursor(c, pic->data[0], pic->linesize[0]);
 
@@ -821,15 +849,18 @@ static int g2m_decode_frame(AVCodecContext *avctx, void *data,
     }
 
     return buf_size;
+
 header_fail:
-    c->width   = c->height  = 0;
-    c->tiles_x = c->tiles_y = 0;
+    c->width   =
+    c->height  = 0;
+    c->tiles_x =
+    c->tiles_y = 0;
     return ret;
 }
 
 static av_cold int g2m_decode_init(AVCodecContext *avctx)
 {
-    G2MContext * const c = avctx->priv_data;
+    G2MContext *const c = avctx->priv_data;
     int ret;
 
     if ((ret = jpg_init(avctx, &c->jc)) != 0) {
@@ -845,7 +876,7 @@ static av_cold int g2m_decode_init(AVCodecContext *avctx)
 
 static av_cold int g2m_decode_end(AVCodecContext *avctx)
 {
-    G2MContext * const c = avctx->priv_data;
+    G2MContext *const c = avctx->priv_data;
 
     jpg_free_context(&c->jc);
 
diff --git a/deps/libav/libavcodec/golomb.h b/deps/libav/libavcodec/golomb.h
index efe5059..ce3500f 100644
--- a/deps/libav/libavcodec/golomb.h
+++ b/deps/libav/libavcodec/golomb.h
@@ -206,6 +206,18 @@ static inline int get_se_golomb(GetBitContext *gb)
     }
 }
 
+static inline int get_se_golomb_long(GetBitContext *gb)
+{
+    unsigned int buf = get_ue_golomb_long(gb);
+
+    if (buf & 1)
+        buf = -(buf >> 1);
+    else
+        buf = (buf >> 1);
+
+    return buf;
+}
+
 static inline int svq3_get_se_golomb(GetBitContext *gb)
 {
     unsigned int buf;
diff --git a/deps/libav/libavcodec/h264.c b/deps/libav/libavcodec/h264.c
index da2d4a5..c76abf7 100644
--- a/deps/libav/libavcodec/h264.c
+++ b/deps/libav/libavcodec/h264.c
@@ -1467,7 +1467,8 @@ int ff_h264_decode_extradata(H264Context *h)
         h->is_avc = 1;
 
         if (avctx->extradata_size < 7) {
-            av_log(avctx, AV_LOG_ERROR, "avcC too short\n");
+            av_log(avctx, AV_LOG_ERROR,
+                   "avcC %d too short\n", avctx->extradata_size);
             return AVERROR_INVALIDDATA;
         }
         /* sps and pps in the avcC always have length coded with 2 bytes,
@@ -1734,7 +1735,7 @@ static int decode_update_thread_context(AVCodecContext *dst,
 
         ret = ff_h264_alloc_tables(h);
         if (ret < 0) {
-            av_log(dst, AV_LOG_ERROR, "Could not allocate memory for h264\n");
+            av_log(dst, AV_LOG_ERROR, "Could not allocate memory\n");
             return ret;
         }
         ret = context_init(h);
@@ -2903,18 +2904,18 @@ static void init_scan_tables(H264Context *h)
 {
     int i;
     for (i = 0; i < 16; i++) {
-#define T(x) (x >> 2) | ((x << 2) & 0xF)
-        h->zigzag_scan[i] = T(zigzag_scan[i]);
-        h->field_scan[i]  = T(field_scan[i]);
-#undef T
+#define TRANSPOSE(x) (x >> 2) | ((x << 2) & 0xF)
+        h->zigzag_scan[i] = TRANSPOSE(zigzag_scan[i]);
+        h->field_scan[i]  = TRANSPOSE(field_scan[i]);
+#undef TRANSPOSE
     }
     for (i = 0; i < 64; i++) {
-#define T(x) (x >> 3) | ((x & 7) << 3)
-        h->zigzag_scan8x8[i]       = T(ff_zigzag_direct[i]);
-        h->zigzag_scan8x8_cavlc[i] = T(zigzag_scan8x8_cavlc[i]);
-        h->field_scan8x8[i]        = T(field_scan8x8[i]);
-        h->field_scan8x8_cavlc[i]  = T(field_scan8x8_cavlc[i]);
-#undef T
+#define TRANSPOSE(x) (x >> 3) | ((x & 7) << 3)
+        h->zigzag_scan8x8[i]       = TRANSPOSE(ff_zigzag_direct[i]);
+        h->zigzag_scan8x8_cavlc[i] = TRANSPOSE(zigzag_scan8x8_cavlc[i]);
+        h->field_scan8x8[i]        = TRANSPOSE(field_scan8x8[i]);
+        h->field_scan8x8_cavlc[i]  = TRANSPOSE(field_scan8x8_cavlc[i]);
+#undef TRANSPOSE
     }
     if (h->sps.transform_bypass) { // FIXME same ugly
         h->zigzag_scan_q0          = zigzag_scan;
@@ -3072,7 +3073,7 @@ static int h264_set_parameter_from_sps(H264Context *h)
                 ff_dsputil_init(&h->dsp, h->avctx);
             ff_videodsp_init(&h->vdsp, h->sps.bit_depth_luma);
         } else {
-            av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth: %d\n",
+            av_log(h->avctx, AV_LOG_ERROR, "Unsupported bit depth %d\n",
                    h->sps.bit_depth_luma);
             return AVERROR_INVALIDDATA;
         }
@@ -3125,7 +3126,7 @@ static enum AVPixelFormat get_pixel_format(H264Context *h)
         break;
     default:
         av_log(h->avctx, AV_LOG_ERROR,
-               "Unsupported bit depth: %d\n", h->sps.bit_depth_luma);
+               "Unsupported bit depth %d\n", h->sps.bit_depth_luma);
         return AVERROR_INVALIDDATA;
     }
 }
@@ -3196,8 +3197,7 @@ static int h264_slice_header_init(H264Context *h, int reinit)
     init_scan_tables(h);
     ret = ff_h264_alloc_tables(h);
     if (ret < 0) {
-        av_log(h->avctx, AV_LOG_ERROR,
-               "Could not allocate memory for h264\n");
+        av_log(h->avctx, AV_LOG_ERROR, "Could not allocate memory\n");
         return ret;
     }
 
@@ -3207,7 +3207,7 @@ static int h264_slice_header_init(H264Context *h, int reinit)
             max_slices = FFMIN(MAX_THREADS, h->mb_height);
         else
             max_slices = MAX_THREADS;
-        av_log(h->avctx, AV_LOG_WARNING, "too many threads/slices (%d),"
+        av_log(h->avctx, AV_LOG_WARNING, "too many threads/slices %d,"
                " reducing to %d\n", nb_slices, max_slices);
         nb_slices = max_slices;
     }
@@ -3325,7 +3325,7 @@ int ff_set_ref_count(H264Context *h)
 
 /**
  * Decode a slice header.
- * This will also call ff_MPV_common_init() and frame_start() as needed.
+ * This will (re)intialize the decoder and call h264_frame_start() as needed.
  *
  * @param h h264context
  * @param h0 h264 master context (differs from 'h' when doing sliced based
@@ -3367,8 +3367,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
     slice_type = get_ue_golomb_31(&h->gb);
     if (slice_type > 9) {
         av_log(h->avctx, AV_LOG_ERROR,
-               "slice type too large (%d) at %d %d\n",
-               h->slice_type, h->mb_x, h->mb_y);
+               "slice type %d too large at %d %d\n",
+               slice_type, h->mb_x, h->mb_y);
         return AVERROR_INVALIDDATA;
     }
     if (slice_type > 4) {
@@ -3396,7 +3396,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
 
     pps_id = get_ue_golomb(&h->gb);
     if (pps_id >= MAX_PPS_COUNT) {
-        av_log(h->avctx, AV_LOG_ERROR, "pps_id out of range\n");
+        av_log(h->avctx, AV_LOG_ERROR, "pps_id %u out of range\n", pps_id);
         return AVERROR_INVALIDDATA;
     }
     if (!h0->pps_buffers[pps_id]) {
@@ -3414,12 +3414,11 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
         return AVERROR_INVALIDDATA;
     }
 
-    if (h->pps.sps_id != h->current_sps_id ||
+    if (h->pps.sps_id != h->sps.sps_id ||
         h0->sps_buffers[h->pps.sps_id]->new) {
         h0->sps_buffers[h->pps.sps_id]->new = 0;
 
-        h->current_sps_id = h->pps.sps_id;
-        h->sps            = *h0->sps_buffers[h->pps.sps_id];
+        h->sps = *h0->sps_buffers[h->pps.sps_id];
 
         if (h->bit_depth_luma    != h->sps.bit_depth_luma ||
             h->chroma_format_idc != h->sps.chroma_format_idc) {
@@ -3472,8 +3471,12 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
          h->height != h->avctx->coded_height  ||
          needs_reinit)) {
         if (h != h0) {
-            av_log(h->avctx, AV_LOG_ERROR, "changing width/height on "
-                   "slice %d\n", h0->current_slice + 1);
+            av_log(h->avctx, AV_LOG_ERROR,
+                   "changing width %d -> %d / height %d -> %d on "
+                   "slice %d\n",
+                   h->width, h->avctx->coded_width,
+                   h->height, h->avctx->coded_height,
+                   h0->current_slice + 1);
             return AVERROR_INVALIDDATA;
         }
 
@@ -3547,7 +3550,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
             return AVERROR_INVALIDDATA;
         } else if (!h0->cur_pic_ptr) {
             av_log(h->avctx, AV_LOG_ERROR,
-                   "unset cur_pic_ptr on %d. slice\n",
+                   "unset cur_pic_ptr on slice %d\n",
                    h0->current_slice + 1);
             return AVERROR_INVALIDDATA;
         }
@@ -3814,7 +3817,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
     if (h->slice_type_nos != AV_PICTURE_TYPE_I && h->pps.cabac) {
         tmp = get_ue_golomb_31(&h->gb);
         if (tmp > 2) {
-            av_log(h->avctx, AV_LOG_ERROR, "cabac_init_idc overflow\n");
+            av_log(h->avctx, AV_LOG_ERROR, "cabac_init_idc %u overflow\n", tmp);
             return AVERROR_INVALIDDATA;
         }
         h->cabac_init_idc = tmp;
@@ -3837,8 +3840,8 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
         get_se_golomb(&h->gb); /* slice_qs_delta */
 
     h->deblocking_filter     = 1;
-    h->slice_alpha_c0_offset = 52;
-    h->slice_beta_offset     = 52;
+    h->slice_alpha_c0_offset = 0;
+    h->slice_beta_offset     = 0;
     if (h->pps.deblocking_filter_parameters_present) {
         tmp = get_ue_golomb_31(&h->gb);
         if (tmp > 2) {
@@ -3851,10 +3854,12 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
             h->deblocking_filter ^= 1;  // 1<->0
 
         if (h->deblocking_filter) {
-            h->slice_alpha_c0_offset += get_se_golomb(&h->gb) << 1;
-            h->slice_beta_offset     += get_se_golomb(&h->gb) << 1;
-            if (h->slice_alpha_c0_offset > 104U ||
-                h->slice_beta_offset     > 104U) {
+            h->slice_alpha_c0_offset = get_se_golomb(&h->gb) * 2;
+            h->slice_beta_offset     = get_se_golomb(&h->gb) * 2;
+            if (h->slice_alpha_c0_offset >  12 ||
+                h->slice_alpha_c0_offset < -12 ||
+                h->slice_beta_offset >  12     ||
+                h->slice_beta_offset < -12) {
                 av_log(h->avctx, AV_LOG_ERROR,
                        "deblocking filter parameters %d %d out of range\n",
                        h->slice_alpha_c0_offset, h->slice_beta_offset);
@@ -3891,7 +3896,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
             }
         }
     }
-    h->qp_thresh = 15 + 52 -
+    h->qp_thresh = 15 -
                    FFMIN(h->slice_alpha_c0_offset, h->slice_beta_offset) -
                    FFMAX3(0,
                           h->pps.chroma_qp_index_offset[0],
@@ -3953,7 +3958,7 @@ static int decode_slice_header(H264Context *h, H264Context *h0)
                h->ref_count[0], h->ref_count[1],
                h->qscale,
                h->deblocking_filter,
-               h->slice_alpha_c0_offset / 2 - 26, h->slice_beta_offset / 2 - 26,
+               h->slice_alpha_c0_offset, h->slice_beta_offset,
                h->use_weight,
                h->use_weight == 1 && h->use_weight_chroma ? "c" : "",
                h->slice_type == AV_PICTURE_TYPE_B ? (h->direct_spatial_mv_pred ? "SPAT" : "TEMP") : "");
@@ -4386,7 +4391,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
             }
             if (ret < 0 || h->cabac.bytestream > h->cabac.bytestream_end + 2) {
                 av_log(h->avctx, AV_LOG_ERROR,
-                       "error while decoding MB %d %d, bytestream (%td)\n",
+                       "error while decoding MB %d %d, bytestream %td\n",
                        h->mb_x, h->mb_y,
                        h->cabac.bytestream_end - h->cabac.bytestream);
                 er_add_slice(h, h->resync_mb_x, h->resync_mb_y, h->mb_x,
@@ -4500,7 +4505,7 @@ static int decode_slice(struct AVCodecContext *avctx, void *arg)
  * @param h h264 master context
  * @param context_count number of contexts to execute
  */
-static int execute_decode_slices(H264Context *h, int context_count)
+static int execute_decode_slices(H264Context *h, unsigned context_count)
 {
     AVCodecContext *const avctx = h->avctx;
     H264Context *hx;
@@ -4544,7 +4549,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size,
     AVCodecContext *const avctx = h->avctx;
     H264Context *hx; ///< thread context
     int buf_index;
-    int context_count;
+    unsigned context_count;
     int next_avc;
     int pass = !(avctx->active_thread_type & FF_THREAD_FRAME);
     int nals_needed = 0; ///< number of NALs that need decoding before the next frame thread starts
diff --git a/deps/libav/libavcodec/h264.h b/deps/libav/libavcodec/h264.h
index 6aa30b9..f29bc6a 100644
--- a/deps/libav/libavcodec/h264.h
+++ b/deps/libav/libavcodec/h264.h
@@ -120,7 +120,7 @@ enum {
  * SEI message types
  */
 typedef enum {
-    SEI_BUFFERING_PERIOD            = 0,   ///< buffering period (H.264, D.1.1)
+    SEI_TYPE_BUFFERING_PERIOD       = 0,   ///< buffering period (H.264, D.1.1)
     SEI_TYPE_PIC_TIMING             = 1,   ///< picture timing
     SEI_TYPE_USER_DATA_UNREGISTERED = 5,   ///< unregistered user data
     SEI_TYPE_RECOVERY_POINT         = 6,   ///< recovery point (frame # to decoder sync)
@@ -146,6 +146,7 @@ typedef enum {
  * Sequence parameter set
  */
 typedef struct SPS {
+    unsigned int sps_id;
     int profile_idc;
     int level_idc;
     int chroma_format_idc;
@@ -353,13 +354,8 @@ typedef struct H264Context {
     ptrdiff_t mb_linesize;  ///< may be equal to s->linesize or s->linesize * 2, for mbaff
     ptrdiff_t mb_uvlinesize;
 
-    unsigned current_sps_id; ///< id of the current SPS
     SPS sps; ///< current sps
-
-    /**
-     * current pps
-     */
-    PPS pps; // FIXME move to Picture perhaps? (->no) do we need that?
+    PPS pps; ///< current pps
 
     uint32_t dequant4_buffer[6][QP_MAX_NUM + 1][16]; // FIXME should these be moved down?
     uint32_t dequant8_buffer[6][QP_MAX_NUM + 1][64];
diff --git a/deps/libav/libavcodec/h264_loopfilter.c b/deps/libav/libavcodec/h264_loopfilter.c
index b8bf555..88ed34c 100644
--- a/deps/libav/libavcodec/h264_loopfilter.c
+++ b/deps/libav/libavcodec/h264_loopfilter.c
@@ -252,8 +252,8 @@ static av_always_inline void h264_filter_mb_fast_internal(H264Context *h,
     int top_type= h->top_type;
 
     int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
-    int a = h->slice_alpha_c0_offset - qp_bd_offset;
-    int b = h->slice_beta_offset - qp_bd_offset;
+    int a = 52 + h->slice_alpha_c0_offset - qp_bd_offset;
+    int b = 52 + h->slice_beta_offset - qp_bd_offset;
 
     int mb_type = h->cur_pic.mb_type[mb_xy];
     int qp      = h->cur_pic.qscale_table[mb_xy];
@@ -707,8 +707,8 @@ void ff_h264_filter_mb( H264Context *h, int mb_x, int mb_y, uint8_t *img_y, uint
     av_unused int dir;
     int chroma = !(CONFIG_GRAY && (h->flags&CODEC_FLAG_GRAY));
     int qp_bd_offset = 6 * (h->sps.bit_depth_luma - 8);
-    int a = h->slice_alpha_c0_offset - qp_bd_offset;
-    int b = h->slice_beta_offset - qp_bd_offset;
+    int a = 52 + h->slice_alpha_c0_offset - qp_bd_offset;
+    int b = 52 + h->slice_beta_offset - qp_bd_offset;
 
     if (FRAME_MBAFF(h)
             // and current and left pair do not have the same interlaced type
diff --git a/deps/libav/libavcodec/h264_parser.c b/deps/libav/libavcodec/h264_parser.c
index 05a40c7..a16229a 100644
--- a/deps/libav/libavcodec/h264_parser.c
+++ b/deps/libav/libavcodec/h264_parser.c
@@ -58,13 +58,15 @@ static int h264_find_frame_end(H264Context *h, const uint8_t *buf,
             else
                 state >>= 1;           // 2->1, 1->0, 0->0
         } else if (state <= 5) {
-            int v = buf[i] & 0x1F;
-            if (v == 6 || v == 7 || v == 8 || v == 9) {
+            int nalu_type = buf[i] & 0x1F;
+            if (nalu_type == NAL_SEI || nalu_type == NAL_SPS ||
+                nalu_type == NAL_PPS || nalu_type == NAL_AUD) {
                 if (pc->frame_start_found) {
                     i++;
                     goto found;
                 }
-            } else if (v == 1 || v == 2 || v == 5) {
+            } else if (nalu_type == NAL_SLICE || nalu_type == NAL_DPA ||
+                       nalu_type == NAL_IDR_SLICE) {
                 if (pc->frame_start_found) {
                     state += 8;
                     continue;
@@ -118,7 +120,8 @@ static int scan_mmco_reset(AVCodecParserContext *s)
                         break;
 
                     if (index >= h->ref_count[list]) {
-                        av_log(h->avctx, AV_LOG_ERROR, "reference count overflow\n");
+                        av_log(h->avctx, AV_LOG_ERROR,
+                               "reference count %d overflow\n", index);
                         return AVERROR_INVALIDDATA;
                     }
                 }
@@ -244,18 +247,18 @@ static inline int parse_nal_units(AVCodecParserContext *s,
             pps_id = get_ue_golomb(&h->gb);
             if (pps_id >= MAX_PPS_COUNT) {
                 av_log(h->avctx, AV_LOG_ERROR,
-                       "pps_id out of range\n");
+                       "pps_id %u out of range\n", pps_id);
                 return -1;
             }
             if (!h->pps_buffers[pps_id]) {
                 av_log(h->avctx, AV_LOG_ERROR,
-                       "non-existing PPS referenced\n");
+                       "non-existing PPS %u referenced\n", pps_id);
                 return -1;
             }
             h->pps = *h->pps_buffers[pps_id];
             if (!h->sps_buffers[h->pps.sps_id]) {
                 av_log(h->avctx, AV_LOG_ERROR,
-                       "non-existing SPS referenced\n");
+                       "non-existing SPS %u referenced\n", h->pps.sps_id);
                 return -1;
             }
             h->sps       = *h->sps_buffers[h->pps.sps_id];
diff --git a/deps/libav/libavcodec/h264_ps.c b/deps/libav/libavcodec/h264_ps.c
index 033bb79..94efaa2 100644
--- a/deps/libav/libavcodec/h264_ps.c
+++ b/deps/libav/libavcodec/h264_ps.c
@@ -306,18 +306,21 @@ int ff_h264_decode_seq_parameter_set(H264Context *h)
     constraint_set_flags |= get_bits1(&h->gb) << 1;   // constraint_set1_flag
     constraint_set_flags |= get_bits1(&h->gb) << 2;   // constraint_set2_flag
     constraint_set_flags |= get_bits1(&h->gb) << 3;   // constraint_set3_flag
-    get_bits(&h->gb, 4); // reserved
+    constraint_set_flags |= get_bits1(&h->gb) << 4;   // constraint_set4_flag
+    constraint_set_flags |= get_bits1(&h->gb) << 5;   // constraint_set5_flag
+    skip_bits(&h->gb, 2);                             // reserved_zero_2bits
     level_idc = get_bits(&h->gb, 8);
     sps_id    = get_ue_golomb_31(&h->gb);
 
     if (sps_id >= MAX_SPS_COUNT) {
-        av_log(h->avctx, AV_LOG_ERROR, "sps_id (%d) out of range\n", sps_id);
+        av_log(h->avctx, AV_LOG_ERROR, "sps_id %u out of range\n", sps_id);
         return AVERROR_INVALIDDATA;
     }
     sps = av_mallocz(sizeof(SPS));
     if (!sps)
         return AVERROR(ENOMEM);
 
+    sps->sps_id               = sps_id;
     sps->time_offset_length   = 24;
     sps->profile_idc          = profile_idc;
     sps->constraint_set_flags = constraint_set_flags;
@@ -327,16 +330,21 @@ int ff_h264_decode_seq_parameter_set(H264Context *h)
     memset(sps->scaling_matrix8, 16, sizeof(sps->scaling_matrix8));
     sps->scaling_matrix_present = 0;
 
-    if (sps->profile_idc == 100 || sps->profile_idc == 110 ||
-        sps->profile_idc == 122 || sps->profile_idc == 244 ||
-        sps->profile_idc ==  44 || sps->profile_idc ==  83 ||
-        sps->profile_idc ==  86 || sps->profile_idc == 118 ||
-        sps->profile_idc == 128 || sps->profile_idc == 144) {
+    if (sps->profile_idc == 100 ||  // High profile
+        sps->profile_idc == 110 ||  // High10 profile
+        sps->profile_idc == 122 ||  // High422 profile
+        sps->profile_idc == 244 ||  // High444 Predictive profile
+        sps->profile_idc ==  44 ||  // Cavlc444 profile
+        sps->profile_idc ==  83 ||  // Scalable Constrained High profile (SVC)
+        sps->profile_idc ==  86 ||  // Scalable High Intra profile (SVC)
+        sps->profile_idc == 118 ||  // Stereo High profile (MVC)
+        sps->profile_idc == 128 ||  // Multiview High profile (MVC)
+        sps->profile_idc == 138 ||  // Multiview Depth High profile (MVCD)
+        sps->profile_idc == 144) {  // old High444 profile
         sps->chroma_format_idc = get_ue_golomb_31(&h->gb);
         if (sps->chroma_format_idc > 3) {
-            av_log(h->avctx, AV_LOG_ERROR,
-                   "chroma_format_idc (%u) out of range\n",
-                   sps->chroma_format_idc);
+            avpriv_request_sample(h->avctx, "chroma_format_idc %u",
+                                  sps->chroma_format_idc);
             goto fail;
         } else if (sps->chroma_format_idc == 3) {
             sps->residual_color_transform_flag = get_bits1(&h->gb);
@@ -394,7 +402,8 @@ int ff_h264_decode_seq_parameter_set(H264Context *h)
     sps->ref_frame_count = get_ue_golomb_31(&h->gb);
     if (sps->ref_frame_count > MAX_PICTURE_COUNT - 2 ||
         sps->ref_frame_count >= 32U) {
-        av_log(h->avctx, AV_LOG_ERROR, "too many reference frames\n");
+        av_log(h->avctx, AV_LOG_ERROR,
+               "too many reference frames %d\n", sps->ref_frame_count);
         goto fail;
     }
     sps->gaps_in_frame_num_allowed_flag = get_bits1(&h->gb);
@@ -503,7 +512,6 @@ int ff_h264_decode_seq_parameter_set(H264Context *h)
     av_free(h->sps_buffers[sps_id]);
     h->sps_buffers[sps_id] = sps;
     h->sps                 = *sps;
-    h->current_sps_id      = sps_id;
 
     return 0;
 
@@ -529,7 +537,7 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length)
     int bits_left;
 
     if (pps_id >= MAX_PPS_COUNT) {
-        av_log(h->avctx, AV_LOG_ERROR, "pps_id (%d) out of range\n", pps_id);
+        av_log(h->avctx, AV_LOG_ERROR, "pps_id %u out of range\n", pps_id);
         return AVERROR_INVALIDDATA;
     } else if (h->sps.bit_depth_luma > 10) {
         av_log(h->avctx, AV_LOG_ERROR,
@@ -544,7 +552,7 @@ int ff_h264_decode_picture_parameter_set(H264Context *h, int bit_length)
     pps->sps_id = get_ue_golomb_31(&h->gb);
     if ((unsigned)pps->sps_id >= MAX_SPS_COUNT ||
         h->sps_buffers[pps->sps_id] == NULL) {
-        av_log(h->avctx, AV_LOG_ERROR, "sps_id out of range\n");
+        av_log(h->avctx, AV_LOG_ERROR, "sps_id %u out of range\n", pps->sps_id);
         goto fail;
     }
 
diff --git a/deps/libav/libavcodec/h264_refs.c b/deps/libav/libavcodec/h264_refs.c
index 88aaac7..ccdb49b 100644
--- a/deps/libav/libavcodec/h264_refs.c
+++ b/deps/libav/libavcodec/h264_refs.c
@@ -220,16 +220,16 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
         for (i = 0; i < h->ref_count[list]; i++)
             COPY_PICTURE(&h->ref_list[list][i], &h->default_ref_list[list][i]);
 
-        if (get_bits1(&h->gb)) {
+        if (get_bits1(&h->gb)) {    // ref_pic_list_modification_flag_l[01]
             int pred = h->curr_pic_num;
 
             for (index = 0; ; index++) {
-                unsigned int reordering_of_pic_nums_idc = get_ue_golomb_31(&h->gb);
+                unsigned int modification_of_pic_nums_idc = get_ue_golomb_31(&h->gb);
                 unsigned int pic_id;
                 int i;
                 Picture *ref = NULL;
 
-                if (reordering_of_pic_nums_idc == 3)
+                if (modification_of_pic_nums_idc == 3)
                     break;
 
                 if (index >= h->ref_count[list]) {
@@ -237,75 +237,84 @@ int ff_h264_decode_ref_pic_list_reordering(H264Context *h)
                     return -1;
                 }
 
-                if (reordering_of_pic_nums_idc < 3) {
-                    if (reordering_of_pic_nums_idc < 2) {
-                        const unsigned int abs_diff_pic_num = get_ue_golomb(&h->gb) + 1;
-                        int frame_num;
-
-                        if (abs_diff_pic_num > h->max_pic_num) {
-                            av_log(h->avctx, AV_LOG_ERROR, "abs_diff_pic_num overflow\n");
-                            return -1;
-                        }
-
-                        if (reordering_of_pic_nums_idc == 0)
-                            pred -= abs_diff_pic_num;
-                        else
-                            pred += abs_diff_pic_num;
-                        pred &= h->max_pic_num - 1;
-
-                        frame_num = pic_num_extract(h, pred, &pic_structure);
-
-                        for (i = h->short_ref_count - 1; i >= 0; i--) {
-                            ref = h->short_ref[i];
-                            assert(ref->reference);
-                            assert(!ref->long_ref);
-                            if (ref->frame_num == frame_num &&
-                                (ref->reference & pic_structure))
-                                break;
-                        }
-                        if (i >= 0)
-                            ref->pic_id = pred;
-                    } else {
-                        int long_idx;
-                        pic_id = get_ue_golomb(&h->gb); //long_term_pic_idx
-
-                        long_idx = pic_num_extract(h, pic_id, &pic_structure);
-
-                        if (long_idx > 31) {
-                            av_log(h->avctx, AV_LOG_ERROR, "long_term_pic_idx overflow\n");
-                            return -1;
-                        }
-                        ref = h->long_ref[long_idx];
-                        assert(!(ref && !ref->reference));
-                        if (ref && (ref->reference & pic_structure)) {
-                            ref->pic_id = pic_id;
-                            assert(ref->long_ref);
-                            i = 0;
-                        } else {
-                            i = -1;
-                        }
+                switch (modification_of_pic_nums_idc) {
+                case 0:
+                case 1: {
+                    const unsigned int abs_diff_pic_num = get_ue_golomb(&h->gb) + 1;
+                    int frame_num;
+
+                    if (abs_diff_pic_num > h->max_pic_num) {
+                        av_log(h->avctx, AV_LOG_ERROR,
+                               "abs_diff_pic_num overflow\n");
+                        return AVERROR_INVALIDDATA;
+                    }
+
+                    if (modification_of_pic_nums_idc == 0)
+                        pred -= abs_diff_pic_num;
+                    else
+                        pred += abs_diff_pic_num;
+                    pred &= h->max_pic_num - 1;
+
+                    frame_num = pic_num_extract(h, pred, &pic_structure);
+
+                    for (i = h->short_ref_count - 1; i >= 0; i--) {
+                        ref = h->short_ref[i];
+                        assert(ref->reference);
+                        assert(!ref->long_ref);
+                        if (ref->frame_num == frame_num &&
+                            (ref->reference & pic_structure))
+                            break;
                     }
+                    if (i >= 0)
+                        ref->pic_id = pred;
+                    break;
+                }
+                case 2: {
+                    int long_idx;
+                    pic_id = get_ue_golomb(&h->gb); // long_term_pic_idx
+
+                    long_idx = pic_num_extract(h, pic_id, &pic_structure);
 
-                    if (i < 0) {
-                        av_log(h->avctx, AV_LOG_ERROR, "reference picture missing during reorder\n");
-                        memset(&h->ref_list[list][index], 0, sizeof(Picture)); //FIXME
+                    if (long_idx > 31) {
+                        av_log(h->avctx, AV_LOG_ERROR,
+                               "long_term_pic_idx overflow\n");
+                        return AVERROR_INVALIDDATA;
+                    }
+                    ref = h->long_ref[long_idx];
+                    assert(!(ref && !ref->reference));
+                    if (ref && (ref->reference & pic_structure)) {
+                        ref->pic_id = pic_id;
+                        assert(ref->long_ref);
+                        i = 0;
                     } else {
-                        for (i = index; i + 1 < h->ref_count[list]; i++) {
-                            if (ref->long_ref == h->ref_list[list][i].long_ref &&
-                                ref->pic_id   == h->ref_list[list][i].pic_id)
-                                break;
-                        }
-                        for (; i > index; i--) {
-                            COPY_PICTURE(&h->ref_list[list][i], &h->ref_list[list][i - 1]);
-                        }
-                        COPY_PICTURE(&h->ref_list[list][index], ref);
-                        if (FIELD_PICTURE(h)) {
-                            pic_as_field(&h->ref_list[list][index], pic_structure);
-                        }
+                        i = -1;
                     }
+                    break;
+                }
+                default:
+                    av_log(h->avctx, AV_LOG_ERROR,
+                           "illegal modification_of_pic_nums_idc %u\n",
+                           modification_of_pic_nums_idc);
+                    return AVERROR_INVALIDDATA;
+                }
+
+                if (i < 0) {
+                    av_log(h->avctx, AV_LOG_ERROR,
+                           "reference picture missing during reorder\n");
+                    memset(&h->ref_list[list][index], 0, sizeof(Picture)); // FIXME
                 } else {
-                    av_log(h->avctx, AV_LOG_ERROR, "illegal reordering_of_pic_nums_idc\n");
-                    return -1;
+                    for (i = index; i + 1 < h->ref_count[list]; i++) {
+                        if (ref->long_ref == h->ref_list[list][i].long_ref &&
+                            ref->pic_id   == h->ref_list[list][i].pic_id)
+                            break;
+                    }
+                    for (; i > index; i--) {
+                        COPY_PICTURE(&h->ref_list[list][i], &h->ref_list[list][i - 1]);
+                    }
+                    COPY_PICTURE(&h->ref_list[list][index], ref);
+                    if (FIELD_PICTURE(h)) {
+                        pic_as_field(&h->ref_list[list][index], pic_structure);
+                    }
                 }
             }
         }
@@ -526,7 +535,7 @@ static int check_opcodes(MMCO *mmco1, MMCO *mmco2, int n_mmcos)
 int ff_generate_sliding_window_mmcos(H264Context *h, int first_slice)
 {
     MMCO mmco_temp[MAX_MMCO_COUNT], *mmco = first_slice ? h->mmco : mmco_temp;
-    int mmco_index = 0, i;
+    int mmco_index = 0, i = 0;
 
     assert(h->long_ref_count + h->short_ref_count <= h->sps.ref_frame_count);
 
diff --git a/deps/libav/libavcodec/h264_sei.c b/deps/libav/libavcodec/h264_sei.c
index 28e044d..6fca2c3 100644
--- a/deps/libav/libavcodec/h264_sei.c
+++ b/deps/libav/libavcodec/h264_sei.c
@@ -25,12 +25,10 @@
  * @author Michael Niedermayer <michaelni at gmx.at>
  */
 
-#include "internal.h"
 #include "avcodec.h"
-#include "h264.h"
 #include "golomb.h"
-
-#include <assert.h>
+#include "h264.h"
+#include "internal.h"
 
 static const uint8_t sei_num_clock_ts_table[9] = {
     1, 1, 1, 2, 2, 3, 3, 2, 3
@@ -238,7 +236,7 @@ int ff_h264_decode_sei(H264Context *h)
             if (ret < 0)
                 return ret;
             break;
-        case SEI_BUFFERING_PERIOD:
+        case SEI_TYPE_BUFFERING_PERIOD:
             ret = decode_buffering_period(h);
             if (ret < 0)
                 return ret;
diff --git a/deps/libav/libavcodec/h264chroma_template.c b/deps/libav/libavcodec/h264chroma_template.c
index 351d9d2..028ed13 100644
--- a/deps/libav/libavcodec/h264chroma_template.c
+++ b/deps/libav/libavcodec/h264chroma_template.c
@@ -43,7 +43,7 @@ static void FUNCC(OPNAME ## h264_chroma_mc2)(uint8_t *_dst/*align 8*/, uint8_t *
             dst+= stride;\
             src+= stride;\
         }\
-    }else{\
+    } else if (B + C) {\
         const int E= B+C;\
         const int step= C ? stride : 1;\
         for(i=0; i<h; i++){\
@@ -52,6 +52,13 @@ static void FUNCC(OPNAME ## h264_chroma_mc2)(uint8_t *_dst/*align 8*/, uint8_t *
             dst+= stride;\
             src+= stride;\
         }\
+    } else {\
+        for ( i = 0; i < h; i++){\
+            OP(dst[0], A * src[0]);\
+            OP(dst[1], A * src[1]);\
+            dst += stride;\
+            src += stride;\
+        }\
     }\
 }\
 \
@@ -76,7 +83,7 @@ static void FUNCC(OPNAME ## h264_chroma_mc4)(uint8_t *_dst/*align 8*/, uint8_t *
             dst+= stride;\
             src+= stride;\
         }\
-    }else{\
+    } else if (B + C) {\
         const int E= B+C;\
         const int step= C ? stride : 1;\
         for(i=0; i<h; i++){\
@@ -87,6 +94,15 @@ static void FUNCC(OPNAME ## h264_chroma_mc4)(uint8_t *_dst/*align 8*/, uint8_t *
             dst+= stride;\
             src+= stride;\
         }\
+    } else {\
+        for ( i = 0; i < h; i++){\
+            OP(dst[0], A * src[0]);\
+            OP(dst[1], A * src[1]);\
+            OP(dst[2], A * src[2]);\
+            OP(dst[3], A * src[3]);\
+            dst += stride;\
+            src += stride;\
+        }\
     }\
 }\
 \
@@ -115,7 +131,7 @@ static void FUNCC(OPNAME ## h264_chroma_mc8)(uint8_t *_dst/*align 8*/, uint8_t *
             dst+= stride;\
             src+= stride;\
         }\
-    }else{\
+    } else if (B + C) {\
         const int E= B+C;\
         const int step= C ? stride : 1;\
         for(i=0; i<h; i++){\
@@ -130,6 +146,19 @@ static void FUNCC(OPNAME ## h264_chroma_mc8)(uint8_t *_dst/*align 8*/, uint8_t *
             dst+= stride;\
             src+= stride;\
         }\
+    } else {\
+        for ( i = 0; i < h; i++){\
+            OP(dst[0], A * src[0]);\
+            OP(dst[1], A * src[1]);\
+            OP(dst[2], A * src[2]);\
+            OP(dst[3], A * src[3]);\
+            OP(dst[4], A * src[4]);\
+            OP(dst[5], A * src[5]);\
+            OP(dst[6], A * src[6]);\
+            OP(dst[7], A * src[7]);\
+            dst += stride;\
+            src += stride;\
+        }\
     }\
 }
 
diff --git a/deps/libav/libavcodec/h264pred.c b/deps/libav/libavcodec/h264pred.c
index 0d47897..531760c 100644
--- a/deps/libav/libavcodec/h264pred.c
+++ b/deps/libav/libavcodec/h264pred.c
@@ -269,7 +269,7 @@ static void pred4x4_horizontal_up_rv40_nodown_c(uint8_t *src,
 static void pred4x4_tm_vp8_c(uint8_t *src, const uint8_t *topright,
                              ptrdiff_t stride)
 {
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP - src[-1-stride];
     uint8_t *top = src-stride;
     int y;
 
@@ -295,7 +295,7 @@ static void pred16x16_plane_rv40_c(uint8_t *src, ptrdiff_t stride)
 
 static void pred16x16_tm_vp8_c(uint8_t *src, ptrdiff_t stride)
 {
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP - src[-1-stride];
     uint8_t *top = src-stride;
     int y;
 
@@ -377,7 +377,7 @@ static void pred8x8_dc_rv40_c(uint8_t *src, ptrdiff_t stride)
 
 static void pred8x8_tm_vp8_c(uint8_t *src, ptrdiff_t stride)
 {
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP - src[-1-stride];
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP - src[-1-stride];
     uint8_t *top = src-stride;
     int y;
 
diff --git a/deps/libav/libavcodec/h264pred_template.c b/deps/libav/libavcodec/h264pred_template.c
index e15c76c..48baec8 100644
--- a/deps/libav/libavcodec/h264pred_template.c
+++ b/deps/libav/libavcodec/h264pred_template.c
@@ -25,6 +25,8 @@
  * @author Michael Niedermayer <michaelni at gmx.at>
  */
 
+#include "libavutil/intreadwrite.h"
+
 #include "mathops.h"
 
 #include "bit_depth_template.c"
diff --git a/deps/libav/libavcodec/h264qpel_template.c b/deps/libav/libavcodec/h264qpel_template.c
index 027edf5..7182179 100644
--- a/deps/libav/libavcodec/h264qpel_template.c
+++ b/deps/libav/libavcodec/h264qpel_template.c
@@ -20,6 +20,8 @@
  */
 
 #include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
+
 #include "bit_depth_template.c"
 #include "hpel_template.c"
 
diff --git a/deps/libav/libavcodec/hevc.c b/deps/libav/libavcodec/hevc.c
index 8d9324a..49ed285 100644
--- a/deps/libav/libavcodec/hevc.c
+++ b/deps/libav/libavcodec/hevc.c
@@ -212,7 +212,7 @@ static int pic_arrays_init(HEVCContext *s, const HEVCSPS *sps)
         goto fail;
 
     s->cbf_luma = av_malloc(sps->min_tb_width * sps->min_tb_height);
-    s->tab_ipm  = av_malloc(min_pu_size);
+    s->tab_ipm  = av_mallocz(min_pu_size);
     s->is_pcm   = av_malloc(min_pu_size);
     if (!s->tab_ipm || !s->cbf_luma || !s->is_pcm)
         goto fail;
@@ -388,7 +388,7 @@ static int decode_lt_rps(HEVCContext *s, LongTermRPS *rps, GetBitContext *gb)
 static int set_sps(HEVCContext *s, const HEVCSPS *sps)
 {
     int ret;
-    int num = 0, den = 0;
+    unsigned int num = 0, den = 0;
 
     pic_arrays_free(s);
     ret = pic_arrays_init(s, sps);
@@ -2521,9 +2521,7 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
     if (ret < 0) {
         av_log(s->avctx, AV_LOG_ERROR, "Invalid NAL unit %d, skipping.\n",
                s->nal_unit_type);
-        if (s->avctx->err_recognition & AV_EF_EXPLODE)
-            return ret;
-        return 0;
+        goto fail;
     } else if (!ret)
         return 0;
 
@@ -2531,23 +2529,23 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
     case NAL_VPS:
         ret = ff_hevc_decode_nal_vps(s);
         if (ret < 0)
-            return ret;
+            goto fail;
         break;
     case NAL_SPS:
         ret = ff_hevc_decode_nal_sps(s);
         if (ret < 0)
-            return ret;
+            goto fail;
         break;
     case NAL_PPS:
         ret = ff_hevc_decode_nal_pps(s);
         if (ret < 0)
-            return ret;
+            goto fail;
         break;
     case NAL_SEI_PREFIX:
     case NAL_SEI_SUFFIX:
         ret = ff_hevc_decode_nal_sei(s);
         if (ret < 0)
-            return ret;
+            goto fail;
         break;
     case NAL_TRAIL_R:
     case NAL_TRAIL_N:
@@ -2593,7 +2591,7 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
                 return ret;
         } else if (!s->ref) {
             av_log(s->avctx, AV_LOG_ERROR, "First slice in a frame missing.\n");
-            return AVERROR_INVALIDDATA;
+            goto fail;
         }
 
         if (s->nal_unit_type != s->first_nal_type) {
@@ -2609,8 +2607,7 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
             if (ret < 0) {
                 av_log(s->avctx, AV_LOG_WARNING,
                        "Error constructing the reference lists for the current slice.\n");
-                if (s->avctx->err_recognition & AV_EF_EXPLODE)
-                    return ret;
+                goto fail;
             }
         }
 
@@ -2623,8 +2620,10 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
                 restore_tqb_pixels(s);
         }
 
-        if (ctb_addr_ts < 0)
-            return ctb_addr_ts;
+        if (ctb_addr_ts < 0) {
+            ret = ctb_addr_ts;
+            goto fail;
+        }
         break;
     case NAL_EOS_NUT:
     case NAL_EOB_NUT:
@@ -2640,6 +2639,10 @@ static int decode_nal_unit(HEVCContext *s, const uint8_t *nal, int length)
     }
 
     return 0;
+fail:
+    if (s->avctx->err_recognition & AV_EF_EXPLODE)
+        return ret;
+    return 0;
 }
 
 /* FIXME: This is adapted from ff_h264_decode_nal, avoiding duplication
@@ -2820,8 +2823,7 @@ static int decode_nal_units(HEVCContext *s, const uint8_t *buf, int length)
         if (ret < 0) {
             av_log(s->avctx, AV_LOG_WARNING,
                    "Error parsing NAL unit #%d.\n", i);
-            if (s->avctx->err_recognition & AV_EF_EXPLODE)
-                goto fail;
+            goto fail;
         }
     }
 
diff --git a/deps/libav/libavcodec/hevc.h b/deps/libav/libavcodec/hevc.h
index accfcb6..1197d08 100644
--- a/deps/libav/libavcodec/hevc.h
+++ b/deps/libav/libavcodec/hevc.h
@@ -463,7 +463,7 @@ typedef struct HEVCSPS {
 } HEVCSPS;
 
 typedef struct HEVCPPS {
-    int sps_id; ///< seq_parameter_set_id
+    unsigned int sps_id; ///< seq_parameter_set_id
 
     uint8_t sign_data_hiding_flag;
 
diff --git a/deps/libav/libavcodec/hevc_filter.c b/deps/libav/libavcodec/hevc_filter.c
index d3f2ff1..eb3f5f3 100644
--- a/deps/libav/libavcodec/hevc_filter.c
+++ b/deps/libav/libavcodec/hevc_filter.c
@@ -317,11 +317,15 @@ static void sao_filter_CTB(HEVCContext *s, int x, int y)
 static int get_pcm(HEVCContext *s, int x, int y)
 {
     int log2_min_pu_size = s->sps->log2_min_pu_size;
-    int x_pu             = x >> log2_min_pu_size;
-    int y_pu             = y >> log2_min_pu_size;
+    int x_pu, y_pu;
 
-    if (x < 0 || x_pu >= s->sps->min_pu_width ||
-        y < 0 || y_pu >= s->sps->min_pu_height)
+    if (x < 0 || y < 0)
+        return 2;
+
+    x_pu = x >> log2_min_pu_size;
+    y_pu = y >> log2_min_pu_size;
+
+    if (x_pu >= s->sps->min_pu_width || y_pu >= s->sps->min_pu_height)
         return 2;
     return s->is_pcm[y_pu * s->sps->min_pu_width + x_pu];
 }
@@ -374,8 +378,8 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
                 const int qp0 = (get_qPy(s, x - 1, y)     + get_qPy(s, x, y)     + 1) >> 1;
                 const int qp1 = (get_qPy(s, x - 1, y + 4) + get_qPy(s, x, y + 4) + 1) >> 1;
 
-                beta[0] = betatable[av_clip(qp0 + (beta_offset >> 1 << 1), 0, MAX_QP)];
-                beta[1] = betatable[av_clip(qp1 + (beta_offset >> 1 << 1), 0, MAX_QP)];
+                beta[0] = betatable[av_clip(qp0 + beta_offset, 0, MAX_QP)];
+                beta[1] = betatable[av_clip(qp1 + beta_offset, 0, MAX_QP)];
                 tc[0]   = bs0 ? TC_CALC(qp0, bs0) : 0;
                 tc[1]   = bs1 ? TC_CALC(qp1, bs1) : 0;
                 src     = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->sps->pixel_shift)];
@@ -439,8 +443,8 @@ static void deblocking_filter_CTB(HEVCContext *s, int x0, int y0)
                 tc_offset   = x >= x0 ? cur_tc_offset : left_tc_offset;
                 beta_offset = x >= x0 ? cur_beta_offset : left_beta_offset;
 
-                beta[0] = betatable[av_clip(qp0 + (beta_offset >> 1 << 1), 0, MAX_QP)];
-                beta[1] = betatable[av_clip(qp1 + (beta_offset >> 1 << 1), 0, MAX_QP)];
+                beta[0] = betatable[av_clip(qp0 + beta_offset, 0, MAX_QP)];
+                beta[1] = betatable[av_clip(qp1 + beta_offset, 0, MAX_QP)];
                 tc[0]   = bs0 ? TC_CALC(qp0, bs0) : 0;
                 tc[1]   = bs1 ? TC_CALC(qp1, bs1) : 0;
                 src     = &s->frame->data[LUMA][y * s->frame->linesize[LUMA] + (x << s->sps->pixel_shift)];
diff --git a/deps/libav/libavcodec/hevc_ps.c b/deps/libav/libavcodec/hevc_ps.c
index 0c1550e..5e5d4a7 100644
--- a/deps/libav/libavcodec/hevc_ps.c
+++ b/deps/libav/libavcodec/hevc_ps.c
@@ -499,8 +499,8 @@ static void decode_vui(HEVCContext *s, HEVCSPS *sps)
 
     vui->vui_timing_info_present_flag = get_bits1(gb);
     if (vui->vui_timing_info_present_flag) {
-        vui->vui_num_units_in_tick               = get_bits(gb, 32);
-        vui->vui_time_scale                      = get_bits(gb, 32);
+        vui->vui_num_units_in_tick               = get_bits_long(gb, 32);
+        vui->vui_time_scale                      = get_bits_long(gb, 32);
         vui->vui_poc_proportional_to_timing_flag = get_bits1(gb);
         if (vui->vui_poc_proportional_to_timing_flag)
             vui->vui_num_ticks_poc_diff_one_minus1 = get_ue_golomb_long(gb);
@@ -609,8 +609,8 @@ int ff_hevc_decode_nal_sps(HEVCContext *s)
 {
     const AVPixFmtDescriptor *desc;
     GetBitContext *gb = &s->HEVClc.gb;
-    int ret    = 0;
-    int sps_id = 0;
+    int ret = 0;
+    unsigned int sps_id = 0;
     int log2_diff_max_min_transform_block_size;
     int bit_depth_chroma, start, vui_present, sublayer_ordering_info;
     int i;
@@ -988,8 +988,8 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
     int pic_area_in_ctbs, pic_area_in_min_cbs, pic_area_in_min_tbs;
     int log2_diff_ctb_min_tb_size;
     int i, j, x, y, ctb_addr_rs, tile_id;
-    int ret    = 0;
-    int pps_id = 0;
+    int ret = 0;
+    unsigned int pps_id = 0;
 
     AVBufferRef *pps_buf;
     HEVCPPS *pps = av_mallocz(sizeof(*pps));
@@ -1029,7 +1029,7 @@ int ff_hevc_decode_nal_pps(HEVCContext *s)
         goto err;
     }
     if (!s->sps_list[pps->sps_id]) {
-        av_log(s->avctx, AV_LOG_ERROR, "SPS does not exist \n");
+        av_log(s->avctx, AV_LOG_ERROR, "SPS %u does not exist.\n", pps->sps_id);
         ret = AVERROR_INVALIDDATA;
         goto err;
     }
diff --git a/deps/libav/libavcodec/hevcdsp_template.c b/deps/libav/libavcodec/hevcdsp_template.c
index 104c1eb..f02e175 100644
--- a/deps/libav/libavcodec/hevcdsp_template.c
+++ b/deps/libav/libavcodec/hevcdsp_template.c
@@ -1281,7 +1281,7 @@ static void FUNC(hevc_loop_filter_chroma)(uint8_t *_pix, ptrdiff_t _xstride,
             const int p0 = P0;
             const int q0 = Q0;
             const int q1 = Q1;
-            delta0 = av_clip((((q0 - p0) << 2) + p1 - q1 + 4) >> 3, -tc, tc);
+            delta0 = av_clip((((q0 - p0) * 4) + p1 - q1 + 4) >> 3, -tc, tc);
             if (!no_p)
                 P0 = av_clip_pixel(p0 + delta0);
             if (!no_q)
diff --git a/deps/libav/libavcodec/hpeldsp.c b/deps/libav/libavcodec/hpeldsp.c
index f8b90e4..9fee199 100644
--- a/deps/libav/libavcodec/hpeldsp.c
+++ b/deps/libav/libavcodec/hpeldsp.c
@@ -62,8 +62,6 @@ av_cold void ff_hpeldsp_init(HpelDSPContext *c, int flags)
         ff_hpeldsp_init_bfin(c, flags);
     if (ARCH_PPC)
         ff_hpeldsp_init_ppc(c, flags);
-    if (HAVE_VIS)
-        ff_hpeldsp_init_vis(c, flags);
     if (ARCH_X86)
         ff_hpeldsp_init_x86(c, flags);
 }
diff --git a/deps/libav/libavcodec/hpeldsp.h b/deps/libav/libavcodec/hpeldsp.h
index a109fe8..b7c2f6e 100644
--- a/deps/libav/libavcodec/hpeldsp.h
+++ b/deps/libav/libavcodec/hpeldsp.h
@@ -98,7 +98,6 @@ void ff_hpeldsp_init_aarch64(HpelDSPContext *c, int flags);
 void ff_hpeldsp_init_arm(HpelDSPContext *c, int flags);
 void ff_hpeldsp_init_bfin(HpelDSPContext *c, int flags);
 void ff_hpeldsp_init_ppc(HpelDSPContext *c, int flags);
-void ff_hpeldsp_init_vis(HpelDSPContext *c, int flags);
 void ff_hpeldsp_init_x86(HpelDSPContext *c, int flags);
 
 #endif /* AVCODEC_HPELDSP_H */
diff --git a/deps/libav/libavcodec/huffyuvdec.c b/deps/libav/libavcodec/huffyuvdec.c
index ed490d4..86d1581 100644
--- a/deps/libav/libavcodec/huffyuvdec.c
+++ b/deps/libav/libavcodec/huffyuvdec.c
@@ -737,7 +737,6 @@ static av_cold int decode_end(AVCodecContext *avctx)
     return 0;
 }
 
-#if CONFIG_HUFFYUV_DECODER
 AVCodec ff_huffyuv_decoder = {
     .name             = "huffyuv",
     .long_name        = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"),
@@ -751,7 +750,6 @@ AVCodec ff_huffyuv_decoder = {
                         CODEC_CAP_FRAME_THREADS,
     .init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
 };
-#endif
 
 #if CONFIG_FFVHUFF_DECODER
 AVCodec ff_ffvhuff_decoder = {
diff --git a/deps/libav/libavcodec/huffyuvenc.c b/deps/libav/libavcodec/huffyuvenc.c
index ec07abd..1442b75 100644
--- a/deps/libav/libavcodec/huffyuvenc.c
+++ b/deps/libav/libavcodec/huffyuvenc.c
@@ -682,7 +682,6 @@ static av_cold int encode_end(AVCodecContext *avctx)
     return 0;
 }
 
-#if CONFIG_HUFFYUV_ENCODER
 AVCodec ff_huffyuv_encoder = {
     .name           = "huffyuv",
     .long_name      = NULL_IF_CONFIG_SMALL("Huffyuv / HuffYUV"),
@@ -697,7 +696,6 @@ AVCodec ff_huffyuv_encoder = {
         AV_PIX_FMT_RGB32, AV_PIX_FMT_NONE
     },
 };
-#endif
 
 #if CONFIG_FFVHUFF_ENCODER
 AVCodec ff_ffvhuff_encoder = {
diff --git a/deps/libav/libavcodec/imgconvert.c b/deps/libav/libavcodec/imgconvert.c
index 4eb049f..3f5d035 100644
--- a/deps/libav/libavcodec/imgconvert.c
+++ b/deps/libav/libavcodec/imgconvert.c
@@ -358,7 +358,7 @@ static void deinterlace_line_c(uint8_t *dst,
                              const uint8_t *lum,
                              int size)
 {
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
     int sum;
 
     for(;size > 0;size--) {
@@ -381,7 +381,7 @@ static void deinterlace_line_inplace_c(uint8_t *lum_m4, uint8_t *lum_m3,
                                        uint8_t *lum_m2, uint8_t *lum_m1,
                                        uint8_t *lum, int size)
 {
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
     int sum;
 
     for(;size > 0;size--) {
diff --git a/deps/libav/libavcodec/ituh263dec.c b/deps/libav/libavcodec/ituh263dec.c
index e365210..98c8cfc 100644
--- a/deps/libav/libavcodec/ituh263dec.c
+++ b/deps/libav/libavcodec/ituh263dec.c
@@ -750,6 +750,8 @@ int ff_h263_decode_mb(MpegEncContext *s,
         }
 
         if(IS_DIRECT(mb_type)){
+            if (!s->pp_time)
+                return AVERROR_INVALIDDATA;
             s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT;
             mb_type |= ff_mpeg4_set_direct_mv(s, 0, 0);
         }else{
diff --git a/deps/libav/libavcodec/libvorbis.c b/deps/libav/libavcodec/libvorbis.c
index a635db3..4b4caaa 100644
--- a/deps/libav/libavcodec/libvorbis.c
+++ b/deps/libav/libavcodec/libvorbis.c
@@ -43,11 +43,11 @@
  * an output packet will always start at the same point as one of the input
  * packets.
  */
-#define OGGVORBIS_FRAME_SIZE 64
+#define LIBVORBIS_FRAME_SIZE 64
 
 #define BUFFER_SIZE (1024 * 64)
 
-typedef struct OggVorbisContext {
+typedef struct LibvorbisContext {
     AVClass *av_class;                  /**< class for AVOptions            */
     vorbis_info vi;                     /**< vorbis_info used during init   */
     vorbis_dsp_state vd;                /**< DSP state used for analysis    */
@@ -60,10 +60,10 @@ typedef struct OggVorbisContext {
     double iblock;                      /**< impulse block bias option      */
     VorbisParseContext vp;              /**< parse context to get durations */
     AudioFrameQueue afq;                /**< frame queue for timestamps     */
-} OggVorbisContext;
+} LibvorbisContext;
 
 static const AVOption options[] = {
-    { "iblock", "Sets the impulse block bias", offsetof(OggVorbisContext, iblock), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, -15, 0, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
+    { "iblock", "Sets the impulse block bias", offsetof(LibvorbisContext, iblock), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, -15, 0, AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_ENCODING_PARAM },
     { NULL }
 };
 
@@ -85,10 +85,9 @@ static int vorbis_error_to_averror(int ov_err)
     }
 }
 
-static av_cold int oggvorbis_init_encoder(vorbis_info *vi,
-                                          AVCodecContext *avctx)
+static av_cold int libvorbis_setup(vorbis_info *vi, AVCodecContext *avctx)
 {
-    OggVorbisContext *s = avctx->priv_data;
+    LibvorbisContext *s = avctx->priv_data;
     double cfreq;
     int ret;
 
@@ -148,9 +147,9 @@ static int xiph_len(int l)
     return 1 + l / 255 + l;
 }
 
-static av_cold int oggvorbis_encode_close(AVCodecContext *avctx)
+static av_cold int libvorbis_encode_close(AVCodecContext *avctx)
 {
-    OggVorbisContext *s = avctx->priv_data;
+    LibvorbisContext *s = avctx->priv_data;
 
     /* notify vorbisenc this is EOF */
     if (s->dsp_initialized)
@@ -167,16 +166,16 @@ static av_cold int oggvorbis_encode_close(AVCodecContext *avctx)
     return 0;
 }
 
-static av_cold int oggvorbis_encode_init(AVCodecContext *avctx)
+static av_cold int libvorbis_encode_init(AVCodecContext *avctx)
 {
-    OggVorbisContext *s = avctx->priv_data;
+    LibvorbisContext *s = avctx->priv_data;
     ogg_packet header, header_comm, header_code;
     uint8_t *p;
     unsigned int offset;
     int ret;
 
     vorbis_info_init(&s->vi);
-    if ((ret = oggvorbis_init_encoder(&s->vi, avctx))) {
+    if ((ret = libvorbis_setup(&s->vi, avctx))) {
         av_log(avctx, AV_LOG_ERROR, "encoder setup failed\n");
         goto error;
     }
@@ -229,7 +228,7 @@ static av_cold int oggvorbis_encode_init(AVCodecContext *avctx)
 
     vorbis_comment_clear(&s->vc);
 
-    avctx->frame_size = OGGVORBIS_FRAME_SIZE;
+    avctx->frame_size = LIBVORBIS_FRAME_SIZE;
     ff_af_queue_init(avctx, &s->afq);
 
     s->pkt_fifo = av_fifo_alloc(BUFFER_SIZE);
@@ -240,14 +239,14 @@ static av_cold int oggvorbis_encode_init(AVCodecContext *avctx)
 
     return 0;
 error:
-    oggvorbis_encode_close(avctx);
+    libvorbis_encode_close(avctx);
     return ret;
 }
 
-static int oggvorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
+static int libvorbis_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
                                   const AVFrame *frame, int *got_packet_ptr)
 {
-    OggVorbisContext *s = avctx->priv_data;
+    LibvorbisContext *s = avctx->priv_data;
     ogg_packet op;
     int ret, duration;
 
@@ -340,10 +339,10 @@ AVCodec ff_libvorbis_encoder = {
     .long_name      = NULL_IF_CONFIG_SMALL("libvorbis Vorbis"),
     .type           = AVMEDIA_TYPE_AUDIO,
     .id             = AV_CODEC_ID_VORBIS,
-    .priv_data_size = sizeof(OggVorbisContext),
-    .init           = oggvorbis_encode_init,
-    .encode2        = oggvorbis_encode_frame,
-    .close          = oggvorbis_encode_close,
+    .priv_data_size = sizeof(LibvorbisContext),
+    .init           = libvorbis_encode_init,
+    .encode2        = libvorbis_encode_frame,
+    .close          = libvorbis_encode_close,
     .capabilities   = CODEC_CAP_DELAY,
     .sample_fmts    = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
                                                       AV_SAMPLE_FMT_NONE },
diff --git a/deps/libav/libavcodec/libwebpenc.c b/deps/libav/libavcodec/libwebpenc.c
index 74e73dc..b981f48 100644
--- a/deps/libav/libavcodec/libwebpenc.c
+++ b/deps/libav/libavcodec/libwebpenc.c
@@ -161,9 +161,7 @@ static int libwebp_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
             ret = av_frame_get_buffer(alt_frame, 32);
             if (ret < 0)
                 goto end;
-            av_image_copy(alt_frame->data, alt_frame->linesize,
-                          frame->data, frame->linesize,
-                          avctx->pix_fmt, frame->width, frame->height);
+            av_frame_copy(alt_frame, frame);
             frame = alt_frame;
         }
         pic->use_argb  = 0;
diff --git a/deps/libav/libavcodec/libx265.c b/deps/libav/libavcodec/libx265.c
index e63e0cb..a6e4193 100644
--- a/deps/libav/libavcodec/libx265.c
+++ b/deps/libav/libavcodec/libx265.c
@@ -29,6 +29,10 @@
 #include "avcodec.h"
 #include "internal.h"
 
+#if defined(_MSC_VER)
+#define X265_API_IMPORTS 1
+#endif
+
 typedef struct libx265Context {
     const AVClass *class;
 
@@ -77,10 +81,20 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
     libx265Context *ctx = avctx->priv_data;
     x265_nal *nal;
     uint8_t *buf;
+    int sar_num, sar_den;
     int nnal;
     int ret;
     int i;
 
+    if (avctx->strict_std_compliance > FF_COMPLIANCE_EXPERIMENTAL &&
+        !av_pix_fmt_desc_get(avctx->pix_fmt)->log2_chroma_w &&
+        !av_pix_fmt_desc_get(avctx->pix_fmt)->log2_chroma_h) {
+        av_log(avctx, AV_LOG_ERROR,
+               "4:4:4 support is not fully defined for HEVC yet. "
+               "Set -strict experimental to encode anyway.\n");
+        return AVERROR(ENOSYS);
+    }
+
     avctx->coded_frame = av_frame_alloc();
     if (!avctx->coded_frame) {
         av_log(avctx, AV_LOG_ERROR, "Could not allocate frame.\n");
@@ -93,17 +107,41 @@ static av_cold int libx265_encode_init(AVCodecContext *avctx)
         return AVERROR(ENOMEM);
     }
 
-    x265_param_default(ctx->params);
     if (x265_param_default_preset(ctx->params, ctx->preset, ctx->tune) < 0) {
         av_log(avctx, AV_LOG_ERROR, "Invalid preset or tune.\n");
         return AVERROR(EINVAL);
     }
 
     ctx->params->frameNumThreads = avctx->thread_count;
-    ctx->params->frameRate       = (int) (avctx->time_base.den / avctx->time_base.num);
+    ctx->params->fpsNum          = avctx->time_base.den;
+    ctx->params->fpsDenom        = avctx->time_base.num * avctx->ticks_per_frame;
     ctx->params->sourceWidth     = avctx->width;
     ctx->params->sourceHeight    = avctx->height;
-    ctx->params->inputBitDepth   = av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth_minus1 + 1;
+
+    av_reduce(&sar_num, &sar_den,
+              avctx->sample_aspect_ratio.num,
+              avctx->sample_aspect_ratio.den, 4096);
+    ctx->params->vui.bEnableVuiParametersPresentFlag = 1;
+    ctx->params->vui.bEnableAspectRatioIdc           = 1;
+    ctx->params->vui.aspectRatioIdc                  = 255;
+    ctx->params->vui.sarWidth                        = sar_num;
+    ctx->params->vui.sarHeight                       = sar_den;
+
+    if (x265_max_bit_depth == 8)
+        ctx->params->internalBitDepth = 8;
+    else if (x265_max_bit_depth == 12)
+        ctx->params->internalBitDepth = 10;
+
+    switch (avctx->pix_fmt) {
+    case AV_PIX_FMT_YUV420P:
+    case AV_PIX_FMT_YUV420P10:
+        ctx->params->internalCsp = X265_CSP_I420;
+        break;
+    case AV_PIX_FMT_YUV444P:
+    case AV_PIX_FMT_YUV444P10:
+        ctx->params->internalCsp = X265_CSP_I444;
+        break;
+    }
 
     if (avctx->bit_rate > 0) {
         ctx->params->rc.bitrate         = avctx->bit_rate / 1000;
@@ -182,13 +220,16 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
     int ret;
     int i;
 
+    x265_picture_init(ctx->params, &x265pic);
+
     if (pic) {
         for (i = 0; i < 3; i++) {
            x265pic.planes[i] = pic->data[i];
            x265pic.stride[i] = pic->linesize[i];
         }
 
-        x265pic.pts = pic->pts;
+        x265pic.pts      = pic->pts;
+        x265pic.bitDepth = av_pix_fmt_desc_get(avctx->pix_fmt)->comp[0].depth_minus1 + 1;
     }
 
     ret = x265_encoder_encode(ctx->encoder, &nal, &nnal,
@@ -236,12 +277,15 @@ static int libx265_encode_frame(AVCodecContext *avctx, AVPacket *pkt,
 
 static const enum AVPixelFormat x265_csp_eight[] = {
     AV_PIX_FMT_YUV420P,
+    AV_PIX_FMT_YUV444P,
     AV_PIX_FMT_NONE
 };
 
 static const enum AVPixelFormat x265_csp_twelve[] = {
     AV_PIX_FMT_YUV420P,
+    AV_PIX_FMT_YUV444P,
     AV_PIX_FMT_YUV420P10,
+    AV_PIX_FMT_YUV444P10,
     AV_PIX_FMT_NONE
 };
 
diff --git a/deps/libav/libavcodec/ljpegenc.c b/deps/libav/libavcodec/ljpegenc.c
index 7eb4675..7c1b3bc 100644
--- a/deps/libav/libavcodec/ljpegenc.c
+++ b/deps/libav/libavcodec/ljpegenc.c
@@ -329,6 +329,6 @@ AVCodec ff_ljpeg_encoder = {
                                                     AV_PIX_FMT_BGR24,
                                                     AV_PIX_FMT_YUV420P,
                                                     AV_PIX_FMT_YUV422P,
-                                                    AV_PIX_FMT_YUVJ444P,
+                                                    AV_PIX_FMT_YUV444P,
                                                     AV_PIX_FMT_NONE },
 };
diff --git a/deps/libav/libavcodec/lzwenc.c b/deps/libav/libavcodec/lzwenc.c
index cb064e7..7c37bf2 100644
--- a/deps/libav/libavcodec/lzwenc.c
+++ b/deps/libav/libavcodec/lzwenc.c
@@ -26,8 +26,9 @@
  */
 
 #include "avcodec.h"
-#include "put_bits.h"
 #include "lzw.h"
+#include "mathops.h"
+#include "put_bits.h"
 
 #define LZW_MAXBITS 12
 #define LZW_SIZTABLE (1<<LZW_MAXBITS)
diff --git a/deps/libav/libavcodec/mathops.h b/deps/libav/libavcodec/mathops.h
index 6c216c2..0489a60 100644
--- a/deps/libav/libavcodec/mathops.h
+++ b/deps/libav/libavcodec/mathops.h
@@ -195,15 +195,6 @@ if ((y) < (x)) {\
 #   define FASTDIV(a,b) ((uint32_t)((((uint64_t)a) * ff_inverse[b]) >> 32))
 #endif /* FASTDIV */
 
-#ifndef MOD_UNLIKELY
-#   define MOD_UNLIKELY(modulus, dividend, divisor, prev_dividend) \
-    do { \
-        if ((prev_dividend) == 0 || (dividend) - (prev_dividend) != (divisor)) \
-            (modulus) = (dividend) % (divisor); \
-        (prev_dividend) = (dividend); \
-    } while (0)
-#endif
-
 static inline av_const unsigned int ff_sqrt(unsigned int a)
 {
     unsigned int b;
diff --git a/deps/libav/libavcodec/mathtables.c b/deps/libav/libavcodec/mathtables.c
index 8a3934b..0f09041 100644
--- a/deps/libav/libavcodec/mathtables.c
+++ b/deps/libav/libavcodec/mathtables.c
@@ -89,7 +89,7 @@ const uint8_t ff_reverse[256] = {
 #define times4(x) x, x, x, x
 #define times256(x) times4(times4(times4(times4(times4(x)))))
 
-const uint8_t ff_cropTbl[256 + 2 * 1024] = {
+const uint8_t ff_crop_tab[256 + 2 * 1024] = {
 times256(0x00),
 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F,
 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17,0x18,0x19,0x1A,0x1B,0x1C,0x1D,0x1E,0x1F,
diff --git a/deps/libav/libavcodec/mjpeg.h b/deps/libav/libavcodec/mjpeg.h
index a69b519..bd3b1e8 100644
--- a/deps/libav/libavcodec/mjpeg.h
+++ b/deps/libav/libavcodec/mjpeg.h
@@ -33,10 +33,11 @@
 #ifndef AVCODEC_MJPEG_H
 #define AVCODEC_MJPEG_H
 
+#include "libavutil/internal.h"
+
 #include "avcodec.h"
 #include "put_bits.h"
 
-
 /* JPEG marker codes */
 typedef enum {
     /* start of frame */
diff --git a/deps/libav/libavcodec/motionpixels_tablegen.c b/deps/libav/libavcodec/motionpixels_tablegen.c
index ad8e0d9..410b76f 100644
--- a/deps/libav/libavcodec/motionpixels_tablegen.c
+++ b/deps/libav/libavcodec/motionpixels_tablegen.c
@@ -23,7 +23,7 @@
 #include <stdlib.h>
 #define CONFIG_HARDCODED_TABLES 0
 #define MAX_NEG_CROP 0
-#define ff_cropTbl ((uint8_t *)NULL)
+#define ff_crop_tab ((uint8_t *)NULL)
 #include "motionpixels_tablegen.h"
 #include "tableprint.h"
 
diff --git a/deps/libav/libavcodec/motionpixels_tablegen.h b/deps/libav/libavcodec/motionpixels_tablegen.h
index cbf56c8..e6c32c7 100644
--- a/deps/libav/libavcodec/motionpixels_tablegen.h
+++ b/deps/libav/libavcodec/motionpixels_tablegen.h
@@ -30,7 +30,7 @@ typedef struct YuvPixel {
 } YuvPixel;
 
 static int mp_yuv_to_rgb(int y, int v, int u, int clip_rgb) {
-    static const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+    static const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
     int r, g, b;
 
     r = (1000 * y + 701 * v) / 1000;
diff --git a/deps/libav/libavcodec/mpc8.c b/deps/libav/libavcodec/mpc8.c
index b6e0cfd..ee05a93 100644
--- a/deps/libav/libavcodec/mpc8.c
+++ b/deps/libav/libavcodec/mpc8.c
@@ -29,7 +29,6 @@
 #include "libavutil/lfg.h"
 #include "avcodec.h"
 #include "get_bits.h"
-#include "dsputil.h"
 #include "internal.h"
 #include "mpegaudiodsp.h"
 
@@ -119,7 +118,6 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
     }
     memset(c->oldDSCF, 0, sizeof(c->oldDSCF));
     av_lfg_init(&c->rnd, 0xDEADBEEF);
-    ff_dsputil_init(&c->dsp, avctx);
     ff_mpadsp_init(&c->mpadsp);
 
     ff_mpc_init();
diff --git a/deps/libav/libavcodec/mpeg12dec.c b/deps/libav/libavcodec/mpeg12dec.c
index 149d5f4..cb713fd 100644
--- a/deps/libav/libavcodec/mpeg12dec.c
+++ b/deps/libav/libavcodec/mpeg12dec.c
@@ -46,6 +46,8 @@ typedef struct Mpeg1Context {
     int mpeg_enc_ctx_allocated; /* true if decoding context allocated */
     int repeat_field;           /* true if we must repeat the field */
     AVPanScan pan_scan;         /* some temporary storage for the panscan */
+    AVStereo3D stereo3d;
+    int has_stereo3d;
     uint8_t *a53_caption;
     int a53_caption_size;
     int slice_count;
@@ -1614,6 +1616,15 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
                 memcpy(sd->data, s1->a53_caption, s1->a53_caption_size);
             av_freep(&s1->a53_caption);
         }
+
+        if (s1->has_stereo3d) {
+            AVStereo3D *stereo = av_stereo3d_create_side_data(&s->current_picture_ptr->f);
+            if (!stereo)
+                return AVERROR(ENOMEM);
+
+            *stereo = s1->stereo3d;
+            s1->has_stereo3d = 0;
+        }
         if (HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_FRAME))
             ff_thread_finish_setup(avctx);
     } else { // second field
@@ -2231,24 +2242,21 @@ static void mpeg_decode_user_data(AVCodecContext *avctx,
             S3D_video_format_type == 0x08 ||
             S3D_video_format_type == 0x23) {
             Mpeg1Context *s1   = avctx->priv_data;
-            MpegEncContext *s  = &s1->mpeg_enc_ctx;
-            AVStereo3D *stereo =
-                av_stereo3d_create_side_data(&s->current_picture_ptr->f);
-            if (!stereo)
-                return;
+
+            s1->has_stereo3d = 1;
 
             switch (S3D_video_format_type) {
             case 0x03:
-                stereo->type = AV_STEREO3D_SIDEBYSIDE;
+                s1->stereo3d.type = AV_STEREO3D_SIDEBYSIDE;
                 break;
             case 0x04:
-                stereo->type = AV_STEREO3D_TOPBOTTOM;
+                s1->stereo3d.type = AV_STEREO3D_TOPBOTTOM;
                 break;
             case 0x08:
-                stereo->type = AV_STEREO3D_2D;
+                s1->stereo3d.type = AV_STEREO3D_2D;
                 break;
             case 0x23:
-                stereo->type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
+                s1->stereo3d.type = AV_STEREO3D_SIDEBYSIDE_QUINCUNX;
                 break;
             }
         }
diff --git a/deps/libav/libavcodec/mpeg4video_parser.c b/deps/libav/libavcodec/mpeg4video_parser.c
index a5689aa..246bb9c 100644
--- a/deps/libav/libavcodec/mpeg4video_parser.c
+++ b/deps/libav/libavcodec/mpeg4video_parser.c
@@ -71,9 +71,8 @@ int ff_mpeg4_find_frame_end(ParseContext *pc, const uint8_t *buf, int buf_size)
 }
 
 /* XXX: make it use less memory */
-static int av_mpeg4_decode_header(AVCodecParserContext *s1,
-                                  AVCodecContext *avctx,
-                                  const uint8_t *buf, int buf_size)
+static int mpeg4_decode_header(AVCodecParserContext *s1, AVCodecContext *avctx,
+                               const uint8_t *buf, int buf_size)
 {
     struct Mp4vParseContext *pc = s1->priv_data;
     Mpeg4DecContext *dec_ctx = &pc->dec_ctx;
@@ -130,7 +129,7 @@ static int mpeg4video_parse(AVCodecParserContext *s,
             return buf_size;
         }
     }
-    av_mpeg4_decode_header(s, avctx, buf, buf_size);
+    mpeg4_decode_header(s, avctx, buf, buf_size);
 
     *poutbuf      = buf;
     *poutbuf_size = buf_size;
diff --git a/deps/libav/libavcodec/mpegvideo_enc.c b/deps/libav/libavcodec/mpegvideo_enc.c
index 091bee3..c5d4c5e 100644
--- a/deps/libav/libavcodec/mpegvideo_enc.c
+++ b/deps/libav/libavcodec/mpegvideo_enc.c
@@ -2292,7 +2292,7 @@ static inline void encode_mb_hq(MpegEncContext *s, MpegEncContext *backup, MpegE
 }
 
 static int sse(MpegEncContext *s, uint8_t *src1, uint8_t *src2, int w, int h, int stride){
-    uint32_t *sq = ff_squareTbl + 256;
+    uint32_t *sq = ff_square_tab + 256;
     int acc=0;
     int x,y;
 
@@ -2357,8 +2357,6 @@ static int pre_estimate_motion_thread(AVCodecContext *c, void *arg){
 static int estimate_motion_thread(AVCodecContext *c, void *arg){
     MpegEncContext *s= *(void**)arg;
 
-    ff_check_alignment();
-
     s->me.dia_size= s->avctx->dia_size;
     s->first_slice_line=1;
     for(s->mb_y= s->start_mb_y; s->mb_y < s->end_mb_y; s->mb_y++) {
@@ -2385,8 +2383,6 @@ static int mb_var_thread(AVCodecContext *c, void *arg){
     MpegEncContext *s= *(void**)arg;
     int mb_x, mb_y;
 
-    ff_check_alignment();
-
     for(mb_y=s->start_mb_y; mb_y < s->end_mb_y; mb_y++) {
         for(mb_x=0; mb_x < s->mb_width; mb_x++) {
             int xx = mb_x * 16;
@@ -2477,8 +2473,6 @@ static int encode_thread(AVCodecContext *c, void *arg){
     uint8_t bit_buf_tex[2][MAX_MB_BYTES];
     PutBitContext pb[2], pb2[2], tex_pb[2];
 
-    ff_check_alignment();
-
     for(i=0; i<2; i++){
         init_put_bits(&pb    [i], bit_buf    [i], MAX_MB_BYTES);
         init_put_bits(&pb2   [i], bit_buf2   [i], MAX_MB_BYTES);
diff --git a/deps/libav/libavcodec/mpegvideo_motion.c b/deps/libav/libavcodec/mpegvideo_motion.c
index 42def5e..756dcad 100644
--- a/deps/libav/libavcodec/mpegvideo_motion.c
+++ b/deps/libav/libavcodec/mpegvideo_motion.c
@@ -404,7 +404,7 @@ static void mpeg_motion_field(MpegEncContext *s, uint8_t *dest_y,
                              motion_x, motion_y, h, 0, mb_y);
 }
 
-// FIXME move to dsputil, avg variant, 16x16 version
+// FIXME: SIMDify, avg variant, 16x16 version
 static inline void put_obmc(uint8_t *dst, uint8_t *src[5], int stride)
 {
     int x;
diff --git a/deps/libav/libavcodec/nellymoserenc.c b/deps/libav/libavcodec/nellymoserenc.c
index fc803a2..5732163 100644
--- a/deps/libav/libavcodec/nellymoserenc.c
+++ b/deps/libav/libavcodec/nellymoserenc.c
@@ -35,13 +35,15 @@
  * http://wiki.multimedia.cx/index.php?title=Nellymoser
  */
 
+#include "libavutil/common.h"
 #include "libavutil/float_dsp.h"
 #include "libavutil/mathematics.h"
-#include "nellymoser.h"
-#include "avcodec.h"
+
 #include "audio_frame_queue.h"
+#include "avcodec.h"
 #include "fft.h"
 #include "internal.h"
+#include "nellymoser.h"
 #include "sinewin.h"
 
 #define BITSTREAM_WRITER_LE
diff --git a/deps/libav/libavcodec/nuv.c b/deps/libav/libavcodec/nuv.c
index 4d244bd..2af6529 100644
--- a/deps/libav/libavcodec/nuv.c
+++ b/deps/libav/libavcodec/nuv.c
@@ -24,6 +24,7 @@
 
 #include "libavutil/bswap.h"
 #include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
 #include "libavutil/lzo.h"
 #include "libavutil/imgutils.h"
 #include "avcodec.h"
diff --git a/deps/libav/libavcodec/options_table.h b/deps/libav/libavcodec/options_table.h
index 8b3a4b6..1006a86 100644
--- a/deps/libav/libavcodec/options_table.h
+++ b/deps/libav/libavcodec/options_table.h
@@ -189,7 +189,9 @@ static const AVOption avcodec_options[] = {
 {"simplemmx", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLEMMX }, INT_MIN, INT_MAX, V|E|D, "idct"},
 {"arm", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_ARM }, INT_MIN, INT_MAX, V|E|D, "idct"},
 {"altivec", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_ALTIVEC }, INT_MIN, INT_MAX, V|E|D, "idct"},
+#if FF_API_ARCH_SH4
 {"sh4", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SH4 }, INT_MIN, INT_MAX, V|E|D, "idct"},
+#endif
 {"simplearm", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLEARM }, INT_MIN, INT_MAX, V|E|D, "idct"},
 {"simplearmv5te", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLEARMV5TE }, INT_MIN, INT_MAX, V|E|D, "idct"},
 {"simplearmv6", NULL, 0, AV_OPT_TYPE_CONST, {.i64 = FF_IDCT_SIMPLEARMV6 }, INT_MIN, INT_MAX, V|E|D, "idct"},
diff --git a/deps/libav/libavcodec/parser.c b/deps/libav/libavcodec/parser.c
index 511f1f3..080bbc3 100644
--- a/deps/libav/libavcodec/parser.c
+++ b/deps/libav/libavcodec/parser.c
@@ -23,14 +23,18 @@
 #include <stdint.h>
 #include <string.h>
 
-#include "parser.h"
 #include "libavutil/mem.h"
 
+#include "parser.h"
+
 static AVCodecParser *av_first_parser = NULL;
 
-AVCodecParser* av_parser_next(AVCodecParser *p){
-    if(p) return p->next;
-    else  return av_first_parser;
+AVCodecParser *av_parser_next(AVCodecParser *p)
+{
+    if (p)
+        return p->next;
+    else
+        return av_first_parser;
 }
 
 void av_register_codec_parser(AVCodecParser *parser)
@@ -45,10 +49,10 @@ AVCodecParserContext *av_parser_init(int codec_id)
     AVCodecParser *parser;
     int ret;
 
-    if(codec_id == AV_CODEC_ID_NONE)
+    if (codec_id == AV_CODEC_ID_NONE)
         return NULL;
 
-    for(parser = av_first_parser; parser != NULL; parser = parser->next) {
+    for (parser = av_first_parser; parser != NULL; parser = parser->next) {
         if (parser->codec_ids[0] == codec_id ||
             parser->codec_ids[1] == codec_id ||
             parser->codec_ids[2] == codec_id ||
@@ -57,7 +61,8 @@ AVCodecParserContext *av_parser_init(int codec_id)
             goto found;
     }
     return NULL;
- found:
+
+found:
     s = av_mallocz(sizeof(AVCodecParserContext));
     if (!s)
         return NULL;
@@ -77,9 +82,9 @@ AVCodecParserContext *av_parser_init(int codec_id)
             return NULL;
         }
     }
-    s->fetch_timestamp=1;
-    s->pict_type = AV_PICTURE_TYPE_I;
-    s->key_frame = -1;
+    s->fetch_timestamp      = 1;
+    s->pict_type            = AV_PICTURE_TYPE_I;
+    s->key_frame            = -1;
     s->convergence_duration = 0;
     s->dts_sync_point       = INT_MIN;
     s->dts_ref_dts_delta    = INT_MIN;
@@ -87,72 +92,70 @@ AVCodecParserContext *av_parser_init(int codec_id)
     return s;
 }
 
-void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove){
+void ff_fetch_timestamp(AVCodecParserContext *s, int off, int remove)
+{
     int i;
 
-    s->dts= s->pts= AV_NOPTS_VALUE;
-    s->pos= -1;
-    s->offset= 0;
-    for(i = 0; i < AV_PARSER_PTS_NB; i++) {
-        if (   s->cur_offset + off >= s->cur_frame_offset[i]
-            && (s->frame_offset < s->cur_frame_offset[i] ||
-              (!s->frame_offset && !s->next_frame_offset)) // first field/frame
-            // check disabled since MPEG-TS does not send complete PES packets
-            && /*s->next_frame_offset + off <*/  s->cur_frame_end[i]){
-            s->dts= s->cur_frame_dts[i];
-            s->pts= s->cur_frame_pts[i];
-            s->pos= s->cur_frame_pos[i];
+    s->dts    =
+    s->pts    = AV_NOPTS_VALUE;
+    s->pos    = -1;
+    s->offset = 0;
+    for (i = 0; i < AV_PARSER_PTS_NB; i++) {
+        if (s->cur_offset + off >= s->cur_frame_offset[i] &&
+            (s->frame_offset < s->cur_frame_offset[i] ||
+             (!s->frame_offset && !s->next_frame_offset)) &&
+            s->cur_frame_end[i]) {
+            s->dts    = s->cur_frame_dts[i];
+            s->pts    = s->cur_frame_pts[i];
+            s->pos    = s->cur_frame_pos[i];
             s->offset = s->next_frame_offset - s->cur_frame_offset[i];
-            if(remove)
-                s->cur_frame_offset[i]= INT64_MAX;
-            if(s->cur_offset + off < s->cur_frame_end[i])
+            if (remove)
+                s->cur_frame_offset[i] = INT64_MAX;
+            if (s->cur_offset + off < s->cur_frame_end[i])
                 break;
         }
     }
 }
 
-int av_parser_parse2(AVCodecParserContext *s,
-                     AVCodecContext *avctx,
+int av_parser_parse2(AVCodecParserContext *s, AVCodecContext *avctx,
                      uint8_t **poutbuf, int *poutbuf_size,
                      const uint8_t *buf, int buf_size,
-                     int64_t pts, int64_t dts,
-                     int64_t pos)
+                     int64_t pts, int64_t dts, int64_t pos)
 {
     int index, i;
     uint8_t dummy_buf[FF_INPUT_BUFFER_PADDING_SIZE];
 
-    if(!(s->flags & PARSER_FLAG_FETCHED_OFFSET)) {
+    if (!(s->flags & PARSER_FLAG_FETCHED_OFFSET)) {
         s->next_frame_offset =
         s->cur_offset        = pos;
-        s->flags |= PARSER_FLAG_FETCHED_OFFSET;
+        s->flags            |= PARSER_FLAG_FETCHED_OFFSET;
     }
 
     if (buf_size == 0) {
         /* padding is always necessary even if EOF, so we add it here */
         memset(dummy_buf, 0, sizeof(dummy_buf));
         buf = dummy_buf;
-    } else if (s->cur_offset + buf_size !=
-               s->cur_frame_end[s->cur_frame_start_index]) { /* skip remainder packets */
+    } else if (s->cur_offset + buf_size != s->cur_frame_end[s->cur_frame_start_index]) { /* skip remainder packets */
         /* add a new packet descriptor */
-            i = (s->cur_frame_start_index + 1) & (AV_PARSER_PTS_NB - 1);
-            s->cur_frame_start_index = i;
-            s->cur_frame_offset[i] = s->cur_offset;
-            s->cur_frame_end[i] = s->cur_offset + buf_size;
-            s->cur_frame_pts[i] = pts;
-            s->cur_frame_dts[i] = dts;
-            s->cur_frame_pos[i] = pos;
+        i = (s->cur_frame_start_index + 1) & (AV_PARSER_PTS_NB - 1);
+        s->cur_frame_start_index = i;
+        s->cur_frame_offset[i]   = s->cur_offset;
+        s->cur_frame_end[i]      = s->cur_offset + buf_size;
+        s->cur_frame_pts[i]      = pts;
+        s->cur_frame_dts[i]      = dts;
+        s->cur_frame_pos[i]      = pos;
     }
 
-    if (s->fetch_timestamp){
-        s->fetch_timestamp=0;
-        s->last_pts = s->pts;
-        s->last_dts = s->dts;
-        s->last_pos = s->pos;
+    if (s->fetch_timestamp) {
+        s->fetch_timestamp = 0;
+        s->last_pts        = s->pts;
+        s->last_dts        = s->dts;
+        s->last_pos        = s->pos;
         ff_fetch_timestamp(s, 0, 0);
     }
-
     /* WARNING: the returned index can be negative */
-    index = s->parser->parser_parse(s, avctx, (const uint8_t **)poutbuf, poutbuf_size, buf, buf_size);
+    index = s->parser->parser_parse(s, avctx, (const uint8_t **) poutbuf,
+                                    poutbuf_size, buf, buf_size);
     /* update the file pointer */
     if (*poutbuf_size) {
         /* fill the data for the current frame */
@@ -160,7 +163,7 @@ int av_parser_parse2(AVCodecParserContext *s,
 
         /* offset of the next frame */
         s->next_frame_offset = s->cur_offset + index;
-        s->fetch_timestamp=1;
+        s->fetch_timestamp   = 1;
     }
     if (index < 0)
         index = 0;
@@ -168,32 +171,32 @@ int av_parser_parse2(AVCodecParserContext *s,
     return index;
 }
 
-int av_parser_change(AVCodecParserContext *s,
-                     AVCodecContext *avctx,
+int av_parser_change(AVCodecParserContext *s, AVCodecContext *avctx,
                      uint8_t **poutbuf, int *poutbuf_size,
-                     const uint8_t *buf, int buf_size, int keyframe){
-
-    if(s && s->parser->split){
-        if((avctx->flags & CODEC_FLAG_GLOBAL_HEADER) || (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER)){
-            int i= s->parser->split(avctx, buf, buf_size);
-            buf += i;
+                     const uint8_t *buf, int buf_size, int keyframe)
+{
+    if (s && s->parser->split) {
+        if (avctx->flags  & CODEC_FLAG_GLOBAL_HEADER ||
+            avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER) {
+            int i = s->parser->split(avctx, buf, buf_size);
+            buf      += i;
             buf_size -= i;
         }
     }
 
     /* cast to avoid warning about discarding qualifiers */
-    *poutbuf= (uint8_t *) buf;
-    *poutbuf_size= buf_size;
-    if(avctx->extradata){
-        if(  (keyframe && (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER))
-            /*||(s->pict_type != AV_PICTURE_TYPE_I && (s->flags & PARSER_FLAG_DUMP_EXTRADATA_AT_NOKEY))*/
-            /*||(? && (s->flags & PARSER_FLAG_DUMP_EXTRADATA_AT_BEGIN)*/){
-            int size= buf_size + avctx->extradata_size;
-            *poutbuf_size= size;
-            *poutbuf= av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
+    *poutbuf      = (uint8_t *) buf;
+    *poutbuf_size = buf_size;
+    if (avctx->extradata) {
+        if (keyframe && (avctx->flags2 & CODEC_FLAG2_LOCAL_HEADER)) {
+            int size = buf_size + avctx->extradata_size;
+
+            *poutbuf_size = size;
+            *poutbuf      = av_malloc(size + FF_INPUT_BUFFER_PADDING_SIZE);
 
             memcpy(*poutbuf, avctx->extradata, avctx->extradata_size);
-            memcpy((*poutbuf) + avctx->extradata_size, buf, buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
+            memcpy(*poutbuf + avctx->extradata_size, buf,
+                   buf_size + FF_INPUT_BUFFER_PADDING_SIZE);
             return 1;
         }
     }
@@ -203,7 +206,7 @@ int av_parser_change(AVCodecParserContext *s,
 
 void av_parser_close(AVCodecParserContext *s)
 {
-    if(s){
+    if (s) {
         if (s->parser->parser_close)
             s->parser->parser_close(s);
         av_free(s->priv_data);
@@ -211,33 +214,33 @@ void av_parser_close(AVCodecParserContext *s)
     }
 }
 
-/*****************************************************/
-
-int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_size)
+int ff_combine_frame(ParseContext *pc, int next,
+                     const uint8_t **buf, int *buf_size)
 {
-    if(pc->overread){
+    if (pc->overread) {
         av_dlog(NULL, "overread %d, state:%X next:%d index:%d o_index:%d\n",
                 pc->overread, pc->state, next, pc->index, pc->overread_index);
-        av_dlog(NULL, "%X %X %X %X\n", (*buf)[0], (*buf)[1], (*buf)[2], (*buf)[3]);
+        av_dlog(NULL, "%X %X %X %X\n",
+                (*buf)[0], (*buf)[1], (*buf)[2], (*buf)[3]);
     }
 
     /* Copy overread bytes from last frame into buffer. */
-    for(; pc->overread>0; pc->overread--){
-        pc->buffer[pc->index++]= pc->buffer[pc->overread_index++];
-    }
+    for (; pc->overread > 0; pc->overread--)
+        pc->buffer[pc->index++] = pc->buffer[pc->overread_index++];
 
     /* flush remaining if EOF */
-    if(!*buf_size && next == END_NOT_FOUND){
-        next= 0;
-    }
+    if (!*buf_size && next == END_NOT_FOUND)
+        next = 0;
 
-    pc->last_index= pc->index;
+    pc->last_index = pc->index;
 
     /* copy into buffer end return */
-    if(next == END_NOT_FOUND){
-        void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, (*buf_size) + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
+    if (next == END_NOT_FOUND) {
+        void *new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size,
+                                           *buf_size + pc->index +
+                                           FF_INPUT_BUFFER_PADDING_SIZE);
 
-        if(!new_buffer)
+        if (!new_buffer)
             return AVERROR(ENOMEM);
         pc->buffer = new_buffer;
         memcpy(&pc->buffer[pc->index], *buf, *buf_size);
@@ -245,34 +248,37 @@ int ff_combine_frame(ParseContext *pc, int next, const uint8_t **buf, int *buf_s
         return -1;
     }
 
-    *buf_size=
-    pc->overread_index= pc->index + next;
+    *buf_size          =
+    pc->overread_index = pc->index + next;
 
     /* append to buffer */
-    if(pc->index){
-        void* new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size, next + pc->index + FF_INPUT_BUFFER_PADDING_SIZE);
+    if (pc->index) {
+        void *new_buffer = av_fast_realloc(pc->buffer, &pc->buffer_size,
+                                           next + pc->index +
+                                           FF_INPUT_BUFFER_PADDING_SIZE);
 
-        if(!new_buffer)
+        if (!new_buffer)
             return AVERROR(ENOMEM);
         pc->buffer = new_buffer;
         if (next > -FF_INPUT_BUFFER_PADDING_SIZE)
             memcpy(&pc->buffer[pc->index], *buf,
                    next + FF_INPUT_BUFFER_PADDING_SIZE);
         pc->index = 0;
-        *buf= pc->buffer;
+        *buf      = pc->buffer;
     }
 
     /* store overread bytes */
-    for(;next < 0; next++){
-        pc->state = (pc->state<<8) | pc->buffer[pc->last_index + next];
-        pc->state64 = (pc->state64<<8) | pc->buffer[pc->last_index + next];
+    for (; next < 0; next++) {
+        pc->state   = pc->state   << 8 | pc->buffer[pc->last_index + next];
+        pc->state64 = pc->state64 << 8 | pc->buffer[pc->last_index + next];
         pc->overread++;
     }
 
-    if(pc->overread){
+    if (pc->overread) {
         av_dlog(NULL, "overread %d, state:%X next:%d index:%d o_index:%d\n",
                 pc->overread, pc->state, next, pc->index, pc->overread_index);
-        av_dlog(NULL, "%X %X %X %X\n", (*buf)[0], (*buf)[1],(*buf)[2],(*buf)[3]);
+        av_dlog(NULL, "%X %X %X %X\n",
+                (*buf)[0], (*buf)[1], (*buf)[2], (*buf)[3]);
     }
 
     return 0;
@@ -285,18 +291,15 @@ void ff_parse_close(AVCodecParserContext *s)
     av_freep(&pc->buffer);
 }
 
-/*************************/
-
-int ff_mpeg4video_split(AVCodecContext *avctx,
-                           const uint8_t *buf, int buf_size)
+int ff_mpeg4video_split(AVCodecContext *avctx, const uint8_t *buf, int buf_size)
 {
     int i;
-    uint32_t state= -1;
+    uint32_t state = -1;
 
-    for(i=0; i<buf_size; i++){
-        state= (state<<8) | buf[i];
-        if(state == 0x1B3 || state == 0x1B6)
-            return i-3;
+    for (i = 0; i < buf_size; i++) {
+        state = state << 8 | buf[i];
+        if (state == 0x1B3 || state == 0x1B6)
+            return i - 3;
     }
     return 0;
 }
diff --git a/deps/libav/libavcodec/pgssubdec.c b/deps/libav/libavcodec/pgssubdec.c
index 2102a51..9b8e919 100644
--- a/deps/libav/libavcodec/pgssubdec.c
+++ b/deps/libav/libavcodec/pgssubdec.c
@@ -237,7 +237,7 @@ static void parse_palette_segment(AVCodecContext *avctx,
     PGSSubContext *ctx = avctx->priv_data;
 
     const uint8_t *buf_end = buf + buf_size;
-    const uint8_t *cm      = ff_cropTbl + MAX_NEG_CROP;
+    const uint8_t *cm      = ff_crop_tab + MAX_NEG_CROP;
     int color_id;
     int y, cb, cr, alpha;
     int r, g, b, r_add, g_add, b_add;
diff --git a/deps/libav/libavcodec/ppc/dsputil_altivec.c b/deps/libav/libavcodec/ppc/dsputil_altivec.c
index f90ec74..9342728 100644
--- a/deps/libav/libavcodec/ppc/dsputil_altivec.c
+++ b/deps/libav/libavcodec/ppc/dsputil_altivec.c
@@ -27,6 +27,7 @@
 #include "libavutil/attributes.h"
 #include "libavutil/ppc/types_altivec.h"
 #include "libavutil/ppc/util_altivec.h"
+#include "libavcodec/avcodec.h"
 #include "libavcodec/dsputil.h"
 #include "dsputil_altivec.h"
 
@@ -285,10 +286,10 @@ static int sad8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, in
         /* Read potentially unaligned pixels into t1 and t2
            Since we're reading 16 pixels, and actually only want 8,
            mask out the last 8 pixels. The 0s don't change the sum. */
-        vector unsigned char pix1l = vec_ld( 0, pix1);
-        vector unsigned char pix1r = vec_ld(15, pix1);
-        vector unsigned char pix2l = vec_ld( 0, pix2);
-        vector unsigned char pix2r = vec_ld(15, pix2);
+        vector unsigned char pix1l = vec_ld(0, pix1);
+        vector unsigned char pix1r = vec_ld(7, pix1);
+        vector unsigned char pix2l = vec_ld(0, pix2);
+        vector unsigned char pix2r = vec_ld(7, pix2);
         t1 = vec_and(vec_perm(pix1l, pix1r, perm1), permclear);
         t2 = vec_and(vec_perm(pix2l, pix2r, perm2), permclear);
 
@@ -367,10 +368,10 @@ static int sse8_altivec(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, in
         /* Read potentially unaligned pixels into t1 and t2
            Since we're reading 16 pixels, and actually only want 8,
            mask out the last 8 pixels. The 0s don't change the sum. */
-        vector unsigned char pix1l = vec_ld( 0, pix1);
-        vector unsigned char pix1r = vec_ld(15, pix1);
-        vector unsigned char pix2l = vec_ld( 0, pix2);
-        vector unsigned char pix2r = vec_ld(15, pix2);
+        vector unsigned char pix1l = vec_ld(0, pix1);
+        vector unsigned char pix1r = vec_ld(7, pix1);
+        vector unsigned char pix2l = vec_ld(0, pix2);
+        vector unsigned char pix2r = vec_ld(7, pix2);
         t1 = vec_and(vec_perm(pix1l, pix1r, perm1), permclear);
         t2 = vec_and(vec_perm(pix2l, pix2r, perm2), permclear);
 
@@ -489,8 +490,8 @@ static void get_pixels_altivec(int16_t *restrict block, const uint8_t *pixels, i
         // Read potentially unaligned pixels.
         // We're reading 16 pixels, and actually only want 8,
         // but we simply ignore the extras.
-        vector unsigned char pixl = vec_ld( 0, pixels);
-        vector unsigned char pixr = vec_ld(15, pixels);
+        vector unsigned char pixl = vec_ld(0, pixels);
+        vector unsigned char pixr = vec_ld(7, pixels);
         bytes = vec_perm(pixl, pixr, perm);
 
         // convert the bytes into shorts
diff --git a/deps/libav/libavcodec/ppc/dsputil_altivec.h b/deps/libav/libavcodec/ppc/dsputil_altivec.h
index de5054b..ce18b1a 100644
--- a/deps/libav/libavcodec/ppc/dsputil_altivec.h
+++ b/deps/libav/libavcodec/ppc/dsputil_altivec.h
@@ -37,7 +37,6 @@ void ff_idct_put_altivec(uint8_t *dest, int line_size, int16_t *block);
 void ff_idct_add_altivec(uint8_t *dest, int line_size, int16_t *block);
 
 void ff_dsputil_init_altivec(DSPContext* c, AVCodecContext *avctx);
-void ff_float_init_altivec(DSPContext* c, AVCodecContext *avctx);
 void ff_int_init_altivec(DSPContext* c, AVCodecContext *avctx);
 
 #endif /* AVCODEC_PPC_DSPUTIL_ALTIVEC_H */
diff --git a/deps/libav/libavcodec/ppc/dsputil_ppc.c b/deps/libav/libavcodec/ppc/dsputil_ppc.c
index 6ae6e3f..8600abb 100644
--- a/deps/libav/libavcodec/ppc/dsputil_ppc.c
+++ b/deps/libav/libavcodec/ppc/dsputil_ppc.c
@@ -26,6 +26,8 @@
 #include "libavutil/cpu.h"
 #include "libavutil/mem.h"
 #include "libavutil/ppc/cpu.h"
+#include "libavcodec/avcodec.h"
+#include "libavcodec/dsputil.h"
 #include "dsputil_altivec.h"
 
 /* ***** WARNING ***** WARNING ***** WARNING ***** */
diff --git a/deps/libav/libavcodec/ppc/vc1dsp_altivec.c b/deps/libav/libavcodec/ppc/vc1dsp_altivec.c
index 4695b1c..d48c4b9 100644
--- a/deps/libav/libavcodec/ppc/vc1dsp_altivec.c
+++ b/deps/libav/libavcodec/ppc/vc1dsp_altivec.c
@@ -21,6 +21,7 @@
 
 #include "config.h"
 #include "libavutil/attributes.h"
+#include "libavutil/cpu.h"
 #include "libavutil/ppc/types_altivec.h"
 #include "libavutil/ppc/util_altivec.h"
 #include "libavcodec/vc1dsp.h"
diff --git a/deps/libav/libavcodec/proresdsp.c b/deps/libav/libavcodec/proresdsp.c
index 1c0f391..1d60897 100644
--- a/deps/libav/libavcodec/proresdsp.c
+++ b/deps/libav/libavcodec/proresdsp.c
@@ -20,9 +20,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "config.h"
 #include "libavutil/attributes.h"
 #include "libavutil/common.h"
-#include "dct.h"
 #include "dsputil.h"
 #include "proresdsp.h"
 #include "simple_idct.h"
@@ -33,7 +33,6 @@
 
 #define CLIP_AND_BIAS(x) (av_clip((x) + BIAS, CLIP_MIN, CLIP_MAX))
 
-#if CONFIG_PRORES_DECODER
 /**
  * Add bias value, clamp and output pixels of a slice
  */
@@ -55,38 +54,15 @@ static void prores_idct_put_c(uint16_t *out, int linesize, int16_t *block, const
     ff_prores_idct(block, qmat);
     put_pixels(out, linesize >> 1, block);
 }
-#endif
-
-#if CONFIG_PRORES_ENCODER
-static void prores_fdct_c(const uint16_t *src, int linesize, int16_t *block)
-{
-    int x, y;
-    const uint16_t *tsrc = src;
-
-    for (y = 0; y < 8; y++) {
-        for (x = 0; x < 8; x++)
-            block[y * 8 + x] = tsrc[x];
-        tsrc += linesize >> 1;
-    }
-    ff_jpeg_fdct_islow_10(block);
-}
-#endif
 
 av_cold void ff_proresdsp_init(ProresDSPContext *dsp)
 {
-#if CONFIG_PRORES_DECODER
     dsp->idct_put = prores_idct_put_c;
     dsp->idct_permutation_type = FF_NO_IDCT_PERM;
 
-    if (ARCH_X86) ff_proresdsp_x86_init(dsp);
+    if (ARCH_X86)
+        ff_proresdsp_init_x86(dsp);
 
     ff_init_scantable_permutation(dsp->idct_permutation,
                                   dsp->idct_permutation_type);
-#endif
-#if CONFIG_PRORES_ENCODER
-    dsp->fdct                 = prores_fdct_c;
-    dsp->dct_permutation_type = FF_NO_IDCT_PERM;
-    ff_init_scantable_permutation(dsp->dct_permutation,
-                                  dsp->dct_permutation_type);
-#endif
 }
diff --git a/deps/libav/libavcodec/proresdsp.h b/deps/libav/libavcodec/proresdsp.h
index 5e35140..e8a3ea9 100644
--- a/deps/libav/libavcodec/proresdsp.h
+++ b/deps/libav/libavcodec/proresdsp.h
@@ -30,14 +30,11 @@
 typedef struct ProresDSPContext {
     int idct_permutation_type;
     uint8_t idct_permutation[64];
-    int dct_permutation_type;
-    uint8_t dct_permutation[64];
     void (* idct_put) (uint16_t *out, int linesize, int16_t *block, const int16_t *qmat);
-    void (* fdct) (const uint16_t *src, int linesize, int16_t *block);
 } ProresDSPContext;
 
 void ff_proresdsp_init(ProresDSPContext *dsp);
 
-void ff_proresdsp_x86_init(ProresDSPContext *dsp);
+void ff_proresdsp_init_x86(ProresDSPContext *dsp);
 
 #endif /* AVCODEC_PRORESDSP_H */
diff --git a/deps/libav/libavcodec/proresenc.c b/deps/libav/libavcodec/proresenc.c
index 7e9ce54..51e3783 100644
--- a/deps/libav/libavcodec/proresenc.c
+++ b/deps/libav/libavcodec/proresenc.c
@@ -23,11 +23,11 @@
 #include "libavutil/opt.h"
 #include "libavutil/pixdesc.h"
 #include "avcodec.h"
+#include "dct.h"
 #include "dsputil.h"
 #include "put_bits.h"
 #include "bytestream.h"
 #include "internal.h"
-#include "proresdsp.h"
 #include "proresdata.h"
 
 #define CFACTOR_Y422 2
@@ -190,9 +190,11 @@ typedef struct ProresContext {
     int16_t quants[MAX_STORED_Q][64];
     int16_t custom_q[64];
     const uint8_t *quant_mat;
+    const uint8_t *scantable;
 
-    ProresDSPContext dsp;
-    ScanTable  scantable;
+    void (* fdct)(DSPContext *dsp, const uint16_t *src,
+                  int linesize, int16_t *block);
+    DSPContext dsp;
 
     int mb_width, mb_height;
     int mbs_per_slice;
@@ -261,27 +263,27 @@ static void get_slice_data(ProresContext *ctx, const uint16_t *src,
                        mb_width * sizeof(*emu_buf));
         }
         if (!is_chroma) {
-            ctx->dsp.fdct(esrc, elinesize, blocks);
+            ctx->fdct(&ctx->dsp, esrc, elinesize, blocks);
             blocks += 64;
             if (blocks_per_mb > 2) {
-                ctx->dsp.fdct(esrc + 8, elinesize, blocks);
+                ctx->fdct(&ctx->dsp, esrc + 8, elinesize, blocks);
                 blocks += 64;
             }
-            ctx->dsp.fdct(esrc + elinesize * 4, elinesize, blocks);
+            ctx->fdct(&ctx->dsp, esrc + elinesize * 4, elinesize, blocks);
             blocks += 64;
             if (blocks_per_mb > 2) {
-                ctx->dsp.fdct(esrc + elinesize * 4 + 8, elinesize, blocks);
+                ctx->fdct(&ctx->dsp, esrc + elinesize * 4 + 8, elinesize, blocks);
                 blocks += 64;
             }
         } else {
-            ctx->dsp.fdct(esrc, elinesize, blocks);
+            ctx->fdct(&ctx->dsp, esrc, elinesize, blocks);
             blocks += 64;
-            ctx->dsp.fdct(esrc + elinesize * 4, elinesize, blocks);
+            ctx->fdct(&ctx->dsp, esrc + elinesize * 4, elinesize, blocks);
             blocks += 64;
             if (blocks_per_mb > 2) {
-                ctx->dsp.fdct(esrc + 8, elinesize, blocks);
+                ctx->fdct(&ctx->dsp, esrc + 8, elinesize, blocks);
                 blocks += 64;
-                ctx->dsp.fdct(esrc + elinesize * 4 + 8, elinesize, blocks);
+                ctx->fdct(&ctx->dsp, esrc + elinesize * 4 + 8, elinesize, blocks);
                 blocks += 64;
             }
         }
@@ -426,7 +428,7 @@ static int encode_slice_plane(ProresContext *ctx, PutBitContext *pb,
 
     encode_dcs(pb, blocks, blocks_per_slice, qmat[0]);
     encode_acs(pb, blocks, blocks_per_slice, plane_size_factor,
-               ctx->scantable.permutated, qmat);
+               ctx->scantable, qmat);
     flush_put_bits(pb);
 
     return (put_bits_count(pb) - saved_pos) >> 3;
@@ -673,7 +675,7 @@ static int estimate_slice_plane(ProresContext *ctx, int *error, int plane,
 
     bits  = estimate_dcs(error, td->blocks[plane], blocks_per_slice, qmat[0]);
     bits += estimate_acs(error, td->blocks[plane], blocks_per_slice,
-                         plane_size_factor, ctx->scantable.permutated, qmat);
+                         plane_size_factor, ctx->scantable, qmat);
 
     return FFALIGN(bits, 8);
 }
@@ -1066,6 +1068,20 @@ static av_cold int encode_close(AVCodecContext *avctx)
     return 0;
 }
 
+static void prores_fdct(DSPContext *dsp, const uint16_t *src,
+                        int linesize, int16_t *block)
+{
+    int x, y;
+    const uint16_t *tsrc = src;
+
+    for (y = 0; y < 8; y++) {
+        for (x = 0; x < 8; x++)
+            block[y * 8 + x] = tsrc[x];
+        tsrc += linesize >> 1;
+    }
+    dsp->fdct(block);
+}
+
 static av_cold int encode_init(AVCodecContext *avctx)
 {
     ProresContext *ctx = avctx->priv_data;
@@ -1079,10 +1095,10 @@ static av_cold int encode_init(AVCodecContext *avctx)
     if (!avctx->coded_frame)
         return AVERROR(ENOMEM);
 
-    ff_proresdsp_init(&ctx->dsp);
-    ff_init_scantable(ctx->dsp.dct_permutation, &ctx->scantable,
-                      interlaced ? ff_prores_interlaced_scan
-                                 : ff_prores_progressive_scan);
+    ctx->fdct      = prores_fdct;
+    ctx->scantable = interlaced ? ff_prores_interlaced_scan
+                                : ff_prores_progressive_scan;
+    ff_dsputil_init(&ctx->dsp, avctx);
 
     mps = ctx->mbs_per_slice;
     if (mps & (mps - 1)) {
diff --git a/deps/libav/libavcodec/pthread_frame.c b/deps/libav/libavcodec/pthread_frame.c
index 36b4fff..1af8ff5 100644
--- a/deps/libav/libavcodec/pthread_frame.c
+++ b/deps/libav/libavcodec/pthread_frame.c
@@ -672,8 +672,6 @@ void ff_thread_flush(AVCodecContext *avctx)
     if (fctx->prev_thread) {
         if (fctx->prev_thread != &fctx->threads[0])
             update_context_from_thread(fctx->threads[0].avctx, fctx->prev_thread->avctx, 0);
-        if (avctx->codec->flush)
-            avctx->codec->flush(fctx->threads[0].avctx);
     }
 
     fctx->next_decoding = fctx->next_finished = 0;
@@ -686,6 +684,9 @@ void ff_thread_flush(AVCodecContext *avctx)
         av_frame_unref(p->frame);
 
         release_delayed_buffers(p);
+
+        if (avctx->codec->flush)
+            avctx->codec->flush(p->avctx);
     }
 }
 
diff --git a/deps/libav/libavcodec/put_bits.h b/deps/libav/libavcodec/put_bits.h
index e3412cb..17666fa 100644
--- a/deps/libav/libavcodec/put_bits.h
+++ b/deps/libav/libavcodec/put_bits.h
@@ -27,15 +27,10 @@
 #define AVCODEC_PUT_BITS_H
 
 #include <stdint.h>
-#include <stdlib.h>
+#include <stddef.h>
 #include <assert.h>
 
-#include "libavutil/bswap.h"
-#include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
-#include "libavutil/log.h"
-#include "mathops.h"
-#include "config.h"
 
 typedef struct PutBitContext {
     uint32_t bit_buf;
diff --git a/deps/libav/libavcodec/ra144enc.c b/deps/libav/libavcodec/ra144enc.c
index 9f953d4..7627adc 100644
--- a/deps/libav/libavcodec/ra144enc.c
+++ b/deps/libav/libavcodec/ra144enc.c
@@ -29,9 +29,10 @@
 
 #include "avcodec.h"
 #include "audio_frame_queue.h"
+#include "celp_filters.h"
 #include "internal.h"
+#include "mathops.h"
 #include "put_bits.h"
-#include "celp_filters.h"
 #include "ra144.h"
 
 
diff --git a/deps/libav/libavcodec/rawenc.c b/deps/libav/libavcodec/rawenc.c
index 6c90d33..bca0d08 100644
--- a/deps/libav/libavcodec/rawenc.c
+++ b/deps/libav/libavcodec/rawenc.c
@@ -31,7 +31,7 @@
 #include "libavutil/intreadwrite.h"
 #include "libavutil/internal.h"
 
-static av_cold int raw_init_encoder(AVCodecContext *avctx)
+static av_cold int raw_encode_init(AVCodecContext *avctx)
 {
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
 
@@ -75,6 +75,6 @@ AVCodec ff_rawvideo_encoder = {
     .type           = AVMEDIA_TYPE_VIDEO,
     .id             = AV_CODEC_ID_RAWVIDEO,
     .priv_data_size = sizeof(AVFrame),
-    .init           = raw_init_encoder,
+    .init           = raw_encode_init,
     .encode2        = raw_encode,
 };
diff --git a/deps/libav/libavcodec/rnd_avg.h b/deps/libav/libavcodec/rnd_avg.h
index 7301578..8feac28 100644
--- a/deps/libav/libavcodec/rnd_avg.h
+++ b/deps/libav/libavcodec/rnd_avg.h
@@ -22,14 +22,16 @@
 #include <stddef.h>
 #include <stdint.h>
 
-#define CALL_2X_PIXELS(a, b, n)\
-static void a(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h){\
-    b(block  , pixels  , line_size, h);\
-    b(block+n, pixels+n, line_size, h);\
+#define CALL_2X_PIXELS(a, b, n)                      \
+static void a(uint8_t *block, const uint8_t *pixels, \
+              ptrdiff_t line_size, int h)            \
+{                                                    \
+    b(block, pixels, line_size, h);                  \
+    b(block + n, pixels + n, line_size, h);          \
 }
 
-#define         BYTE_VEC32(c)   ((c)*0x01010101UL)
-#define         BYTE_VEC64(c)   ((c)*0x0001000100010001UL)
+#define BYTE_VEC32(c) ((c) * 0x01010101UL)
+#define BYTE_VEC64(c) ((c) * 0x0001000100010001UL)
 
 static inline uint32_t rnd_avg32(uint32_t a, uint32_t b)
 {
diff --git a/deps/libav/libavcodec/rv10.c b/deps/libav/libavcodec/rv10.c
index ae8c5b3..771d5a8 100644
--- a/deps/libav/libavcodec/rv10.c
+++ b/deps/libav/libavcodec/rv10.c
@@ -26,18 +26,19 @@
  */
 
 #include "libavutil/imgutils.h"
+
 #include "avcodec.h"
 #include "error_resilience.h"
+#include "h263.h"
 #include "internal.h"
 #include "mpegvideo.h"
 #include "mpeg4video.h"
-#include "h263.h"
 
 #define RV_GET_MAJOR_VER(x)  ((x) >> 28)
 #define RV_GET_MINOR_VER(x) (((x) >> 20) & 0xFF)
 #define RV_GET_MICRO_VER(x) (((x) >> 12) & 0xFF)
 
-#define DC_VLC_BITS 14 //FIXME find a better solution
+#define DC_VLC_BITS 14 // FIXME find a better solution
 
 typedef struct RVDecContext {
     MpegEncContext m;
@@ -194,18 +195,18 @@ int ff_rv_decode_dc(MpegEncContext *s, int n)
         code = get_vlc2(&s->gb, rv_dc_lum.table, DC_VLC_BITS, 2);
         if (code < 0) {
             /* XXX: I don't understand why they use LONGER codes than
-               necessary. The following code would be completely useless
-               if they had thought about it !!! */
+             * necessary. The following code would be completely useless
+             * if they had thought about it !!! */
             code = get_bits(&s->gb, 7);
             if (code == 0x7c) {
-                code = (int8_t)(get_bits(&s->gb, 7) + 1);
+                code = (int8_t) (get_bits(&s->gb, 7) + 1);
             } else if (code == 0x7d) {
                 code = -128 + get_bits(&s->gb, 7);
             } else if (code == 0x7e) {
                 if (get_bits1(&s->gb) == 0)
-                    code = (int8_t)(get_bits(&s->gb, 8) + 1);
+                    code = (int8_t) (get_bits(&s->gb, 8) + 1);
                 else
-                    code = (int8_t)(get_bits(&s->gb, 8));
+                    code = (int8_t) (get_bits(&s->gb, 8));
             } else if (code == 0x7f) {
                 skip_bits(&s->gb, 11);
                 code = 1;
@@ -219,7 +220,7 @@ int ff_rv_decode_dc(MpegEncContext *s, int n)
         if (code < 0) {
             code = get_bits(&s->gb, 9);
             if (code == 0x1fc) {
-                code = (int8_t)(get_bits(&s->gb, 7) + 1);
+                code = (int8_t) (get_bits(&s->gb, 7) + 1);
             } else if (code == 0x1fd) {
                 code = -128 + get_bits(&s->gb, 7);
             } else if (code == 0x1fe) {
@@ -277,7 +278,7 @@ static int rv10_decode_picture_header(MpegEncContext *s)
         }
     }
     /* if multiple packets per frame are sent, the position at which
-       to display the macroblocks is coded here */
+     * to display the macroblocks is coded here */
 
     mb_xy = s->mb_x + s->mb_y * s->mb_width;
     if (show_bits(&s->gb, 12) == 0 || (mb_xy && mb_xy < s->mb_num)) {
@@ -290,7 +291,7 @@ static int rv10_decode_picture_header(MpegEncContext *s)
         mb_count = s->mb_width * s->mb_height;
     }
     skip_bits(&s->gb, 3);   /* ignored */
-    s->f_code = 1;
+    s->f_code          = 1;
     s->unrestricted_mv = 1;
 
     return mb_count;
@@ -304,10 +305,18 @@ static int rv20_decode_picture_header(RVDecContext *rv)
 
     i = get_bits(&s->gb, 2);
     switch (i) {
-    case 0: s->pict_type = AV_PICTURE_TYPE_I; break;
-    case 1: s->pict_type = AV_PICTURE_TYPE_I; break; //hmm ...
-    case 2: s->pict_type = AV_PICTURE_TYPE_P; break;
-    case 3: s->pict_type = AV_PICTURE_TYPE_B; break;
+    case 0:
+        s->pict_type = AV_PICTURE_TYPE_I;
+        break;
+    case 1:
+        s->pict_type = AV_PICTURE_TYPE_I;
+        break;                                  // hmm ...
+    case 2:
+        s->pict_type = AV_PICTURE_TYPE_P;
+        break;
+    case 3:
+        s->pict_type = AV_PICTURE_TYPE_B;
+        break;
     default:
         av_log(s->avctx, AV_LOG_ERROR, "unknown frame type\n");
         return AVERROR_INVALIDDATA;
@@ -350,10 +359,10 @@ static int rv20_decode_picture_header(RVDecContext *rv)
                 return AVERROR_INVALIDDATA;
             }
 
-            new_w = 4 * ((uint8_t*)s->avctx->extradata)[6 + 2 * f];
-            new_h = 4 * ((uint8_t*)s->avctx->extradata)[7 + 2 * f];
+            new_w = 4 * ((uint8_t *) s->avctx->extradata)[6 + 2 * f];
+            new_h = 4 * ((uint8_t *) s->avctx->extradata)[7 + 2 * f];
         } else {
-            new_w = s->orig_width ;
+            new_w = s->orig_width;
             new_h = s->orig_height;
         }
         if (new_w != s->width || new_h != s->height) {
@@ -406,7 +415,8 @@ static int rv20_decode_picture_header(RVDecContext *rv)
     s->no_rounding = get_bits1(&s->gb);
 
     if (RV_GET_MINOR_VER(rv->sub_id) <= 1 && s->pict_type == AV_PICTURE_TYPE_B)
-        skip_bits(&s->gb, 5); // binary decoder reads 3+2 bits here but they don't seem to be used
+        // binary decoder reads 3+2 bits here but they don't seem to be used
+        skip_bits(&s->gb, 5);
 
     s->f_code          = 1;
     s->unrestricted_mv = 1;
@@ -415,18 +425,20 @@ static int rv20_decode_picture_header(RVDecContext *rv)
     s->loop_filter     = 1;
 
     if (s->avctx->debug & FF_DEBUG_PICT_INFO) {
-        av_log(s->avctx, AV_LOG_INFO, "num:%5d x:%2d y:%2d type:%d qscale:%2d rnd:%d\n",
-               seq, s->mb_x, s->mb_y, s->pict_type, s->qscale, s->no_rounding);
+        av_log(s->avctx, AV_LOG_INFO,
+               "num:%5d x:%2d y:%2d type:%d qscale:%2d rnd:%d\n",
+               seq, s->mb_x, s->mb_y, s->pict_type, s->qscale,
+               s->no_rounding);
     }
 
     assert(s->pict_type != AV_PICTURE_TYPE_B || !s->low_delay);
 
-    return s->mb_width*s->mb_height - mb_pos;
+    return s->mb_width * s->mb_height - mb_pos;
 }
 
 static av_cold int rv10_decode_init(AVCodecContext *avctx)
 {
-    RVDecContext  *rv = avctx->priv_data;
+    RVDecContext *rv = avctx->priv_data;
     MpegEncContext *s = &rv->m;
     static int done = 0;
     int major_ver, minor_ver, micro_ver, ret;
@@ -441,15 +453,17 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
 
     ff_MPV_decode_defaults(s);
 
-    s->avctx      = avctx;
-    s->out_format = FMT_H263;
-    s->codec_id   = avctx->codec_id;
+    s->avctx       = avctx;
+    s->out_format  = FMT_H263;
+    s->codec_id    = avctx->codec_id;
 
-    s->orig_width  = s->width  = avctx->coded_width;
-    s->orig_height = s->height = avctx->coded_height;
+    s->orig_width  =
+    s->width       = avctx->coded_width;
+    s->orig_height =
+    s->height      = avctx->coded_height;
 
-    s->h263_long_vectors = ((uint8_t*)avctx->extradata)[3] & 1;
-    rv->sub_id           = AV_RB32((uint8_t*)avctx->extradata + 4);
+    s->h263_long_vectors = ((uint8_t *) avctx->extradata)[3] & 1;
+    rv->sub_id           = AV_RB32((uint8_t *) avctx->extradata + 4);
 
     major_ver = RV_GET_MAJOR_VER(rv->sub_id);
     minor_ver = RV_GET_MINOR_VER(rv->sub_id);
@@ -475,7 +489,8 @@ static av_cold int rv10_decode_init(AVCodecContext *avctx)
 
     if (avctx->debug & FF_DEBUG_PICT_INFO) {
         av_log(avctx, AV_LOG_DEBUG, "ver:%X ver0:%X\n", rv->sub_id,
-               avctx->extradata_size >= 4 ? ((uint32_t*)avctx->extradata)[0] : -1);
+               avctx->extradata_size >= 4 ? ((uint32_t *) avctx->extradata)[0]
+                                          : -1);
     }
 
     avctx->pix_fmt = AV_PIX_FMT_YUV420P;
@@ -508,10 +523,10 @@ static av_cold int rv10_decode_end(AVCodecContext *avctx)
     return 0;
 }
 
-static int rv10_decode_packet(AVCodecContext *avctx,
-                              const uint8_t *buf, int buf_size, int buf_size2)
+static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf,
+                              int buf_size, int buf_size2)
 {
-    RVDecContext  *rv = avctx->priv_data;
+    RVDecContext *rv = avctx->priv_data;
     MpegEncContext *s = &rv->m;
     int mb_count, mb_pos, left, start_mb_x, active_bits_size, ret;
 
@@ -532,14 +547,15 @@ static int rv10_decode_packet(AVCodecContext *avctx,
         return AVERROR_INVALIDDATA;
     }
     mb_pos = s->mb_y * s->mb_width + s->mb_x;
-    left = s->mb_width * s->mb_height - mb_pos;
+    left   = s->mb_width * s->mb_height - mb_pos;
     if (mb_count > left) {
         av_log(s->avctx, AV_LOG_ERROR, "COUNT ERROR\n");
         return AVERROR_INVALIDDATA;
     }
 
     if ((s->mb_x == 0 && s->mb_y == 0) || s->current_picture_ptr == NULL) {
-        if (s->current_picture_ptr) { // FIXME write parser so we always have complete frames?
+        // FIXME write parser so we always have complete frames?
+        if (s->current_picture_ptr) {
             ff_er_frame_end(&s->er);
             ff_MPV_frame_end(s);
             s->mb_x = s->mb_y = s->resync_mb_x = s->resync_mb_y = 0;
@@ -567,9 +583,11 @@ static int rv10_decode_packet(AVCodecContext *avctx,
     start_mb_x     = s->mb_x;
     s->resync_mb_y = s->mb_y;
     if (s->h263_aic) {
-        s->y_dc_scale_table = s->c_dc_scale_table = ff_aic_dc_scale_table;
+        s->y_dc_scale_table =
+        s->c_dc_scale_table = ff_aic_dc_scale_table;
     } else {
-        s->y_dc_scale_table = s->c_dc_scale_table = ff_mpeg1_dc_scale_table;
+        s->y_dc_scale_table =
+        s->c_dc_scale_table = ff_mpeg1_dc_scale_table;
     }
 
     if (s->modified_quant)
@@ -618,7 +636,8 @@ static int rv10_decode_packet(AVCodecContext *avctx,
         }
 
         if (ret == SLICE_ERROR || active_bits_size < get_bits_count(&s->gb)) {
-            av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x, s->mb_y);
+            av_log(s->avctx, AV_LOG_ERROR, "ERROR at MB %d %d\n", s->mb_x,
+                   s->mb_y);
             return AVERROR_INVALIDDATA;
         }
         if (s->pict_type != AV_PICTURE_TYPE_B)
@@ -638,7 +657,7 @@ static int rv10_decode_packet(AVCodecContext *avctx,
             break;
     }
 
-    ff_er_add_slice(&s->er, start_mb_x, s->resync_mb_y, s->mb_x-1, s->mb_y,
+    ff_er_add_slice(&s->er, start_mb_x, s->resync_mb_y, s->mb_x - 1, s->mb_y,
                     ER_MB_END);
 
     return active_bits_size;
@@ -652,14 +671,13 @@ static int get_slice_offset(AVCodecContext *avctx, const uint8_t *buf, int n)
         return AV_RL32(buf + n * 8);
 }
 
-static int rv10_decode_frame(AVCodecContext *avctx,
-                             void *data, int *got_frame,
+static int rv10_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
                              AVPacket *avpkt)
 {
     const uint8_t *buf = avpkt->data;
     int buf_size       = avpkt->size;
-    MpegEncContext *s  = avctx->priv_data;
-    AVFrame *pict      = data;
+    MpegEncContext *s = avctx->priv_data;
+    AVFrame *pict = data;
     int i, ret;
     int slice_count;
     const uint8_t *slices_hdr = NULL;
@@ -676,7 +694,8 @@ static int rv10_decode_frame(AVCodecContext *avctx,
         buf_size--;
 
         if (!slice_count || buf_size <= 8 * slice_count) {
-            av_log(avctx, AV_LOG_ERROR, "Invalid slice count: %d.\n", slice_count);
+            av_log(avctx, AV_LOG_ERROR, "Invalid slice count: %d.\n",
+                   slice_count);
             return AVERROR_INVALIDDATA;
         }
 
@@ -707,7 +726,10 @@ static int rv10_decode_frame(AVCodecContext *avctx,
             offset + FFMAX(size, size2) > buf_size)
             return AVERROR_INVALIDDATA;
 
-        if (rv10_decode_packet(avctx, buf + offset, size, size2) > 8 * size)
+        if ((ret = rv10_decode_packet(avctx, buf + offset, size, size2)) < 0)
+            return ret;
+
+        if (ret > 8 * size)
             i++;
     }
 
diff --git a/deps/libav/libavcodec/rv30.c b/deps/libav/libavcodec/rv30.c
index 82ad7d4..f23b83d 100644
--- a/deps/libav/libavcodec/rv30.c
+++ b/deps/libav/libavcodec/rv30.c
@@ -127,7 +127,7 @@ static int rv30_decode_mb_info(RV34DecContext *r)
 static inline void rv30_weak_loop_filter(uint8_t *src, const int step,
                                          const int stride, const int lim)
 {
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
     int i, diff;
 
     for(i = 0; i < 4; i++){
diff --git a/deps/libav/libavcodec/rv30dsp.c b/deps/libav/libavcodec/rv30dsp.c
index d4b122e..bae39bd 100644
--- a/deps/libav/libavcodec/rv30dsp.c
+++ b/deps/libav/libavcodec/rv30dsp.c
@@ -32,7 +32,7 @@
 #define RV30_LOWPASS(OPNAME, OP) \
 static av_unused void OPNAME ## rv30_tpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, const int C1, const int C2){\
     const int h = 8;\
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
     int i;\
     for(i = 0; i < h; i++)\
     {\
@@ -51,7 +51,7 @@ static av_unused void OPNAME ## rv30_tpel8_h_lowpass(uint8_t *dst, uint8_t *src,
 \
 static void OPNAME ## rv30_tpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, const int C1, const int C2){\
     const int w = 8;\
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
     int i;\
     for(i = 0; i < w; i++)\
     {\
@@ -82,7 +82,7 @@ static void OPNAME ## rv30_tpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstSt
 static void OPNAME ## rv30_tpel8_hv_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
     const int w = 8;\
     const int h = 8;\
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
     int i, j;\
     for(j = 0; j < h; j++){\
         for(i = 0; i < w; i++){\
@@ -101,7 +101,7 @@ static void OPNAME ## rv30_tpel8_hv_lowpass(uint8_t *dst, uint8_t *src, int dstS
 static void OPNAME ## rv30_tpel8_hhv_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
     const int w = 8;\
     const int h = 8;\
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
     int i, j;\
     for(j = 0; j < h; j++){\
         for(i = 0; i < w; i++){\
@@ -120,7 +120,7 @@ static void OPNAME ## rv30_tpel8_hhv_lowpass(uint8_t *dst, uint8_t *src, int dst
 static void OPNAME ## rv30_tpel8_hvv_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
     const int w = 8;\
     const int h = 8;\
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
     int i, j;\
     for(j = 0; j < h; j++){\
         for(i = 0; i < w; i++){\
@@ -139,7 +139,7 @@ static void OPNAME ## rv30_tpel8_hvv_lowpass(uint8_t *dst, uint8_t *src, int dst
 static void OPNAME ## rv30_tpel8_hhvv_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
     const int w = 8;\
     const int h = 8;\
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
     int i, j;\
     for(j = 0; j < h; j++){\
         for(i = 0; i < w; i++){\
diff --git a/deps/libav/libavcodec/rv40dsp.c b/deps/libav/libavcodec/rv40dsp.c
index 6517d46..169ecad 100644
--- a/deps/libav/libavcodec/rv40dsp.c
+++ b/deps/libav/libavcodec/rv40dsp.c
@@ -32,7 +32,7 @@
 #define RV40_LOWPASS(OPNAME, OP) \
 static av_unused void OPNAME ## rv40_qpel8_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride,\
                                                      const int h, const int C1, const int C2, const int SHIFT){\
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
     int i;\
     for(i = 0; i < h; i++)\
     {\
@@ -51,7 +51,7 @@ static av_unused void OPNAME ## rv40_qpel8_h_lowpass(uint8_t *dst, uint8_t *src,
 \
 static void OPNAME ## rv40_qpel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride,\
                                            const int w, const int C1, const int C2, const int SHIFT){\
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\
     int i;\
     for(i = 0; i < w; i++)\
     {\
@@ -350,7 +350,7 @@ static av_always_inline void rv40_weak_loop_filter(uint8_t *src,
                                                    const int lim_q1,
                                                    const int lim_p1)
 {
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
     int i, t, u, diff;
 
     for (i = 0; i < 4; i++, src += stride) {
diff --git a/deps/libav/libavcodec/sh4/Makefile b/deps/libav/libavcodec/sh4/Makefile
deleted file mode 100644
index 01a573b..0000000
--- a/deps/libav/libavcodec/sh4/Makefile
+++ /dev/null
@@ -1,2 +0,0 @@
-OBJS += sh4/dsputil_sh4.o                                               \
-        sh4/idct_sh4.o                                                  \
diff --git a/deps/libav/libavcodec/sh4/dsputil_sh4.c b/deps/libav/libavcodec/sh4/dsputil_sh4.c
deleted file mode 100644
index 6fd287d..0000000
--- a/deps/libav/libavcodec/sh4/dsputil_sh4.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- *  sh4 dsputil
- *
- * Copyright (c) 2003 BERO <bero at geocities.co.jp>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/attributes.h"
-#include "libavcodec/avcodec.h"
-#include "libavcodec/dsputil.h"
-#include "dsputil_sh4.h"
-#include "sh4.h"
-
-static void memzero_align8(void *dst,size_t size)
-{
-        int fpscr;
-        fp_single_enter(fpscr);
-        dst = (char *)dst + size;
-        size /= 32;
-        __asm__ volatile (
-        " fldi0 fr0\n"
-        " fldi0 fr1\n"
-        " fschg\n"  // double
-        "1: \n" \
-        " dt %1\n"
-        " fmov  dr0, at -%0\n"
-        " fmov  dr0, at -%0\n"
-        " fmov  dr0, at -%0\n"
-        " bf.s 1b\n"
-        " fmov  dr0, at -%0\n"
-        " fschg" //back to single
-        : "+r"(dst),"+r"(size) :: "memory" );
-        fp_single_leave(fpscr);
-}
-
-static void clear_blocks_sh4(int16_t *blocks)
-{
-        memzero_align8(blocks,sizeof(int16_t)*6*64);
-}
-
-static void idct_put(uint8_t *dest, int line_size, int16_t *block)
-{
-        int i;
-        const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
-        ff_idct_sh4(block);
-        for(i=0;i<8;i++) {
-                dest[0] = cm[block[0]];
-                dest[1] = cm[block[1]];
-                dest[2] = cm[block[2]];
-                dest[3] = cm[block[3]];
-                dest[4] = cm[block[4]];
-                dest[5] = cm[block[5]];
-                dest[6] = cm[block[6]];
-                dest[7] = cm[block[7]];
-                dest+=line_size;
-                block+=8;
-        }
-}
-static void idct_add(uint8_t *dest, int line_size, int16_t *block)
-{
-        int i;
-        const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
-        ff_idct_sh4(block);
-        for(i=0;i<8;i++) {
-                dest[0] = cm[dest[0]+block[0]];
-                dest[1] = cm[dest[1]+block[1]];
-                dest[2] = cm[dest[2]+block[2]];
-                dest[3] = cm[dest[3]+block[3]];
-                dest[4] = cm[dest[4]+block[4]];
-                dest[5] = cm[dest[5]+block[5]];
-                dest[6] = cm[dest[6]+block[6]];
-                dest[7] = cm[dest[7]+block[7]];
-                dest+=line_size;
-                block+=8;
-        }
-}
-
-av_cold void ff_dsputil_init_sh4(DSPContext *c, AVCodecContext *avctx)
-{
-        const int idct_algo= avctx->idct_algo;
-        const int high_bit_depth = avctx->bits_per_raw_sample > 8;
-
-        if (!high_bit_depth)
-        c->clear_blocks = clear_blocks_sh4;
-        if (avctx->bits_per_raw_sample <= 8 &&
-            (idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4)) {
-                c->idct_put = idct_put;
-                c->idct_add = idct_add;
-                c->idct     = ff_idct_sh4;
-                c->idct_permutation_type= FF_NO_IDCT_PERM;
-        }
-}
diff --git a/deps/libav/libavcodec/sh4/dsputil_sh4.h b/deps/libav/libavcodec/sh4/dsputil_sh4.h
deleted file mode 100644
index 9c2b311..0000000
--- a/deps/libav/libavcodec/sh4/dsputil_sh4.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_SH4_DSPUTIL_SH4_H
-#define AVCODEC_SH4_DSPUTIL_SH4_H
-
-#include "libavcodec/avcodec.h"
-#include "libavcodec/dsputil.h"
-
-void ff_idct_sh4(int16_t *block);
-
-#endif /* AVCODEC_SH4_DSPUTIL_SH4_H */
diff --git a/deps/libav/libavcodec/sh4/idct_sh4.c b/deps/libav/libavcodec/sh4/idct_sh4.c
deleted file mode 100644
index 768b334..0000000
--- a/deps/libav/libavcodec/sh4/idct_sh4.c
+++ /dev/null
@@ -1,210 +0,0 @@
-/*
- * idct for sh4
- *
- * Copyright (c) 2001-2003 BERO <bero at geocities.co.jp>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "dsputil_sh4.h"
-#include "sh4.h"
-
-#define c1      1.38703984532214752434  /* sqrt(2)*cos(1*pi/16) */
-#define c2      1.30656296487637657577  /* sqrt(2)*cos(2*pi/16) */
-#define c3      1.17587560241935884520  /* sqrt(2)*cos(3*pi/16) */
-#define c4      1.00000000000000000000  /* sqrt(2)*cos(4*pi/16) */
-#define c5      0.78569495838710234903  /* sqrt(2)*cos(5*pi/16) */
-#define c6      0.54119610014619712324  /* sqrt(2)*cos(6*pi/16) */
-#define c7      0.27589937928294311353  /* sqrt(2)*cos(7*pi/16) */
-
-static const float even_table[] __attribute__ ((aligned(8))) = {
-        c4, c4, c4, c4,
-        c2, c6,-c6,-c2,
-        c4,-c4,-c4, c4,
-        c6,-c2, c2,-c6
-};
-
-static const float odd_table[] __attribute__ ((aligned(8))) = {
-        c1, c3, c5, c7,
-        c3,-c7,-c1,-c5,
-        c5,-c1, c7, c3,
-        c7,-c5, c3,-c1
-};
-
-#undef  c1
-#undef  c2
-#undef  c3
-#undef  c4
-#undef  c5
-#undef  c6
-#undef  c7
-
-#define         load_matrix(table) \
-    do { \
-        const float *t = table; \
-        __asm__ volatile( \
-        "       fschg\n" \
-        "       fmov   @%0+,xd0\n" \
-        "       fmov   @%0+,xd2\n" \
-        "       fmov   @%0+,xd4\n" \
-        "       fmov   @%0+,xd6\n" \
-        "       fmov   @%0+,xd8\n" \
-        "       fmov   @%0+,xd10\n" \
-        "       fmov   @%0+,xd12\n" \
-        "       fmov   @%0+,xd14\n" \
-        "       fschg\n" \
-        : "+r"(t) \
-        ); \
-    } while (0)
-
-#define         ftrv() \
-                __asm__ volatile("ftrv xmtrx,fv0" \
-                : "+f"(fr0),"+f"(fr1),"+f"(fr2),"+f"(fr3));
-
-#define         DEFREG        \
-        register float fr0 __asm__("fr0"); \
-        register float fr1 __asm__("fr1"); \
-        register float fr2 __asm__("fr2"); \
-        register float fr3 __asm__("fr3")
-
-#define         DESCALE(x,n)    (x)*(1.0f/(1<<(n)))
-
-/* this code work worse on gcc cvs. 3.2.3 work fine */
-
-
-//optimized
-
-void ff_idct_sh4(int16_t *block)
-{
-        DEFREG;
-
-        int i;
-        float        tblock[8*8],*fblock;
-        int ofs1,ofs2,ofs3;
-        int fpscr;
-
-        fp_single_enter(fpscr);
-
-        /* row */
-
-        /* even part */
-        load_matrix(even_table);
-
-        fblock = tblock+4;
-        i = 8;
-        do {
-                fr0 = block[0];
-                fr1 = block[2];
-                fr2 = block[4];
-                fr3 = block[6];
-                block+=8;
-                ftrv();
-                *--fblock = fr3;
-                *--fblock = fr2;
-                *--fblock = fr1;
-                *--fblock = fr0;
-                fblock+=8+4;
-        } while(--i);
-        block-=8*8;
-        fblock-=8*8+4;
-
-        load_matrix(odd_table);
-
-        i = 8;
-
-        do {
-                float t0,t1,t2,t3;
-                fr0 = block[1];
-                fr1 = block[3];
-                fr2 = block[5];
-                fr3 = block[7];
-                block+=8;
-                ftrv();
-                t0 = *fblock++;
-                t1 = *fblock++;
-                t2 = *fblock++;
-                t3 = *fblock++;
-                fblock+=4;
-                *--fblock = t0 - fr0;
-                *--fblock = t1 - fr1;
-                *--fblock = t2 - fr2;
-                *--fblock = t3 - fr3;
-                *--fblock = t3 + fr3;
-                *--fblock = t2 + fr2;
-                *--fblock = t1 + fr1;
-                *--fblock = t0 + fr0;
-                fblock+=8;
-        } while(--i);
-        block-=8*8;
-        fblock-=8*8;
-
-        /* col */
-
-        /* even part */
-        load_matrix(even_table);
-
-        ofs1 = sizeof(float)*2*8;
-        ofs2 = sizeof(float)*4*8;
-        ofs3 = sizeof(float)*6*8;
-
-        i = 8;
-
-#define        OA(fblock,ofs)   *(float*)((char*)fblock + ofs)
-
-        do {
-                fr0 = OA(fblock,   0);
-                fr1 = OA(fblock,ofs1);
-                fr2 = OA(fblock,ofs2);
-                fr3 = OA(fblock,ofs3);
-                ftrv();
-                OA(fblock,0   ) = fr0;
-                OA(fblock,ofs1) = fr1;
-                OA(fblock,ofs2) = fr2;
-                OA(fblock,ofs3) = fr3;
-                fblock++;
-        } while(--i);
-        fblock-=8;
-
-        load_matrix(odd_table);
-
-        i=8;
-        do {
-                float t0,t1,t2,t3;
-                t0 = OA(fblock,   0); /* [8*0] */
-                t1 = OA(fblock,ofs1); /* [8*2] */
-                t2 = OA(fblock,ofs2); /* [8*4] */
-                t3 = OA(fblock,ofs3); /* [8*6] */
-                fblock+=8;
-                fr0 = OA(fblock,   0); /* [8*1] */
-                fr1 = OA(fblock,ofs1); /* [8*3] */
-                fr2 = OA(fblock,ofs2); /* [8*5] */
-                fr3 = OA(fblock,ofs3); /* [8*7] */
-                fblock+=-8+1;
-                ftrv();
-                block[8*0] = DESCALE(t0 + fr0,3);
-                block[8*7] = DESCALE(t0 - fr0,3);
-                block[8*1] = DESCALE(t1 + fr1,3);
-                block[8*6] = DESCALE(t1 - fr1,3);
-                block[8*2] = DESCALE(t2 + fr2,3);
-                block[8*5] = DESCALE(t2 - fr2,3);
-                block[8*3] = DESCALE(t3 + fr3,3);
-                block[8*4] = DESCALE(t3 - fr3,3);
-                block++;
-        } while(--i);
-
-        fp_single_leave(fpscr);
-}
diff --git a/deps/libav/libavcodec/sh4/sh4.h b/deps/libav/libavcodec/sh4/sh4.h
deleted file mode 100644
index acd12e6..0000000
--- a/deps/libav/libavcodec/sh4/sh4.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (c) 2008 Mans Rullgard <mans at mansr.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_SH4_SH4_H
-#define AVCODEC_SH4_SH4_H
-
-#ifdef __SH4__
-#   define fp_single_enter(fpscr)                               \
-    do {                                                        \
-        __asm__ volatile ("sts   fpscr, %0     \n\t"            \
-                          "and   %1,    %0     \n\t"            \
-                          "lds   %0,    fpscr  \n\t"            \
-                          : "=&r"(fpscr) : "r"(~(1<<19)));      \
-    } while (0)
-
-#   define fp_single_leave(fpscr)                       \
-    do {                                                \
-        __asm__ volatile ("or    %1,    %0     \n\t"    \
-                          "lds   %0,    fpscr  \n\t"    \
-                          : "+r"(fpscr) : "r"(1<<19));  \
-    } while (0)
-#else
-#   define fp_single_enter(fpscr) ((void)fpscr)
-#   define fp_single_leave(fpscr)
-#endif
-
-#endif /* AVCODEC_SH4_SH4_H */
diff --git a/deps/libav/libavcodec/sparc/Makefile b/deps/libav/libavcodec/sparc/Makefile
deleted file mode 100644
index aeb0f47..0000000
--- a/deps/libav/libavcodec/sparc/Makefile
+++ /dev/null
@@ -1,4 +0,0 @@
-VIS-OBJS += sparc/dsputil_vis.o                                         \
-            sparc/simple_idct_vis.o                                     \
-
-VIS-OBJS-$(CONFIG_HPELDSP) += sparc/hpeldsp_vis.o
diff --git a/deps/libav/libavcodec/sparc/dsputil_vis.c b/deps/libav/libavcodec/sparc/dsputil_vis.c
deleted file mode 100644
index cee2e1d..0000000
--- a/deps/libav/libavcodec/sparc/dsputil_vis.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2003 David S. Miller <davem at redhat.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include "libavutil/attributes.h"
-#include "libavcodec/dsputil.h"
-#include "dsputil_vis.h"
-#include "vis.h"
-
-av_cold void ff_dsputil_init_vis(DSPContext *c, AVCodecContext *avctx)
-{
-  /* VIS-specific optimizations */
-  int accel = vis_level ();
-  const int high_bit_depth = avctx->bits_per_raw_sample > 8;
-
-  if (accel & ACCEL_SPARC_VIS && !high_bit_depth) {
-      if (avctx->idct_algo == FF_IDCT_SIMPLEVIS) {
-          c->idct_put = ff_simple_idct_put_vis;
-          c->idct_add = ff_simple_idct_add_vis;
-          c->idct     = ff_simple_idct_vis;
-          c->idct_permutation_type = FF_TRANSPOSE_IDCT_PERM;
-      }
-  }
-}
diff --git a/deps/libav/libavcodec/sparc/dsputil_vis.h b/deps/libav/libavcodec/sparc/dsputil_vis.h
deleted file mode 100644
index d7f6e01..0000000
--- a/deps/libav/libavcodec/sparc/dsputil_vis.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef AVCODEC_SPARC_DSPUTIL_VIS_H
-#define AVCODEC_SPARC_DSPUTIL_VIS_H
-
-#include <stdint.h>
-
-void ff_simple_idct_put_vis(uint8_t *dest, int line_size, int16_t *data);
-void ff_simple_idct_add_vis(uint8_t *dest, int line_size, int16_t *data);
-void ff_simple_idct_vis(int16_t *data);
-
-#endif /* AVCODEC_SPARC_DSPUTIL_VIS_H */
diff --git a/deps/libav/libavcodec/sparc/hpeldsp_vis.c b/deps/libav/libavcodec/sparc/hpeldsp_vis.c
deleted file mode 100644
index bca32e2..0000000
--- a/deps/libav/libavcodec/sparc/hpeldsp_vis.c
+++ /dev/null
@@ -1,3524 +0,0 @@
-/*
- * Copyright (C) 2003 David S. Miller <davem at redhat.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/* The *no_round* functions have been added by James A. Morrison, 2003,2004.
-   The vis code from libmpeg2 was adapted for libavcodec by James A. Morrison.
- */
-
-#include <stddef.h>
-#include <stdint.h>
-
-#include "libavutil/attributes.h"
-#include "libavutil/mem.h"
-#include "libavcodec/hpeldsp.h"
-#include "vis.h"
-
-/* The trick used in some of this file is the formula from the MMX
- * motion comp code, which is:
- *
- * (x+y+1)>>1 == (x|y)-((x^y)>>1)
- *
- * This allows us to average 8 bytes at a time in a 64-bit FPU reg.
- * We avoid overflows by masking before we do the shift, and we
- * implement the shift by multiplying by 1/2 using mul8x16.  So in
- * VIS this is (assume 'x' is in f0, 'y' is in f2, a repeating mask
- * of '0xfe' is in f4, a repeating mask of '0x7f' is in f6, and
- * the value 0x80808080 is in f8):
- *
- *      fxor            f0,   f2, f10
- *      fand            f10,  f4, f10
- *      fmul8x16        f8,  f10, f10
- *      fand            f10,  f6, f10
- *      for             f0,   f2, f12
- *      fpsub16         f12, f10, f10
- */
-
-#define DUP4(x) {x, x, x, x}
-#define DUP8(x) {x, x, x, x, x, x, x, x}
-DECLARE_ALIGNED(8, static const int16_t, constants1)[] = DUP4 (1);
-DECLARE_ALIGNED(8, static const int16_t, constants2)[] = DUP4 (2);
-DECLARE_ALIGNED(8, static const int16_t, constants3)[] = DUP4 (3);
-DECLARE_ALIGNED(8, static const int16_t, constants6)[] = DUP4 (6);
-DECLARE_ALIGNED(8, static const int8_t, constants_fe)[] = DUP8 (0xfe);
-DECLARE_ALIGNED(8, static const int8_t, constants_7f)[] = DUP8 (0x7f);
-DECLARE_ALIGNED(8, static const int8_t, constants128)[] = DUP8 (128);
-DECLARE_ALIGNED(8, static const int16_t, constants256_512)[] =
-        {256, 512, 256, 512};
-DECLARE_ALIGNED(8, static const int16_t, constants256_1024)[] =
-        {256, 1024, 256, 1024};
-
-#define REF_0           0
-#define REF_0_1         1
-#define REF_2           2
-#define REF_2_1         3
-#define REF_4           4
-#define REF_4_1         5
-#define REF_6           6
-#define REF_6_1         7
-#define REF_S0          8
-#define REF_S0_1        9
-#define REF_S2          10
-#define REF_S2_1        11
-#define REF_S4          12
-#define REF_S4_1        13
-#define REF_S6          14
-#define REF_S6_1        15
-#define DST_0           16
-#define DST_1           17
-#define DST_2           18
-#define DST_3           19
-#define CONST_1         20
-#define CONST_2         20
-#define CONST_3         20
-#define CONST_6         20
-#define MASK_fe         20
-#define CONST_128       22
-#define CONST_256       22
-#define CONST_512       22
-#define CONST_1024      22
-#define TMP0            24
-#define TMP1            25
-#define TMP2            26
-#define TMP3            27
-#define TMP4            28
-#define TMP5            29
-#define ZERO            30
-#define MASK_7f         30
-
-#define TMP6            32
-#define TMP8            34
-#define TMP10           36
-#define TMP12           38
-#define TMP14           40
-#define TMP16           42
-#define TMP18           44
-#define TMP20           46
-#define TMP22           48
-#define TMP24           50
-#define TMP26           52
-#define TMP28           54
-#define TMP30           56
-#define TMP32           58
-
-static void MC_put_o_16_vis (uint8_t * dest, const uint8_t * ref,
-                             const ptrdiff_t stride, int height)
-{
-        ref = vis_alignaddr(ref);
-        do {    /* 5 cycles */
-                vis_ld64(ref[0], TMP0);
-
-                vis_ld64_2(ref, 8, TMP2);
-
-                vis_ld64_2(ref, 16, TMP4);
-                ref += stride;
-
-                vis_faligndata(TMP0, TMP2, REF_0);
-                vis_st64(REF_0, dest[0]);
-
-                vis_faligndata(TMP2, TMP4, REF_2);
-                vis_st64_2(REF_2, dest, 8);
-                dest += stride;
-        } while (--height);
-}
-
-static void MC_put_o_8_vis (uint8_t * dest, const uint8_t * ref,
-                            const ptrdiff_t stride, int height)
-{
-        ref = vis_alignaddr(ref);
-        do {    /* 4 cycles */
-                vis_ld64(ref[0], TMP0);
-
-                vis_ld64(ref[8], TMP2);
-                ref += stride;
-
-                /* stall */
-
-                vis_faligndata(TMP0, TMP2, REF_0);
-                vis_st64(REF_0, dest[0]);
-                dest += stride;
-        } while (--height);
-}
-
-
-static void MC_avg_o_16_vis (uint8_t * dest, const uint8_t * ref,
-                             const ptrdiff_t stride, int height)
-{
-        int stride_8 = stride + 8;
-
-        ref = vis_alignaddr(ref);
-
-        vis_ld64(ref[0], TMP0);
-
-        vis_ld64(ref[8], TMP2);
-
-        vis_ld64(ref[16], TMP4);
-
-        vis_ld64(dest[0], DST_0);
-
-        vis_ld64(dest[8], DST_2);
-
-        vis_ld64(constants_fe[0], MASK_fe);
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        vis_ld64(constants_7f[0], MASK_7f);
-        vis_faligndata(TMP2, TMP4, REF_2);
-
-        vis_ld64(constants128[0], CONST_128);
-
-        ref += stride;
-        height = (height >> 1) - 1;
-
-        do {    /* 24 cycles */
-                vis_ld64(ref[0], TMP0);
-                vis_xor(DST_0, REF_0, TMP6);
-
-                vis_ld64_2(ref, 8, TMP2);
-                vis_and(TMP6, MASK_fe, TMP6);
-
-                vis_ld64_2(ref, 16, TMP4);
-                ref += stride;
-                vis_mul8x16(CONST_128, TMP6, TMP6);
-                vis_xor(DST_2, REF_2, TMP8);
-
-                vis_and(TMP8, MASK_fe, TMP8);
-
-                vis_or(DST_0, REF_0, TMP10);
-                vis_ld64_2(dest, stride, DST_0);
-                vis_mul8x16(CONST_128, TMP8, TMP8);
-
-                vis_or(DST_2, REF_2, TMP12);
-                vis_ld64_2(dest, stride_8, DST_2);
-
-                vis_ld64(ref[0], TMP14);
-                vis_and(TMP6, MASK_7f, TMP6);
-
-                vis_and(TMP8, MASK_7f, TMP8);
-
-                vis_psub16(TMP10, TMP6, TMP6);
-                vis_st64(TMP6, dest[0]);
-
-                vis_psub16(TMP12, TMP8, TMP8);
-                vis_st64_2(TMP8, dest, 8);
-
-                dest += stride;
-                vis_ld64_2(ref, 8, TMP16);
-                vis_faligndata(TMP0, TMP2, REF_0);
-
-                vis_ld64_2(ref, 16, TMP18);
-                vis_faligndata(TMP2, TMP4, REF_2);
-                ref += stride;
-
-                vis_xor(DST_0, REF_0, TMP20);
-
-                vis_and(TMP20, MASK_fe, TMP20);
-
-                vis_xor(DST_2, REF_2, TMP22);
-                vis_mul8x16(CONST_128, TMP20, TMP20);
-
-                vis_and(TMP22, MASK_fe, TMP22);
-
-                vis_or(DST_0, REF_0, TMP24);
-                vis_mul8x16(CONST_128, TMP22, TMP22);
-
-                vis_or(DST_2, REF_2, TMP26);
-
-                vis_ld64_2(dest, stride, DST_0);
-                vis_faligndata(TMP14, TMP16, REF_0);
-
-                vis_ld64_2(dest, stride_8, DST_2);
-                vis_faligndata(TMP16, TMP18, REF_2);
-
-                vis_and(TMP20, MASK_7f, TMP20);
-
-                vis_and(TMP22, MASK_7f, TMP22);
-
-                vis_psub16(TMP24, TMP20, TMP20);
-                vis_st64(TMP20, dest[0]);
-
-                vis_psub16(TMP26, TMP22, TMP22);
-                vis_st64_2(TMP22, dest, 8);
-                dest += stride;
-        } while (--height);
-
-        vis_ld64(ref[0], TMP0);
-        vis_xor(DST_0, REF_0, TMP6);
-
-        vis_ld64_2(ref, 8, TMP2);
-        vis_and(TMP6, MASK_fe, TMP6);
-
-        vis_ld64_2(ref, 16, TMP4);
-        vis_mul8x16(CONST_128, TMP6, TMP6);
-        vis_xor(DST_2, REF_2, TMP8);
-
-        vis_and(TMP8, MASK_fe, TMP8);
-
-        vis_or(DST_0, REF_0, TMP10);
-        vis_ld64_2(dest, stride, DST_0);
-        vis_mul8x16(CONST_128, TMP8, TMP8);
-
-        vis_or(DST_2, REF_2, TMP12);
-        vis_ld64_2(dest, stride_8, DST_2);
-
-        vis_ld64(ref[0], TMP14);
-        vis_and(TMP6, MASK_7f, TMP6);
-
-        vis_and(TMP8, MASK_7f, TMP8);
-
-        vis_psub16(TMP10, TMP6, TMP6);
-        vis_st64(TMP6, dest[0]);
-
-        vis_psub16(TMP12, TMP8, TMP8);
-        vis_st64_2(TMP8, dest, 8);
-
-        dest += stride;
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        vis_faligndata(TMP2, TMP4, REF_2);
-
-        vis_xor(DST_0, REF_0, TMP20);
-
-        vis_and(TMP20, MASK_fe, TMP20);
-
-        vis_xor(DST_2, REF_2, TMP22);
-        vis_mul8x16(CONST_128, TMP20, TMP20);
-
-        vis_and(TMP22, MASK_fe, TMP22);
-
-        vis_or(DST_0, REF_0, TMP24);
-        vis_mul8x16(CONST_128, TMP22, TMP22);
-
-        vis_or(DST_2, REF_2, TMP26);
-
-        vis_and(TMP20, MASK_7f, TMP20);
-
-        vis_and(TMP22, MASK_7f, TMP22);
-
-        vis_psub16(TMP24, TMP20, TMP20);
-        vis_st64(TMP20, dest[0]);
-
-        vis_psub16(TMP26, TMP22, TMP22);
-        vis_st64_2(TMP22, dest, 8);
-}
-
-static void MC_avg_o_8_vis (uint8_t * dest, const uint8_t * ref,
-                            const ptrdiff_t stride, int height)
-{
-        ref = vis_alignaddr(ref);
-
-        vis_ld64(ref[0], TMP0);
-
-        vis_ld64(ref[8], TMP2);
-
-        vis_ld64(dest[0], DST_0);
-
-        vis_ld64(constants_fe[0], MASK_fe);
-
-        vis_ld64(constants_7f[0], MASK_7f);
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        vis_ld64(constants128[0], CONST_128);
-
-        ref += stride;
-        height = (height >> 1) - 1;
-
-        do {    /* 12 cycles */
-                vis_ld64(ref[0], TMP0);
-                vis_xor(DST_0, REF_0, TMP4);
-
-                vis_ld64(ref[8], TMP2);
-                vis_and(TMP4, MASK_fe, TMP4);
-
-                vis_or(DST_0, REF_0, TMP6);
-                vis_ld64_2(dest, stride, DST_0);
-                ref += stride;
-                vis_mul8x16(CONST_128, TMP4, TMP4);
-
-                vis_ld64(ref[0], TMP12);
-                vis_faligndata(TMP0, TMP2, REF_0);
-
-                vis_ld64(ref[8], TMP2);
-                vis_xor(DST_0, REF_0, TMP0);
-                ref += stride;
-
-                vis_and(TMP0, MASK_fe, TMP0);
-
-                vis_and(TMP4, MASK_7f, TMP4);
-
-                vis_psub16(TMP6, TMP4, TMP4);
-                vis_st64(TMP4, dest[0]);
-                dest += stride;
-                vis_mul8x16(CONST_128, TMP0, TMP0);
-
-                vis_or(DST_0, REF_0, TMP6);
-                vis_ld64_2(dest, stride, DST_0);
-
-                vis_faligndata(TMP12, TMP2, REF_0);
-
-                vis_and(TMP0, MASK_7f, TMP0);
-
-                vis_psub16(TMP6, TMP0, TMP4);
-                vis_st64(TMP4, dest[0]);
-                dest += stride;
-        } while (--height);
-
-        vis_ld64(ref[0], TMP0);
-        vis_xor(DST_0, REF_0, TMP4);
-
-        vis_ld64(ref[8], TMP2);
-        vis_and(TMP4, MASK_fe, TMP4);
-
-        vis_or(DST_0, REF_0, TMP6);
-        vis_ld64_2(dest, stride, DST_0);
-        vis_mul8x16(CONST_128, TMP4, TMP4);
-
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        vis_xor(DST_0, REF_0, TMP0);
-
-        vis_and(TMP0, MASK_fe, TMP0);
-
-        vis_and(TMP4, MASK_7f, TMP4);
-
-        vis_psub16(TMP6, TMP4, TMP4);
-        vis_st64(TMP4, dest[0]);
-        dest += stride;
-        vis_mul8x16(CONST_128, TMP0, TMP0);
-
-        vis_or(DST_0, REF_0, TMP6);
-
-        vis_and(TMP0, MASK_7f, TMP0);
-
-        vis_psub16(TMP6, TMP0, TMP4);
-        vis_st64(TMP4, dest[0]);
-}
-
-static void MC_put_x_16_vis (uint8_t * dest, const uint8_t * ref,
-                             const ptrdiff_t stride, int height)
-{
-        unsigned long off = (unsigned long) ref & 0x7;
-        unsigned long off_plus_1 = off + 1;
-
-        ref = vis_alignaddr(ref);
-
-        vis_ld64(ref[0],    TMP0);
-
-        vis_ld64_2(ref, 8,  TMP2);
-
-        vis_ld64_2(ref, 16, TMP4);
-
-        vis_ld64(constants_fe[0], MASK_fe);
-
-        vis_ld64(constants_7f[0], MASK_7f);
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        vis_ld64(constants128[0], CONST_128);
-        vis_faligndata(TMP2, TMP4, REF_4);
-
-        if (off != 0x7) {
-                vis_alignaddr_g0((void *)off_plus_1);
-                vis_faligndata(TMP0, TMP2, REF_2);
-                vis_faligndata(TMP2, TMP4, REF_6);
-        } else {
-                vis_src1(TMP2, REF_2);
-                vis_src1(TMP4, REF_6);
-        }
-
-        ref += stride;
-        height = (height >> 1) - 1;
-
-        do {    /* 34 cycles */
-                vis_ld64(ref[0],    TMP0);
-                vis_xor(REF_0, REF_2, TMP6);
-
-                vis_ld64_2(ref, 8,  TMP2);
-                vis_xor(REF_4, REF_6, TMP8);
-
-                vis_ld64_2(ref, 16, TMP4);
-                vis_and(TMP6, MASK_fe, TMP6);
-                ref += stride;
-
-                vis_ld64(ref[0],    TMP14);
-                vis_mul8x16(CONST_128, TMP6, TMP6);
-                vis_and(TMP8, MASK_fe, TMP8);
-
-                vis_ld64_2(ref, 8,  TMP16);
-                vis_mul8x16(CONST_128, TMP8, TMP8);
-                vis_or(REF_0, REF_2, TMP10);
-
-                vis_ld64_2(ref, 16, TMP18);
-                ref += stride;
-                vis_or(REF_4, REF_6, TMP12);
-
-                vis_alignaddr_g0((void *)off);
-
-                vis_faligndata(TMP0, TMP2, REF_0);
-
-                vis_faligndata(TMP2, TMP4, REF_4);
-
-                if (off != 0x7) {
-                        vis_alignaddr_g0((void *)off_plus_1);
-                        vis_faligndata(TMP0, TMP2, REF_2);
-                        vis_faligndata(TMP2, TMP4, REF_6);
-                } else {
-                        vis_src1(TMP2, REF_2);
-                        vis_src1(TMP4, REF_6);
-                }
-
-                vis_and(TMP6, MASK_7f, TMP6);
-
-                vis_and(TMP8, MASK_7f, TMP8);
-
-                vis_psub16(TMP10, TMP6, TMP6);
-                vis_st64(TMP6, dest[0]);
-
-                vis_psub16(TMP12, TMP8, TMP8);
-                vis_st64_2(TMP8, dest, 8);
-                dest += stride;
-
-                vis_xor(REF_0, REF_2, TMP6);
-
-                vis_xor(REF_4, REF_6, TMP8);
-
-                vis_and(TMP6, MASK_fe, TMP6);
-
-                vis_mul8x16(CONST_128, TMP6, TMP6);
-                vis_and(TMP8, MASK_fe, TMP8);
-
-                vis_mul8x16(CONST_128, TMP8, TMP8);
-                vis_or(REF_0, REF_2, TMP10);
-
-                vis_or(REF_4, REF_6, TMP12);
-
-                vis_alignaddr_g0((void *)off);
-
-                vis_faligndata(TMP14, TMP16, REF_0);
-
-                vis_faligndata(TMP16, TMP18, REF_4);
-
-                if (off != 0x7) {
-                        vis_alignaddr_g0((void *)off_plus_1);
-                        vis_faligndata(TMP14, TMP16, REF_2);
-                        vis_faligndata(TMP16, TMP18, REF_6);
-                } else {
-                        vis_src1(TMP16, REF_2);
-                        vis_src1(TMP18, REF_6);
-                }
-
-                vis_and(TMP6, MASK_7f, TMP6);
-
-                vis_and(TMP8, MASK_7f, TMP8);
-
-                vis_psub16(TMP10, TMP6, TMP6);
-                vis_st64(TMP6, dest[0]);
-
-                vis_psub16(TMP12, TMP8, TMP8);
-                vis_st64_2(TMP8, dest, 8);
-                dest += stride;
-        } while (--height);
-
-        vis_ld64(ref[0],    TMP0);
-        vis_xor(REF_0, REF_2, TMP6);
-
-        vis_ld64_2(ref, 8,  TMP2);
-        vis_xor(REF_4, REF_6, TMP8);
-
-        vis_ld64_2(ref, 16, TMP4);
-        vis_and(TMP6, MASK_fe, TMP6);
-
-        vis_mul8x16(CONST_128, TMP6, TMP6);
-        vis_and(TMP8, MASK_fe, TMP8);
-
-        vis_mul8x16(CONST_128, TMP8, TMP8);
-        vis_or(REF_0, REF_2, TMP10);
-
-        vis_or(REF_4, REF_6, TMP12);
-
-        vis_alignaddr_g0((void *)off);
-
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        vis_faligndata(TMP2, TMP4, REF_4);
-
-        if (off != 0x7) {
-                vis_alignaddr_g0((void *)off_plus_1);
-                vis_faligndata(TMP0, TMP2, REF_2);
-                vis_faligndata(TMP2, TMP4, REF_6);
-        } else {
-                vis_src1(TMP2, REF_2);
-                vis_src1(TMP4, REF_6);
-        }
-
-        vis_and(TMP6, MASK_7f, TMP6);
-
-        vis_and(TMP8, MASK_7f, TMP8);
-
-        vis_psub16(TMP10, TMP6, TMP6);
-        vis_st64(TMP6, dest[0]);
-
-        vis_psub16(TMP12, TMP8, TMP8);
-        vis_st64_2(TMP8, dest, 8);
-        dest += stride;
-
-        vis_xor(REF_0, REF_2, TMP6);
-
-        vis_xor(REF_4, REF_6, TMP8);
-
-        vis_and(TMP6, MASK_fe, TMP6);
-
-        vis_mul8x16(CONST_128, TMP6, TMP6);
-        vis_and(TMP8, MASK_fe, TMP8);
-
-        vis_mul8x16(CONST_128, TMP8, TMP8);
-        vis_or(REF_0, REF_2, TMP10);
-
-        vis_or(REF_4, REF_6, TMP12);
-
-        vis_and(TMP6, MASK_7f, TMP6);
-
-        vis_and(TMP8, MASK_7f, TMP8);
-
-        vis_psub16(TMP10, TMP6, TMP6);
-        vis_st64(TMP6, dest[0]);
-
-        vis_psub16(TMP12, TMP8, TMP8);
-        vis_st64_2(TMP8, dest, 8);
-}
-
-static void MC_put_x_8_vis (uint8_t * dest, const uint8_t * ref,
-                            const ptrdiff_t stride, int height)
-{
-        unsigned long off = (unsigned long) ref & 0x7;
-        unsigned long off_plus_1 = off + 1;
-
-        ref = vis_alignaddr(ref);
-
-        vis_ld64(ref[0], TMP0);
-
-        vis_ld64(ref[8], TMP2);
-
-        vis_ld64(constants_fe[0], MASK_fe);
-
-        vis_ld64(constants_7f[0], MASK_7f);
-
-        vis_ld64(constants128[0], CONST_128);
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        if (off != 0x7) {
-                vis_alignaddr_g0((void *)off_plus_1);
-                vis_faligndata(TMP0, TMP2, REF_2);
-        } else {
-                vis_src1(TMP2, REF_2);
-        }
-
-        ref += stride;
-        height = (height >> 1) - 1;
-
-        do {    /* 20 cycles */
-                vis_ld64(ref[0], TMP0);
-                vis_xor(REF_0, REF_2, TMP4);
-
-                vis_ld64_2(ref, 8, TMP2);
-                vis_and(TMP4, MASK_fe, TMP4);
-                ref += stride;
-
-                vis_ld64(ref[0], TMP8);
-                vis_or(REF_0, REF_2, TMP6);
-                vis_mul8x16(CONST_128, TMP4, TMP4);
-
-                vis_alignaddr_g0((void *)off);
-
-                vis_ld64_2(ref, 8, TMP10);
-                ref += stride;
-                vis_faligndata(TMP0, TMP2, REF_0);
-
-                if (off != 0x7) {
-                        vis_alignaddr_g0((void *)off_plus_1);
-                        vis_faligndata(TMP0, TMP2, REF_2);
-                } else {
-                        vis_src1(TMP2, REF_2);
-                }
-
-                vis_and(TMP4, MASK_7f, TMP4);
-
-                vis_psub16(TMP6, TMP4, DST_0);
-                vis_st64(DST_0, dest[0]);
-                dest += stride;
-
-                vis_xor(REF_0, REF_2, TMP12);
-
-                vis_and(TMP12, MASK_fe, TMP12);
-
-                vis_or(REF_0, REF_2, TMP14);
-                vis_mul8x16(CONST_128, TMP12, TMP12);
-
-                vis_alignaddr_g0((void *)off);
-                vis_faligndata(TMP8, TMP10, REF_0);
-                if (off != 0x7) {
-                        vis_alignaddr_g0((void *)off_plus_1);
-                        vis_faligndata(TMP8, TMP10, REF_2);
-                } else {
-                        vis_src1(TMP10, REF_2);
-                }
-
-                vis_and(TMP12, MASK_7f, TMP12);
-
-                vis_psub16(TMP14, TMP12, DST_0);
-                vis_st64(DST_0, dest[0]);
-                dest += stride;
-        } while (--height);
-
-        vis_ld64(ref[0], TMP0);
-        vis_xor(REF_0, REF_2, TMP4);
-
-        vis_ld64_2(ref, 8, TMP2);
-        vis_and(TMP4, MASK_fe, TMP4);
-
-        vis_or(REF_0, REF_2, TMP6);
-        vis_mul8x16(CONST_128, TMP4, TMP4);
-
-        vis_alignaddr_g0((void *)off);
-
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        if (off != 0x7) {
-                vis_alignaddr_g0((void *)off_plus_1);
-                vis_faligndata(TMP0, TMP2, REF_2);
-        } else {
-                vis_src1(TMP2, REF_2);
-        }
-
-        vis_and(TMP4, MASK_7f, TMP4);
-
-        vis_psub16(TMP6, TMP4, DST_0);
-        vis_st64(DST_0, dest[0]);
-        dest += stride;
-
-        vis_xor(REF_0, REF_2, TMP12);
-
-        vis_and(TMP12, MASK_fe, TMP12);
-
-        vis_or(REF_0, REF_2, TMP14);
-        vis_mul8x16(CONST_128, TMP12, TMP12);
-
-        vis_and(TMP12, MASK_7f, TMP12);
-
-        vis_psub16(TMP14, TMP12, DST_0);
-        vis_st64(DST_0, dest[0]);
-        dest += stride;
-}
-
-static void MC_avg_x_16_vis (uint8_t * dest, const uint8_t * ref,
-                             const ptrdiff_t stride, int height)
-{
-        unsigned long off = (unsigned long) ref & 0x7;
-        unsigned long off_plus_1 = off + 1;
-
-        vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-        vis_ld64(constants3[0], CONST_3);
-        vis_fzero(ZERO);
-        vis_ld64(constants256_512[0], CONST_256);
-
-        ref = vis_alignaddr(ref);
-        do {    /* 26 cycles */
-                vis_ld64(ref[0], TMP0);
-
-                vis_ld64(ref[8], TMP2);
-
-                vis_alignaddr_g0((void *)off);
-
-                vis_ld64(ref[16], TMP4);
-
-                vis_ld64(dest[0], DST_0);
-                vis_faligndata(TMP0, TMP2, REF_0);
-
-                vis_ld64(dest[8], DST_2);
-                vis_faligndata(TMP2, TMP4, REF_4);
-
-                if (off != 0x7) {
-                        vis_alignaddr_g0((void *)off_plus_1);
-                        vis_faligndata(TMP0, TMP2, REF_2);
-                        vis_faligndata(TMP2, TMP4, REF_6);
-                } else {
-                        vis_src1(TMP2, REF_2);
-                        vis_src1(TMP4, REF_6);
-                }
-
-                vis_mul8x16au(REF_0,   CONST_256, TMP0);
-
-                vis_pmerge(ZERO,     REF_2,     TMP4);
-                vis_mul8x16au(REF_0_1, CONST_256, TMP2);
-
-                vis_pmerge(ZERO, REF_2_1, TMP6);
-
-                vis_padd16(TMP0, TMP4, TMP0);
-
-                vis_mul8x16al(DST_0,   CONST_512, TMP4);
-                vis_padd16(TMP2, TMP6, TMP2);
-
-                vis_mul8x16al(DST_1,   CONST_512, TMP6);
-
-                vis_mul8x16au(REF_6,   CONST_256, TMP12);
-
-                vis_padd16(TMP0, TMP4, TMP0);
-                vis_mul8x16au(REF_6_1, CONST_256, TMP14);
-
-                vis_padd16(TMP2, TMP6, TMP2);
-                vis_mul8x16au(REF_4,   CONST_256, TMP16);
-
-                vis_padd16(TMP0, CONST_3, TMP8);
-                vis_mul8x16au(REF_4_1, CONST_256, TMP18);
-
-                vis_padd16(TMP2, CONST_3, TMP10);
-                vis_pack16(TMP8, DST_0);
-
-                vis_pack16(TMP10, DST_1);
-                vis_padd16(TMP16, TMP12, TMP0);
-
-                vis_st64(DST_0, dest[0]);
-                vis_mul8x16al(DST_2,   CONST_512, TMP4);
-                vis_padd16(TMP18, TMP14, TMP2);
-
-                vis_mul8x16al(DST_3,   CONST_512, TMP6);
-                vis_padd16(TMP0, CONST_3, TMP0);
-
-                vis_padd16(TMP2, CONST_3, TMP2);
-
-                vis_padd16(TMP0, TMP4, TMP0);
-
-                vis_padd16(TMP2, TMP6, TMP2);
-                vis_pack16(TMP0, DST_2);
-
-                vis_pack16(TMP2, DST_3);
-                vis_st64(DST_2, dest[8]);
-
-                ref += stride;
-                dest += stride;
-        } while (--height);
-}
-
-static void MC_avg_x_8_vis (uint8_t * dest, const uint8_t * ref,
-                            const ptrdiff_t stride, int height)
-{
-        unsigned long off = (unsigned long) ref & 0x7;
-        unsigned long off_plus_1 = off + 1;
-        int stride_times_2 = stride << 1;
-
-        vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-        vis_ld64(constants3[0], CONST_3);
-        vis_fzero(ZERO);
-        vis_ld64(constants256_512[0], CONST_256);
-
-        ref = vis_alignaddr(ref);
-        height >>= 2;
-        do {    /* 47 cycles */
-                vis_ld64(ref[0],   TMP0);
-
-                vis_ld64_2(ref, 8, TMP2);
-                ref += stride;
-
-                vis_alignaddr_g0((void *)off);
-
-                vis_ld64(ref[0],   TMP4);
-                vis_faligndata(TMP0, TMP2, REF_0);
-
-                vis_ld64_2(ref, 8, TMP6);
-                ref += stride;
-
-                vis_ld64(ref[0],   TMP8);
-
-                vis_ld64_2(ref, 8, TMP10);
-                ref += stride;
-                vis_faligndata(TMP4, TMP6, REF_4);
-
-                vis_ld64(ref[0],   TMP12);
-
-                vis_ld64_2(ref, 8, TMP14);
-                ref += stride;
-                vis_faligndata(TMP8, TMP10, REF_S0);
-
-                vis_faligndata(TMP12, TMP14, REF_S4);
-
-                if (off != 0x7) {
-                        vis_alignaddr_g0((void *)off_plus_1);
-
-                        vis_ld64(dest[0], DST_0);
-                        vis_faligndata(TMP0, TMP2, REF_2);
-
-                        vis_ld64_2(dest, stride, DST_2);
-                        vis_faligndata(TMP4, TMP6, REF_6);
-
-                        vis_faligndata(TMP8, TMP10, REF_S2);
-
-                        vis_faligndata(TMP12, TMP14, REF_S6);
-                } else {
-                        vis_ld64(dest[0], DST_0);
-                        vis_src1(TMP2, REF_2);
-
-                        vis_ld64_2(dest, stride, DST_2);
-                        vis_src1(TMP6, REF_6);
-
-                        vis_src1(TMP10, REF_S2);
-
-                        vis_src1(TMP14, REF_S6);
-                }
-
-                vis_pmerge(ZERO,     REF_0,     TMP0);
-                vis_mul8x16au(REF_0_1, CONST_256, TMP2);
-
-                vis_pmerge(ZERO,     REF_2,     TMP4);
-                vis_mul8x16au(REF_2_1, CONST_256, TMP6);
-
-                vis_padd16(TMP0, CONST_3, TMP0);
-                vis_mul8x16al(DST_0,   CONST_512, TMP16);
-
-                vis_padd16(TMP2, CONST_3, TMP2);
-                vis_mul8x16al(DST_1,   CONST_512, TMP18);
-
-                vis_padd16(TMP0, TMP4, TMP0);
-                vis_mul8x16au(REF_4, CONST_256, TMP8);
-
-                vis_padd16(TMP2, TMP6, TMP2);
-                vis_mul8x16au(REF_4_1, CONST_256, TMP10);
-
-                vis_padd16(TMP0, TMP16, TMP0);
-                vis_mul8x16au(REF_6, CONST_256, TMP12);
-
-                vis_padd16(TMP2, TMP18, TMP2);
-                vis_mul8x16au(REF_6_1, CONST_256, TMP14);
-
-                vis_padd16(TMP8, CONST_3, TMP8);
-                vis_mul8x16al(DST_2, CONST_512, TMP16);
-
-                vis_padd16(TMP8, TMP12, TMP8);
-                vis_mul8x16al(DST_3, CONST_512, TMP18);
-
-                vis_padd16(TMP10, TMP14, TMP10);
-                vis_pack16(TMP0, DST_0);
-
-                vis_pack16(TMP2, DST_1);
-                vis_st64(DST_0, dest[0]);
-                dest += stride;
-                vis_padd16(TMP10, CONST_3, TMP10);
-
-                vis_ld64_2(dest, stride, DST_0);
-                vis_padd16(TMP8, TMP16, TMP8);
-
-                vis_ld64_2(dest, stride_times_2, TMP4/*DST_2*/);
-                vis_padd16(TMP10, TMP18, TMP10);
-                vis_pack16(TMP8, DST_2);
-
-                vis_pack16(TMP10, DST_3);
-                vis_st64(DST_2, dest[0]);
-                dest += stride;
-
-                vis_mul8x16au(REF_S0_1, CONST_256, TMP2);
-                vis_pmerge(ZERO,     REF_S0,     TMP0);
-
-                vis_pmerge(ZERO,     REF_S2,     TMP24);
-                vis_mul8x16au(REF_S2_1, CONST_256, TMP6);
-
-                vis_padd16(TMP0, CONST_3, TMP0);
-                vis_mul8x16au(REF_S4, CONST_256, TMP8);
-
-                vis_padd16(TMP2, CONST_3, TMP2);
-                vis_mul8x16au(REF_S4_1, CONST_256, TMP10);
-
-                vis_padd16(TMP0, TMP24, TMP0);
-                vis_mul8x16au(REF_S6, CONST_256, TMP12);
-
-                vis_padd16(TMP2, TMP6, TMP2);
-                vis_mul8x16au(REF_S6_1, CONST_256, TMP14);
-
-                vis_padd16(TMP8, CONST_3, TMP8);
-                vis_mul8x16al(DST_0,   CONST_512, TMP16);
-
-                vis_padd16(TMP10, CONST_3, TMP10);
-                vis_mul8x16al(DST_1,   CONST_512, TMP18);
-
-                vis_padd16(TMP8, TMP12, TMP8);
-                vis_mul8x16al(TMP4/*DST_2*/, CONST_512, TMP20);
-
-                vis_mul8x16al(TMP5/*DST_3*/, CONST_512, TMP22);
-                vis_padd16(TMP0, TMP16, TMP0);
-
-                vis_padd16(TMP2, TMP18, TMP2);
-                vis_pack16(TMP0, DST_0);
-
-                vis_padd16(TMP10, TMP14, TMP10);
-                vis_pack16(TMP2, DST_1);
-                vis_st64(DST_0, dest[0]);
-                dest += stride;
-
-                vis_padd16(TMP8, TMP20, TMP8);
-
-                vis_padd16(TMP10, TMP22, TMP10);
-                vis_pack16(TMP8, DST_2);
-
-                vis_pack16(TMP10, DST_3);
-                vis_st64(DST_2, dest[0]);
-                dest += stride;
-        } while (--height);
-}
-
-static void MC_put_y_16_vis (uint8_t * dest, const uint8_t * ref,
-                             const ptrdiff_t stride, int height)
-{
-        ref = vis_alignaddr(ref);
-        vis_ld64(ref[0], TMP0);
-
-        vis_ld64_2(ref, 8, TMP2);
-
-        vis_ld64_2(ref, 16, TMP4);
-        ref += stride;
-
-        vis_ld64(ref[0], TMP6);
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        vis_ld64_2(ref, 8, TMP8);
-        vis_faligndata(TMP2, TMP4, REF_4);
-
-        vis_ld64_2(ref, 16, TMP10);
-        ref += stride;
-
-        vis_ld64(constants_fe[0], MASK_fe);
-        vis_faligndata(TMP6, TMP8, REF_2);
-
-        vis_ld64(constants_7f[0], MASK_7f);
-        vis_faligndata(TMP8, TMP10, REF_6);
-
-        vis_ld64(constants128[0], CONST_128);
-        height = (height >> 1) - 1;
-        do {    /* 24 cycles */
-                vis_ld64(ref[0], TMP0);
-                vis_xor(REF_0, REF_2, TMP12);
-
-                vis_ld64_2(ref, 8, TMP2);
-                vis_xor(REF_4, REF_6, TMP16);
-
-                vis_ld64_2(ref, 16, TMP4);
-                ref += stride;
-                vis_or(REF_0, REF_2, TMP14);
-
-                vis_ld64(ref[0], TMP6);
-                vis_or(REF_4, REF_6, TMP18);
-
-                vis_ld64_2(ref, 8, TMP8);
-                vis_faligndata(TMP0, TMP2, REF_0);
-
-                vis_ld64_2(ref, 16, TMP10);
-                ref += stride;
-                vis_faligndata(TMP2, TMP4, REF_4);
-
-                vis_and(TMP12, MASK_fe, TMP12);
-
-                vis_and(TMP16, MASK_fe, TMP16);
-                vis_mul8x16(CONST_128, TMP12, TMP12);
-
-                vis_mul8x16(CONST_128, TMP16, TMP16);
-                vis_xor(REF_0, REF_2, TMP0);
-
-                vis_xor(REF_4, REF_6, TMP2);
-
-                vis_or(REF_0, REF_2, TMP20);
-
-                vis_and(TMP12, MASK_7f, TMP12);
-
-                vis_and(TMP16, MASK_7f, TMP16);
-
-                vis_psub16(TMP14, TMP12, TMP12);
-                vis_st64(TMP12, dest[0]);
-
-                vis_psub16(TMP18, TMP16, TMP16);
-                vis_st64_2(TMP16, dest, 8);
-                dest += stride;
-
-                vis_or(REF_4, REF_6, TMP18);
-
-                vis_and(TMP0, MASK_fe, TMP0);
-
-                vis_and(TMP2, MASK_fe, TMP2);
-                vis_mul8x16(CONST_128, TMP0, TMP0);
-
-                vis_faligndata(TMP6, TMP8, REF_2);
-                vis_mul8x16(CONST_128, TMP2, TMP2);
-
-                vis_faligndata(TMP8, TMP10, REF_6);
-
-                vis_and(TMP0, MASK_7f, TMP0);
-
-                vis_and(TMP2, MASK_7f, TMP2);
-
-                vis_psub16(TMP20, TMP0, TMP0);
-                vis_st64(TMP0, dest[0]);
-
-                vis_psub16(TMP18, TMP2, TMP2);
-                vis_st64_2(TMP2, dest, 8);
-                dest += stride;
-        } while (--height);
-
-        vis_ld64(ref[0], TMP0);
-        vis_xor(REF_0, REF_2, TMP12);
-
-        vis_ld64_2(ref, 8, TMP2);
-        vis_xor(REF_4, REF_6, TMP16);
-
-        vis_ld64_2(ref, 16, TMP4);
-        vis_or(REF_0, REF_2, TMP14);
-
-        vis_or(REF_4, REF_6, TMP18);
-
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        vis_faligndata(TMP2, TMP4, REF_4);
-
-        vis_and(TMP12, MASK_fe, TMP12);
-
-        vis_and(TMP16, MASK_fe, TMP16);
-        vis_mul8x16(CONST_128, TMP12, TMP12);
-
-        vis_mul8x16(CONST_128, TMP16, TMP16);
-        vis_xor(REF_0, REF_2, TMP0);
-
-        vis_xor(REF_4, REF_6, TMP2);
-
-        vis_or(REF_0, REF_2, TMP20);
-
-        vis_and(TMP12, MASK_7f, TMP12);
-
-        vis_and(TMP16, MASK_7f, TMP16);
-
-        vis_psub16(TMP14, TMP12, TMP12);
-        vis_st64(TMP12, dest[0]);
-
-        vis_psub16(TMP18, TMP16, TMP16);
-        vis_st64_2(TMP16, dest, 8);
-        dest += stride;
-
-        vis_or(REF_4, REF_6, TMP18);
-
-        vis_and(TMP0, MASK_fe, TMP0);
-
-        vis_and(TMP2, MASK_fe, TMP2);
-        vis_mul8x16(CONST_128, TMP0, TMP0);
-
-        vis_mul8x16(CONST_128, TMP2, TMP2);
-
-        vis_and(TMP0, MASK_7f, TMP0);
-
-        vis_and(TMP2, MASK_7f, TMP2);
-
-        vis_psub16(TMP20, TMP0, TMP0);
-        vis_st64(TMP0, dest[0]);
-
-        vis_psub16(TMP18, TMP2, TMP2);
-        vis_st64_2(TMP2, dest, 8);
-}
-
-static void MC_put_y_8_vis (uint8_t * dest, const uint8_t * ref,
-                            const ptrdiff_t stride, int height)
-{
-        ref = vis_alignaddr(ref);
-        vis_ld64(ref[0], TMP0);
-
-        vis_ld64_2(ref, 8, TMP2);
-        ref += stride;
-
-        vis_ld64(ref[0], TMP4);
-
-        vis_ld64_2(ref, 8, TMP6);
-        ref += stride;
-
-        vis_ld64(constants_fe[0], MASK_fe);
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        vis_ld64(constants_7f[0], MASK_7f);
-        vis_faligndata(TMP4, TMP6, REF_2);
-
-        vis_ld64(constants128[0], CONST_128);
-        height = (height >> 1) - 1;
-        do {    /* 12 cycles */
-                vis_ld64(ref[0], TMP0);
-                vis_xor(REF_0, REF_2, TMP4);
-
-                vis_ld64_2(ref, 8, TMP2);
-                ref += stride;
-                vis_and(TMP4, MASK_fe, TMP4);
-
-                vis_or(REF_0, REF_2, TMP6);
-                vis_mul8x16(CONST_128, TMP4, TMP4);
-
-                vis_faligndata(TMP0, TMP2, REF_0);
-                vis_ld64(ref[0], TMP0);
-
-                vis_ld64_2(ref, 8, TMP2);
-                ref += stride;
-                vis_xor(REF_0, REF_2, TMP12);
-
-                vis_and(TMP4, MASK_7f, TMP4);
-
-                vis_and(TMP12, MASK_fe, TMP12);
-
-                vis_mul8x16(CONST_128, TMP12, TMP12);
-                vis_or(REF_0, REF_2, TMP14);
-
-                vis_psub16(TMP6, TMP4, DST_0);
-                vis_st64(DST_0, dest[0]);
-                dest += stride;
-
-                vis_faligndata(TMP0, TMP2, REF_2);
-
-                vis_and(TMP12, MASK_7f, TMP12);
-
-                vis_psub16(TMP14, TMP12, DST_0);
-                vis_st64(DST_0, dest[0]);
-                dest += stride;
-        } while (--height);
-
-        vis_ld64(ref[0], TMP0);
-        vis_xor(REF_0, REF_2, TMP4);
-
-        vis_ld64_2(ref, 8, TMP2);
-        vis_and(TMP4, MASK_fe, TMP4);
-
-        vis_or(REF_0, REF_2, TMP6);
-        vis_mul8x16(CONST_128, TMP4, TMP4);
-
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        vis_xor(REF_0, REF_2, TMP12);
-
-        vis_and(TMP4, MASK_7f, TMP4);
-
-        vis_and(TMP12, MASK_fe, TMP12);
-
-        vis_mul8x16(CONST_128, TMP12, TMP12);
-        vis_or(REF_0, REF_2, TMP14);
-
-        vis_psub16(TMP6, TMP4, DST_0);
-        vis_st64(DST_0, dest[0]);
-        dest += stride;
-
-        vis_and(TMP12, MASK_7f, TMP12);
-
-        vis_psub16(TMP14, TMP12, DST_0);
-        vis_st64(DST_0, dest[0]);
-}
-
-static void MC_avg_y_16_vis (uint8_t * dest, const uint8_t * ref,
-                             const ptrdiff_t stride, int height)
-{
-        int stride_8 = stride + 8;
-        int stride_16 = stride + 16;
-
-        vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-        ref = vis_alignaddr(ref);
-
-        vis_ld64(ref[ 0], TMP0);
-        vis_fzero(ZERO);
-
-        vis_ld64(ref[ 8], TMP2);
-
-        vis_ld64(ref[16], TMP4);
-
-        vis_ld64(constants3[0], CONST_3);
-        vis_faligndata(TMP0, TMP2, REF_2);
-
-        vis_ld64(constants256_512[0], CONST_256);
-        vis_faligndata(TMP2, TMP4, REF_6);
-        height >>= 1;
-
-        do {    /* 31 cycles */
-                vis_ld64_2(ref, stride, TMP0);
-                vis_pmerge(ZERO,       REF_2,     TMP12);
-                vis_mul8x16au(REF_2_1, CONST_256, TMP14);
-
-                vis_ld64_2(ref, stride_8, TMP2);
-                vis_pmerge(ZERO,       REF_6,     TMP16);
-                vis_mul8x16au(REF_6_1, CONST_256, TMP18);
-
-                vis_ld64_2(ref, stride_16, TMP4);
-                ref += stride;
-
-                vis_ld64(dest[0], DST_0);
-                vis_faligndata(TMP0, TMP2, REF_0);
-
-                vis_ld64_2(dest, 8, DST_2);
-                vis_faligndata(TMP2, TMP4, REF_4);
-
-                vis_ld64_2(ref, stride, TMP6);
-                vis_pmerge(ZERO,     REF_0,     TMP0);
-                vis_mul8x16au(REF_0_1, CONST_256, TMP2);
-
-                vis_ld64_2(ref, stride_8, TMP8);
-                vis_pmerge(ZERO,     REF_4,     TMP4);
-
-                vis_ld64_2(ref, stride_16, TMP10);
-                ref += stride;
-
-                vis_ld64_2(dest, stride, REF_S0/*DST_4*/);
-                vis_faligndata(TMP6, TMP8, REF_2);
-                vis_mul8x16au(REF_4_1, CONST_256, TMP6);
-
-                vis_ld64_2(dest, stride_8, REF_S2/*DST_6*/);
-                vis_faligndata(TMP8, TMP10, REF_6);
-                vis_mul8x16al(DST_0,   CONST_512, TMP20);
-
-                vis_padd16(TMP0, CONST_3, TMP0);
-                vis_mul8x16al(DST_1,   CONST_512, TMP22);
-
-                vis_padd16(TMP2, CONST_3, TMP2);
-                vis_mul8x16al(DST_2,   CONST_512, TMP24);
-
-                vis_padd16(TMP4, CONST_3, TMP4);
-                vis_mul8x16al(DST_3,   CONST_512, TMP26);
-
-                vis_padd16(TMP6, CONST_3, TMP6);
-
-                vis_padd16(TMP12, TMP20, TMP12);
-                vis_mul8x16al(REF_S0,   CONST_512, TMP20);
-
-                vis_padd16(TMP14, TMP22, TMP14);
-                vis_mul8x16al(REF_S0_1, CONST_512, TMP22);
-
-                vis_padd16(TMP16, TMP24, TMP16);
-                vis_mul8x16al(REF_S2,   CONST_512, TMP24);
-
-                vis_padd16(TMP18, TMP26, TMP18);
-                vis_mul8x16al(REF_S2_1, CONST_512, TMP26);
-
-                vis_padd16(TMP12, TMP0, TMP12);
-                vis_mul8x16au(REF_2,   CONST_256, TMP28);
-
-                vis_padd16(TMP14, TMP2, TMP14);
-                vis_mul8x16au(REF_2_1, CONST_256, TMP30);
-
-                vis_padd16(TMP16, TMP4, TMP16);
-                vis_mul8x16au(REF_6,   CONST_256, REF_S4);
-
-                vis_padd16(TMP18, TMP6, TMP18);
-                vis_mul8x16au(REF_6_1, CONST_256, REF_S6);
-
-                vis_pack16(TMP12, DST_0);
-                vis_padd16(TMP28, TMP0, TMP12);
-
-                vis_pack16(TMP14, DST_1);
-                vis_st64(DST_0, dest[0]);
-                vis_padd16(TMP30, TMP2, TMP14);
-
-                vis_pack16(TMP16, DST_2);
-                vis_padd16(REF_S4, TMP4, TMP16);
-
-                vis_pack16(TMP18, DST_3);
-                vis_st64_2(DST_2, dest, 8);
-                dest += stride;
-                vis_padd16(REF_S6, TMP6, TMP18);
-
-                vis_padd16(TMP12, TMP20, TMP12);
-
-                vis_padd16(TMP14, TMP22, TMP14);
-                vis_pack16(TMP12, DST_0);
-
-                vis_padd16(TMP16, TMP24, TMP16);
-                vis_pack16(TMP14, DST_1);
-                vis_st64(DST_0, dest[0]);
-
-                vis_padd16(TMP18, TMP26, TMP18);
-                vis_pack16(TMP16, DST_2);
-
-                vis_pack16(TMP18, DST_3);
-                vis_st64_2(DST_2, dest, 8);
-                dest += stride;
-        } while (--height);
-}
-
-static void MC_avg_y_8_vis (uint8_t * dest, const uint8_t * ref,
-                            const ptrdiff_t stride, int height)
-{
-        int stride_8 = stride + 8;
-
-        vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-        ref = vis_alignaddr(ref);
-
-        vis_ld64(ref[ 0], TMP0);
-        vis_fzero(ZERO);
-
-        vis_ld64(ref[ 8], TMP2);
-
-        vis_ld64(constants3[0], CONST_3);
-        vis_faligndata(TMP0, TMP2, REF_2);
-
-        vis_ld64(constants256_512[0], CONST_256);
-
-        height >>= 1;
-        do {    /* 20 cycles */
-                vis_ld64_2(ref, stride, TMP0);
-                vis_pmerge(ZERO,       REF_2,     TMP8);
-                vis_mul8x16au(REF_2_1, CONST_256, TMP10);
-
-                vis_ld64_2(ref, stride_8, TMP2);
-                ref += stride;
-
-                vis_ld64(dest[0], DST_0);
-
-                vis_ld64_2(dest, stride, DST_2);
-                vis_faligndata(TMP0, TMP2, REF_0);
-
-                vis_ld64_2(ref, stride, TMP4);
-                vis_mul8x16al(DST_0,   CONST_512, TMP16);
-                vis_pmerge(ZERO,       REF_0,     TMP12);
-
-                vis_ld64_2(ref, stride_8, TMP6);
-                ref += stride;
-                vis_mul8x16al(DST_1,   CONST_512, TMP18);
-                vis_pmerge(ZERO,       REF_0_1,   TMP14);
-
-                vis_padd16(TMP12, CONST_3, TMP12);
-                vis_mul8x16al(DST_2,   CONST_512, TMP24);
-
-                vis_padd16(TMP14, CONST_3, TMP14);
-                vis_mul8x16al(DST_3,   CONST_512, TMP26);
-
-                vis_faligndata(TMP4, TMP6, REF_2);
-
-                vis_padd16(TMP8, TMP12, TMP8);
-
-                vis_padd16(TMP10, TMP14, TMP10);
-                vis_mul8x16au(REF_2,   CONST_256, TMP20);
-
-                vis_padd16(TMP8, TMP16, TMP0);
-                vis_mul8x16au(REF_2_1, CONST_256, TMP22);
-
-                vis_padd16(TMP10, TMP18, TMP2);
-                vis_pack16(TMP0, DST_0);
-
-                vis_pack16(TMP2, DST_1);
-                vis_st64(DST_0, dest[0]);
-                dest += stride;
-                vis_padd16(TMP12, TMP20, TMP12);
-
-                vis_padd16(TMP14, TMP22, TMP14);
-
-                vis_padd16(TMP12, TMP24, TMP0);
-
-                vis_padd16(TMP14, TMP26, TMP2);
-                vis_pack16(TMP0, DST_2);
-
-                vis_pack16(TMP2, DST_3);
-                vis_st64(DST_2, dest[0]);
-                dest += stride;
-        } while (--height);
-}
-
-static void MC_put_xy_16_vis (uint8_t * dest, const uint8_t * ref,
-                              const ptrdiff_t stride, int height)
-{
-        unsigned long off = (unsigned long) ref & 0x7;
-        unsigned long off_plus_1 = off + 1;
-        int stride_8 = stride + 8;
-        int stride_16 = stride + 16;
-
-        vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-        ref = vis_alignaddr(ref);
-
-        vis_ld64(ref[ 0], TMP0);
-        vis_fzero(ZERO);
-
-        vis_ld64(ref[ 8], TMP2);
-
-        vis_ld64(ref[16], TMP4);
-
-        vis_ld64(constants2[0], CONST_2);
-        vis_faligndata(TMP0, TMP2, REF_S0);
-
-        vis_ld64(constants256_512[0], CONST_256);
-        vis_faligndata(TMP2, TMP4, REF_S4);
-
-        if (off != 0x7) {
-                vis_alignaddr_g0((void *)off_plus_1);
-                vis_faligndata(TMP0, TMP2, REF_S2);
-                vis_faligndata(TMP2, TMP4, REF_S6);
-        } else {
-                vis_src1(TMP2, REF_S2);
-                vis_src1(TMP4, REF_S6);
-        }
-
-        height >>= 1;
-        do {
-                vis_ld64_2(ref, stride, TMP0);
-                vis_mul8x16au(REF_S0, CONST_256, TMP12);
-                vis_pmerge(ZERO,      REF_S0_1,  TMP14);
-
-                vis_alignaddr_g0((void *)off);
-
-                vis_ld64_2(ref, stride_8, TMP2);
-                vis_mul8x16au(REF_S2, CONST_256, TMP16);
-                vis_pmerge(ZERO,      REF_S2_1,  TMP18);
-
-                vis_ld64_2(ref, stride_16, TMP4);
-                ref += stride;
-                vis_mul8x16au(REF_S4, CONST_256, TMP20);
-                vis_pmerge(ZERO,      REF_S4_1,  TMP22);
-
-                vis_ld64_2(ref, stride, TMP6);
-                vis_mul8x16au(REF_S6, CONST_256, TMP24);
-                vis_pmerge(ZERO,      REF_S6_1,  TMP26);
-
-                vis_ld64_2(ref, stride_8, TMP8);
-                vis_faligndata(TMP0, TMP2, REF_0);
-
-                vis_ld64_2(ref, stride_16, TMP10);
-                ref += stride;
-                vis_faligndata(TMP2, TMP4, REF_4);
-
-                vis_faligndata(TMP6, TMP8, REF_S0);
-
-                vis_faligndata(TMP8, TMP10, REF_S4);
-
-                if (off != 0x7) {
-                        vis_alignaddr_g0((void *)off_plus_1);
-                        vis_faligndata(TMP0, TMP2, REF_2);
-                        vis_faligndata(TMP2, TMP4, REF_6);
-                        vis_faligndata(TMP6, TMP8, REF_S2);
-                        vis_faligndata(TMP8, TMP10, REF_S6);
-                } else {
-                        vis_src1(TMP2, REF_2);
-                        vis_src1(TMP4, REF_6);
-                        vis_src1(TMP8, REF_S2);
-                        vis_src1(TMP10, REF_S6);
-                }
-
-                vis_mul8x16au(REF_0, CONST_256, TMP0);
-                vis_pmerge(ZERO,      REF_0_1,  TMP2);
-
-                vis_mul8x16au(REF_2, CONST_256, TMP4);
-                vis_pmerge(ZERO,      REF_2_1,  TMP6);
-
-                vis_padd16(TMP0, CONST_2, TMP8);
-                vis_mul8x16au(REF_4, CONST_256, TMP0);
-
-                vis_padd16(TMP2, CONST_2, TMP10);
-                vis_mul8x16au(REF_4_1, CONST_256, TMP2);
-
-                vis_padd16(TMP8, TMP4, TMP8);
-                vis_mul8x16au(REF_6, CONST_256, TMP4);
-
-                vis_padd16(TMP10, TMP6, TMP10);
-                vis_mul8x16au(REF_6_1, CONST_256, TMP6);
-
-                vis_padd16(TMP12, TMP8, TMP12);
-
-                vis_padd16(TMP14, TMP10, TMP14);
-
-                vis_padd16(TMP12, TMP16, TMP12);
-
-                vis_padd16(TMP14, TMP18, TMP14);
-                vis_pack16(TMP12, DST_0);
-
-                vis_pack16(TMP14, DST_1);
-                vis_st64(DST_0, dest[0]);
-                vis_padd16(TMP0, CONST_2, TMP12);
-
-                vis_mul8x16au(REF_S0, CONST_256, TMP0);
-                vis_padd16(TMP2, CONST_2, TMP14);
-
-                vis_mul8x16au(REF_S0_1, CONST_256, TMP2);
-                vis_padd16(TMP12, TMP4, TMP12);
-
-                vis_mul8x16au(REF_S2, CONST_256, TMP4);
-                vis_padd16(TMP14, TMP6, TMP14);
-
-                vis_mul8x16au(REF_S2_1, CONST_256, TMP6);
-                vis_padd16(TMP20, TMP12, TMP20);
-
-                vis_padd16(TMP22, TMP14, TMP22);
-
-                vis_padd16(TMP20, TMP24, TMP20);
-
-                vis_padd16(TMP22, TMP26, TMP22);
-                vis_pack16(TMP20, DST_2);
-
-                vis_pack16(TMP22, DST_3);
-                vis_st64_2(DST_2, dest, 8);
-                dest += stride;
-                vis_padd16(TMP0, TMP4, TMP24);
-
-                vis_mul8x16au(REF_S4, CONST_256, TMP0);
-                vis_padd16(TMP2, TMP6, TMP26);
-
-                vis_mul8x16au(REF_S4_1, CONST_256, TMP2);
-                vis_padd16(TMP24, TMP8, TMP24);
-
-                vis_padd16(TMP26, TMP10, TMP26);
-                vis_pack16(TMP24, DST_0);
-
-                vis_pack16(TMP26, DST_1);
-                vis_st64(DST_0, dest[0]);
-                vis_pmerge(ZERO, REF_S6, TMP4);
-
-                vis_pmerge(ZERO,      REF_S6_1,  TMP6);
-
-                vis_padd16(TMP0, TMP4, TMP0);
-
-                vis_padd16(TMP2, TMP6, TMP2);
-
-                vis_padd16(TMP0, TMP12, TMP0);
-
-                vis_padd16(TMP2, TMP14, TMP2);
-                vis_pack16(TMP0, DST_2);
-
-                vis_pack16(TMP2, DST_3);
-                vis_st64_2(DST_2, dest, 8);
-                dest += stride;
-        } while (--height);
-}
-
-static void MC_put_xy_8_vis (uint8_t * dest, const uint8_t * ref,
-                             const ptrdiff_t stride, int height)
-{
-        unsigned long off = (unsigned long) ref & 0x7;
-        unsigned long off_plus_1 = off + 1;
-        int stride_8 = stride + 8;
-
-        vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-        ref = vis_alignaddr(ref);
-
-        vis_ld64(ref[ 0], TMP0);
-        vis_fzero(ZERO);
-
-        vis_ld64(ref[ 8], TMP2);
-
-        vis_ld64(constants2[0], CONST_2);
-
-        vis_ld64(constants256_512[0], CONST_256);
-        vis_faligndata(TMP0, TMP2, REF_S0);
-
-        if (off != 0x7) {
-                vis_alignaddr_g0((void *)off_plus_1);
-                vis_faligndata(TMP0, TMP2, REF_S2);
-        } else {
-                vis_src1(TMP2, REF_S2);
-        }
-
-        height >>= 1;
-        do {    /* 26 cycles */
-                vis_ld64_2(ref, stride, TMP0);
-                vis_mul8x16au(REF_S0,   CONST_256, TMP8);
-                vis_pmerge(ZERO,        REF_S2,    TMP12);
-
-                vis_alignaddr_g0((void *)off);
-
-                vis_ld64_2(ref, stride_8, TMP2);
-                ref += stride;
-                vis_mul8x16au(REF_S0_1, CONST_256, TMP10);
-                vis_pmerge(ZERO,        REF_S2_1,  TMP14);
-
-                vis_ld64_2(ref, stride, TMP4);
-
-                vis_ld64_2(ref, stride_8, TMP6);
-                ref += stride;
-                vis_faligndata(TMP0, TMP2, REF_S4);
-
-                vis_pmerge(ZERO, REF_S4, TMP18);
-
-                vis_pmerge(ZERO, REF_S4_1, TMP20);
-
-                vis_faligndata(TMP4, TMP6, REF_S0);
-
-                if (off != 0x7) {
-                        vis_alignaddr_g0((void *)off_plus_1);
-                        vis_faligndata(TMP0, TMP2, REF_S6);
-                        vis_faligndata(TMP4, TMP6, REF_S2);
-                } else {
-                        vis_src1(TMP2, REF_S6);
-                        vis_src1(TMP6, REF_S2);
-                }
-
-                vis_padd16(TMP18, CONST_2, TMP18);
-                vis_mul8x16au(REF_S6,   CONST_256, TMP22);
-
-                vis_padd16(TMP20, CONST_2, TMP20);
-                vis_mul8x16au(REF_S6_1, CONST_256, TMP24);
-
-                vis_mul8x16au(REF_S0,   CONST_256, TMP26);
-                vis_pmerge(ZERO, REF_S0_1, TMP28);
-
-                vis_mul8x16au(REF_S2,   CONST_256, TMP30);
-                vis_padd16(TMP18, TMP22, TMP18);
-
-                vis_mul8x16au(REF_S2_1, CONST_256, TMP32);
-                vis_padd16(TMP20, TMP24, TMP20);
-
-                vis_padd16(TMP8,  TMP18, TMP8);
-
-                vis_padd16(TMP10, TMP20, TMP10);
-
-                vis_padd16(TMP8,  TMP12, TMP8);
-
-                vis_padd16(TMP10, TMP14, TMP10);
-                vis_pack16(TMP8,  DST_0);
-
-                vis_pack16(TMP10, DST_1);
-                vis_st64(DST_0, dest[0]);
-                dest += stride;
-                vis_padd16(TMP18, TMP26, TMP18);
-
-                vis_padd16(TMP20, TMP28, TMP20);
-
-                vis_padd16(TMP18, TMP30, TMP18);
-
-                vis_padd16(TMP20, TMP32, TMP20);
-                vis_pack16(TMP18, DST_2);
-
-                vis_pack16(TMP20, DST_3);
-                vis_st64(DST_2, dest[0]);
-                dest += stride;
-        } while (--height);
-}
-
-static void MC_avg_xy_16_vis (uint8_t * dest, const uint8_t * ref,
-                              const ptrdiff_t stride, int height)
-{
-        unsigned long off = (unsigned long) ref & 0x7;
-        unsigned long off_plus_1 = off + 1;
-        int stride_8 = stride + 8;
-        int stride_16 = stride + 16;
-
-        vis_set_gsr(4 << VIS_GSR_SCALEFACT_SHIFT);
-
-        ref = vis_alignaddr(ref);
-
-        vis_ld64(ref[ 0], TMP0);
-        vis_fzero(ZERO);
-
-        vis_ld64(ref[ 8], TMP2);
-
-        vis_ld64(ref[16], TMP4);
-
-        vis_ld64(constants6[0], CONST_6);
-        vis_faligndata(TMP0, TMP2, REF_S0);
-
-        vis_ld64(constants256_1024[0], CONST_256);
-        vis_faligndata(TMP2, TMP4, REF_S4);
-
-        if (off != 0x7) {
-                vis_alignaddr_g0((void *)off_plus_1);
-                vis_faligndata(TMP0, TMP2, REF_S2);
-                vis_faligndata(TMP2, TMP4, REF_S6);
-        } else {
-                vis_src1(TMP2, REF_S2);
-                vis_src1(TMP4, REF_S6);
-        }
-
-        height >>= 1;
-        do {    /* 55 cycles */
-                vis_ld64_2(ref, stride, TMP0);
-                vis_mul8x16au(REF_S0, CONST_256, TMP12);
-                vis_pmerge(ZERO,      REF_S0_1,  TMP14);
-
-                vis_alignaddr_g0((void *)off);
-
-                vis_ld64_2(ref, stride_8, TMP2);
-                vis_mul8x16au(REF_S2, CONST_256, TMP16);
-                vis_pmerge(ZERO,      REF_S2_1,  TMP18);
-
-                vis_ld64_2(ref, stride_16, TMP4);
-                ref += stride;
-                vis_mul8x16au(REF_S4, CONST_256, TMP20);
-                vis_pmerge(ZERO,      REF_S4_1,  TMP22);
-
-                vis_ld64_2(ref, stride, TMP6);
-                vis_mul8x16au(REF_S6, CONST_256, TMP24);
-                vis_pmerge(ZERO,      REF_S6_1,  TMP26);
-
-                vis_ld64_2(ref, stride_8, TMP8);
-                vis_faligndata(TMP0, TMP2, REF_0);
-
-                vis_ld64_2(ref, stride_16, TMP10);
-                ref += stride;
-                vis_faligndata(TMP2, TMP4, REF_4);
-
-                vis_ld64(dest[0], DST_0);
-                vis_faligndata(TMP6, TMP8, REF_S0);
-
-                vis_ld64_2(dest, 8, DST_2);
-                vis_faligndata(TMP8, TMP10, REF_S4);
-
-                if (off != 0x7) {
-                        vis_alignaddr_g0((void *)off_plus_1);
-                        vis_faligndata(TMP0, TMP2, REF_2);
-                        vis_faligndata(TMP2, TMP4, REF_6);
-                        vis_faligndata(TMP6, TMP8, REF_S2);
-                        vis_faligndata(TMP8, TMP10, REF_S6);
-                } else {
-                        vis_src1(TMP2, REF_2);
-                        vis_src1(TMP4, REF_6);
-                        vis_src1(TMP8, REF_S2);
-                        vis_src1(TMP10, REF_S6);
-                }
-
-                vis_mul8x16al(DST_0,   CONST_1024, TMP30);
-                vis_pmerge(ZERO, REF_0, TMP0);
-
-                vis_mul8x16al(DST_1,   CONST_1024, TMP32);
-                vis_pmerge(ZERO,      REF_0_1,  TMP2);
-
-                vis_mul8x16au(REF_2, CONST_256, TMP4);
-                vis_pmerge(ZERO,      REF_2_1,  TMP6);
-
-                vis_mul8x16al(DST_2,   CONST_1024, REF_0);
-                vis_padd16(TMP0, CONST_6, TMP0);
-
-                vis_mul8x16al(DST_3,   CONST_1024, REF_2);
-                vis_padd16(TMP2, CONST_6, TMP2);
-
-                vis_padd16(TMP0, TMP4, TMP0);
-                vis_mul8x16au(REF_4, CONST_256, TMP4);
-
-                vis_padd16(TMP2, TMP6, TMP2);
-                vis_mul8x16au(REF_4_1, CONST_256, TMP6);
-
-                vis_padd16(TMP12, TMP0, TMP12);
-                vis_mul8x16au(REF_6, CONST_256, TMP8);
-
-                vis_padd16(TMP14, TMP2, TMP14);
-                vis_mul8x16au(REF_6_1, CONST_256, TMP10);
-
-                vis_padd16(TMP12, TMP16, TMP12);
-                vis_mul8x16au(REF_S0, CONST_256, REF_4);
-
-                vis_padd16(TMP14, TMP18, TMP14);
-                vis_mul8x16au(REF_S0_1, CONST_256, REF_6);
-
-                vis_padd16(TMP12, TMP30, TMP12);
-
-                vis_padd16(TMP14, TMP32, TMP14);
-                vis_pack16(TMP12, DST_0);
-
-                vis_pack16(TMP14, DST_1);
-                vis_st64(DST_0, dest[0]);
-                vis_padd16(TMP4, CONST_6, TMP4);
-
-                vis_ld64_2(dest, stride, DST_0);
-                vis_padd16(TMP6, CONST_6, TMP6);
-                vis_mul8x16au(REF_S2, CONST_256, TMP12);
-
-                vis_padd16(TMP4, TMP8, TMP4);
-                vis_mul8x16au(REF_S2_1, CONST_256,  TMP14);
-
-                vis_padd16(TMP6, TMP10, TMP6);
-
-                vis_padd16(TMP20, TMP4, TMP20);
-
-                vis_padd16(TMP22, TMP6, TMP22);
-
-                vis_padd16(TMP20, TMP24, TMP20);
-
-                vis_padd16(TMP22, TMP26, TMP22);
-
-                vis_padd16(TMP20, REF_0, TMP20);
-                vis_mul8x16au(REF_S4, CONST_256, REF_0);
-
-                vis_padd16(TMP22, REF_2, TMP22);
-                vis_pack16(TMP20, DST_2);
-
-                vis_pack16(TMP22, DST_3);
-                vis_st64_2(DST_2, dest, 8);
-                dest += stride;
-
-                vis_ld64_2(dest, 8, DST_2);
-                vis_mul8x16al(DST_0,   CONST_1024, TMP30);
-                vis_pmerge(ZERO,      REF_S4_1,  REF_2);
-
-                vis_mul8x16al(DST_1,   CONST_1024, TMP32);
-                vis_padd16(REF_4, TMP0, TMP8);
-
-                vis_mul8x16au(REF_S6, CONST_256, REF_4);
-                vis_padd16(REF_6, TMP2, TMP10);
-
-                vis_mul8x16au(REF_S6_1, CONST_256, REF_6);
-                vis_padd16(TMP8, TMP12, TMP8);
-
-                vis_padd16(TMP10, TMP14, TMP10);
-
-                vis_padd16(TMP8, TMP30, TMP8);
-
-                vis_padd16(TMP10, TMP32, TMP10);
-                vis_pack16(TMP8, DST_0);
-
-                vis_pack16(TMP10, DST_1);
-                vis_st64(DST_0, dest[0]);
-
-                vis_padd16(REF_0, TMP4, REF_0);
-
-                vis_mul8x16al(DST_2,   CONST_1024, TMP30);
-                vis_padd16(REF_2, TMP6, REF_2);
-
-                vis_mul8x16al(DST_3,   CONST_1024, TMP32);
-                vis_padd16(REF_0, REF_4, REF_0);
-
-                vis_padd16(REF_2, REF_6, REF_2);
-
-                vis_padd16(REF_0, TMP30, REF_0);
-
-                /* stall */
-
-                vis_padd16(REF_2, TMP32, REF_2);
-                vis_pack16(REF_0, DST_2);
-
-                vis_pack16(REF_2, DST_3);
-                vis_st64_2(DST_2, dest, 8);
-                dest += stride;
-        } while (--height);
-}
-
-static void MC_avg_xy_8_vis (uint8_t * dest, const uint8_t * ref,
-                             const ptrdiff_t stride, int height)
-{
-        unsigned long off = (unsigned long) ref & 0x7;
-        unsigned long off_plus_1 = off + 1;
-        int stride_8 = stride + 8;
-
-        vis_set_gsr(4 << VIS_GSR_SCALEFACT_SHIFT);
-
-        ref = vis_alignaddr(ref);
-
-        vis_ld64(ref[0], TMP0);
-        vis_fzero(ZERO);
-
-        vis_ld64_2(ref, 8, TMP2);
-
-        vis_ld64(constants6[0], CONST_6);
-
-        vis_ld64(constants256_1024[0], CONST_256);
-        vis_faligndata(TMP0, TMP2, REF_S0);
-
-        if (off != 0x7) {
-                vis_alignaddr_g0((void *)off_plus_1);
-                vis_faligndata(TMP0, TMP2, REF_S2);
-        } else {
-                vis_src1(TMP2, REF_S2);
-        }
-
-        height >>= 1;
-        do {    /* 31 cycles */
-                vis_ld64_2(ref, stride, TMP0);
-                vis_mul8x16au(REF_S0, CONST_256, TMP8);
-                vis_pmerge(ZERO,      REF_S0_1,  TMP10);
-
-                vis_ld64_2(ref, stride_8, TMP2);
-                ref += stride;
-                vis_mul8x16au(REF_S2, CONST_256, TMP12);
-                vis_pmerge(ZERO,      REF_S2_1,  TMP14);
-
-                vis_alignaddr_g0((void *)off);
-
-                vis_ld64_2(ref, stride, TMP4);
-                vis_faligndata(TMP0, TMP2, REF_S4);
-
-                vis_ld64_2(ref, stride_8, TMP6);
-                ref += stride;
-
-                vis_ld64(dest[0], DST_0);
-                vis_faligndata(TMP4, TMP6, REF_S0);
-
-                vis_ld64_2(dest, stride, DST_2);
-
-                if (off != 0x7) {
-                        vis_alignaddr_g0((void *)off_plus_1);
-                        vis_faligndata(TMP0, TMP2, REF_S6);
-                        vis_faligndata(TMP4, TMP6, REF_S2);
-                } else {
-                        vis_src1(TMP2, REF_S6);
-                        vis_src1(TMP6, REF_S2);
-                }
-
-                vis_mul8x16al(DST_0,   CONST_1024, TMP30);
-                vis_pmerge(ZERO, REF_S4, TMP22);
-
-                vis_mul8x16al(DST_1,   CONST_1024, TMP32);
-                vis_pmerge(ZERO,      REF_S4_1,  TMP24);
-
-                vis_mul8x16au(REF_S6, CONST_256, TMP26);
-                vis_pmerge(ZERO,      REF_S6_1,  TMP28);
-
-                vis_mul8x16au(REF_S0, CONST_256, REF_S4);
-                vis_padd16(TMP22, CONST_6, TMP22);
-
-                vis_mul8x16au(REF_S0_1, CONST_256, REF_S6);
-                vis_padd16(TMP24, CONST_6, TMP24);
-
-                vis_mul8x16al(DST_2,   CONST_1024, REF_0);
-                vis_padd16(TMP22, TMP26, TMP22);
-
-                vis_mul8x16al(DST_3,   CONST_1024, REF_2);
-                vis_padd16(TMP24, TMP28, TMP24);
-
-                vis_mul8x16au(REF_S2, CONST_256, TMP26);
-                vis_padd16(TMP8, TMP22, TMP8);
-
-                vis_mul8x16au(REF_S2_1, CONST_256, TMP28);
-                vis_padd16(TMP10, TMP24, TMP10);
-
-                vis_padd16(TMP8, TMP12, TMP8);
-
-                vis_padd16(TMP10, TMP14, TMP10);
-
-                vis_padd16(TMP8, TMP30, TMP8);
-
-                vis_padd16(TMP10, TMP32, TMP10);
-                vis_pack16(TMP8, DST_0);
-
-                vis_pack16(TMP10, DST_1);
-                vis_st64(DST_0, dest[0]);
-                dest += stride;
-
-                vis_padd16(REF_S4, TMP22, TMP12);
-
-                vis_padd16(REF_S6, TMP24, TMP14);
-
-                vis_padd16(TMP12, TMP26, TMP12);
-
-                vis_padd16(TMP14, TMP28, TMP14);
-
-                vis_padd16(TMP12, REF_0, TMP12);
-
-                vis_padd16(TMP14, REF_2, TMP14);
-                vis_pack16(TMP12, DST_2);
-
-                vis_pack16(TMP14, DST_3);
-                vis_st64(DST_2, dest[0]);
-                dest += stride;
-        } while (--height);
-}
-
-/* End of rounding code */
-
-/* Start of no rounding code */
-/* The trick used in some of this file is the formula from the MMX
- * motion comp code, which is:
- *
- * (x+y)>>1 == (x&y)+((x^y)>>1)
- *
- * This allows us to average 8 bytes at a time in a 64-bit FPU reg.
- * We avoid overflows by masking before we do the shift, and we
- * implement the shift by multiplying by 1/2 using mul8x16.  So in
- * VIS this is (assume 'x' is in f0, 'y' is in f2, a repeating mask
- * of '0xfe' is in f4, a repeating mask of '0x7f' is in f6, and
- * the value 0x80808080 is in f8):
- *
- *      fxor            f0,   f2, f10
- *      fand            f10,  f4, f10
- *      fmul8x16        f8,  f10, f10
- *      fand            f10,  f6, f10
- *      fand            f0,   f2, f12
- *      fpadd16         f12, f10, f10
- */
-
-static void MC_put_no_round_o_16_vis (uint8_t * dest, const uint8_t * ref,
-                                      const ptrdiff_t stride, int height)
-{
-        ref = vis_alignaddr(ref);
-        do {    /* 5 cycles */
-                vis_ld64(ref[0], TMP0);
-
-                vis_ld64_2(ref, 8, TMP2);
-
-                vis_ld64_2(ref, 16, TMP4);
-                ref += stride;
-
-                vis_faligndata(TMP0, TMP2, REF_0);
-                vis_st64(REF_0, dest[0]);
-
-                vis_faligndata(TMP2, TMP4, REF_2);
-                vis_st64_2(REF_2, dest, 8);
-                dest += stride;
-        } while (--height);
-}
-
-static void MC_put_no_round_o_8_vis (uint8_t * dest, const uint8_t * ref,
-                                     const ptrdiff_t stride, int height)
-{
-        ref = vis_alignaddr(ref);
-        do {    /* 4 cycles */
-                vis_ld64(ref[0], TMP0);
-
-                vis_ld64(ref[8], TMP2);
-                ref += stride;
-
-                /* stall */
-
-                vis_faligndata(TMP0, TMP2, REF_0);
-                vis_st64(REF_0, dest[0]);
-                dest += stride;
-        } while (--height);
-}
-
-
-static void MC_avg_no_round_o_16_vis (uint8_t * dest, const uint8_t * ref,
-                                      const ptrdiff_t stride, int height)
-{
-        int stride_8 = stride + 8;
-
-        ref = vis_alignaddr(ref);
-
-        vis_ld64(ref[0], TMP0);
-
-        vis_ld64(ref[8], TMP2);
-
-        vis_ld64(ref[16], TMP4);
-
-        vis_ld64(dest[0], DST_0);
-
-        vis_ld64(dest[8], DST_2);
-
-        vis_ld64(constants_fe[0], MASK_fe);
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        vis_ld64(constants_7f[0], MASK_7f);
-        vis_faligndata(TMP2, TMP4, REF_2);
-
-        vis_ld64(constants128[0], CONST_128);
-
-        ref += stride;
-        height = (height >> 1) - 1;
-
-        do {    /* 24 cycles */
-                vis_ld64(ref[0], TMP0);
-                vis_xor(DST_0, REF_0, TMP6);
-
-                vis_ld64_2(ref, 8, TMP2);
-                vis_and(TMP6, MASK_fe, TMP6);
-
-                vis_ld64_2(ref, 16, TMP4);
-                ref += stride;
-                vis_mul8x16(CONST_128, TMP6, TMP6);
-                vis_xor(DST_2, REF_2, TMP8);
-
-                vis_and(TMP8, MASK_fe, TMP8);
-
-                vis_and(DST_0, REF_0, TMP10);
-                vis_ld64_2(dest, stride, DST_0);
-                vis_mul8x16(CONST_128, TMP8, TMP8);
-
-                vis_and(DST_2, REF_2, TMP12);
-                vis_ld64_2(dest, stride_8, DST_2);
-
-                vis_ld64(ref[0], TMP14);
-                vis_and(TMP6, MASK_7f, TMP6);
-
-                vis_and(TMP8, MASK_7f, TMP8);
-
-                vis_padd16(TMP10, TMP6, TMP6);
-                vis_st64(TMP6, dest[0]);
-
-                vis_padd16(TMP12, TMP8, TMP8);
-                vis_st64_2(TMP8, dest, 8);
-
-                dest += stride;
-                vis_ld64_2(ref, 8, TMP16);
-                vis_faligndata(TMP0, TMP2, REF_0);
-
-                vis_ld64_2(ref, 16, TMP18);
-                vis_faligndata(TMP2, TMP4, REF_2);
-                ref += stride;
-
-                vis_xor(DST_0, REF_0, TMP20);
-
-                vis_and(TMP20, MASK_fe, TMP20);
-
-                vis_xor(DST_2, REF_2, TMP22);
-                vis_mul8x16(CONST_128, TMP20, TMP20);
-
-                vis_and(TMP22, MASK_fe, TMP22);
-
-                vis_and(DST_0, REF_0, TMP24);
-                vis_mul8x16(CONST_128, TMP22, TMP22);
-
-                vis_and(DST_2, REF_2, TMP26);
-
-                vis_ld64_2(dest, stride, DST_0);
-                vis_faligndata(TMP14, TMP16, REF_0);
-
-                vis_ld64_2(dest, stride_8, DST_2);
-                vis_faligndata(TMP16, TMP18, REF_2);
-
-                vis_and(TMP20, MASK_7f, TMP20);
-
-                vis_and(TMP22, MASK_7f, TMP22);
-
-                vis_padd16(TMP24, TMP20, TMP20);
-                vis_st64(TMP20, dest[0]);
-
-                vis_padd16(TMP26, TMP22, TMP22);
-                vis_st64_2(TMP22, dest, 8);
-                dest += stride;
-        } while (--height);
-
-        vis_ld64(ref[0], TMP0);
-        vis_xor(DST_0, REF_0, TMP6);
-
-        vis_ld64_2(ref, 8, TMP2);
-        vis_and(TMP6, MASK_fe, TMP6);
-
-        vis_ld64_2(ref, 16, TMP4);
-        vis_mul8x16(CONST_128, TMP6, TMP6);
-        vis_xor(DST_2, REF_2, TMP8);
-
-        vis_and(TMP8, MASK_fe, TMP8);
-
-        vis_and(DST_0, REF_0, TMP10);
-        vis_ld64_2(dest, stride, DST_0);
-        vis_mul8x16(CONST_128, TMP8, TMP8);
-
-        vis_and(DST_2, REF_2, TMP12);
-        vis_ld64_2(dest, stride_8, DST_2);
-
-        vis_ld64(ref[0], TMP14);
-        vis_and(TMP6, MASK_7f, TMP6);
-
-        vis_and(TMP8, MASK_7f, TMP8);
-
-        vis_padd16(TMP10, TMP6, TMP6);
-        vis_st64(TMP6, dest[0]);
-
-        vis_padd16(TMP12, TMP8, TMP8);
-        vis_st64_2(TMP8, dest, 8);
-
-        dest += stride;
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        vis_faligndata(TMP2, TMP4, REF_2);
-
-        vis_xor(DST_0, REF_0, TMP20);
-
-        vis_and(TMP20, MASK_fe, TMP20);
-
-        vis_xor(DST_2, REF_2, TMP22);
-        vis_mul8x16(CONST_128, TMP20, TMP20);
-
-        vis_and(TMP22, MASK_fe, TMP22);
-
-        vis_and(DST_0, REF_0, TMP24);
-        vis_mul8x16(CONST_128, TMP22, TMP22);
-
-        vis_and(DST_2, REF_2, TMP26);
-
-        vis_and(TMP20, MASK_7f, TMP20);
-
-        vis_and(TMP22, MASK_7f, TMP22);
-
-        vis_padd16(TMP24, TMP20, TMP20);
-        vis_st64(TMP20, dest[0]);
-
-        vis_padd16(TMP26, TMP22, TMP22);
-        vis_st64_2(TMP22, dest, 8);
-}
-
-static void MC_put_no_round_x_16_vis (uint8_t * dest, const uint8_t * ref,
-                                      const ptrdiff_t stride, int height)
-{
-        unsigned long off = (unsigned long) ref & 0x7;
-        unsigned long off_plus_1 = off + 1;
-
-        ref = vis_alignaddr(ref);
-
-        vis_ld64(ref[0],    TMP0);
-
-        vis_ld64_2(ref, 8,  TMP2);
-
-        vis_ld64_2(ref, 16, TMP4);
-
-        vis_ld64(constants_fe[0], MASK_fe);
-
-        vis_ld64(constants_7f[0], MASK_7f);
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        vis_ld64(constants128[0], CONST_128);
-        vis_faligndata(TMP2, TMP4, REF_4);
-
-        if (off != 0x7) {
-                vis_alignaddr_g0((void *)off_plus_1);
-                vis_faligndata(TMP0, TMP2, REF_2);
-                vis_faligndata(TMP2, TMP4, REF_6);
-        } else {
-                vis_src1(TMP2, REF_2);
-                vis_src1(TMP4, REF_6);
-        }
-
-        ref += stride;
-        height = (height >> 1) - 1;
-
-        do {    /* 34 cycles */
-                vis_ld64(ref[0],    TMP0);
-                vis_xor(REF_0, REF_2, TMP6);
-
-                vis_ld64_2(ref, 8,  TMP2);
-                vis_xor(REF_4, REF_6, TMP8);
-
-                vis_ld64_2(ref, 16, TMP4);
-                vis_and(TMP6, MASK_fe, TMP6);
-                ref += stride;
-
-                vis_ld64(ref[0],    TMP14);
-                vis_mul8x16(CONST_128, TMP6, TMP6);
-                vis_and(TMP8, MASK_fe, TMP8);
-
-                vis_ld64_2(ref, 8,  TMP16);
-                vis_mul8x16(CONST_128, TMP8, TMP8);
-                vis_and(REF_0, REF_2, TMP10);
-
-                vis_ld64_2(ref, 16, TMP18);
-                ref += stride;
-                vis_and(REF_4, REF_6, TMP12);
-
-                vis_alignaddr_g0((void *)off);
-
-                vis_faligndata(TMP0, TMP2, REF_0);
-
-                vis_faligndata(TMP2, TMP4, REF_4);
-
-                if (off != 0x7) {
-                        vis_alignaddr_g0((void *)off_plus_1);
-                        vis_faligndata(TMP0, TMP2, REF_2);
-                        vis_faligndata(TMP2, TMP4, REF_6);
-                } else {
-                        vis_src1(TMP2, REF_2);
-                        vis_src1(TMP4, REF_6);
-                }
-
-                vis_and(TMP6, MASK_7f, TMP6);
-
-                vis_and(TMP8, MASK_7f, TMP8);
-
-                vis_padd16(TMP10, TMP6, TMP6);
-                vis_st64(TMP6, dest[0]);
-
-                vis_padd16(TMP12, TMP8, TMP8);
-                vis_st64_2(TMP8, dest, 8);
-                dest += stride;
-
-                vis_xor(REF_0, REF_2, TMP6);
-
-                vis_xor(REF_4, REF_6, TMP8);
-
-                vis_and(TMP6, MASK_fe, TMP6);
-
-                vis_mul8x16(CONST_128, TMP6, TMP6);
-                vis_and(TMP8, MASK_fe, TMP8);
-
-                vis_mul8x16(CONST_128, TMP8, TMP8);
-                vis_and(REF_0, REF_2, TMP10);
-
-                vis_and(REF_4, REF_6, TMP12);
-
-                vis_alignaddr_g0((void *)off);
-
-                vis_faligndata(TMP14, TMP16, REF_0);
-
-                vis_faligndata(TMP16, TMP18, REF_4);
-
-                if (off != 0x7) {
-                        vis_alignaddr_g0((void *)off_plus_1);
-                        vis_faligndata(TMP14, TMP16, REF_2);
-                        vis_faligndata(TMP16, TMP18, REF_6);
-                } else {
-                        vis_src1(TMP16, REF_2);
-                        vis_src1(TMP18, REF_6);
-                }
-
-                vis_and(TMP6, MASK_7f, TMP6);
-
-                vis_and(TMP8, MASK_7f, TMP8);
-
-                vis_padd16(TMP10, TMP6, TMP6);
-                vis_st64(TMP6, dest[0]);
-
-                vis_padd16(TMP12, TMP8, TMP8);
-                vis_st64_2(TMP8, dest, 8);
-                dest += stride;
-        } while (--height);
-
-        vis_ld64(ref[0],    TMP0);
-        vis_xor(REF_0, REF_2, TMP6);
-
-        vis_ld64_2(ref, 8,  TMP2);
-        vis_xor(REF_4, REF_6, TMP8);
-
-        vis_ld64_2(ref, 16, TMP4);
-        vis_and(TMP6, MASK_fe, TMP6);
-
-        vis_mul8x16(CONST_128, TMP6, TMP6);
-        vis_and(TMP8, MASK_fe, TMP8);
-
-        vis_mul8x16(CONST_128, TMP8, TMP8);
-        vis_and(REF_0, REF_2, TMP10);
-
-        vis_and(REF_4, REF_6, TMP12);
-
-        vis_alignaddr_g0((void *)off);
-
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        vis_faligndata(TMP2, TMP4, REF_4);
-
-        if (off != 0x7) {
-                vis_alignaddr_g0((void *)off_plus_1);
-                vis_faligndata(TMP0, TMP2, REF_2);
-                vis_faligndata(TMP2, TMP4, REF_6);
-        } else {
-                vis_src1(TMP2, REF_2);
-                vis_src1(TMP4, REF_6);
-        }
-
-        vis_and(TMP6, MASK_7f, TMP6);
-
-        vis_and(TMP8, MASK_7f, TMP8);
-
-        vis_padd16(TMP10, TMP6, TMP6);
-        vis_st64(TMP6, dest[0]);
-
-        vis_padd16(TMP12, TMP8, TMP8);
-        vis_st64_2(TMP8, dest, 8);
-        dest += stride;
-
-        vis_xor(REF_0, REF_2, TMP6);
-
-        vis_xor(REF_4, REF_6, TMP8);
-
-        vis_and(TMP6, MASK_fe, TMP6);
-
-        vis_mul8x16(CONST_128, TMP6, TMP6);
-        vis_and(TMP8, MASK_fe, TMP8);
-
-        vis_mul8x16(CONST_128, TMP8, TMP8);
-        vis_and(REF_0, REF_2, TMP10);
-
-        vis_and(REF_4, REF_6, TMP12);
-
-        vis_and(TMP6, MASK_7f, TMP6);
-
-        vis_and(TMP8, MASK_7f, TMP8);
-
-        vis_padd16(TMP10, TMP6, TMP6);
-        vis_st64(TMP6, dest[0]);
-
-        vis_padd16(TMP12, TMP8, TMP8);
-        vis_st64_2(TMP8, dest, 8);
-}
-
-static void MC_put_no_round_x_8_vis (uint8_t * dest, const uint8_t * ref,
-                                     const ptrdiff_t stride, int height)
-{
-        unsigned long off = (unsigned long) ref & 0x7;
-        unsigned long off_plus_1 = off + 1;
-
-        ref = vis_alignaddr(ref);
-
-        vis_ld64(ref[0], TMP0);
-
-        vis_ld64(ref[8], TMP2);
-
-        vis_ld64(constants_fe[0], MASK_fe);
-
-        vis_ld64(constants_7f[0], MASK_7f);
-
-        vis_ld64(constants128[0], CONST_128);
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        if (off != 0x7) {
-                vis_alignaddr_g0((void *)off_plus_1);
-                vis_faligndata(TMP0, TMP2, REF_2);
-        } else {
-                vis_src1(TMP2, REF_2);
-        }
-
-        ref += stride;
-        height = (height >> 1) - 1;
-
-        do {    /* 20 cycles */
-                vis_ld64(ref[0], TMP0);
-                vis_xor(REF_0, REF_2, TMP4);
-
-                vis_ld64_2(ref, 8, TMP2);
-                vis_and(TMP4, MASK_fe, TMP4);
-                ref += stride;
-
-                vis_ld64(ref[0], TMP8);
-                vis_and(REF_0, REF_2, TMP6);
-                vis_mul8x16(CONST_128, TMP4, TMP4);
-
-                vis_alignaddr_g0((void *)off);
-
-                vis_ld64_2(ref, 8, TMP10);
-                ref += stride;
-                vis_faligndata(TMP0, TMP2, REF_0);
-
-                if (off != 0x7) {
-                        vis_alignaddr_g0((void *)off_plus_1);
-                        vis_faligndata(TMP0, TMP2, REF_2);
-                } else {
-                        vis_src1(TMP2, REF_2);
-                }
-
-                vis_and(TMP4, MASK_7f, TMP4);
-
-                vis_padd16(TMP6, TMP4, DST_0);
-                vis_st64(DST_0, dest[0]);
-                dest += stride;
-
-                vis_xor(REF_0, REF_2, TMP12);
-
-                vis_and(TMP12, MASK_fe, TMP12);
-
-                vis_and(REF_0, REF_2, TMP14);
-                vis_mul8x16(CONST_128, TMP12, TMP12);
-
-                vis_alignaddr_g0((void *)off);
-                vis_faligndata(TMP8, TMP10, REF_0);
-                if (off != 0x7) {
-                        vis_alignaddr_g0((void *)off_plus_1);
-                        vis_faligndata(TMP8, TMP10, REF_2);
-                } else {
-                        vis_src1(TMP10, REF_2);
-                }
-
-                vis_and(TMP12, MASK_7f, TMP12);
-
-                vis_padd16(TMP14, TMP12, DST_0);
-                vis_st64(DST_0, dest[0]);
-                dest += stride;
-        } while (--height);
-
-        vis_ld64(ref[0], TMP0);
-        vis_xor(REF_0, REF_2, TMP4);
-
-        vis_ld64_2(ref, 8, TMP2);
-        vis_and(TMP4, MASK_fe, TMP4);
-
-        vis_and(REF_0, REF_2, TMP6);
-        vis_mul8x16(CONST_128, TMP4, TMP4);
-
-        vis_alignaddr_g0((void *)off);
-
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        if (off != 0x7) {
-                vis_alignaddr_g0((void *)off_plus_1);
-                vis_faligndata(TMP0, TMP2, REF_2);
-        } else {
-                vis_src1(TMP2, REF_2);
-        }
-
-        vis_and(TMP4, MASK_7f, TMP4);
-
-        vis_padd16(TMP6, TMP4, DST_0);
-        vis_st64(DST_0, dest[0]);
-        dest += stride;
-
-        vis_xor(REF_0, REF_2, TMP12);
-
-        vis_and(TMP12, MASK_fe, TMP12);
-
-        vis_and(REF_0, REF_2, TMP14);
-        vis_mul8x16(CONST_128, TMP12, TMP12);
-
-        vis_and(TMP12, MASK_7f, TMP12);
-
-        vis_padd16(TMP14, TMP12, DST_0);
-        vis_st64(DST_0, dest[0]);
-        dest += stride;
-}
-
-static void MC_avg_no_round_x_16_vis (uint8_t * dest, const uint8_t * ref,
-                                      const ptrdiff_t stride, int height)
-{
-        unsigned long off = (unsigned long) ref & 0x7;
-        unsigned long off_plus_1 = off + 1;
-
-        vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-        vis_ld64(constants3[0], CONST_3);
-        vis_fzero(ZERO);
-        vis_ld64(constants256_512[0], CONST_256);
-
-        ref = vis_alignaddr(ref);
-        do {    /* 26 cycles */
-                vis_ld64(ref[0], TMP0);
-
-                vis_ld64(ref[8], TMP2);
-
-                vis_alignaddr_g0((void *)off);
-
-                vis_ld64(ref[16], TMP4);
-
-                vis_ld64(dest[0], DST_0);
-                vis_faligndata(TMP0, TMP2, REF_0);
-
-                vis_ld64(dest[8], DST_2);
-                vis_faligndata(TMP2, TMP4, REF_4);
-
-                if (off != 0x7) {
-                        vis_alignaddr_g0((void *)off_plus_1);
-                        vis_faligndata(TMP0, TMP2, REF_2);
-                        vis_faligndata(TMP2, TMP4, REF_6);
-                } else {
-                        vis_src1(TMP2, REF_2);
-                        vis_src1(TMP4, REF_6);
-                }
-
-                vis_mul8x16au(REF_0,   CONST_256, TMP0);
-
-                vis_pmerge(ZERO,     REF_2,     TMP4);
-                vis_mul8x16au(REF_0_1, CONST_256, TMP2);
-
-                vis_pmerge(ZERO, REF_2_1, TMP6);
-
-                vis_padd16(TMP0, TMP4, TMP0);
-
-                vis_mul8x16al(DST_0,   CONST_512, TMP4);
-                vis_padd16(TMP2, TMP6, TMP2);
-
-                vis_mul8x16al(DST_1,   CONST_512, TMP6);
-
-                vis_mul8x16au(REF_6,   CONST_256, TMP12);
-
-                vis_padd16(TMP0, TMP4, TMP0);
-                vis_mul8x16au(REF_6_1, CONST_256, TMP14);
-
-                vis_padd16(TMP2, TMP6, TMP2);
-                vis_mul8x16au(REF_4,   CONST_256, TMP16);
-
-                vis_padd16(TMP0, CONST_3, TMP8);
-                vis_mul8x16au(REF_4_1, CONST_256, TMP18);
-
-                vis_padd16(TMP2, CONST_3, TMP10);
-                vis_pack16(TMP8, DST_0);
-
-                vis_pack16(TMP10, DST_1);
-                vis_padd16(TMP16, TMP12, TMP0);
-
-                vis_st64(DST_0, dest[0]);
-                vis_mul8x16al(DST_2,   CONST_512, TMP4);
-                vis_padd16(TMP18, TMP14, TMP2);
-
-                vis_mul8x16al(DST_3,   CONST_512, TMP6);
-                vis_padd16(TMP0, CONST_3, TMP0);
-
-                vis_padd16(TMP2, CONST_3, TMP2);
-
-                vis_padd16(TMP0, TMP4, TMP0);
-
-                vis_padd16(TMP2, TMP6, TMP2);
-                vis_pack16(TMP0, DST_2);
-
-                vis_pack16(TMP2, DST_3);
-                vis_st64(DST_2, dest[8]);
-
-                ref += stride;
-                dest += stride;
-        } while (--height);
-}
-
-static void MC_put_no_round_y_16_vis (uint8_t * dest, const uint8_t * ref,
-                                      const ptrdiff_t stride, int height)
-{
-        ref = vis_alignaddr(ref);
-        vis_ld64(ref[0], TMP0);
-
-        vis_ld64_2(ref, 8, TMP2);
-
-        vis_ld64_2(ref, 16, TMP4);
-        ref += stride;
-
-        vis_ld64(ref[0], TMP6);
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        vis_ld64_2(ref, 8, TMP8);
-        vis_faligndata(TMP2, TMP4, REF_4);
-
-        vis_ld64_2(ref, 16, TMP10);
-        ref += stride;
-
-        vis_ld64(constants_fe[0], MASK_fe);
-        vis_faligndata(TMP6, TMP8, REF_2);
-
-        vis_ld64(constants_7f[0], MASK_7f);
-        vis_faligndata(TMP8, TMP10, REF_6);
-
-        vis_ld64(constants128[0], CONST_128);
-        height = (height >> 1) - 1;
-        do {    /* 24 cycles */
-                vis_ld64(ref[0], TMP0);
-                vis_xor(REF_0, REF_2, TMP12);
-
-                vis_ld64_2(ref, 8, TMP2);
-                vis_xor(REF_4, REF_6, TMP16);
-
-                vis_ld64_2(ref, 16, TMP4);
-                ref += stride;
-                vis_and(REF_0, REF_2, TMP14);
-
-                vis_ld64(ref[0], TMP6);
-                vis_and(REF_4, REF_6, TMP18);
-
-                vis_ld64_2(ref, 8, TMP8);
-                vis_faligndata(TMP0, TMP2, REF_0);
-
-                vis_ld64_2(ref, 16, TMP10);
-                ref += stride;
-                vis_faligndata(TMP2, TMP4, REF_4);
-
-                vis_and(TMP12, MASK_fe, TMP12);
-
-                vis_and(TMP16, MASK_fe, TMP16);
-                vis_mul8x16(CONST_128, TMP12, TMP12);
-
-                vis_mul8x16(CONST_128, TMP16, TMP16);
-                vis_xor(REF_0, REF_2, TMP0);
-
-                vis_xor(REF_4, REF_6, TMP2);
-
-                vis_and(REF_0, REF_2, TMP20);
-
-                vis_and(TMP12, MASK_7f, TMP12);
-
-                vis_and(TMP16, MASK_7f, TMP16);
-
-                vis_padd16(TMP14, TMP12, TMP12);
-                vis_st64(TMP12, dest[0]);
-
-                vis_padd16(TMP18, TMP16, TMP16);
-                vis_st64_2(TMP16, dest, 8);
-                dest += stride;
-
-                vis_and(REF_4, REF_6, TMP18);
-
-                vis_and(TMP0, MASK_fe, TMP0);
-
-                vis_and(TMP2, MASK_fe, TMP2);
-                vis_mul8x16(CONST_128, TMP0, TMP0);
-
-                vis_faligndata(TMP6, TMP8, REF_2);
-                vis_mul8x16(CONST_128, TMP2, TMP2);
-
-                vis_faligndata(TMP8, TMP10, REF_6);
-
-                vis_and(TMP0, MASK_7f, TMP0);
-
-                vis_and(TMP2, MASK_7f, TMP2);
-
-                vis_padd16(TMP20, TMP0, TMP0);
-                vis_st64(TMP0, dest[0]);
-
-                vis_padd16(TMP18, TMP2, TMP2);
-                vis_st64_2(TMP2, dest, 8);
-                dest += stride;
-        } while (--height);
-
-        vis_ld64(ref[0], TMP0);
-        vis_xor(REF_0, REF_2, TMP12);
-
-        vis_ld64_2(ref, 8, TMP2);
-        vis_xor(REF_4, REF_6, TMP16);
-
-        vis_ld64_2(ref, 16, TMP4);
-        vis_and(REF_0, REF_2, TMP14);
-
-        vis_and(REF_4, REF_6, TMP18);
-
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        vis_faligndata(TMP2, TMP4, REF_4);
-
-        vis_and(TMP12, MASK_fe, TMP12);
-
-        vis_and(TMP16, MASK_fe, TMP16);
-        vis_mul8x16(CONST_128, TMP12, TMP12);
-
-        vis_mul8x16(CONST_128, TMP16, TMP16);
-        vis_xor(REF_0, REF_2, TMP0);
-
-        vis_xor(REF_4, REF_6, TMP2);
-
-        vis_and(REF_0, REF_2, TMP20);
-
-        vis_and(TMP12, MASK_7f, TMP12);
-
-        vis_and(TMP16, MASK_7f, TMP16);
-
-        vis_padd16(TMP14, TMP12, TMP12);
-        vis_st64(TMP12, dest[0]);
-
-        vis_padd16(TMP18, TMP16, TMP16);
-        vis_st64_2(TMP16, dest, 8);
-        dest += stride;
-
-        vis_and(REF_4, REF_6, TMP18);
-
-        vis_and(TMP0, MASK_fe, TMP0);
-
-        vis_and(TMP2, MASK_fe, TMP2);
-        vis_mul8x16(CONST_128, TMP0, TMP0);
-
-        vis_mul8x16(CONST_128, TMP2, TMP2);
-
-        vis_and(TMP0, MASK_7f, TMP0);
-
-        vis_and(TMP2, MASK_7f, TMP2);
-
-        vis_padd16(TMP20, TMP0, TMP0);
-        vis_st64(TMP0, dest[0]);
-
-        vis_padd16(TMP18, TMP2, TMP2);
-        vis_st64_2(TMP2, dest, 8);
-}
-
-static void MC_put_no_round_y_8_vis (uint8_t * dest, const uint8_t * ref,
-                                     const ptrdiff_t stride, int height)
-{
-        ref = vis_alignaddr(ref);
-        vis_ld64(ref[0], TMP0);
-
-        vis_ld64_2(ref, 8, TMP2);
-        ref += stride;
-
-        vis_ld64(ref[0], TMP4);
-
-        vis_ld64_2(ref, 8, TMP6);
-        ref += stride;
-
-        vis_ld64(constants_fe[0], MASK_fe);
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        vis_ld64(constants_7f[0], MASK_7f);
-        vis_faligndata(TMP4, TMP6, REF_2);
-
-        vis_ld64(constants128[0], CONST_128);
-        height = (height >> 1) - 1;
-        do {    /* 12 cycles */
-                vis_ld64(ref[0], TMP0);
-                vis_xor(REF_0, REF_2, TMP4);
-
-                vis_ld64_2(ref, 8, TMP2);
-                ref += stride;
-                vis_and(TMP4, MASK_fe, TMP4);
-
-                vis_and(REF_0, REF_2, TMP6);
-                vis_mul8x16(CONST_128, TMP4, TMP4);
-
-                vis_faligndata(TMP0, TMP2, REF_0);
-                vis_ld64(ref[0], TMP0);
-
-                vis_ld64_2(ref, 8, TMP2);
-                ref += stride;
-                vis_xor(REF_0, REF_2, TMP12);
-
-                vis_and(TMP4, MASK_7f, TMP4);
-
-                vis_and(TMP12, MASK_fe, TMP12);
-
-                vis_mul8x16(CONST_128, TMP12, TMP12);
-                vis_and(REF_0, REF_2, TMP14);
-
-                vis_padd16(TMP6, TMP4, DST_0);
-                vis_st64(DST_0, dest[0]);
-                dest += stride;
-
-                vis_faligndata(TMP0, TMP2, REF_2);
-
-                vis_and(TMP12, MASK_7f, TMP12);
-
-                vis_padd16(TMP14, TMP12, DST_0);
-                vis_st64(DST_0, dest[0]);
-                dest += stride;
-        } while (--height);
-
-        vis_ld64(ref[0], TMP0);
-        vis_xor(REF_0, REF_2, TMP4);
-
-        vis_ld64_2(ref, 8, TMP2);
-        vis_and(TMP4, MASK_fe, TMP4);
-
-        vis_and(REF_0, REF_2, TMP6);
-        vis_mul8x16(CONST_128, TMP4, TMP4);
-
-        vis_faligndata(TMP0, TMP2, REF_0);
-
-        vis_xor(REF_0, REF_2, TMP12);
-
-        vis_and(TMP4, MASK_7f, TMP4);
-
-        vis_and(TMP12, MASK_fe, TMP12);
-
-        vis_mul8x16(CONST_128, TMP12, TMP12);
-        vis_and(REF_0, REF_2, TMP14);
-
-        vis_padd16(TMP6, TMP4, DST_0);
-        vis_st64(DST_0, dest[0]);
-        dest += stride;
-
-        vis_and(TMP12, MASK_7f, TMP12);
-
-        vis_padd16(TMP14, TMP12, DST_0);
-        vis_st64(DST_0, dest[0]);
-}
-
-static void MC_avg_no_round_y_16_vis (uint8_t * dest, const uint8_t * ref,
-                                      const ptrdiff_t stride, int height)
-{
-        int stride_8 = stride + 8;
-        int stride_16 = stride + 16;
-
-        vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-        ref = vis_alignaddr(ref);
-
-        vis_ld64(ref[ 0], TMP0);
-        vis_fzero(ZERO);
-
-        vis_ld64(ref[ 8], TMP2);
-
-        vis_ld64(ref[16], TMP4);
-
-        vis_ld64(constants3[0], CONST_3);
-        vis_faligndata(TMP0, TMP2, REF_2);
-
-        vis_ld64(constants256_512[0], CONST_256);
-        vis_faligndata(TMP2, TMP4, REF_6);
-        height >>= 1;
-
-        do {    /* 31 cycles */
-                vis_ld64_2(ref, stride, TMP0);
-                vis_pmerge(ZERO,       REF_2,     TMP12);
-                vis_mul8x16au(REF_2_1, CONST_256, TMP14);
-
-                vis_ld64_2(ref, stride_8, TMP2);
-                vis_pmerge(ZERO,       REF_6,     TMP16);
-                vis_mul8x16au(REF_6_1, CONST_256, TMP18);
-
-                vis_ld64_2(ref, stride_16, TMP4);
-                ref += stride;
-
-                vis_ld64(dest[0], DST_0);
-                vis_faligndata(TMP0, TMP2, REF_0);
-
-                vis_ld64_2(dest, 8, DST_2);
-                vis_faligndata(TMP2, TMP4, REF_4);
-
-                vis_ld64_2(ref, stride, TMP6);
-                vis_pmerge(ZERO,     REF_0,     TMP0);
-                vis_mul8x16au(REF_0_1, CONST_256, TMP2);
-
-                vis_ld64_2(ref, stride_8, TMP8);
-                vis_pmerge(ZERO,     REF_4,     TMP4);
-
-                vis_ld64_2(ref, stride_16, TMP10);
-                ref += stride;
-
-                vis_ld64_2(dest, stride, REF_S0/*DST_4*/);
-                vis_faligndata(TMP6, TMP8, REF_2);
-                vis_mul8x16au(REF_4_1, CONST_256, TMP6);
-
-                vis_ld64_2(dest, stride_8, REF_S2/*DST_6*/);
-                vis_faligndata(TMP8, TMP10, REF_6);
-                vis_mul8x16al(DST_0,   CONST_512, TMP20);
-
-                vis_padd16(TMP0, CONST_3, TMP0);
-                vis_mul8x16al(DST_1,   CONST_512, TMP22);
-
-                vis_padd16(TMP2, CONST_3, TMP2);
-                vis_mul8x16al(DST_2,   CONST_512, TMP24);
-
-                vis_padd16(TMP4, CONST_3, TMP4);
-                vis_mul8x16al(DST_3,   CONST_512, TMP26);
-
-                vis_padd16(TMP6, CONST_3, TMP6);
-
-                vis_padd16(TMP12, TMP20, TMP12);
-                vis_mul8x16al(REF_S0,   CONST_512, TMP20);
-
-                vis_padd16(TMP14, TMP22, TMP14);
-                vis_mul8x16al(REF_S0_1, CONST_512, TMP22);
-
-                vis_padd16(TMP16, TMP24, TMP16);
-                vis_mul8x16al(REF_S2,   CONST_512, TMP24);
-
-                vis_padd16(TMP18, TMP26, TMP18);
-                vis_mul8x16al(REF_S2_1, CONST_512, TMP26);
-
-                vis_padd16(TMP12, TMP0, TMP12);
-                vis_mul8x16au(REF_2,   CONST_256, TMP28);
-
-                vis_padd16(TMP14, TMP2, TMP14);
-                vis_mul8x16au(REF_2_1, CONST_256, TMP30);
-
-                vis_padd16(TMP16, TMP4, TMP16);
-                vis_mul8x16au(REF_6,   CONST_256, REF_S4);
-
-                vis_padd16(TMP18, TMP6, TMP18);
-                vis_mul8x16au(REF_6_1, CONST_256, REF_S6);
-
-                vis_pack16(TMP12, DST_0);
-                vis_padd16(TMP28, TMP0, TMP12);
-
-                vis_pack16(TMP14, DST_1);
-                vis_st64(DST_0, dest[0]);
-                vis_padd16(TMP30, TMP2, TMP14);
-
-                vis_pack16(TMP16, DST_2);
-                vis_padd16(REF_S4, TMP4, TMP16);
-
-                vis_pack16(TMP18, DST_3);
-                vis_st64_2(DST_2, dest, 8);
-                dest += stride;
-                vis_padd16(REF_S6, TMP6, TMP18);
-
-                vis_padd16(TMP12, TMP20, TMP12);
-
-                vis_padd16(TMP14, TMP22, TMP14);
-                vis_pack16(TMP12, DST_0);
-
-                vis_padd16(TMP16, TMP24, TMP16);
-                vis_pack16(TMP14, DST_1);
-                vis_st64(DST_0, dest[0]);
-
-                vis_padd16(TMP18, TMP26, TMP18);
-                vis_pack16(TMP16, DST_2);
-
-                vis_pack16(TMP18, DST_3);
-                vis_st64_2(DST_2, dest, 8);
-                dest += stride;
-        } while (--height);
-}
-
-static void MC_put_no_round_xy_16_vis (uint8_t * dest, const uint8_t * ref,
-                                       const ptrdiff_t stride, int height)
-{
-        unsigned long off = (unsigned long) ref & 0x7;
-        unsigned long off_plus_1 = off + 1;
-        int stride_8 = stride + 8;
-        int stride_16 = stride + 16;
-
-        vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-        ref = vis_alignaddr(ref);
-
-        vis_ld64(ref[ 0], TMP0);
-        vis_fzero(ZERO);
-
-        vis_ld64(ref[ 8], TMP2);
-
-        vis_ld64(ref[16], TMP4);
-
-        vis_ld64(constants1[0], CONST_1);
-        vis_faligndata(TMP0, TMP2, REF_S0);
-
-        vis_ld64(constants256_512[0], CONST_256);
-        vis_faligndata(TMP2, TMP4, REF_S4);
-
-        if (off != 0x7) {
-                vis_alignaddr_g0((void *)off_plus_1);
-                vis_faligndata(TMP0, TMP2, REF_S2);
-                vis_faligndata(TMP2, TMP4, REF_S6);
-        } else {
-                vis_src1(TMP2, REF_S2);
-                vis_src1(TMP4, REF_S6);
-        }
-
-        height >>= 1;
-        do {
-                vis_ld64_2(ref, stride, TMP0);
-                vis_mul8x16au(REF_S0, CONST_256, TMP12);
-                vis_pmerge(ZERO,      REF_S0_1,  TMP14);
-
-                vis_alignaddr_g0((void *)off);
-
-                vis_ld64_2(ref, stride_8, TMP2);
-                vis_mul8x16au(REF_S2, CONST_256, TMP16);
-                vis_pmerge(ZERO,      REF_S2_1,  TMP18);
-
-                vis_ld64_2(ref, stride_16, TMP4);
-                ref += stride;
-                vis_mul8x16au(REF_S4, CONST_256, TMP20);
-                vis_pmerge(ZERO,      REF_S4_1,  TMP22);
-
-                vis_ld64_2(ref, stride, TMP6);
-                vis_mul8x16au(REF_S6, CONST_256, TMP24);
-                vis_pmerge(ZERO,      REF_S6_1,  TMP26);
-
-                vis_ld64_2(ref, stride_8, TMP8);
-                vis_faligndata(TMP0, TMP2, REF_0);
-
-                vis_ld64_2(ref, stride_16, TMP10);
-                ref += stride;
-                vis_faligndata(TMP2, TMP4, REF_4);
-
-                vis_faligndata(TMP6, TMP8, REF_S0);
-
-                vis_faligndata(TMP8, TMP10, REF_S4);
-
-                if (off != 0x7) {
-                        vis_alignaddr_g0((void *)off_plus_1);
-                        vis_faligndata(TMP0, TMP2, REF_2);
-                        vis_faligndata(TMP2, TMP4, REF_6);
-                        vis_faligndata(TMP6, TMP8, REF_S2);
-                        vis_faligndata(TMP8, TMP10, REF_S6);
-                } else {
-                        vis_src1(TMP2, REF_2);
-                        vis_src1(TMP4, REF_6);
-                        vis_src1(TMP8, REF_S2);
-                        vis_src1(TMP10, REF_S6);
-                }
-
-                vis_mul8x16au(REF_0, CONST_256, TMP0);
-                vis_pmerge(ZERO,      REF_0_1,  TMP2);
-
-                vis_mul8x16au(REF_2, CONST_256, TMP4);
-                vis_pmerge(ZERO,      REF_2_1,  TMP6);
-
-                vis_padd16(TMP0, CONST_2, TMP8);
-                vis_mul8x16au(REF_4, CONST_256, TMP0);
-
-                vis_padd16(TMP2, CONST_1, TMP10);
-                vis_mul8x16au(REF_4_1, CONST_256, TMP2);
-
-                vis_padd16(TMP8, TMP4, TMP8);
-                vis_mul8x16au(REF_6, CONST_256, TMP4);
-
-                vis_padd16(TMP10, TMP6, TMP10);
-                vis_mul8x16au(REF_6_1, CONST_256, TMP6);
-
-                vis_padd16(TMP12, TMP8, TMP12);
-
-                vis_padd16(TMP14, TMP10, TMP14);
-
-                vis_padd16(TMP12, TMP16, TMP12);
-
-                vis_padd16(TMP14, TMP18, TMP14);
-                vis_pack16(TMP12, DST_0);
-
-                vis_pack16(TMP14, DST_1);
-                vis_st64(DST_0, dest[0]);
-                vis_padd16(TMP0, CONST_1, TMP12);
-
-                vis_mul8x16au(REF_S0, CONST_256, TMP0);
-                vis_padd16(TMP2, CONST_1, TMP14);
-
-                vis_mul8x16au(REF_S0_1, CONST_256, TMP2);
-                vis_padd16(TMP12, TMP4, TMP12);
-
-                vis_mul8x16au(REF_S2, CONST_256, TMP4);
-                vis_padd16(TMP14, TMP6, TMP14);
-
-                vis_mul8x16au(REF_S2_1, CONST_256, TMP6);
-                vis_padd16(TMP20, TMP12, TMP20);
-
-                vis_padd16(TMP22, TMP14, TMP22);
-
-                vis_padd16(TMP20, TMP24, TMP20);
-
-                vis_padd16(TMP22, TMP26, TMP22);
-                vis_pack16(TMP20, DST_2);
-
-                vis_pack16(TMP22, DST_3);
-                vis_st64_2(DST_2, dest, 8);
-                dest += stride;
-                vis_padd16(TMP0, TMP4, TMP24);
-
-                vis_mul8x16au(REF_S4, CONST_256, TMP0);
-                vis_padd16(TMP2, TMP6, TMP26);
-
-                vis_mul8x16au(REF_S4_1, CONST_256, TMP2);
-                vis_padd16(TMP24, TMP8, TMP24);
-
-                vis_padd16(TMP26, TMP10, TMP26);
-                vis_pack16(TMP24, DST_0);
-
-                vis_pack16(TMP26, DST_1);
-                vis_st64(DST_0, dest[0]);
-                vis_pmerge(ZERO, REF_S6, TMP4);
-
-                vis_pmerge(ZERO,      REF_S6_1,  TMP6);
-
-                vis_padd16(TMP0, TMP4, TMP0);
-
-                vis_padd16(TMP2, TMP6, TMP2);
-
-                vis_padd16(TMP0, TMP12, TMP0);
-
-                vis_padd16(TMP2, TMP14, TMP2);
-                vis_pack16(TMP0, DST_2);
-
-                vis_pack16(TMP2, DST_3);
-                vis_st64_2(DST_2, dest, 8);
-                dest += stride;
-        } while (--height);
-}
-
-static void MC_put_no_round_xy_8_vis (uint8_t * dest, const uint8_t * ref,
-                                      const ptrdiff_t stride, int height)
-{
-        unsigned long off = (unsigned long) ref & 0x7;
-        unsigned long off_plus_1 = off + 1;
-        int stride_8 = stride + 8;
-
-        vis_set_gsr(5 << VIS_GSR_SCALEFACT_SHIFT);
-
-        ref = vis_alignaddr(ref);
-
-        vis_ld64(ref[ 0], TMP0);
-        vis_fzero(ZERO);
-
-        vis_ld64(ref[ 8], TMP2);
-
-        vis_ld64(constants1[0], CONST_1);
-
-        vis_ld64(constants256_512[0], CONST_256);
-        vis_faligndata(TMP0, TMP2, REF_S0);
-
-        if (off != 0x7) {
-                vis_alignaddr_g0((void *)off_plus_1);
-                vis_faligndata(TMP0, TMP2, REF_S2);
-        } else {
-                vis_src1(TMP2, REF_S2);
-        }
-
-        height >>= 1;
-        do {    /* 26 cycles */
-                vis_ld64_2(ref, stride, TMP0);
-                vis_mul8x16au(REF_S0,   CONST_256, TMP8);
-                vis_pmerge(ZERO,        REF_S2,    TMP12);
-
-                vis_alignaddr_g0((void *)off);
-
-                vis_ld64_2(ref, stride_8, TMP2);
-                ref += stride;
-                vis_mul8x16au(REF_S0_1, CONST_256, TMP10);
-                vis_pmerge(ZERO,        REF_S2_1,  TMP14);
-
-                vis_ld64_2(ref, stride, TMP4);
-
-                vis_ld64_2(ref, stride_8, TMP6);
-                ref += stride;
-                vis_faligndata(TMP0, TMP2, REF_S4);
-
-                vis_pmerge(ZERO, REF_S4, TMP18);
-
-                vis_pmerge(ZERO, REF_S4_1, TMP20);
-
-                vis_faligndata(TMP4, TMP6, REF_S0);
-
-                if (off != 0x7) {
-                        vis_alignaddr_g0((void *)off_plus_1);
-                        vis_faligndata(TMP0, TMP2, REF_S6);
-                        vis_faligndata(TMP4, TMP6, REF_S2);
-                } else {
-                        vis_src1(TMP2, REF_S6);
-                        vis_src1(TMP6, REF_S2);
-                }
-
-                vis_padd16(TMP18, CONST_1, TMP18);
-                vis_mul8x16au(REF_S6,   CONST_256, TMP22);
-
-                vis_padd16(TMP20, CONST_1, TMP20);
-                vis_mul8x16au(REF_S6_1, CONST_256, TMP24);
-
-                vis_mul8x16au(REF_S0,   CONST_256, TMP26);
-                vis_pmerge(ZERO, REF_S0_1, TMP28);
-
-                vis_mul8x16au(REF_S2,   CONST_256, TMP30);
-                vis_padd16(TMP18, TMP22, TMP18);
-
-                vis_mul8x16au(REF_S2_1, CONST_256, TMP32);
-                vis_padd16(TMP20, TMP24, TMP20);
-
-                vis_padd16(TMP8,  TMP18, TMP8);
-
-                vis_padd16(TMP10, TMP20, TMP10);
-
-                vis_padd16(TMP8,  TMP12, TMP8);
-
-                vis_padd16(TMP10, TMP14, TMP10);
-                vis_pack16(TMP8,  DST_0);
-
-                vis_pack16(TMP10, DST_1);
-                vis_st64(DST_0, dest[0]);
-                dest += stride;
-                vis_padd16(TMP18, TMP26, TMP18);
-
-                vis_padd16(TMP20, TMP28, TMP20);
-
-                vis_padd16(TMP18, TMP30, TMP18);
-
-                vis_padd16(TMP20, TMP32, TMP20);
-                vis_pack16(TMP18, DST_2);
-
-                vis_pack16(TMP20, DST_3);
-                vis_st64(DST_2, dest[0]);
-                dest += stride;
-        } while (--height);
-}
-
-static void MC_avg_no_round_xy_16_vis (uint8_t * dest, const uint8_t * ref,
-                                       const ptrdiff_t stride, int height)
-{
-        unsigned long off = (unsigned long) ref & 0x7;
-        unsigned long off_plus_1 = off + 1;
-        int stride_8 = stride + 8;
-        int stride_16 = stride + 16;
-
-        vis_set_gsr(4 << VIS_GSR_SCALEFACT_SHIFT);
-
-        ref = vis_alignaddr(ref);
-
-        vis_ld64(ref[ 0], TMP0);
-        vis_fzero(ZERO);
-
-        vis_ld64(ref[ 8], TMP2);
-
-        vis_ld64(ref[16], TMP4);
-
-        vis_ld64(constants6[0], CONST_6);
-        vis_faligndata(TMP0, TMP2, REF_S0);
-
-        vis_ld64(constants256_1024[0], CONST_256);
-        vis_faligndata(TMP2, TMP4, REF_S4);
-
-        if (off != 0x7) {
-                vis_alignaddr_g0((void *)off_plus_1);
-                vis_faligndata(TMP0, TMP2, REF_S2);
-                vis_faligndata(TMP2, TMP4, REF_S6);
-        } else {
-                vis_src1(TMP2, REF_S2);
-                vis_src1(TMP4, REF_S6);
-        }
-
-        height >>= 1;
-        do {    /* 55 cycles */
-                vis_ld64_2(ref, stride, TMP0);
-                vis_mul8x16au(REF_S0, CONST_256, TMP12);
-                vis_pmerge(ZERO,      REF_S0_1,  TMP14);
-
-                vis_alignaddr_g0((void *)off);
-
-                vis_ld64_2(ref, stride_8, TMP2);
-                vis_mul8x16au(REF_S2, CONST_256, TMP16);
-                vis_pmerge(ZERO,      REF_S2_1,  TMP18);
-
-                vis_ld64_2(ref, stride_16, TMP4);
-                ref += stride;
-                vis_mul8x16au(REF_S4, CONST_256, TMP20);
-                vis_pmerge(ZERO,      REF_S4_1,  TMP22);
-
-                vis_ld64_2(ref, stride, TMP6);
-                vis_mul8x16au(REF_S6, CONST_256, TMP24);
-                vis_pmerge(ZERO,      REF_S6_1,  TMP26);
-
-                vis_ld64_2(ref, stride_8, TMP8);
-                vis_faligndata(TMP0, TMP2, REF_0);
-
-                vis_ld64_2(ref, stride_16, TMP10);
-                ref += stride;
-                vis_faligndata(TMP2, TMP4, REF_4);
-
-                vis_ld64(dest[0], DST_0);
-                vis_faligndata(TMP6, TMP8, REF_S0);
-
-                vis_ld64_2(dest, 8, DST_2);
-                vis_faligndata(TMP8, TMP10, REF_S4);
-
-                if (off != 0x7) {
-                        vis_alignaddr_g0((void *)off_plus_1);
-                        vis_faligndata(TMP0, TMP2, REF_2);
-                        vis_faligndata(TMP2, TMP4, REF_6);
-                        vis_faligndata(TMP6, TMP8, REF_S2);
-                        vis_faligndata(TMP8, TMP10, REF_S6);
-                } else {
-                        vis_src1(TMP2, REF_2);
-                        vis_src1(TMP4, REF_6);
-                        vis_src1(TMP8, REF_S2);
-                        vis_src1(TMP10, REF_S6);
-                }
-
-                vis_mul8x16al(DST_0,   CONST_1024, TMP30);
-                vis_pmerge(ZERO, REF_0, TMP0);
-
-                vis_mul8x16al(DST_1,   CONST_1024, TMP32);
-                vis_pmerge(ZERO,      REF_0_1,  TMP2);
-
-                vis_mul8x16au(REF_2, CONST_256, TMP4);
-                vis_pmerge(ZERO,      REF_2_1,  TMP6);
-
-                vis_mul8x16al(DST_2,   CONST_1024, REF_0);
-                vis_padd16(TMP0, CONST_6, TMP0);
-
-                vis_mul8x16al(DST_3,   CONST_1024, REF_2);
-                vis_padd16(TMP2, CONST_6, TMP2);
-
-                vis_padd16(TMP0, TMP4, TMP0);
-                vis_mul8x16au(REF_4, CONST_256, TMP4);
-
-                vis_padd16(TMP2, TMP6, TMP2);
-                vis_mul8x16au(REF_4_1, CONST_256, TMP6);
-
-                vis_padd16(TMP12, TMP0, TMP12);
-                vis_mul8x16au(REF_6, CONST_256, TMP8);
-
-                vis_padd16(TMP14, TMP2, TMP14);
-                vis_mul8x16au(REF_6_1, CONST_256, TMP10);
-
-                vis_padd16(TMP12, TMP16, TMP12);
-                vis_mul8x16au(REF_S0, CONST_256, REF_4);
-
-                vis_padd16(TMP14, TMP18, TMP14);
-                vis_mul8x16au(REF_S0_1, CONST_256, REF_6);
-
-                vis_padd16(TMP12, TMP30, TMP12);
-
-                vis_padd16(TMP14, TMP32, TMP14);
-                vis_pack16(TMP12, DST_0);
-
-                vis_pack16(TMP14, DST_1);
-                vis_st64(DST_0, dest[0]);
-                vis_padd16(TMP4, CONST_6, TMP4);
-
-                vis_ld64_2(dest, stride, DST_0);
-                vis_padd16(TMP6, CONST_6, TMP6);
-                vis_mul8x16au(REF_S2, CONST_256, TMP12);
-
-                vis_padd16(TMP4, TMP8, TMP4);
-                vis_mul8x16au(REF_S2_1, CONST_256,  TMP14);
-
-                vis_padd16(TMP6, TMP10, TMP6);
-
-                vis_padd16(TMP20, TMP4, TMP20);
-
-                vis_padd16(TMP22, TMP6, TMP22);
-
-                vis_padd16(TMP20, TMP24, TMP20);
-
-                vis_padd16(TMP22, TMP26, TMP22);
-
-                vis_padd16(TMP20, REF_0, TMP20);
-                vis_mul8x16au(REF_S4, CONST_256, REF_0);
-
-                vis_padd16(TMP22, REF_2, TMP22);
-                vis_pack16(TMP20, DST_2);
-
-                vis_pack16(TMP22, DST_3);
-                vis_st64_2(DST_2, dest, 8);
-                dest += stride;
-
-                vis_ld64_2(dest, 8, DST_2);
-                vis_mul8x16al(DST_0,   CONST_1024, TMP30);
-                vis_pmerge(ZERO,      REF_S4_1,  REF_2);
-
-                vis_mul8x16al(DST_1,   CONST_1024, TMP32);
-                vis_padd16(REF_4, TMP0, TMP8);
-
-                vis_mul8x16au(REF_S6, CONST_256, REF_4);
-                vis_padd16(REF_6, TMP2, TMP10);
-
-                vis_mul8x16au(REF_S6_1, CONST_256, REF_6);
-                vis_padd16(TMP8, TMP12, TMP8);
-
-                vis_padd16(TMP10, TMP14, TMP10);
-
-                vis_padd16(TMP8, TMP30, TMP8);
-
-                vis_padd16(TMP10, TMP32, TMP10);
-                vis_pack16(TMP8, DST_0);
-
-                vis_pack16(TMP10, DST_1);
-                vis_st64(DST_0, dest[0]);
-
-                vis_padd16(REF_0, TMP4, REF_0);
-
-                vis_mul8x16al(DST_2,   CONST_1024, TMP30);
-                vis_padd16(REF_2, TMP6, REF_2);
-
-                vis_mul8x16al(DST_3,   CONST_1024, TMP32);
-                vis_padd16(REF_0, REF_4, REF_0);
-
-                vis_padd16(REF_2, REF_6, REF_2);
-
-                vis_padd16(REF_0, TMP30, REF_0);
-
-                /* stall */
-
-                vis_padd16(REF_2, TMP32, REF_2);
-                vis_pack16(REF_0, DST_2);
-
-                vis_pack16(REF_2, DST_3);
-                vis_st64_2(DST_2, dest, 8);
-                dest += stride;
-        } while (--height);
-}
-
-/* End of no rounding code */
-
-av_cold void ff_hpeldsp_init_vis(HpelDSPContext *c, int flags)
-{
-  /* VIS-specific optimizations */
-  int accel = vis_level ();
-
-  if (accel & ACCEL_SPARC_VIS) {
-      c->put_pixels_tab[0][0] = MC_put_o_16_vis;
-      c->put_pixels_tab[0][1] = MC_put_x_16_vis;
-      c->put_pixels_tab[0][2] = MC_put_y_16_vis;
-      c->put_pixels_tab[0][3] = MC_put_xy_16_vis;
-
-      c->put_pixels_tab[1][0] = MC_put_o_8_vis;
-      c->put_pixels_tab[1][1] = MC_put_x_8_vis;
-      c->put_pixels_tab[1][2] = MC_put_y_8_vis;
-      c->put_pixels_tab[1][3] = MC_put_xy_8_vis;
-
-      c->avg_pixels_tab[0][0] = MC_avg_o_16_vis;
-      c->avg_pixels_tab[0][1] = MC_avg_x_16_vis;
-      c->avg_pixels_tab[0][2] = MC_avg_y_16_vis;
-      c->avg_pixels_tab[0][3] = MC_avg_xy_16_vis;
-
-      c->avg_pixels_tab[1][0] = MC_avg_o_8_vis;
-      c->avg_pixels_tab[1][1] = MC_avg_x_8_vis;
-      c->avg_pixels_tab[1][2] = MC_avg_y_8_vis;
-      c->avg_pixels_tab[1][3] = MC_avg_xy_8_vis;
-
-      c->put_no_rnd_pixels_tab[0][0] = MC_put_no_round_o_16_vis;
-      c->put_no_rnd_pixels_tab[0][1] = MC_put_no_round_x_16_vis;
-      c->put_no_rnd_pixels_tab[0][2] = MC_put_no_round_y_16_vis;
-      c->put_no_rnd_pixels_tab[0][3] = MC_put_no_round_xy_16_vis;
-
-      c->put_no_rnd_pixels_tab[1][0] = MC_put_no_round_o_8_vis;
-      c->put_no_rnd_pixels_tab[1][1] = MC_put_no_round_x_8_vis;
-      c->put_no_rnd_pixels_tab[1][2] = MC_put_no_round_y_8_vis;
-      c->put_no_rnd_pixels_tab[1][3] = MC_put_no_round_xy_8_vis;
-
-      c->avg_no_rnd_pixels_tab[0] = MC_avg_no_round_o_16_vis;
-      c->avg_no_rnd_pixels_tab[1] = MC_avg_no_round_x_16_vis;
-      c->avg_no_rnd_pixels_tab[2] = MC_avg_no_round_y_16_vis;
-      c->avg_no_rnd_pixels_tab[3] = MC_avg_no_round_xy_16_vis;
-  }
-}
diff --git a/deps/libav/libavcodec/sparc/simple_idct_vis.c b/deps/libav/libavcodec/sparc/simple_idct_vis.c
deleted file mode 100644
index 2057d66..0000000
--- a/deps/libav/libavcodec/sparc/simple_idct_vis.c
+++ /dev/null
@@ -1,531 +0,0 @@
-/*
- * SPARC VIS optimized inverse DCT
- * Copyright (c) 2007 Denes Balatoni < dbalatoni XatX interware XdotX hu >
- *
- * I did consult the following fine web page about dct
- * http://www.geocities.com/ssavekar/dct.htm
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <stdint.h>
-
-#include "dsputil_vis.h"
-#include "libavutil/mem.h"
-
-static const DECLARE_ALIGNED(8, int16_t, coeffs)[28] = {
-    - 1259,- 1259,- 1259,- 1259,
-    - 4989,- 4989,- 4989,- 4989,
-    -11045,-11045,-11045,-11045,
-    -19195,-19195,-19195,-19195,
-    -29126,-29126,-29126,-29126,
-     25080, 25080, 25080, 25080,
-     12785, 12785, 12785, 12785
-};
-static const DECLARE_ALIGNED(8, uint16_t, scale)[4] = {
-    65536>>6, 65536>>6, 65536>>6, 65536>>6
-};
-static const DECLARE_ALIGNED(8, uint16_t, rounder)[4] = {
-    1<<5, 1<<5, 1<<5, 1<<5
-};
-static const DECLARE_ALIGNED(8, uint16_t, expand)[4] = {
-    1<<14, 1<<14, 1<<14, 1<<14
-};
-
-#define INIT_IDCT \
-        "ldd [%1], %%f32         \n\t"\
-        "ldd [%1+8], %%f34       \n\t"\
-        "ldd [%1+16], %%f36      \n\t"\
-        "ldd [%1+24], %%f38      \n\t"\
-        "ldd [%1+32], %%f40      \n\t"\
-        "ldd [%1+40], %%f42      \n\t"\
-        "ldd [%1+48], %%f44      \n\t"\
-        "ldd [%0], %%f46         \n\t"\
-        "fzero %%f62             \n\t"\
-
-#define LOADSCALE(in) \
-        "ldd [" in "], %%f0          \n\t"\
-        "ldd [" in "+16], %%f2       \n\t"\
-        "ldd [" in "+32], %%f4       \n\t"\
-        "ldd [" in "+48], %%f6       \n\t"\
-        "ldd [" in "+64], %%f8       \n\t"\
-        "ldd [" in "+80], %%f10      \n\t"\
-        "ldd [" in "+96], %%f12      \n\t"\
-        "ldd [" in "+112], %%f14     \n\t"\
-        "fpadd16 %%f0, %%f0, %%f0    \n\t"\
-        "fpadd16 %%f2, %%f2, %%f2    \n\t"\
-        "fpadd16 %%f4, %%f4, %%f4    \n\t"\
-        "fpadd16 %%f6, %%f6, %%f6    \n\t"\
-        "fpadd16 %%f8, %%f8, %%f8    \n\t"\
-        "fpadd16 %%f10, %%f10, %%f10 \n\t"\
-        "fpadd16 %%f12, %%f12, %%f12 \n\t"\
-        "fpadd16 %%f14, %%f14, %%f14 \n\t"\
-\
-        "fpadd16 %%f0, %%f0, %%f0    \n\t"\
-        "fpadd16 %%f2, %%f2, %%f2    \n\t"\
-        "fpadd16 %%f4, %%f4, %%f4    \n\t"\
-        "fpadd16 %%f6, %%f6, %%f6    \n\t"\
-        "fpadd16 %%f8, %%f8, %%f8    \n\t"\
-        "fpadd16 %%f10, %%f10, %%f10 \n\t"\
-        "fpadd16 %%f12, %%f12, %%f12 \n\t"\
-        "fpadd16 %%f14, %%f14, %%f14 \n\t"\
-\
-        "fpadd16 %%f0, %%f0, %%f0    \n\t"\
-        "fpadd16 %%f2, %%f2, %%f2    \n\t"\
-        "fpadd16 %%f4, %%f4, %%f4    \n\t"\
-        "fpadd16 %%f6, %%f6, %%f6    \n\t"\
-        "fpadd16 %%f8, %%f8, %%f8    \n\t"\
-        "fpadd16 %%f10, %%f10, %%f10 \n\t"\
-        "fpadd16 %%f12, %%f12, %%f12 \n\t"\
-        "fpadd16 %%f14, %%f14, %%f14 \n\t"\
-\
-        "fpadd16 %%f0, %%f0, %%f0    \n\t"\
-        "fpadd16 %%f2, %%f2, %%f2    \n\t"\
-        "fpadd16 %%f4, %%f4, %%f4    \n\t"\
-        "fpadd16 %%f6, %%f6, %%f6    \n\t"\
-        "fpadd16 %%f8, %%f8, %%f8    \n\t"\
-        "fpadd16 %%f10, %%f10, %%f10 \n\t"\
-        "fpadd16 %%f12, %%f12, %%f12 \n\t"\
-        "fpadd16 %%f14, %%f14, %%f14 \n\t"\
-
-#define LOAD(in) \
-        "ldd [" in "], %%f16         \n\t"\
-        "ldd [" in "+8], %%f18       \n\t"\
-        "ldd [" in "+16], %%f20      \n\t"\
-        "ldd [" in "+24], %%f22      \n\t"\
-        "ldd [" in "+32], %%f24      \n\t"\
-        "ldd [" in "+40], %%f26      \n\t"\
-        "ldd [" in "+48], %%f28      \n\t"\
-        "ldd [" in "+56], %%f30      \n\t"\
-
-#define TRANSPOSE \
-        "fpmerge %%f16, %%f24, %%f0  \n\t"\
-        "fpmerge %%f20, %%f28, %%f2  \n\t"\
-        "fpmerge %%f17, %%f25, %%f4  \n\t"\
-        "fpmerge %%f21, %%f29, %%f6  \n\t"\
-        "fpmerge %%f18, %%f26, %%f8  \n\t"\
-        "fpmerge %%f22, %%f30, %%f10 \n\t"\
-        "fpmerge %%f19, %%f27, %%f12 \n\t"\
-        "fpmerge %%f23, %%f31, %%f14 \n\t"\
-\
-        "fpmerge %%f0, %%f2, %%f16   \n\t"\
-        "fpmerge %%f1, %%f3, %%f18   \n\t"\
-        "fpmerge %%f4, %%f6, %%f20   \n\t"\
-        "fpmerge %%f5, %%f7, %%f22   \n\t"\
-        "fpmerge %%f8, %%f10, %%f24  \n\t"\
-        "fpmerge %%f9, %%f11, %%f26  \n\t"\
-        "fpmerge %%f12, %%f14, %%f28 \n\t"\
-        "fpmerge %%f13, %%f15, %%f30 \n\t"\
-\
-        "fpmerge %%f16, %%f17, %%f0  \n\t"\
-        "fpmerge %%f18, %%f19, %%f2  \n\t"\
-        "fpmerge %%f20, %%f21, %%f4  \n\t"\
-        "fpmerge %%f22, %%f23, %%f6  \n\t"\
-        "fpmerge %%f24, %%f25, %%f8  \n\t"\
-        "fpmerge %%f26, %%f27, %%f10 \n\t"\
-        "fpmerge %%f28, %%f29, %%f12 \n\t"\
-        "fpmerge %%f30, %%f31, %%f14 \n\t"\
-
-#define IDCT4ROWS \
-    /* 1. column */\
-        "fmul8ulx16 %%f0, %%f38, %%f28 \n\t"\
-        "for %%f4, %%f6, %%f60         \n\t"\
-        "fmul8ulx16 %%f2, %%f32, %%f18 \n\t"\
-        "fmul8ulx16 %%f2, %%f36, %%f22 \n\t"\
-        "fmul8ulx16 %%f2, %%f40, %%f26 \n\t"\
-        "fmul8ulx16 %%f2, %%f44, %%f30 \n\t"\
-\
-        ADDROUNDER\
-\
-        "fmul8sux16 %%f0, %%f38, %%f48 \n\t"\
-        "fcmpd %%fcc0, %%f62, %%f60    \n\t"\
-        "for %%f8, %%f10, %%f60        \n\t"\
-        "fmul8sux16 %%f2, %%f32, %%f50 \n\t"\
-        "fmul8sux16 %%f2, %%f36, %%f52 \n\t"\
-        "fmul8sux16 %%f2, %%f40, %%f54 \n\t"\
-        "fmul8sux16 %%f2, %%f44, %%f56 \n\t"\
-\
-        "fpadd16 %%f48, %%f28, %%f28 \n\t"\
-        "fcmpd %%fcc1, %%f62, %%f60  \n\t"\
-        "for %%f12, %%f14, %%f60     \n\t"\
-        "fpadd16 %%f50, %%f18, %%f18 \n\t"\
-        "fpadd16 %%f52, %%f22, %%f22 \n\t"\
-        "fpadd16 %%f54, %%f26, %%f26 \n\t"\
-        "fpadd16 %%f56, %%f30, %%f30 \n\t"\
-\
-        "fpadd16 %%f28, %%f0, %%f16  \n\t"\
-        "fcmpd %%fcc2, %%f62, %%f60  \n\t"\
-        "fpadd16 %%f28, %%f0, %%f20  \n\t"\
-        "fpadd16 %%f28, %%f0, %%f24  \n\t"\
-        "fpadd16 %%f28, %%f0, %%f28  \n\t"\
-        "fpadd16 %%f18, %%f2, %%f18  \n\t"\
-        "fpadd16 %%f22, %%f2, %%f22  \n\t"\
-    /* 2. column */\
-        "fbe %%fcc0, 3f                \n\t"\
-        "fpadd16 %%f26, %%f2, %%f26    \n\t"\
-        "fmul8ulx16 %%f4, %%f34, %%f48 \n\t"\
-        "fmul8ulx16 %%f4, %%f42, %%f50 \n\t"\
-        "fmul8ulx16 %%f6, %%f36, %%f52 \n\t"\
-        "fmul8ulx16 %%f6, %%f44, %%f54 \n\t"\
-        "fmul8ulx16 %%f6, %%f32, %%f56 \n\t"\
-        "fmul8ulx16 %%f6, %%f40, %%f58 \n\t"\
-\
-        "fpadd16 %%f16, %%f48, %%f16 \n\t"\
-        "fpadd16 %%f20, %%f50, %%f20 \n\t"\
-        "fpsub16 %%f24, %%f50, %%f24 \n\t"\
-        "fpsub16 %%f28, %%f48, %%f28 \n\t"\
-        "fpadd16 %%f18, %%f52, %%f18 \n\t"\
-        "fpsub16 %%f22, %%f54, %%f22 \n\t"\
-        "fpsub16 %%f26, %%f56, %%f26 \n\t"\
-        "fpsub16 %%f30, %%f58, %%f30 \n\t"\
-\
-        "fmul8sux16 %%f4, %%f34, %%f48 \n\t"\
-        "fmul8sux16 %%f4, %%f42, %%f50 \n\t"\
-        "fmul8sux16 %%f6, %%f36, %%f52 \n\t"\
-        "fmul8sux16 %%f6, %%f44, %%f54 \n\t"\
-        "fmul8sux16 %%f6, %%f32, %%f56 \n\t"\
-        "fmul8sux16 %%f6, %%f40, %%f58 \n\t"\
-\
-        "fpadd16 %%f16, %%f48, %%f16 \n\t"\
-        "fpadd16 %%f20, %%f50, %%f20 \n\t"\
-        "fpsub16 %%f24, %%f50, %%f24 \n\t"\
-        "fpsub16 %%f28, %%f48, %%f28 \n\t"\
-        "fpadd16 %%f18, %%f52, %%f18 \n\t"\
-        "fpsub16 %%f22, %%f54, %%f22 \n\t"\
-        "fpsub16 %%f26, %%f56, %%f26 \n\t"\
-        "fpsub16 %%f30, %%f58, %%f30 \n\t"\
-\
-        "fpadd16 %%f16, %%f4, %%f16  \n\t"\
-        "fpsub16 %%f28, %%f4, %%f28  \n\t"\
-        "fpadd16 %%f18, %%f6, %%f18  \n\t"\
-        "fpsub16 %%f26, %%f6, %%f26  \n\t"\
-    /* 3. column */\
-        "3:                             \n\t"\
-        "fbe %%fcc1, 4f                 \n\t"\
-        "fpsub16 %%f30, %%f6, %%f30     \n\t"\
-        "fmul8ulx16 %%f8, %%f38, %%f48  \n\t"\
-        "fmul8ulx16 %%f10, %%f40, %%f50 \n\t"\
-        "fmul8ulx16 %%f10, %%f32, %%f52 \n\t"\
-        "fmul8ulx16 %%f10, %%f44, %%f54 \n\t"\
-        "fmul8ulx16 %%f10, %%f36, %%f56 \n\t"\
-\
-        "fpadd16 %%f16, %%f48, %%f16 \n\t"\
-        "fpsub16 %%f20, %%f48, %%f20 \n\t"\
-        "fpsub16 %%f24, %%f48, %%f24 \n\t"\
-        "fpadd16 %%f28, %%f48, %%f28 \n\t"\
-        "fpadd16 %%f18, %%f50, %%f18 \n\t"\
-        "fpsub16 %%f22, %%f52, %%f22 \n\t"\
-        "fpadd16 %%f26, %%f54, %%f26 \n\t"\
-        "fpadd16 %%f30, %%f56, %%f30 \n\t"\
-\
-        "fmul8sux16 %%f8, %%f38, %%f48 \n\t"\
-        "fmul8sux16 %%f10, %%f40, %%f50 \n\t"\
-        "fmul8sux16 %%f10, %%f32, %%f52 \n\t"\
-        "fmul8sux16 %%f10, %%f44, %%f54 \n\t"\
-        "fmul8sux16 %%f10, %%f36, %%f56 \n\t"\
-\
-        "fpadd16 %%f16, %%f48, %%f16 \n\t"\
-        "fpsub16 %%f20, %%f48, %%f20 \n\t"\
-        "fpsub16 %%f24, %%f48, %%f24 \n\t"\
-        "fpadd16 %%f28, %%f48, %%f28 \n\t"\
-        "fpadd16 %%f18, %%f50, %%f18 \n\t"\
-        "fpsub16 %%f22, %%f52, %%f22 \n\t"\
-        "fpadd16 %%f26, %%f54, %%f26 \n\t"\
-        "fpadd16 %%f30, %%f56, %%f30 \n\t"\
-\
-        "fpadd16 %%f16, %%f8, %%f16  \n\t"\
-        "fpsub16 %%f20, %%f8, %%f20  \n\t"\
-        "fpsub16 %%f24, %%f8, %%f24  \n\t"\
-        "fpadd16 %%f28, %%f8, %%f28  \n\t"\
-        "fpadd16 %%f18, %%f10, %%f18 \n\t"\
-        "fpsub16 %%f22, %%f10, %%f22 \n\t"\
-    /* 4. column */\
-        "4:                             \n\t"\
-        "fbe %%fcc2, 5f                 \n\t"\
-        "fpadd16 %%f30, %%f10, %%f30    \n\t"\
-        "fmul8ulx16 %%f12, %%f42, %%f48 \n\t"\
-        "fmul8ulx16 %%f12, %%f34, %%f50 \n\t"\
-        "fmul8ulx16 %%f14, %%f44, %%f52 \n\t"\
-        "fmul8ulx16 %%f14, %%f40, %%f54 \n\t"\
-        "fmul8ulx16 %%f14, %%f36, %%f56 \n\t"\
-        "fmul8ulx16 %%f14, %%f32, %%f58 \n\t"\
-\
-        "fpadd16 %%f16, %%f48, %%f16 \n\t"\
-        "fpsub16 %%f20, %%f50, %%f20 \n\t"\
-        "fpadd16 %%f24, %%f50, %%f24 \n\t"\
-        "fpsub16 %%f28, %%f48, %%f28 \n\t"\
-        "fpadd16 %%f18, %%f52, %%f18 \n\t"\
-        "fpsub16 %%f22, %%f54, %%f22 \n\t"\
-        "fpadd16 %%f26, %%f56, %%f26 \n\t"\
-        "fpsub16 %%f30, %%f58, %%f30 \n\t"\
-\
-        "fmul8sux16 %%f12, %%f42, %%f48 \n\t"\
-        "fmul8sux16 %%f12, %%f34, %%f50 \n\t"\
-        "fmul8sux16 %%f14, %%f44, %%f52 \n\t"\
-        "fmul8sux16 %%f14, %%f40, %%f54 \n\t"\
-        "fmul8sux16 %%f14, %%f36, %%f56 \n\t"\
-        "fmul8sux16 %%f14, %%f32, %%f58 \n\t"\
-\
-        "fpadd16 %%f16, %%f48, %%f16 \n\t"\
-        "fpsub16 %%f20, %%f50, %%f20 \n\t"\
-        "fpadd16 %%f24, %%f50, %%f24 \n\t"\
-        "fpsub16 %%f28, %%f48, %%f28 \n\t"\
-        "fpadd16 %%f18, %%f52, %%f18 \n\t"\
-        "fpsub16 %%f22, %%f54, %%f22 \n\t"\
-        "fpadd16 %%f26, %%f56, %%f26 \n\t"\
-        "fpsub16 %%f30, %%f58, %%f30 \n\t"\
-\
-        "fpsub16 %%f20, %%f12, %%f20 \n\t"\
-        "fpadd16 %%f24, %%f12, %%f24 \n\t"\
-        "fpsub16 %%f22, %%f14, %%f22 \n\t"\
-        "fpadd16 %%f26, %%f14, %%f26 \n\t"\
-        "fpsub16 %%f30, %%f14, %%f30 \n\t"\
-    /* final butterfly */\
-        "5:                          \n\t"\
-        "fpsub16 %%f16, %%f18, %%f48 \n\t"\
-        "fpsub16 %%f20, %%f22, %%f50 \n\t"\
-        "fpsub16 %%f24, %%f26, %%f52 \n\t"\
-        "fpsub16 %%f28, %%f30, %%f54 \n\t"\
-        "fpadd16 %%f16, %%f18, %%f16 \n\t"\
-        "fpadd16 %%f20, %%f22, %%f20 \n\t"\
-        "fpadd16 %%f24, %%f26, %%f24 \n\t"\
-        "fpadd16 %%f28, %%f30, %%f28 \n\t"\
-
-#define STOREROWS(out) \
-        "std %%f48, [" out "+112]          \n\t"\
-        "std %%f50, [" out "+96]           \n\t"\
-        "std %%f52, [" out "+80]           \n\t"\
-        "std %%f54, [" out "+64]           \n\t"\
-        "std %%f16, [" out "]              \n\t"\
-        "std %%f20, [" out "+16]           \n\t"\
-        "std %%f24, [" out "+32]           \n\t"\
-        "std %%f28, [" out "+48]           \n\t"\
-
-#define SCALEROWS \
-        "fmul8sux16 %%f46, %%f48, %%f48 \n\t"\
-        "fmul8sux16 %%f46, %%f50, %%f50 \n\t"\
-        "fmul8sux16 %%f46, %%f52, %%f52 \n\t"\
-        "fmul8sux16 %%f46, %%f54, %%f54 \n\t"\
-        "fmul8sux16 %%f46, %%f16, %%f16 \n\t"\
-        "fmul8sux16 %%f46, %%f20, %%f20 \n\t"\
-        "fmul8sux16 %%f46, %%f24, %%f24 \n\t"\
-        "fmul8sux16 %%f46, %%f28, %%f28 \n\t"\
-
-#define PUTPIXELSCLAMPED(dest) \
-        "fpack16 %%f48, %%f14 \n\t"\
-        "fpack16 %%f50, %%f12 \n\t"\
-        "fpack16 %%f16, %%f0  \n\t"\
-        "fpack16 %%f20, %%f2  \n\t"\
-        "fpack16 %%f24, %%f4  \n\t"\
-        "fpack16 %%f28, %%f6  \n\t"\
-        "fpack16 %%f54, %%f8  \n\t"\
-        "fpack16 %%f52, %%f10 \n\t"\
-        "st %%f0, [%3+" dest "]   \n\t"\
-        "st %%f2, [%5+" dest "]   \n\t"\
-        "st %%f4, [%6+" dest "]   \n\t"\
-        "st %%f6, [%7+" dest "]   \n\t"\
-        "st %%f8, [%8+" dest "]   \n\t"\
-        "st %%f10, [%9+" dest "]  \n\t"\
-        "st %%f12, [%10+" dest "] \n\t"\
-        "st %%f14, [%11+" dest "] \n\t"\
-
-#define ADDPIXELSCLAMPED(dest) \
-        "ldd [%5], %%f18         \n\t"\
-        "ld [%3+" dest"], %%f0   \n\t"\
-        "ld [%6+" dest"], %%f2   \n\t"\
-        "ld [%7+" dest"], %%f4   \n\t"\
-        "ld [%8+" dest"], %%f6   \n\t"\
-        "ld [%9+" dest"], %%f8   \n\t"\
-        "ld [%10+" dest"], %%f10 \n\t"\
-        "ld [%11+" dest"], %%f12 \n\t"\
-        "ld [%12+" dest"], %%f14 \n\t"\
-        "fmul8x16 %%f0, %%f18, %%f0   \n\t"\
-        "fmul8x16 %%f2, %%f18, %%f2   \n\t"\
-        "fmul8x16 %%f4, %%f18, %%f4   \n\t"\
-        "fmul8x16 %%f6, %%f18, %%f6   \n\t"\
-        "fmul8x16 %%f8, %%f18, %%f8   \n\t"\
-        "fmul8x16 %%f10, %%f18, %%f10 \n\t"\
-        "fmul8x16 %%f12, %%f18, %%f12 \n\t"\
-        "fmul8x16 %%f14, %%f18, %%f14 \n\t"\
-        "fpadd16 %%f0, %%f16, %%f0    \n\t"\
-        "fpadd16 %%f2, %%f20, %%f2    \n\t"\
-        "fpadd16 %%f4, %%f24, %%f4    \n\t"\
-        "fpadd16 %%f6, %%f28, %%f6    \n\t"\
-        "fpadd16 %%f8, %%f54, %%f8    \n\t"\
-        "fpadd16 %%f10, %%f52, %%f10  \n\t"\
-        "fpadd16 %%f12, %%f50, %%f12  \n\t"\
-        "fpadd16 %%f14, %%f48, %%f14  \n\t"\
-        "fpack16 %%f0, %%f0   \n\t"\
-        "fpack16 %%f2, %%f2   \n\t"\
-        "fpack16 %%f4, %%f4   \n\t"\
-        "fpack16 %%f6, %%f6   \n\t"\
-        "fpack16 %%f8, %%f8   \n\t"\
-        "fpack16 %%f10, %%f10 \n\t"\
-        "fpack16 %%f12, %%f12 \n\t"\
-        "fpack16 %%f14, %%f14 \n\t"\
-        "st %%f0, [%3+" dest "]   \n\t"\
-        "st %%f2, [%6+" dest "]   \n\t"\
-        "st %%f4, [%7+" dest "]   \n\t"\
-        "st %%f6, [%8+" dest "]   \n\t"\
-        "st %%f8, [%9+" dest "]   \n\t"\
-        "st %%f10, [%10+" dest "] \n\t"\
-        "st %%f12, [%11+" dest "] \n\t"\
-        "st %%f14, [%12+" dest "] \n\t"\
-
-
-void ff_simple_idct_vis(int16_t *data) {
-    int out1, out2, out3, out4;
-    DECLARE_ALIGNED(8, int16_t, temp)[8*8];
-
-    __asm__ volatile(
-        INIT_IDCT
-
-#define ADDROUNDER
-
-        // shift right 16-4=12
-        LOADSCALE("%2+8")
-        IDCT4ROWS
-        STOREROWS("%3+8")
-        LOADSCALE("%2+0")
-        IDCT4ROWS
-        "std %%f48, [%3+112] \n\t"
-        "std %%f50, [%3+96]  \n\t"
-        "std %%f52, [%3+80]  \n\t"
-        "std %%f54, [%3+64]  \n\t"
-
-        // shift right 16+4
-        "ldd [%3+8], %%f18  \n\t"
-        "ldd [%3+24], %%f22 \n\t"
-        "ldd [%3+40], %%f26 \n\t"
-        "ldd [%3+56], %%f30 \n\t"
-        TRANSPOSE
-        IDCT4ROWS
-        SCALEROWS
-        STOREROWS("%2+0")
-        LOAD("%3+64")
-        TRANSPOSE
-        IDCT4ROWS
-        SCALEROWS
-        STOREROWS("%2+8")
-
-        : "=r" (out1), "=r" (out2), "=r" (out3), "=r" (out4)
-        : "0" (scale), "1" (coeffs), "2" (data), "3" (temp)
-    );
-}
-
-void ff_simple_idct_put_vis(uint8_t *dest, int line_size, int16_t *data) {
-    int out1, out2, out3, out4, out5;
-    int r1, r2, r3, r4, r5, r6, r7;
-
-    __asm__ volatile(
-        "wr %%g0, 0x8, %%gsr \n\t"
-
-        INIT_IDCT
-
-        "add %3, %4, %5   \n\t"
-        "add %5, %4, %6   \n\t"
-        "add %6, %4, %7   \n\t"
-        "add %7, %4, %8   \n\t"
-        "add %8, %4, %9   \n\t"
-        "add %9, %4, %10  \n\t"
-        "add %10, %4, %11 \n\t"
-
-        // shift right 16-4=12
-        LOADSCALE("%2+8")
-        IDCT4ROWS
-        STOREROWS("%2+8")
-        LOADSCALE("%2+0")
-        IDCT4ROWS
-        "std %%f48, [%2+112] \n\t"
-        "std %%f50, [%2+96]  \n\t"
-        "std %%f52, [%2+80]  \n\t"
-        "std %%f54, [%2+64]  \n\t"
-
-#undef ADDROUNDER
-#define ADDROUNDER "fpadd16 %%f28, %%f46, %%f28 \n\t"
-
-        // shift right 16+4
-        "ldd [%2+8], %%f18  \n\t"
-        "ldd [%2+24], %%f22 \n\t"
-        "ldd [%2+40], %%f26 \n\t"
-        "ldd [%2+56], %%f30 \n\t"
-        TRANSPOSE
-        IDCT4ROWS
-        PUTPIXELSCLAMPED("0")
-        LOAD("%2+64")
-        TRANSPOSE
-        IDCT4ROWS
-        PUTPIXELSCLAMPED("4")
-
-        : "=r" (out1), "=r" (out2), "=r" (out3), "=r" (out4), "=r" (out5),
-          "=r" (r1), "=r" (r2), "=r" (r3), "=r" (r4), "=r" (r5), "=r" (r6), "=r" (r7)
-        : "0" (rounder), "1" (coeffs), "2" (data), "3" (dest), "4" (line_size)
-    );
-}
-
-void ff_simple_idct_add_vis(uint8_t *dest, int line_size, int16_t *data) {
-    int out1, out2, out3, out4, out5, out6;
-    int r1, r2, r3, r4, r5, r6, r7;
-
-    __asm__ volatile(
-        "wr %%g0, 0x8, %%gsr \n\t"
-
-        INIT_IDCT
-
-        "add %3, %4, %6   \n\t"
-        "add %6, %4, %7   \n\t"
-        "add %7, %4, %8   \n\t"
-        "add %8, %4, %9   \n\t"
-        "add %9, %4, %10  \n\t"
-        "add %10, %4, %11 \n\t"
-        "add %11, %4, %12 \n\t"
-
-#undef ADDROUNDER
-#define ADDROUNDER
-
-        // shift right 16-4=12
-        LOADSCALE("%2+8")
-        IDCT4ROWS
-        STOREROWS("%2+8")
-        LOADSCALE("%2+0")
-        IDCT4ROWS
-        "std %%f48, [%2+112] \n\t"
-        "std %%f50, [%2+96]  \n\t"
-        "std %%f52, [%2+80]  \n\t"
-        "std %%f54, [%2+64]  \n\t"
-
-#undef ADDROUNDER
-#define ADDROUNDER "fpadd16 %%f28, %%f46, %%f28 \n\t"
-
-        // shift right 16+4
-        "ldd [%2+8], %%f18  \n\t"
-        "ldd [%2+24], %%f22 \n\t"
-        "ldd [%2+40], %%f26 \n\t"
-        "ldd [%2+56], %%f30 \n\t"
-        TRANSPOSE
-        IDCT4ROWS
-        ADDPIXELSCLAMPED("0")
-        LOAD("%2+64")
-        TRANSPOSE
-        IDCT4ROWS
-        ADDPIXELSCLAMPED("4")
-
-        : "=r" (out1), "=r" (out2), "=r" (out3), "=r" (out4), "=r" (out5), "=r" (out6),
-          "=r" (r1), "=r" (r2), "=r" (r3), "=r" (r4), "=r" (r5), "=r" (r6), "=r" (r7)
-        : "0" (rounder), "1" (coeffs), "2" (data), "3" (dest), "4" (line_size), "5" (expand)
-    );
-}
diff --git a/deps/libav/libavcodec/sparc/vis.h b/deps/libav/libavcodec/sparc/vis.h
deleted file mode 100644
index ff2fb9d..0000000
--- a/deps/libav/libavcodec/sparc/vis.h
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * Copyright (C) 2003 David S. Miller <davem at redhat.com>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/* You may be asking why I hard-code the instruction opcodes and don't
- * use the normal VIS assembler mnenomics for the VIS instructions.
- *
- * The reason is that Sun, in their infinite wisdom, decided that a binary
- * using a VIS instruction will cause it to be marked (in the ELF headers)
- * as doing so, and this prevents the OS from loading such binaries if the
- * current cpu doesn't have VIS.  There is no way to easily override this
- * behavior of the assembler that I am aware of.
- *
- * This totally defeats what libmpeg2 is trying to do which is allow a
- * single binary to be created, and then detect the availability of VIS
- * at runtime.
- *
- * I'm not saying that tainting the binary by default is bad, rather I'm
- * saying that not providing a way to override this easily unnecessarily
- * ties people's hands.
- *
- * Thus, we do the opcode encoding by hand and output 32-bit words in
- * the assembler to keep the binary from becoming tainted.
- */
-
-#ifndef AVCODEC_SPARC_VIS_H
-#define AVCODEC_SPARC_VIS_H
-
-#define ACCEL_SPARC_VIS 1
-#define ACCEL_SPARC_VIS2 2
-
-static inline int vis_level(void)
-{
-    int accel = 0;
-    accel |= ACCEL_SPARC_VIS;
-    accel |= ACCEL_SPARC_VIS2;
-    return accel;
-}
-
-#define vis_opc_base    ((0x1 << 31) | (0x36 << 19))
-#define vis_opf(X)      ((X) << 5)
-#define vis_sreg(X)     (X)
-#define vis_dreg(X)     (((X)&0x1f)|((X)>>5))
-#define vis_rs1_s(X)    (vis_sreg(X) << 14)
-#define vis_rs1_d(X)    (vis_dreg(X) << 14)
-#define vis_rs2_s(X)    (vis_sreg(X) << 0)
-#define vis_rs2_d(X)    (vis_dreg(X) << 0)
-#define vis_rd_s(X)     (vis_sreg(X) << 25)
-#define vis_rd_d(X)     (vis_dreg(X) << 25)
-
-#define vis_ss2s(opf,rs1,rs2,rd) \
-        __asm__ volatile (".word %0" \
-                              : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs1_s(rs1) | \
-                                       vis_rs2_s(rs2) | \
-                                       vis_rd_s(rd)))
-
-#define vis_dd2d(opf,rs1,rs2,rd) \
-        __asm__ volatile (".word %0" \
-                              : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs1_d(rs1) | \
-                                       vis_rs2_d(rs2) | \
-                                       vis_rd_d(rd)))
-
-#define vis_ss2d(opf,rs1,rs2,rd) \
-        __asm__ volatile (".word %0" \
-                              : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs1_s(rs1) | \
-                                       vis_rs2_s(rs2) | \
-                                       vis_rd_d(rd)))
-
-#define vis_sd2d(opf,rs1,rs2,rd) \
-        __asm__ volatile (".word %0" \
-                              : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs1_s(rs1) | \
-                                       vis_rs2_d(rs2) | \
-                                       vis_rd_d(rd)))
-
-#define vis_d2s(opf,rs2,rd) \
-        __asm__ volatile (".word %0" \
-                              : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs2_d(rs2) | \
-                                       vis_rd_s(rd)))
-
-#define vis_s2d(opf,rs2,rd) \
-        __asm__ volatile (".word %0" \
-                              : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs2_s(rs2) | \
-                                       vis_rd_d(rd)))
-
-#define vis_d12d(opf,rs1,rd) \
-        __asm__ volatile (".word %0" \
-                              : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs1_d(rs1) | \
-                                       vis_rd_d(rd)))
-
-#define vis_d22d(opf,rs2,rd) \
-        __asm__ volatile (".word %0" \
-                              : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs2_d(rs2) | \
-                                       vis_rd_d(rd)))
-
-#define vis_s12s(opf,rs1,rd) \
-        __asm__ volatile (".word %0" \
-                              : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs1_s(rs1) | \
-                                       vis_rd_s(rd)))
-
-#define vis_s22s(opf,rs2,rd) \
-        __asm__ volatile (".word %0" \
-                              : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rs2_s(rs2) | \
-                                       vis_rd_s(rd)))
-
-#define vis_s(opf,rd) \
-        __asm__ volatile (".word %0" \
-                              : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rd_s(rd)))
-
-#define vis_d(opf,rd) \
-        __asm__ volatile (".word %0" \
-                              : : "i" (vis_opc_base | vis_opf(opf) | \
-                                       vis_rd_d(rd)))
-
-#define vis_r2m(op,rd,mem) \
-        __asm__ volatile (#op "\t%%f" #rd ", [%0]" : : "r" (&(mem)) )
-
-#define vis_r2m_2(op,rd,mem1,mem2) \
-        __asm__ volatile (#op "\t%%f" #rd ", [%0 + %1]" : : "r" (mem1), "r" (mem2) )
-
-#define vis_m2r(op,mem,rd) \
-        __asm__ volatile (#op "\t[%0], %%f" #rd : : "r" (&(mem)) )
-
-#define vis_m2r_2(op,mem1,mem2,rd) \
-        __asm__ volatile (#op "\t[%0 + %1], %%f" #rd : : "r" (mem1), "r" (mem2) )
-
-static inline void vis_set_gsr(unsigned int val)
-{
-        __asm__ volatile("mov %0,%%asr19"
-                             : : "r" (val));
-}
-
-#define VIS_GSR_ALIGNADDR_MASK          0x0000007
-#define VIS_GSR_ALIGNADDR_SHIFT         0
-#define VIS_GSR_SCALEFACT_MASK          0x0000078
-#define VIS_GSR_SCALEFACT_SHIFT         3
-
-#define vis_ld32(mem,rs1)               vis_m2r(ld, mem, rs1)
-#define vis_ld32_2(mem1,mem2,rs1)       vis_m2r_2(ld, mem1, mem2, rs1)
-#define vis_st32(rs1,mem)               vis_r2m(st, rs1, mem)
-#define vis_st32_2(rs1,mem1,mem2)       vis_r2m_2(st, rs1, mem1, mem2)
-#define vis_ld64(mem,rs1)               vis_m2r(ldd, mem, rs1)
-#define vis_ld64_2(mem1,mem2,rs1)       vis_m2r_2(ldd, mem1, mem2, rs1)
-#define vis_st64(rs1,mem)               vis_r2m(std, rs1, mem)
-#define vis_st64_2(rs1,mem1,mem2)       vis_r2m_2(std, rs1, mem1, mem2)
-
-/* 16 and 32 bit partitioned addition and subtraction.  The normal
- * versions perform 4 16-bit or 2 32-bit additions or subtractions.
- * The 's' versions perform 2 16-bit or 1 32-bit additions or
- * subtractions.
- */
-
-#define vis_padd16(rs1,rs2,rd)          vis_dd2d(0x50, rs1, rs2, rd)
-#define vis_padd16s(rs1,rs2,rd)         vis_ss2s(0x51, rs1, rs2, rd)
-#define vis_padd32(rs1,rs2,rd)          vis_dd2d(0x52, rs1, rs2, rd)
-#define vis_padd32s(rs1,rs2,rd)         vis_ss2s(0x53, rs1, rs2, rd)
-#define vis_psub16(rs1,rs2,rd)          vis_dd2d(0x54, rs1, rs2, rd)
-#define vis_psub16s(rs1,rs2,rd)         vis_ss2s(0x55, rs1, rs2, rd)
-#define vis_psub32(rs1,rs2,rd)          vis_dd2d(0x56, rs1, rs2, rd)
-#define vis_psub32s(rs1,rs2,rd)         vis_ss2s(0x57, rs1, rs2, rd)
-
-/* Pixel formatting instructions.  */
-
-#define vis_pack16(rs2,rd)              vis_d2s( 0x3b,      rs2, rd)
-#define vis_pack32(rs1,rs2,rd)          vis_dd2d(0x3a, rs1, rs2, rd)
-#define vis_packfix(rs2,rd)             vis_d2s( 0x3d,      rs2, rd)
-#define vis_expand(rs2,rd)              vis_s2d( 0x4d,      rs2, rd)
-#define vis_pmerge(rs1,rs2,rd)          vis_ss2d(0x4b, rs1, rs2, rd)
-
-/* Partitioned multiply instructions.  */
-
-#define vis_mul8x16(rs1,rs2,rd)         vis_sd2d(0x31, rs1, rs2, rd)
-#define vis_mul8x16au(rs1,rs2,rd)       vis_ss2d(0x33, rs1, rs2, rd)
-#define vis_mul8x16al(rs1,rs2,rd)       vis_ss2d(0x35, rs1, rs2, rd)
-#define vis_mul8sux16(rs1,rs2,rd)       vis_dd2d(0x36, rs1, rs2, rd)
-#define vis_mul8ulx16(rs1,rs2,rd)       vis_dd2d(0x37, rs1, rs2, rd)
-#define vis_muld8sux16(rs1,rs2,rd)      vis_ss2d(0x38, rs1, rs2, rd)
-#define vis_muld8ulx16(rs1,rs2,rd)      vis_ss2d(0x39, rs1, rs2, rd)
-
-/* Alignment instructions.  */
-
-static inline const void *vis_alignaddr(const void *ptr)
-{
-        __asm__ volatile("alignaddr %0, %%g0, %0"
-                             : "=&r" (ptr)
-                             : "0" (ptr));
-
-        return ptr;
-}
-
-static inline void vis_alignaddr_g0(void *ptr)
-{
-        __asm__ volatile("alignaddr %0, %%g0, %%g0"
-                             : : "r" (ptr));
-}
-
-#define vis_faligndata(rs1,rs2,rd)        vis_dd2d(0x48, rs1, rs2, rd)
-
-/* Logical operate instructions.  */
-
-#define vis_fzero(rd)                   vis_d(   0x60,           rd)
-#define vis_fzeros(rd)                  vis_s(   0x61,           rd)
-#define vis_fone(rd)                    vis_d(   0x7e,           rd)
-#define vis_fones(rd)                   vis_s(   0x7f,           rd)
-#define vis_src1(rs1,rd)                vis_d12d(0x74, rs1,      rd)
-#define vis_src1s(rs1,rd)               vis_s12s(0x75, rs1,      rd)
-#define vis_src2(rs2,rd)                vis_d22d(0x78,      rs2, rd)
-#define vis_src2s(rs2,rd)               vis_s22s(0x79,      rs2, rd)
-#define vis_not1(rs1,rd)                vis_d12d(0x6a, rs1,      rd)
-#define vis_not1s(rs1,rd)               vis_s12s(0x6b, rs1,      rd)
-#define vis_not2(rs2,rd)                vis_d22d(0x66,      rs2, rd)
-#define vis_not2s(rs2,rd)               vis_s22s(0x67,      rs2, rd)
-#define vis_or(rs1,rs2,rd)              vis_dd2d(0x7c, rs1, rs2, rd)
-#define vis_ors(rs1,rs2,rd)             vis_ss2s(0x7d, rs1, rs2, rd)
-#define vis_nor(rs1,rs2,rd)             vis_dd2d(0x62, rs1, rs2, rd)
-#define vis_nors(rs1,rs2,rd)            vis_ss2s(0x63, rs1, rs2, rd)
-#define vis_and(rs1,rs2,rd)             vis_dd2d(0x70, rs1, rs2, rd)
-#define vis_ands(rs1,rs2,rd)            vis_ss2s(0x71, rs1, rs2, rd)
-#define vis_nand(rs1,rs2,rd)            vis_dd2d(0x6e, rs1, rs2, rd)
-#define vis_nands(rs1,rs2,rd)           vis_ss2s(0x6f, rs1, rs2, rd)
-#define vis_xor(rs1,rs2,rd)             vis_dd2d(0x6c, rs1, rs2, rd)
-#define vis_xors(rs1,rs2,rd)            vis_ss2s(0x6d, rs1, rs2, rd)
-#define vis_xnor(rs1,rs2,rd)            vis_dd2d(0x72, rs1, rs2, rd)
-#define vis_xnors(rs1,rs2,rd)           vis_ss2s(0x73, rs1, rs2, rd)
-#define vis_ornot1(rs1,rs2,rd)          vis_dd2d(0x7a, rs1, rs2, rd)
-#define vis_ornot1s(rs1,rs2,rd)         vis_ss2s(0x7b, rs1, rs2, rd)
-#define vis_ornot2(rs1,rs2,rd)          vis_dd2d(0x76, rs1, rs2, rd)
-#define vis_ornot2s(rs1,rs2,rd)         vis_ss2s(0x77, rs1, rs2, rd)
-#define vis_andnot1(rs1,rs2,rd)         vis_dd2d(0x68, rs1, rs2, rd)
-#define vis_andnot1s(rs1,rs2,rd)        vis_ss2s(0x69, rs1, rs2, rd)
-#define vis_andnot2(rs1,rs2,rd)         vis_dd2d(0x64, rs1, rs2, rd)
-#define vis_andnot2s(rs1,rs2,rd)        vis_ss2s(0x65, rs1, rs2, rd)
-
-/* Pixel component distance.  */
-
-#define vis_pdist(rs1,rs2,rd)           vis_dd2d(0x3e, rs1, rs2, rd)
-
-#endif /* AVCODEC_SPARC_VIS_H */
diff --git a/deps/libav/libavcodec/svq3.h b/deps/libav/libavcodec/svq3.h
index 8c67a23..a20e620 100644
--- a/deps/libav/libavcodec/svq3.h
+++ b/deps/libav/libavcodec/svq3.h
@@ -24,4 +24,4 @@
 void ff_svq3_luma_dc_dequant_idct_c(int16_t *output, int16_t *input, int qp);
 void ff_svq3_add_idct_c(uint8_t *dst, int16_t *block, int stride, int qp, int dc);
 
-#endif /* AVCODEC_DSPUTIL_H */
+#endif /* AVCODEC_SVQ3_H */
diff --git a/deps/libav/libavcodec/synth_filter.c b/deps/libav/libavcodec/synth_filter.c
index 8e6f120..d0ace40 100644
--- a/deps/libav/libavcodec/synth_filter.c
+++ b/deps/libav/libavcodec/synth_filter.c
@@ -61,4 +61,5 @@ av_cold void ff_synth_filter_init(SynthFilterContext *c)
     c->synth_filter_float = synth_filter_float;
 
     if (ARCH_ARM) ff_synth_filter_init_arm(c);
+    if (ARCH_X86) ff_synth_filter_init_x86(c);
 }
diff --git a/deps/libav/libavcodec/synth_filter.h b/deps/libav/libavcodec/synth_filter.h
index 7b73578..f842c70 100644
--- a/deps/libav/libavcodec/synth_filter.h
+++ b/deps/libav/libavcodec/synth_filter.h
@@ -33,5 +33,6 @@ typedef struct SynthFilterContext {
 
 void ff_synth_filter_init(SynthFilterContext *c);
 void ff_synth_filter_init_arm(SynthFilterContext *c);
+void ff_synth_filter_init_x86(SynthFilterContext *c);
 
 #endif /* AVCODEC_SYNTH_FILTER_H */
diff --git a/deps/libav/libavcodec/utils.c b/deps/libav/libavcodec/utils.c
index b2b11ef..c88b346 100644
--- a/deps/libav/libavcodec/utils.c
+++ b/deps/libav/libavcodec/utils.c
@@ -754,7 +754,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
 
 int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
 {
-    AVFrame tmp;
+    AVFrame *tmp;
     int ret;
 
     av_assert0(avctx->codec_type == AVMEDIA_TYPE_VIDEO);
@@ -768,18 +768,20 @@ int ff_reget_buffer(AVCodecContext *avctx, AVFrame *frame)
         return 0;
     }
 
-    av_frame_move_ref(&tmp, frame);
+    tmp = av_frame_alloc();
+    if (!tmp)
+        return AVERROR(ENOMEM);
+
+    av_frame_move_ref(tmp, frame);
 
     ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF);
     if (ret < 0) {
-        av_frame_unref(&tmp);
+        av_frame_free(&tmp);
         return ret;
     }
 
-    av_image_copy(frame->data, frame->linesize, tmp.data, tmp.linesize,
-                  frame->format, frame->width, frame->height);
-
-    av_frame_unref(&tmp);
+    av_frame_copy(frame, tmp);
+    av_frame_free(&tmp);
 
     return 0;
 }
diff --git a/deps/libav/libavcodec/utvideoenc.c b/deps/libav/libavcodec/utvideoenc.c
index 47a4f3a..b63858d 100644
--- a/deps/libav/libavcodec/utvideoenc.c
+++ b/deps/libav/libavcodec/utvideoenc.c
@@ -58,7 +58,7 @@ static av_cold int utvideo_encode_close(AVCodecContext *avctx)
 static av_cold int utvideo_encode_init(AVCodecContext *avctx)
 {
     UtvideoContext *c = avctx->priv_data;
-    int i;
+    int i, subsampled_height;
     uint32_t original_format;
 
     c->avctx           = avctx;
@@ -132,6 +132,26 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
         return AVERROR_OPTION_NOT_FOUND;
     }
 
+    /*
+     * Check the asked slice count for obviously invalid
+     * values (> 256 or negative).
+     */
+    if (avctx->slices > 256 || avctx->slices < 0) {
+        av_log(avctx, AV_LOG_ERROR,
+               "Slice count %d is not supported in Ut Video (theoretical range is 0-256).\n",
+               avctx->slices);
+        return AVERROR(EINVAL);
+    }
+
+    /* Check that the slice count is not larger than the subsampled height */
+    subsampled_height = avctx->height >> av_pix_fmt_desc_get(avctx->pix_fmt)->log2_chroma_h;
+    if (avctx->slices > subsampled_height) {
+        av_log(avctx, AV_LOG_ERROR,
+               "Slice count %d is larger than the subsampling-applied height %d.\n",
+               avctx->slices, subsampled_height);
+        return AVERROR(EINVAL);
+    }
+
     avctx->coded_frame = av_frame_alloc();
 
     if (!avctx->coded_frame) {
@@ -181,9 +201,19 @@ static av_cold int utvideo_encode_init(AVCodecContext *avctx)
 
     /*
      * Set how many slices are going to be used.
-     * Set one slice for now.
+     * By default uses multiple slices depending on the subsampled height.
+     * This enables multithreading in the official decoder.
      */
-    c->slices = 1;
+    if (!avctx->slices) {
+        c->slices = subsampled_height / 120;
+
+        if (!c->slices)
+            c->slices = 1;
+        else if (c->slices > 256)
+            c->slices = 256;
+    } else {
+        c->slices = avctx->slices;
+    }
 
     /* Set compression mode */
     c->compression = COMP_HUFF;
diff --git a/deps/libav/libavcodec/vdpau.c b/deps/libav/libavcodec/vdpau.c
index d8a35ee..50a57d0 100644
--- a/deps/libav/libavcodec/vdpau.c
+++ b/deps/libav/libavcodec/vdpau.c
@@ -114,7 +114,7 @@ do {                        \
         default:                               return AVERROR(EINVAL);
         }
     case AV_CODEC_ID_H264:
-        switch (avctx->profile) {
+        switch (avctx->profile & ~FF_PROFILE_H264_INTRA) {
         case FF_PROFILE_H264_CONSTRAINED_BASELINE:
         case FF_PROFILE_H264_BASELINE:         PROFILE(VDP_DECODER_PROFILE_H264_BASELINE);
         case FF_PROFILE_H264_MAIN:             PROFILE(VDP_DECODER_PROFILE_H264_MAIN);
diff --git a/deps/libav/libavcodec/version.h b/deps/libav/libavcodec/version.h
index 4253074..5ab49d5 100644
--- a/deps/libav/libavcodec/version.h
+++ b/deps/libav/libavcodec/version.h
@@ -30,7 +30,7 @@
 
 #define LIBAVCODEC_VERSION_MAJOR 55
 #define LIBAVCODEC_VERSION_MINOR 34
-#define LIBAVCODEC_VERSION_MICRO  0
+#define LIBAVCODEC_VERSION_MICRO  1
 
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
                                                LIBAVCODEC_VERSION_MINOR, \
@@ -123,5 +123,11 @@
 #ifndef FF_API_EMU_EDGE
 #define FF_API_EMU_EDGE          (LIBAVCODEC_VERSION_MAJOR < 56)
 #endif
+#ifndef FF_API_ARCH_SH4
+#define FF_API_ARCH_SH4          (LIBAVCODEC_VERSION_MAJOR < 56)
+#endif
+#ifndef FF_API_ARCH_SPARC
+#define FF_API_ARCH_SPARC        (LIBAVCODEC_VERSION_MAJOR < 56)
+#endif
 
 #endif /* AVCODEC_VERSION_H */
diff --git a/deps/libav/libavcodec/vorbisenc.c b/deps/libav/libavcodec/vorbisenc.c
index f16060e..830e5d1 100644
--- a/deps/libav/libavcodec/vorbisenc.c
+++ b/deps/libav/libavcodec/vorbisenc.c
@@ -25,9 +25,11 @@
  */
 
 #include <float.h>
+
 #include "avcodec.h"
 #include "internal.h"
 #include "fft.h"
+#include "mathops.h"
 #include "vorbis.h"
 #include "vorbis_enc_data.h"
 
diff --git a/deps/libav/libavcodec/vp3.c b/deps/libav/libavcodec/vp3.c
index adcecbc..a45f2db 100644
--- a/deps/libav/libavcodec/vp3.c
+++ b/deps/libav/libavcodec/vp3.c
@@ -1705,10 +1705,10 @@ static av_cold int vp3_decode_init(AVCodecContext *avctx)
     ff_vp3dsp_init(&s->vp3dsp, avctx->flags);
 
     for (i = 0; i < 64; i++) {
-#define T(x) (x >> 3) | ((x & 7) << 3)
-        s->idct_permutation[i] = T(i);
-        s->idct_scantable[i] = T(ff_zigzag_direct[i]);
-#undef T
+#define TRANSPOSE(x) (x >> 3) | ((x & 7) << 3)
+        s->idct_permutation[i] = TRANSPOSE(i);
+        s->idct_scantable[i]   = TRANSPOSE(ff_zigzag_direct[i]);
+#undef TRANSPOSE
     }
 
     /* initialize to an impossible value which will force a recalculation
diff --git a/deps/libav/libavcodec/vp3dsp.c b/deps/libav/libavcodec/vp3dsp.c
index 94de0e5..703fe38 100644
--- a/deps/libav/libavcodec/vp3dsp.c
+++ b/deps/libav/libavcodec/vp3dsp.c
@@ -26,6 +26,7 @@
 
 #include "libavutil/attributes.h"
 #include "libavutil/common.h"
+#include "libavutil/intreadwrite.h"
 #include "avcodec.h"
 #include "dsputil.h"
 #include "rnd_avg.h"
diff --git a/deps/libav/libavcodec/vp56.c b/deps/libav/libavcodec/vp56.c
index 7fbf9a0..b9d3c87 100644
--- a/deps/libav/libavcodec/vp56.c
+++ b/deps/libav/libavcodec/vp56.c
@@ -664,9 +664,9 @@ av_cold int ff_vp56_init(AVCodecContext *avctx, int flip, int has_alpha)
     ff_vp3dsp_init(&s->vp3dsp, avctx->flags);
     ff_vp56dsp_init(&s->vp56dsp, avctx->codec->id);
     for (i = 0; i < 64; i++) {
-#define T(x) (x >> 3) | ((x & 7) << 3)
-        s->idct_scantable[i] = T(ff_zigzag_direct[i]);
-#undef T
+#define TRANSPOSE(x) (x >> 3) | ((x & 7) << 3)
+        s->idct_scantable[i] = TRANSPOSE(ff_zigzag_direct[i]);
+#undef TRANSPOSE
     }
 
     for (i = 0; i < FF_ARRAY_ELEMS(s->frames); i++) {
diff --git a/deps/libav/libavcodec/vp8dsp.c b/deps/libav/libavcodec/vp8dsp.c
index 0978da5..9219092 100644
--- a/deps/libav/libavcodec/vp8dsp.c
+++ b/deps/libav/libavcodec/vp8dsp.c
@@ -160,7 +160,7 @@ static av_always_inline void filter_common(uint8_t *p, ptrdiff_t stride, int is4
 {
     LOAD_PIXELS
     int a, f1, f2;
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
 
     a = 3*(q0 - p0);
 
@@ -215,7 +215,7 @@ static av_always_inline int hev(uint8_t *p, ptrdiff_t stride, int thresh)
 static av_always_inline void filter_mbedge(uint8_t *p, ptrdiff_t stride)
 {
     int a0, a1, a2, w;
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;
 
     LOAD_PIXELS
 
@@ -337,7 +337,7 @@ PUT_PIXELS(4)
 static void put_vp8_epel ## SIZE ## _h ## TAPS ## _c(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my) \
 { \
     const uint8_t *filter = subpel_filters[mx-1]; \
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; \
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
     int x, y; \
 \
     for (y = 0; y < h; y++) { \
@@ -351,7 +351,7 @@ static void put_vp8_epel ## SIZE ## _h ## TAPS ## _c(uint8_t *dst, ptrdiff_t dst
 static void put_vp8_epel ## SIZE ## _v ## TAPS ## _c(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my) \
 { \
     const uint8_t *filter = subpel_filters[my-1]; \
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; \
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
     int x, y; \
 \
     for (y = 0; y < h; y++) { \
@@ -365,7 +365,7 @@ static void put_vp8_epel ## SIZE ## _v ## TAPS ## _c(uint8_t *dst, ptrdiff_t dst
 static void put_vp8_epel ## SIZE ## _h ## HTAPS ## v ## VTAPS ## _c(uint8_t *dst, ptrdiff_t dststride, uint8_t *src, ptrdiff_t srcstride, int h, int mx, int my) \
 { \
     const uint8_t *filter = subpel_filters[mx-1]; \
-    const uint8_t *cm = ff_cropTbl + MAX_NEG_CROP; \
+    const uint8_t *cm = ff_crop_tab + MAX_NEG_CROP; \
     int x, y; \
     uint8_t tmp_array[(2*SIZE+VTAPS-1)*SIZE]; \
     uint8_t *tmp = tmp_array; \
diff --git a/deps/libav/libavcodec/x86/ac3dsp.asm b/deps/libav/libavcodec/x86/ac3dsp.asm
index b432318..d0ab3e7 100644
--- a/deps/libav/libavcodec/x86/ac3dsp.asm
+++ b/deps/libav/libavcodec/x86/ac3dsp.asm
@@ -1,5 +1,5 @@
 ;*****************************************************************************
-;* x86-optimized AC-3 DSP utils
+;* x86-optimized AC-3 DSP functions
 ;* Copyright (c) 2011 Justin Ruggles
 ;*
 ;* This file is part of Libav.
diff --git a/deps/libav/libavcodec/x86/ac3dsp_init.c b/deps/libav/libavcodec/x86/ac3dsp_init.c
index f3a9213..a82c249 100644
--- a/deps/libav/libavcodec/x86/ac3dsp_init.c
+++ b/deps/libav/libavcodec/x86/ac3dsp_init.c
@@ -1,5 +1,5 @@
 /*
- * x86-optimized AC-3 DSP utils
+ * x86-optimized AC-3 DSP functions
  * Copyright (c) 2011 Justin Ruggles
  *
  * This file is part of Libav.
diff --git a/deps/libav/libavcodec/x86/cabac.h b/deps/libav/libavcodec/x86/cabac.h
index fdb0a29..d1701bf 100644
--- a/deps/libav/libavcodec/x86/cabac.h
+++ b/deps/libav/libavcodec/x86/cabac.h
@@ -23,8 +23,8 @@
 
 #include "libavcodec/cabac.h"
 #include "libavutil/attributes.h"
+#include "libavutil/macros.h"
 #include "libavutil/x86/asm.h"
-#include "libavutil/internal.h"
 #include "config.h"
 
 #if HAVE_INLINE_ASM
diff --git a/deps/libav/libavcodec/x86/dca.h b/deps/libav/libavcodec/x86/dca.h
index ab175b3..11d45ae 100644
--- a/deps/libav/libavcodec/x86/dca.h
+++ b/deps/libav/libavcodec/x86/dca.h
@@ -18,6 +18,9 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#ifndef AVCODEC_X86_DCA_H
+#define AVCODEC_X86_DCA_H
+
 #include "config.h"
 
 #if ARCH_X86_64 && HAVE_SSE2_INLINE
@@ -53,3 +56,5 @@ static inline void int8x8_fmul_int32(av_unused DCADSPContext *dsp,
 }
 
 #endif /* ARCH_X86_64 && HAVE_SSE2_INLINE */
+
+#endif /* AVCODEC_X86_DCA_H */
diff --git a/deps/libav/libavcodec/x86/dcadsp.asm b/deps/libav/libavcodec/x86/dcadsp.asm
index 214f514..56039ba 100644
--- a/deps/libav/libavcodec/x86/dcadsp.asm
+++ b/deps/libav/libavcodec/x86/dcadsp.asm
@@ -26,18 +26,35 @@ pf_inv16:  times 4 dd 0x3D800000 ; 1/16
 
 SECTION_TEXT
 
-; void int8x8_fmul_int32_sse2(float *dst, const int8_t *src, int scale)
-%macro INT8X8_FMUL_INT32 0
-cglobal int8x8_fmul_int32, 3,3,5, dst, src, scale
-    cvtsi2ss    m0, scalem
+; void decode_hf(float dst[DCA_SUBBANDS][8], const int32_t vq_num[DCA_SUBBANDS],
+;                const int8_t hf_vq[1024][32], intptr_t vq_offset,
+;                int32_t scale[DCA_SUBBANDS][2], intptr_t start, intptr_t end)
+
+%macro DECODE_HF 0
+cglobal decode_hf, 6,6,5, dst, num, src, offset, scale, start, end
+    lea       srcq, [srcq + offsetq]
+    shl     startq, 2
+    mov    offsetd, endm
+%define DICT offsetq
+    shl    offsetq, 2
+    mov       endm, offsetq
+.loop:
+%if ARCH_X86_64
+    mov    offsetd, [scaleq + 2 * startq]
+    cvtsi2ss    m0, offsetd
+%else
+    cvtsi2ss    m0, [scaleq + 2 * startq]
+%endif
+    mov    offsetd, [numq + startq]
     mulss       m0, [pf_inv16]
+    shl       DICT, 5
     shufps      m0, m0, 0
 %if cpuflag(sse2)
 %if cpuflag(sse4)
-    pmovsxbd    m1, [srcq+0]
-    pmovsxbd    m2, [srcq+4]
+    pmovsxbd    m1, [srcq + DICT + 0]
+    pmovsxbd    m2, [srcq + DICT + 4]
 %else
-    movq        m1, [srcq]
+    movq        m1, [srcq + DICT]
     punpcklbw   m1, m1
     mova        m2, m1
     punpcklwd   m1, m1
@@ -48,8 +65,8 @@ cglobal int8x8_fmul_int32, 3,3,5, dst, src, scale
     cvtdq2ps    m1, m1
     cvtdq2ps    m2, m2
 %else
-    movd       mm0, [srcq+0]
-    movd       mm1, [srcq+4]
+    movd       mm0, [srcq + DICT + 0]
+    movd       mm1, [srcq + DICT + 4]
     punpcklbw  mm0, mm0
     punpcklbw  mm1, mm1
     movq       mm2, mm0
@@ -67,24 +84,269 @@ cglobal int8x8_fmul_int32, 3,3,5, dst, src, scale
     cvtpi2ps    m3, mm2
     cvtpi2ps    m4, mm3
     shufps      m0, m0, 0
-    emms
     shufps      m1, m3, q1010
     shufps      m2, m4, q1010
 %endif
     mulps       m1, m0
     mulps       m2, m0
-    mova [dstq+ 0], m1
-    mova [dstq+16], m2
+    mova [dstq + 8 * startq +  0], m1
+    mova [dstq + 8 * startq + 16], m2
+    add     startq, 4
+    cmp     startq, endm
+    jl       .loop
+.end:
+%if notcpuflag(sse2)
+    emms
+%endif
     REP_RET
 %endmacro
 
 %if ARCH_X86_32
 INIT_XMM sse
-INT8X8_FMUL_INT32
+DECODE_HF
 %endif
 
 INIT_XMM sse2
-INT8X8_FMUL_INT32
+DECODE_HF
 
 INIT_XMM sse4
-INT8X8_FMUL_INT32
+DECODE_HF
+
+; %1=v0/v1  %2=in1  %3=in2
+%macro FIR_LOOP 2-3
+.loop%1:
+%define va          m1
+%define vb          m2
+%if %1
+%define OFFSET      0
+%else
+%define OFFSET      NUM_COEF*count
+%endif
+; for v0, incrementing and for v1, decrementing
+    mova        va, [cf0q + OFFSET]
+    mova        vb, [cf0q + OFFSET + 4*NUM_COEF]
+%if %0 == 3
+    mova        m4, [cf0q + OFFSET + mmsize]
+    mova        m0, [cf0q + OFFSET + 4*NUM_COEF + mmsize]
+%endif
+    mulps       va, %2
+    mulps       vb, %2
+%if %0 == 3
+    mulps       m4, %3
+    mulps       m0, %3
+    addps       va, m4
+    addps       vb, m0
+%endif
+    ; va = va1 va2 va3 va4
+    ; vb = vb1 vb2 vb3 vb4
+%if %1
+    SWAP        va, vb
+%endif
+    mova        m4, va
+    unpcklps    va, vb ; va3 vb3 va4 vb4
+    unpckhps    m4, vb ; va1 vb1 va2 vb2
+    addps       m4, va ; va1+3 vb1+3 va2+4 vb2+4
+    movhlps     vb, m4 ; va1+3  vb1+3
+    addps       vb, m4 ; va0..4 vb0..4
+    movh    [outq + count], vb
+%if %1
+    sub       cf0q, 8*NUM_COEF
+%endif
+    add      count, 8
+    jl   .loop%1
+%endmacro
+
+; void dca_lfe_fir(float *out, float *in, float *coefs)
+%macro DCA_LFE_FIR 1
+cglobal dca_lfe_fir%1, 3,3,6-%1, out, in, cf0
+%define IN1       m3
+%define IN2       m5
+%define count     inq
+%define NUM_COEF  4*(2-%1)
+%define NUM_OUT   32*(%1+1)
+
+    movu     IN1, [inq + 4 - 1*mmsize]
+    shufps   IN1, IN1, q0123
+%if %1 == 0
+    movu     IN2, [inq + 4 - 2*mmsize]
+    shufps   IN2, IN2, q0123
+%endif
+
+    mov    count, -4*NUM_OUT
+    add     cf0q, 4*NUM_COEF*NUM_OUT
+    add     outq, 4*NUM_OUT
+    ; compute v0 first
+%if %1 == 0
+    FIR_LOOP   0, IN1, IN2
+%else
+    FIR_LOOP   0, IN1
+%endif
+    shufps   IN1, IN1, q0123
+    mov    count, -4*NUM_OUT
+    ; cf1 already correctly positioned
+    add     outq, 4*NUM_OUT          ; outq now at out2
+    sub     cf0q, 8*NUM_COEF
+%if %1 == 0
+    shufps   IN2, IN2, q0123
+    FIR_LOOP   1, IN2, IN1
+%else
+    FIR_LOOP   1, IN1
+%endif
+    RET
+%endmacro
+
+INIT_XMM sse
+DCA_LFE_FIR 0
+DCA_LFE_FIR 1
+
+INIT_XMM sse2
+%macro INNER_LOOP   1
+    ; reading backwards:  ptr1 = synth_buf + j + i; ptr2 = synth_buf + j - i
+    ;~ a += window[i + j]      * (-synth_buf[15 - i + j])
+    ;~ b += window[i + j + 16] * (synth_buf[i + j])
+    pshufd        m5, [ptr2 + j + (15 - 3) * 4], q0123
+    mova          m6, [ptr1 + j]
+%if ARCH_X86_64
+    pshufd       m11, [ptr2 + j + (15 - 3) * 4 - mmsize], q0123
+    mova         m12, [ptr1 + j + mmsize]
+%endif
+    mulps         m6, [win  + %1 + j + 16 * 4]
+    mulps         m5, [win  + %1 + j]
+%if ARCH_X86_64
+    mulps        m12, [win  + %1 + j + mmsize + 16 * 4]
+    mulps        m11, [win  + %1 + j + mmsize]
+%endif
+    addps         m2, m6
+    subps         m1, m5
+%if ARCH_X86_64
+    addps         m8, m12
+    subps         m7, m11
+%endif
+    ;~ c += window[i + j + 32] * (synth_buf[16 + i + j])
+    ;~ d += window[i + j + 48] * (synth_buf[31 - i + j])
+    pshufd        m6, [ptr2 + j + (31 - 3) * 4], q0123
+    mova          m5, [ptr1 + j + 16 * 4]
+%if ARCH_X86_64
+    pshufd       m12, [ptr2 + j + (31 - 3) * 4 - mmsize], q0123
+    mova         m11, [ptr1 + j + mmsize + 16 * 4]
+%endif
+    mulps         m5, [win  + %1 + j + 32 * 4]
+    mulps         m6, [win  + %1 + j + 48 * 4]
+%if ARCH_X86_64
+    mulps        m11, [win  + %1 + j + mmsize + 32 * 4]
+    mulps        m12, [win  + %1 + j + mmsize + 48 * 4]
+%endif
+    addps         m3, m5
+    addps         m4, m6
+%if ARCH_X86_64
+    addps         m9, m11
+    addps        m10, m12
+%endif
+    sub            j, 64 * 4
+%endmacro
+
+; void ff_synth_filter_inner_sse2(float *synth_buf, float synth_buf2[32],
+;                                 const float window[512], float out[32],
+;                                 intptr_t offset, float scale)
+cglobal synth_filter_inner, 0, 6 + 4 * ARCH_X86_64, 7 + 6 * ARCH_X86_64, \
+                              synth_buf, synth_buf2, window, out, off, scale
+%define scale m0
+%if ARCH_X86_32 || WIN64
+    movd       scale, scalem
+; Make sure offset is in a register and not on the stack
+%define OFFQ  r4q
+%else
+%define OFFQ  offq
+%endif
+    pshufd        m0, m0, 0
+    ; prepare inner counter limit 1
+    mov          r5q, 480
+    sub          r5q, offmp
+    and          r5q, -64
+    shl          r5q, 2
+    mov         OFFQ, r5q
+%define i        r5q
+    mov            i, 16 * 4 - (ARCH_X86_64 + 1) * mmsize  ; main loop counter
+
+%define buf2     synth_buf2q
+%if ARCH_X86_32
+    mov         buf2, synth_buf2mp
+%endif
+.mainloop
+    ; m1 = a  m2 = b  m3 = c  m4 = d
+    pxor          m3, m3
+    pxor          m4, m4
+    mova          m1, [buf2 + i]
+    mova          m2, [buf2 + i + 16 * 4]
+%if ARCH_X86_32
+%define ptr1     r0q
+%define ptr2     r1q
+%define win      r2q
+%define j        r3q
+    mov          win, windowm
+    mov         ptr1, synth_bufm
+    add          win, i
+    add         ptr1, i
+%else ; ARCH_X86_64
+%define ptr1     r6q
+%define ptr2     r7q ; must be loaded
+%define win      r8q
+%define j        r9q
+    pxor          m9, m9
+    pxor         m10, m10
+    mova          m7, [buf2 + i + mmsize]
+    mova          m8, [buf2 + i + mmsize + 16 * 4]
+    lea          win, [windowq + i]
+    lea         ptr1, [synth_bufq + i]
+%endif
+    mov         ptr2, synth_bufmp
+    ; prepare the inner loop counter
+    mov            j, OFFQ
+    sub         ptr2, i
+.loop1:
+    INNER_LOOP  0
+    jge       .loop1
+
+    mov            j, 448 * 4
+    sub            j, OFFQ
+    jz          .end
+    sub         ptr1, j
+    sub         ptr2, j
+    add          win, OFFQ ; now at j-64, so define OFFSET
+    sub            j, 64 * 4
+.loop2:
+    INNER_LOOP  64 * 4
+    jge       .loop2
+
+.end:
+%if ARCH_X86_32
+    mov         buf2, synth_buf2m ; needed for next iteration anyway
+    mov         outq, outmp       ; j, which will be set again during it
+%endif
+    ;~ out[i]      = a * scale;
+    ;~ out[i + 16] = b * scale;
+    mulps         m1, scale
+    mulps         m2, scale
+%if ARCH_X86_64
+    mulps         m7, scale
+    mulps         m8, scale
+%endif
+    ;~ synth_buf2[i]      = c;
+    ;~ synth_buf2[i + 16] = d;
+    mova   [buf2 + i +  0 * 4], m3
+    mova   [buf2 + i + 16 * 4], m4
+%if ARCH_X86_64
+    mova   [buf2 + i +  0 * 4 + mmsize], m9
+    mova   [buf2 + i + 16 * 4 + mmsize], m10
+%endif
+    ;~ out[i]      = a;
+    ;~ out[i + 16] = a;
+    mova   [outq + i +  0 * 4], m1
+    mova   [outq + i + 16 * 4], m2
+%if ARCH_X86_64
+    mova   [outq + i +  0 * 4 + mmsize], m7
+    mova   [outq + i + 16 * 4 + mmsize], m8
+%endif
+    sub            i, (ARCH_X86_64 + 1) * mmsize
+    jge    .mainloop
+    RET
diff --git a/deps/libav/libavcodec/x86/dcadsp_init.c b/deps/libav/libavcodec/x86/dcadsp_init.c
index 976d8a3..65e3db5 100644
--- a/deps/libav/libavcodec/x86/dcadsp_init.c
+++ b/deps/libav/libavcodec/x86/dcadsp_init.c
@@ -23,9 +23,17 @@
 #include "libavutil/x86/cpu.h"
 #include "libavcodec/dcadsp.h"
 
-void ff_int8x8_fmul_int32_sse(float *dst, const int8_t *src, int scale);
-void ff_int8x8_fmul_int32_sse2(float *dst, const int8_t *src, int scale);
-void ff_int8x8_fmul_int32_sse4(float *dst, const int8_t *src, int scale);
+void ff_decode_hf_sse(float dst[DCA_SUBBANDS][8], const int vq_num[DCA_SUBBANDS],
+                      const int8_t hf_vq[1024][32], intptr_t vq_offset,
+                      int scale[DCA_SUBBANDS][2], intptr_t start, intptr_t end);
+void ff_decode_hf_sse2(float dst[DCA_SUBBANDS][8], const int vq_num[DCA_SUBBANDS],
+                       const int8_t hf_vq[1024][32], intptr_t vq_offset,
+                       int scale[DCA_SUBBANDS][2], intptr_t start, intptr_t end);
+void ff_decode_hf_sse4(float dst[DCA_SUBBANDS][8], const int vq_num[DCA_SUBBANDS],
+                       const int8_t hf_vq[1024][32], intptr_t vq_offset,
+                       int scale[DCA_SUBBANDS][2], intptr_t start, intptr_t end);
+void ff_dca_lfe_fir0_sse(float *out, const float *in, const float *coefs);
+void ff_dca_lfe_fir1_sse(float *out, const float *in, const float *coefs);
 
 av_cold void ff_dcadsp_init_x86(DCADSPContext *s)
 {
@@ -33,15 +41,49 @@ av_cold void ff_dcadsp_init_x86(DCADSPContext *s)
 
     if (EXTERNAL_SSE(cpu_flags)) {
 #if ARCH_X86_32
-        s->int8x8_fmul_int32 = ff_int8x8_fmul_int32_sse;
+        s->decode_hf = ff_decode_hf_sse;
 #endif
+        s->lfe_fir[0]        = ff_dca_lfe_fir0_sse;
+        s->lfe_fir[1]        = ff_dca_lfe_fir1_sse;
     }
 
     if (EXTERNAL_SSE2(cpu_flags)) {
-        s->int8x8_fmul_int32 = ff_int8x8_fmul_int32_sse2;
+        s->decode_hf = ff_decode_hf_sse2;
     }
 
     if (EXTERNAL_SSE4(cpu_flags)) {
-        s->int8x8_fmul_int32 = ff_int8x8_fmul_int32_sse4;
+        s->decode_hf = ff_decode_hf_sse4;
     }
 }
+
+void ff_synth_filter_inner_sse2(float *synth_buf_ptr, float synth_buf2[32],
+                                const float window[512],
+                                float out[32], intptr_t offset, float scale);
+
+#if HAVE_YASM
+static void synth_filter_sse2(FFTContext *imdct,
+                              float *synth_buf_ptr, int *synth_buf_offset,
+                              float synth_buf2[32], const float window[512],
+                              float out[32], const float in[32], float scale)
+{
+    float *synth_buf= synth_buf_ptr + *synth_buf_offset;
+
+    imdct->imdct_half(imdct, synth_buf, in);
+
+    ff_synth_filter_inner_sse2(synth_buf, synth_buf2, window,
+                               out, *synth_buf_offset, scale);
+
+    *synth_buf_offset = (*synth_buf_offset - 32) & 511;
+}
+#endif /* HAVE_YASM */
+
+av_cold void ff_synth_filter_init_x86(SynthFilterContext *s)
+{
+#if HAVE_YASM
+    int cpu_flags = av_get_cpu_flags();
+
+    if (EXTERNAL_SSE2(cpu_flags)) {
+        s->synth_filter_float = synth_filter_sse2;
+    }
+#endif /* HAVE_YASM */
+}
diff --git a/deps/libav/libavcodec/x86/deinterlace.asm b/deps/libav/libavcodec/x86/deinterlace.asm
index b2828f3..70d000e 100644
--- a/deps/libav/libavcodec/x86/deinterlace.asm
+++ b/deps/libav/libavcodec/x86/deinterlace.asm
@@ -1,5 +1,5 @@
 ;******************************************************************************
-;* MMX optimized deinterlacing functions
+;* SIMD-optimized deinterlacing functions
 ;* Copyright (c) 2010 Vitor Sessak
 ;* Copyright (c) 2002 Michael Niedermayer
 ;*
diff --git a/deps/libav/libavcodec/x86/dsputil.asm b/deps/libav/libavcodec/x86/dsputil.asm
index 5d73ff8..414d212 100644
--- a/deps/libav/libavcodec/x86/dsputil.asm
+++ b/deps/libav/libavcodec/x86/dsputil.asm
@@ -34,7 +34,7 @@ pb_bswap32: db 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12
 SECTION_TEXT
 
 %macro SCALARPRODUCT 0
-; int scalarproduct_int16(int16_t *v1, int16_t *v2, int order)
+; int ff_scalarproduct_int16(int16_t *v1, int16_t *v2, int order)
 cglobal scalarproduct_int16, 3,3,3, v1, v2, order
     shl orderq, 1
     add v1q, orderq
@@ -61,7 +61,8 @@ cglobal scalarproduct_int16, 3,3,3, v1, v2, order
     movd   eax, m2
     RET
 
-; int scalarproduct_and_madd_int16(int16_t *v1, int16_t *v2, int16_t *v3, int order, int mul)
+; int ff_scalarproduct_and_madd_int16(int16_t *v1, int16_t *v2, int16_t *v3,
+;                                     int order, int mul)
 cglobal scalarproduct_and_madd_int16, 4,4,8, v1, v2, v3, order, mul
     shl orderq, 1
     movd    m7, mulm
@@ -157,7 +158,8 @@ align 16
 %endif
 %endmacro
 
-; int scalarproduct_and_madd_int16(int16_t *v1, int16_t *v2, int16_t *v3, int order, int mul)
+; int ff_scalarproduct_and_madd_int16(int16_t *v1, int16_t *v2, int16_t *v3,
+;                                     int order, int mul)
 INIT_XMM ssse3
 cglobal scalarproduct_and_madd_int16, 4,5,10, v1, v2, v3, order, mul
     shl orderq, 1
@@ -331,7 +333,9 @@ INIT_XMM ssse3, atom
 APPLY_WINDOW_INT16 1
 
 
-; void add_hfyu_median_prediction_mmxext(uint8_t *dst, const uint8_t *top, const uint8_t *diff, int w, int *left, int *left_top)
+; void ff_add_hfyu_median_prediction_mmxext(uint8_t *dst, const uint8_t *top,
+;                                           const uint8_t *diff, int w,
+;                                           int *left, int *left_top)
 INIT_MMX mmxext
 cglobal add_hfyu_median_prediction, 6,6,0, dst, top, diff, w, left, left_top
     movq    mm0, [topq]
@@ -434,7 +438,8 @@ cglobal add_hfyu_median_prediction, 6,6,0, dst, top, diff, w, left, left_top
     RET
 %endmacro
 
-; int add_hfyu_left_prediction(uint8_t *dst, const uint8_t *src, int w, int left)
+; int ff_add_hfyu_left_prediction(uint8_t *dst, const uint8_t *src,
+;                                 int w, int left)
 INIT_MMX ssse3
 cglobal add_hfyu_left_prediction, 3,3,7, dst, src, w, left
 .skip_prologue:
@@ -595,7 +600,7 @@ VECTOR_CLIP_INT32 6, 1, 0, 0
     add      r0, 16
 %endmacro
 
-; void bswap_buf(uint32_t *dst, const uint32_t *src, int w);
+; void ff_bswap_buf(uint32_t *dst, const uint32_t *src, int w);
 %macro BSWAP32_BUF 0
 %if cpuflag(ssse3)
 cglobal bswap32_buf, 3,4,3
diff --git a/deps/libav/libavcodec/x86/dsputil_init.c b/deps/libav/libavcodec/x86/dsputil_init.c
index 82864e8..00f89b2 100644
--- a/deps/libav/libavcodec/x86/dsputil_init.c
+++ b/deps/libav/libavcodec/x86/dsputil_init.c
@@ -22,6 +22,7 @@
 #include "libavutil/internal.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
+#include "libavcodec/avcodec.h"
 #include "libavcodec/dsputil.h"
 #include "libavcodec/simple_idct.h"
 #include "libavcodec/version.h"
@@ -42,29 +43,29 @@ void ff_avg_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
 void ff_put_no_rnd_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
                                       int dstStride, int src1Stride, int h);
 void ff_put_mpeg4_qpel16_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                         int dstStride, int srcStride, int h);
+                                          int dstStride, int srcStride, int h);
 void ff_avg_mpeg4_qpel16_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                         int dstStride, int srcStride, int h);
+                                          int dstStride, int srcStride, int h);
 void ff_put_no_rnd_mpeg4_qpel16_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
                                                  int dstStride, int srcStride,
                                                  int h);
 void ff_put_mpeg4_qpel8_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                        int dstStride, int srcStride, int h);
+                                         int dstStride, int srcStride, int h);
 void ff_avg_mpeg4_qpel8_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                        int dstStride, int srcStride, int h);
+                                         int dstStride, int srcStride, int h);
 void ff_put_no_rnd_mpeg4_qpel8_h_lowpass_mmxext(uint8_t *dst, uint8_t *src,
                                                 int dstStride, int srcStride,
                                                 int h);
 void ff_put_mpeg4_qpel16_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                         int dstStride, int srcStride);
+                                          int dstStride, int srcStride);
 void ff_avg_mpeg4_qpel16_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                         int dstStride, int srcStride);
+                                          int dstStride, int srcStride);
 void ff_put_no_rnd_mpeg4_qpel16_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
                                                  int dstStride, int srcStride);
 void ff_put_mpeg4_qpel8_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                        int dstStride, int srcStride);
+                                         int dstStride, int srcStride);
 void ff_avg_mpeg4_qpel8_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
-                                        int dstStride, int srcStride);
+                                         int dstStride, int srcStride);
 void ff_put_no_rnd_mpeg4_qpel8_v_lowpass_mmxext(uint8_t *dst, uint8_t *src,
                                                 int dstStride, int srcStride);
 #define ff_put_no_rnd_pixels16_mmxext ff_put_pixels16_mmxext
@@ -90,19 +91,19 @@ void ff_bswap32_buf_sse2(uint32_t *dst, const uint32_t *src, int w);
 void ff_add_hfyu_median_prediction_mmxext(uint8_t *dst, const uint8_t *top,
                                           const uint8_t *diff, int w,
                                           int *left, int *left_top);
-int  ff_add_hfyu_left_prediction_ssse3(uint8_t *dst, const uint8_t *src,
-                                       int w, int left);
-int  ff_add_hfyu_left_prediction_sse4(uint8_t *dst, const uint8_t *src,
+int ff_add_hfyu_left_prediction_ssse3(uint8_t *dst, const uint8_t *src,
                                       int w, int left);
+int ff_add_hfyu_left_prediction_sse4(uint8_t *dst, const uint8_t *src,
+                                     int w, int left);
 
-void ff_vector_clip_int32_mmx     (int32_t *dst, const int32_t *src,
-                                   int32_t min, int32_t max, unsigned int len);
-void ff_vector_clip_int32_sse2    (int32_t *dst, const int32_t *src,
-                                   int32_t min, int32_t max, unsigned int len);
+void ff_vector_clip_int32_mmx(int32_t *dst, const int32_t *src,
+                              int32_t min, int32_t max, unsigned int len);
+void ff_vector_clip_int32_sse2(int32_t *dst, const int32_t *src,
+                               int32_t min, int32_t max, unsigned int len);
 void ff_vector_clip_int32_int_sse2(int32_t *dst, const int32_t *src,
                                    int32_t min, int32_t max, unsigned int len);
-void ff_vector_clip_int32_sse4    (int32_t *dst, const int32_t *src,
-                                   int32_t min, int32_t max, unsigned int len);
+void ff_vector_clip_int32_sse4(int32_t *dst, const int32_t *src,
+                               int32_t min, int32_t max, unsigned int len);
 
 #if HAVE_YASM
 
@@ -110,8 +111,8 @@ PIXELS16(static, ff_avg, , , _mmxext)
 PIXELS16(static, ff_put, , , _mmxext)
 
 #define QPEL_OP(OPNAME, RND, MMX)                                       \
-static void OPNAME ## qpel8_mc00_ ## MMX (uint8_t *dst, uint8_t *src,   \
-                                          ptrdiff_t stride)             \
+static void OPNAME ## qpel8_mc00_ ## MMX(uint8_t *dst, uint8_t *src,    \
+                                         ptrdiff_t stride)              \
 {                                                                       \
     ff_ ## OPNAME ## pixels8_ ## MMX(dst, src, stride, 8);              \
 }                                                                       \
@@ -120,7 +121,7 @@ static void OPNAME ## qpel8_mc10_ ## MMX(uint8_t *dst, uint8_t *src,    \
                                          ptrdiff_t stride)              \
 {                                                                       \
     uint64_t temp[8];                                                   \
-    uint8_t * const half = (uint8_t*)temp;                              \
+    uint8_t *const half = (uint8_t *) temp;                             \
     ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(half, src, 8,        \
                                                    stride, 8);          \
     ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, src, half,                 \
@@ -138,7 +139,7 @@ static void OPNAME ## qpel8_mc30_ ## MMX(uint8_t *dst, uint8_t *src,    \
                                          ptrdiff_t stride)              \
 {                                                                       \
     uint64_t temp[8];                                                   \
-    uint8_t * const half = (uint8_t*)temp;                              \
+    uint8_t *const half = (uint8_t *) temp;                             \
     ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(half, src, 8,        \
                                                    stride, 8);          \
     ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, src + 1, half, stride,     \
@@ -149,7 +150,7 @@ static void OPNAME ## qpel8_mc01_ ## MMX(uint8_t *dst, uint8_t *src,    \
                                          ptrdiff_t stride)              \
 {                                                                       \
     uint64_t temp[8];                                                   \
-    uint8_t * const half = (uint8_t*)temp;                              \
+    uint8_t *const half = (uint8_t *) temp;                             \
     ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(half, src,           \
                                                    8, stride);          \
     ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, src, half,                 \
@@ -167,7 +168,7 @@ static void OPNAME ## qpel8_mc03_ ## MMX(uint8_t *dst, uint8_t *src,    \
                                          ptrdiff_t stride)              \
 {                                                                       \
     uint64_t temp[8];                                                   \
-    uint8_t * const half = (uint8_t*)temp;                              \
+    uint8_t *const half = (uint8_t *) temp;                             \
     ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(half, src,           \
                                                    8, stride);          \
     ff_ ## OPNAME ## pixels8_l2_ ## MMX(dst, src + stride, half, stride,\
@@ -178,8 +179,8 @@ static void OPNAME ## qpel8_mc11_ ## MMX(uint8_t *dst, uint8_t *src,    \
                                          ptrdiff_t stride)              \
 {                                                                       \
     uint64_t half[8 + 9];                                               \
-    uint8_t * const halfH  = ((uint8_t*)half) + 64;                     \
-    uint8_t * const halfHV = ((uint8_t*)half);                          \
+    uint8_t *const halfH  = (uint8_t *) half + 64;                      \
+    uint8_t *const halfHV = (uint8_t *) half;                           \
     ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8,       \
                                                    stride, 9);          \
     ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, 8,           \
@@ -193,8 +194,8 @@ static void OPNAME ## qpel8_mc31_ ## MMX(uint8_t *dst, uint8_t *src,    \
                                          ptrdiff_t stride)              \
 {                                                                       \
     uint64_t half[8 + 9];                                               \
-    uint8_t * const halfH  = ((uint8_t*)half) + 64;                     \
-    uint8_t * const halfHV = ((uint8_t*)half);                          \
+    uint8_t *const halfH  = (uint8_t *) half + 64;                      \
+    uint8_t *const halfHV = (uint8_t *) half;                           \
     ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8,       \
                                                    stride, 9);          \
     ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src + 1, halfH, 8,       \
@@ -208,8 +209,8 @@ static void OPNAME ## qpel8_mc13_ ## MMX(uint8_t *dst, uint8_t *src,    \
                                          ptrdiff_t stride)              \
 {                                                                       \
     uint64_t half[8 + 9];                                               \
-    uint8_t * const halfH  = ((uint8_t*)half) + 64;                     \
-    uint8_t * const halfHV = ((uint8_t*)half);                          \
+    uint8_t *const halfH  = (uint8_t *) half + 64;                      \
+    uint8_t *const halfHV = (uint8_t *) half;                           \
     ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8,       \
                                                    stride, 9);          \
     ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH, 8,           \
@@ -223,8 +224,8 @@ static void OPNAME ## qpel8_mc33_ ## MMX(uint8_t *dst, uint8_t *src,    \
                                          ptrdiff_t stride)              \
 {                                                                       \
     uint64_t half[8 + 9];                                               \
-    uint8_t * const halfH  = ((uint8_t*)half) + 64;                     \
-    uint8_t * const halfHV = ((uint8_t*)half);                          \
+    uint8_t *const halfH  = (uint8_t *) half + 64;                      \
+    uint8_t *const halfHV = (uint8_t *) half;                           \
     ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8,       \
                                                    stride, 9);          \
     ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src + 1, halfH, 8,       \
@@ -238,8 +239,8 @@ static void OPNAME ## qpel8_mc21_ ## MMX(uint8_t *dst, uint8_t *src,    \
                                          ptrdiff_t stride)              \
 {                                                                       \
     uint64_t half[8 + 9];                                               \
-    uint8_t * const halfH  = ((uint8_t*)half) + 64;                     \
-    uint8_t * const halfHV = ((uint8_t*)half);                          \
+    uint8_t *const halfH  = (uint8_t *) half + 64;                      \
+    uint8_t *const halfHV = (uint8_t *) half;                           \
     ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8,       \
                                                    stride, 9);          \
     ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
@@ -251,8 +252,8 @@ static void OPNAME ## qpel8_mc23_ ## MMX(uint8_t *dst, uint8_t *src,    \
                                          ptrdiff_t stride)              \
 {                                                                       \
     uint64_t half[8 + 9];                                               \
-    uint8_t * const halfH  = ((uint8_t*)half) + 64;                     \
-    uint8_t * const halfHV = ((uint8_t*)half);                          \
+    uint8_t *const halfH  = (uint8_t *) half + 64;                      \
+    uint8_t *const halfHV = (uint8_t *) half;                           \
     ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8,       \
                                                    stride, 9);          \
     ff_put ## RND ## mpeg4_qpel8_v_lowpass_ ## MMX(halfHV, halfH, 8, 8);\
@@ -264,7 +265,7 @@ static void OPNAME ## qpel8_mc12_ ## MMX(uint8_t *dst, uint8_t *src,    \
                                          ptrdiff_t stride)              \
 {                                                                       \
     uint64_t half[8 + 9];                                               \
-    uint8_t * const halfH = ((uint8_t*)half);                           \
+    uint8_t *const halfH = (uint8_t *) half;                            \
     ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8,       \
                                                    stride, 9);          \
     ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src, halfH,              \
@@ -277,7 +278,7 @@ static void OPNAME ## qpel8_mc32_ ## MMX(uint8_t *dst, uint8_t *src,    \
                                          ptrdiff_t stride)              \
 {                                                                       \
     uint64_t half[8 + 9];                                               \
-    uint8_t * const halfH = ((uint8_t*)half);                           \
+    uint8_t *const halfH = (uint8_t *) half;                            \
     ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8,       \
                                                    stride, 9);          \
     ff_put ## RND ## pixels8_l2_ ## MMX(halfH, src + 1, halfH, 8,       \
@@ -290,15 +291,15 @@ static void OPNAME ## qpel8_mc22_ ## MMX(uint8_t *dst, uint8_t *src,    \
                                          ptrdiff_t stride)              \
 {                                                                       \
     uint64_t half[9];                                                   \
-    uint8_t * const halfH = ((uint8_t*)half);                           \
+    uint8_t *const halfH = (uint8_t *) half;                            \
     ff_put ## RND ## mpeg4_qpel8_h_lowpass_ ## MMX(halfH, src, 8,       \
                                                    stride, 9);          \
     ff_ ## OPNAME ## mpeg4_qpel8_v_lowpass_ ## MMX(dst, halfH,          \
                                                    stride, 8);          \
 }                                                                       \
                                                                         \
-static void OPNAME ## qpel16_mc00_ ## MMX (uint8_t *dst, uint8_t *src,  \
-                                           ptrdiff_t stride)            \
+static void OPNAME ## qpel16_mc00_ ## MMX(uint8_t *dst, uint8_t *src,   \
+                                          ptrdiff_t stride)             \
 {                                                                       \
     ff_ ## OPNAME ## pixels16_ ## MMX(dst, src, stride, 16);            \
 }                                                                       \
@@ -307,7 +308,7 @@ static void OPNAME ## qpel16_mc10_ ## MMX(uint8_t *dst, uint8_t *src,   \
                                           ptrdiff_t stride)             \
 {                                                                       \
     uint64_t temp[32];                                                  \
-    uint8_t * const half = (uint8_t*)temp;                              \
+    uint8_t *const half = (uint8_t *) temp;                             \
     ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(half, src, 16,      \
                                                     stride, 16);        \
     ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, src, half, stride,        \
@@ -325,7 +326,7 @@ static void OPNAME ## qpel16_mc30_ ## MMX(uint8_t *dst, uint8_t *src,   \
                                           ptrdiff_t stride)             \
 {                                                                       \
     uint64_t temp[32];                                                  \
-    uint8_t * const half = (uint8_t*)temp;                              \
+    uint8_t *const half = (uint8_t*) temp;                              \
     ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(half, src, 16,      \
                                                     stride, 16);        \
     ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, src + 1, half,            \
@@ -336,7 +337,7 @@ static void OPNAME ## qpel16_mc01_ ## MMX(uint8_t *dst, uint8_t *src,   \
                                           ptrdiff_t stride)             \
 {                                                                       \
     uint64_t temp[32];                                                  \
-    uint8_t * const half = (uint8_t*)temp;                              \
+    uint8_t *const half = (uint8_t *) temp;                             \
     ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(half, src, 16,      \
                                                     stride);            \
     ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, src, half, stride,        \
@@ -354,7 +355,7 @@ static void OPNAME ## qpel16_mc03_ ## MMX(uint8_t *dst, uint8_t *src,   \
                                           ptrdiff_t stride)             \
 {                                                                       \
     uint64_t temp[32];                                                  \
-    uint8_t * const half = (uint8_t*)temp;                              \
+    uint8_t *const half = (uint8_t *) temp;                             \
     ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(half, src, 16,      \
                                                     stride);            \
     ff_ ## OPNAME ## pixels16_l2_ ## MMX(dst, src+stride, half,         \
@@ -365,8 +366,8 @@ static void OPNAME ## qpel16_mc11_ ## MMX(uint8_t *dst, uint8_t *src,   \
                                           ptrdiff_t stride)             \
 {                                                                       \
     uint64_t half[16 * 2 + 17 * 2];                                     \
-    uint8_t * const halfH  = ((uint8_t*)half) + 256;                    \
-    uint8_t * const halfHV = ((uint8_t*)half);                          \
+    uint8_t *const halfH  = (uint8_t *) half + 256;                     \
+    uint8_t *const halfHV = (uint8_t *) half;                           \
     ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16,     \
                                                     stride, 17);        \
     ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src, halfH, 16,         \
@@ -381,8 +382,8 @@ static void OPNAME ## qpel16_mc31_ ## MMX(uint8_t *dst, uint8_t *src,   \
                                           ptrdiff_t stride)             \
 {                                                                       \
     uint64_t half[16 * 2 + 17 * 2];                                     \
-    uint8_t * const halfH  = ((uint8_t*)half) + 256;                    \
-    uint8_t * const halfHV = ((uint8_t*)half);                          \
+    uint8_t *const halfH  = (uint8_t *) half + 256;                     \
+    uint8_t *const halfHV = (uint8_t *) half;                           \
     ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16,     \
                                                     stride, 17);        \
     ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src + 1, halfH, 16,     \
@@ -397,8 +398,8 @@ static void OPNAME ## qpel16_mc13_ ## MMX(uint8_t *dst, uint8_t *src,   \
                                           ptrdiff_t stride)             \
 {                                                                       \
     uint64_t half[16 * 2 + 17 * 2];                                     \
-    uint8_t * const halfH  = ((uint8_t*)half) + 256;                    \
-    uint8_t * const halfHV = ((uint8_t*)half);                          \
+    uint8_t *const halfH  = (uint8_t *) half + 256;                     \
+    uint8_t *const halfHV = (uint8_t *) half;                           \
     ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16,     \
                                                     stride, 17);        \
     ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src, halfH, 16,         \
@@ -413,8 +414,8 @@ static void OPNAME ## qpel16_mc33_ ## MMX(uint8_t *dst, uint8_t *src,   \
                                           ptrdiff_t stride)             \
 {                                                                       \
     uint64_t half[16 * 2 + 17 * 2];                                     \
-    uint8_t * const halfH  = ((uint8_t*)half) + 256;                    \
-    uint8_t * const halfHV = ((uint8_t*)half);                          \
+    uint8_t *const halfH  = (uint8_t *) half + 256;                     \
+    uint8_t *const halfHV = (uint8_t *) half;                           \
     ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16,     \
                                                     stride, 17);        \
     ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src + 1, halfH, 16,     \
@@ -429,8 +430,8 @@ static void OPNAME ## qpel16_mc21_ ## MMX(uint8_t *dst, uint8_t *src,   \
                                           ptrdiff_t stride)             \
 {                                                                       \
     uint64_t half[16 * 2 + 17 * 2];                                     \
-    uint8_t * const halfH  = ((uint8_t*)half) + 256;                    \
-    uint8_t * const halfHV = ((uint8_t*)half);                          \
+    uint8_t *const halfH  = (uint8_t *) half + 256;                     \
+    uint8_t *const halfHV = (uint8_t *) half;                           \
     ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16,     \
                                                     stride, 17);        \
     ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH,      \
@@ -443,8 +444,8 @@ static void OPNAME ## qpel16_mc23_ ## MMX(uint8_t *dst, uint8_t *src,   \
                                           ptrdiff_t stride)             \
 {                                                                       \
     uint64_t half[16 * 2 + 17 * 2];                                     \
-    uint8_t * const halfH  = ((uint8_t*)half) + 256;                    \
-    uint8_t * const halfHV = ((uint8_t*)half);                          \
+    uint8_t *const halfH  = (uint8_t *) half + 256;                     \
+    uint8_t *const halfHV = (uint8_t *) half;                           \
     ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16,     \
                                                     stride, 17);        \
     ff_put ## RND ## mpeg4_qpel16_v_lowpass_ ## MMX(halfHV, halfH,      \
@@ -457,7 +458,7 @@ static void OPNAME ## qpel16_mc12_ ## MMX(uint8_t *dst, uint8_t *src,   \
                                           ptrdiff_t stride)             \
 {                                                                       \
     uint64_t half[17 * 2];                                              \
-    uint8_t * const halfH = ((uint8_t*)half);                           \
+    uint8_t *const halfH = (uint8_t *) half;                            \
     ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16,     \
                                                     stride, 17);        \
     ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src, halfH, 16,         \
@@ -470,7 +471,7 @@ static void OPNAME ## qpel16_mc32_ ## MMX(uint8_t *dst, uint8_t *src,   \
                                           ptrdiff_t stride)             \
 {                                                                       \
     uint64_t half[17 * 2];                                              \
-    uint8_t * const halfH = ((uint8_t*)half);                           \
+    uint8_t *const halfH = (uint8_t *) half;                            \
     ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16,     \
                                                     stride, 17);        \
     ff_put ## RND ## pixels16_l2_ ## MMX(halfH, src + 1, halfH, 16,     \
@@ -483,7 +484,7 @@ static void OPNAME ## qpel16_mc22_ ## MMX(uint8_t *dst, uint8_t *src,   \
                                           ptrdiff_t stride)             \
 {                                                                       \
     uint64_t half[17 * 2];                                              \
-    uint8_t * const halfH = ((uint8_t*)half);                           \
+    uint8_t *const halfH = (uint8_t *) half;                            \
     ff_put ## RND ## mpeg4_qpel16_h_lowpass_ ## MMX(halfH, src, 16,     \
                                                     stride, 17);        \
     ff_ ## OPNAME ## mpeg4_qpel16_v_lowpass_ ## MMX(dst, halfH,         \
@@ -493,10 +494,11 @@ static void OPNAME ## qpel16_mc22_ ## MMX(uint8_t *dst, uint8_t *src,   \
 QPEL_OP(put_,        _,        mmxext)
 QPEL_OP(avg_,        _,        mmxext)
 QPEL_OP(put_no_rnd_, _no_rnd_, mmxext)
+
 #endif /* HAVE_YASM */
 
 #define SET_QPEL_FUNCS(PFX, IDX, SIZE, CPU, PREFIX)                          \
-    do {                                                                     \
+do {                                                                         \
     c->PFX ## _pixels_tab[IDX][ 0] = PREFIX ## PFX ## SIZE ## _mc00_ ## CPU; \
     c->PFX ## _pixels_tab[IDX][ 1] = PREFIX ## PFX ## SIZE ## _mc10_ ## CPU; \
     c->PFX ## _pixels_tab[IDX][ 2] = PREFIX ## PFX ## SIZE ## _mc20_ ## CPU; \
@@ -513,7 +515,7 @@ QPEL_OP(put_no_rnd_, _no_rnd_, mmxext)
     c->PFX ## _pixels_tab[IDX][13] = PREFIX ## PFX ## SIZE ## _mc13_ ## CPU; \
     c->PFX ## _pixels_tab[IDX][14] = PREFIX ## PFX ## SIZE ## _mc23_ ## CPU; \
     c->PFX ## _pixels_tab[IDX][15] = PREFIX ## PFX ## SIZE ## _mc33_ ## CPU; \
-    } while (0)
+} while (0)
 
 static av_cold void dsputil_init_mmx(DSPContext *c, AVCodecContext *avctx,
                                      int cpu_flags)
diff --git a/deps/libav/libavcodec/x86/dsputil_mmx.c b/deps/libav/libavcodec/x86/dsputil_mmx.c
index 885c10a..d6136f6 100644
--- a/deps/libav/libavcodec/x86/dsputil_mmx.c
+++ b/deps/libav/libavcodec/x86/dsputil_mmx.c
@@ -57,8 +57,8 @@ void ff_put_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
         "movq     %%mm2, (%0, %1)       \n\t"
         "movq     %%mm4, (%0, %1, 2)    \n\t"
         "movq     %%mm6, (%0, %2)       \n\t"
-        :: "r"(pix), "r"((x86_reg)line_size), "r"((x86_reg)line_size * 3),
-           "r"(p)
+        :: "r" (pix), "r" ((x86_reg) line_size), "r" ((x86_reg) line_size * 3),
+           "r" (p)
         : "memory");
     pix += line_size * 4;
     p   += 32;
@@ -83,7 +83,8 @@ void ff_put_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
         "movq      %%mm2, (%0, %1)      \n\t"
         "movq      %%mm4, (%0, %1, 2)   \n\t"
         "movq      %%mm6, (%0, %2)      \n\t"
-        :: "r"(pix), "r"((x86_reg)line_size), "r"((x86_reg)line_size * 3), "r"(p)
+        :: "r" (pix), "r" ((x86_reg) line_size), "r" ((x86_reg) line_size * 3),
+           "r" (p)
         : "memory");
 }
 
@@ -117,8 +118,8 @@ void ff_put_signed_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
         put_signed_pixels_clamped_mmx_half(0)
         "lea         (%0, %3, 4), %0        \n\t"
         put_signed_pixels_clamped_mmx_half(64)
-        : "+&r"(pixels), "=&r"(line_skip3)
-        : "r"(block), "r"(line_skip)
+        : "+&r" (pixels), "=&r" (line_skip3)
+        : "r" (block), "r" (line_skip)
         : "memory");
 }
 
@@ -156,8 +157,8 @@ void ff_add_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
             "packuswb   %%mm3, %%mm2    \n\t"
             "movq       %%mm0, %0       \n\t"
             "movq       %%mm2, %1       \n\t"
-            : "+m"(*pix), "+m"(*(pix + line_size))
-            : "r"(p)
+            : "+m" (*pix), "+m" (*(pix + line_size))
+            : "r" (p)
             : "memory");
         pix += line_size * 2;
         p   += 16;
@@ -177,10 +178,9 @@ void name(int16_t *blocks)                              \
         "movq %%mm7, 24(%0, %%"REG_a")  \n\t"           \
         "add    $32, %%"REG_a"          \n\t"           \
         "js      1b                     \n\t"           \
-        :: "r"(((uint8_t *)blocks) + 128 * n),          \
+        :: "r"(((uint8_t *) blocks) + 128 * n),         \
            "i"(-128 * n)                                \
-        : "%"REG_a                                      \
-        );                                              \
+        : "%"REG_a);                                    \
 }
 CLEAR_BLOCKS(ff_clear_blocks_mmx, 6)
 CLEAR_BLOCKS(ff_clear_block_mmx, 1)
@@ -197,9 +197,8 @@ void ff_clear_block_sse(int16_t *block)
         "movaps %%xmm0,  80(%0)         \n"
         "movaps %%xmm0,  96(%0)         \n"
         "movaps %%xmm0, 112(%0)         \n"
-        :: "r"(block)
-        : "memory"
-    );
+        :: "r" (block)
+        : "memory");
 }
 
 void ff_clear_blocks_sse(int16_t *blocks)
@@ -218,15 +217,14 @@ void ff_clear_blocks_sse(int16_t *blocks)
         "movaps %%xmm0, 112(%0, %%"REG_a")  \n"
         "add      $128,         %%"REG_a"   \n"
         "js         1b                      \n"
-        :: "r"(((uint8_t *)blocks) + 128 * 6),
-           "i"(-128 * 6)
-        : "%"REG_a
-    );
+        :: "r"(((uint8_t *) blocks) + 128 * 6), "i"(-128 * 6)
+        : "%"REG_a);
 }
 
 void ff_add_bytes_mmx(uint8_t *dst, uint8_t *src, int w)
 {
     x86_reg i = 0;
+
     __asm__ volatile (
         "jmp          2f                \n\t"
         "1:                             \n\t"
@@ -242,10 +240,10 @@ void ff_add_bytes_mmx(uint8_t *dst, uint8_t *src, int w)
         "2:                             \n\t"
         "cmp          %3, %0            \n\t"
         "js           1b                \n\t"
-        : "+r"(i)
-        : "r"(src), "r"(dst), "r"((x86_reg)w - 15)
-    );
-    for ( ; i < w; i++)
+        : "+r" (i)
+        : "r" (src), "r" (dst), "r" ((x86_reg) w - 15));
+
+    for (; i < w; i++)
         dst[i + 0] += src[i + 0];
 }
 
@@ -276,9 +274,9 @@ void ff_draw_edges_mmx(uint8_t *buf, int wrap, int width, int height,
             "add               %1, %0       \n\t"
             "cmp               %3, %0       \n\t"
             "jb                1b           \n\t"
-            : "+r"(ptr)
-            : "r"((x86_reg)wrap), "r"((x86_reg)width), "r"(ptr + wrap * height)
-            );
+            : "+r" (ptr)
+            : "r" ((x86_reg) wrap), "r" ((x86_reg) width),
+              "r" (ptr + wrap * height));
     } else {
         __asm__ volatile (
             "1:                                 \n\t"
@@ -297,9 +295,9 @@ void ff_draw_edges_mmx(uint8_t *buf, int wrap, int width, int height,
             "add               %1, %0           \n\t"
             "cmp               %3, %0           \n\t"
             "jb                1b               \n\t"
-            : "+r"(ptr)
-            : "r"((x86_reg)wrap), "r"((x86_reg)width), "r"(ptr + wrap * height)
-            );
+            : "+r" (ptr)
+            : "r" ((x86_reg) wrap), "r" ((x86_reg) width),
+              "r" (ptr + wrap * height));
     }
 
     /* top and bottom (and hopefully also the corners) */
@@ -316,10 +314,10 @@ void ff_draw_edges_mmx(uint8_t *buf, int wrap, int width, int height,
                 "add        $8, %0              \n\t"
                 "cmp        %4, %0              \n\t"
                 "jb         1b                  \n\t"
-                : "+r"(ptr)
-                : "r"((x86_reg)buf - (x86_reg)ptr - w), "r"((x86_reg) -wrap),
-                  "r"((x86_reg) -wrap * 3), "r"(ptr + width + 2 * w)
-                );
+                : "+r" (ptr)
+                : "r" ((x86_reg) buf - (x86_reg) ptr - w),
+                  "r" ((x86_reg) - wrap), "r" ((x86_reg) - wrap * 3),
+                  "r" (ptr + width + 2 * w));
         }
     }
 
@@ -336,11 +334,10 @@ void ff_draw_edges_mmx(uint8_t *buf, int wrap, int width, int height,
                 "add        $8, %0              \n\t"
                 "cmp        %4, %0              \n\t"
                 "jb         1b                  \n\t"
-                : "+r"(ptr)
-                : "r"((x86_reg)last_line - (x86_reg)ptr - w),
-                  "r"((x86_reg)wrap), "r"((x86_reg)wrap * 3),
-                  "r"(ptr + width + 2 * w)
-                );
+                : "+r" (ptr)
+                : "r" ((x86_reg) last_line - (x86_reg) ptr - w),
+                  "r" ((x86_reg) wrap), "r" ((x86_reg) wrap * 3),
+                  "r" (ptr + width + 2 * w));
         }
     }
 }
@@ -362,20 +359,21 @@ void ff_gmc_mmx(uint8_t *dst, uint8_t *src,
     const uint16_t r4[4]   = { r, r, r, r };
     const uint16_t dxy4[4] = { dxys, dxys, dxys, dxys };
     const uint16_t dyy4[4] = { dyys, dyys, dyys, dyys };
-    const uint64_t shift2 = 2 * shift;
+    const uint64_t shift2  = 2 * shift;
     int x, y;
 
     const int dxw = (dxx - (1 << (16 + shift))) * (w - 1);
     const int dyh = (dyy - (1 << (16 + shift))) * (h - 1);
     const int dxh = dxy * (h - 1);
     const int dyw = dyx * (w - 1);
+
     if ( // non-constant fullpel offset (3% of blocks)
         ((ox ^ (ox + dxw)) | (ox ^ (ox + dxh)) | (ox ^ (ox + dxw + dxh)) |
-         (oy ^ (oy + dyw)) | (oy ^ (oy + dyh)) | (oy ^ (oy + dyw + dyh))) >> (16 + shift)
+         (oy ^ (oy + dyw)) | (oy ^ (oy + dyh)) | (oy ^ (oy + dyw + dyh))) >> (16 + shift) ||
         // uses more than 16 bits of subpel mv (only at huge resolution)
-        || (dxx | dxy | dyx | dyy) & 15 ||
-        (unsigned)ix >= width  - w ||
-        (unsigned)iy >= height - h) {
+        (dxx | dxy | dyx | dyy) & 15 ||
+        (unsigned) ix >= width  - w ||
+        (unsigned) iy >= height - h) {
         // FIXME could still use mmx for some of the rows
         ff_gmc_c(dst, src, stride, h, ox, oy, dxx, dxy, dyx, dyy,
                  shift, r, width, height);
@@ -389,8 +387,7 @@ void ff_gmc_mmx(uint8_t *dst, uint8_t *src,
         "pxor      %%mm7, %%mm7         \n\t"
         "punpcklwd %%mm6, %%mm6         \n\t"
         "punpcklwd %%mm6, %%mm6         \n\t"
-        :: "r"(1<<shift)
-    );
+        :: "r" (1 << shift));
 
     for (x = 0; x < w; x += 4) {
         uint16_t dx4[4] = { oxs - dxys + dxxs * (x + 0),
@@ -412,9 +409,8 @@ void ff_gmc_mmx(uint8_t *dst, uint8_t *src,
                 "movq   %%mm5, %1       \n\t"
                 "psrlw    $12, %%mm4    \n\t"
                 "psrlw    $12, %%mm5    \n\t"
-                : "+m"(*dx4), "+m"(*dy4)
-                : "m"(*dxy4), "m"(*dyy4)
-            );
+                : "+m" (*dx4), "+m" (*dy4)
+                : "m" (*dxy4), "m" (*dyy4));
 
             __asm__ volatile (
                 "movq      %%mm6, %%mm2 \n\t"
@@ -450,11 +446,10 @@ void ff_gmc_mmx(uint8_t *dst, uint8_t *src,
                 "packuswb  %%mm0, %%mm0 \n\t"
                 "movd      %%mm0, %0    \n\t"
 
-                : "=m"(dst[x + y * stride])
-                : "m"(src[0]), "m"(src[1]),
-                  "m"(src[stride]), "m"(src[stride + 1]),
-                  "m"(*r4), "m"(shift2)
-            );
+                : "=m" (dst[x + y * stride])
+                : "m" (src[0]), "m" (src[1]),
+                  "m" (src[stride]), "m" (src[stride + 1]),
+                  "m" (*r4), "m" (shift2));
             src += stride;
         }
         src += 4 - h * stride;
@@ -489,10 +484,9 @@ void ff_vector_clipf_sse(float *dst, const float *src,
         "movaps     %%xmm3, 48(%1, %0)  \n\t"
         "sub           $64, %0          \n\t"
         "jge            1b              \n\t"
-        : "+&r"(i)
-        : "r"(dst), "r"(src), "m"(min), "m"(max)
-        : "memory"
-    );
+        : "+&r" (i)
+        : "r" (dst), "r" (src), "m" (min), "m" (max)
+        : "memory");
 }
 
 #endif /* HAVE_INLINE_ASM */
diff --git a/deps/libav/libavcodec/x86/dsputil_x86.h b/deps/libav/libavcodec/x86/dsputil_x86.h
index c8615b2..8f1fc17 100644
--- a/deps/libav/libavcodec/x86/dsputil_x86.h
+++ b/deps/libav/libavcodec/x86/dsputil_x86.h
@@ -19,12 +19,13 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#ifndef AVCODEC_X86_DSPUTIL_MMX_H
-#define AVCODEC_X86_DSPUTIL_MMX_H
+#ifndef AVCODEC_X86_DSPUTIL_X86_H
+#define AVCODEC_X86_DSPUTIL_X86_H
 
 #include <stddef.h>
 #include <stdint.h>
 
+#include "libavcodec/avcodec.h"
 #include "libavcodec/dsputil.h"
 #include "libavutil/x86/asm.h"
 #include "constants.h"
@@ -103,12 +104,15 @@
     "psubb "#regb", "#regr"             \n\t"                    \
     "psubb "#regd", "#regp"             \n\t"
 
-void ff_dsputilenc_init_mmx(DSPContext* c, AVCodecContext *avctx);
-void ff_dsputil_init_pix_mmx(DSPContext* c, AVCodecContext *avctx);
+void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx);
+void ff_dsputil_init_pix_mmx(DSPContext *c, AVCodecContext *avctx);
 
-void ff_add_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels, int line_size);
-void ff_put_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels, int line_size);
-void ff_put_signed_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels, int line_size);
+void ff_add_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
+                               int line_size);
+void ff_put_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
+                               int line_size);
+void ff_put_signed_pixels_clamped_mmx(const int16_t *block, uint8_t *pixels,
+                                      int line_size);
 
 void ff_clear_block_mmx(int16_t *block);
 void ff_clear_block_sse(int16_t *block);
@@ -180,10 +184,10 @@ STATIC void PFX1 ## _pixels16 ## TYPE ## CPUEXT(uint8_t *block,         \
                                                 ptrdiff_t line_size,    \
                                                 int h)                  \
 {                                                                       \
-    PFX2 ## PFX1 ## _pixels8 ## TYPE ## CPUEXT(block,      pixels,      \
+    PFX2 ## PFX1 ## _pixels8 ## TYPE ## CPUEXT(block, pixels,           \
                                                line_size, h);           \
-    PFX2 ## PFX1 ## _pixels8 ## TYPE ## CPUEXT(block + 8,  pixels + 8,  \
+    PFX2 ## PFX1 ## _pixels8 ## TYPE ## CPUEXT(block + 8, pixels + 8,   \
                                                line_size, h);           \
 }
 
-#endif /* AVCODEC_X86_DSPUTIL_MMX_H */
+#endif /* AVCODEC_X86_DSPUTIL_X86_H */
diff --git a/deps/libav/libavcodec/x86/dsputilenc.asm b/deps/libav/libavcodec/x86/dsputilenc.asm
index 7e4fd81..2790a88 100644
--- a/deps/libav/libavcodec/x86/dsputilenc.asm
+++ b/deps/libav/libavcodec/x86/dsputilenc.asm
@@ -209,8 +209,8 @@ hadamard8x8_diff %+ SUFFIX:
 hadamard8_16_wrapper %1, 3
 %elif cpuflag(mmx)
 ALIGN 16
-; int hadamard8_diff_##cpu(void *s, uint8_t *src1, uint8_t *src2,
-;                          int stride, int h)
+; int ff_hadamard8_diff_ ## cpu(void *s, uint8_t *src1, uint8_t *src2,
+;                               int stride, int h)
 ; r0 = void *s = unused, int h = unused (always 8)
 ; note how r1, r2 and r3 are not clobbered in this function, so 16x16
 ; can simply call this 2x2x (and that's why we access rsp+gprsize
@@ -275,7 +275,7 @@ INIT_XMM ssse3
 HADAMARD8_DIFF 9
 
 INIT_XMM sse2
-; sse16_sse2(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h)
+; int ff_sse16_sse2(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
 cglobal sse16, 5, 5, 8
     shr      r4d, 1
     pxor      m0, m0         ; mm0 = 0
@@ -335,7 +335,7 @@ cglobal sse16, 5, 5, 8
     RET
 
 INIT_MMX mmx
-; get_pixels_mmx(int16_t *block, const uint8_t *pixels, int line_size)
+; void ff_get_pixels_mmx(int16_t *block, const uint8_t *pixels, int line_size)
 cglobal get_pixels, 3,4
     movsxdifnidn r2, r2d
     add          r0, 128
@@ -392,7 +392,8 @@ cglobal get_pixels, 3, 4
     RET
 
 INIT_MMX mmx
-; diff_pixels_mmx(int16_t *block, const uint8_t *s1, const unint8_t *s2, stride)
+; void ff_diff_pixels_mmx(int16_t *block, const uint8_t *s1, const uint8_t *s2,
+;                         int stride);
 cglobal diff_pixels, 4,5
     movsxdifnidn r3, r3d
     pxor         m7, m7
@@ -418,7 +419,7 @@ cglobal diff_pixels, 4,5
     REP_RET
 
 INIT_MMX mmx
-; pix_sum16_mmx(uint8_t * pix, int line_size)
+; int ff_pix_sum16_mmx(uint8_t *pix, int line_size)
 cglobal pix_sum16, 2, 3
     movsxdifnidn r1, r1d
     mov          r2, r1
@@ -453,7 +454,7 @@ cglobal pix_sum16, 2, 3
     RET
 
 INIT_MMX mmx
-; pix_norm1_mmx(uint8_t *pix, int line_size)
+; int ff_pix_norm1_mmx(uint8_t *pix, int line_size)
 cglobal pix_norm1, 2, 4
     movsxdifnidn r1, r1d
     mov          r2, 16
diff --git a/deps/libav/libavcodec/x86/dsputilenc_mmx.c b/deps/libav/libavcodec/x86/dsputilenc_mmx.c
index a1f80af..2c32037 100644
--- a/deps/libav/libavcodec/x86/dsputilenc_mmx.c
+++ b/deps/libav/libavcodec/x86/dsputilenc_mmx.c
@@ -34,450 +34,479 @@
 
 void ff_get_pixels_mmx(int16_t *block, const uint8_t *pixels, int line_size);
 void ff_get_pixels_sse2(int16_t *block, const uint8_t *pixels, int line_size);
-void ff_diff_pixels_mmx(int16_t *block, const uint8_t *s1, const uint8_t *s2, int stride);
-int ff_pix_sum16_mmx(uint8_t * pix, int line_size);
+void ff_diff_pixels_mmx(int16_t *block, const uint8_t *s1, const uint8_t *s2,
+                        int stride);
+int ff_pix_sum16_mmx(uint8_t *pix, int line_size);
 int ff_pix_norm1_mmx(uint8_t *pix, int line_size);
 
 #if HAVE_INLINE_ASM
 
-static int sse8_mmx(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
+static int sse8_mmx(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
+{
     int tmp;
-  __asm__ volatile (
-      "movl %4,%%ecx\n"
-      "shr $1,%%ecx\n"
-      "pxor %%mm0,%%mm0\n"      /* mm0 = 0 */
-      "pxor %%mm7,%%mm7\n"      /* mm7 holds the sum */
-      "1:\n"
-      "movq (%0),%%mm1\n"       /* mm1 = pix1[0][0-7] */
-      "movq (%1),%%mm2\n"       /* mm2 = pix2[0][0-7] */
-      "movq (%0,%3),%%mm3\n"    /* mm3 = pix1[1][0-7] */
-      "movq (%1,%3),%%mm4\n"    /* mm4 = pix2[1][0-7] */
-
-      /* todo: mm1-mm2, mm3-mm4 */
-      /* algo: subtract mm1 from mm2 with saturation and vice versa */
-      /*       OR the results to get absolute difference */
-      "movq %%mm1,%%mm5\n"
-      "movq %%mm3,%%mm6\n"
-      "psubusb %%mm2,%%mm1\n"
-      "psubusb %%mm4,%%mm3\n"
-      "psubusb %%mm5,%%mm2\n"
-      "psubusb %%mm6,%%mm4\n"
-
-      "por %%mm1,%%mm2\n"
-      "por %%mm3,%%mm4\n"
-
-      /* now convert to 16-bit vectors so we can square them */
-      "movq %%mm2,%%mm1\n"
-      "movq %%mm4,%%mm3\n"
-
-      "punpckhbw %%mm0,%%mm2\n"
-      "punpckhbw %%mm0,%%mm4\n"
-      "punpcklbw %%mm0,%%mm1\n" /* mm1 now spread over (mm1,mm2) */
-      "punpcklbw %%mm0,%%mm3\n" /* mm4 now spread over (mm3,mm4) */
-
-      "pmaddwd %%mm2,%%mm2\n"
-      "pmaddwd %%mm4,%%mm4\n"
-      "pmaddwd %%mm1,%%mm1\n"
-      "pmaddwd %%mm3,%%mm3\n"
-
-      "lea (%0,%3,2), %0\n"     /* pix1 += 2*line_size */
-      "lea (%1,%3,2), %1\n"     /* pix2 += 2*line_size */
-
-      "paddd %%mm2,%%mm1\n"
-      "paddd %%mm4,%%mm3\n"
-      "paddd %%mm1,%%mm7\n"
-      "paddd %%mm3,%%mm7\n"
-
-      "decl %%ecx\n"
-      "jnz 1b\n"
-
-      "movq %%mm7,%%mm1\n"
-      "psrlq $32, %%mm7\n"      /* shift hi dword to lo */
-      "paddd %%mm7,%%mm1\n"
-      "movd %%mm1,%2\n"
-      : "+r" (pix1), "+r" (pix2), "=r"(tmp)
-      : "r" ((x86_reg)line_size) , "m" (h)
-      : "%ecx");
+
+    __asm__ volatile (
+        "movl         %4, %%ecx          \n"
+        "shr          $1, %%ecx          \n"
+        "pxor      %%mm0, %%mm0          \n" /* mm0 = 0 */
+        "pxor      %%mm7, %%mm7          \n" /* mm7 holds the sum */
+        "1:                              \n"
+        "movq       (%0), %%mm1          \n" /* mm1 = pix1[0][0 - 7] */
+        "movq       (%1), %%mm2          \n" /* mm2 = pix2[0][0 - 7] */
+        "movq   (%0, %3), %%mm3          \n" /* mm3 = pix1[1][0 - 7] */
+        "movq   (%1, %3), %%mm4          \n" /* mm4 = pix2[1][0 - 7] */
+
+        /* todo: mm1-mm2, mm3-mm4 */
+        /* algo: subtract mm1 from mm2 with saturation and vice versa */
+        /*       OR the results to get absolute difference */
+        "movq      %%mm1, %%mm5          \n"
+        "movq      %%mm3, %%mm6          \n"
+        "psubusb   %%mm2, %%mm1          \n"
+        "psubusb   %%mm4, %%mm3          \n"
+        "psubusb   %%mm5, %%mm2          \n"
+        "psubusb   %%mm6, %%mm4          \n"
+
+        "por       %%mm1, %%mm2          \n"
+        "por       %%mm3, %%mm4          \n"
+
+        /* now convert to 16-bit vectors so we can square them */
+        "movq      %%mm2, %%mm1          \n"
+        "movq      %%mm4, %%mm3          \n"
+
+        "punpckhbw %%mm0, %%mm2          \n"
+        "punpckhbw %%mm0, %%mm4          \n"
+        "punpcklbw %%mm0, %%mm1          \n" /* mm1 now spread over (mm1, mm2) */
+        "punpcklbw %%mm0, %%mm3          \n" /* mm4 now spread over (mm3, mm4) */
+
+        "pmaddwd   %%mm2, %%mm2          \n"
+        "pmaddwd   %%mm4, %%mm4          \n"
+        "pmaddwd   %%mm1, %%mm1          \n"
+        "pmaddwd   %%mm3, %%mm3          \n"
+
+        "lea (%0, %3, 2), %0             \n" /* pix1 += 2 * line_size */
+        "lea (%1, %3, 2), %1             \n" /* pix2 += 2 * line_size */
+
+        "paddd     %%mm2, %%mm1          \n"
+        "paddd     %%mm4, %%mm3          \n"
+        "paddd     %%mm1, %%mm7          \n"
+        "paddd     %%mm3, %%mm7          \n"
+
+        "decl      %%ecx                 \n"
+        "jnz       1b                    \n"
+
+        "movq      %%mm7, %%mm1          \n"
+        "psrlq       $32, %%mm7          \n" /* shift hi dword to lo */
+        "paddd     %%mm7, %%mm1          \n"
+        "movd      %%mm1, %2             \n"
+        : "+r" (pix1), "+r" (pix2), "=r" (tmp)
+        : "r" ((x86_reg) line_size), "m" (h)
+        : "%ecx");
+
     return tmp;
 }
 
-static int sse16_mmx(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
+static int sse16_mmx(void *v, uint8_t *pix1, uint8_t *pix2,
+                     int line_size, int h)
+{
     int tmp;
-  __asm__ volatile (
-      "movl %4,%%ecx\n"
-      "pxor %%mm0,%%mm0\n"      /* mm0 = 0 */
-      "pxor %%mm7,%%mm7\n"      /* mm7 holds the sum */
-      "1:\n"
-      "movq (%0),%%mm1\n"       /* mm1 = pix1[0-7] */
-      "movq (%1),%%mm2\n"       /* mm2 = pix2[0-7] */
-      "movq 8(%0),%%mm3\n"      /* mm3 = pix1[8-15] */
-      "movq 8(%1),%%mm4\n"      /* mm4 = pix2[8-15] */
-
-      /* todo: mm1-mm2, mm3-mm4 */
-      /* algo: subtract mm1 from mm2 with saturation and vice versa */
-      /*       OR the results to get absolute difference */
-      "movq %%mm1,%%mm5\n"
-      "movq %%mm3,%%mm6\n"
-      "psubusb %%mm2,%%mm1\n"
-      "psubusb %%mm4,%%mm3\n"
-      "psubusb %%mm5,%%mm2\n"
-      "psubusb %%mm6,%%mm4\n"
-
-      "por %%mm1,%%mm2\n"
-      "por %%mm3,%%mm4\n"
-
-      /* now convert to 16-bit vectors so we can square them */
-      "movq %%mm2,%%mm1\n"
-      "movq %%mm4,%%mm3\n"
-
-      "punpckhbw %%mm0,%%mm2\n"
-      "punpckhbw %%mm0,%%mm4\n"
-      "punpcklbw %%mm0,%%mm1\n" /* mm1 now spread over (mm1,mm2) */
-      "punpcklbw %%mm0,%%mm3\n" /* mm4 now spread over (mm3,mm4) */
-
-      "pmaddwd %%mm2,%%mm2\n"
-      "pmaddwd %%mm4,%%mm4\n"
-      "pmaddwd %%mm1,%%mm1\n"
-      "pmaddwd %%mm3,%%mm3\n"
-
-      "add %3,%0\n"
-      "add %3,%1\n"
-
-      "paddd %%mm2,%%mm1\n"
-      "paddd %%mm4,%%mm3\n"
-      "paddd %%mm1,%%mm7\n"
-      "paddd %%mm3,%%mm7\n"
-
-      "decl %%ecx\n"
-      "jnz 1b\n"
-
-      "movq %%mm7,%%mm1\n"
-      "psrlq $32, %%mm7\n"      /* shift hi dword to lo */
-      "paddd %%mm7,%%mm1\n"
-      "movd %%mm1,%2\n"
-      : "+r" (pix1), "+r" (pix2), "=r"(tmp)
-      : "r" ((x86_reg)line_size) , "m" (h)
-      : "%ecx");
+
+    __asm__ volatile (
+        "movl %4, %%ecx\n"
+        "pxor %%mm0, %%mm0\n"    /* mm0 = 0 */
+        "pxor %%mm7, %%mm7\n"    /* mm7 holds the sum */
+        "1:\n"
+        "movq (%0), %%mm1\n"     /* mm1 = pix1[0 -  7] */
+        "movq (%1), %%mm2\n"     /* mm2 = pix2[0 -  7] */
+        "movq 8(%0), %%mm3\n"    /* mm3 = pix1[8 - 15] */
+        "movq 8(%1), %%mm4\n"    /* mm4 = pix2[8 - 15] */
+
+        /* todo: mm1-mm2, mm3-mm4 */
+        /* algo: subtract mm1 from mm2 with saturation and vice versa */
+        /*       OR the results to get absolute difference */
+        "movq %%mm1, %%mm5\n"
+        "movq %%mm3, %%mm6\n"
+        "psubusb %%mm2, %%mm1\n"
+        "psubusb %%mm4, %%mm3\n"
+        "psubusb %%mm5, %%mm2\n"
+        "psubusb %%mm6, %%mm4\n"
+
+        "por %%mm1, %%mm2\n"
+        "por %%mm3, %%mm4\n"
+
+        /* now convert to 16-bit vectors so we can square them */
+        "movq %%mm2, %%mm1\n"
+        "movq %%mm4, %%mm3\n"
+
+        "punpckhbw %%mm0, %%mm2\n"
+        "punpckhbw %%mm0, %%mm4\n"
+        "punpcklbw %%mm0, %%mm1\n" /* mm1 now spread over (mm1, mm2) */
+        "punpcklbw %%mm0, %%mm3\n" /* mm4 now spread over (mm3, mm4) */
+
+        "pmaddwd %%mm2, %%mm2\n"
+        "pmaddwd %%mm4, %%mm4\n"
+        "pmaddwd %%mm1, %%mm1\n"
+        "pmaddwd %%mm3, %%mm3\n"
+
+        "add %3, %0\n"
+        "add %3, %1\n"
+
+        "paddd %%mm2, %%mm1\n"
+        "paddd %%mm4, %%mm3\n"
+        "paddd %%mm1, %%mm7\n"
+        "paddd %%mm3, %%mm7\n"
+
+        "decl %%ecx\n"
+        "jnz 1b\n"
+
+        "movq %%mm7, %%mm1\n"
+        "psrlq $32, %%mm7\n"    /* shift hi dword to lo */
+        "paddd %%mm7, %%mm1\n"
+        "movd %%mm1, %2\n"
+        : "+r" (pix1), "+r" (pix2), "=r" (tmp)
+        : "r" ((x86_reg) line_size), "m" (h)
+        : "%ecx");
+
     return tmp;
 }
 
-static int hf_noise8_mmx(uint8_t * pix1, int line_size, int h) {
+static int hf_noise8_mmx(uint8_t *pix1, int line_size, int h)
+{
     int tmp;
-  __asm__ volatile (
-      "movl %3,%%ecx\n"
-      "pxor %%mm7,%%mm7\n"
-      "pxor %%mm6,%%mm6\n"
-
-      "movq (%0),%%mm0\n"
-      "movq %%mm0, %%mm1\n"
-      "psllq $8, %%mm0\n"
-      "psrlq $8, %%mm1\n"
-      "psrlq $8, %%mm0\n"
-      "movq %%mm0, %%mm2\n"
-      "movq %%mm1, %%mm3\n"
-      "punpcklbw %%mm7,%%mm0\n"
-      "punpcklbw %%mm7,%%mm1\n"
-      "punpckhbw %%mm7,%%mm2\n"
-      "punpckhbw %%mm7,%%mm3\n"
-      "psubw %%mm1, %%mm0\n"
-      "psubw %%mm3, %%mm2\n"
-
-      "add %2,%0\n"
-
-      "movq (%0),%%mm4\n"
-      "movq %%mm4, %%mm1\n"
-      "psllq $8, %%mm4\n"
-      "psrlq $8, %%mm1\n"
-      "psrlq $8, %%mm4\n"
-      "movq %%mm4, %%mm5\n"
-      "movq %%mm1, %%mm3\n"
-      "punpcklbw %%mm7,%%mm4\n"
-      "punpcklbw %%mm7,%%mm1\n"
-      "punpckhbw %%mm7,%%mm5\n"
-      "punpckhbw %%mm7,%%mm3\n"
-      "psubw %%mm1, %%mm4\n"
-      "psubw %%mm3, %%mm5\n"
-      "psubw %%mm4, %%mm0\n"
-      "psubw %%mm5, %%mm2\n"
-      "pxor %%mm3, %%mm3\n"
-      "pxor %%mm1, %%mm1\n"
-      "pcmpgtw %%mm0, %%mm3\n\t"
-      "pcmpgtw %%mm2, %%mm1\n\t"
-      "pxor %%mm3, %%mm0\n"
-      "pxor %%mm1, %%mm2\n"
-      "psubw %%mm3, %%mm0\n"
-      "psubw %%mm1, %%mm2\n"
-      "paddw %%mm0, %%mm2\n"
-      "paddw %%mm2, %%mm6\n"
-
-      "add %2,%0\n"
-      "1:\n"
-
-      "movq (%0),%%mm0\n"
-      "movq %%mm0, %%mm1\n"
-      "psllq $8, %%mm0\n"
-      "psrlq $8, %%mm1\n"
-      "psrlq $8, %%mm0\n"
-      "movq %%mm0, %%mm2\n"
-      "movq %%mm1, %%mm3\n"
-      "punpcklbw %%mm7,%%mm0\n"
-      "punpcklbw %%mm7,%%mm1\n"
-      "punpckhbw %%mm7,%%mm2\n"
-      "punpckhbw %%mm7,%%mm3\n"
-      "psubw %%mm1, %%mm0\n"
-      "psubw %%mm3, %%mm2\n"
-      "psubw %%mm0, %%mm4\n"
-      "psubw %%mm2, %%mm5\n"
-      "pxor %%mm3, %%mm3\n"
-      "pxor %%mm1, %%mm1\n"
-      "pcmpgtw %%mm4, %%mm3\n\t"
-      "pcmpgtw %%mm5, %%mm1\n\t"
-      "pxor %%mm3, %%mm4\n"
-      "pxor %%mm1, %%mm5\n"
-      "psubw %%mm3, %%mm4\n"
-      "psubw %%mm1, %%mm5\n"
-      "paddw %%mm4, %%mm5\n"
-      "paddw %%mm5, %%mm6\n"
-
-      "add %2,%0\n"
-
-      "movq (%0),%%mm4\n"
-      "movq %%mm4, %%mm1\n"
-      "psllq $8, %%mm4\n"
-      "psrlq $8, %%mm1\n"
-      "psrlq $8, %%mm4\n"
-      "movq %%mm4, %%mm5\n"
-      "movq %%mm1, %%mm3\n"
-      "punpcklbw %%mm7,%%mm4\n"
-      "punpcklbw %%mm7,%%mm1\n"
-      "punpckhbw %%mm7,%%mm5\n"
-      "punpckhbw %%mm7,%%mm3\n"
-      "psubw %%mm1, %%mm4\n"
-      "psubw %%mm3, %%mm5\n"
-      "psubw %%mm4, %%mm0\n"
-      "psubw %%mm5, %%mm2\n"
-      "pxor %%mm3, %%mm3\n"
-      "pxor %%mm1, %%mm1\n"
-      "pcmpgtw %%mm0, %%mm3\n\t"
-      "pcmpgtw %%mm2, %%mm1\n\t"
-      "pxor %%mm3, %%mm0\n"
-      "pxor %%mm1, %%mm2\n"
-      "psubw %%mm3, %%mm0\n"
-      "psubw %%mm1, %%mm2\n"
-      "paddw %%mm0, %%mm2\n"
-      "paddw %%mm2, %%mm6\n"
-
-      "add %2,%0\n"
-      "subl $2, %%ecx\n"
-      " jnz 1b\n"
-
-      "movq %%mm6, %%mm0\n"
-      "punpcklwd %%mm7,%%mm0\n"
-      "punpckhwd %%mm7,%%mm6\n"
-      "paddd %%mm0, %%mm6\n"
-
-      "movq %%mm6,%%mm0\n"
-      "psrlq $32, %%mm6\n"
-      "paddd %%mm6,%%mm0\n"
-      "movd %%mm0,%1\n"
-      : "+r" (pix1), "=r"(tmp)
-      : "r" ((x86_reg)line_size) , "g" (h-2)
-      : "%ecx");
-      return tmp;
+
+    __asm__ volatile (
+        "movl %3, %%ecx\n"
+        "pxor %%mm7, %%mm7\n"
+        "pxor %%mm6, %%mm6\n"
+
+        "movq (%0), %%mm0\n"
+        "movq %%mm0, %%mm1\n"
+        "psllq $8, %%mm0\n"
+        "psrlq $8, %%mm1\n"
+        "psrlq $8, %%mm0\n"
+        "movq %%mm0, %%mm2\n"
+        "movq %%mm1, %%mm3\n"
+        "punpcklbw %%mm7, %%mm0\n"
+        "punpcklbw %%mm7, %%mm1\n"
+        "punpckhbw %%mm7, %%mm2\n"
+        "punpckhbw %%mm7, %%mm3\n"
+        "psubw %%mm1, %%mm0\n"
+        "psubw %%mm3, %%mm2\n"
+
+        "add %2, %0\n"
+
+        "movq (%0), %%mm4\n"
+        "movq %%mm4, %%mm1\n"
+        "psllq $8, %%mm4\n"
+        "psrlq $8, %%mm1\n"
+        "psrlq $8, %%mm4\n"
+        "movq %%mm4, %%mm5\n"
+        "movq %%mm1, %%mm3\n"
+        "punpcklbw %%mm7, %%mm4\n"
+        "punpcklbw %%mm7, %%mm1\n"
+        "punpckhbw %%mm7, %%mm5\n"
+        "punpckhbw %%mm7, %%mm3\n"
+        "psubw %%mm1, %%mm4\n"
+        "psubw %%mm3, %%mm5\n"
+        "psubw %%mm4, %%mm0\n"
+        "psubw %%mm5, %%mm2\n"
+        "pxor %%mm3, %%mm3\n"
+        "pxor %%mm1, %%mm1\n"
+        "pcmpgtw %%mm0, %%mm3\n\t"
+        "pcmpgtw %%mm2, %%mm1\n\t"
+        "pxor %%mm3, %%mm0\n"
+        "pxor %%mm1, %%mm2\n"
+        "psubw %%mm3, %%mm0\n"
+        "psubw %%mm1, %%mm2\n"
+        "paddw %%mm0, %%mm2\n"
+        "paddw %%mm2, %%mm6\n"
+
+        "add %2, %0\n"
+        "1:\n"
+
+        "movq (%0), %%mm0\n"
+        "movq %%mm0, %%mm1\n"
+        "psllq $8, %%mm0\n"
+        "psrlq $8, %%mm1\n"
+        "psrlq $8, %%mm0\n"
+        "movq %%mm0, %%mm2\n"
+        "movq %%mm1, %%mm3\n"
+        "punpcklbw %%mm7, %%mm0\n"
+        "punpcklbw %%mm7, %%mm1\n"
+        "punpckhbw %%mm7, %%mm2\n"
+        "punpckhbw %%mm7, %%mm3\n"
+        "psubw %%mm1, %%mm0\n"
+        "psubw %%mm3, %%mm2\n"
+        "psubw %%mm0, %%mm4\n"
+        "psubw %%mm2, %%mm5\n"
+        "pxor  %%mm3, %%mm3\n"
+        "pxor  %%mm1, %%mm1\n"
+        "pcmpgtw %%mm4, %%mm3\n\t"
+        "pcmpgtw %%mm5, %%mm1\n\t"
+        "pxor  %%mm3, %%mm4\n"
+        "pxor  %%mm1, %%mm5\n"
+        "psubw %%mm3, %%mm4\n"
+        "psubw %%mm1, %%mm5\n"
+        "paddw %%mm4, %%mm5\n"
+        "paddw %%mm5, %%mm6\n"
+
+        "add %2, %0\n"
+
+        "movq (%0), %%mm4\n"
+        "movq      %%mm4, %%mm1\n"
+        "psllq $8, %%mm4\n"
+        "psrlq $8, %%mm1\n"
+        "psrlq $8, %%mm4\n"
+        "movq      %%mm4, %%mm5\n"
+        "movq      %%mm1, %%mm3\n"
+        "punpcklbw %%mm7, %%mm4\n"
+        "punpcklbw %%mm7, %%mm1\n"
+        "punpckhbw %%mm7, %%mm5\n"
+        "punpckhbw %%mm7, %%mm3\n"
+        "psubw     %%mm1, %%mm4\n"
+        "psubw     %%mm3, %%mm5\n"
+        "psubw     %%mm4, %%mm0\n"
+        "psubw     %%mm5, %%mm2\n"
+        "pxor      %%mm3, %%mm3\n"
+        "pxor      %%mm1, %%mm1\n"
+        "pcmpgtw   %%mm0, %%mm3\n\t"
+        "pcmpgtw   %%mm2, %%mm1\n\t"
+        "pxor      %%mm3, %%mm0\n"
+        "pxor      %%mm1, %%mm2\n"
+        "psubw     %%mm3, %%mm0\n"
+        "psubw     %%mm1, %%mm2\n"
+        "paddw     %%mm0, %%mm2\n"
+        "paddw     %%mm2, %%mm6\n"
+
+        "add  %2, %0\n"
+        "subl $2, %%ecx\n"
+        " jnz 1b\n"
+
+        "movq      %%mm6, %%mm0\n"
+        "punpcklwd %%mm7, %%mm0\n"
+        "punpckhwd %%mm7, %%mm6\n"
+        "paddd     %%mm0, %%mm6\n"
+
+        "movq  %%mm6, %%mm0\n"
+        "psrlq $32,   %%mm6\n"
+        "paddd %%mm6, %%mm0\n"
+        "movd  %%mm0, %1\n"
+        : "+r" (pix1), "=r" (tmp)
+        : "r" ((x86_reg) line_size), "g" (h - 2)
+        : "%ecx");
+
+    return tmp;
 }
 
-static int hf_noise16_mmx(uint8_t * pix1, int line_size, int h) {
+static int hf_noise16_mmx(uint8_t *pix1, int line_size, int h)
+{
     int tmp;
-    uint8_t * pix= pix1;
-  __asm__ volatile (
-      "movl %3,%%ecx\n"
-      "pxor %%mm7,%%mm7\n"
-      "pxor %%mm6,%%mm6\n"
-
-      "movq (%0),%%mm0\n"
-      "movq 1(%0),%%mm1\n"
-      "movq %%mm0, %%mm2\n"
-      "movq %%mm1, %%mm3\n"
-      "punpcklbw %%mm7,%%mm0\n"
-      "punpcklbw %%mm7,%%mm1\n"
-      "punpckhbw %%mm7,%%mm2\n"
-      "punpckhbw %%mm7,%%mm3\n"
-      "psubw %%mm1, %%mm0\n"
-      "psubw %%mm3, %%mm2\n"
-
-      "add %2,%0\n"
-
-      "movq (%0),%%mm4\n"
-      "movq 1(%0),%%mm1\n"
-      "movq %%mm4, %%mm5\n"
-      "movq %%mm1, %%mm3\n"
-      "punpcklbw %%mm7,%%mm4\n"
-      "punpcklbw %%mm7,%%mm1\n"
-      "punpckhbw %%mm7,%%mm5\n"
-      "punpckhbw %%mm7,%%mm3\n"
-      "psubw %%mm1, %%mm4\n"
-      "psubw %%mm3, %%mm5\n"
-      "psubw %%mm4, %%mm0\n"
-      "psubw %%mm5, %%mm2\n"
-      "pxor %%mm3, %%mm3\n"
-      "pxor %%mm1, %%mm1\n"
-      "pcmpgtw %%mm0, %%mm3\n\t"
-      "pcmpgtw %%mm2, %%mm1\n\t"
-      "pxor %%mm3, %%mm0\n"
-      "pxor %%mm1, %%mm2\n"
-      "psubw %%mm3, %%mm0\n"
-      "psubw %%mm1, %%mm2\n"
-      "paddw %%mm0, %%mm2\n"
-      "paddw %%mm2, %%mm6\n"
-
-      "add %2,%0\n"
-      "1:\n"
-
-      "movq (%0),%%mm0\n"
-      "movq 1(%0),%%mm1\n"
-      "movq %%mm0, %%mm2\n"
-      "movq %%mm1, %%mm3\n"
-      "punpcklbw %%mm7,%%mm0\n"
-      "punpcklbw %%mm7,%%mm1\n"
-      "punpckhbw %%mm7,%%mm2\n"
-      "punpckhbw %%mm7,%%mm3\n"
-      "psubw %%mm1, %%mm0\n"
-      "psubw %%mm3, %%mm2\n"
-      "psubw %%mm0, %%mm4\n"
-      "psubw %%mm2, %%mm5\n"
-      "pxor %%mm3, %%mm3\n"
-      "pxor %%mm1, %%mm1\n"
-      "pcmpgtw %%mm4, %%mm3\n\t"
-      "pcmpgtw %%mm5, %%mm1\n\t"
-      "pxor %%mm3, %%mm4\n"
-      "pxor %%mm1, %%mm5\n"
-      "psubw %%mm3, %%mm4\n"
-      "psubw %%mm1, %%mm5\n"
-      "paddw %%mm4, %%mm5\n"
-      "paddw %%mm5, %%mm6\n"
-
-      "add %2,%0\n"
-
-      "movq (%0),%%mm4\n"
-      "movq 1(%0),%%mm1\n"
-      "movq %%mm4, %%mm5\n"
-      "movq %%mm1, %%mm3\n"
-      "punpcklbw %%mm7,%%mm4\n"
-      "punpcklbw %%mm7,%%mm1\n"
-      "punpckhbw %%mm7,%%mm5\n"
-      "punpckhbw %%mm7,%%mm3\n"
-      "psubw %%mm1, %%mm4\n"
-      "psubw %%mm3, %%mm5\n"
-      "psubw %%mm4, %%mm0\n"
-      "psubw %%mm5, %%mm2\n"
-      "pxor %%mm3, %%mm3\n"
-      "pxor %%mm1, %%mm1\n"
-      "pcmpgtw %%mm0, %%mm3\n\t"
-      "pcmpgtw %%mm2, %%mm1\n\t"
-      "pxor %%mm3, %%mm0\n"
-      "pxor %%mm1, %%mm2\n"
-      "psubw %%mm3, %%mm0\n"
-      "psubw %%mm1, %%mm2\n"
-      "paddw %%mm0, %%mm2\n"
-      "paddw %%mm2, %%mm6\n"
-
-      "add %2,%0\n"
-      "subl $2, %%ecx\n"
-      " jnz 1b\n"
-
-      "movq %%mm6, %%mm0\n"
-      "punpcklwd %%mm7,%%mm0\n"
-      "punpckhwd %%mm7,%%mm6\n"
-      "paddd %%mm0, %%mm6\n"
-
-      "movq %%mm6,%%mm0\n"
-      "psrlq $32, %%mm6\n"
-      "paddd %%mm6,%%mm0\n"
-      "movd %%mm0,%1\n"
-      : "+r" (pix1), "=r"(tmp)
-      : "r" ((x86_reg)line_size) , "g" (h-2)
-      : "%ecx");
-      return tmp + hf_noise8_mmx(pix+8, line_size, h);
+    uint8_t *pix = pix1;
+
+    __asm__ volatile (
+        "movl %3, %%ecx\n"
+        "pxor %%mm7, %%mm7\n"
+        "pxor %%mm6, %%mm6\n"
+
+        "movq (%0), %%mm0\n"
+        "movq 1(%0), %%mm1\n"
+        "movq %%mm0, %%mm2\n"
+        "movq %%mm1, %%mm3\n"
+        "punpcklbw %%mm7, %%mm0\n"
+        "punpcklbw %%mm7, %%mm1\n"
+        "punpckhbw %%mm7, %%mm2\n"
+        "punpckhbw %%mm7, %%mm3\n"
+        "psubw %%mm1, %%mm0\n"
+        "psubw %%mm3, %%mm2\n"
+
+        "add %2, %0\n"
+
+        "movq (%0), %%mm4\n"
+        "movq 1(%0), %%mm1\n"
+        "movq %%mm4, %%mm5\n"
+        "movq %%mm1, %%mm3\n"
+        "punpcklbw %%mm7, %%mm4\n"
+        "punpcklbw %%mm7, %%mm1\n"
+        "punpckhbw %%mm7, %%mm5\n"
+        "punpckhbw %%mm7, %%mm3\n"
+        "psubw %%mm1, %%mm4\n"
+        "psubw %%mm3, %%mm5\n"
+        "psubw %%mm4, %%mm0\n"
+        "psubw %%mm5, %%mm2\n"
+        "pxor %%mm3, %%mm3\n"
+        "pxor %%mm1, %%mm1\n"
+        "pcmpgtw %%mm0, %%mm3\n\t"
+        "pcmpgtw %%mm2, %%mm1\n\t"
+        "pxor %%mm3, %%mm0\n"
+        "pxor %%mm1, %%mm2\n"
+        "psubw %%mm3, %%mm0\n"
+        "psubw %%mm1, %%mm2\n"
+        "paddw %%mm0, %%mm2\n"
+        "paddw %%mm2, %%mm6\n"
+
+        "add %2, %0\n"
+        "1:\n"
+
+        "movq (%0), %%mm0\n"
+        "movq 1(%0), %%mm1\n"
+        "movq %%mm0, %%mm2\n"
+        "movq %%mm1, %%mm3\n"
+        "punpcklbw %%mm7, %%mm0\n"
+        "punpcklbw %%mm7, %%mm1\n"
+        "punpckhbw %%mm7, %%mm2\n"
+        "punpckhbw %%mm7, %%mm3\n"
+        "psubw %%mm1, %%mm0\n"
+        "psubw %%mm3, %%mm2\n"
+        "psubw %%mm0, %%mm4\n"
+        "psubw %%mm2, %%mm5\n"
+        "pxor %%mm3, %%mm3\n"
+        "pxor %%mm1, %%mm1\n"
+        "pcmpgtw %%mm4, %%mm3\n\t"
+        "pcmpgtw %%mm5, %%mm1\n\t"
+        "pxor %%mm3, %%mm4\n"
+        "pxor %%mm1, %%mm5\n"
+        "psubw %%mm3, %%mm4\n"
+        "psubw %%mm1, %%mm5\n"
+        "paddw %%mm4, %%mm5\n"
+        "paddw %%mm5, %%mm6\n"
+
+        "add %2, %0\n"
+
+        "movq (%0), %%mm4\n"
+        "movq 1(%0), %%mm1\n"
+        "movq %%mm4, %%mm5\n"
+        "movq %%mm1, %%mm3\n"
+        "punpcklbw %%mm7, %%mm4\n"
+        "punpcklbw %%mm7, %%mm1\n"
+        "punpckhbw %%mm7, %%mm5\n"
+        "punpckhbw %%mm7, %%mm3\n"
+        "psubw %%mm1, %%mm4\n"
+        "psubw %%mm3, %%mm5\n"
+        "psubw %%mm4, %%mm0\n"
+        "psubw %%mm5, %%mm2\n"
+        "pxor %%mm3, %%mm3\n"
+        "pxor %%mm1, %%mm1\n"
+        "pcmpgtw %%mm0, %%mm3\n\t"
+        "pcmpgtw %%mm2, %%mm1\n\t"
+        "pxor %%mm3, %%mm0\n"
+        "pxor %%mm1, %%mm2\n"
+        "psubw %%mm3, %%mm0\n"
+        "psubw %%mm1, %%mm2\n"
+        "paddw %%mm0, %%mm2\n"
+        "paddw %%mm2, %%mm6\n"
+
+        "add %2, %0\n"
+        "subl $2, %%ecx\n"
+        " jnz 1b\n"
+
+        "movq %%mm6, %%mm0\n"
+        "punpcklwd %%mm7, %%mm0\n"
+        "punpckhwd %%mm7, %%mm6\n"
+        "paddd %%mm0, %%mm6\n"
+
+        "movq %%mm6, %%mm0\n"
+        "psrlq $32, %%mm6\n"
+        "paddd %%mm6, %%mm0\n"
+        "movd %%mm0, %1\n"
+        : "+r" (pix1), "=r" (tmp)
+        : "r" ((x86_reg) line_size), "g" (h - 2)
+        : "%ecx");
+
+    return tmp + hf_noise8_mmx(pix + 8, line_size, h);
 }
 
-static int nsse16_mmx(void *p, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
+static int nsse16_mmx(void *p, uint8_t *pix1, uint8_t *pix2,
+                      int line_size, int h)
+{
     MpegEncContext *c = p;
     int score1, score2;
 
-    if(c) score1 = c->dsp.sse[0](c, pix1, pix2, line_size, h);
-    else  score1 = sse16_mmx(c, pix1, pix2, line_size, h);
-    score2= hf_noise16_mmx(pix1, line_size, h) - hf_noise16_mmx(pix2, line_size, h);
-
-    if(c) return score1 + FFABS(score2)*c->avctx->nsse_weight;
-    else  return score1 + FFABS(score2)*8;
+    if (c)
+        score1 = c->dsp.sse[0](c, pix1, pix2, line_size, h);
+    else
+        score1 = sse16_mmx(c, pix1, pix2, line_size, h);
+    score2 = hf_noise16_mmx(pix1, line_size, h) -
+             hf_noise16_mmx(pix2, line_size, h);
+
+    if (c)
+        return score1 + FFABS(score2) * c->avctx->nsse_weight;
+    else
+        return score1 + FFABS(score2) * 8;
 }
 
-static int nsse8_mmx(void *p, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
+static int nsse8_mmx(void *p, uint8_t *pix1, uint8_t *pix2,
+                     int line_size, int h)
+{
     MpegEncContext *c = p;
-    int score1= sse8_mmx(c, pix1, pix2, line_size, h);
-    int score2= hf_noise8_mmx(pix1, line_size, h) - hf_noise8_mmx(pix2, line_size, h);
-
-    if(c) return score1 + FFABS(score2)*c->avctx->nsse_weight;
-    else  return score1 + FFABS(score2)*8;
+    int score1 = sse8_mmx(c, pix1, pix2, line_size, h);
+    int score2 = hf_noise8_mmx(pix1, line_size, h) -
+                 hf_noise8_mmx(pix2, line_size, h);
+
+    if (c)
+        return score1 + FFABS(score2) * c->avctx->nsse_weight;
+    else
+        return score1 + FFABS(score2) * 8;
 }
 
-static int vsad_intra16_mmx(void *v, uint8_t * pix, uint8_t * dummy, int line_size, int h) {
+static int vsad_intra16_mmx(void *v, uint8_t *pix, uint8_t *dummy,
+                            int line_size, int h)
+{
     int tmp;
 
-    assert( (((int)pix) & 7) == 0);
-    assert((line_size &7) ==0);
-
-#define SUM(in0, in1, out0, out1) \
-      "movq (%0), %%mm2\n"\
-      "movq 8(%0), %%mm3\n"\
-      "add %2,%0\n"\
-      "movq %%mm2, " #out0 "\n"\
-      "movq %%mm3, " #out1 "\n"\
-      "psubusb " #in0 ", %%mm2\n"\
-      "psubusb " #in1 ", %%mm3\n"\
-      "psubusb " #out0 ", " #in0 "\n"\
-      "psubusb " #out1 ", " #in1 "\n"\
-      "por %%mm2, " #in0 "\n"\
-      "por %%mm3, " #in1 "\n"\
-      "movq " #in0 ", %%mm2\n"\
-      "movq " #in1 ", %%mm3\n"\
-      "punpcklbw %%mm7, " #in0 "\n"\
-      "punpcklbw %%mm7, " #in1 "\n"\
-      "punpckhbw %%mm7, %%mm2\n"\
-      "punpckhbw %%mm7, %%mm3\n"\
-      "paddw " #in1 ", " #in0 "\n"\
-      "paddw %%mm3, %%mm2\n"\
-      "paddw %%mm2, " #in0 "\n"\
-      "paddw " #in0 ", %%mm6\n"
-
-
-  __asm__ volatile (
-      "movl %3,%%ecx\n"
-      "pxor %%mm6,%%mm6\n"
-      "pxor %%mm7,%%mm7\n"
-      "movq (%0),%%mm0\n"
-      "movq 8(%0),%%mm1\n"
-      "add %2,%0\n"
-      "jmp 2f\n"
-      "1:\n"
-
-      SUM(%%mm4, %%mm5, %%mm0, %%mm1)
-      "2:\n"
-      SUM(%%mm0, %%mm1, %%mm4, %%mm5)
-
-      "subl $2, %%ecx\n"
-      "jnz 1b\n"
-
-      "movq %%mm6,%%mm0\n"
-      "psrlq $32, %%mm6\n"
-      "paddw %%mm6,%%mm0\n"
-      "movq %%mm0,%%mm6\n"
-      "psrlq $16, %%mm0\n"
-      "paddw %%mm6,%%mm0\n"
-      "movd %%mm0,%1\n"
-      : "+r" (pix), "=r"(tmp)
-      : "r" ((x86_reg)line_size) , "m" (h)
-      : "%ecx");
+    assert((((int) pix) & 7) == 0);
+    assert((line_size & 7) == 0);
+
+#define SUM(in0, in1, out0, out1)               \
+    "movq (%0), %%mm2\n"                        \
+    "movq 8(%0), %%mm3\n"                       \
+    "add %2,%0\n"                               \
+    "movq %%mm2, " #out0 "\n"                   \
+    "movq %%mm3, " #out1 "\n"                   \
+    "psubusb " #in0 ", %%mm2\n"                 \
+    "psubusb " #in1 ", %%mm3\n"                 \
+    "psubusb " #out0 ", " #in0 "\n"             \
+    "psubusb " #out1 ", " #in1 "\n"             \
+    "por %%mm2, " #in0 "\n"                     \
+    "por %%mm3, " #in1 "\n"                     \
+    "movq " #in0 ", %%mm2\n"                    \
+    "movq " #in1 ", %%mm3\n"                    \
+    "punpcklbw %%mm7, " #in0 "\n"               \
+    "punpcklbw %%mm7, " #in1 "\n"               \
+    "punpckhbw %%mm7, %%mm2\n"                  \
+    "punpckhbw %%mm7, %%mm3\n"                  \
+    "paddw " #in1 ", " #in0 "\n"                \
+    "paddw %%mm3, %%mm2\n"                      \
+    "paddw %%mm2, " #in0 "\n"                   \
+    "paddw " #in0 ", %%mm6\n"
+
+
+    __asm__ volatile (
+        "movl    %3, %%ecx\n"
+        "pxor %%mm6, %%mm6\n"
+        "pxor %%mm7, %%mm7\n"
+        "movq  (%0), %%mm0\n"
+        "movq 8(%0), %%mm1\n"
+        "add %2, %0\n"
+        "jmp 2f\n"
+        "1:\n"
+
+        SUM(%%mm4, %%mm5, %%mm0, %%mm1)
+        "2:\n"
+        SUM(%%mm0, %%mm1, %%mm4, %%mm5)
+
+        "subl $2, %%ecx\n"
+        "jnz 1b\n"
+
+        "movq  %%mm6, %%mm0\n"
+        "psrlq $32,   %%mm6\n"
+        "paddw %%mm6, %%mm0\n"
+        "movq  %%mm0, %%mm6\n"
+        "psrlq $16,   %%mm0\n"
+        "paddw %%mm6, %%mm0\n"
+        "movd  %%mm0, %1\n"
+        : "+r" (pix), "=r" (tmp)
+        : "r" ((x86_reg) line_size), "m" (h)
+        : "%ecx");
+
     return tmp & 0xFFFF;
 }
 #undef SUM
@@ -487,117 +516,121 @@ static int vsad_intra16_mmxext(void *v, uint8_t *pix, uint8_t *dummy,
 {
     int tmp;
 
-    assert( (((int)pix) & 7) == 0);
-    assert((line_size &7) ==0);
-
-#define SUM(in0, in1, out0, out1) \
-      "movq (%0), " #out0 "\n"\
-      "movq 8(%0), " #out1 "\n"\
-      "add %2,%0\n"\
-      "psadbw " #out0 ", " #in0 "\n"\
-      "psadbw " #out1 ", " #in1 "\n"\
-      "paddw " #in1 ", " #in0 "\n"\
-      "paddw " #in0 ", %%mm6\n"
-
-  __asm__ volatile (
-      "movl %3,%%ecx\n"
-      "pxor %%mm6,%%mm6\n"
-      "pxor %%mm7,%%mm7\n"
-      "movq (%0),%%mm0\n"
-      "movq 8(%0),%%mm1\n"
-      "add %2,%0\n"
-      "jmp 2f\n"
-      "1:\n"
-
-      SUM(%%mm4, %%mm5, %%mm0, %%mm1)
-      "2:\n"
-      SUM(%%mm0, %%mm1, %%mm4, %%mm5)
-
-      "subl $2, %%ecx\n"
-      "jnz 1b\n"
-
-      "movd %%mm6,%1\n"
-      : "+r" (pix), "=r"(tmp)
-      : "r" ((x86_reg)line_size) , "m" (h)
-      : "%ecx");
+    assert((((int) pix) & 7) == 0);
+    assert((line_size & 7) == 0);
+
+#define SUM(in0, in1, out0, out1)               \
+    "movq (%0), " #out0 "\n"                    \
+    "movq 8(%0), " #out1 "\n"                   \
+    "add %2, %0\n"                              \
+    "psadbw " #out0 ", " #in0 "\n"              \
+    "psadbw " #out1 ", " #in1 "\n"              \
+    "paddw " #in1 ", " #in0 "\n"                \
+    "paddw " #in0 ", %%mm6\n"
+
+    __asm__ volatile (
+        "movl %3, %%ecx\n"
+        "pxor %%mm6, %%mm6\n"
+        "pxor %%mm7, %%mm7\n"
+        "movq (%0), %%mm0\n"
+        "movq 8(%0), %%mm1\n"
+        "add %2, %0\n"
+        "jmp 2f\n"
+        "1:\n"
+
+        SUM(%%mm4, %%mm5, %%mm0, %%mm1)
+        "2:\n"
+        SUM(%%mm0, %%mm1, %%mm4, %%mm5)
+
+        "subl $2, %%ecx\n"
+        "jnz 1b\n"
+
+        "movd %%mm6, %1\n"
+        : "+r" (pix), "=r" (tmp)
+        : "r" ((x86_reg) line_size), "m" (h)
+        : "%ecx");
+
     return tmp;
 }
 #undef SUM
 
-static int vsad16_mmx(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h) {
+static int vsad16_mmx(void *v, uint8_t *pix1, uint8_t *pix2,
+                      int line_size, int h)
+{
     int tmp;
 
-    assert( (((int)pix1) & 7) == 0);
-    assert( (((int)pix2) & 7) == 0);
-    assert((line_size &7) ==0);
-
-#define SUM(in0, in1, out0, out1) \
-      "movq (%0),%%mm2\n"\
-      "movq (%1)," #out0 "\n"\
-      "movq 8(%0),%%mm3\n"\
-      "movq 8(%1)," #out1 "\n"\
-      "add %3,%0\n"\
-      "add %3,%1\n"\
-      "psubb " #out0 ", %%mm2\n"\
-      "psubb " #out1 ", %%mm3\n"\
-      "pxor %%mm7, %%mm2\n"\
-      "pxor %%mm7, %%mm3\n"\
-      "movq %%mm2, " #out0 "\n"\
-      "movq %%mm3, " #out1 "\n"\
-      "psubusb " #in0 ", %%mm2\n"\
-      "psubusb " #in1 ", %%mm3\n"\
-      "psubusb " #out0 ", " #in0 "\n"\
-      "psubusb " #out1 ", " #in1 "\n"\
-      "por %%mm2, " #in0 "\n"\
-      "por %%mm3, " #in1 "\n"\
-      "movq " #in0 ", %%mm2\n"\
-      "movq " #in1 ", %%mm3\n"\
-      "punpcklbw %%mm7, " #in0 "\n"\
-      "punpcklbw %%mm7, " #in1 "\n"\
-      "punpckhbw %%mm7, %%mm2\n"\
-      "punpckhbw %%mm7, %%mm3\n"\
-      "paddw " #in1 ", " #in0 "\n"\
-      "paddw %%mm3, %%mm2\n"\
-      "paddw %%mm2, " #in0 "\n"\
-      "paddw " #in0 ", %%mm6\n"
-
-
-  __asm__ volatile (
-      "movl %4,%%ecx\n"
-      "pxor %%mm6,%%mm6\n"
-      "pcmpeqw %%mm7,%%mm7\n"
-      "psllw $15, %%mm7\n"
-      "packsswb %%mm7, %%mm7\n"
-      "movq (%0),%%mm0\n"
-      "movq (%1),%%mm2\n"
-      "movq 8(%0),%%mm1\n"
-      "movq 8(%1),%%mm3\n"
-      "add %3,%0\n"
-      "add %3,%1\n"
-      "psubb %%mm2, %%mm0\n"
-      "psubb %%mm3, %%mm1\n"
-      "pxor %%mm7, %%mm0\n"
-      "pxor %%mm7, %%mm1\n"
-      "jmp 2f\n"
-      "1:\n"
-
-      SUM(%%mm4, %%mm5, %%mm0, %%mm1)
-      "2:\n"
-      SUM(%%mm0, %%mm1, %%mm4, %%mm5)
-
-      "subl $2, %%ecx\n"
-      "jnz 1b\n"
-
-      "movq %%mm6,%%mm0\n"
-      "psrlq $32, %%mm6\n"
-      "paddw %%mm6,%%mm0\n"
-      "movq %%mm0,%%mm6\n"
-      "psrlq $16, %%mm0\n"
-      "paddw %%mm6,%%mm0\n"
-      "movd %%mm0,%2\n"
-      : "+r" (pix1), "+r" (pix2), "=r"(tmp)
-      : "r" ((x86_reg)line_size) , "m" (h)
-      : "%ecx");
+    assert((((int) pix1) & 7) == 0);
+    assert((((int) pix2) & 7) == 0);
+    assert((line_size & 7) == 0);
+
+#define SUM(in0, in1, out0, out1)       \
+    "movq (%0), %%mm2\n"                \
+    "movq (%1), " #out0 "\n"            \
+    "movq 8(%0), %%mm3\n"               \
+    "movq 8(%1), " #out1 "\n"           \
+    "add %3, %0\n"                      \
+    "add %3, %1\n"                      \
+    "psubb " #out0 ", %%mm2\n"          \
+    "psubb " #out1 ", %%mm3\n"          \
+    "pxor %%mm7, %%mm2\n"               \
+    "pxor %%mm7, %%mm3\n"               \
+    "movq %%mm2, " #out0 "\n"           \
+    "movq %%mm3, " #out1 "\n"           \
+    "psubusb " #in0 ", %%mm2\n"         \
+    "psubusb " #in1 ", %%mm3\n"         \
+    "psubusb " #out0 ", " #in0 "\n"     \
+    "psubusb " #out1 ", " #in1 "\n"     \
+    "por %%mm2, " #in0 "\n"             \
+    "por %%mm3, " #in1 "\n"             \
+    "movq " #in0 ", %%mm2\n"            \
+    "movq " #in1 ", %%mm3\n"            \
+    "punpcklbw %%mm7, " #in0 "\n"       \
+    "punpcklbw %%mm7, " #in1 "\n"       \
+    "punpckhbw %%mm7, %%mm2\n"          \
+    "punpckhbw %%mm7, %%mm3\n"          \
+    "paddw " #in1 ", " #in0 "\n"        \
+    "paddw %%mm3, %%mm2\n"              \
+    "paddw %%mm2, " #in0 "\n"           \
+    "paddw " #in0 ", %%mm6\n"
+
+
+    __asm__ volatile (
+        "movl %4, %%ecx\n"
+        "pxor %%mm6, %%mm6\n"
+        "pcmpeqw %%mm7, %%mm7\n"
+        "psllw $15, %%mm7\n"
+        "packsswb %%mm7, %%mm7\n"
+        "movq (%0), %%mm0\n"
+        "movq (%1), %%mm2\n"
+        "movq 8(%0), %%mm1\n"
+        "movq 8(%1), %%mm3\n"
+        "add %3, %0\n"
+        "add %3, %1\n"
+        "psubb %%mm2, %%mm0\n"
+        "psubb %%mm3, %%mm1\n"
+        "pxor %%mm7, %%mm0\n"
+        "pxor %%mm7, %%mm1\n"
+        "jmp 2f\n"
+        "1:\n"
+
+        SUM(%%mm4, %%mm5, %%mm0, %%mm1)
+        "2:\n"
+        SUM(%%mm0, %%mm1, %%mm4, %%mm5)
+
+        "subl $2, %%ecx\n"
+        "jnz 1b\n"
+
+        "movq %%mm6, %%mm0\n"
+        "psrlq $32, %%mm6\n"
+        "paddw %%mm6, %%mm0\n"
+        "movq %%mm0, %%mm6\n"
+        "psrlq $16, %%mm0\n"
+        "paddw %%mm6, %%mm0\n"
+        "movd %%mm0, %2\n"
+        : "+r" (pix1), "+r" (pix2), "=r" (tmp)
+        : "r" ((x86_reg) line_size), "m" (h)
+        : "%ecx");
+
     return tmp & 0x7FFF;
 }
 #undef SUM
@@ -607,63 +640,66 @@ static int vsad16_mmxext(void *v, uint8_t *pix1, uint8_t *pix2,
 {
     int tmp;
 
-    assert( (((int)pix1) & 7) == 0);
-    assert( (((int)pix2) & 7) == 0);
-    assert((line_size &7) ==0);
-
-#define SUM(in0, in1, out0, out1) \
-      "movq (%0)," #out0 "\n"\
-      "movq (%1),%%mm2\n"\
-      "movq 8(%0)," #out1 "\n"\
-      "movq 8(%1),%%mm3\n"\
-      "add %3,%0\n"\
-      "add %3,%1\n"\
-      "psubb %%mm2, " #out0 "\n"\
-      "psubb %%mm3, " #out1 "\n"\
-      "pxor %%mm7, " #out0 "\n"\
-      "pxor %%mm7, " #out1 "\n"\
-      "psadbw " #out0 ", " #in0 "\n"\
-      "psadbw " #out1 ", " #in1 "\n"\
-      "paddw " #in1 ", " #in0 "\n"\
-      "paddw " #in0 ", %%mm6\n"
-
-  __asm__ volatile (
-      "movl %4,%%ecx\n"
-      "pxor %%mm6,%%mm6\n"
-      "pcmpeqw %%mm7,%%mm7\n"
-      "psllw $15, %%mm7\n"
-      "packsswb %%mm7, %%mm7\n"
-      "movq (%0),%%mm0\n"
-      "movq (%1),%%mm2\n"
-      "movq 8(%0),%%mm1\n"
-      "movq 8(%1),%%mm3\n"
-      "add %3,%0\n"
-      "add %3,%1\n"
-      "psubb %%mm2, %%mm0\n"
-      "psubb %%mm3, %%mm1\n"
-      "pxor %%mm7, %%mm0\n"
-      "pxor %%mm7, %%mm1\n"
-      "jmp 2f\n"
-      "1:\n"
-
-      SUM(%%mm4, %%mm5, %%mm0, %%mm1)
-      "2:\n"
-      SUM(%%mm0, %%mm1, %%mm4, %%mm5)
-
-      "subl $2, %%ecx\n"
-      "jnz 1b\n"
-
-      "movd %%mm6,%2\n"
-      : "+r" (pix1), "+r" (pix2), "=r"(tmp)
-      : "r" ((x86_reg)line_size) , "m" (h)
-      : "%ecx");
+    assert((((int) pix1) & 7) == 0);
+    assert((((int) pix2) & 7) == 0);
+    assert((line_size & 7) == 0);
+
+#define SUM(in0, in1, out0, out1)               \
+    "movq (%0), " #out0 "\n"                    \
+    "movq (%1), %%mm2\n"                        \
+    "movq 8(%0), " #out1 "\n"                   \
+    "movq 8(%1), %%mm3\n"                       \
+    "add %3, %0\n"                              \
+    "add %3, %1\n"                              \
+    "psubb %%mm2, " #out0 "\n"                  \
+    "psubb %%mm3, " #out1 "\n"                  \
+    "pxor %%mm7, " #out0 "\n"                   \
+    "pxor %%mm7, " #out1 "\n"                   \
+    "psadbw " #out0 ", " #in0 "\n"              \
+    "psadbw " #out1 ", " #in1 "\n"              \
+    "paddw " #in1 ", " #in0 "\n"                \
+    "paddw " #in0 ", %%mm6\n    "
+
+    __asm__ volatile (
+        "movl %4, %%ecx\n"
+        "pxor %%mm6, %%mm6\n"
+        "pcmpeqw %%mm7, %%mm7\n"
+        "psllw $15, %%mm7\n"
+        "packsswb %%mm7, %%mm7\n"
+        "movq (%0), %%mm0\n"
+        "movq (%1), %%mm2\n"
+        "movq 8(%0), %%mm1\n"
+        "movq 8(%1), %%mm3\n"
+        "add %3, %0\n"
+        "add %3, %1\n"
+        "psubb %%mm2, %%mm0\n"
+        "psubb %%mm3, %%mm1\n"
+        "pxor %%mm7, %%mm0\n"
+        "pxor %%mm7, %%mm1\n"
+        "jmp 2f\n"
+        "1:\n"
+
+        SUM(%%mm4, %%mm5, %%mm0, %%mm1)
+        "2:\n"
+        SUM(%%mm0, %%mm1, %%mm4, %%mm5)
+
+        "subl $2, %%ecx\n"
+        "jnz 1b\n"
+
+        "movd %%mm6, %2\n"
+        : "+r" (pix1), "+r" (pix2), "=r" (tmp)
+        : "r" ((x86_reg) line_size), "m" (h)
+        : "%ecx");
+
     return tmp;
 }
 #undef SUM
 
-static void diff_bytes_mmx(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
-    x86_reg i=0;
-    __asm__ volatile(
+static void diff_bytes_mmx(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w)
+{
+    x86_reg i = 0;
+
+    __asm__ volatile (
         "1:                             \n\t"
         "movq  (%2, %0), %%mm0          \n\t"
         "movq  (%1, %0), %%mm1          \n\t"
@@ -677,20 +713,20 @@ static void diff_bytes_mmx(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
         "cmp %4, %0                     \n\t"
         " jb 1b                         \n\t"
         : "+r" (i)
-        : "r"(src1), "r"(src2), "r"(dst), "r"((x86_reg)w-15)
-    );
-    for(; i<w; i++)
-        dst[i+0] = src1[i+0]-src2[i+0];
+        : "r" (src1), "r" (src2), "r" (dst), "r" ((x86_reg) w - 15));
+
+    for (; i < w; i++)
+        dst[i + 0] = src1[i + 0] - src2[i + 0];
 }
 
 static void sub_hfyu_median_prediction_mmxext(uint8_t *dst, const uint8_t *src1,
                                               const uint8_t *src2, int w,
                                               int *left, int *left_top)
 {
-    x86_reg i=0;
+    x86_reg i = 0;
     uint8_t l, lt;
 
-    __asm__ volatile(
+    __asm__ volatile (
         "movq  (%1, %0), %%mm0          \n\t" // LT
         "psllq $8, %%mm0                \n\t"
         "1:                             \n\t"
@@ -712,139 +748,142 @@ static void sub_hfyu_median_prediction_mmxext(uint8_t *dst, const uint8_t *src1,
         "cmp %4, %0                     \n\t"
         " jb 1b                         \n\t"
         : "+r" (i)
-        : "r"(src1), "r"(src2), "r"(dst), "r"((x86_reg)w)
-    );
+        : "r" (src1), "r" (src2), "r" (dst), "r" ((x86_reg) w));
 
-    l= *left;
-    lt= *left_top;
+    l  = *left;
+    lt = *left_top;
 
-    dst[0]= src2[0] - mid_pred(l, src1[0], (l + src1[0] - lt)&0xFF);
+    dst[0] = src2[0] - mid_pred(l, src1[0], (l + src1[0] - lt) & 0xFF);
 
-    *left_top= src1[w-1];
-    *left    = src2[w-1];
+    *left_top = src1[w - 1];
+    *left     = src2[w - 1];
 }
 
-#define MMABS_MMX(a,z)\
-    "pxor " #z ", " #z "              \n\t"\
-    "pcmpgtw " #a ", " #z "           \n\t"\
-    "pxor " #z ", " #a "              \n\t"\
-    "psubw " #z ", " #a "             \n\t"
-
-#define MMABS_MMXEXT(a, z)                 \
-    "pxor " #z ", " #z "              \n\t"\
-    "psubw " #a ", " #z "             \n\t"\
-    "pmaxsw " #z ", " #a "            \n\t"
-
-#define MMABS_SSSE3(a,z)\
-    "pabsw " #a ", " #a "             \n\t"
-
-#define MMABS_SUM(a,z, sum)\
-    MMABS(a,z)\
-    "paddusw " #a ", " #sum "         \n\t"
-
-/* FIXME: HSUM_* saturates at 64k, while an 8x8 hadamard or dct block can get up to
- * about 100k on extreme inputs. But that's very unlikely to occur in natural video,
- * and it's even more unlikely to not have any alternative mvs/modes with lower cost. */
-#define HSUM_MMX(a, t, dst)\
-    "movq "#a", "#t"                  \n\t"\
-    "psrlq $32, "#a"                  \n\t"\
-    "paddusw "#t", "#a"               \n\t"\
-    "movq "#a", "#t"                  \n\t"\
-    "psrlq $16, "#a"                  \n\t"\
-    "paddusw "#t", "#a"               \n\t"\
-    "movd "#a", "#dst"                \n\t"\
-
-#define HSUM_MMXEXT(a, t, dst)             \
-    "pshufw $0x0E, "#a", "#t"         \n\t"\
-    "paddusw "#t", "#a"               \n\t"\
-    "pshufw $0x01, "#a", "#t"         \n\t"\
-    "paddusw "#t", "#a"               \n\t"\
-    "movd "#a", "#dst"                \n\t"\
-
-#define HSUM_SSE2(a, t, dst)\
-    "movhlps "#a", "#t"               \n\t"\
-    "paddusw "#t", "#a"               \n\t"\
-    "pshuflw $0x0E, "#a", "#t"        \n\t"\
-    "paddusw "#t", "#a"               \n\t"\
-    "pshuflw $0x01, "#a", "#t"        \n\t"\
-    "paddusw "#t", "#a"               \n\t"\
-    "movd "#a", "#dst"                \n\t"\
-
-#define DCT_SAD4(m,mm,o)\
-    "mov"#m" "#o"+ 0(%1), "#mm"2      \n\t"\
-    "mov"#m" "#o"+16(%1), "#mm"3      \n\t"\
-    "mov"#m" "#o"+32(%1), "#mm"4      \n\t"\
-    "mov"#m" "#o"+48(%1), "#mm"5      \n\t"\
-    MMABS_SUM(mm##2, mm##6, mm##0)\
-    MMABS_SUM(mm##3, mm##7, mm##1)\
-    MMABS_SUM(mm##4, mm##6, mm##0)\
-    MMABS_SUM(mm##5, mm##7, mm##1)\
-
-#define DCT_SAD_MMX\
-    "pxor %%mm0, %%mm0                \n\t"\
-    "pxor %%mm1, %%mm1                \n\t"\
-    DCT_SAD4(q, %%mm, 0)\
-    DCT_SAD4(q, %%mm, 8)\
-    DCT_SAD4(q, %%mm, 64)\
-    DCT_SAD4(q, %%mm, 72)\
-    "paddusw %%mm1, %%mm0             \n\t"\
+#define MMABS_MMX(a,z)                          \
+    "pxor "    #z ", " #z "             \n\t"   \
+    "pcmpgtw " #a ", " #z "             \n\t"   \
+    "pxor "    #z ", " #a "             \n\t"   \
+    "psubw "   #z ", " #a "             \n\t"
+
+#define MMABS_MMXEXT(a, z)                      \
+    "pxor "    #z ", " #z "             \n\t"   \
+    "psubw "   #a ", " #z "             \n\t"   \
+    "pmaxsw "  #z ", " #a "             \n\t"
+
+#define MMABS_SSSE3(a,z)                        \
+    "pabsw "   #a ", " #a "             \n\t"
+
+#define MMABS_SUM(a,z, sum)                     \
+    MMABS(a,z)                                  \
+    "paddusw " #a ", " #sum "           \n\t"
+
+/* FIXME: HSUM_* saturates at 64k, while an 8x8 hadamard or dct block can get
+ * up to about 100k on extreme inputs. But that's very unlikely to occur in
+ * natural video, and it's even more unlikely to not have any alternative
+ * mvs/modes with lower cost. */
+#define HSUM_MMX(a, t, dst)                     \
+    "movq    " #a ", " #t "             \n\t"   \
+    "psrlq      $32, " #a "             \n\t"   \
+    "paddusw " #t ", " #a "             \n\t"   \
+    "movq    " #a ", " #t "             \n\t"   \
+    "psrlq      $16, " #a "             \n\t"   \
+    "paddusw " #t ", " #a "             \n\t"   \
+    "movd    " #a ", " #dst "           \n\t"   \
+
+#define HSUM_MMXEXT(a, t, dst)                  \
+    "pshufw   $0x0E, " #a ", " #t "     \n\t"   \
+    "paddusw " #t ", " #a "             \n\t"   \
+    "pshufw   $0x01, " #a ", " #t "     \n\t"   \
+    "paddusw " #t ", " #a "             \n\t"   \
+    "movd    " #a ", " #dst "           \n\t"   \
+
+#define HSUM_SSE2(a, t, dst)                    \
+    "movhlps " #a ", " #t "             \n\t"   \
+    "paddusw " #t ", " #a "             \n\t"   \
+    "pshuflw  $0x0E, " #a ", " #t "     \n\t"   \
+    "paddusw " #t ", " #a "             \n\t"   \
+    "pshuflw  $0x01, " #a ", " #t "     \n\t"   \
+    "paddusw " #t ", " #a "             \n\t"   \
+    "movd    " #a ", " #dst "           \n\t"   \
+
+#define DCT_SAD4(m, mm, o)                      \
+    "mov"#m" "#o" +  0(%1), " #mm "2    \n\t"   \
+    "mov"#m" "#o" + 16(%1), " #mm "3    \n\t"   \
+    "mov"#m" "#o" + 32(%1), " #mm "4    \n\t"   \
+    "mov"#m" "#o" + 48(%1), " #mm "5    \n\t"   \
+    MMABS_SUM(mm ## 2, mm ## 6, mm ## 0)        \
+    MMABS_SUM(mm ## 3, mm ## 7, mm ## 1)        \
+    MMABS_SUM(mm ## 4, mm ## 6, mm ## 0)        \
+    MMABS_SUM(mm ## 5, mm ## 7, mm ## 1)        \
+
+#define DCT_SAD_MMX                             \
+    "pxor    %%mm0, %%mm0               \n\t"   \
+    "pxor    %%mm1, %%mm1               \n\t"   \
+    DCT_SAD4(q, %%mm, 0)                        \
+    DCT_SAD4(q, %%mm, 8)                        \
+    DCT_SAD4(q, %%mm, 64)                       \
+    DCT_SAD4(q, %%mm, 72)                       \
+    "paddusw %%mm1, %%mm0               \n\t"   \
     HSUM(%%mm0, %%mm1, %0)
 
-#define DCT_SAD_SSE2\
-    "pxor %%xmm0, %%xmm0              \n\t"\
-    "pxor %%xmm1, %%xmm1              \n\t"\
-    DCT_SAD4(dqa, %%xmm, 0)\
-    DCT_SAD4(dqa, %%xmm, 64)\
-    "paddusw %%xmm1, %%xmm0           \n\t"\
+#define DCT_SAD_SSE2                            \
+    "pxor    %%xmm0, %%xmm0             \n\t"   \
+    "pxor    %%xmm1, %%xmm1             \n\t"   \
+    DCT_SAD4(dqa, %%xmm, 0)                     \
+    DCT_SAD4(dqa, %%xmm, 64)                    \
+    "paddusw %%xmm1, %%xmm0             \n\t"   \
     HSUM(%%xmm0, %%xmm1, %0)
 
-#define DCT_SAD_FUNC(cpu) \
-static int sum_abs_dctelem_##cpu(int16_t *block){\
-    int sum;\
-    __asm__ volatile(\
-        DCT_SAD\
-        :"=r"(sum)\
-        :"r"(block)\
-    );\
-    return sum&0xFFFF;\
+#define DCT_SAD_FUNC(cpu)                           \
+static int sum_abs_dctelem_ ## cpu(int16_t *block)  \
+{                                                   \
+    int sum;                                        \
+    __asm__ volatile (                              \
+        DCT_SAD                                     \
+        :"=r"(sum)                                  \
+        :"r"(block));                               \
+    return sum & 0xFFFF;                            \
 }
 
-#define DCT_SAD       DCT_SAD_MMX
-#define HSUM(a,t,dst) HSUM_MMX(a,t,dst)
-#define MMABS(a,z)    MMABS_MMX(a,z)
+#define DCT_SAD         DCT_SAD_MMX
+#define HSUM(a, t, dst) HSUM_MMX(a, t, dst)
+#define MMABS(a, z)     MMABS_MMX(a, z)
 DCT_SAD_FUNC(mmx)
 #undef MMABS
 #undef HSUM
 
-#define HSUM(a,t,dst) HSUM_MMXEXT(a,t,dst)
-#define MMABS(a,z)    MMABS_MMXEXT(a,z)
+#define HSUM(a, t, dst) HSUM_MMXEXT(a, t, dst)
+#define MMABS(a, z)     MMABS_MMXEXT(a, z)
 DCT_SAD_FUNC(mmxext)
 #undef HSUM
 #undef DCT_SAD
 
-#define DCT_SAD       DCT_SAD_SSE2
-#define HSUM(a,t,dst) HSUM_SSE2(a,t,dst)
+#define DCT_SAD         DCT_SAD_SSE2
+#define HSUM(a, t, dst) HSUM_SSE2(a, t, dst)
 DCT_SAD_FUNC(sse2)
 #undef MMABS
 
 #if HAVE_SSSE3_INLINE
-#define MMABS(a,z)    MMABS_SSSE3(a,z)
+#define MMABS(a, z)     MMABS_SSSE3(a, z)
 DCT_SAD_FUNC(ssse3)
 #undef MMABS
 #endif
 #undef HSUM
 #undef DCT_SAD
 
-static int ssd_int8_vs_int16_mmx(const int8_t *pix1, const int16_t *pix2, int size){
+static int ssd_int8_vs_int16_mmx(const int8_t *pix1, const int16_t *pix2,
+                                 int size)
+{
     int sum;
-    x86_reg i=size;
-    __asm__ volatile(
+    x86_reg i = size;
+
+    __asm__ volatile (
         "pxor %%mm4, %%mm4 \n"
         "1: \n"
         "sub $8, %0 \n"
-        "movq (%2,%0), %%mm2 \n"
-        "movq (%3,%0,2), %%mm0 \n"
-        "movq 8(%3,%0,2), %%mm1 \n"
+        "movq (%2, %0), %%mm2 \n"
+        "movq (%3, %0, 2), %%mm0 \n"
+        "movq 8(%3, %0, 2), %%mm1 \n"
         "punpckhbw %%mm2, %%mm3 \n"
         "punpcklbw %%mm2, %%mm2 \n"
         "psraw $8, %%mm3 \n"
@@ -860,28 +899,29 @@ static int ssd_int8_vs_int16_mmx(const int8_t *pix1, const int16_t *pix2, int si
         "psrlq $32, %%mm3 \n"
         "paddd %%mm3, %%mm4 \n"
         "movd %%mm4, %1 \n"
-        :"+r"(i), "=r"(sum)
-        :"r"(pix1), "r"(pix2)
-    );
+        : "+r" (i), "=r" (sum)
+        : "r" (pix1), "r" (pix2));
+
     return sum;
 }
 
-#define PHADDD(a, t)\
-    "movq "#a", "#t"                  \n\t"\
-    "psrlq $32, "#a"                  \n\t"\
-    "paddd "#t", "#a"                 \n\t"
+#define PHADDD(a, t)                            \
+    "movq  " #a ", " #t "               \n\t"   \
+    "psrlq    $32, " #a "               \n\t"   \
+    "paddd " #t ", " #a "               \n\t"
+
 /*
-   pmulhw: dst[0-15]=(src[0-15]*dst[0-15])[16-31]
-   pmulhrw: dst[0-15]=(src[0-15]*dst[0-15] + 0x8000)[16-31]
-   pmulhrsw: dst[0-15]=(src[0-15]*dst[0-15] + 0x4000)[15-30]
+ * pmulhw:   dst[0 - 15] = (src[0 - 15] * dst[0 - 15])[16 - 31]
+ * pmulhrw:  dst[0 - 15] = (src[0 - 15] * dst[0 - 15] + 0x8000)[16 - 31]
+ * pmulhrsw: dst[0 - 15] = (src[0 - 15] * dst[0 - 15] + 0x4000)[15 - 30]
  */
-#define PMULHRW(x, y, s, o)\
-    "pmulhw " #s ", "#x "            \n\t"\
-    "pmulhw " #s ", "#y "            \n\t"\
-    "paddw " #o ", "#x "             \n\t"\
-    "paddw " #o ", "#y "             \n\t"\
-    "psraw $1, "#x "                 \n\t"\
-    "psraw $1, "#y "                 \n\t"
+#define PMULHRW(x, y, s, o)                     \
+    "pmulhw " #s ", " #x "              \n\t"   \
+    "pmulhw " #s ", " #y "              \n\t"   \
+    "paddw  " #o ", " #x "              \n\t"   \
+    "paddw  " #o ", " #y "              \n\t"   \
+    "psraw      $1, " #x "              \n\t"   \
+    "psraw      $1, " #y "              \n\t"
 #define DEF(x) x ## _mmx
 #define SET_RND MOVQ_WONE
 #define SCALE_OFFSET 1
@@ -896,9 +936,9 @@ static int ssd_int8_vs_int16_mmx(const int8_t *pix1, const int16_t *pix2, int si
 #define DEF(x) x ## _3dnow
 #define SET_RND(x)
 #define SCALE_OFFSET 0
-#define PMULHRW(x, y, s, o)\
-    "pmulhrw " #s ", "#x "           \n\t"\
-    "pmulhrw " #s ", "#y "           \n\t"
+#define PMULHRW(x, y, s, o)                     \
+    "pmulhrw " #s ", " #x "             \n\t"   \
+    "pmulhrw " #s ", " #y "             \n\t"
 
 #include "dsputil_qns_template.c"
 
@@ -912,12 +952,15 @@ static int ssd_int8_vs_int16_mmx(const int8_t *pix1, const int16_t *pix2, int si
 #define DEF(x) x ## _ssse3
 #define SET_RND(x)
 #define SCALE_OFFSET -1
-#define PHADDD(a, t)\
-    "pshufw $0x0E, "#a", "#t"         \n\t"\
-    "paddd "#t", "#a"                 \n\t" /* faster than phaddd on core2 */
-#define PMULHRW(x, y, s, o)\
-    "pmulhrsw " #s ", "#x "          \n\t"\
-    "pmulhrsw " #s ", "#y "          \n\t"
+
+#define PHADDD(a, t)                            \
+    "pshufw $0x0E, " #a ", " #t "       \n\t"   \
+    /* faster than phaddd on core2 */           \
+    "paddd " #t ", " #a "               \n\t"
+
+#define PMULHRW(x, y, s, o)                     \
+    "pmulhrsw " #s ", " #x "            \n\t"   \
+    "pmulhrsw " #s ", " #y "            \n\t"
 
 #include "dsputil_qns_template.c"
 
@@ -930,13 +973,13 @@ static int ssd_int8_vs_int16_mmx(const int8_t *pix1, const int16_t *pix2, int si
 
 #endif /* HAVE_INLINE_ASM */
 
-int ff_sse16_sse2(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h);
+int ff_sse16_sse2(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h);
 
-#define hadamard_func(cpu) \
-int ff_hadamard8_diff_##cpu  (void *s, uint8_t *src1, uint8_t *src2, \
-                              int stride, int h); \
-int ff_hadamard8_diff16_##cpu(void *s, uint8_t *src1, uint8_t *src2, \
-                              int stride, int h);
+#define hadamard_func(cpu)                                              \
+int ff_hadamard8_diff_ ## cpu(void *s, uint8_t *src1, uint8_t *src2,    \
+                              int stride, int h);                       \
+int ff_hadamard8_diff16_ ## cpu(void *s, uint8_t *src1, uint8_t *src2,  \
+                                int stride, int h);
 
 hadamard_func(mmx)
 hadamard_func(mmxext)
@@ -955,10 +998,10 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx)
         if (bit_depth <= 8)
             c->get_pixels = ff_get_pixels_mmx;
         c->diff_pixels = ff_diff_pixels_mmx;
-        c->pix_sum = ff_pix_sum16_mmx;
-
-        c->pix_norm1 = ff_pix_norm1_mmx;
+        c->pix_sum     = ff_pix_sum16_mmx;
+        c->pix_norm1   = ff_pix_norm1_mmx;
     }
+
     if (EXTERNAL_SSE2(cpu_flags))
         if (bit_depth <= 8)
             c->get_pixels = ff_get_pixels_sse2;
@@ -970,23 +1013,20 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx)
             (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX))
             c->fdct = ff_fdct_mmx;
 
-        c->diff_bytes= diff_bytes_mmx;
-        c->sum_abs_dctelem= sum_abs_dctelem_mmx;
+        c->diff_bytes      = diff_bytes_mmx;
+        c->sum_abs_dctelem = sum_abs_dctelem_mmx;
 
-        c->sse[0] = sse16_mmx;
-        c->sse[1] = sse8_mmx;
-        c->vsad[4]= vsad_intra16_mmx;
+        c->sse[0]  = sse16_mmx;
+        c->sse[1]  = sse8_mmx;
+        c->vsad[4] = vsad_intra16_mmx;
 
         c->nsse[0] = nsse16_mmx;
         c->nsse[1] = nsse8_mmx;
-        if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
-            c->vsad[0] = vsad16_mmx;
-        }
-
-        if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
-            c->try_8x8basis= try_8x8basis_mmx;
+        if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
+            c->vsad[0]      = vsad16_mmx;
+            c->try_8x8basis = try_8x8basis_mmx;
         }
-        c->add_8x8basis= add_8x8basis_mmx;
+        c->add_8x8basis = add_8x8basis_mmx;
 
         c->ssd_int8_vs_int16 = ssd_int8_vs_int16_mmx;
     }
@@ -1006,7 +1046,7 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx)
         c->sum_abs_dctelem = sum_abs_dctelem_mmxext;
         c->vsad[4]         = vsad_intra16_mmxext;
 
-        if (!(avctx->flags & CODEC_FLAG_BITEXACT)){
+        if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
             c->vsad[0] = vsad16_mmxext;
         }
 
@@ -1018,7 +1058,7 @@ av_cold void ff_dsputilenc_init_mmx(DSPContext *c, AVCodecContext *avctx)
             (dct_algo == FF_DCT_AUTO || dct_algo == FF_DCT_MMX))
             c->fdct = ff_fdct_sse2;
 
-        c->sum_abs_dctelem= sum_abs_dctelem_sse2;
+        c->sum_abs_dctelem = sum_abs_dctelem_sse2;
     }
 
 #if HAVE_SSSE3_INLINE
diff --git a/deps/libav/libavcodec/x86/fdct.c b/deps/libav/libavcodec/x86/fdct.c
index 6d595aa..6c95439 100644
--- a/deps/libav/libavcodec/x86/fdct.c
+++ b/deps/libav/libavcodec/x86/fdct.c
@@ -1,5 +1,5 @@
 /*
- * MMX optimized forward DCT
+ * SIMD-optimized forward DCT
  * The gcc porting is Copyright (c) 2001 Fabrice Bellard.
  * cleanup/optimizations are Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  * SSE2 optimization is Copyright (c) 2004 Denes Balatoni.
diff --git a/deps/libav/libavcodec/x86/fmtconvert.asm b/deps/libav/libavcodec/x86/fmtconvert.asm
index e7803df..8184376 100644
--- a/deps/libav/libavcodec/x86/fmtconvert.asm
+++ b/deps/libav/libavcodec/x86/fmtconvert.asm
@@ -31,9 +31,10 @@ SECTION_TEXT
 %endif
 %endmacro
 
-;---------------------------------------------------------------------------------
-; void int32_to_float_fmul_scalar(float *dst, const int32_t *src, float mul, int len);
-;---------------------------------------------------------------------------------
+;------------------------------------------------------------------------------
+; void ff_int32_to_float_fmul_scalar(float *dst, const int32_t *src, float mul,
+;                                    int len);
+;------------------------------------------------------------------------------
 %macro INT32_TO_FLOAT_FMUL_SCALAR 1
 %if UNIX64
 cglobal int32_to_float_fmul_scalar, 3, 3, %1, dst, src, len
@@ -243,8 +244,10 @@ FLOAT_TO_INT16_INTERLEAVE2
 INIT_XMM sse2
 FLOAT_TO_INT16_INTERLEAVE2
 
+;-----------------------------------------------------------------------------
+; void ff_float_to_int16_interleave6(int16_t *dst, const float **src, int len)
+;-----------------------------------------------------------------------------
 %macro FLOAT_TO_INT16_INTERLEAVE6 0
-; void float_to_int16_interleave6_sse(int16_t *dst, const float **src, int len)
 cglobal float_to_int16_interleave6, 2, 8, 0, dst, src, src1, src2, src3, src4, src5, len
 %if ARCH_X86_64
     mov     lend, r2d
diff --git a/deps/libav/libavcodec/x86/fpel.asm b/deps/libav/libavcodec/x86/fpel.asm
index 43b039d..b581471 100644
--- a/deps/libav/libavcodec/x86/fpel.asm
+++ b/deps/libav/libavcodec/x86/fpel.asm
@@ -1,5 +1,5 @@
 ;******************************************************************************
-;* MMX optimized DSP utils
+;* SIMD-optimized fullpel functions
 ;* Copyright (c) 2008 Loren Merritt
 ;* Copyright (c) 2003-2013 Michael Niedermayer
 ;* Copyright (c) 2013 Daniel Kang
@@ -26,7 +26,8 @@
 SECTION .text
 
 INIT_MMX mmxext
-; void pixels(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_put/avg_pixels(uint8_t *block, const uint8_t *pixels,
+;                        ptrdiff_t line_size, int h)
 %macro PIXELS48 2
 %if %2 == 4
 %define OP movh
@@ -65,7 +66,8 @@ PIXELS48 avg, 8
 
 
 INIT_XMM sse2
-; void put_pixels16_sse2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_put_pixels16_sse2(uint8_t *block, const uint8_t *pixels,
+;                           ptrdiff_t line_size, int h)
 cglobal put_pixels16, 4,5,4
     lea          r4, [r2*3]
 .loop:
@@ -83,7 +85,8 @@ cglobal put_pixels16, 4,5,4
     jnz       .loop
     REP_RET
 
-; void avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_avg_pixels16_sse2(uint8_t *block, const uint8_t *pixels,
+;                           ptrdiff_t line_size, int h)
 cglobal avg_pixels16, 4,5,4
     lea          r4, [r2*3]
 .loop:
diff --git a/deps/libav/libavcodec/x86/h263_loopfilter.asm b/deps/libav/libavcodec/x86/h263_loopfilter.asm
index a940aad..673f795 100644
--- a/deps/libav/libavcodec/x86/h263_loopfilter.asm
+++ b/deps/libav/libavcodec/x86/h263_loopfilter.asm
@@ -99,7 +99,7 @@ SECTION_TEXT
 %endmacro
 
 INIT_MMX mmx
-; void h263_v_loop_filter(uint8_t *src, int stride, int qscale)
+; void ff_h263_v_loop_filter_mmx(uint8_t *src, int stride, int qscale)
 cglobal h263_v_loop_filter, 3,5
     movsxdifnidn r1, r1d
     movsxdifnidn r2, r2d
@@ -140,7 +140,7 @@ cglobal h263_v_loop_filter, 3,5
 %endmacro
 
 
-; void h263_h_loop_filter(uint8_t *src, int stride, int qscale)
+; void ff_h263_h_loop_filter_mmx(uint8_t *src, int stride, int qscale)
 INIT_MMX mmx
 cglobal h263_h_loop_filter, 3,5,0,32
     movsxdifnidn r1, r1d
diff --git a/deps/libav/libavcodec/x86/h264_chromamc.asm b/deps/libav/libavcodec/x86/h264_chromamc.asm
index b7b18e0..cc41f00 100644
--- a/deps/libav/libavcodec/x86/h264_chromamc.asm
+++ b/deps/libav/libavcodec/x86/h264_chromamc.asm
@@ -103,8 +103,9 @@ SECTION .text
 %else
 %define extra_regs 0
 %endif ; rv40
-; put/avg_h264_chroma_mc8_*(uint8_t *dst /*align 8*/, uint8_t *src /*align 1*/,
-;                           int stride, int h, int mx, int my)
+; void ff_put/avg_h264_chroma_mc8_*(uint8_t *dst /* align 8 */,
+;                                   uint8_t *src /* align 1 */,
+;                                   int stride, int h, int mx, int my)
 cglobal %1_%2_chroma_mc8%3, 6, 7 + extra_regs, 0
 %if ARCH_X86_64
     movsxd        r2, r2d
diff --git a/deps/libav/libavcodec/x86/h264_chromamc_10bit.asm b/deps/libav/libavcodec/x86/h264_chromamc_10bit.asm
index aec7678..7b00351 100644
--- a/deps/libav/libavcodec/x86/h264_chromamc_10bit.asm
+++ b/deps/libav/libavcodec/x86/h264_chromamc_10bit.asm
@@ -57,11 +57,10 @@ SECTION .text
 %endmacro
 
 ;-----------------------------------------------------------------------------
-; void put/avg_h264_chroma_mc8(pixel *dst, pixel *src, int stride, int h, int mx, int my)
+; void ff_put/avg_h264_chroma_mc8(pixel *dst, pixel *src, int stride, int h,
+;                                 int mx, int my)
 ;-----------------------------------------------------------------------------
 %macro CHROMA_MC8 1
-; put/avg_h264_chroma_mc8_*(uint8_t *dst /*align 8*/, uint8_t *src /*align 1*/,
-;                              int stride, int h, int mx, int my)
 cglobal %1_h264_chroma_mc8_10, 6,7,8
     movsxdifnidn  r2, r2d
     mov          r6d, r5d
@@ -150,7 +149,8 @@ cglobal %1_h264_chroma_mc8_10, 6,7,8
 %endmacro
 
 ;-----------------------------------------------------------------------------
-; void put/avg_h264_chroma_mc4(pixel *dst, pixel *src, int stride, int h, int mx, int my)
+; void ff_put/avg_h264_chroma_mc4(pixel *dst, pixel *src, int stride, int h,
+;                                 int mx, int my)
 ;-----------------------------------------------------------------------------
 ;TODO: xmm mc4
 %macro MC4_OP 2
@@ -200,7 +200,8 @@ cglobal %1_h264_chroma_mc4_10, 6,6,7
 %endmacro
 
 ;-----------------------------------------------------------------------------
-; void put/avg_h264_chroma_mc2(pixel *dst, pixel *src, int stride, int h, int mx, int my)
+; void ff_put/avg_h264_chroma_mc2(pixel *dst, pixel *src, int stride, int h,
+;                                 int mx, int my)
 ;-----------------------------------------------------------------------------
 %macro CHROMA_MC2 1
 cglobal %1_h264_chroma_mc2_10, 6,7
diff --git a/deps/libav/libavcodec/x86/h264_deblock.asm b/deps/libav/libavcodec/x86/h264_deblock.asm
index 6e29ce7..8a9fdf6 100644
--- a/deps/libav/libavcodec/x86/h264_deblock.asm
+++ b/deps/libav/libavcodec/x86/h264_deblock.asm
@@ -283,7 +283,8 @@ cextern pb_3
 
 %if ARCH_X86_64
 ;-----------------------------------------------------------------------------
-; void deblock_v_luma( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 )
+; void ff_deblock_v_luma(uint8_t *pix, int stride, int alpha, int beta,
+;                        int8_t *tc0)
 ;-----------------------------------------------------------------------------
 %macro DEBLOCK_LUMA 0
 cglobal deblock_v_luma_8, 5,5,10
@@ -328,7 +329,8 @@ cglobal deblock_v_luma_8, 5,5,10
     RET
 
 ;-----------------------------------------------------------------------------
-; void deblock_h_luma( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 )
+; void ff_deblock_h_luma(uint8_t *pix, int stride, int alpha, int beta,
+;                        int8_t *tc0)
 ;-----------------------------------------------------------------------------
 INIT_MMX cpuname
 cglobal deblock_h_luma_8, 5,9,0,0x60+16*WIN64
@@ -389,7 +391,8 @@ DEBLOCK_LUMA
 
 %macro DEBLOCK_LUMA 2
 ;-----------------------------------------------------------------------------
-; void deblock_v8_luma( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 )
+; void ff_deblock_v8_luma(uint8_t *pix, int stride, int alpha, int beta,
+;                         int8_t *tc0)
 ;-----------------------------------------------------------------------------
 cglobal deblock_%1_luma_8, 5,5,8,2*%2
     lea     r4, [r1*3]
@@ -437,7 +440,8 @@ cglobal deblock_%1_luma_8, 5,5,8,2*%2
     RET
 
 ;-----------------------------------------------------------------------------
-; void deblock_h_luma( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 )
+; void ff_deblock_h_luma(uint8_t *pix, int stride, int alpha, int beta,
+;                        int8_t *tc0)
 ;-----------------------------------------------------------------------------
 INIT_MMX cpuname
 cglobal deblock_h_luma_8, 0,5,8,0x60+HAVE_ALIGNED_STACK*12
@@ -635,7 +639,7 @@ DEBLOCK_LUMA v, 16
 %endif
 
 ;-----------------------------------------------------------------------------
-; void deblock_v_luma_intra( uint8_t *pix, int stride, int alpha, int beta )
+; void ff_deblock_v_luma_intra(uint8_t *pix, int stride, int alpha, int beta)
 ;-----------------------------------------------------------------------------
 %if WIN64
 cglobal deblock_%1_luma_intra_8, 4,6,16,0x10
@@ -695,7 +699,7 @@ cglobal deblock_%1_luma_intra_8, 4,6,16,ARCH_X86_64*0x50-0x50
 INIT_MMX cpuname
 %if ARCH_X86_64
 ;-----------------------------------------------------------------------------
-; void deblock_h_luma_intra( uint8_t *pix, int stride, int alpha, int beta )
+; void ff_deblock_h_luma_intra(uint8_t *pix, int stride, int alpha, int beta)
 ;-----------------------------------------------------------------------------
 cglobal deblock_h_luma_intra_8, 4,9,0,0x80
     movsxd r7,  r1d
@@ -798,7 +802,8 @@ INIT_MMX mmxext
 %define t6 r6
 
 ;-----------------------------------------------------------------------------
-; void ff_deblock_v_chroma( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 )
+; void ff_deblock_v_chroma(uint8_t *pix, int stride, int alpha, int beta,
+;                          int8_t *tc0)
 ;-----------------------------------------------------------------------------
 cglobal deblock_v_chroma_8, 5,6
     CHROMA_V_START
@@ -812,7 +817,8 @@ cglobal deblock_v_chroma_8, 5,6
     RET
 
 ;-----------------------------------------------------------------------------
-; void ff_deblock_h_chroma( uint8_t *pix, int stride, int alpha, int beta, int8_t *tc0 )
+; void ff_deblock_h_chroma(uint8_t *pix, int stride, int alpha, int beta,
+;                          int8_t *tc0)
 ;-----------------------------------------------------------------------------
 cglobal deblock_h_chroma_8, 5,7
 %if UNIX64
@@ -864,9 +870,9 @@ ff_chroma_inter_body_mmxext:
 %define t5 r4
 %define t6 r5
 
-;-----------------------------------------------------------------------------
-; void ff_deblock_v_chroma_intra( uint8_t *pix, int stride, int alpha, int beta )
-;-----------------------------------------------------------------------------
+;------------------------------------------------------------------------------
+; void ff_deblock_v_chroma_intra(uint8_t *pix, int stride, int alpha, int beta)
+;------------------------------------------------------------------------------
 cglobal deblock_v_chroma_intra_8, 4,5
     CHROMA_V_START
     movq  m0, [t5]
@@ -878,9 +884,9 @@ cglobal deblock_v_chroma_intra_8, 4,5
     movq  [r0], m2
     RET
 
-;-----------------------------------------------------------------------------
-; void ff_deblock_h_chroma_intra( uint8_t *pix, int stride, int alpha, int beta )
-;-----------------------------------------------------------------------------
+;------------------------------------------------------------------------------
+; void ff_deblock_h_chroma_intra(uint8_t *pix, int stride, int alpha, int beta)
+;------------------------------------------------------------------------------
 cglobal deblock_h_chroma_intra_8, 4,6
     CHROMA_H_START
     TRANSPOSE4x8_LOAD  bw, wd, dq, PASS8ROWS(t5, r0, r1, t6)
@@ -904,10 +910,10 @@ ff_chroma_intra_body_mmxext:
     ret
 
 ;-----------------------------------------------------------------------------
-; void h264_loop_filter_strength(int16_t bs[2][4][4], uint8_t nnz[40],
-;                                int8_t ref[2][40], int16_t mv[2][40][2],
-;                                int bidir,    int edges,    int step,
-;                                int mask_mv0, int mask_mv1, int field);
+; void ff_h264_loop_filter_strength(int16_t bs[2][4][4], uint8_t nnz[40],
+;                                   int8_t ref[2][40], int16_t mv[2][40][2],
+;                                   int bidir,    int edges,    int step,
+;                                   int mask_mv0, int mask_mv1, int field);
 ;
 ; bidir    is 0 or 1
 ; edges    is 1 or 4
diff --git a/deps/libav/libavcodec/x86/h264_deblock_10bit.asm b/deps/libav/libavcodec/x86/h264_deblock_10bit.asm
index 3b81ef6..7242cb6 100644
--- a/deps/libav/libavcodec/x86/h264_deblock_10bit.asm
+++ b/deps/libav/libavcodec/x86/h264_deblock_10bit.asm
@@ -152,7 +152,8 @@ cextern pw_4
 
 %macro DEBLOCK_LUMA 0
 ;-----------------------------------------------------------------------------
-; void deblock_v_luma( uint16_t *pix, int stride, int alpha, int beta, int8_t *tc0 )
+; void ff_deblock_v_luma_10(uint16_t *pix, int stride, int alpha, int beta,
+;                           int8_t *tc0)
 ;-----------------------------------------------------------------------------
 cglobal deblock_v_luma_10, 5,5,8*(mmsize/16)
     %assign pad 5*mmsize+12-(stack_offset&15)
@@ -598,7 +599,8 @@ DEBLOCK_LUMA_64
 
 %if ARCH_X86_64
 ;-----------------------------------------------------------------------------
-; void deblock_v_luma_intra( uint16_t *pix, int stride, int alpha, int beta )
+; void ff_deblock_v_luma_intra_10(uint16_t *pix, int stride, int alpha,
+;                                 int beta)
 ;-----------------------------------------------------------------------------
 %macro DEBLOCK_LUMA_INTRA_64 0
 cglobal deblock_v_luma_intra_10, 4,7,16
@@ -649,7 +651,8 @@ cglobal deblock_v_luma_intra_10, 4,7,16
     REP_RET
 
 ;-----------------------------------------------------------------------------
-; void deblock_h_luma_intra( uint16_t *pix, int stride, int alpha, int beta )
+; void ff_deblock_h_luma_intra_10(uint16_t *pix, int stride, int alpha,
+;                                 int beta)
 ;-----------------------------------------------------------------------------
 cglobal deblock_h_luma_intra_10, 4,7,16
     %define t0 m15
@@ -719,7 +722,8 @@ DEBLOCK_LUMA_INTRA_64
 
 %macro DEBLOCK_LUMA_INTRA 0
 ;-----------------------------------------------------------------------------
-; void deblock_v_luma_intra( uint16_t *pix, int stride, int alpha, int beta )
+; void ff_deblock_v_luma_intra_10(uint16_t *pix, int stride, int alpha,
+;                                 int beta)
 ;-----------------------------------------------------------------------------
 cglobal deblock_v_luma_intra_10, 4,7,8*(mmsize/16)
     LUMA_INTRA_INIT 3
@@ -747,7 +751,8 @@ cglobal deblock_v_luma_intra_10, 4,7,8*(mmsize/16)
     RET
 
 ;-----------------------------------------------------------------------------
-; void deblock_h_luma_intra( uint16_t *pix, int stride, int alpha, int beta )
+; void ff_deblock_h_luma_intra_10(uint16_t *pix, int stride, int alpha,
+;                                 int beta)
 ;-----------------------------------------------------------------------------
 cglobal deblock_h_luma_intra_10, 4,7,8*(mmsize/16)
     LUMA_INTRA_INIT 8
@@ -843,7 +848,8 @@ DEBLOCK_LUMA_INTRA
 
 %macro DEBLOCK_CHROMA 0
 ;-----------------------------------------------------------------------------
-; void deblock_v_chroma( uint16_t *pix, int stride, int alpha, int beta, int8_t *tc0 )
+; void ff_deblock_v_chroma_10(uint16_t *pix, int stride, int alpha, int beta,
+;                             int8_t *tc0)
 ;-----------------------------------------------------------------------------
 cglobal deblock_v_chroma_10, 5,7-(mmsize/16),8*(mmsize/16)
     mov         r5, r0
@@ -877,7 +883,8 @@ cglobal deblock_v_chroma_10, 5,7-(mmsize/16),8*(mmsize/16)
 %endif
 
 ;-----------------------------------------------------------------------------
-; void deblock_v_chroma_intra( uint16_t *pix, int stride, int alpha, int beta )
+; void ff_deblock_v_chroma_intra_10(uint16_t *pix, int stride, int alpha,
+;                                   int beta)
 ;-----------------------------------------------------------------------------
 cglobal deblock_v_chroma_intra_10, 4,6-(mmsize/16),8*(mmsize/16)
     mov         r4, r0
diff --git a/deps/libav/libavcodec/x86/h264_idct.asm b/deps/libav/libavcodec/x86/h264_idct.asm
index 2771291..313791a 100644
--- a/deps/libav/libavcodec/x86/h264_idct.asm
+++ b/deps/libav/libavcodec/x86/h264_idct.asm
@@ -80,7 +80,7 @@ SECTION .text
 %endmacro
 
 INIT_MMX mmx
-; ff_h264_idct_add_8_mmx(uint8_t *dst, int16_t *block, int stride)
+; void ff_h264_idct_add_8_mmx(uint8_t *dst, int16_t *block, int stride)
 cglobal h264_idct_add_8, 3, 3, 0
     IDCT4_ADD    r0, r1, r2
     RET
@@ -202,7 +202,7 @@ cglobal h264_idct_add_8, 3, 3, 0
 %endmacro
 
 INIT_MMX mmx
-; ff_h264_idct8_add_8_mmx(uint8_t *dst, int16_t *block, int stride)
+; void ff_h264_idct8_add_8_mmx(uint8_t *dst, int16_t *block, int stride)
 cglobal h264_idct8_add_8, 3, 4, 0
     %assign pad 128+4-(stack_offset&7)
     SUB         rsp, pad
@@ -270,7 +270,7 @@ cglobal h264_idct8_add_8, 3, 4, 0
 %endmacro
 
 INIT_XMM sse2
-; ff_h264_idct8_add_8_sse2(uint8_t *dst, int16_t *block, int stride)
+; void ff_h264_idct8_add_8_sse2(uint8_t *dst, int16_t *block, int stride)
 cglobal h264_idct8_add_8, 3, 4, 10
     IDCT8_ADD_SSE r0, r1, r2, r3
     RET
@@ -307,7 +307,7 @@ cglobal h264_idct8_add_8, 3, 4, 10
 %endmacro
 
 INIT_MMX mmxext
-; ff_h264_idct_dc_add_8_mmxext(uint8_t *dst, int16_t *block, int stride)
+; void ff_h264_idct_dc_add_8_mmxext(uint8_t *dst, int16_t *block, int stride)
 %if ARCH_X86_64
 cglobal h264_idct_dc_add_8, 3, 4, 0
     movsx        r3, word [r1]
@@ -316,7 +316,7 @@ cglobal h264_idct_dc_add_8, 3, 4, 0
     DC_ADD_MMXEXT_OP movh, r0, r2, r3
     RET
 
-; ff_h264_idct8_dc_add_8_mmxext(uint8_t *dst, int16_t *block, int stride)
+; void ff_h264_idct8_dc_add_8_mmxext(uint8_t *dst, int16_t *block, int stride)
 cglobal h264_idct8_dc_add_8, 3, 4, 0
     movsx        r3, word [r1]
     mov  dword [r1], 0
@@ -326,7 +326,7 @@ cglobal h264_idct8_dc_add_8, 3, 4, 0
     DC_ADD_MMXEXT_OP mova, r0, r2, r3
     RET
 %else
-; ff_h264_idct_dc_add_8_mmxext(uint8_t *dst, int16_t *block, int stride)
+; void ff_h264_idct_dc_add_8_mmxext(uint8_t *dst, int16_t *block, int stride)
 cglobal h264_idct_dc_add_8, 2, 3, 0
     movsx        r2, word [r1]
     mov  dword [r1], 0
@@ -335,7 +335,7 @@ cglobal h264_idct_dc_add_8, 2, 3, 0
     DC_ADD_MMXEXT_OP movh, r0, r1, r2
     RET
 
-; ff_h264_idct8_dc_add_8_mmxext(uint8_t *dst, int16_t *block, int stride)
+; void ff_h264_idct8_dc_add_8_mmxext(uint8_t *dst, int16_t *block, int stride)
 cglobal h264_idct8_dc_add_8, 2, 3, 0
     movsx        r2, word [r1]
     mov  dword [r1], 0
@@ -348,9 +348,9 @@ cglobal h264_idct8_dc_add_8, 2, 3, 0
 %endif
 
 INIT_MMX mmx
-; ff_h264_idct_add16_8_mmx(uint8_t *dst, const int *block_offset,
-;                          int16_t *block, int stride,
-;                          const uint8_t nnzc[6 * 8])
+; void ff_h264_idct_add16_8_mmx(uint8_t *dst, const int *block_offset,
+;                               int16_t *block, int stride,
+;                               const uint8_t nnzc[6 * 8])
 cglobal h264_idct_add16_8, 5, 7 + npicregs, 0, dst, block_offset, block, stride, nnzc, cntr, coeff, picreg
     xor          r5, r5
 %ifdef PIC
@@ -371,9 +371,9 @@ cglobal h264_idct_add16_8, 5, 7 + npicregs, 0, dst, block_offset, block, stride,
     jl .nextblock
     REP_RET
 
-; ff_h264_idct8_add4_8_mmx(uint8_t *dst, const int *block_offset,
-;                          int16_t *block, int stride,
-;                          const uint8_t nnzc[6 * 8])
+; void ff_h264_idct8_add4_8_mmx(uint8_t *dst, const int *block_offset,
+;                               int16_t *block, int stride,
+;                               const uint8_t nnzc[6 * 8])
 cglobal h264_idct8_add4_8, 5, 7 + npicregs, 0, dst, block_offset, block, stride, nnzc, cntr, coeff, picreg
     %assign pad 128+4-(stack_offset&7)
     SUB         rsp, pad
@@ -405,9 +405,9 @@ cglobal h264_idct8_add4_8, 5, 7 + npicregs, 0, dst, block_offset, block, stride,
     RET
 
 INIT_MMX mmxext
-; ff_h264_idct_add16_8_mmxext(uint8_t *dst, const int *block_offset,
-;                             int16_t *block, int stride,
-;                             const uint8_t nnzc[6 * 8])
+; void ff_h264_idct_add16_8_mmxext(uint8_t *dst, const int *block_offset,
+;                                  int16_t *block, int stride,
+;                                  const uint8_t nnzc[6 * 8])
 cglobal h264_idct_add16_8, 5, 8 + npicregs, 0, dst1, block_offset, block, stride, nnzc, cntr, coeff, dst2, picreg
     xor          r5, r5
 %ifdef PIC
@@ -452,9 +452,9 @@ cglobal h264_idct_add16_8, 5, 8 + npicregs, 0, dst1, block_offset, block, stride
     REP_RET
 
 INIT_MMX mmx
-; ff_h264_idct_add16intra_8_mmx(uint8_t *dst, const int *block_offset,
-;                               int16_t *block, int stride,
-;                               const uint8_t nnzc[6 * 8])
+; void ff_h264_idct_add16intra_8_mmx(uint8_t *dst, const int *block_offset,
+;                                    int16_t *block, int stride,
+;                                    const uint8_t nnzc[6 * 8])
 cglobal h264_idct_add16intra_8, 5, 7 + npicregs, 0, dst, block_offset, block, stride, nnzc, cntr, coeff, picreg
     xor          r5, r5
 %ifdef PIC
@@ -477,9 +477,9 @@ cglobal h264_idct_add16intra_8, 5, 7 + npicregs, 0, dst, block_offset, block, st
     REP_RET
 
 INIT_MMX mmxext
-; ff_h264_idct_add16intra_8_mmxext(uint8_t *dst, const int *block_offset,
-;                                  int16_t *block, int stride,
-;                                  const uint8_t nnzc[6 * 8])
+; void ff_h264_idct_add16intra_8_mmxext(uint8_t *dst, const int *block_offset,
+;                                       int16_t *block, int stride,
+;                                       const uint8_t nnzc[6 * 8])
 cglobal h264_idct_add16intra_8, 5, 8 + npicregs, 0, dst1, block_offset, block, stride, nnzc, cntr, coeff, dst2, picreg
     xor          r5, r5
 %ifdef PIC
@@ -521,9 +521,9 @@ cglobal h264_idct_add16intra_8, 5, 8 + npicregs, 0, dst1, block_offset, block, s
     jl .nextblock
     REP_RET
 
-; ff_h264_idct8_add4_8_mmxext(uint8_t *dst, const int *block_offset,
-;                             int16_t *block, int stride,
-;                             const uint8_t nnzc[6 * 8])
+; void ff_h264_idct8_add4_8_mmxext(uint8_t *dst, const int *block_offset,
+;                                  int16_t *block, int stride,
+;                                  const uint8_t nnzc[6 * 8])
 cglobal h264_idct8_add4_8, 5, 8 + npicregs, 0, dst1, block_offset, block, stride, nnzc, cntr, coeff, dst2, picreg
     %assign pad 128+4-(stack_offset&7)
     SUB         rsp, pad
@@ -583,9 +583,9 @@ cglobal h264_idct8_add4_8, 5, 8 + npicregs, 0, dst1, block_offset, block, stride
     RET
 
 INIT_XMM sse2
-; ff_h264_idct8_add4_8_sse2(uint8_t *dst, const int *block_offset,
-;                           int16_t *block, int stride,
-;                           const uint8_t nnzc[6 * 8])
+; void ff_h264_idct8_add4_8_sse2(uint8_t *dst, const int *block_offset,
+;                                int16_t *block, int stride,
+;                                const uint8_t nnzc[6 * 8])
 cglobal h264_idct8_add4_8, 5, 8 + npicregs, 10, dst1, block_offset, block, stride, nnzc, cntr, coeff, dst2, picreg
     xor          r5, r5
 %ifdef PIC
@@ -660,8 +660,9 @@ h264_idct_add8_mmx_plane:
     jnz .nextblock
     rep ret
 
-; ff_h264_idct_add8_8_mmx(uint8_t **dest, const int *block_offset,
-;                         int16_t *block, int stride, const uint8_t nnzc[6 * 8])
+; void ff_h264_idct_add8_8_mmx(uint8_t **dest, const int *block_offset,
+;                              int16_t *block, int stride,
+;                              const uint8_t nnzc[6 * 8])
 cglobal h264_idct_add8_8, 5, 8 + npicregs, 0, dst1, block_offset, block, stride, nnzc, cntr, coeff, dst2, picreg
     mov          r5, 16
     add          r2, 512
@@ -725,9 +726,9 @@ h264_idct_add8_mmxext_plane:
     rep ret
 
 INIT_MMX mmxext
-; ff_h264_idct_add8_8_mmxext(uint8_t **dest, const int *block_offset,
-;                            int16_t *block, int stride,
-;                            const uint8_t nnzc[6 * 8])
+; void ff_h264_idct_add8_8_mmxext(uint8_t **dest, const int *block_offset,
+;                                 int16_t *block, int stride,
+;                                 const uint8_t nnzc[6 * 8])
 cglobal h264_idct_add8_8, 5, 8 + npicregs, 0, dst1, block_offset, block, stride, nnzc, cntr, coeff, dst2, picreg
     mov          r5, 16
     add          r2, 512
@@ -809,9 +810,9 @@ h264_add8x4_idct_sse2:
 %endif
 %endmacro
 
-; ff_h264_idct_add16_8_sse2(uint8_t *dst, const int *block_offset,
-;                           int16_t *block, int stride,
-;                           const uint8_t nnzc[6 * 8])
+; void ff_h264_idct_add16_8_sse2(uint8_t *dst, const int *block_offset,
+;                                int16_t *block, int stride,
+;                                const uint8_t nnzc[6 * 8])
 cglobal h264_idct_add16_8, 5, 5 + ARCH_X86_64, 8
 %if ARCH_X86_64
     mov         r5, r0
@@ -857,9 +858,9 @@ cglobal h264_idct_add16_8, 5, 5 + ARCH_X86_64, 8
 %endif
 %endmacro
 
-; ff_h264_idct_add16intra_8_sse2(uint8_t *dst, const int *block_offset,
-;                                int16_t *block, int stride,
-;                                const uint8_t nnzc[6 * 8])
+; void ff_h264_idct_add16intra_8_sse2(uint8_t *dst, const int *block_offset,
+;                                     int16_t *block, int stride,
+;                                     const uint8_t nnzc[6 * 8])
 cglobal h264_idct_add16intra_8, 5, 7 + ARCH_X86_64, 8
 %if ARCH_X86_64
     mov         r7, r0
@@ -909,9 +910,9 @@ cglobal h264_idct_add16intra_8, 5, 7 + ARCH_X86_64, 8
 %endif
 %endmacro
 
-; ff_h264_idct_add8_8_sse2(uint8_t **dest, const int *block_offset,
-;                          int16_t *block, int stride,
-;                          const uint8_t nnzc[6 * 8])
+; void ff_h264_idct_add8_8_sse2(uint8_t **dest, const int *block_offset,
+;                               int16_t *block, int stride,
+;                               const uint8_t nnzc[6 * 8])
 cglobal h264_idct_add8_8, 5, 7 + ARCH_X86_64, 8
     add          r2, 512
 %if ARCH_X86_64
diff --git a/deps/libav/libavcodec/x86/h264_idct_10bit.asm b/deps/libav/libavcodec/x86/h264_idct_10bit.asm
index 4e51d2b..b7d5105 100644
--- a/deps/libav/libavcodec/x86/h264_idct_10bit.asm
+++ b/deps/libav/libavcodec/x86/h264_idct_10bit.asm
@@ -32,7 +32,7 @@ pd_32:        times 4 dd 32
 SECTION .text
 
 ;-----------------------------------------------------------------------------
-; void h264_idct_add(pixel *dst, dctcoef *block, int stride)
+; void ff_h264_idct_add_10(pixel *dst, int16_t *block, int stride)
 ;-----------------------------------------------------------------------------
 %macro STORE_DIFFx2 6
     psrad       %1, 6
@@ -87,7 +87,9 @@ INIT_XMM avx
 IDCT_ADD_10
 
 ;-----------------------------------------------------------------------------
-; h264_idct_add16(pixel *dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
+; void ff_h264_idct_add16_10(pixel *dst, const int *block_offset,
+;                            int16_t *block, int stride,
+;                            const uint8_t nnzc[6*8])
 ;-----------------------------------------------------------------------------
 ;;;;;;; NO FATE SAMPLES TRIGGER THIS
 %macro ADD4x4IDCT 0
@@ -157,7 +159,7 @@ INIT_XMM avx
 IDCT_ADD16_10
 
 ;-----------------------------------------------------------------------------
-; void h264_idct_dc_add(pixel *dst, dctcoef *block, int stride)
+; void ff_h264_idct_dc_add_10(pixel *dst, int16_t *block, int stride)
 ;-----------------------------------------------------------------------------
 %macro IDCT_DC_ADD_OP_10 3
     pxor      m5, m5
@@ -199,7 +201,7 @@ cglobal h264_idct_dc_add_10,3,3
     RET
 
 ;-----------------------------------------------------------------------------
-; void h264_idct8_dc_add(pixel *dst, dctcoef *block, int stride)
+; void ff_h264_idct8_dc_add_10(pixel *dst, int16_t *block, int stride)
 ;-----------------------------------------------------------------------------
 %macro IDCT8_DC_ADD 0
 cglobal h264_idct8_dc_add_10,3,4,7
@@ -222,7 +224,9 @@ INIT_XMM avx
 IDCT8_DC_ADD
 
 ;-----------------------------------------------------------------------------
-; h264_idct_add16intra(pixel *dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
+; void ff_h264_idct_add16intra_10(pixel *dst, const int *block_offset,
+;                                 int16_t *block, int stride,
+;                                 const uint8_t nnzc[6*8])
 ;-----------------------------------------------------------------------------
 %macro AC 1
 .ac%1:
@@ -294,7 +298,9 @@ IDCT_ADD16INTRA_10
 
 %assign last_block 36
 ;-----------------------------------------------------------------------------
-; h264_idct_add8(pixel **dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
+; void ff_h264_idct_add8_10(pixel **dst, const int *block_offset,
+;                           int16_t *block, int stride,
+;                           const uint8_t nnzc[6*8])
 ;-----------------------------------------------------------------------------
 %macro IDCT_ADD8 0
 cglobal h264_idct_add8_10,5,8,7
@@ -328,7 +334,7 @@ INIT_XMM avx
 IDCT_ADD8
 
 ;-----------------------------------------------------------------------------
-; void h264_idct8_add(pixel *dst, dctcoef *block, int stride)
+; void ff_h264_idct8_add_10(pixel *dst, int16_t *block, int stride)
 ;-----------------------------------------------------------------------------
 %macro IDCT8_1D 2
     SWAP      0, 1
@@ -535,7 +541,9 @@ INIT_XMM avx
 IDCT8_ADD
 
 ;-----------------------------------------------------------------------------
-; h264_idct8_add4(pixel **dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
+; void ff_h264_idct8_add4_10(pixel **dst, const int *block_offset,
+;                            int16_t *block, int stride,
+;                            const uint8_t nnzc[6*8])
 ;-----------------------------------------------------------------------------
 ;;;;;;; NO FATE SAMPLES TRIGGER THIS
 %macro IDCT8_ADD4_OP 2
diff --git a/deps/libav/libavcodec/x86/h264_intrapred.asm b/deps/libav/libavcodec/x86/h264_intrapred.asm
index b9db3f4..394dcf4 100644
--- a/deps/libav/libavcodec/x86/h264_intrapred.asm
+++ b/deps/libav/libavcodec/x86/h264_intrapred.asm
@@ -49,7 +49,7 @@ cextern pw_17
 cextern pw_32
 
 ;-----------------------------------------------------------------------------
-; void pred16x16_vertical_8(uint8_t *src, int stride)
+; void ff_pred16x16_vertical_8(uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 
 INIT_MMX mmx
@@ -85,7 +85,7 @@ cglobal pred16x16_vertical_8, 2,3
     REP_RET
 
 ;-----------------------------------------------------------------------------
-; void pred16x16_horizontal_8(uint8_t *src, int stride)
+; void ff_pred16x16_horizontal_8(uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 
 %macro PRED16x16_H 0
@@ -126,7 +126,7 @@ INIT_XMM ssse3
 PRED16x16_H
 
 ;-----------------------------------------------------------------------------
-; void pred16x16_dc_8(uint8_t *src, int stride)
+; void ff_pred16x16_dc_8(uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 
 %macro PRED16x16_DC 0
@@ -188,7 +188,7 @@ INIT_XMM ssse3
 PRED16x16_DC
 
 ;-----------------------------------------------------------------------------
-; void pred16x16_tm_vp8_8(uint8_t *src, int stride)
+; void ff_pred16x16_tm_vp8_8(uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 
 %macro PRED16x16_TM 0
@@ -269,7 +269,7 @@ cglobal pred16x16_tm_vp8_8, 2,6,6
     REP_RET
 
 ;-----------------------------------------------------------------------------
-; void pred16x16_plane_*_8(uint8_t *src, int stride)
+; void ff_pred16x16_plane_*_8(uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 
 %macro H264_PRED16x16_PLANE 1
@@ -550,7 +550,7 @@ H264_PRED16x16_PLANE rv40
 H264_PRED16x16_PLANE svq3
 
 ;-----------------------------------------------------------------------------
-; void pred8x8_plane_8(uint8_t *src, int stride)
+; void ff_pred8x8_plane_8(uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 
 %macro H264_PRED8x8_PLANE 0
@@ -724,7 +724,7 @@ INIT_XMM ssse3
 H264_PRED8x8_PLANE
 
 ;-----------------------------------------------------------------------------
-; void pred8x8_vertical_8(uint8_t *src, int stride)
+; void ff_pred8x8_vertical_8(uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 
 INIT_MMX mmx
@@ -741,7 +741,7 @@ cglobal pred8x8_vertical_8, 2,2
     RET
 
 ;-----------------------------------------------------------------------------
-; void pred8x8_horizontal_8(uint8_t *src, int stride)
+; void ff_pred8x8_horizontal_8(uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 
 %macro PRED8x8_H 0
@@ -769,7 +769,7 @@ INIT_MMX ssse3
 PRED8x8_H
 
 ;-----------------------------------------------------------------------------
-; void pred8x8_top_dc_8_mmxext(uint8_t *src, int stride)
+; void ff_pred8x8_top_dc_8_mmxext(uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 INIT_MMX mmxext
 cglobal pred8x8_top_dc_8, 2,5
@@ -803,7 +803,7 @@ cglobal pred8x8_top_dc_8, 2,5
     RET
 
 ;-----------------------------------------------------------------------------
-; void pred8x8_dc_8_mmxext(uint8_t *src, int stride)
+; void ff_pred8x8_dc_8_mmxext(uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 
 INIT_MMX mmxext
@@ -864,7 +864,7 @@ cglobal pred8x8_dc_8, 2,5
     RET
 
 ;-----------------------------------------------------------------------------
-; void pred8x8_dc_rv40_8(uint8_t *src, int stride)
+; void ff_pred8x8_dc_rv40_8(uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 
 INIT_MMX mmxext
@@ -901,7 +901,7 @@ cglobal pred8x8_dc_rv40_8, 2,7
     REP_RET
 
 ;-----------------------------------------------------------------------------
-; void pred8x8_tm_vp8_8(uint8_t *src, int stride)
+; void ff_pred8x8_tm_vp8_8(uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 
 %macro PRED8x8_TM 0
@@ -1013,7 +1013,8 @@ cglobal pred8x8_tm_vp8_8, 2,3,6
 %endmacro
 
 ;-----------------------------------------------------------------------------
-; void pred8x8l_top_dc_8(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_top_dc_8(uint8_t *src, int has_topleft, int has_topright,
+;                           int stride)
 ;-----------------------------------------------------------------------------
 %macro PRED8x8L_TOP_DC 0
 cglobal pred8x8l_top_dc_8, 4,4
@@ -1068,7 +1069,8 @@ INIT_MMX ssse3
 PRED8x8L_TOP_DC
 
 ;-----------------------------------------------------------------------------
-;void pred8x8l_dc_8(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_dc_8(uint8_t *src, int has_topleft, int has_topright,
+;                       int stride)
 ;-----------------------------------------------------------------------------
 
 %macro PRED8x8L_DC 0
@@ -1171,7 +1173,8 @@ INIT_MMX ssse3
 PRED8x8L_DC
 
 ;-----------------------------------------------------------------------------
-; void pred8x8l_horizontal_8(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_horizontal_8(uint8_t *src, int has_topleft,
+;                               int has_topright, int stride)
 ;-----------------------------------------------------------------------------
 
 %macro PRED8x8L_HORIZONTAL 0
@@ -1242,7 +1245,8 @@ INIT_MMX ssse3
 PRED8x8L_HORIZONTAL
 
 ;-----------------------------------------------------------------------------
-; void pred8x8l_vertical_8(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_vertical_8(uint8_t *src, int has_topleft, int has_topright,
+;                             int stride)
 ;-----------------------------------------------------------------------------
 
 %macro PRED8x8L_VERTICAL 0
@@ -1292,7 +1296,8 @@ INIT_MMX ssse3
 PRED8x8L_VERTICAL
 
 ;-----------------------------------------------------------------------------
-;void pred8x8l_down_left_8(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_down_left_8(uint8_t *src, int has_topleft,
+;                              int has_topright, int stride)
 ;-----------------------------------------------------------------------------
 
 INIT_MMX mmxext
@@ -1492,7 +1497,8 @@ INIT_MMX ssse3
 PRED8x8L_DOWN_LEFT
 
 ;-----------------------------------------------------------------------------
-;void pred8x8l_down_right_8_mmxext(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_down_right_8_mmxext(uint8_t *src, int has_topleft,
+;                                      int has_topright, int stride)
 ;-----------------------------------------------------------------------------
 
 INIT_MMX mmxext
@@ -1743,7 +1749,8 @@ INIT_MMX ssse3
 PRED8x8L_DOWN_RIGHT
 
 ;-----------------------------------------------------------------------------
-; void pred8x8l_vertical_right_8(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_vertical_right_8(uint8_t *src, int has_topleft,
+;                                   int has_topright, int stride)
 ;-----------------------------------------------------------------------------
 
 INIT_MMX mmxext
@@ -1970,7 +1977,8 @@ INIT_MMX ssse3
 PRED8x8L_VERTICAL_RIGHT
 
 ;-----------------------------------------------------------------------------
-;void pred8x8l_vertical_left_8(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_vertical_left_8(uint8_t *src, int has_topleft,
+;                                  int has_topright, int stride)
 ;-----------------------------------------------------------------------------
 
 %macro PRED8x8L_VERTICAL_LEFT 0
@@ -2059,7 +2067,8 @@ INIT_MMX ssse3
 PRED8x8L_VERTICAL_LEFT
 
 ;-----------------------------------------------------------------------------
-; void pred8x8l_horizontal_up_8(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_horizontal_up_8(uint8_t *src, int has_topleft,
+;                                  int has_topright, int stride)
 ;-----------------------------------------------------------------------------
 
 %macro PRED8x8L_HORIZONTAL_UP 0
@@ -2146,7 +2155,8 @@ INIT_MMX ssse3
 PRED8x8L_HORIZONTAL_UP
 
 ;-----------------------------------------------------------------------------
-;void pred8x8l_horizontal_down_8(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_horizontal_down_8(uint8_t *src, int has_topleft,
+;                                    int has_topright, int stride)
 ;-----------------------------------------------------------------------------
 
 INIT_MMX mmxext
@@ -2393,9 +2403,9 @@ PRED8x8L_HORIZONTAL_DOWN
 INIT_MMX ssse3
 PRED8x8L_HORIZONTAL_DOWN
 
-;-----------------------------------------------------------------------------
-; void pred4x4_dc_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
-;-----------------------------------------------------------------------------
+;-------------------------------------------------------------------------------
+; void ff_pred4x4_dc_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+;-------------------------------------------------------------------------------
 
 INIT_MMX mmxext
 cglobal pred4x4_dc_8, 3,5
@@ -2424,7 +2434,8 @@ cglobal pred4x4_dc_8, 3,5
     RET
 
 ;-----------------------------------------------------------------------------
-; void pred4x4_tm_vp8_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+; void ff_pred4x4_tm_vp8_8_mmxext(uint8_t *src, const uint8_t *topright,
+;                                 int stride)
 ;-----------------------------------------------------------------------------
 
 %macro PRED4x4_TM 0
@@ -2505,7 +2516,8 @@ cglobal pred4x4_tm_vp8_8, 3,3
     RET
 
 ;-----------------------------------------------------------------------------
-; void pred4x4_vertical_vp8_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+; void ff_pred4x4_vertical_vp8_8_mmxext(uint8_t *src, const uint8_t *topright,
+;                                       int stride)
 ;-----------------------------------------------------------------------------
 
 INIT_MMX mmxext
@@ -2525,7 +2537,8 @@ cglobal pred4x4_vertical_vp8_8, 3,3
     RET
 
 ;-----------------------------------------------------------------------------
-; void pred4x4_down_left_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+; void ff_pred4x4_down_left_8_mmxext(uint8_t *src, const uint8_t *topright,
+;                                    int stride)
 ;-----------------------------------------------------------------------------
 INIT_MMX mmxext
 cglobal pred4x4_down_left_8, 3,3
@@ -2550,9 +2563,10 @@ cglobal pred4x4_down_left_8, 3,3
     movd      [r1+r2*2], m0
     RET
 
-;-----------------------------------------------------------------------------
-; void pred4x4_vertical_left_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
-;-----------------------------------------------------------------------------
+;------------------------------------------------------------------------------
+; void ff_pred4x4_vertical_left_8_mmxext(uint8_t *src, const uint8_t *topright,
+;                                        int stride)
+;------------------------------------------------------------------------------
 
 INIT_MMX mmxext
 cglobal pred4x4_vertical_left_8, 3,3
@@ -2575,9 +2589,10 @@ cglobal pred4x4_vertical_left_8, 3,3
     movh      [r1+r2*2], m0
     RET
 
-;-----------------------------------------------------------------------------
-; void pred4x4_horizontal_up_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
-;-----------------------------------------------------------------------------
+;------------------------------------------------------------------------------
+; void ff_pred4x4_horizontal_up_8_mmxext(uint8_t *src, const uint8_t *topright,
+;                                        int stride)
+;------------------------------------------------------------------------------
 
 INIT_MMX mmxext
 cglobal pred4x4_horizontal_up_8, 3,3
@@ -2608,9 +2623,10 @@ cglobal pred4x4_horizontal_up_8, 3,3
     movd    [r1+r2*2], m1
     RET
 
-;-----------------------------------------------------------------------------
-; void pred4x4_horizontal_down_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
-;-----------------------------------------------------------------------------
+;------------------------------------------------------------------------------
+; void ff_pred4x4_horizontal_down_8_mmxext(uint8_t *src,
+;                                          const uint8_t *topright, int stride)
+;------------------------------------------------------------------------------
 
 INIT_MMX mmxext
 cglobal pred4x4_horizontal_down_8, 3,3
@@ -2644,7 +2660,8 @@ cglobal pred4x4_horizontal_down_8, 3,3
     RET
 
 ;-----------------------------------------------------------------------------
-; void pred4x4_vertical_right_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+; void ff_pred4x4_vertical_right_8_mmxext(uint8_t *src,
+;                                         const uint8_t *topright, int stride)
 ;-----------------------------------------------------------------------------
 
 INIT_MMX mmxext
@@ -2674,7 +2691,8 @@ cglobal pred4x4_vertical_right_8, 3,3
     RET
 
 ;-----------------------------------------------------------------------------
-; void pred4x4_down_right_8_mmxext(uint8_t *src, const uint8_t *topright, int stride)
+; void ff_pred4x4_down_right_8_mmxext(uint8_t *src, const uint8_t *topright,
+;                                     int stride)
 ;-----------------------------------------------------------------------------
 
 INIT_MMX mmxext
diff --git a/deps/libav/libavcodec/x86/h264_intrapred_10bit.asm b/deps/libav/libavcodec/x86/h264_intrapred_10bit.asm
index 1b7974b..55790a9 100644
--- a/deps/libav/libavcodec/x86/h264_intrapred_10bit.asm
+++ b/deps/libav/libavcodec/x86/h264_intrapred_10bit.asm
@@ -50,7 +50,7 @@ SECTION .text
 %endmacro
 
 ;-----------------------------------------------------------------------------
-; void pred4x4_down_right(pixel *src, const pixel *topright, int stride)
+; void ff_pred4x4_down_right(pixel *src, const pixel *topright, int stride)
 ;-----------------------------------------------------------------------------
 %macro PRED4x4_DR 0
 cglobal pred4x4_down_right_10, 3, 3
@@ -85,9 +85,9 @@ PRED4x4_DR
 INIT_XMM avx
 PRED4x4_DR
 
-;-----------------------------------------------------------------------------
-; void pred4x4_vertical_right(pixel *src, const pixel *topright, int stride)
-;-----------------------------------------------------------------------------
+;------------------------------------------------------------------------------
+; void ff_pred4x4_vertical_right(pixel *src, const pixel *topright, int stride)
+;------------------------------------------------------------------------------
 %macro PRED4x4_VR 0
 cglobal pred4x4_vertical_right_10, 3, 3, 6
     sub     r0, r2
@@ -122,9 +122,9 @@ PRED4x4_VR
 INIT_XMM avx
 PRED4x4_VR
 
-;-----------------------------------------------------------------------------
-; void pred4x4_horizontal_down(pixel *src, const pixel *topright, int stride)
-;-----------------------------------------------------------------------------
+;-------------------------------------------------------------------------------
+; void ff_pred4x4_horizontal_down(pixel *src, const pixel *topright, int stride)
+;-------------------------------------------------------------------------------
 %macro PRED4x4_HD 0
 cglobal pred4x4_horizontal_down_10, 3, 3
     sub        r0, r2
@@ -163,7 +163,7 @@ INIT_XMM avx
 PRED4x4_HD
 
 ;-----------------------------------------------------------------------------
-; void pred4x4_dc(pixel *src, const pixel *topright, int stride)
+; void ff_pred4x4_dc(pixel *src, const pixel *topright, int stride)
 ;-----------------------------------------------------------------------------
 %macro HADDD 2 ; sum junk
 %if mmsize == 16
@@ -204,7 +204,7 @@ cglobal pred4x4_dc_10, 3, 3
     RET
 
 ;-----------------------------------------------------------------------------
-; void pred4x4_down_left(pixel *src, const pixel *topright, int stride)
+; void ff_pred4x4_down_left(pixel *src, const pixel *topright, int stride)
 ;-----------------------------------------------------------------------------
 %macro PRED4x4_DL 0
 cglobal pred4x4_down_left_10, 3, 3
@@ -232,7 +232,7 @@ INIT_XMM avx
 PRED4x4_DL
 
 ;-----------------------------------------------------------------------------
-; void pred4x4_vertical_left(pixel *src, const pixel *topright, int stride)
+; void ff_pred4x4_vertical_left(pixel *src, const pixel *topright, int stride)
 ;-----------------------------------------------------------------------------
 %macro PRED4x4_VL 0
 cglobal pred4x4_vertical_left_10, 3, 3
@@ -259,7 +259,7 @@ INIT_XMM avx
 PRED4x4_VL
 
 ;-----------------------------------------------------------------------------
-; void pred4x4_horizontal_up(pixel *src, const pixel *topright, int stride)
+; void ff_pred4x4_horizontal_up(pixel *src, const pixel *topright, int stride)
 ;-----------------------------------------------------------------------------
 INIT_MMX mmxext
 cglobal pred4x4_horizontal_up_10, 3, 3
@@ -293,7 +293,7 @@ cglobal pred4x4_horizontal_up_10, 3, 3
 
 
 ;-----------------------------------------------------------------------------
-; void pred8x8_vertical(pixel *src, int stride)
+; void ff_pred8x8_vertical(pixel *src, int stride)
 ;-----------------------------------------------------------------------------
 INIT_XMM sse2
 cglobal pred8x8_vertical_10, 2, 2
@@ -309,7 +309,7 @@ cglobal pred8x8_vertical_10, 2, 2
     RET
 
 ;-----------------------------------------------------------------------------
-; void pred8x8_horizontal(pixel *src, int stride)
+; void ff_pred8x8_horizontal(pixel *src, int stride)
 ;-----------------------------------------------------------------------------
 INIT_XMM sse2
 cglobal pred8x8_horizontal_10, 2, 3
@@ -329,7 +329,7 @@ cglobal pred8x8_horizontal_10, 2, 3
     REP_RET
 
 ;-----------------------------------------------------------------------------
-; void predict_8x8_dc(pixel *src, int stride)
+; void ff_predict_8x8_dc(pixel *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro MOV8 2-3
 ; sort of a hack, but it works
@@ -416,7 +416,7 @@ INIT_XMM sse2
 PRED8x8_DC pshuflw
 
 ;-----------------------------------------------------------------------------
-; void pred8x8_top_dc(pixel *src, int stride)
+; void ff_pred8x8_top_dc(pixel *src, int stride)
 ;-----------------------------------------------------------------------------
 INIT_XMM sse2
 cglobal pred8x8_top_dc_10, 2, 4
@@ -443,7 +443,7 @@ cglobal pred8x8_top_dc_10, 2, 4
     RET
 
 ;-----------------------------------------------------------------------------
-; void pred8x8_plane(pixel *src, int stride)
+; void ff_pred8x8_plane(pixel *src, int stride)
 ;-----------------------------------------------------------------------------
 INIT_XMM sse2
 cglobal pred8x8_plane_10, 2, 7, 7
@@ -506,7 +506,8 @@ cglobal pred8x8_plane_10, 2, 7, 7
 
 
 ;-----------------------------------------------------------------------------
-; void pred8x8l_128_dc(pixel *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_128_dc(pixel *src, int has_topleft, int has_topright,
+;                         int stride)
 ;-----------------------------------------------------------------------------
 %macro PRED8x8L_128_DC 0
 cglobal pred8x8l_128_dc_10, 4, 4
@@ -530,7 +531,8 @@ INIT_XMM sse2
 PRED8x8L_128_DC
 
 ;-----------------------------------------------------------------------------
-; void pred8x8l_top_dc(pixel *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_top_dc(pixel *src, int has_topleft, int has_topright,
+;                         int stride)
 ;-----------------------------------------------------------------------------
 %macro PRED8x8L_TOP_DC 0
 cglobal pred8x8l_top_dc_10, 4, 4, 6
@@ -566,9 +568,9 @@ PRED8x8L_TOP_DC
 INIT_XMM avx
 PRED8x8L_TOP_DC
 
-;-----------------------------------------------------------------------------
-;void pred8x8l_dc(pixel *src, int has_topleft, int has_topright, int stride)
-;-----------------------------------------------------------------------------
+;-------------------------------------------------------------------------------
+; void ff_pred8x8l_dc(pixel *src, int has_topleft, int has_topright, int stride)
+;-------------------------------------------------------------------------------
 ;TODO: see if scalar is faster
 %macro PRED8x8L_DC 0
 cglobal pred8x8l_dc_10, 4, 6, 6
@@ -624,7 +626,8 @@ INIT_XMM avx
 PRED8x8L_DC
 
 ;-----------------------------------------------------------------------------
-; void pred8x8l_vertical(pixel *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_vertical(pixel *src, int has_topleft, int has_topright,
+;                           int stride)
 ;-----------------------------------------------------------------------------
 %macro PRED8x8L_VERTICAL 0
 cglobal pred8x8l_vertical_10, 4, 4, 6
@@ -657,7 +660,8 @@ INIT_XMM avx
 PRED8x8L_VERTICAL
 
 ;-----------------------------------------------------------------------------
-; void pred8x8l_horizontal(uint8_t *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_horizontal(uint8_t *src, int has_topleft, int has_topright,
+;                             int stride)
 ;-----------------------------------------------------------------------------
 %macro PRED8x8L_HORIZONTAL 0
 cglobal pred8x8l_horizontal_10, 4, 4, 5
@@ -711,7 +715,8 @@ INIT_XMM avx
 PRED8x8L_HORIZONTAL
 
 ;-----------------------------------------------------------------------------
-;void pred8x8l_down_left(pixel *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_down_left(pixel *src, int has_topleft, int has_topright,
+;                            int stride)
 ;-----------------------------------------------------------------------------
 %macro PRED8x8L_DOWN_LEFT 0
 cglobal pred8x8l_down_left_10, 4, 4, 7
@@ -777,7 +782,8 @@ INIT_XMM avx
 PRED8x8L_DOWN_LEFT
 
 ;-----------------------------------------------------------------------------
-;void pred8x8l_down_right(pixel *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_down_right(pixel *src, int has_topleft, int has_topright,
+;                             int stride)
 ;-----------------------------------------------------------------------------
 %macro PRED8x8L_DOWN_RIGHT 0
 ; standard forbids this when has_topleft is false
@@ -849,7 +855,8 @@ INIT_XMM avx
 PRED8x8L_DOWN_RIGHT
 
 ;-----------------------------------------------------------------------------
-; void pred8x8l_vertical_right(pixel *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_vertical_right(pixel *src, int has_topleft,
+;                                 int has_topright, int stride)
 ;-----------------------------------------------------------------------------
 %macro PRED8x8L_VERTICAL_RIGHT 0
 ; likewise with 8x8l_down_right
@@ -917,7 +924,8 @@ INIT_XMM avx
 PRED8x8L_VERTICAL_RIGHT
 
 ;-----------------------------------------------------------------------------
-; void pred8x8l_horizontal_up(pixel *src, int has_topleft, int has_topright, int stride)
+; void ff_pred8x8l_horizontal_up(pixel *src, int has_topleft,
+;                                int has_topright, int stride)
 ;-----------------------------------------------------------------------------
 %macro PRED8x8L_HORIZONTAL_UP 0
 cglobal pred8x8l_horizontal_up_10, 4, 4, 6
@@ -977,7 +985,7 @@ PRED8x8L_HORIZONTAL_UP
 
 
 ;-----------------------------------------------------------------------------
-; void pred16x16_vertical(pixel *src, int stride)
+; void ff_pred16x16_vertical(pixel *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro MOV16 3-5
     mova [%1+     0], %2
@@ -1013,7 +1021,7 @@ INIT_XMM sse2
 PRED16x16_VERTICAL
 
 ;-----------------------------------------------------------------------------
-; void pred16x16_horizontal(pixel *src, int stride)
+; void ff_pred16x16_horizontal(pixel *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro PRED16x16_HORIZONTAL 0
 cglobal pred16x16_horizontal_10, 2, 3
@@ -1037,7 +1045,7 @@ INIT_XMM sse2
 PRED16x16_HORIZONTAL
 
 ;-----------------------------------------------------------------------------
-; void pred16x16_dc(pixel *src, int stride)
+; void ff_pred16x16_dc(pixel *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro PRED16x16_DC 0
 cglobal pred16x16_dc_10, 2, 6
@@ -1083,7 +1091,7 @@ INIT_XMM sse2
 PRED16x16_DC
 
 ;-----------------------------------------------------------------------------
-; void pred16x16_top_dc(pixel *src, int stride)
+; void ff_pred16x16_top_dc(pixel *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro PRED16x16_TOP_DC 0
 cglobal pred16x16_top_dc_10, 2, 3
@@ -1115,7 +1123,7 @@ INIT_XMM sse2
 PRED16x16_TOP_DC
 
 ;-----------------------------------------------------------------------------
-; void pred16x16_left_dc(pixel *src, int stride)
+; void ff_pred16x16_left_dc(pixel *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro PRED16x16_LEFT_DC 0
 cglobal pred16x16_left_dc_10, 2, 6
@@ -1152,7 +1160,7 @@ INIT_XMM sse2
 PRED16x16_LEFT_DC
 
 ;-----------------------------------------------------------------------------
-; void pred16x16_128_dc(pixel *src, int stride)
+; void ff_pred16x16_128_dc(pixel *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro PRED16x16_128_DC 0
 cglobal pred16x16_128_dc_10, 2,3
diff --git a/deps/libav/libavcodec/x86/h264_qpel_10bit.asm b/deps/libav/libavcodec/x86/h264_qpel_10bit.asm
index e14df84..f92c4aa 100644
--- a/deps/libav/libavcodec/x86/h264_qpel_10bit.asm
+++ b/deps/libav/libavcodec/x86/h264_qpel_10bit.asm
@@ -167,7 +167,7 @@ stub_%1_h264_qpel%3_%2_10 %+ SUFFIX:
 %endmacro
 
 ;-----------------------------------------------------------------------------
-; void h264_qpel_mc00(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc00(uint8_t *dst, uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro COPY4 0
     movu          m0, [r1     ]
@@ -221,7 +221,7 @@ MC00 put
 MC00 avg
 
 ;-----------------------------------------------------------------------------
-; void h264_qpel_mc20(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc20(uint8_t *dst, uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro MC_CACHE 1
 %define OP_MOV mova
@@ -305,7 +305,7 @@ cglobal_mc %1, mc20, %2, 3,4,9
 MC_CACHE MC20
 
 ;-----------------------------------------------------------------------------
-; void h264_qpel_mc30(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc30(uint8_t *dst, uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro MC30 2
 cglobal_mc %1, mc30, %2, 3,5,9
@@ -316,7 +316,7 @@ cglobal_mc %1, mc30, %2, 3,5,9
 MC_CACHE MC30
 
 ;-----------------------------------------------------------------------------
-; void h264_qpel_mc10(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc10(uint8_t *dst, uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro MC10 2
 cglobal_mc %1, mc10, %2, 3,5,9
@@ -383,7 +383,7 @@ cglobal_mc %1, mc10, %2, 3,5,9
 MC_CACHE MC10
 
 ;-----------------------------------------------------------------------------
-; void h264_qpel_mc02(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc02(uint8_t *dst, uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro V_FILT 10
 v_filt%9_%10_10
@@ -432,7 +432,7 @@ cglobal_mc %1, mc02, %2, 3,4,8
 MC MC02
 
 ;-----------------------------------------------------------------------------
-; void h264_qpel_mc01(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc01(uint8_t *dst, uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro MC01 2
 cglobal_mc %1, mc01, %2, 3,5,8
@@ -458,7 +458,7 @@ cglobal_mc %1, mc01, %2, 3,5,8
 MC MC01
 
 ;-----------------------------------------------------------------------------
-; void h264_qpel_mc03(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc03(uint8_t *dst, uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro MC03 2
 cglobal_mc %1, mc03, %2, 3,5,8
@@ -469,7 +469,7 @@ cglobal_mc %1, mc03, %2, 3,5,8
 MC MC03
 
 ;-----------------------------------------------------------------------------
-; void h264_qpel_mc11(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc11(uint8_t *dst, uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro H_FILT_AVG 2-3
 h_filt%1_%2_10:
@@ -551,7 +551,7 @@ cglobal_mc %1, mc11, %2, 3,6,8
 MC MC11
 
 ;-----------------------------------------------------------------------------
-; void h264_qpel_mc31(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc31(uint8_t *dst, uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro MC31 2
 cglobal_mc %1, mc31, %2, 3,6,8
@@ -563,7 +563,7 @@ cglobal_mc %1, mc31, %2, 3,6,8
 MC MC31
 
 ;-----------------------------------------------------------------------------
-; void h264_qpel_mc13(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc13(uint8_t *dst, uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro MC13 2
 cglobal_mc %1, mc13, %2, 3,7,12
@@ -574,7 +574,7 @@ cglobal_mc %1, mc13, %2, 3,7,12
 MC MC13
 
 ;-----------------------------------------------------------------------------
-; void h264_qpel_mc33(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc33(uint8_t *dst, uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro MC33 2
 cglobal_mc %1, mc33, %2, 3,6,8
@@ -586,7 +586,7 @@ cglobal_mc %1, mc33, %2, 3,6,8
 MC MC33
 
 ;-----------------------------------------------------------------------------
-; void h264_qpel_mc22(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc22(uint8_t *dst, uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro FILT_H2 3
     psubw  %1, %2  ; a-b
@@ -757,7 +757,7 @@ cglobal_mc %1, mc22, %2, 3,7,12
 MC MC22
 
 ;-----------------------------------------------------------------------------
-; void h264_qpel_mc12(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc12(uint8_t *dst, uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro MC12 2
 cglobal_mc %1, mc12, %2, 3,7,12
@@ -802,7 +802,7 @@ cglobal_mc %1, mc12, %2, 3,7,12
 MC MC12
 
 ;-----------------------------------------------------------------------------
-; void h264_qpel_mc32(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc32(uint8_t *dst, uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro MC32 2
 cglobal_mc %1, mc32, %2, 3,7,12
@@ -820,7 +820,7 @@ cglobal_mc %1, mc32, %2, 3,7,12
 MC MC32
 
 ;-----------------------------------------------------------------------------
-; void h264_qpel_mc21(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc21(uint8_t *dst, uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro H_NRD 1
 put_h%1_10:
@@ -873,7 +873,7 @@ cglobal_mc %1, mc21, %2, 3,7,12
 MC MC21
 
 ;-----------------------------------------------------------------------------
-; void h264_qpel_mc23(uint8_t *dst, uint8_t *src, int stride)
+; void ff_h264_qpel_mc23(uint8_t *dst, uint8_t *src, int stride)
 ;-----------------------------------------------------------------------------
 %macro MC23 2
 cglobal_mc %1, mc23, %2, 3,7,12
diff --git a/deps/libav/libavcodec/x86/h264_weight.asm b/deps/libav/libavcodec/x86/h264_weight.asm
index 646acdf..d1873af 100644
--- a/deps/libav/libavcodec/x86/h264_weight.asm
+++ b/deps/libav/libavcodec/x86/h264_weight.asm
@@ -28,12 +28,12 @@ SECTION .text
 ;-----------------------------------------------------------------------------
 ; biweight pred:
 ;
-; void h264_biweight_16_sse2(uint8_t *dst, uint8_t *src, int stride,
-;                            int height, int log2_denom, int weightd,
-;                            int weights, int offset);
+; void ff_h264_biweight_16_sse2(uint8_t *dst, uint8_t *src, int stride,
+;                               int height, int log2_denom, int weightd,
+;                               int weights, int offset);
 ; and
-; void h264_weight_16_sse2(uint8_t *dst, int stride, int height,
-;                          int log2_denom, int weight, int offset);
+; void ff_h264_weight_16_sse2(uint8_t *dst, int stride, int height,
+;                             int log2_denom, int weight, int offset);
 ;-----------------------------------------------------------------------------
 
 %macro WEIGHT_SETUP 0
diff --git a/deps/libav/libavcodec/x86/h264_weight_10bit.asm b/deps/libav/libavcodec/x86/h264_weight_10bit.asm
index 3b09e42..961ec8c 100644
--- a/deps/libav/libavcodec/x86/h264_weight_10bit.asm
+++ b/deps/libav/libavcodec/x86/h264_weight_10bit.asm
@@ -35,8 +35,8 @@ cextern pw_1
 SECTION .text
 
 ;-----------------------------------------------------------------------------
-; void h264_weight(uint8_t *dst, int stride, int height, int log2_denom,
-;                  int weight, int offset);
+; void ff_h264_weight_16_10(uint8_t *dst, int stride, int height,
+;                           int log2_denom, int weight, int offset);
 ;-----------------------------------------------------------------------------
 %macro WEIGHT_PROLOGUE 0
 .prologue:
@@ -151,8 +151,9 @@ WEIGHT_FUNC_HALF_MM
 
 
 ;-----------------------------------------------------------------------------
-; void h264_biweight(uint8_t *dst, uint8_t *src, int stride, int height,
-;                    int log2_denom, int weightd, int weights, int offset);
+; void ff_h264_biweight_16_10(uint8_t *dst, uint8_t *src, int stride,
+;                             int height, int log2_denom, int weightd,
+;                             int weights, int offset);
 ;-----------------------------------------------------------------------------
 %if ARCH_X86_32
 DECLARE_REG_TMP 3
diff --git a/deps/libav/libavcodec/x86/hpeldsp.asm b/deps/libav/libavcodec/x86/hpeldsp.asm
index ff6e57a..073f7f9 100644
--- a/deps/libav/libavcodec/x86/hpeldsp.asm
+++ b/deps/libav/libavcodec/x86/hpeldsp.asm
@@ -1,5 +1,5 @@
 ;******************************************************************************
-;* MMX optimized hpel functions
+;* SIMD-optimized halfpel functions
 ;*
 ;* This file is part of Libav.
 ;*
@@ -25,7 +25,7 @@ cextern pb_1
 
 SECTION_TEXT
 
-; put_pixels8_x2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_put_pixels8_x2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
 %macro PUT_PIXELS8_X2 0
 cglobal put_pixels8_x2, 4,5
     lea          r4, [r2*2]
@@ -57,7 +57,7 @@ INIT_MMX 3dnow
 PUT_PIXELS8_X2
 
 
-; put_pixels16_x2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_put_pixels16_x2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
 %macro PUT_PIXELS_16 0
 cglobal put_pixels16_x2, 4,5
     lea          r4, [r2*2]
@@ -101,7 +101,7 @@ INIT_MMX 3dnow
 PUT_PIXELS_16
 
 
-; put_no_rnd_pixels8_x2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_put_no_rnd_pixels8_x2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
 %macro PUT_NO_RND_PIXELS8_X2 0
 cglobal put_no_rnd_pixels8_x2, 4,5
     mova         m6, [pb_1]
@@ -142,7 +142,7 @@ INIT_MMX 3dnow
 PUT_NO_RND_PIXELS8_X2
 
 
-; put_no_rnd_pixels8_x2_exact(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_put_no_rnd_pixels8_x2_exact(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
 %macro PUT_NO_RND_PIXELS8_X2_EXACT 0
 cglobal put_no_rnd_pixels8_x2_exact, 4,5
     lea          r4, [r2*3]
@@ -189,7 +189,7 @@ INIT_MMX 3dnow
 PUT_NO_RND_PIXELS8_X2_EXACT
 
 
-; put_pixels8_y2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_put_pixels8_y2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
 %macro PUT_PIXELS8_Y2 0
 cglobal put_pixels8_y2, 4,5
     lea          r4, [r2*2]
@@ -223,7 +223,7 @@ INIT_MMX 3dnow
 PUT_PIXELS8_Y2
 
 
-; put_no_rnd_pixels8_y2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_put_no_rnd_pixels8_y2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
 %macro PUT_NO_RND_PIXELS8_Y2 0
 cglobal put_no_rnd_pixels8_y2, 4,5
     mova         m6, [pb_1]
@@ -260,7 +260,7 @@ INIT_MMX 3dnow
 PUT_NO_RND_PIXELS8_Y2
 
 
-; put_no_rnd_pixels8_y2_exact(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_put_no_rnd_pixels8_y2_exact(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
 %macro PUT_NO_RND_PIXELS8_Y2_EXACT 0
 cglobal put_no_rnd_pixels8_y2_exact, 4,5
     lea          r4, [r2*3]
@@ -302,7 +302,7 @@ INIT_MMX 3dnow
 PUT_NO_RND_PIXELS8_Y2_EXACT
 
 
-; avg_pixels8(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_avg_pixels8(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
 %macro AVG_PIXELS8 0
 cglobal avg_pixels8, 4,5
     lea          r4, [r2*2]
@@ -332,7 +332,7 @@ INIT_MMX 3dnow
 AVG_PIXELS8
 
 
-; avg_pixels8_x2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_avg_pixels8_x2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
 %macro AVG_PIXELS8_X2 0
 cglobal avg_pixels8_x2, 4,5
     lea          r4, [r2*2]
@@ -368,7 +368,7 @@ INIT_MMX 3dnow
 AVG_PIXELS8_X2
 
 
-; avg_pixels8_y2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_avg_pixels8_y2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
 %macro AVG_PIXELS8_Y2 0
 cglobal avg_pixels8_y2, 4,5
     lea          r4, [r2*2]
@@ -410,7 +410,7 @@ INIT_MMX 3dnow
 AVG_PIXELS8_Y2
 
 
-; avg_pixels8_xy2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
+; void ff_avg_pixels8_xy2(uint8_t *block, const uint8_t *pixels, ptrdiff_t line_size, int h)
 %macro AVG_PIXELS8_XY2 0
 cglobal avg_pixels8_xy2, 4,5
     mova         m6, [pb_1]
diff --git a/deps/libav/libavcodec/x86/hpeldsp_init.c b/deps/libav/libavcodec/x86/hpeldsp_init.c
index c4f555c..83d53de 100644
--- a/deps/libav/libavcodec/x86/hpeldsp_init.c
+++ b/deps/libav/libavcodec/x86/hpeldsp_init.c
@@ -1,5 +1,5 @@
 /*
- * MMX optimized DSP utils
+ * SIMD-optimized halfpel functions
  * Copyright (c) 2000, 2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  *
@@ -26,6 +26,7 @@
 #include "libavutil/cpu.h"
 #include "libavutil/x86/asm.h"
 #include "libavutil/x86/cpu.h"
+#include "libavcodec/avcodec.h"
 #include "libavcodec/hpeldsp.h"
 #include "dsputil_x86.h"
 
diff --git a/deps/libav/libavcodec/x86/hpeldsp_rnd_template.c b/deps/libav/libavcodec/x86/hpeldsp_rnd_template.c
index 516a03a..b514a8f 100644
--- a/deps/libav/libavcodec/x86/hpeldsp_rnd_template.c
+++ b/deps/libav/libavcodec/x86/hpeldsp_rnd_template.c
@@ -1,5 +1,5 @@
 /*
- * DSP utils mmx functions are compiled twice for rnd/no_rnd
+ * SIMD-optimized halfpel functions are compiled twice for rnd/no_rnd
  * Copyright (c) 2000, 2001 Fabrice Bellard
  * Copyright (c) 2003-2004 Michael Niedermayer <michaelni at gmx.at>
  *
diff --git a/deps/libav/libavcodec/x86/lpc.c b/deps/libav/libavcodec/x86/lpc.c
index 12245c4..ea5d2ea 100644
--- a/deps/libav/libavcodec/x86/lpc.c
+++ b/deps/libav/libavcodec/x86/lpc.c
@@ -1,5 +1,5 @@
 /*
- * MMX optimized LPC DSP utils
+ * SIMD-optimized LPC functions
  * Copyright (c) 2007 Loren Merritt
  *
  * This file is part of Libav.
diff --git a/deps/libav/libavcodec/x86/motion_est.c b/deps/libav/libavcodec/x86/motion_est.c
index 41b9c5c..d126012 100644
--- a/deps/libav/libavcodec/x86/motion_est.c
+++ b/deps/libav/libavcodec/x86/motion_est.c
@@ -31,18 +31,18 @@
 
 #if HAVE_INLINE_ASM
 
-DECLARE_ASM_CONST(8, uint64_t, round_tab)[3]={
-0x0000000000000000ULL,
-0x0001000100010001ULL,
-0x0002000200020002ULL,
+DECLARE_ASM_CONST(8, uint64_t, round_tab)[3] = {
+    0x0000000000000000ULL,
+    0x0001000100010001ULL,
+    0x0002000200020002ULL,
 };
 
-DECLARE_ASM_CONST(8, uint64_t, bone)= 0x0101010101010101LL;
+DECLARE_ASM_CONST(8, uint64_t, bone) = 0x0101010101010101LL;
 
 static inline void sad8_1_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
 {
-    x86_reg len= -(stride*h);
-    __asm__ volatile(
+    x86_reg len = -(stride * h);
+    __asm__ volatile (
         ".p2align 4                     \n\t"
         "1:                             \n\t"
         "movq (%1, %%"REG_a"), %%mm0    \n\t"
@@ -71,14 +71,13 @@ static inline void sad8_1_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
         "add %3, %%"REG_a"              \n\t"
         " js 1b                         \n\t"
         : "+a" (len)
-        : "r" (blk1 - len), "r" (blk2 - len), "r" ((x86_reg)stride)
-    );
+        : "r" (blk1 - len), "r" (blk2 - len), "r" ((x86_reg) stride));
 }
 
 static inline void sad8_1_mmxext(uint8_t *blk1, uint8_t *blk2,
                                  int stride, int h)
 {
-    __asm__ volatile(
+    __asm__ volatile (
         ".p2align 4                     \n\t"
         "1:                             \n\t"
         "movq (%1), %%mm0               \n\t"
@@ -92,14 +91,13 @@ static inline void sad8_1_mmxext(uint8_t *blk1, uint8_t *blk2,
         "sub $2, %0                     \n\t"
         " jg 1b                         \n\t"
         : "+r" (h), "+r" (blk1), "+r" (blk2)
-        : "r" ((x86_reg)stride)
-    );
+        : "r" ((x86_reg) stride));
 }
 
 static int sad16_sse2(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)
 {
     int ret;
-    __asm__ volatile(
+    __asm__ volatile (
         "pxor %%xmm2, %%xmm2            \n\t"
         ".p2align 4                     \n\t"
         "1:                             \n\t"
@@ -116,16 +114,15 @@ static int sad16_sse2(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)
         "movhlps %%xmm2, %%xmm0         \n\t"
         "paddw   %%xmm0, %%xmm2         \n\t"
         "movd    %%xmm2, %3             \n\t"
-        : "+r" (h), "+r" (blk1), "+r" (blk2), "=r"(ret)
-        : "r" ((x86_reg)stride)
-    );
+        : "+r" (h), "+r" (blk1), "+r" (blk2), "=r" (ret)
+        : "r" ((x86_reg) stride));
     return ret;
 }
 
 static inline void sad8_x2a_mmxext(uint8_t *blk1, uint8_t *blk2,
                                    int stride, int h)
 {
-    __asm__ volatile(
+    __asm__ volatile (
         ".p2align 4                     \n\t"
         "1:                             \n\t"
         "movq (%1), %%mm0               \n\t"
@@ -141,14 +138,13 @@ static inline void sad8_x2a_mmxext(uint8_t *blk1, uint8_t *blk2,
         "sub $2, %0                     \n\t"
         " jg 1b                         \n\t"
         : "+r" (h), "+r" (blk1), "+r" (blk2)
-        : "r" ((x86_reg)stride)
-    );
+        : "r" ((x86_reg) stride));
 }
 
 static inline void sad8_y2a_mmxext(uint8_t *blk1, uint8_t *blk2,
                                    int stride, int h)
 {
-    __asm__ volatile(
+    __asm__ volatile (
         "movq (%1), %%mm0               \n\t"
         "add %3, %1                     \n\t"
         ".p2align 4                     \n\t"
@@ -167,14 +163,13 @@ static inline void sad8_y2a_mmxext(uint8_t *blk1, uint8_t *blk2,
         "sub $2, %0                     \n\t"
         " jg 1b                         \n\t"
         : "+r" (h), "+r" (blk1), "+r" (blk2)
-        : "r" ((x86_reg)stride)
-    );
+        : "r" ((x86_reg) stride));
 }
 
 static inline void sad8_4_mmxext(uint8_t *blk1, uint8_t *blk2,
                                  int stride, int h)
 {
-    __asm__ volatile(
+    __asm__ volatile (
         "movq "MANGLE(bone)", %%mm5     \n\t"
         "movq (%1), %%mm0               \n\t"
         "pavgb 1(%1), %%mm0             \n\t"
@@ -198,14 +193,14 @@ static inline void sad8_4_mmxext(uint8_t *blk1, uint8_t *blk2,
         "sub $2, %0                     \n\t"
         " jg 1b                         \n\t"
         : "+r" (h), "+r" (blk1), "+r" (blk2)
-        : "r" ((x86_reg)stride)
-    );
+        : "r" ((x86_reg) stride));
 }
 
-static inline void sad8_2_mmx(uint8_t *blk1a, uint8_t *blk1b, uint8_t *blk2, int stride, int h)
+static inline void sad8_2_mmx(uint8_t *blk1a, uint8_t *blk1b, uint8_t *blk2,
+                              int stride, int h)
 {
-    x86_reg len= -(stride*h);
-    __asm__ volatile(
+    x86_reg len = -(stride * h);
+    __asm__ volatile (
         ".p2align 4                     \n\t"
         "1:                             \n\t"
         "movq (%1, %%"REG_a"), %%mm0    \n\t"
@@ -236,15 +231,15 @@ static inline void sad8_2_mmx(uint8_t *blk1a, uint8_t *blk1b, uint8_t *blk2, int
         "add %4, %%"REG_a"              \n\t"
         " js 1b                         \n\t"
         : "+a" (len)
-        : "r" (blk1a - len), "r" (blk1b -len), "r" (blk2 - len), "r" ((x86_reg)stride)
-    );
+        : "r" (blk1a - len), "r" (blk1b - len), "r" (blk2 - len),
+          "r" ((x86_reg) stride));
 }
 
 static inline void sad8_4_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
 {
-    x86_reg len= -(stride*h);
-    __asm__ volatile(
-        "movq (%1, %%"REG_a"), %%mm0    \n\t"
+    x86_reg len = -(stride * h);
+    __asm__ volatile (
+        "movq  (%1, %%"REG_a"), %%mm0   \n\t"
         "movq 1(%1, %%"REG_a"), %%mm2   \n\t"
         "movq %%mm0, %%mm1              \n\t"
         "movq %%mm2, %%mm3              \n\t"
@@ -256,7 +251,7 @@ static inline void sad8_4_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
         "paddw %%mm3, %%mm1             \n\t"
         ".p2align 4                     \n\t"
         "1:                             \n\t"
-        "movq (%2, %%"REG_a"), %%mm2    \n\t"
+        "movq  (%2, %%"REG_a"), %%mm2   \n\t"
         "movq 1(%2, %%"REG_a"), %%mm4   \n\t"
         "movq %%mm2, %%mm3              \n\t"
         "movq %%mm4, %%mm5              \n\t"
@@ -289,14 +284,14 @@ static inline void sad8_4_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
         "add %4, %%"REG_a"              \n\t"
         " js 1b                         \n\t"
         : "+a" (len)
-        : "r" (blk1 - len), "r" (blk1 -len + stride), "r" (blk2 - len), "r" ((x86_reg)stride)
-    );
+        : "r" (blk1 - len), "r" (blk1 - len + stride), "r" (blk2 - len),
+          "r" ((x86_reg) stride));
 }
 
 static inline int sum_mmx(void)
 {
     int ret;
-    __asm__ volatile(
+    __asm__ volatile (
         "movq %%mm6, %%mm0              \n\t"
         "psrlq $32, %%mm6               \n\t"
         "paddw %%mm0, %%mm6             \n\t"
@@ -304,129 +299,145 @@ static inline int sum_mmx(void)
         "psrlq $16, %%mm6               \n\t"
         "paddw %%mm0, %%mm6             \n\t"
         "movd %%mm6, %0                 \n\t"
-        : "=r" (ret)
-    );
-    return ret&0xFFFF;
+        : "=r" (ret));
+    return ret & 0xFFFF;
 }
 
 static inline int sum_mmxext(void)
 {
     int ret;
-    __asm__ volatile(
+    __asm__ volatile (
         "movd %%mm6, %0                 \n\t"
-        : "=r" (ret)
-    );
+        : "=r" (ret));
     return ret;
 }
 
 static inline void sad8_x2a_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
 {
-    sad8_2_mmx(blk1, blk1+1, blk2, stride, h);
+    sad8_2_mmx(blk1, blk1 + 1, blk2, stride, h);
 }
+
 static inline void sad8_y2a_mmx(uint8_t *blk1, uint8_t *blk2, int stride, int h)
 {
-    sad8_2_mmx(blk1, blk1+stride, blk2, stride, h);
+    sad8_2_mmx(blk1, blk1 + stride, blk2, stride, h);
 }
 
-
-#define PIX_SAD(suf)\
-static int sad8_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
-    assert(h==8);\
-    __asm__ volatile("pxor %%mm7, %%mm7     \n\t"\
-                 "pxor %%mm6, %%mm6     \n\t":);\
-\
-    sad8_1_ ## suf(blk1, blk2, stride, 8);\
-\
-    return sum_ ## suf();\
-}\
-static int sad8_x2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
-    assert(h==8);\
-    __asm__ volatile("pxor %%mm7, %%mm7     \n\t"\
-                 "pxor %%mm6, %%mm6     \n\t"\
-                 "movq %0, %%mm5        \n\t"\
-                 :: "m"(round_tab[1]) \
-                 );\
-\
-    sad8_x2a_ ## suf(blk1, blk2, stride, 8);\
-\
-    return sum_ ## suf();\
-}\
-\
-static int sad8_y2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
-    assert(h==8);\
-    __asm__ volatile("pxor %%mm7, %%mm7     \n\t"\
-                 "pxor %%mm6, %%mm6     \n\t"\
-                 "movq %0, %%mm5        \n\t"\
-                 :: "m"(round_tab[1]) \
-                 );\
-\
-    sad8_y2a_ ## suf(blk1, blk2, stride, 8);\
-\
-    return sum_ ## suf();\
-}\
-\
-static int sad8_xy2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
-    assert(h==8);\
-    __asm__ volatile("pxor %%mm7, %%mm7     \n\t"\
-                 "pxor %%mm6, %%mm6     \n\t"\
-                 ::);\
-\
-    sad8_4_ ## suf(blk1, blk2, stride, 8);\
-\
-    return sum_ ## suf();\
-}\
-\
-static int sad16_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
-    __asm__ volatile("pxor %%mm7, %%mm7     \n\t"\
-                 "pxor %%mm6, %%mm6     \n\t":);\
-\
-    sad8_1_ ## suf(blk1  , blk2  , stride, h);\
-    sad8_1_ ## suf(blk1+8, blk2+8, stride, h);\
-\
-    return sum_ ## suf();\
-}\
-static int sad16_x2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
-    __asm__ volatile("pxor %%mm7, %%mm7     \n\t"\
-                 "pxor %%mm6, %%mm6     \n\t"\
-                 "movq %0, %%mm5        \n\t"\
-                 :: "m"(round_tab[1]) \
-                 );\
-\
-    sad8_x2a_ ## suf(blk1  , blk2  , stride, h);\
-    sad8_x2a_ ## suf(blk1+8, blk2+8, stride, h);\
-\
-    return sum_ ## suf();\
-}\
-static int sad16_y2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
-    __asm__ volatile("pxor %%mm7, %%mm7     \n\t"\
-                 "pxor %%mm6, %%mm6     \n\t"\
-                 "movq %0, %%mm5        \n\t"\
-                 :: "m"(round_tab[1]) \
-                 );\
-\
-    sad8_y2a_ ## suf(blk1  , blk2  , stride, h);\
-    sad8_y2a_ ## suf(blk1+8, blk2+8, stride, h);\
-\
-    return sum_ ## suf();\
-}\
-static int sad16_xy2_ ## suf(void *v, uint8_t *blk2, uint8_t *blk1, int stride, int h)\
-{\
-    __asm__ volatile("pxor %%mm7, %%mm7     \n\t"\
-                 "pxor %%mm6, %%mm6     \n\t"\
-                 ::);\
-\
-    sad8_4_ ## suf(blk1  , blk2  , stride, h);\
-    sad8_4_ ## suf(blk1+8, blk2+8, stride, h);\
-\
-    return sum_ ## suf();\
-}\
+#define PIX_SAD(suf)                                                    \
+static int sad8_ ## suf(void *v, uint8_t *blk2,                         \
+                        uint8_t *blk1, int stride, int h)               \
+{                                                                       \
+    assert(h == 8);                                                     \
+    __asm__ volatile (                                                  \
+        "pxor %%mm7, %%mm7     \n\t"                                    \
+        "pxor %%mm6, %%mm6     \n\t"                                    \
+        :);                                                             \
+                                                                        \
+    sad8_1_ ## suf(blk1, blk2, stride, 8);                              \
+                                                                        \
+    return sum_ ## suf();                                               \
+}                                                                       \
+                                                                        \
+static int sad8_x2_ ## suf(void *v, uint8_t *blk2,                      \
+                           uint8_t *blk1, int stride, int h)            \
+{                                                                       \
+    assert(h == 8);                                                     \
+    __asm__ volatile (                                                  \
+        "pxor %%mm7, %%mm7     \n\t"                                    \
+        "pxor %%mm6, %%mm6     \n\t"                                    \
+        "movq %0, %%mm5        \n\t"                                    \
+        :: "m" (round_tab[1]));                                         \
+                                                                        \
+    sad8_x2a_ ## suf(blk1, blk2, stride, 8);                            \
+                                                                        \
+    return sum_ ## suf();                                               \
+}                                                                       \
+                                                                        \
+static int sad8_y2_ ## suf(void *v, uint8_t *blk2,                      \
+                           uint8_t *blk1, int stride, int h)            \
+{                                                                       \
+    assert(h == 8);                                                     \
+    __asm__ volatile (                                                  \
+        "pxor %%mm7, %%mm7     \n\t"                                    \
+        "pxor %%mm6, %%mm6     \n\t"                                    \
+        "movq %0, %%mm5        \n\t"                                    \
+        :: "m" (round_tab[1]));                                         \
+                                                                        \
+    sad8_y2a_ ## suf(blk1, blk2, stride, 8);                            \
+                                                                        \
+    return sum_ ## suf();                                               \
+}                                                                       \
+                                                                        \
+static int sad8_xy2_ ## suf(void *v, uint8_t *blk2,                     \
+                            uint8_t *blk1, int stride, int h)           \
+{                                                                       \
+    assert(h == 8);                                                     \
+    __asm__ volatile (                                                  \
+        "pxor %%mm7, %%mm7     \n\t"                                    \
+        "pxor %%mm6, %%mm6     \n\t"                                    \
+        ::);                                                            \
+                                                                        \
+    sad8_4_ ## suf(blk1, blk2, stride, 8);                              \
+                                                                        \
+    return sum_ ## suf();                                               \
+}                                                                       \
+                                                                        \
+static int sad16_ ## suf(void *v, uint8_t *blk2,                        \
+                         uint8_t *blk1, int stride, int h)              \
+{                                                                       \
+    __asm__ volatile (                                                  \
+        "pxor %%mm7, %%mm7     \n\t"                                    \
+        "pxor %%mm6, %%mm6     \n\t"                                    \
+        :);                                                             \
+                                                                        \
+    sad8_1_ ## suf(blk1,     blk2,     stride, h);                      \
+    sad8_1_ ## suf(blk1 + 8, blk2 + 8, stride, h);                      \
+                                                                        \
+    return sum_ ## suf();                                               \
+}                                                                       \
+                                                                        \
+static int sad16_x2_ ## suf(void *v, uint8_t *blk2,                     \
+                            uint8_t *blk1, int stride, int h)           \
+{                                                                       \
+    __asm__ volatile (                                                  \
+        "pxor %%mm7, %%mm7     \n\t"                                    \
+        "pxor %%mm6, %%mm6     \n\t"                                    \
+        "movq %0, %%mm5        \n\t"                                    \
+        :: "m" (round_tab[1]));                                         \
+                                                                        \
+    sad8_x2a_ ## suf(blk1,     blk2,     stride, h);                    \
+    sad8_x2a_ ## suf(blk1 + 8, blk2 + 8, stride, h);                    \
+                                                                        \
+    return sum_ ## suf();                                               \
+}                                                                       \
+                                                                        \
+static int sad16_y2_ ## suf(void *v, uint8_t *blk2,                     \
+                            uint8_t *blk1, int stride, int h)           \
+{                                                                       \
+    __asm__ volatile (                                                  \
+        "pxor %%mm7, %%mm7     \n\t"                                    \
+        "pxor %%mm6, %%mm6     \n\t"                                    \
+        "movq %0, %%mm5        \n\t"                                    \
+        :: "m" (round_tab[1]));                                         \
+                                                                        \
+    sad8_y2a_ ## suf(blk1,     blk2,     stride, h);                    \
+    sad8_y2a_ ## suf(blk1 + 8, blk2 + 8, stride, h);                    \
+                                                                        \
+    return sum_ ## suf();                                               \
+}                                                                       \
+                                                                        \
+static int sad16_xy2_ ## suf(void *v, uint8_t *blk2,                    \
+                             uint8_t *blk1, int stride, int h)          \
+{                                                                       \
+    __asm__ volatile (                                                  \
+        "pxor %%mm7, %%mm7     \n\t"                                    \
+        "pxor %%mm6, %%mm6     \n\t"                                    \
+        ::);                                                            \
+                                                                        \
+    sad8_4_ ## suf(blk1,     blk2,     stride, h);                      \
+    sad8_4_ ## suf(blk1 + 8, blk2 + 8, stride, h);                      \
+                                                                        \
+    return sum_ ## suf();                                               \
+}                                                                       \
 
 PIX_SAD(mmx)
 PIX_SAD(mmxext)
@@ -448,17 +459,17 @@ av_cold void ff_dsputil_init_pix_mmx(DSPContext *c, AVCodecContext *avctx)
         c->pix_abs[1][2] = sad8_y2_mmx;
         c->pix_abs[1][3] = sad8_xy2_mmx;
 
-        c->sad[0]= sad16_mmx;
-        c->sad[1]= sad8_mmx;
+        c->sad[0] = sad16_mmx;
+        c->sad[1] = sad8_mmx;
     }
     if (INLINE_MMXEXT(cpu_flags)) {
         c->pix_abs[0][0] = sad16_mmxext;
         c->pix_abs[1][0] = sad8_mmxext;
 
-        c->sad[0]        = sad16_mmxext;
-        c->sad[1]        = sad8_mmxext;
+        c->sad[0] = sad16_mmxext;
+        c->sad[1] = sad8_mmxext;
 
-        if(!(avctx->flags & CODEC_FLAG_BITEXACT)){
+        if (!(avctx->flags & CODEC_FLAG_BITEXACT)) {
             c->pix_abs[0][1] = sad16_x2_mmxext;
             c->pix_abs[0][2] = sad16_y2_mmxext;
             c->pix_abs[0][3] = sad16_xy2_mmxext;
@@ -468,7 +479,7 @@ av_cold void ff_dsputil_init_pix_mmx(DSPContext *c, AVCodecContext *avctx)
         }
     }
     if (INLINE_SSE2(cpu_flags) && !(cpu_flags & AV_CPU_FLAG_3DNOW)) {
-        c->sad[0]= sad16_sse2;
+        c->sad[0] = sad16_sse2;
     }
 #endif /* HAVE_INLINE_ASM */
 }
diff --git a/deps/libav/libavcodec/x86/mpeg4qpel.asm b/deps/libav/libavcodec/x86/mpeg4qpel.asm
index df20ea9..2cdd84b 100644
--- a/deps/libav/libavcodec/x86/mpeg4qpel.asm
+++ b/deps/libav/libavcodec/x86/mpeg4qpel.asm
@@ -31,7 +31,7 @@ cextern pw_20
 
 SECTION_TEXT
 
-; put_no_rnd_pixels8_l2(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
+; void ff_put_no_rnd_pixels8_l2(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
 %macro PUT_NO_RND_PIXELS8_L2 0
 cglobal put_no_rnd_pixels8_l2, 6,6
     movsxdifnidn r4, r4d
@@ -97,7 +97,7 @@ INIT_MMX mmxext
 PUT_NO_RND_PIXELS8_L2
 
 
-; put_no_rnd_pixels16_l2(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
+; void ff_put_no_rnd_pixels16_l2(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
 %macro PUT_NO_RND_PIXELS16_l2 0
 cglobal put_no_rnd_pixels16_l2, 6,6
     movsxdifnidn r3, r3d
diff --git a/deps/libav/libavcodec/x86/mpegaudiodsp.c b/deps/libav/libavcodec/x86/mpegaudiodsp.c
index f45cb7e..533b4a7 100644
--- a/deps/libav/libavcodec/x86/mpegaudiodsp.c
+++ b/deps/libav/libavcodec/x86/mpegaudiodsp.c
@@ -1,5 +1,5 @@
 /*
- * MMX optimized MP3 decoding functions
+ * SIMD-optimized MP3 decoding functions
  * Copyright (c) 2010 Vitor Sessak
  *
  * This file is part of Libav.
diff --git a/deps/libav/libavcodec/x86/mpegvideoenc_template.c b/deps/libav/libavcodec/x86/mpegvideoenc_template.c
index a8d2a2c..ed00e8e 100644
--- a/deps/libav/libavcodec/x86/mpegvideoenc_template.c
+++ b/deps/libav/libavcodec/x86/mpegvideoenc_template.c
@@ -267,50 +267,6 @@ static int RENAME(dct_quantize)(MpegEncContext *s,
         block[0x3E] = temp_block[0x3D]; block[0x27] = temp_block[0x36];
         block[0x3D] = temp_block[0x2F]; block[0x2F] = temp_block[0x37];
         block[0x37] = temp_block[0x3E]; block[0x3F] = temp_block[0x3F];
-    }else if(s->dsp.idct_permutation_type == FF_LIBMPEG2_IDCT_PERM){
-        if(last_non_zero_p1 <= 1) goto end;
-        block[0x04] = temp_block[0x01];
-        block[0x08] = temp_block[0x08]; block[0x10] = temp_block[0x10];
-        if(last_non_zero_p1 <= 4) goto end;
-        block[0x0C] = temp_block[0x09]; block[0x01] = temp_block[0x02];
-        block[0x05] = temp_block[0x03];
-        if(last_non_zero_p1 <= 7) goto end;
-        block[0x09] = temp_block[0x0A]; block[0x14] = temp_block[0x11];
-        block[0x18] = temp_block[0x18]; block[0x20] = temp_block[0x20];
-        if(last_non_zero_p1 <= 11) goto end;
-        block[0x1C] = temp_block[0x19];
-        block[0x11] = temp_block[0x12]; block[0x0D] = temp_block[0x0B];
-        block[0x02] = temp_block[0x04]; block[0x06] = temp_block[0x05];
-        if(last_non_zero_p1 <= 16) goto end;
-        block[0x0A] = temp_block[0x0C]; block[0x15] = temp_block[0x13];
-        block[0x19] = temp_block[0x1A]; block[0x24] = temp_block[0x21];
-        block[0x28] = temp_block[0x28]; block[0x30] = temp_block[0x30];
-        block[0x2C] = temp_block[0x29]; block[0x21] = temp_block[0x22];
-        if(last_non_zero_p1 <= 24) goto end;
-        block[0x1D] = temp_block[0x1B]; block[0x12] = temp_block[0x14];
-        block[0x0E] = temp_block[0x0D]; block[0x03] = temp_block[0x06];
-        block[0x07] = temp_block[0x07]; block[0x0B] = temp_block[0x0E];
-        block[0x16] = temp_block[0x15]; block[0x1A] = temp_block[0x1C];
-        if(last_non_zero_p1 <= 32) goto end;
-        block[0x25] = temp_block[0x23]; block[0x29] = temp_block[0x2A];
-        block[0x34] = temp_block[0x31]; block[0x38] = temp_block[0x38];
-        block[0x3C] = temp_block[0x39]; block[0x31] = temp_block[0x32];
-        block[0x2D] = temp_block[0x2B]; block[0x22] = temp_block[0x24];
-        if(last_non_zero_p1 <= 40) goto end;
-        block[0x1E] = temp_block[0x1D]; block[0x13] = temp_block[0x16];
-        block[0x0F] = temp_block[0x0F]; block[0x17] = temp_block[0x17];
-        block[0x1B] = temp_block[0x1E]; block[0x26] = temp_block[0x25];
-        block[0x2A] = temp_block[0x2C]; block[0x35] = temp_block[0x33];
-        if(last_non_zero_p1 <= 48) goto end;
-        block[0x39] = temp_block[0x3A]; block[0x3D] = temp_block[0x3B];
-        block[0x32] = temp_block[0x34]; block[0x2E] = temp_block[0x2D];
-            block[0x23] = temp_block[0x26]; block[0x1F] = temp_block[0x1F];
-        block[0x27] = temp_block[0x27]; block[0x2B] = temp_block[0x2E];
-        if(last_non_zero_p1 <= 56) goto end;
-        block[0x36] = temp_block[0x35]; block[0x3A] = temp_block[0x3C];
-        block[0x3E] = temp_block[0x3D]; block[0x33] = temp_block[0x36];
-        block[0x2F] = temp_block[0x2F]; block[0x37] = temp_block[0x37];
-        block[0x3B] = temp_block[0x3E]; block[0x3F] = temp_block[0x3F];
     }else{
         if(last_non_zero_p1 <= 1) goto end;
         block[0x01] = temp_block[0x01];
diff --git a/deps/libav/libavcodec/x86/proresdsp.asm b/deps/libav/libavcodec/x86/proresdsp.asm
index 855f209..a0e97b3 100644
--- a/deps/libav/libavcodec/x86/proresdsp.asm
+++ b/deps/libav/libavcodec/x86/proresdsp.asm
@@ -326,8 +326,8 @@ section .text align=16
     SUMSUB_SHPK m2,  m3,  m4,  m5,  m6,  m7,  %2
 %endmacro
 
-; void prores_idct_put_10_<opt>(uint8_t *pixels, int stride,
-;                               int16_t *block, const int16_t *qmat);
+; void ff_prores_idct_put_10_<opt>(uint8_t *pixels, int stride,
+;                                  int16_t *block, const int16_t *qmat);
 %macro idct_put_fn 1
 cglobal prores_idct_put_10, 4, 4, %1
     movsxd      r1,  r1d
diff --git a/deps/libav/libavcodec/x86/proresdsp_init.c b/deps/libav/libavcodec/x86/proresdsp_init.c
index d63382c..68ad929 100644
--- a/deps/libav/libavcodec/x86/proresdsp_init.c
+++ b/deps/libav/libavcodec/x86/proresdsp_init.c
@@ -32,7 +32,7 @@ void ff_prores_idct_put_10_sse4(uint16_t *dst, int linesize,
 void ff_prores_idct_put_10_avx (uint16_t *dst, int linesize,
                                 int16_t *block, const int16_t *qmat);
 
-av_cold void ff_proresdsp_x86_init(ProresDSPContext *dsp)
+av_cold void ff_proresdsp_init_x86(ProresDSPContext *dsp)
 {
 #if ARCH_X86_64
     int cpu_flags = av_get_cpu_flags();
diff --git a/deps/libav/libavcodec/x86/qpel.asm b/deps/libav/libavcodec/x86/qpel.asm
index c90b393..27a1c63 100644
--- a/deps/libav/libavcodec/x86/qpel.asm
+++ b/deps/libav/libavcodec/x86/qpel.asm
@@ -1,5 +1,5 @@
 ;******************************************************************************
-;* MMX optimized DSP utils
+;* SIMD-optimized quarterpel functions
 ;* Copyright (c) 2008 Loren Merritt
 ;* Copyright (c) 2003-2013 Michael Niedermayer
 ;* Copyright (c) 2013 Daniel Kang
@@ -44,7 +44,8 @@ SECTION .text
     mova   %2, %1
 %endmacro
 
-; void pixels4_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
+; void ff_put/avg_pixels4_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
+;                                   int dstStride, int src1Stride, int h)
 %macro PIXELS4_L2 1
 %define OP op_%1h
 cglobal %1_pixels4_l2, 6,6
@@ -87,7 +88,8 @@ INIT_MMX mmxext
 PIXELS4_L2 put
 PIXELS4_L2 avg
 
-; void pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
+; void ff_put/avg_pixels8_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
+;                                   int dstStride, int src1Stride, int h)
 %macro PIXELS8_L2 1
 %define OP op_%1
 cglobal %1_pixels8_l2, 6,6
@@ -130,7 +132,8 @@ INIT_MMX mmxext
 PIXELS8_L2 put
 PIXELS8_L2 avg
 
-; void pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2, int dstStride, int src1Stride, int h)
+; void ff_put/avg_pixels16_l2_mmxext(uint8_t *dst, uint8_t *src1, uint8_t *src2,
+;                                    int dstStride, int src1Stride, int h)
 %macro PIXELS16_L2 1
 %define OP op_%1
 cglobal %1_pixels16_l2, 6,6
diff --git a/deps/libav/libavcodec/x86/rnd_template.c b/deps/libav/libavcodec/x86/rnd_template.c
index e9a5a45..144f111 100644
--- a/deps/libav/libavcodec/x86/rnd_template.c
+++ b/deps/libav/libavcodec/x86/rnd_template.c
@@ -1,5 +1,5 @@
 /*
- * DSP utils mmx functions are compiled twice for rnd/no_rnd
+ * SIMD-optimized halfpel functions are compiled twice for rnd/no_rnd
  * Copyright (c) 2000, 2001 Fabrice Bellard
  * Copyright (c) 2003-2004 Michael Niedermayer <michaelni at gmx.at>
  *
diff --git a/deps/libav/libavcodec/x86/rv40dsp.asm b/deps/libav/libavcodec/x86/rv40dsp.asm
index d12b079..1a33aa0 100644
--- a/deps/libav/libavcodec/x86/rv40dsp.asm
+++ b/deps/libav/libavcodec/x86/rv40dsp.asm
@@ -77,9 +77,9 @@ SECTION .text
 ;-----------------------------------------------------------------------------
 ; subpel MC functions:
 ;
-; void [put|rv40]_rv40_qpel_[h|v]_<opt>(uint8_t *dst, int deststride,
-;                                       uint8_t *src, int srcstride,
-;                                       int len, int m);
+; void ff_[put|rv40]_rv40_qpel_[h|v]_<opt>(uint8_t *dst, int deststride,
+;                                          uint8_t *src, int srcstride,
+;                                          int len, int m);
 ;----------------------------------------------------------------------
 %macro LOAD  2
 %if WIN64
@@ -438,7 +438,7 @@ FILTER_SSSE3  avg
 
 %endmacro
 
-; rv40_weight_func_%1(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w1, int w2, int stride)
+; void ff_rv40_weight_func_%1(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w1, int w2, int stride)
 ; %1=size  %2=num of xmm regs
 ; The weights are FP0.14 notation of fractions depending on pts.
 ; For timebases without rounding error (i.e. PAL), the fractions
diff --git a/deps/libav/libavcodec/x86/sbrdsp.asm b/deps/libav/libavcodec/x86/sbrdsp.asm
index 36a0918..d7164b6 100644
--- a/deps/libav/libavcodec/x86/sbrdsp.asm
+++ b/deps/libav/libavcodec/x86/sbrdsp.asm
@@ -118,9 +118,9 @@ cglobal sbr_hf_g_filt, 5, 6, 5
 .end:
     RET
 
-; static void sbr_hf_gen_c(float (*X_high)[2], const float (*X_low)[2],
-;                          const float alpha0[2], const float alpha1[2],
-;                          float bw, int start, int end)
+; void ff_sbr_hf_gen_sse(float (*X_high)[2], const float (*X_low)[2],
+;                        const float alpha0[2], const float alpha1[2],
+;                        float bw, int start, int end)
 ;
 cglobal sbr_hf_gen, 4,4,8, X_high, X_low, alpha0, alpha1, BW, S, E
     ; load alpha factors
@@ -247,7 +247,7 @@ cglobal sbr_neg_odd_64, 1,2,4,z
     REP_RET
 
 INIT_XMM sse2
-; sbr_qmf_deint_bfly(float *v, const float *src0, const float *src1)
+; void ff_sbr_qmf_deint_bfly_sse2(float *v, const float *src0, const float *src1)
 cglobal sbr_qmf_deint_bfly, 3,5,8, v,src0,src1,vrev,c
     mov               cq, 64*4-2*mmsize
     lea            vrevq, [vq + 64*4]
diff --git a/deps/libav/libavcodec/x86/simple_idct.c b/deps/libav/libavcodec/x86/simple_idct.c
index 36f0b47..a342110 100644
--- a/deps/libav/libavcodec/x86/simple_idct.c
+++ b/deps/libav/libavcodec/x86/simple_idct.c
@@ -22,6 +22,7 @@
 #include "libavcodec/simple_idct.h"
 #include "libavutil/internal.h"
 #include "libavutil/mem.h"
+#include "libavutil/x86/asm.h"
 #include "dsputil_x86.h"
 
 #if HAVE_INLINE_ASM
diff --git a/deps/libav/libavcodec/x86/vp8dsp.asm b/deps/libav/libavcodec/x86/vp8dsp.asm
index d41b6b4..2f05334 100644
--- a/deps/libav/libavcodec/x86/vp8dsp.asm
+++ b/deps/libav/libavcodec/x86/vp8dsp.asm
@@ -153,13 +153,13 @@ cextern pw_64
 
 SECTION .text
 
-;-----------------------------------------------------------------------------
+;-------------------------------------------------------------------------------
 ; subpel MC functions:
 ;
-; void put_vp8_epel<size>_h<htap>v<vtap>_<opt>(uint8_t *dst, int deststride,
-;                                              uint8_t *src, int srcstride,
-;                                              int height,   int mx, int my);
-;-----------------------------------------------------------------------------
+; void ff_put_vp8_epel<size>_h<htap>v<vtap>_<opt>(uint8_t *dst, int deststride,
+;                                                 uint8_t *src, int srcstride,
+;                                                 int height,   int mx, int my);
+;-------------------------------------------------------------------------------
 
 %macro FILTER_SSSE3 1
 cglobal put_vp8_epel%1_h6, 6, 6 + npicregs, 8, dst, dststride, src, srcstride, height, mx, picreg
@@ -884,7 +884,7 @@ cglobal put_vp8_pixels16, 5, 5, 2, dst, dststride, src, srcstride, height
     REP_RET
 
 ;-----------------------------------------------------------------------------
-; void vp8_idct_dc_add_<opt>(uint8_t *dst, int16_t block[16], int stride);
+; void ff_vp8_idct_dc_add_<opt>(uint8_t *dst, int16_t block[16], int stride);
 ;-----------------------------------------------------------------------------
 
 %macro ADD_DC 4
@@ -962,7 +962,7 @@ cglobal vp8_idct_dc_add, 3, 3, 6, dst, block, stride
     RET
 
 ;-----------------------------------------------------------------------------
-; void vp8_idct_dc_add4y_<opt>(uint8_t *dst, int16_t block[4][16], int stride);
+; void ff_vp8_idct_dc_add4y_<opt>(uint8_t *dst, int16_t block[4][16], int stride);
 ;-----------------------------------------------------------------------------
 
 %if ARCH_X86_32
@@ -1035,7 +1035,7 @@ cglobal vp8_idct_dc_add4y, 3, 3, 6, dst, block, stride
     RET
 
 ;-----------------------------------------------------------------------------
-; void vp8_idct_dc_add4uv_<opt>(uint8_t *dst, int16_t block[4][16], int stride);
+; void ff_vp8_idct_dc_add4uv_<opt>(uint8_t *dst, int16_t block[4][16], int stride);
 ;-----------------------------------------------------------------------------
 
 INIT_MMX mmx
@@ -1077,7 +1077,7 @@ cglobal vp8_idct_dc_add4uv, 3, 3, 0, dst, block, stride
     RET
 
 ;-----------------------------------------------------------------------------
-; void vp8_idct_add_<opt>(uint8_t *dst, int16_t block[16], int stride);
+; void ff_vp8_idct_add_<opt>(uint8_t *dst, int16_t block[16], int stride);
 ;-----------------------------------------------------------------------------
 
 ; calculate %1=mul_35468(%1)-mul_20091(%2); %2=mul_20091(%1)+mul_35468(%2)
@@ -1157,7 +1157,7 @@ INIT_MMX sse
 VP8_IDCT_ADD
 
 ;-----------------------------------------------------------------------------
-; void vp8_luma_dc_wht_mmxext(int16_t block[4][4][16], int16_t dc[16])
+; void ff_vp8_luma_dc_wht(int16_t block[4][4][16], int16_t dc[16])
 ;-----------------------------------------------------------------------------
 
 %macro SCATTER_WHT 3
diff --git a/deps/libav/libavcodec/x86/vp8dsp_loopfilter.asm b/deps/libav/libavcodec/x86/vp8dsp_loopfilter.asm
index cbad085..8305881 100644
--- a/deps/libav/libavcodec/x86/vp8dsp_loopfilter.asm
+++ b/deps/libav/libavcodec/x86/vp8dsp_loopfilter.asm
@@ -43,7 +43,7 @@ cextern pb_80
 SECTION .text
 
 ;-----------------------------------------------------------------------------
-; void vp8_h/v_loop_filter_simple_<opt>(uint8_t *dst, int stride, int flim);
+; void ff_vp8_h/v_loop_filter_simple_<opt>(uint8_t *dst, int stride, int flim);
 ;-----------------------------------------------------------------------------
 
 ; macro called with 7 mm register indexes as argument, and 4 regular registers
@@ -429,8 +429,8 @@ INIT_XMM sse4
 SIMPLE_LOOPFILTER h, 5
 
 ;-----------------------------------------------------------------------------
-; void vp8_h/v_loop_filter<size>_inner_<opt>(uint8_t *dst, [uint8_t *v,] int stride,
-;                                            int flimE, int flimI, int hev_thr);
+; void ff_vp8_h/v_loop_filter<size>_inner_<opt>(uint8_t *dst, [uint8_t *v,] int stride,
+;                                               int flimE, int flimI, int hev_thr);
 ;-----------------------------------------------------------------------------
 
 %macro INNER_LOOPFILTER 2
@@ -921,8 +921,8 @@ INNER_LOOPFILTER v,  8
 INNER_LOOPFILTER h,  8
 
 ;-----------------------------------------------------------------------------
-; void vp8_h/v_loop_filter<size>_mbedge_<opt>(uint8_t *dst, [uint8_t *v,] int stride,
-;                                            int flimE, int flimI, int hev_thr);
+; void ff_vp8_h/v_loop_filter<size>_mbedge_<opt>(uint8_t *dst, [uint8_t *v,] int stride,
+;                                                int flimE, int flimI, int hev_thr);
 ;-----------------------------------------------------------------------------
 
 %macro MBEDGE_LOOPFILTER 2
diff --git a/deps/libav/libavfilter/Makefile b/deps/libav/libavfilter/Makefile
index 92c1561..5312c83 100644
--- a/deps/libav/libavfilter/Makefile
+++ b/deps/libav/libavfilter/Makefile
@@ -34,6 +34,7 @@ OBJS-$(CONFIG_ASYNCTS_FILTER)                += af_asyncts.o
 OBJS-$(CONFIG_ATRIM_FILTER)                  += trim.o
 OBJS-$(CONFIG_CHANNELMAP_FILTER)             += af_channelmap.o
 OBJS-$(CONFIG_CHANNELSPLIT_FILTER)           += af_channelsplit.o
+OBJS-$(CONFIG_COMPAND_FILTER)                += af_compand.o
 OBJS-$(CONFIG_JOIN_FILTER)                   += af_join.o
 OBJS-$(CONFIG_RESAMPLE_FILTER)               += af_resample.o
 OBJS-$(CONFIG_VOLUME_FILTER)                 += af_volume.o
@@ -77,6 +78,7 @@ OBJS-$(CONFIG_SETPTS_FILTER)                 += setpts.o
 OBJS-$(CONFIG_SETSAR_FILTER)                 += vf_aspect.o
 OBJS-$(CONFIG_SETTB_FILTER)                  += vf_settb.o
 OBJS-$(CONFIG_SHOWINFO_FILTER)               += vf_showinfo.o
+OBJS-$(CONFIG_SHUFFLEPLANES_FILTER)          += vf_shuffleplanes.o
 OBJS-$(CONFIG_SPLIT_FILTER)                  += split.o
 OBJS-$(CONFIG_TRANSPOSE_FILTER)              += vf_transpose.o
 OBJS-$(CONFIG_TRIM_FILTER)                   += trim.o
diff --git a/deps/libav/libavfilter/af_compand.c b/deps/libav/libavfilter/af_compand.c
new file mode 100644
index 0000000..a6692bc
--- /dev/null
+++ b/deps/libav/libavfilter/af_compand.c
@@ -0,0 +1,603 @@
+/*
+ * Copyright (c) 1999 Chris Bagwell
+ * Copyright (c) 1999 Nick Bailey
+ * Copyright (c) 2007 Rob Sykes <robs at users.sourceforge.net>
+ * Copyright (c) 2013 Paul B Mahol
+ * Copyright (c) 2014 Andrew Kelley
+ *
+ * This file is part of libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * audio compand filter
+ */
+
+#include <string.h>
+
+#include "libavutil/avstring.h"
+#include "libavutil/channel_layout.h"
+#include "libavutil/common.h"
+#include "libavutil/mathematics.h"
+#include "libavutil/mem.h"
+#include "libavutil/opt.h"
+#include "audio.h"
+#include "avfilter.h"
+#include "formats.h"
+#include "internal.h"
+
+typedef struct ChanParam {
+    float attack;
+    float decay;
+    float volume;
+} ChanParam;
+
+typedef struct CompandSegment {
+    float x, y;
+    float a, b;
+} CompandSegment;
+
+typedef struct CompandContext {
+    const AVClass *class;
+    int nb_channels;
+    int nb_segments;
+    char *attacks, *decays, *points;
+    CompandSegment *segments;
+    ChanParam *channels;
+    float in_min_lin;
+    float out_min_lin;
+    double curve_dB;
+    double gain_dB;
+    double initial_volume;
+    double delay;
+    AVFrame *delay_frame;
+    int delay_samples;
+    int delay_count;
+    int delay_index;
+    int64_t pts;
+
+    int (*compand)(AVFilterContext *ctx, AVFrame *frame);
+} CompandContext;
+
+#define OFFSET(x) offsetof(CompandContext, x)
+#define A AV_OPT_FLAG_AUDIO_PARAM
+
+static const AVOption compand_options[] = {
+    { "attacks", "set time over which increase of volume is determined", OFFSET(attacks), AV_OPT_TYPE_STRING, { .str = "0.3" }, 0, 0, A },
+    { "decays", "set time over which decrease of volume is determined", OFFSET(decays), AV_OPT_TYPE_STRING, { .str = "0.8" }, 0, 0, A },
+    { "points", "set points of transfer function", OFFSET(points), AV_OPT_TYPE_STRING, { .str = "-70/-70|-60/-20" }, 0, 0, A },
+    { "soft-knee", "set soft-knee", OFFSET(curve_dB), AV_OPT_TYPE_DOUBLE, { .dbl = 0.01 }, 0.01, 900, A },
+    { "gain", "set output gain", OFFSET(gain_dB), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, -900, 900, A },
+    { "volume", "set initial volume", OFFSET(initial_volume), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, -900, 0, A },
+    { "delay", "set delay for samples before sending them to volume adjuster", OFFSET(delay), AV_OPT_TYPE_DOUBLE, { .dbl = 0 }, 0, 20, A },
+    { NULL }
+};
+
+static const AVClass compand_class = {
+    .class_name = "compand filter",
+    .item_name  = av_default_item_name,
+    .option     = compand_options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
+static av_cold int init(AVFilterContext *ctx)
+{
+    CompandContext *s = ctx->priv;
+    s->pts            = AV_NOPTS_VALUE;
+    return 0;
+}
+
+static av_cold void uninit(AVFilterContext *ctx)
+{
+    CompandContext *s = ctx->priv;
+
+    av_freep(&s->channels);
+    av_freep(&s->segments);
+    av_frame_free(&s->delay_frame);
+}
+
+static int query_formats(AVFilterContext *ctx)
+{
+    AVFilterChannelLayouts *layouts;
+    AVFilterFormats *formats;
+    static const enum AVSampleFormat sample_fmts[] = {
+        AV_SAMPLE_FMT_FLTP,
+        AV_SAMPLE_FMT_NONE
+    };
+
+    layouts = ff_all_channel_layouts();
+    if (!layouts)
+        return AVERROR(ENOMEM);
+    ff_set_common_channel_layouts(ctx, layouts);
+
+    formats = ff_make_format_list(sample_fmts);
+    if (!formats)
+        return AVERROR(ENOMEM);
+    ff_set_common_formats(ctx, formats);
+
+    formats = ff_all_samplerates();
+    if (!formats)
+        return AVERROR(ENOMEM);
+    ff_set_common_samplerates(ctx, formats);
+
+    return 0;
+}
+
+static void count_items(char *item_str, int *nb_items)
+{
+    char *p;
+
+    *nb_items = 1;
+    for (p = item_str; *p; p++) {
+        if (*p == '|')
+            (*nb_items)++;
+    }
+}
+
+static void update_volume(ChanParam *cp, float in)
+{
+    float delta = in - cp->volume;
+
+    if (delta > 0.0)
+        cp->volume += delta * cp->attack;
+    else
+        cp->volume += delta * cp->decay;
+}
+
+static float get_volume(CompandContext *s, float in_lin)
+{
+    CompandSegment *cs;
+    float in_log, out_log;
+    int i;
+
+    if (in_lin < s->in_min_lin)
+        return s->out_min_lin;
+
+    in_log = logf(in_lin);
+
+    for (i = 1; i < s->nb_segments; i++)
+        if (in_log <= s->segments[i].x)
+            break;
+    cs = &s->segments[i - 1];
+    in_log -= cs->x;
+    out_log = cs->y + in_log * (cs->a * in_log + cs->b);
+
+    return expf(out_log);
+}
+
+static int compand_nodelay(AVFilterContext *ctx, AVFrame *frame)
+{
+    CompandContext *s    = ctx->priv;
+    AVFilterLink *inlink = ctx->inputs[0];
+    const int channels   = s->nb_channels;
+    const int nb_samples = frame->nb_samples;
+    AVFrame *out_frame;
+    int chan, i;
+    int err;
+
+    if (av_frame_is_writable(frame)) {
+        out_frame = frame;
+    } else {
+        out_frame = ff_get_audio_buffer(inlink, nb_samples);
+        if (!out_frame) {
+            av_frame_free(&frame);
+            return AVERROR(ENOMEM);
+        }
+        err = av_frame_copy_props(out_frame, frame);
+        if (err < 0) {
+            av_frame_free(&out_frame);
+            av_frame_free(&frame);
+            return err;
+        }
+    }
+
+    for (chan = 0; chan < channels; chan++) {
+        const float *src = (float *)frame->extended_data[chan];
+        float *dst = (float *)out_frame->extended_data[chan];
+        ChanParam *cp = &s->channels[chan];
+
+        for (i = 0; i < nb_samples; i++) {
+            update_volume(cp, fabs(src[i]));
+
+            dst[i] = av_clipf(src[i] * get_volume(s, cp->volume), -1.0f, 1.0f);
+        }
+    }
+
+    if (frame != out_frame)
+        av_frame_free(&frame);
+
+    return ff_filter_frame(ctx->outputs[0], out_frame);
+}
+
+#define MOD(a, b) (((a) >= (b)) ? (a) - (b) : (a))
+
+static int compand_delay(AVFilterContext *ctx, AVFrame *frame)
+{
+    CompandContext *s    = ctx->priv;
+    AVFilterLink *inlink = ctx->inputs[0];
+    const int channels   = s->nb_channels;
+    const int nb_samples = frame->nb_samples;
+    int chan, i, dindex  = 0, oindex, count = 0;
+    AVFrame *out_frame   = NULL;
+    int err;
+
+    if (s->pts == AV_NOPTS_VALUE) {
+        s->pts = (frame->pts == AV_NOPTS_VALUE) ? 0 : frame->pts;
+    }
+
+    for (chan = 0; chan < channels; chan++) {
+        AVFrame *delay_frame = s->delay_frame;
+        const float *src     = (float *)frame->extended_data[chan];
+        float *dbuf          = (float *)delay_frame->extended_data[chan];
+        ChanParam *cp        = &s->channels[chan];
+        float *dst;
+
+        count  = s->delay_count;
+        dindex = s->delay_index;
+        for (i = 0, oindex = 0; i < nb_samples; i++) {
+            const float in = src[i];
+            update_volume(cp, fabs(in));
+
+            if (count >= s->delay_samples) {
+                if (!out_frame) {
+                    out_frame = ff_get_audio_buffer(inlink, nb_samples - i);
+                    if (!out_frame) {
+                        av_frame_free(&frame);
+                        return AVERROR(ENOMEM);
+                    }
+                    err = av_frame_copy_props(out_frame, frame);
+                    if (err < 0) {
+                        av_frame_free(&out_frame);
+                        av_frame_free(&frame);
+                        return err;
+                    }
+                    out_frame->pts = s->pts;
+                    s->pts += av_rescale_q(nb_samples - i,
+                        (AVRational){ 1, inlink->sample_rate },
+                        inlink->time_base);
+                }
+
+                dst = (float *)out_frame->extended_data[chan];
+                dst[oindex++] = av_clipf(dbuf[dindex] *
+                        get_volume(s, cp->volume), -1.0f, 1.0f);
+            } else {
+                count++;
+            }
+
+            dbuf[dindex] = in;
+            dindex = MOD(dindex + 1, s->delay_samples);
+        }
+    }
+
+    s->delay_count = count;
+    s->delay_index = dindex;
+
+    av_frame_free(&frame);
+    return out_frame ? ff_filter_frame(ctx->outputs[0], out_frame) : 0;
+}
+
+static int compand_drain(AVFilterLink *outlink)
+{
+    AVFilterContext *ctx = outlink->src;
+    CompandContext *s    = ctx->priv;
+    const int channels   = s->nb_channels;
+    AVFrame *frame       = NULL;
+    int chan, i, dindex;
+
+    /* 2048 is to limit output frame size during drain */
+    frame = ff_get_audio_buffer(outlink, FFMIN(2048, s->delay_count));
+    if (!frame)
+        return AVERROR(ENOMEM);
+    frame->pts = s->pts;
+    s->pts += av_rescale_q(frame->nb_samples,
+            (AVRational){ 1, outlink->sample_rate }, outlink->time_base);
+
+    for (chan = 0; chan < channels; chan++) {
+        AVFrame *delay_frame = s->delay_frame;
+        float *dbuf = (float *)delay_frame->extended_data[chan];
+        float *dst = (float *)frame->extended_data[chan];
+        ChanParam *cp = &s->channels[chan];
+
+        dindex = s->delay_index;
+        for (i = 0; i < frame->nb_samples; i++) {
+            dst[i] = av_clipf(dbuf[dindex] * get_volume(s, cp->volume),
+                    -1.0f, 1.0f);
+            dindex = MOD(dindex + 1, s->delay_samples);
+        }
+    }
+    s->delay_count -= frame->nb_samples;
+    s->delay_index = dindex;
+
+    return ff_filter_frame(outlink, frame);
+}
+
+static int config_output(AVFilterLink *outlink)
+{
+    AVFilterContext *ctx  = outlink->src;
+    CompandContext *s     = ctx->priv;
+    const int sample_rate = outlink->sample_rate;
+    double radius         = s->curve_dB * M_LN10 / 20.0;
+    const char *p;
+    const int channels    =
+        av_get_channel_layout_nb_channels(outlink->channel_layout);
+    int nb_attacks, nb_decays, nb_points;
+    int new_nb_items, num;
+    int i;
+    int err;
+
+
+    count_items(s->attacks, &nb_attacks);
+    count_items(s->decays, &nb_decays);
+    count_items(s->points, &nb_points);
+
+    if (channels <= 0) {
+        av_log(ctx, AV_LOG_ERROR, "Invalid number of channels: %d\n", channels);
+        return AVERROR(EINVAL);
+    }
+
+    if (nb_attacks > channels || nb_decays > channels) {
+        av_log(ctx, AV_LOG_ERROR,
+                "Number of attacks/decays bigger than number of channels.\n");
+        return AVERROR(EINVAL);
+    }
+
+    uninit(ctx);
+
+    s->nb_channels = channels;
+    s->channels = av_mallocz_array(channels, sizeof(*s->channels));
+    s->nb_segments = (nb_points + 4) * 2;
+    s->segments = av_mallocz_array(s->nb_segments, sizeof(*s->segments));
+
+    if (!s->channels || !s->segments) {
+        uninit(ctx);
+        return AVERROR(ENOMEM);
+    }
+
+    p = s->attacks;
+    for (i = 0, new_nb_items = 0; i < nb_attacks; i++) {
+        char *tstr = av_get_token(&p, "|");
+        if (!tstr)
+            return AVERROR(ENOMEM);
+
+        new_nb_items += sscanf(tstr, "%f", &s->channels[i].attack) == 1;
+        av_freep(&tstr);
+        if (s->channels[i].attack < 0) {
+            uninit(ctx);
+            return AVERROR(EINVAL);
+        }
+        if (*p)
+            p++;
+    }
+    nb_attacks = new_nb_items;
+
+    p = s->decays;
+    for (i = 0, new_nb_items = 0; i < nb_decays; i++) {
+        char *tstr = av_get_token(&p, "|");
+        if (!tstr)
+            return AVERROR(ENOMEM);
+        new_nb_items += sscanf(tstr, "%f", &s->channels[i].decay) == 1;
+        av_freep(&tstr);
+        if (s->channels[i].decay < 0) {
+            uninit(ctx);
+            return AVERROR(EINVAL);
+        }
+        if (*p)
+            p++;
+    }
+    nb_decays = new_nb_items;
+
+    if (nb_attacks != nb_decays) {
+        av_log(ctx, AV_LOG_ERROR,
+                "Number of attacks %d differs from number of decays %d.\n",
+                nb_attacks, nb_decays);
+        uninit(ctx);
+        return AVERROR(EINVAL);
+    }
+
+#define S(x) s->segments[2 * ((x) + 1)]
+    p = s->points;
+    for (i = 0, new_nb_items = 0; i < nb_points; i++) {
+        char *tstr = av_get_token(&p, "|");
+        if (!tstr)
+            return AVERROR(ENOMEM);
+
+        err = sscanf(tstr, "%f/%f", &S(i).x, &S(i).y);
+        av_freep(&tstr);
+        if (err != 2) {
+            av_log(ctx, AV_LOG_ERROR,
+                    "Invalid and/or missing input/output value.\n");
+            uninit(ctx);
+            return AVERROR(EINVAL);
+        }
+        if (i && S(i - 1).x > S(i).x) {
+            av_log(ctx, AV_LOG_ERROR,
+                    "Transfer function input values must be increasing.\n");
+            uninit(ctx);
+            return AVERROR(EINVAL);
+        }
+        S(i).y -= S(i).x;
+        av_log(ctx, AV_LOG_DEBUG, "%d: x=%f y=%f\n", i, S(i).x, S(i).y);
+        new_nb_items++;
+        if (*p)
+            p++;
+    }
+    num = new_nb_items;
+
+    /* Add 0,0 if necessary */
+    if (num == 0 || S(num - 1).x)
+        num++;
+
+#undef S
+#define S(x) s->segments[2 * (x)]
+    /* Add a tail off segment at the start */
+    S(0).x = S(1).x - 2 * s->curve_dB;
+    S(0).y = S(1).y;
+    num++;
+
+    /* Join adjacent colinear segments */
+    for (i = 2; i < num; i++) {
+        double g1 = (S(i - 1).y - S(i - 2).y) * (S(i - 0).x - S(i - 1).x);
+        double g2 = (S(i - 0).y - S(i - 1).y) * (S(i - 1).x - S(i - 2).x);
+        int j;
+
+        /* here we purposefully lose precision so that we can compare floats */
+        if (fabs(g1 - g2))
+            continue;
+        num--;
+        for (j = --i; j < num; j++)
+            S(j) = S(j + 1);
+    }
+
+    for (i = 0; !i || s->segments[i - 2].x; i += 2) {
+        s->segments[i].y += s->gain_dB;
+        s->segments[i].x *= M_LN10 / 20;
+        s->segments[i].y *= M_LN10 / 20;
+    }
+
+#define L(x) s->segments[i - (x)]
+    for (i = 4; s->segments[i - 2].x; i += 2) {
+        double x, y, cx, cy, in1, in2, out1, out2, theta, len, r;
+
+        L(4).a = 0;
+        L(4).b = (L(2).y - L(4).y) / (L(2).x - L(4).x);
+
+        L(2).a = 0;
+        L(2).b = (L(0).y - L(2).y) / (L(0).x - L(2).x);
+
+        theta = atan2(L(2).y - L(4).y, L(2).x - L(4).x);
+        len = sqrt(pow(L(2).x - L(4).x, 2.) + pow(L(2).y - L(4).y, 2.));
+        r = FFMIN(radius, len);
+        L(3).x = L(2).x - r * cos(theta);
+        L(3).y = L(2).y - r * sin(theta);
+
+        theta = atan2(L(0).y - L(2).y, L(0).x - L(2).x);
+        len = sqrt(pow(L(0).x - L(2).x, 2.) + pow(L(0).y - L(2).y, 2.));
+        r = FFMIN(radius, len / 2);
+        x = L(2).x + r * cos(theta);
+        y = L(2).y + r * sin(theta);
+
+        cx = (L(3).x + L(2).x + x) / 3;
+        cy = (L(3).y + L(2).y + y) / 3;
+
+        L(2).x = x;
+        L(2).y = y;
+
+        in1  = cx - L(3).x;
+        out1 = cy - L(3).y;
+        in2  = L(2).x - L(3).x;
+        out2 = L(2).y - L(3).y;
+        L(3).a = (out2 / in2 - out1 / in1) / (in2 - in1);
+        L(3).b = out1 / in1 - L(3).a * in1;
+    }
+    L(3).x = 0;
+    L(3).y = L(2).y;
+
+    s->in_min_lin  = exp(s->segments[1].x);
+    s->out_min_lin = exp(s->segments[1].y);
+
+    for (i = 0; i < channels; i++) {
+        ChanParam *cp = &s->channels[i];
+
+        if (cp->attack > 1.0 / sample_rate)
+            cp->attack = 1.0 - exp(-1.0 / (sample_rate * cp->attack));
+        else
+            cp->attack = 1.0;
+        if (cp->decay > 1.0 / sample_rate)
+            cp->decay = 1.0 - exp(-1.0 / (sample_rate * cp->decay));
+        else
+            cp->decay = 1.0;
+        cp->volume = pow(10.0, s->initial_volume / 20);
+    }
+
+    s->delay_samples = s->delay * sample_rate;
+    if (s->delay_samples <= 0) {
+        s->compand = compand_nodelay;
+        return 0;
+    }
+
+    s->delay_frame = av_frame_alloc();
+    if (!s->delay_frame) {
+        uninit(ctx);
+        return AVERROR(ENOMEM);
+    }
+
+    s->delay_frame->format         = outlink->format;
+    s->delay_frame->nb_samples     = s->delay_samples;
+    s->delay_frame->channel_layout = outlink->channel_layout;
+
+    err = av_frame_get_buffer(s->delay_frame, 32);
+    if (err)
+        return err;
+
+    s->compand = compand_delay;
+    return 0;
+}
+
+static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
+{
+    AVFilterContext *ctx = inlink->dst;
+    CompandContext *s    = ctx->priv;
+
+    return s->compand(ctx, frame);
+}
+
+static int request_frame(AVFilterLink *outlink)
+{
+    AVFilterContext *ctx = outlink->src;
+    CompandContext *s    = ctx->priv;
+    int ret;
+
+    ret = ff_request_frame(ctx->inputs[0]);
+
+    if (ret == AVERROR_EOF && s->delay_count)
+        ret = compand_drain(outlink);
+
+    return ret;
+}
+
+static const AVFilterPad compand_inputs[] = {
+    {
+        .name         = "default",
+        .type         = AVMEDIA_TYPE_AUDIO,
+        .filter_frame = filter_frame,
+    },
+    { NULL }
+};
+
+static const AVFilterPad compand_outputs[] = {
+    {
+        .name          = "default",
+        .request_frame = request_frame,
+        .config_props  = config_output,
+        .type          = AVMEDIA_TYPE_AUDIO,
+    },
+    { NULL }
+};
+
+
+AVFilter ff_af_compand = {
+    .name           = "compand",
+    .description    = NULL_IF_CONFIG_SMALL(
+            "Compress or expand audio dynamic range."),
+    .query_formats  = query_formats,
+    .priv_size      = sizeof(CompandContext),
+    .priv_class     = &compand_class,
+    .init           = init,
+    .uninit         = uninit,
+    .inputs         = compand_inputs,
+    .outputs        = compand_outputs,
+};
diff --git a/deps/libav/libavfilter/af_resample.c b/deps/libav/libavfilter/af_resample.c
index 224e0ed..a89ab35 100644
--- a/deps/libav/libavfilter/af_resample.c
+++ b/deps/libav/libavfilter/af_resample.c
@@ -252,6 +252,14 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
 
         if (ret > 0) {
             out->nb_samples = ret;
+
+            ret = av_frame_copy_props(out, in);
+            if (ret < 0) {
+                av_frame_free(&out);
+                goto fail;
+            }
+
+            out->sample_rate = outlink->sample_rate;
             if (in->pts != AV_NOPTS_VALUE) {
                 out->pts = av_rescale_q(in->pts, inlink->time_base,
                                             outlink->time_base) -
diff --git a/deps/libav/libavfilter/af_volume.c b/deps/libav/libavfilter/af_volume.c
index 85d7067..59223e5 100644
--- a/deps/libav/libavfilter/af_volume.c
+++ b/deps/libav/libavfilter/af_volume.c
@@ -229,6 +229,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
     AVFilterLink *outlink = inlink->dst->outputs[0];
     int nb_samples        = buf->nb_samples;
     AVFrame *out_buf;
+    int ret;
 
     if (vol->volume == 1.0 || vol->volume_i == 256)
         return ff_filter_frame(outlink, buf);
@@ -240,7 +241,12 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
         out_buf = ff_get_audio_buffer(inlink, nb_samples);
         if (!out_buf)
             return AVERROR(ENOMEM);
-        out_buf->pts = buf->pts;
+        ret = av_frame_copy_props(out_buf, buf);
+        if (ret < 0) {
+            av_frame_free(&out_buf);
+            av_frame_free(&buf);
+            return ret;
+        }
     }
 
     if (vol->precision != PRECISION_FIXED || vol->volume_i > 0) {
@@ -272,6 +278,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
         }
     }
 
+    emms_c();
+
     if (buf != out_buf)
         av_frame_free(&buf);
 
diff --git a/deps/libav/libavfilter/allfilters.c b/deps/libav/libavfilter/allfilters.c
index 9702a0a..ddca153 100644
--- a/deps/libav/libavfilter/allfilters.c
+++ b/deps/libav/libavfilter/allfilters.c
@@ -54,6 +54,7 @@ void avfilter_register_all(void)
     REGISTER_FILTER(ATRIM,          atrim,          af);
     REGISTER_FILTER(CHANNELMAP,     channelmap,     af);
     REGISTER_FILTER(CHANNELSPLIT,   channelsplit,   af);
+    REGISTER_FILTER(COMPAND,        compand,        af);
     REGISTER_FILTER(JOIN,           join,           af);
     REGISTER_FILTER(RESAMPLE,       resample,       af);
     REGISTER_FILTER(VOLUME,         volume,         af);
@@ -97,6 +98,7 @@ void avfilter_register_all(void)
     REGISTER_FILTER(SETSAR,         setsar,         vf);
     REGISTER_FILTER(SETTB,          settb,          vf);
     REGISTER_FILTER(SHOWINFO,       showinfo,       vf);
+    REGISTER_FILTER(SHUFFLEPLANES,  shuffleplanes,  vf);
     REGISTER_FILTER(SPLIT,          split,          vf);
     REGISTER_FILTER(TRANSPOSE,      transpose,      vf);
     REGISTER_FILTER(TRIM,           trim,           vf);
diff --git a/deps/libav/libavfilter/avfilter.c b/deps/libav/libavfilter/avfilter.c
index f02358f..c9617dc 100644
--- a/deps/libav/libavfilter/avfilter.c
+++ b/deps/libav/libavfilter/avfilter.c
@@ -204,7 +204,7 @@ int avfilter_config_links(AVFilterContext *filter)
 
             if ((config_link = link->dstpad->config_props))
                 if ((ret = config_link(link)) < 0) {
-                    av_log(link->src, AV_LOG_ERROR,
+                    av_log(link->dst, AV_LOG_ERROR,
                            "Failed to configure input pad on %s\n",
                            link->dst->name);
                     return ret;
diff --git a/deps/libav/libavfilter/buffersink.h b/deps/libav/libavfilter/buffersink.h
index 75cea35..83a8bd9 100644
--- a/deps/libav/libavfilter/buffersink.h
+++ b/deps/libav/libavfilter/buffersink.h
@@ -21,11 +21,18 @@
 
 /**
  * @file
+ * @ingroup lavfi_buffersink
  * memory buffer sink API
  */
 
 #include "avfilter.h"
 
+/**
+ * @defgroup lavfi_buffersink Buffer sink API
+ * @ingroup lavfi
+ * @{
+ */
+
 #if FF_API_AVFILTERBUFFER
 /**
  * Get a buffer with filtered data from sink and put it in buf.
@@ -70,8 +77,12 @@ int av_buffersink_read_samples(AVFilterContext *ctx, AVFilterBufferRef **buf,
  * @param frame pointer to an allocated frame that will be filled with data.
  *              The data must be freed using av_frame_unref() / av_frame_free()
  *
- * @return >= 0 in case of success, a negative AVERROR code in case of
- *         failure.
+ * @return
+ *         - >= 0 if a frame was successfully returned.
+ *         - AVERROR(EAGAIN) if no frames are available at this point; more
+ *           input frames must be added to the filtergraph to get more output.
+ *         - AVERROR_EOF if there will be no more output frames on this sink.
+ *         - A different negative AVERROR code in other failure cases.
  */
 int av_buffersink_get_frame(AVFilterContext *ctx, AVFrame *frame);
 
@@ -86,9 +97,16 @@ int av_buffersink_get_frame(AVFilterContext *ctx, AVFrame *frame);
  *              frame will contain exactly nb_samples audio samples, except at
  *              the end of stream, when it can contain less than nb_samples.
  *
+ * @return The return codes have the same meaning as for
+ *         av_buffersink_get_samples().
+ *
  * @warning do not mix this function with av_buffersink_get_frame(). Use only one or
  * the other with a single sink, not both.
  */
 int av_buffersink_get_samples(AVFilterContext *ctx, AVFrame *frame, int nb_samples);
 
+/**
+ * @}
+ */
+
 #endif /* AVFILTER_BUFFERSINK_H */
diff --git a/deps/libav/libavfilter/buffersrc.h b/deps/libav/libavfilter/buffersrc.h
index 0f9d93a..0ca4d96 100644
--- a/deps/libav/libavfilter/buffersrc.h
+++ b/deps/libav/libavfilter/buffersrc.h
@@ -22,11 +22,18 @@
 
 /**
  * @file
+ * @ingroup lavfi_buffersrc
  * Memory buffer source API.
  */
 
 #include "avfilter.h"
 
+/**
+ * @defgroup lavfi_buffersrc Buffer source API
+ * @ingroup lavfi
+ * @{
+ */
+
 #if FF_API_AVFILTERBUFFER
 /**
  * Add a buffer to a filtergraph.
@@ -71,4 +78,8 @@ int av_buffersrc_write_frame(AVFilterContext *ctx, const AVFrame *frame);
  */
 int av_buffersrc_add_frame(AVFilterContext *ctx, AVFrame *frame);
 
+/**
+ * @}
+ */
+
 #endif /* AVFILTER_BUFFERSRC_H */
diff --git a/deps/libav/libavfilter/version.h b/deps/libav/libavfilter/version.h
index 1684aa5..1fd0eb6 100644
--- a/deps/libav/libavfilter/version.h
+++ b/deps/libav/libavfilter/version.h
@@ -30,7 +30,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVFILTER_VERSION_MAJOR  4
-#define LIBAVFILTER_VERSION_MINOR  1
+#define LIBAVFILTER_VERSION_MINOR  3
 #define LIBAVFILTER_VERSION_MICRO  0
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
@@ -71,5 +71,8 @@
 #ifndef FF_API_NOCONST_GET_NAME
 #define FF_API_NOCONST_GET_NAME             (LIBAVFILTER_VERSION_MAJOR < 5)
 #endif
+#ifndef FF_API_INTERLACE_LOWPASS_SET
+#define FF_API_INTERLACE_LOWPASS_SET        (LIBAVFILTER_VERSION_MAJOR < 5)
+#endif
 
 #endif /* AVFILTER_VERSION_H */
diff --git a/deps/libav/libavfilter/vf_copy.c b/deps/libav/libavfilter/vf_copy.c
index 55175a0..5e60f20 100644
--- a/deps/libav/libavfilter/vf_copy.c
+++ b/deps/libav/libavfilter/vf_copy.c
@@ -37,9 +37,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in)
         return AVERROR(ENOMEM);
     }
     av_frame_copy_props(out, in);
-    av_image_copy(out->data, out->linesize, in->data, in->linesize,
-                  in->format, in->width, in->height);
-
+    av_frame_copy(out, in);
     av_frame_free(&in);
     return ff_filter_frame(outlink, out);
 }
diff --git a/deps/libav/libavfilter/vf_frei0r.c b/deps/libav/libavfilter/vf_frei0r.c
index 0d0866a..771443d 100644
--- a/deps/libav/libavfilter/vf_frei0r.c
+++ b/deps/libav/libavfilter/vf_frei0r.c
@@ -81,7 +81,7 @@ static void *load_sym(AVFilterContext *ctx, const char *sym_name)
     Frei0rContext *s = ctx->priv;
     void *sym = dlsym(s->dl_handle, sym_name);
     if (!sym)
-        av_log(ctx, AV_LOG_ERROR, "Could not find symbol '%s' in loaded module\n", sym_name);
+        av_log(ctx, AV_LOG_ERROR, "Could not find symbol '%s' in loaded module.\n", sym_name);
     return sym;
 }
 
@@ -129,7 +129,7 @@ static int set_param(AVFilterContext *ctx, f0r_param_info_t info, int index, cha
     return 0;
 
 fail:
-    av_log(ctx, AV_LOG_ERROR, "Invalid value '%s' for parameter '%s'\n",
+    av_log(ctx, AV_LOG_ERROR, "Invalid value '%s' for parameter '%s'.\n",
            param, info.name);
     return AVERROR(EINVAL);
 }
@@ -198,11 +198,11 @@ static int set_params(AVFilterContext *ctx, const char *params)
         default: /* F0R_PARAM_STRING */
             v = s;
             s->get_param_value(s->instance, v, i);
-            av_log(ctx, AV_LOG_DEBUG, "'%s'\n", s);
+            av_log(ctx, AV_LOG_DEBUG, "'%s'", s);
             break;
         }
 #endif
-        av_log(ctx, AV_LOG_VERBOSE, "\n");
+        av_log(ctx, AV_LOG_VERBOSE, ".\n");
     }
 
     return 0;
@@ -213,7 +213,7 @@ static void *load_path(AVFilterContext *ctx, const char *prefix, const char *nam
     char path[1024];
 
     snprintf(path, sizeof(path), "%s%s%s", prefix, name, SLIBSUF);
-    av_log(ctx, AV_LOG_DEBUG, "Looking for frei0r effect in '%s'\n", path);
+    av_log(ctx, AV_LOG_DEBUG, "Looking for frei0r effect in '%s'.\n", path);
     return dlopen(path, RTLD_NOW|RTLD_LOCAL);
 }
 
@@ -232,12 +232,18 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
     }
 
     /* see: http://piksel.org/frei0r/1.2/spec/1.2/spec/group__pluglocations.html */
-    if ((path = av_strdup(getenv("FREI0R_PATH")))) {
-        char *p, *ptr = NULL;
-        for (p = path; p = strtok_r(p, ":", &ptr); p = NULL)
-            if (s->dl_handle = load_path(ctx, p, dl_name))
-                break;
-        av_free(path);
+    if (path = getenv("FREI0R_PATH")) {
+        while(*path) {
+            char *ptr = av_get_token((const char **)&path, ":");
+            if (!ptr)
+                return AVERROR(ENOMEM);
+            s->dl_handle = load_path(ctx, ptr, dl_name);
+            av_freep(&ptr);
+            if (s->dl_handle)
+                break;              /* found */
+            if (*path)
+                path++;             /* skip ':' */
+        }
     }
     if (!s->dl_handle && (path = getenv("HOME"))) {
         char prefix[1024];
@@ -249,7 +255,7 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
     if (!s->dl_handle)
         s->dl_handle = load_path(ctx, "/usr/lib/frei0r-1/", dl_name);
     if (!s->dl_handle) {
-        av_log(ctx, AV_LOG_ERROR, "Could not find module '%s'\n", dl_name);
+        av_log(ctx, AV_LOG_ERROR, "Could not find module '%s'.\n", dl_name);
         return AVERROR(EINVAL);
     }
 
@@ -265,7 +271,7 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
         return AVERROR(EINVAL);
 
     if (f0r_init() < 0) {
-        av_log(ctx, AV_LOG_ERROR, "Could not init the frei0r module");
+        av_log(ctx, AV_LOG_ERROR, "Could not init the frei0r module.\n");
         return AVERROR(EINVAL);
     }
 
@@ -273,7 +279,7 @@ static av_cold int frei0r_init(AVFilterContext *ctx,
     pi = &s->plugin_info;
     if (pi->plugin_type != type) {
         av_log(ctx, AV_LOG_ERROR,
-               "Invalid type '%s' for the plugin\n",
+               "Invalid type '%s' for this plugin\n",
                pi->plugin_type == F0R_PLUGIN_TYPE_FILTER ? "filter" :
                pi->plugin_type == F0R_PLUGIN_TYPE_SOURCE ? "source" :
                pi->plugin_type == F0R_PLUGIN_TYPE_MIXER2 ? "mixer2" :
@@ -320,7 +326,7 @@ static int config_input_props(AVFilterLink *inlink)
     if (s->destruct && s->instance)
         s->destruct(s->instance);
     if (!(s->instance = s->construct(inlink->w, inlink->h))) {
-        av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance");
+        av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance.\n");
         return AVERROR(EINVAL);
     }
 
@@ -427,13 +433,13 @@ static av_cold int source_init(AVFilterContext *ctx)
     AVRational frame_rate_q;
 
     if (av_parse_video_size(&s->w, &s->h, s->size) < 0) {
-        av_log(ctx, AV_LOG_ERROR, "Invalid frame size: '%s'\n", s->size);
+        av_log(ctx, AV_LOG_ERROR, "Invalid frame size: '%s'.\n", s->size);
         return AVERROR(EINVAL);
     }
 
     if (av_parse_video_rate(&frame_rate_q, s->framerate) < 0 ||
         frame_rate_q.den <= 0 || frame_rate_q.num <= 0) {
-        av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: '%s'\n", s->framerate);
+        av_log(ctx, AV_LOG_ERROR, "Invalid frame rate: '%s'.\n", s->framerate);
         return AVERROR(EINVAL);
     }
     s->time_base.num = frame_rate_q.den;
@@ -456,7 +462,11 @@ static int source_config_props(AVFilterLink *outlink)
     if (s->destruct && s->instance)
         s->destruct(s->instance);
     if (!(s->instance = s->construct(outlink->w, outlink->h))) {
-        av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance");
+        av_log(ctx, AV_LOG_ERROR, "Impossible to load frei0r instance.\n");
+        return AVERROR(EINVAL);
+    }
+    if (!s->params) {
+        av_log(ctx, AV_LOG_ERROR, "frei0r filter parameters not set.\n");
         return AVERROR(EINVAL);
     }
 
diff --git a/deps/libav/libavfilter/vf_gradfun.c b/deps/libav/libavfilter/vf_gradfun.c
index 79f6790..f7c4372 100644
--- a/deps/libav/libavfilter/vf_gradfun.c
+++ b/deps/libav/libavfilter/vf_gradfun.c
@@ -118,6 +118,7 @@ static void filter(GradFunContext *ctx, uint8_t *dst, uint8_t *src, int width, i
         ctx->filter_line(dst + y * dst_linesize, src + y * src_linesize, dc - r / 2, width, thresh, dither[y & 7]);
         if (++y >= height) break;
     }
+    emms_c();
 }
 
 static av_cold int init(AVFilterContext *ctx)
diff --git a/deps/libav/libavfilter/vf_hqdn3d.c b/deps/libav/libavfilter/vf_hqdn3d.c
index cd9f0d2..be6b761 100644
--- a/deps/libav/libavfilter/vf_hqdn3d.c
+++ b/deps/libav/libavfilter/vf_hqdn3d.c
@@ -147,6 +147,7 @@ static void denoise_depth(HQDN3DContext *s,
     else
         denoise_temporal(src, dst, frame_ant,
                          w, h, sstride, dstride, temporal, depth);
+    emms_c();
 }
 
 #define denoise(...) \
diff --git a/deps/libav/libavfilter/vf_interlace.c b/deps/libav/libavfilter/vf_interlace.c
index a05ab03..8a16e19 100644
--- a/deps/libav/libavfilter/vf_interlace.c
+++ b/deps/libav/libavfilter/vf_interlace.c
@@ -29,6 +29,7 @@
 #include "formats.h"
 #include "avfilter.h"
 #include "internal.h"
+#include "version.h"
 #include "video.h"
 
 enum ScanMode {
@@ -44,7 +45,9 @@ enum FieldType {
 typedef struct {
     const AVClass *class;
     enum ScanMode scan;    // top or bottom field first scanning
+#if FF_API_INTERLACE_LOWPASS_SET
     int lowpass;           // enable or disable low pass filterning
+#endif
     AVFrame *cur, *next;   // the two frames from which the new one is obtained
     int got_output;        // signal an output frame is reday to request_frame()
 } InterlaceContext;
@@ -58,8 +61,10 @@ static const AVOption options[] = {
         AV_OPT_TYPE_CONST, {.i64 = MODE_TFF }, INT_MIN, INT_MAX, .flags = V, .unit = "scan" },
     { "bff", "bottom field first", 0,
         AV_OPT_TYPE_CONST, {.i64 = MODE_BFF }, INT_MIN, INT_MAX, .flags = V, .unit = "scan" },
-    { "lowpass", "enable vertical low-pass filter", OFFSET(lowpass),
+#if FF_API_INTERLACE_LOWPASS_SET
+    { "lowpass", "(deprecated, this option is always set)", OFFSET(lowpass),
         AV_OPT_TYPE_INT,   {.i64 = 1 },        0, 1, .flags = V },
+#endif
     { NULL }
 };
 
@@ -100,6 +105,11 @@ static int config_out_props(AVFilterLink *outlink)
     AVFilterLink *inlink = outlink->src->inputs[0];
     InterlaceContext *s = ctx->priv;
 
+#if FF_API_INTERLACE_LOWPASS_SET
+    if (!s->lowpass)
+        av_log(ctx, AV_LOG_WARNING, "This option is deprecated and always set.\n");
+#endif
+
     if (inlink->h < 2) {
         av_log(ctx, AV_LOG_ERROR, "input video height is too small\n");
         return AVERROR_INVALIDDATA;
@@ -111,15 +121,14 @@ static int config_out_props(AVFilterLink *outlink)
     // half framerate
     outlink->time_base.num *= 2;
 
-    av_log(ctx, AV_LOG_VERBOSE, "%s interlacing %s lowpass filter\n",
-           s->scan == MODE_TFF ? "tff" : "bff", (s->lowpass) ? "with" : "without");
+    av_log(ctx, AV_LOG_VERBOSE, "%s interlacing\n",
+           s->scan == MODE_TFF ? "tff" : "bff");
 
     return 0;
 }
 
 static void copy_picture_field(AVFrame *src_frame, AVFrame *dst_frame,
-                               AVFilterLink *inlink, enum FieldType field_type,
-                               int lowpass)
+                               AVFilterLink *inlink, enum FieldType field_type)
 {
     const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
     int vsub = desc->log2_chroma_h;
@@ -130,6 +139,8 @@ static void copy_picture_field(AVFrame *src_frame, AVFrame *dst_frame,
         int linesize = av_image_get_linesize(inlink->format, inlink->w, plane);
         uint8_t *dstp = dst_frame->data[plane];
         const uint8_t *srcp = src_frame->data[plane];
+        int srcp_linesize;
+        int dstp_linesize;
 
         av_assert0(linesize >= 0);
 
@@ -138,29 +149,24 @@ static void copy_picture_field(AVFrame *src_frame, AVFrame *dst_frame,
             srcp += src_frame->linesize[plane];
         if (field_type == FIELD_LOWER)
             dstp += dst_frame->linesize[plane];
-        if (lowpass) {
-            int srcp_linesize = src_frame->linesize[plane] * 2;
-            int dstp_linesize = dst_frame->linesize[plane] * 2;
-            for (j = lines; j > 0; j--) {
-                const uint8_t *srcp_above = srcp - src_frame->linesize[plane];
-                const uint8_t *srcp_below = srcp + src_frame->linesize[plane];
-                if (j == lines)
-                    srcp_above = srcp; // there is no line above
-                if (j == 1)
-                    srcp_below = srcp; // there is no line below
-                for (i = 0; i < linesize; i++) {
-                    // this calculation is an integer representation of
-                    // '0.5 * current + 0.25 * above + 0.25 * below'
-                    // '1 +' is for rounding.
-                    dstp[i] = (1 + srcp[i] + srcp[i] + srcp_above[i] + srcp_below[i]) >> 2;
-                }
-                dstp += dstp_linesize;
-                srcp += srcp_linesize;
+
+        srcp_linesize = src_frame->linesize[plane] * 2;
+        dstp_linesize = dst_frame->linesize[plane] * 2;
+        for (j = lines; j > 0; j--) {
+            const uint8_t *srcp_above = srcp - src_frame->linesize[plane];
+            const uint8_t *srcp_below = srcp + src_frame->linesize[plane];
+            if (j == lines)
+                srcp_above = srcp; // there is no line above
+            if (j == 1)
+                srcp_below = srcp; // there is no line below
+            for (i = 0; i < linesize; i++) {
+                // this calculation is an integer representation of
+                // '0.5 * current + 0.25 * above + 0.25 * below'
+                // '1 +' is for rounding.
+                dstp[i] = (1 + srcp[i] + srcp[i] + srcp_above[i] + srcp_below[i]) >> 2;
             }
-        } else {
-            av_image_copy_plane(dstp, dst_frame->linesize[plane] * 2,
-                                srcp, src_frame->linesize[plane] * 2,
-                                linesize, lines);
+            dstp += dstp_linesize;
+            srcp += srcp_linesize;
         }
     }
 }
@@ -204,11 +210,11 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *buf)
     out->pts             /= 2;  // adjust pts to new framerate
 
     /* copy upper/lower field from cur */
-    copy_picture_field(s->cur, out, inlink, tff ? FIELD_UPPER : FIELD_LOWER, s->lowpass);
+    copy_picture_field(s->cur, out, inlink, tff ? FIELD_UPPER : FIELD_LOWER);
     av_frame_free(&s->cur);
 
     /* copy lower/upper field from next */
-    copy_picture_field(s->next, out, inlink, tff ? FIELD_LOWER : FIELD_UPPER, s->lowpass);
+    copy_picture_field(s->next, out, inlink, tff ? FIELD_LOWER : FIELD_UPPER);
     av_frame_free(&s->next);
 
     ret = ff_filter_frame(outlink, out);
diff --git a/deps/libav/libavfilter/vf_shuffleplanes.c b/deps/libav/libavfilter/vf_shuffleplanes.c
new file mode 100644
index 0000000..1bc77b0
--- /dev/null
+++ b/deps/libav/libavfilter/vf_shuffleplanes.c
@@ -0,0 +1,172 @@
+/*
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/avstring.h"
+#include "libavutil/common.h"
+#include "libavutil/internal.h"
+#include "libavutil/opt.h"
+#include "libavutil/pixdesc.h"
+#include "libavutil/pixfmt.h"
+
+#include "avfilter.h"
+#include "internal.h"
+#include "video.h"
+
+typedef struct ShufflePlanesContext {
+    const AVClass *class;
+
+    /* number of planes in the selected pixel format */
+    int planes;
+
+    /* mapping indices */
+    int map[4];
+
+    /* set to 1 if some plane is used more than once, so we need to make a copy */
+    int copy;
+} ShufflePlanesContext;
+
+static av_cold int shuffleplanes_config_input(AVFilterLink *inlink)
+{
+    AVFilterContext    *ctx = inlink->dst;
+    ShufflePlanesContext *s = ctx->priv;
+    const AVPixFmtDescriptor *desc;
+    int used[4] = { 0 };
+    int i;
+
+    s->copy   = 0;
+    s->planes = av_pix_fmt_count_planes(inlink->format);
+    desc      = av_pix_fmt_desc_get(inlink->format);
+
+    for (i = 0; i < s->planes; i++) {
+        if (s->map[i] >= s->planes) {
+            av_log(ctx, AV_LOG_ERROR,
+                   "Non-existing input plane #%d mapped to output plane #%d.\n",
+                   s->map[i], i);
+            return AVERROR(EINVAL);
+        }
+
+        if ((desc->log2_chroma_h || desc->log2_chroma_w) &&
+            (i == 1 || i == 2) != (s->map[i] == 1 || s->map[i] == 2)) {
+            av_log(ctx, AV_LOG_ERROR,
+                   "Cannot map between a subsampled chroma plane and a luma "
+                   "or alpha plane.\n");
+            return AVERROR(EINVAL);
+        }
+
+        if ((desc->flags & AV_PIX_FMT_FLAG_PAL ||
+             desc->flags & AV_PIX_FMT_FLAG_PSEUDOPAL) &&
+            (i == 1) != (s->map[i] == 1)) {
+            av_log(ctx, AV_LOG_ERROR,
+                   "Cannot map between a palette plane and a data plane.\n");
+            return AVERROR(EINVAL);
+        }
+        if (used[s->map[i]])
+            s->copy = 1;
+        used[s->map[i]]++;
+    }
+
+    return 0;
+}
+
+static int shuffleplanes_filter_frame(AVFilterLink *inlink, AVFrame *frame)
+{
+    AVFilterContext          *ctx = inlink->dst;
+    ShufflePlanesContext       *s = ctx->priv;
+    uint8_t *shuffled_data[4]     = { NULL };
+    int      shuffled_linesize[4] = { 0 };
+    int i, ret;
+
+    for (i = 0; i < s->planes; i++) {
+        shuffled_data[i]     = frame->data[s->map[i]];
+        shuffled_linesize[i] = frame->linesize[s->map[i]];
+    }
+    memcpy(frame->data,     shuffled_data,     sizeof(shuffled_data));
+    memcpy(frame->linesize, shuffled_linesize, sizeof(shuffled_linesize));
+
+    if (s->copy) {
+        AVFrame *copy = ff_get_video_buffer(ctx->outputs[0], frame->width, frame->height);
+
+        if (!copy) {
+            ret = AVERROR(ENOMEM);
+            goto fail;
+        }
+
+        av_frame_copy(copy, frame);
+
+        ret = av_frame_copy_props(copy, frame);
+        if (ret < 0) {
+            av_frame_free(&copy);
+            goto fail;
+        }
+
+        av_frame_free(&frame);
+        frame = copy;
+    }
+
+    return ff_filter_frame(ctx->outputs[0], frame);
+fail:
+    av_frame_free(&frame);
+    return ret;
+}
+
+#define OFFSET(x) offsetof(ShufflePlanesContext, x)
+#define FLAGS AV_OPT_FLAG_VIDEO_PARAM
+static const AVOption shuffleplanes_options[] = {
+    { "map0", "Index of the input plane to be used as the first output plane ",  OFFSET(map[0]), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 4, FLAGS },
+    { "map1", "Index of the input plane to be used as the second output plane ", OFFSET(map[1]), AV_OPT_TYPE_INT, { .i64 = 1 }, 0, 4, FLAGS },
+    { "map2", "Index of the input plane to be used as the third output plane ",  OFFSET(map[2]), AV_OPT_TYPE_INT, { .i64 = 2 }, 0, 4, FLAGS },
+    { "map3", "Index of the input plane to be used as the fourth output plane ", OFFSET(map[3]), AV_OPT_TYPE_INT, { .i64 = 3 }, 0, 4, FLAGS },
+    { NULL },
+};
+
+static const AVClass shuffleplanes_class = {
+    .class_name = "shuffleplanes",
+    .item_name  = av_default_item_name,
+    .option     = shuffleplanes_options,
+    .version    = LIBAVUTIL_VERSION_INT,
+};
+
+static const AVFilterPad shuffleplanes_inputs[] = {
+    {
+        .name             = "default",
+        .type             = AVMEDIA_TYPE_VIDEO,
+        .config_props     = shuffleplanes_config_input,
+        .filter_frame     = shuffleplanes_filter_frame,
+        .get_video_buffer = ff_null_get_video_buffer,
+    },
+    { NULL },
+};
+
+static const AVFilterPad shuffleplanes_outputs[] = {
+    {
+        .name = "default",
+        .type = AVMEDIA_TYPE_VIDEO,
+    },
+    { NULL },
+};
+
+AVFilter ff_vf_shuffleplanes = {
+    .name         = "shuffleplanes",
+    .description  = NULL_IF_CONFIG_SMALL("Shuffle video planes"),
+
+    .priv_size    = sizeof(ShufflePlanesContext),
+    .priv_class   = &shuffleplanes_class,
+
+    .inputs       = shuffleplanes_inputs,
+    .outputs      = shuffleplanes_outputs,
+};
diff --git a/deps/libav/libavformat/Makefile b/deps/libav/libavformat/Makefile
index 4da3c3b..5694314 100644
--- a/deps/libav/libavformat/Makefile
+++ b/deps/libav/libavformat/Makefile
@@ -168,7 +168,7 @@ OBJS-$(CONFIG_M4V_MUXER)                 += rawenc.o
 OBJS-$(CONFIG_MATROSKA_DEMUXER)          += matroskadec.o matroska.o  \
                                             isom.o rmsipr.o
 OBJS-$(CONFIG_MATROSKA_MUXER)            += matroskaenc.o matroska.o \
-                                            isom.o avc.o \
+                                            isom.o avc.o hevc.o \
                                             flacenc_header.o avlanguage.o wv.o
 OBJS-$(CONFIG_MD5_MUXER)                 += md5enc.o
 OBJS-$(CONFIG_MJPEG_DEMUXER)             += rawdec.o
@@ -179,7 +179,7 @@ OBJS-$(CONFIG_MM_DEMUXER)                += mm.o
 OBJS-$(CONFIG_MMF_DEMUXER)               += mmf.o pcm.o
 OBJS-$(CONFIG_MMF_MUXER)                 += mmf.o
 OBJS-$(CONFIG_MOV_DEMUXER)               += mov.o isom.o mov_chan.o
-OBJS-$(CONFIG_MOV_MUXER)                 += movenc.o isom.o avc.o \
+OBJS-$(CONFIG_MOV_MUXER)                 += movenc.o isom.o avc.o hevc.o \
                                             movenchint.o mov_chan.o
 OBJS-$(CONFIG_MP2_MUXER)                 += mp3enc.o rawenc.o id3v2enc.o
 OBJS-$(CONFIG_MP3_DEMUXER)               += mp3dec.o
@@ -392,8 +392,6 @@ OBJS-$(HAVE_LIBC_MSVCRT)                 += file_open.o
 SKIPHEADERS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh.h
 SKIPHEADERS-$(CONFIG_NETWORK)            += network.h rtsp.h
 
-EXAMPLES  = metadata                                                    \
-
 TESTPROGS = seek                                                        \
             srtp                                                        \
             url                                                         \
diff --git a/deps/libav/libavformat/aacdec.c b/deps/libav/libavformat/aacdec.c
index 8d87ce6..b9a4b4b 100644
--- a/deps/libav/libavformat/aacdec.c
+++ b/deps/libav/libavformat/aacdec.c
@@ -26,7 +26,6 @@
 #include "rawdec.h"
 #include "id3v1.h"
 
-
 static int adts_aac_probe(AVProbeData *p)
 {
     int max_frames = 0, first_frames = 0;
@@ -38,27 +37,33 @@ static int adts_aac_probe(AVProbeData *p)
 
     buf = buf0;
 
-    for(; buf < end; buf= buf2+1) {
+    for (; buf < end; buf = buf2 + 1) {
         buf2 = buf;
 
-        for(frames = 0; buf2 < end; frames++) {
+        for (frames = 0; buf2 < end; frames++) {
             uint32_t header = AV_RB16(buf2);
-            if((header&0xFFF6) != 0xFFF0)
+            if ((header & 0xFFF6) != 0xFFF0)
                 break;
             fsize = (AV_RB32(buf2 + 3) >> 13) & 0x1FFF;
-            if(fsize < 7)
+            if (fsize < 7)
                 break;
             buf2 += fsize;
         }
         max_frames = FFMAX(max_frames, frames);
-        if(buf == buf0)
-            first_frames= frames;
+        if (buf == buf0)
+            first_frames = frames;
     }
-    if   (first_frames>=3) return AVPROBE_SCORE_EXTENSION + 1;
-    else if(max_frames>500)return AVPROBE_SCORE_EXTENSION;
-    else if(max_frames>=3) return AVPROBE_SCORE_EXTENSION / 2;
-    else if(max_frames>=1) return 1;
-    else                   return 0;
+
+    if (first_frames >= 3)
+        return AVPROBE_SCORE_EXTENSION + 1;
+    else if (max_frames > 500)
+        return AVPROBE_SCORE_EXTENSION;
+    else if (max_frames >= 3)
+        return AVPROBE_SCORE_EXTENSION / 2;
+    else if (max_frames >= 1)
+        return 1;
+    else
+        return 0;
 }
 
 static int adts_aac_read_header(AVFormatContext *s)
@@ -70,24 +75,24 @@ static int adts_aac_read_header(AVFormatContext *s)
         return AVERROR(ENOMEM);
 
     st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
-    st->codec->codec_id = s->iformat->raw_codec_id;
-    st->need_parsing = AVSTREAM_PARSE_FULL;
+    st->codec->codec_id   = s->iformat->raw_codec_id;
+    st->need_parsing      = AVSTREAM_PARSE_FULL;
 
     ff_id3v1_read(s);
 
-    //LCM of all possible ADTS sample rates
+    // LCM of all possible ADTS sample rates
     avpriv_set_pts_info(st, 64, 1, 28224000);
 
     return 0;
 }
 
 AVInputFormat ff_aac_demuxer = {
-    .name           = "aac",
-    .long_name      = NULL_IF_CONFIG_SMALL("raw ADTS AAC (Advanced Audio Coding)"),
-    .read_probe     = adts_aac_probe,
-    .read_header    = adts_aac_read_header,
-    .read_packet    = ff_raw_read_partial_packet,
-    .flags          = AVFMT_GENERIC_INDEX,
-    .extensions     = "aac",
-    .raw_codec_id   = AV_CODEC_ID_AAC,
+    .name         = "aac",
+    .long_name    = NULL_IF_CONFIG_SMALL("raw ADTS AAC (Advanced Audio Coding)"),
+    .read_probe   = adts_aac_probe,
+    .read_header  = adts_aac_read_header,
+    .read_packet  = ff_raw_read_partial_packet,
+    .flags        = AVFMT_GENERIC_INDEX,
+    .extensions   = "aac",
+    .raw_codec_id = AV_CODEC_ID_AAC,
 };
diff --git a/deps/libav/libavformat/apetag.c b/deps/libav/libavformat/apetag.c
index d4be91c..22884ef 100644
--- a/deps/libav/libavformat/apetag.c
+++ b/deps/libav/libavformat/apetag.c
@@ -20,6 +20,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <inttypes.h>
+
 #include "libavutil/intreadwrite.h"
 #include "libavutil/dict.h"
 #include "avformat.h"
@@ -147,14 +149,14 @@ int64_t ff_ape_parse_tag(AVFormatContext *s)
     }
 
     if (tag_bytes > file_size - APE_TAG_FOOTER_BYTES) {
-        av_log(s, AV_LOG_ERROR, "Invalid tag size %u.\n", tag_bytes);
+        av_log(s, AV_LOG_ERROR, "Invalid tag size %"PRIu32".\n", tag_bytes);
         return 0;
     }
     tag_start = file_size - tag_bytes - APE_TAG_FOOTER_BYTES;
 
     fields = avio_rl32(pb);    /* number of fields */
     if (fields > 65536) {
-        av_log(s, AV_LOG_ERROR, "Too many tag fields (%d)\n", fields);
+        av_log(s, AV_LOG_ERROR, "Too many tag fields (%"PRIu32")\n", fields);
         return 0;
     }
 
diff --git a/deps/libav/libavformat/asfdec.c b/deps/libav/libavformat/asfdec.c
index 28a403a..85e800d 100644
--- a/deps/libav/libavformat/asfdec.c
+++ b/deps/libav/libavformat/asfdec.c
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <inttypes.h>
+
 #include "libavutil/attributes.h"
 #include "libavutil/avassert.h"
 #include "libavutil/avstring.h"
@@ -921,13 +923,13 @@ static int asf_get_packet(AVFormatContext *s, AVIOContext *pb)
     // the following checks prevent overflows and infinite loops
     if (!packet_length || packet_length >= (1U << 29)) {
         av_log(s, AV_LOG_ERROR,
-               "invalid packet_length %d at:%"PRId64"\n",
+               "invalid packet_length %"PRIu32" at:%"PRId64"\n",
                packet_length, avio_tell(pb));
         return -1;
     }
     if (padsize >= packet_length) {
         av_log(s, AV_LOG_ERROR,
-               "invalid padsize %d at:%"PRId64"\n", padsize, avio_tell(pb));
+               "invalid padsize %"PRIu32" at:%"PRId64"\n", padsize, avio_tell(pb));
         return -1;
     }
 
@@ -946,7 +948,7 @@ static int asf_get_packet(AVFormatContext *s, AVIOContext *pb)
     if (rsize > packet_length - padsize) {
         asf->packet_size_left = 0;
         av_log(s, AV_LOG_ERROR,
-               "invalid packet header length %d for pktlen %d-%d at %"PRId64"\n",
+               "invalid packet header length %d for pktlen %"PRIu32"-%"PRIu32" at %"PRId64"\n",
                rsize, packet_length, padsize, avio_tell(pb));
         return -1;
     }
diff --git a/deps/libav/libavformat/assdec.c b/deps/libav/libavformat/assdec.c
index b994cc1..7bd3d17 100644
--- a/deps/libav/libavformat/assdec.c
+++ b/deps/libav/libavformat/assdec.c
@@ -22,24 +22,25 @@
 #include <stdint.h>
 
 #include "libavutil/mathematics.h"
+
 #include "avformat.h"
 #include "internal.h"
 
 #define MAX_LINESIZE 2000
 
-typedef struct ASSContext{
+typedef struct ASSContext {
     uint8_t *event_buffer;
     uint8_t **event;
     unsigned int event_count;
     unsigned int event_index;
-}ASSContext;
+} ASSContext;
 
 static int probe(AVProbeData *p)
 {
-    const char *header= "[Script Info]";
+    const char *header = "[Script Info]";
 
-    if(   !memcmp(p->buf  , header, strlen(header))
-       || !memcmp(p->buf+3, header, strlen(header)))
+    if (!memcmp(p->buf, header, strlen(header)) ||
+        !memcmp(p->buf + 3, header, strlen(header)))
         return AVPROBE_SCORE_MAX;
 
     return 0;
@@ -59,15 +60,15 @@ static int64_t get_pts(const uint8_t *p)
 {
     int hour, min, sec, hsec;
 
-    if(sscanf(p, "%*[^,],%d:%d:%d%*c%d", &hour, &min, &sec, &hsec) != 4)
+    if (sscanf(p, "%*[^,],%d:%d:%d%*c%d", &hour, &min, &sec, &hsec) != 4)
         return AV_NOPTS_VALUE;
 
     av_dlog(NULL, "%d %d %d %d [%s]\n", hour, min, sec, hsec, p);
 
-    min+= 60*hour;
-    sec+= 60*min;
+    min += 60 * hour;
+    sec += 60 * min;
 
-    return sec*100+hsec;
+    return sec * 100 + hsec;
 }
 
 static int event_cmp(const void *_a, const void *_b)
@@ -82,54 +83,56 @@ static int read_header(AVFormatContext *s)
     ASSContext *ass = s->priv_data;
     AVIOContext *pb = s->pb;
     AVStream *st;
-    int allocated[2]={0};
-    uint8_t *p, **dst[2]={0};
-    int pos[2]={0};
+    int allocated[2] = { 0 };
+    uint8_t *p, **dst[2] = { 0 };
+    int pos[2] = { 0 };
 
     st = avformat_new_stream(s, NULL);
     if (!st)
         return -1;
     avpriv_set_pts_info(st, 64, 1, 100);
     st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
-    st->codec->codec_id= AV_CODEC_ID_SSA;
+    st->codec->codec_id   = AV_CODEC_ID_SSA;
 
-    header_remaining= INT_MAX;
+    header_remaining = INT_MAX;
     dst[0] = &st->codec->extradata;
     dst[1] = &ass->event_buffer;
-    while(!pb->eof_reached){
+    while (!pb->eof_reached) {
         uint8_t line[MAX_LINESIZE];
 
         len = ff_get_line(pb, line, sizeof(line));
 
-        if(!memcmp(line, "[Events]", 8))
-            header_remaining= 2;
-        else if(line[0]=='[')
-            header_remaining= INT_MAX;
+        if (!memcmp(line, "[Events]", 8))
+            header_remaining = 2;
+        else if (line[0] == '[')
+            header_remaining = INT_MAX;
 
-        i= header_remaining==0;
+        i = header_remaining == 0;
 
-        if(i && get_pts(line) == AV_NOPTS_VALUE)
+        if (i && get_pts(line) == AV_NOPTS_VALUE)
             continue;
 
-        p = av_fast_realloc(*(dst[i]), &allocated[i], pos[i]+MAX_LINESIZE);
-        if(!p)
+        p = av_fast_realloc(*(dst[i]), &allocated[i], pos[i] + MAX_LINESIZE);
+        if (!p)
             goto fail;
-        *(dst[i])= p;
-        memcpy(p + pos[i], line, len+1);
+        *(dst[i]) = p;
+        memcpy(p + pos[i], line, len + 1);
         pos[i] += len;
-        if(i) ass->event_count++;
-        else  header_remaining--;
+        if (i)
+            ass->event_count++;
+        else
+            header_remaining--;
     }
-    st->codec->extradata_size= pos[0];
+    st->codec->extradata_size = pos[0];
 
-    if(ass->event_count >= UINT_MAX / sizeof(*ass->event))
+    if (ass->event_count >= UINT_MAX / sizeof(*ass->event))
         goto fail;
 
-    ass->event= av_malloc(ass->event_count * sizeof(*ass->event));
-    p= ass->event_buffer;
-    for(i=0; i<ass->event_count; i++){
-        ass->event[i]= p;
-        while(*p && *p != '\n')
+    ass->event = av_malloc(ass->event_count * sizeof(*ass->event));
+    p = ass->event_buffer;
+    for (i = 0; i < ass->event_count; i++) {
+        ass->event[i] = p;
+        while (*p && *p != '\n')
             p++;
         p++;
     }
@@ -149,16 +152,16 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
     ASSContext *ass = s->priv_data;
     uint8_t *p, *end;
 
-    if(ass->event_index >= ass->event_count)
+    if (ass->event_index >= ass->event_count)
         return AVERROR(EIO);
 
-    p= ass->event[ ass->event_index ];
+    p = ass->event[ass->event_index];
 
-    end= strchr(p, '\n');
-    av_new_packet(pkt, end ? end-p+1 : strlen(p));
+    end = strchr(p, '\n');
+    av_new_packet(pkt, end ? end - p + 1 : strlen(p));
     pkt->flags |= AV_PKT_FLAG_KEY;
-    pkt->pos= p - ass->event_buffer + s->streams[0]->codec->extradata_size;
-    pkt->pts= pkt->dts= get_pts(p);
+    pkt->pos    = p - ass->event_buffer + s->streams[0]->codec->extradata_size;
+    pkt->pts    = pkt->dts = get_pts(p);
     memcpy(pkt->data, p, pkt->size);
 
     ass->event_index++;
@@ -182,21 +185,21 @@ static int read_seek2(AVFormatContext *s, int stream_index,
         int64_t min_ts_diff = INT64_MAX;
         if (stream_index == -1) {
             AVRational time_base = s->streams[0]->time_base;
-            ts = av_rescale_q(ts, AV_TIME_BASE_Q, time_base);
+            ts     = av_rescale_q(ts, AV_TIME_BASE_Q, time_base);
             min_ts = av_rescale_rnd(min_ts, time_base.den,
-                                    time_base.num * (int64_t)AV_TIME_BASE,
+                                    time_base.num * (int64_t) AV_TIME_BASE,
                                     AV_ROUND_UP);
             max_ts = av_rescale_rnd(max_ts, time_base.den,
-                                    time_base.num * (int64_t)AV_TIME_BASE,
+                                    time_base.num * (int64_t) AV_TIME_BASE,
                                     AV_ROUND_DOWN);
         }
         /* TODO: ass->event[] is sorted by pts so we could do a binary search */
-        for (i=0; i<ass->event_count; i++) {
-            int64_t pts = get_pts(ass->event[i]);
+        for (i = 0; i < ass->event_count; i++) {
+            int64_t pts     = get_pts(ass->event[i]);
             int64_t ts_diff = FFABS(pts - ts);
             if (pts >= min_ts && pts <= max_ts && ts_diff < min_ts_diff) {
                 min_ts_diff = ts_diff;
-                idx = i;
+                idx         = i;
             }
         }
         if (idx < 0)
diff --git a/deps/libav/libavformat/avformat.h b/deps/libav/libavformat/avformat.h
index 0b8fca2..ec9c262 100644
--- a/deps/libav/libavformat/avformat.h
+++ b/deps/libav/libavformat/avformat.h
@@ -342,6 +342,7 @@ struct AVFormatContext;
  * Allocate and read the payload of a packet and initialize its
  * fields with default values.
  *
+ * @param s    associated IO context
  * @param pkt packet
  * @param size desired payload size
  * @return >0 (read size) if OK, AVERROR_xxx otherwise
@@ -357,6 +358,7 @@ int av_get_packet(AVIOContext *s, AVPacket *pkt, int size);
  * when there is no reasonable way to know (an upper bound of)
  * the final size.
  *
+ * @param s    associated IO context
  * @param pkt packet
  * @param size amount of data to read
  * @return >0 (read size) if OK, AVERROR_xxx otherwise, previous data
@@ -1269,6 +1271,7 @@ const AVClass *avformat_get_class(void);
  *
  * When muxing, should be called by the user before avformat_write_header().
  *
+ * @param s media file handle
  * @param c If non-NULL, the AVCodecContext corresponding to the new stream
  * will be initialized to use this codec. This is needed for e.g. codec-specific
  * defaults to be set, so codec should be provided if it is known.
@@ -1297,6 +1300,7 @@ AVInputFormat *av_find_input_format(const char *short_name);
 /**
  * Guess the file format.
  *
+ * @param pd        data to be probed
  * @param is_opened Whether the file is already opened; determines whether
  *                  demuxers with or without AVFMT_NOFILE are probed.
  */
@@ -1305,6 +1309,7 @@ AVInputFormat *av_probe_input_format(AVProbeData *pd, int is_opened);
 /**
  * Guess the file format.
  *
+ * @param pd        data to be probed
  * @param is_opened Whether the file is already opened; determines whether
  *                  demuxers with or without AVFMT_NOFILE are probed.
  * @param score_max A probe score larger that this is required to accept a
@@ -1438,6 +1443,8 @@ int av_read_frame(AVFormatContext *s, AVPacket *pkt);
 /**
  * Seek to the keyframe at timestamp.
  * 'timestamp' in 'stream_index'.
+ *
+ * @param s media file handle
  * @param stream_index If stream_index is (-1), a default
  * stream is selected, and timestamp is automatically converted
  * from AV_TIME_BASE units to the stream specific time_base.
@@ -1464,6 +1471,7 @@ int av_seek_frame(AVFormatContext *s, int stream_index, int64_t timestamp,
  * If flags contain AVSEEK_FLAG_ANY, then non-keyframes are treated as
  * keyframes (this may not be supported by all demuxers).
  *
+ * @param s media file handle
  * @param stream_index index of the stream which is used as time base reference
  * @param min_ts smallest acceptable timestamp
  * @param ts target timestamp
@@ -1535,24 +1543,22 @@ int avformat_write_header(AVFormatContext *s, AVDictionary **options);
  * function.
  *
  * @param s media file handle
- * @param pkt @parblock
- *            The packet containing the data to be written. Note that unlike
+ * @param pkt The packet containing the data to be written. Note that unlike
  *            av_interleaved_write_frame(), this function does not take
  *            ownership of the packet passed to it (though some muxers may make
  *            an internal reference to the input packet).
- *
+ *            <br>
  *            This parameter can be NULL (at any time, not just at the end), in
  *            order to immediately flush data buffered within the muxer, for
  *            muxers that buffer up data internally before writing it to the
  *            output.
- *
+ *            <br>
  *            Packet's @ref AVPacket.stream_index "stream_index" field must be
  *            set to the index of the corresponding stream in @ref
  *            AVFormatContext.streams "s->streams". It is very strongly
  *            recommended that timing information (@ref AVPacket.pts "pts", @ref
  *            AVPacket.dts "dts", @ref AVPacket.duration "duration") is set to
  *            correct values.
- *            @endparblock
  * @return < 0 on error, = 0 if OK, 1 if flushed and there is no more data to flush
  *
  * @see av_interleaved_write_frame()
@@ -1568,26 +1574,24 @@ int av_write_frame(AVFormatContext *s, AVPacket *pkt);
  * av_write_frame() instead of this function.
  *
  * @param s media file handle
- * @param pkt @parblock
- *            The packet containing the data to be written.
- *
+ * @param pkt The packet containing the data to be written.
+ *            <br>
  *            If the packet is reference-counted, this function will take
  *            ownership of this reference and unreference it later when it sees
  *            fit.
  *            The caller must not access the data through this reference after
  *            this function returns. If the packet is not reference-counted,
  *            libavformat will make a copy.
- *
+ *            <br>
  *            This parameter can be NULL (at any time, not just at the end), to
  *            flush the interleaving queues.
- *
+ *            <br>
  *            Packet's @ref AVPacket.stream_index "stream_index" field must be
  *            set to the index of the corresponding stream in @ref
  *            AVFormatContext.streams "s->streams". It is very strongly
  *            recommended that timing information (@ref AVPacket.pts "pts", @ref
  *            AVPacket.dts "dts", @ref AVPacket.duration "duration") is set to
  *            correct values.
- *            @endparblock
  *
  * @return 0 on success, a negative AVERROR on error. Libavformat will always
  *         take care of freeing the packet, even if this function fails.
@@ -1700,6 +1704,7 @@ void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload,
  *
  * @param tags list of supported codec_id-codec_tag pairs, as stored
  * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag
+ * @param tag  codec tag to match to a codec ID
  */
 enum AVCodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned int tag);
 
@@ -1709,6 +1714,7 @@ enum AVCodecID av_codec_get_id(const struct AVCodecTag * const *tags, unsigned i
  *
  * @param tags list of supported codec_id-codec_tag pairs, as stored
  * in AVInputFormat.codec_tag and AVOutputFormat.codec_tag
+ * @param id   codec ID to match to a codec tag
  */
 unsigned int av_codec_get_tag(const struct AVCodecTag * const *tags, enum AVCodecID id);
 
@@ -1716,6 +1722,9 @@ int av_find_default_stream_index(AVFormatContext *s);
 
 /**
  * Get the index for a specific timestamp.
+ *
+ * @param st        stream that the timestamp belongs to
+ * @param timestamp timestamp to retrieve the index for
  * @param flags if AVSEEK_FLAG_BACKWARD then the returned index will correspond
  *                 to the timestamp which is <= the requested one, if backward
  *                 is 0, then it will be >=
@@ -1812,6 +1821,7 @@ int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size);
  * Return a positive value if the given filename has one of the given
  * extensions, 0 otherwise.
  *
+ * @param filename   file name to check against the given extensions
  * @param extensions a comma-separated list of filename extensions
  */
 int av_match_ext(const char *filename, const char *extensions);
@@ -1819,6 +1829,8 @@ int av_match_ext(const char *filename, const char *extensions);
 /**
  * Test if the given container can store a codec.
  *
+ * @param ofmt           container to check for compatibility
+ * @param codec_id       codec to potentially store in container
  * @param std_compliance standards compliance level, one of FF_COMPLIANCE_*
  *
  * @return 1 if codec with ID codec_id can be stored in ofmt, 0 if it cannot.
diff --git a/deps/libav/libavformat/avidec.c b/deps/libav/libavformat/avidec.c
index 6f80d21..f48c441 100644
--- a/deps/libav/libavformat/avidec.c
+++ b/deps/libav/libavformat/avidec.c
@@ -19,7 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <stdint.h>
+#include <inttypes.h>
 
 #include "libavutil/avstring.h"
 #include "libavutil/bswap.h"
@@ -525,7 +525,7 @@ static int avi_read_header(AVFormatContext *s)
             ast->rate  = avio_rl32(pb);
             if (!(ast->scale && ast->rate)) {
                 av_log(s, AV_LOG_WARNING,
-                       "scale/rate is %u/%u which is invalid. "
+                       "scale/rate is %"PRIu32"/%"PRIu32" which is invalid. "
                        "(This file has been generated by broken software.)\n",
                        ast->scale,
                        ast->rate);
diff --git a/deps/libav/libavformat/avienc.c b/deps/libav/libavformat/avienc.c
index 0b1d578..a5a2885 100644
--- a/deps/libav/libavformat/avienc.c
+++ b/deps/libav/libavformat/avienc.c
@@ -57,9 +57,9 @@ typedef struct  {
     int entry;
 
     AVIIndex indexes;
-} AVIStream ;
+} AVIStream;
 
-static inline AVIIentry* avi_get_ientry(AVIIndex* idx, int ent_id)
+static inline AVIIentry *avi_get_ientry(AVIIndex *idx, int ent_id)
 {
     int cl = ent_id / AVI_INDEX_CLUSTER_SIZE;
     int id = ent_id % AVI_INDEX_CLUSTER_SIZE;
@@ -67,15 +67,15 @@ static inline AVIIentry* avi_get_ientry(AVIIndex* idx, int ent_id)
 }
 
 static int64_t avi_start_new_riff(AVFormatContext *s, AVIOContext *pb,
-                                  const char* riff_tag, const char* list_tag)
+                                  const char *riff_tag, const char *list_tag)
 {
-    AVIContext *avi= s->priv_data;
+    AVIContext *avi = s->priv_data;
     int64_t loff;
     int i;
 
     avi->riff_id++;
-    for (i=0; i<s->nb_streams; i++){
-        AVIStream *avist= s->streams[i]->priv_data;
+    for (i = 0; i < s->nb_streams; i++) {
+        AVIStream *avist = s->streams[i]->priv_data;
         avist->indexes.entry = 0;
     }
 
@@ -86,10 +86,10 @@ static int64_t avi_start_new_riff(AVFormatContext *s, AVIOContext *pb,
     return loff;
 }
 
-static char* avi_stream2fourcc(char* tag, int index, enum AVMediaType type)
+static char *avi_stream2fourcc(char *tag, int index, enum AVMediaType type)
 {
-    tag[0] = '0' + index/10;
-    tag[1] = '0' + index%10;
+    tag[0] = '0' + index / 10;
+    tag[1] = '0' + index % 10;
     if (type == AVMEDIA_TYPE_VIDEO) {
         tag[2] = 'd';
         tag[3] = 'c';
@@ -105,31 +105,30 @@ static char* avi_stream2fourcc(char* tag, int index, enum AVMediaType type)
     return tag;
 }
 
-static int avi_write_counters(AVFormatContext* s, int riff_id)
+static int avi_write_counters(AVFormatContext *s, int riff_id)
 {
     AVIOContext *pb = s->pb;
     AVIContext *avi = s->priv_data;
     int n, au_byterate, au_ssize, au_scale, nb_frames = 0;
     int64_t file_size;
-    AVCodecContext* stream;
+    AVCodecContext *stream;
 
     file_size = avio_tell(pb);
-    for(n = 0; n < s->nb_streams; n++) {
-        AVIStream *avist= s->streams[n]->priv_data;
+    for (n = 0; n < s->nb_streams; n++) {
+        AVIStream *avist = s->streams[n]->priv_data;
 
         assert(avist->frames_hdr_strm);
         stream = s->streams[n]->codec;
         avio_seek(pb, avist->frames_hdr_strm, SEEK_SET);
         ff_parse_specific_params(stream, &au_byterate, &au_ssize, &au_scale);
-        if(au_ssize == 0) {
+        if (au_ssize == 0)
             avio_wl32(pb, avist->packet_count);
-        } else {
+        else
             avio_wl32(pb, avist->audio_strm_length / au_ssize);
-        }
-        if(stream->codec_type == AVMEDIA_TYPE_VIDEO)
+        if (stream->codec_type == AVMEDIA_TYPE_VIDEO)
             nb_frames = FFMAX(nb_frames, avist->packet_count);
     }
-    if(riff_id == 1) {
+    if (riff_id == 1) {
         assert(avi->frames_hdr_all);
         avio_seek(pb, avi->frames_hdr_all, SEEK_SET);
         avio_wl32(pb, nb_frames);
@@ -154,9 +153,9 @@ static int avi_write_header(AVFormatContext *s)
         return -1;
     }
 
-    for(n=0;n<s->nb_streams;n++) {
-        s->streams[n]->priv_data= av_mallocz(sizeof(AVIStream));
-        if(!s->streams[n]->priv_data)
+    for (n = 0; n < s->nb_streams; n++) {
+        s->streams[n]->priv_data = av_mallocz(sizeof(AVIStream));
+        if (!s->streams[n]->priv_data)
             return AVERROR(ENOMEM);
     }
 
@@ -170,8 +169,8 @@ static int avi_write_header(AVFormatContext *s)
     bitrate = 0;
 
     video_enc = NULL;
-    for(n=0;n<s->nb_streams;n++) {
-        stream = s->streams[n]->codec;
+    for (n = 0; n < s->nb_streams; n++) {
+        stream   = s->streams[n]->codec;
         bitrate += stream->bit_rate;
         if (stream->codec_type == AVMEDIA_TYPE_VIDEO)
             video_enc = stream;
@@ -179,23 +178,23 @@ static int avi_write_header(AVFormatContext *s)
 
     nb_frames = 0;
 
-    if(video_enc){
-        avio_wl32(pb, (uint32_t)(INT64_C(1000000) * video_enc->time_base.num / video_enc->time_base.den));
-    } else {
+    if (video_enc)
+        avio_wl32(pb, (uint32_t) (INT64_C(1000000) * video_enc->time_base.num /
+                                  video_enc->time_base.den));
+    else
         avio_wl32(pb, 0);
-    }
     avio_wl32(pb, bitrate / 8); /* XXX: not quite exact */
     avio_wl32(pb, 0); /* padding */
     if (!pb->seekable)
-        avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_ISINTERLEAVED); /* flags */
+        avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_ISINTERLEAVED);  /* flags */
     else
-        avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_HASINDEX | AVIF_ISINTERLEAVED); /* flags */
+        avio_wl32(pb, AVIF_TRUSTCKTYPE | AVIF_HASINDEX | AVIF_ISINTERLEAVED);  /* flags */
     avi->frames_hdr_all = avio_tell(pb); /* remember this offset to fill later */
     avio_wl32(pb, nb_frames); /* nb frames, filled later */
     avio_wl32(pb, 0); /* initial frame */
     avio_wl32(pb, s->nb_streams); /* nb streams */
     avio_wl32(pb, 1024 * 1024); /* suggested buffer size */
-    if(video_enc){
+    if (video_enc) {
         avio_wl32(pb, video_enc->width);
         avio_wl32(pb, video_enc->height);
     } else {
@@ -208,8 +207,8 @@ static int avi_write_header(AVFormatContext *s)
     avio_wl32(pb, 0); /* reserved */
 
     /* stream list */
-    for(i=0;i<n;i++) {
-        AVIStream *avist= s->streams[i]->priv_data;
+    for (i = 0; i < n; i++) {
+        AVIStream *avist = s->streams[i]->priv_data;
         list2 = ff_start_tag(pb, "LIST");
         ffio_wfourcc(pb, "strl");
 
@@ -217,21 +216,30 @@ static int avi_write_header(AVFormatContext *s)
 
         /* stream generic header */
         strh = ff_start_tag(pb, "strh");
-        switch(stream->codec_type) {
+        switch (stream->codec_type) {
         case AVMEDIA_TYPE_SUBTITLE:
             // XSUB subtitles behave like video tracks, other subtitles
             // are not (yet) supported.
             if (stream->codec_id != AV_CODEC_ID_XSUB) {
-                av_log(s, AV_LOG_ERROR, "Subtitle streams other than DivX XSUB are not supported by the AVI muxer.\n");
+                av_log(s, AV_LOG_ERROR,
+                       "Subtitle streams other than DivX XSUB are not supported by the AVI muxer.\n");
                 return AVERROR_PATCHWELCOME;
             }
-        case AVMEDIA_TYPE_VIDEO: ffio_wfourcc(pb, "vids"); break;
-        case AVMEDIA_TYPE_AUDIO: ffio_wfourcc(pb, "auds"); break;
-//      case AVMEDIA_TYPE_TEXT : ffio_wfourcc(pb, "txts"); break;
-        case AVMEDIA_TYPE_DATA : ffio_wfourcc(pb, "dats"); break;
+        case AVMEDIA_TYPE_VIDEO:
+            ffio_wfourcc(pb, "vids");
+            break;
+        case AVMEDIA_TYPE_AUDIO:
+            ffio_wfourcc(pb, "auds");
+            break;
+//      case AVMEDIA_TYPE_TEXT:
+//          ffio_wfourcc(pb, "txts");
+//          break;
+        case AVMEDIA_TYPE_DATA:
+            ffio_wfourcc(pb, "dats");
+            break;
         }
-        if(stream->codec_type == AVMEDIA_TYPE_VIDEO ||
-           stream->codec_id == AV_CODEC_ID_XSUB)
+        if (stream->codec_type == AVMEDIA_TYPE_VIDEO ||
+            stream->codec_id == AV_CODEC_ID_XSUB)
             avio_wl32(pb, stream->codec_tag);
         else
             avio_wl32(pb, 1);
@@ -247,16 +255,18 @@ static int avi_write_header(AVFormatContext *s)
         avpriv_set_pts_info(s->streams[i], 64, au_scale, au_byterate);
 
         avio_wl32(pb, 0); /* start */
-        avist->frames_hdr_strm = avio_tell(pb); /* remember this offset to fill later */
+        /* remember this offset to fill later */
+        avist->frames_hdr_strm = avio_tell(pb);
         if (!pb->seekable)
-            avio_wl32(pb, AVI_MAX_RIFF_SIZE); /* FIXME: this may be broken, but who cares */
+            /* FIXME: this may be broken, but who cares */
+            avio_wl32(pb, AVI_MAX_RIFF_SIZE);
         else
-            avio_wl32(pb, 0); /* length, XXX: filled later */
+            avio_wl32(pb, 0);  /* length, XXX: filled later */
 
         /* suggested buffer size */ //FIXME set at the end to largest chunk
-        if(stream->codec_type == AVMEDIA_TYPE_VIDEO)
+        if (stream->codec_type == AVMEDIA_TYPE_VIDEO)
             avio_wl32(pb, 1024 * 1024);
-        else if(stream->codec_type == AVMEDIA_TYPE_AUDIO)
+        else if (stream->codec_type == AVMEDIA_TYPE_AUDIO)
             avio_wl32(pb, 12 * 1024);
         else
             avio_wl32(pb, 0);
@@ -267,30 +277,30 @@ static int avi_write_header(AVFormatContext *s)
         avio_wl16(pb, stream->height);
         ff_end_tag(pb, strh);
 
-      if(stream->codec_type != AVMEDIA_TYPE_DATA){
-        strf = ff_start_tag(pb, "strf");
-        switch(stream->codec_type) {
-        case AVMEDIA_TYPE_SUBTITLE:
-            // XSUB subtitles behave like video tracks, other subtitles
-            // are not (yet) supported.
-            if (stream->codec_id != AV_CODEC_ID_XSUB) break;
-        case AVMEDIA_TYPE_VIDEO:
-            ff_put_bmp_header(pb, stream, ff_codec_bmp_tags, 0);
-            break;
-        case AVMEDIA_TYPE_AUDIO:
-            if (ff_put_wav_header(pb, stream) < 0) {
+        if (stream->codec_type != AVMEDIA_TYPE_DATA) {
+            strf = ff_start_tag(pb, "strf");
+            switch (stream->codec_type) {
+            case AVMEDIA_TYPE_SUBTITLE:
+                /* XSUB subtitles behave like video tracks, other subtitles
+                 * are not (yet) supported. */
+                if (stream->codec_id != AV_CODEC_ID_XSUB)
+                    break;
+            case AVMEDIA_TYPE_VIDEO:
+                ff_put_bmp_header(pb, stream, ff_codec_bmp_tags, 0);
+                break;
+            case AVMEDIA_TYPE_AUDIO:
+                if (ff_put_wav_header(pb, stream) < 0)
+                    return -1;
+                break;
+            default:
                 return -1;
             }
-            break;
-        default:
-            return -1;
-        }
-        ff_end_tag(pb, strf);
-        if ((t = av_dict_get(s->streams[i]->metadata, "title", NULL, 0))) {
-            ff_riff_write_info_tag(s->pb, "strn", t->value);
-            t = NULL;
+            ff_end_tag(pb, strf);
+            if ((t = av_dict_get(s->streams[i]->metadata, "title", NULL, 0))) {
+                ff_riff_write_info_tag(s->pb, "strn", t->value);
+                t = NULL;
+            }
         }
-      }
 
         if (pb->seekable) {
             unsigned char tag[5];
@@ -299,47 +309,47 @@ static int avi_write_header(AVFormatContext *s)
             /* Starting to lay out AVI OpenDML master index.
              * We want to make it JUNK entry for now, since we'd
              * like to get away without making AVI an OpenDML one
-             * for compatibility reasons.
-             */
-            avist->indexes.entry = avist->indexes.ents_allocated = 0;
+             * for compatibility reasons. */
+            avist->indexes.entry      = avist->indexes.ents_allocated = 0;
             avist->indexes.indx_start = ff_start_tag(pb, "JUNK");
-            avio_wl16(pb, 4);        /* wLongsPerEntry */
-            avio_w8(pb, 0);          /* bIndexSubType (0 == frame index) */
-            avio_w8(pb, 0);          /* bIndexType (0 == AVI_INDEX_OF_INDEXES) */
-            avio_wl32(pb, 0);        /* nEntriesInUse (will fill out later on) */
+            avio_wl16(pb, 4);   /* wLongsPerEntry */
+            avio_w8(pb, 0);     /* bIndexSubType (0 == frame index) */
+            avio_w8(pb, 0);     /* bIndexType (0 == AVI_INDEX_OF_INDEXES) */
+            avio_wl32(pb, 0);   /* nEntriesInUse (will fill out later on) */
             ffio_wfourcc(pb, avi_stream2fourcc(tag, i, stream->codec_type));
-                                    /* dwChunkId */
-            avio_wl64(pb, 0);        /* dwReserved[3]
-            avio_wl32(pb, 0);           Must be 0.    */
-            for (j=0; j < AVI_MASTER_INDEX_SIZE * 2; j++)
-                 avio_wl64(pb, 0);
+                                /* dwChunkId */
+            avio_wl64(pb, 0);   /* dwReserved[3] */
+            // avio_wl32(pb, 0);   /* Must be 0.    */
+            for (j = 0; j < AVI_MASTER_INDEX_SIZE * 2; j++)
+                avio_wl64(pb, 0);
             ff_end_tag(pb, avist->indexes.indx_start);
         }
 
-        if(   stream->codec_type == AVMEDIA_TYPE_VIDEO
-           && s->streams[i]->sample_aspect_ratio.num>0
-           && s->streams[i]->sample_aspect_ratio.den>0){
-            int vprp= ff_start_tag(pb, "vprp");
+        if (stream->codec_type == AVMEDIA_TYPE_VIDEO   &&
+            s->streams[i]->sample_aspect_ratio.num > 0 &&
+            s->streams[i]->sample_aspect_ratio.den > 0) {
+            int vprp       = ff_start_tag(pb, "vprp");
             AVRational dar = av_mul_q(s->streams[i]->sample_aspect_ratio,
-                                      (AVRational){stream->width, stream->height});
+                                      (AVRational) { stream->width,
+                                                     stream->height });
             int num, den;
             av_reduce(&num, &den, dar.num, dar.den, 0xFFFF);
 
-            avio_wl32(pb, 0); //video format  = unknown
-            avio_wl32(pb, 0); //video standard= unknown
-            avio_wl32(pb, lrintf(1.0/av_q2d(stream->time_base)));
-            avio_wl32(pb, stream->width );
+            avio_wl32(pb, 0); // video format   = unknown
+            avio_wl32(pb, 0); // video standard = unknown
+            avio_wl32(pb, lrintf(1.0 / av_q2d(stream->time_base)));
+            avio_wl32(pb, stream->width);
             avio_wl32(pb, stream->height);
             avio_wl16(pb, den);
             avio_wl16(pb, num);
-            avio_wl32(pb, stream->width );
+            avio_wl32(pb, stream->width);
             avio_wl32(pb, stream->height);
-            avio_wl32(pb, 1); //progressive FIXME
+            avio_wl32(pb, 1); // progressive FIXME
 
             avio_wl32(pb, stream->height);
-            avio_wl32(pb, stream->width );
+            avio_wl32(pb, stream->width);
             avio_wl32(pb, stream->height);
-            avio_wl32(pb, stream->width );
+            avio_wl32(pb, stream->width);
             avio_wl32(pb, 0);
             avio_wl32(pb, 0);
 
@@ -357,8 +367,8 @@ static int avi_write_header(AVFormatContext *s)
         ffio_wfourcc(pb, "odml");
         ffio_wfourcc(pb, "dmlh");
         avio_wl32(pb, 248);
-        for (i = 0; i < 248; i+= 4)
-             avio_wl32(pb, 0);
+        for (i = 0; i < 248; i += 4)
+            avio_wl32(pb, 0);
         ff_end_tag(pb, avi->odml_list);
     }
 
@@ -393,47 +403,47 @@ static int avi_write_ix(AVFormatContext *s)
     if (avi->riff_id > AVI_MASTER_INDEX_SIZE)
         return -1;
 
-    for (i=0;i<s->nb_streams;i++) {
-        AVIStream *avist= s->streams[i]->priv_data;
-         int64_t ix, pos;
-
-         avi_stream2fourcc(tag, i, s->streams[i]->codec->codec_type);
-         ix_tag[3] = '0' + i;
-
-         /* Writing AVI OpenDML leaf index chunk */
-         ix = avio_tell(pb);
-         ffio_wfourcc(pb, ix_tag);     /* ix?? */
-         avio_wl32(pb, avist->indexes.entry * 8 + 24);
-                                      /* chunk size */
-         avio_wl16(pb, 2);             /* wLongsPerEntry */
-         avio_w8(pb, 0);             /* bIndexSubType (0 == frame index) */
-         avio_w8(pb, 1);             /* bIndexType (1 == AVI_INDEX_OF_CHUNKS) */
-         avio_wl32(pb, avist->indexes.entry);
-                                      /* nEntriesInUse */
-         ffio_wfourcc(pb, tag);        /* dwChunkId */
-         avio_wl64(pb, avi->movi_list);/* qwBaseOffset */
-         avio_wl32(pb, 0);             /* dwReserved_3 (must be 0) */
-
-         for (j=0; j<avist->indexes.entry; j++) {
-             AVIIentry* ie = avi_get_ientry(&avist->indexes, j);
-             avio_wl32(pb, ie->pos + 8);
-             avio_wl32(pb, ((uint32_t)ie->len & ~0x80000000) |
+    for (i = 0; i < s->nb_streams; i++) {
+        AVIStream *avist = s->streams[i]->priv_data;
+        int64_t ix, pos;
+
+        avi_stream2fourcc(tag, i, s->streams[i]->codec->codec_type);
+        ix_tag[3] = '0' + i;
+
+        /* Writing AVI OpenDML leaf index chunk */
+        ix = avio_tell(pb);
+        ffio_wfourcc(pb, ix_tag);      /* ix?? */
+        avio_wl32(pb, avist->indexes.entry * 8 + 24);
+        /* chunk size */
+        avio_wl16(pb, 2);           /* wLongsPerEntry */
+        avio_w8(pb, 0);             /* bIndexSubType (0 == frame index) */
+        avio_w8(pb, 1);             /* bIndexType (1 == AVI_INDEX_OF_CHUNKS) */
+        avio_wl32(pb, avist->indexes.entry);
+        /* nEntriesInUse */
+        ffio_wfourcc(pb, tag);         /* dwChunkId */
+        avio_wl64(pb, avi->movi_list); /* qwBaseOffset */
+        avio_wl32(pb, 0);              /* dwReserved_3 (must be 0) */
+
+        for (j = 0; j < avist->indexes.entry; j++) {
+            AVIIentry *ie = avi_get_ientry(&avist->indexes, j);
+            avio_wl32(pb, ie->pos + 8);
+            avio_wl32(pb, ((uint32_t) ie->len & ~0x80000000) |
                           (ie->flags & 0x10 ? 0 : 0x80000000));
-         }
-         avio_flush(pb);
-         pos = avio_tell(pb);
-
-         /* Updating one entry in the AVI OpenDML master index */
-         avio_seek(pb, avist->indexes.indx_start - 8, SEEK_SET);
-         ffio_wfourcc(pb, "indx");            /* enabling this entry */
-         avio_skip(pb, 8);
-         avio_wl32(pb, avi->riff_id);         /* nEntriesInUse */
-         avio_skip(pb, 16*avi->riff_id);
-         avio_wl64(pb, ix);                   /* qwOffset */
-         avio_wl32(pb, pos - ix);             /* dwSize */
-         avio_wl32(pb, avist->indexes.entry); /* dwDuration */
-
-         avio_seek(pb, pos, SEEK_SET);
+        }
+        avio_flush(pb);
+        pos = avio_tell(pb);
+
+        /* Updating one entry in the AVI OpenDML master index */
+        avio_seek(pb, avist->indexes.indx_start - 8, SEEK_SET);
+        ffio_wfourcc(pb, "indx");             /* enabling this entry */
+        avio_skip(pb, 8);
+        avio_wl32(pb, avi->riff_id);          /* nEntriesInUse */
+        avio_skip(pb, 16 * avi->riff_id);
+        avio_wl64(pb, ix);                    /* qwOffset */
+        avio_wl32(pb, pos - ix);              /* dwSize */
+        avio_wl32(pb, avist->indexes.entry);  /* dwDuration */
+
+        avio_seek(pb, pos, SEEK_SET);
     }
     return 0;
 }
@@ -448,31 +458,31 @@ static int avi_write_idx1(AVFormatContext *s)
 
     if (pb->seekable) {
         AVIStream *avist;
-        AVIIentry* ie = 0, *tie;
+        AVIIentry *ie = 0, *tie;
         int empty, stream_id = -1;
 
         idx_chunk = ff_start_tag(pb, "idx1");
-        for(i=0; i<s->nb_streams; i++){
-            avist= s->streams[i]->priv_data;
-            avist->entry=0;
+        for (i = 0; i < s->nb_streams; i++) {
+            avist        = s->streams[i]->priv_data;
+            avist->entry = 0;
         }
 
         do {
             empty = 1;
-            for (i=0; i<s->nb_streams; i++) {
-                avist= s->streams[i]->priv_data;
-                 if (avist->indexes.entry <= avist->entry)
-                     continue;
-
-                 tie = avi_get_ientry(&avist->indexes, avist->entry);
-                 if (empty || tie->pos < ie->pos) {
-                     ie = tie;
-                     stream_id = i;
-                 }
-                 empty = 0;
+            for (i = 0; i < s->nb_streams; i++) {
+                avist = s->streams[i]->priv_data;
+                if (avist->indexes.entry <= avist->entry)
+                    continue;
+
+                tie = avi_get_ientry(&avist->indexes, avist->entry);
+                if (empty || tie->pos < ie->pos) {
+                    ie        = tie;
+                    stream_id = i;
+                }
+                empty = 0;
             }
             if (!empty) {
-                avist= s->streams[stream_id]->priv_data;
+                avist = s->streams[stream_id]->priv_data;
                 avi_stream2fourcc(tag, stream_id,
                                   s->streams[stream_id]->codec->codec_type);
                 ffio_wfourcc(pb, tag);
@@ -491,22 +501,23 @@ static int avi_write_idx1(AVFormatContext *s)
 
 static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
 {
-    AVIContext *avi = s->priv_data;
-    AVIOContext *pb = s->pb;
     unsigned char tag[5];
-    unsigned int flags=0;
-    const int stream_index= pkt->stream_index;
-    AVIStream *avist= s->streams[stream_index]->priv_data;
-    AVCodecContext *enc= s->streams[stream_index]->codec;
-    int size= pkt->size;
-
-    while(enc->block_align==0 && pkt->dts != AV_NOPTS_VALUE && pkt->dts > avist->packet_count){
+    unsigned int flags = 0;
+    const int stream_index = pkt->stream_index;
+    int size               = pkt->size;
+    AVIContext *avi     = s->priv_data;
+    AVIOContext *pb     = s->pb;
+    AVIStream *avist    = s->streams[stream_index]->priv_data;
+    AVCodecContext *enc = s->streams[stream_index]->codec;
+
+    while (enc->block_align == 0 && pkt->dts != AV_NOPTS_VALUE &&
+           pkt->dts > avist->packet_count) {
         AVPacket empty_packet;
 
         av_init_packet(&empty_packet);
-        empty_packet.size= 0;
-        empty_packet.data= NULL;
-        empty_packet.stream_index= stream_index;
+        empty_packet.size         = 0;
+        empty_packet.data         = NULL;
+        empty_packet.stream_index = stream_index;
         avi_write_packet(s, &empty_packet);
     }
     avist->packet_count++;
@@ -514,7 +525,6 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
     // Make sure to put an OpenDML chunk when the file size exceeds the limits
     if (pb->seekable &&
         (avio_tell(pb) - avi->riff_start > AVI_MAX_RIFF_SIZE)) {
-
         avi_write_ix(s);
         ff_end_tag(pb, avi->movi_list);
 
@@ -526,32 +536,33 @@ static int avi_write_packet(AVFormatContext *s, AVPacket *pkt)
     }
 
     avi_stream2fourcc(tag, stream_index, enc->codec_type);
-    if(pkt->flags&AV_PKT_FLAG_KEY)
+    if (pkt->flags & AV_PKT_FLAG_KEY)
         flags = 0x10;
-    if (enc->codec_type == AVMEDIA_TYPE_AUDIO) {
-       avist->audio_strm_length += size;
-    }
+    if (enc->codec_type == AVMEDIA_TYPE_AUDIO)
+        avist->audio_strm_length += size;
 
     if (s->pb->seekable) {
         int err;
-        AVIIndex* idx = &avist->indexes;
+        AVIIndex *idx = &avist->indexes;
         int cl = idx->entry / AVI_INDEX_CLUSTER_SIZE;
         int id = idx->entry % AVI_INDEX_CLUSTER_SIZE;
         if (idx->ents_allocated <= idx->entry) {
-            if ((err = av_reallocp(&idx->cluster, (cl + 1) * sizeof(*idx->cluster))) < 0) {
+            if ((err = av_reallocp(&idx->cluster,
+                                   (cl + 1) * sizeof(*idx->cluster))) < 0) {
                 idx->ents_allocated = 0;
-                idx->entry = 0;
+                idx->entry          = 0;
                 return err;
             }
-            idx->cluster[cl] = av_malloc(AVI_INDEX_CLUSTER_SIZE*sizeof(AVIIentry));
+            idx->cluster[cl] =
+                av_malloc(AVI_INDEX_CLUSTER_SIZE * sizeof(AVIIentry));
             if (!idx->cluster[cl])
                 return -1;
             idx->ents_allocated += AVI_INDEX_CLUSTER_SIZE;
         }
 
         idx->cluster[cl][id].flags = flags;
-        idx->cluster[cl][id].pos = avio_tell(pb) - avi->movi_list;
-        idx->cluster[cl][id].len = size;
+        idx->cluster[cl][id].pos   = avio_tell(pb) - avi->movi_list;
+        idx->cluster[cl][id].len   = size;
         idx->entry++;
     }
 
@@ -572,7 +583,7 @@ static int avi_write_trailer(AVFormatContext *s)
     int i, j, n, nb_frames;
     int64_t file_size;
 
-    if (pb->seekable){
+    if (pb->seekable) {
         if (avi->riff_id == 1) {
             ff_end_tag(pb, avi->movi_list);
             res = avi_write_idx1(s);
@@ -587,17 +598,17 @@ static int avi_write_trailer(AVFormatContext *s)
             ffio_wfourcc(pb, "LIST"); /* Making this AVI OpenDML one */
             avio_skip(pb, 16);
 
-            for (n=nb_frames=0;n<s->nb_streams;n++) {
+            for (n = nb_frames = 0; n < s->nb_streams; n++) {
                 AVCodecContext *stream = s->streams[n]->codec;
-                AVIStream *avist= s->streams[n]->priv_data;
+                AVIStream *avist       = s->streams[n]->priv_data;
 
                 if (stream->codec_type == AVMEDIA_TYPE_VIDEO) {
                     if (nb_frames < avist->packet_count)
                         nb_frames = avist->packet_count;
                 } else {
-                    if (stream->codec_id == AV_CODEC_ID_MP2 || stream->codec_id == AV_CODEC_ID_MP3) {
+                    if (stream->codec_id == AV_CODEC_ID_MP2 ||
+                        stream->codec_id == AV_CODEC_ID_MP3)
                         nb_frames += avist->packet_count;
-                    }
                 }
             }
             avio_wl32(pb, nb_frames);
@@ -607,29 +618,29 @@ static int avi_write_trailer(AVFormatContext *s)
         }
     }
 
-    for (i=0; i<s->nb_streams; i++) {
-         AVIStream *avist= s->streams[i]->priv_data;
-         for (j=0; j<avist->indexes.ents_allocated/AVI_INDEX_CLUSTER_SIZE; j++)
-              av_free(avist->indexes.cluster[j]);
-         av_freep(&avist->indexes.cluster);
-         avist->indexes.ents_allocated = avist->indexes.entry = 0;
+    for (i = 0; i < s->nb_streams; i++) {
+        AVIStream *avist = s->streams[i]->priv_data;
+        for (j = 0; j < avist->indexes.ents_allocated / AVI_INDEX_CLUSTER_SIZE; j++)
+            av_free(avist->indexes.cluster[j]);
+        av_freep(&avist->indexes.cluster);
+        avist->indexes.ents_allocated = avist->indexes.entry = 0;
     }
 
     return res;
 }
 
 AVOutputFormat ff_avi_muxer = {
-    .name              = "avi",
-    .long_name         = NULL_IF_CONFIG_SMALL("AVI (Audio Video Interleaved)"),
-    .mime_type         = "video/x-msvideo",
-    .extensions        = "avi",
-    .priv_data_size    = sizeof(AVIContext),
-    .audio_codec       = CONFIG_LIBMP3LAME ? AV_CODEC_ID_MP3 : AV_CODEC_ID_AC3,
-    .video_codec       = AV_CODEC_ID_MPEG4,
-    .write_header      = avi_write_header,
-    .write_packet      = avi_write_packet,
-    .write_trailer     = avi_write_trailer,
-    .codec_tag         = (const AVCodecTag* const []){
+    .name           = "avi",
+    .long_name      = NULL_IF_CONFIG_SMALL("AVI (Audio Video Interleaved)"),
+    .mime_type      = "video/x-msvideo",
+    .extensions     = "avi",
+    .priv_data_size = sizeof(AVIContext),
+    .audio_codec    = CONFIG_LIBMP3LAME ? AV_CODEC_ID_MP3 : AV_CODEC_ID_AC3,
+    .video_codec    = AV_CODEC_ID_MPEG4,
+    .write_header   = avi_write_header,
+    .write_packet   = avi_write_packet,
+    .write_trailer  = avi_write_trailer,
+    .codec_tag      = (const AVCodecTag * const []) {
         ff_codec_bmp_tags, ff_codec_wav_tags, 0
     },
 };
diff --git a/deps/libav/libavformat/avio.h b/deps/libav/libavformat/avio.h
index b6d3cb3..3360e82 100644
--- a/deps/libav/libavformat/avio.h
+++ b/deps/libav/libavformat/avio.h
@@ -318,6 +318,7 @@ int avio_get_str16be(AVIOContext *pb, int maxlen, char *buf, int buflen);
  *
  * @param s Used to return the pointer to the created AVIOContext.
  * In case of failure the pointed to value is set to NULL.
+ * @param url resource to access
  * @param flags flags which control how the resource indicated by url
  * is to be opened
  * @return 0 in case of success, a negative value corresponding to an
@@ -333,6 +334,7 @@ int avio_open(AVIOContext **s, const char *url, int flags);
  *
  * @param s Used to return the pointer to the created AVIOContext.
  * In case of failure the pointed to value is set to NULL.
+ * @param url resource to access
  * @param flags flags which control how the resource indicated by url
  * is to be opened
  * @param int_cb an interrupt callback to be used at the protocols level
@@ -406,6 +408,8 @@ const char *avio_enum_protocols(void **opaque, int output);
 /**
  * Pause and resume playing - only meaningful if using a network streaming
  * protocol (e.g. MMS).
+ *
+ * @param h     IO context from which to call the read_pause function pointer
  * @param pause 1 for pause, 0 for resume
  */
 int     avio_pause(AVIOContext *h, int pause);
@@ -413,6 +417,8 @@ int     avio_pause(AVIOContext *h, int pause);
 /**
  * Seek to a given timestamp relative to some component stream.
  * Only meaningful if using a network streaming protocol (e.g. MMS.).
+ *
+ * @param h IO context from which to call the seek function pointers
  * @param stream_index The stream index that the timestamp is relative to.
  *        If stream_index is (-1) the timestamp should be in AV_TIME_BASE
  *        units from the beginning of the presentation.
diff --git a/deps/libav/libavformat/bink.c b/deps/libav/libavformat/bink.c
index f093e7c..4d2a735 100644
--- a/deps/libav/libavformat/bink.c
+++ b/deps/libav/libavformat/bink.c
@@ -28,6 +28,8 @@
  *  http://wiki.multimedia.cx/index.php?title=Bink_Container
  */
 
+#include <inttypes.h>
+
 #include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
@@ -108,7 +110,9 @@ static int read_header(AVFormatContext *s)
     fps_num = avio_rl32(pb);
     fps_den = avio_rl32(pb);
     if (fps_num == 0 || fps_den == 0) {
-        av_log(s, AV_LOG_ERROR, "invalid header: invalid fps (%d/%d)\n", fps_num, fps_den);
+        av_log(s, AV_LOG_ERROR,
+               "invalid header: invalid fps (%"PRIu32"/%"PRIu32")\n",
+               fps_num, fps_den);
         return AVERROR(EIO);
     }
     avpriv_set_pts_info(vst, 64, fps_den, fps_num);
@@ -126,7 +130,7 @@ static int read_header(AVFormatContext *s)
 
     if (bink->num_audio_tracks > BINK_MAX_AUDIO_TRACKS) {
         av_log(s, AV_LOG_ERROR,
-               "invalid header: more than "AV_STRINGIFY(BINK_MAX_AUDIO_TRACKS)" audio tracks (%d)\n",
+               "invalid header: more than "AV_STRINGIFY(BINK_MAX_AUDIO_TRACKS)" audio tracks (%"PRIu32")\n",
                bink->num_audio_tracks);
         return AVERROR(EIO);
     }
@@ -221,7 +225,7 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
         uint32_t audio_size = avio_rl32(pb);
         if (audio_size > bink->remain_packet_size - 4) {
             av_log(s, AV_LOG_ERROR,
-                   "frame %"PRId64": audio size in header (%u) > size of packet left (%u)\n",
+                   "frame %"PRId64": audio size in header (%"PRIu32") > size of packet left (%"PRIu32")\n",
                    bink->video_pts, audio_size, bink->remain_packet_size);
             return AVERROR(EIO);
         }
diff --git a/deps/libav/libavformat/cafdec.c b/deps/libav/libavformat/cafdec.c
index 6950eb2..7966225 100644
--- a/deps/libav/libavformat/cafdec.c
+++ b/deps/libav/libavformat/cafdec.c
@@ -25,6 +25,8 @@
  * Core Audio Format demuxer
  */
 
+#include <inttypes.h>
+
 #include "avformat.h"
 #include "internal.h"
 #include "isom.h"
@@ -289,7 +291,8 @@ static int read_header(AVFormatContext *s)
 
         default:
 #define _(x) ((x) >= ' ' ? (x) : ' ')
-            av_log(s, AV_LOG_WARNING, "skipping CAF chunk: %08X (%c%c%c%c)\n",
+            av_log(s, AV_LOG_WARNING,
+                   "skipping CAF chunk: %08"PRIX32" (%"PRIu8"%"PRIu8"%"PRIu8"%"PRIu8")\n",
                 tag, _(tag>>24), _((tag>>16)&0xFF), _((tag>>8)&0xFF), _(tag&0xFF));
 #undef _
         case MKBETAG('f','r','e','e'):
diff --git a/deps/libav/libavformat/crcenc.c b/deps/libav/libavformat/crcenc.c
index 3b30cc9..925646b 100644
--- a/deps/libav/libavformat/crcenc.c
+++ b/deps/libav/libavformat/crcenc.c
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <inttypes.h>
+
 #include "libavutil/adler32.h"
 #include "avformat.h"
 
@@ -48,7 +50,7 @@ static int crc_write_trailer(struct AVFormatContext *s)
     CRCState *crc = s->priv_data;
     char buf[64];
 
-    snprintf(buf, sizeof(buf), "CRC=0x%08x\n", crc->crcval);
+    snprintf(buf, sizeof(buf), "CRC=0x%08"PRIx32"\n", crc->crcval);
     avio_write(s->pb, buf, strlen(buf));
 
     return 0;
diff --git a/deps/libav/libavformat/dfa.c b/deps/libav/libavformat/dfa.c
index fa32d1f..c097d72 100644
--- a/deps/libav/libavformat/dfa.c
+++ b/deps/libav/libavformat/dfa.c
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <inttypes.h>
+
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
 #include "internal.h"
@@ -87,12 +89,13 @@ static int dfa_read_packet(AVFormatContext *s, AVPacket *pkt)
             first = 0;
         frame_size = AV_RL32(pkt->data + pkt->size - 8);
         if (frame_size > INT_MAX - 4) {
-            av_log(s, AV_LOG_ERROR, "Too large chunk size: %d\n", frame_size);
+            av_log(s, AV_LOG_ERROR, "Too large chunk size: %"PRIu32"\n", frame_size);
             return AVERROR(EIO);
         }
         if (AV_RL32(pkt->data + pkt->size - 12) == MKTAG('E', 'O', 'F', 'R')) {
             if (frame_size) {
-                av_log(s, AV_LOG_WARNING, "skipping %d bytes of end-of-frame marker chunk\n",
+                av_log(s, AV_LOG_WARNING,
+                       "skipping %"PRIu32" bytes of end-of-frame marker chunk\n",
                        frame_size);
                 avio_skip(pb, frame_size);
             }
diff --git a/deps/libav/libavformat/dxa.c b/deps/libav/libavformat/dxa.c
index a1b85fe..78e7290 100644
--- a/deps/libav/libavformat/dxa.c
+++ b/deps/libav/libavformat/dxa.c
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <inttypes.h>
+
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
 #include "internal.h"
@@ -190,7 +192,8 @@ static int dxa_read_packet(AVFormatContext *s, AVPacket *pkt)
             avio_read(s->pb, buf + 4, DXA_EXTRA_SIZE - 4);
             size = AV_RB32(buf + 5);
             if(size > 0xFFFFFF){
-                av_log(s, AV_LOG_ERROR, "Frame size is too big: %d\n", size);
+                av_log(s, AV_LOG_ERROR, "Frame size is too big: %"PRIu32"\n",
+                       size);
                 return -1;
             }
             if(av_new_packet(pkt, size + DXA_EXTRA_SIZE + pal_size) < 0)
diff --git a/deps/libav/libavformat/electronicarts.c b/deps/libav/libavformat/electronicarts.c
index 9d00c2d..879ed97 100644
--- a/deps/libav/libavformat/electronicarts.c
+++ b/deps/libav/libavformat/electronicarts.c
@@ -25,6 +25,8 @@
  * by Robin Kay (komadori at gekkou.co.uk)
  */
 
+#include <inttypes.h>
+
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
 #include "internal.h"
@@ -151,7 +153,7 @@ static int process_audio_header_elements(AVFormatContext *s)
                     break;
                 case 0x8A:
                     av_log(s, AV_LOG_DEBUG,
-                           "element 0x%02x set to 0x%08x\n",
+                           "element 0x%02x set to 0x%08"PRIx32"\n",
                            subbyte, read_arbitrary(pb));
                     av_log(s, AV_LOG_DEBUG, "exited audio subheader\n");
                     in_subheader = 0;
@@ -170,7 +172,7 @@ static int process_audio_header_elements(AVFormatContext *s)
                     break;
                 default:
                     av_log(s, AV_LOG_DEBUG,
-                           "element 0x%02x set to 0x%08x\n",
+                           "element 0x%02x set to 0x%08"PRIx32"\n",
                            subbyte, read_arbitrary(pb));
                     break;
                 }
@@ -182,7 +184,7 @@ static int process_audio_header_elements(AVFormatContext *s)
             break;
         default:
             av_log(s, AV_LOG_DEBUG,
-                   "header element 0x%02x set to 0x%08x\n",
+                   "header element 0x%02x set to 0x%08"PRIx32"\n",
                    byte, read_arbitrary(pb));
             break;
         }
diff --git a/deps/libav/libavformat/framecrcenc.c b/deps/libav/libavformat/framecrcenc.c
index dd55c12..4d5483a 100644
--- a/deps/libav/libavformat/framecrcenc.c
+++ b/deps/libav/libavformat/framecrcenc.c
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <inttypes.h>
+
 #include "libavutil/adler32.h"
 #include "avformat.h"
 #include "internal.h"
@@ -28,7 +30,7 @@ static int framecrc_write_packet(struct AVFormatContext *s, AVPacket *pkt)
     uint32_t crc = av_adler32_update(0, pkt->data, pkt->size);
     char buf[256];
 
-    snprintf(buf, sizeof(buf), "%d, %10"PRId64", %10"PRId64", %8d, %8d, 0x%08x\n",
+    snprintf(buf, sizeof(buf), "%d, %10"PRId64", %10"PRId64", %8d, %8d, 0x%08"PRIx32"\n",
              pkt->stream_index, pkt->dts, pkt->pts, pkt->duration, pkt->size, crc);
     avio_write(s->pb, buf, strlen(buf));
     return 0;
diff --git a/deps/libav/libavformat/gxf.c b/deps/libav/libavformat/gxf.c
index 6feb3c3..1895840 100644
--- a/deps/libav/libavformat/gxf.c
+++ b/deps/libav/libavformat/gxf.c
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <inttypes.h>
+
 #include "libavutil/channel_layout.h"
 #include "libavutil/common.h"
 #include "avformat.h"
@@ -259,7 +261,9 @@ static void gxf_read_index(AVFormatContext *s, int pkt_len) {
         return;
     }
     if (map_cnt > 1000) {
-        av_log(s, AV_LOG_ERROR, "too many index entries %u (%x)\n", map_cnt, map_cnt);
+        av_log(s, AV_LOG_ERROR,
+               "too many index entries %"PRIu32" (%"PRIx32")\n",
+               map_cnt, map_cnt);
         map_cnt = 1000;
     }
     if (pkt_len < 4 * map_cnt) {
diff --git a/deps/libav/libavformat/hevc.c b/deps/libav/libavformat/hevc.c
new file mode 100644
index 0000000..37b35b4
--- /dev/null
+++ b/deps/libav/libavformat/hevc.c
@@ -0,0 +1,1140 @@
+/*
+ * Copyright (c) 2014 Tim Walker <tdskywalker at gmail.com>
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavcodec/get_bits.h"
+#include "libavcodec/golomb.h"
+#include "libavcodec/hevc.h"
+#include "libavutil/intreadwrite.h"
+#include "avc.h"
+#include "avio.h"
+#include "hevc.h"
+
+#define MAX_SPATIAL_SEGMENTATION 4096 // max. value of u(12) field
+
+typedef struct HVCCNALUnitArray {
+    uint8_t  array_completeness;
+    uint8_t  NAL_unit_type;
+    uint16_t numNalus;
+    uint16_t *nalUnitLength;
+    uint8_t  **nalUnit;
+} HVCCNALUnitArray;
+
+typedef struct HEVCDecoderConfigurationRecord {
+    uint8_t  configurationVersion;
+    uint8_t  general_profile_space;
+    uint8_t  general_tier_flag;
+    uint8_t  general_profile_idc;
+    uint32_t general_profile_compatibility_flags;
+    uint64_t general_constraint_indicator_flags;
+    uint8_t  general_level_idc;
+    uint16_t min_spatial_segmentation_idc;
+    uint8_t  parallelismType;
+    uint8_t  chromaFormat;
+    uint8_t  bitDepthLumaMinus8;
+    uint8_t  bitDepthChromaMinus8;
+    uint16_t avgFrameRate;
+    uint8_t  constantFrameRate;
+    uint8_t  numTemporalLayers;
+    uint8_t  temporalIdNested;
+    uint8_t  lengthSizeMinusOne;
+    uint8_t  numOfArrays;
+    HVCCNALUnitArray *array;
+} HEVCDecoderConfigurationRecord;
+
+typedef struct HVCCProfileTierLevel {
+    uint8_t  profile_space;
+    uint8_t  tier_flag;
+    uint8_t  profile_idc;
+    uint32_t profile_compatibility_flags;
+    uint64_t constraint_indicator_flags;
+    uint8_t  level_idc;
+} HVCCProfileTierLevel;
+
+static void hvcc_update_ptl(HEVCDecoderConfigurationRecord *hvcc,
+                            HVCCProfileTierLevel *ptl)
+{
+    /*
+     * The value of general_profile_space in all the parameter sets must be
+     * identical.
+     */
+    hvcc->general_profile_space = ptl->profile_space;
+
+    /*
+     * The level indication general_level_idc must indicate a level of
+     * capability equal to or greater than the highest level indicated for the
+     * highest tier in all the parameter sets.
+     */
+    if (hvcc->general_tier_flag < ptl->tier_flag)
+        hvcc->general_level_idc = ptl->level_idc;
+    else
+        hvcc->general_level_idc = FFMAX(hvcc->general_level_idc, ptl->level_idc);
+
+    /*
+     * The tier indication general_tier_flag must indicate a tier equal to or
+     * greater than the highest tier indicated in all the parameter sets.
+     */
+    hvcc->general_tier_flag = FFMAX(hvcc->general_tier_flag, ptl->tier_flag);
+
+    /*
+     * The profile indication general_profile_idc must indicate a profile to
+     * which the stream associated with this configuration record conforms.
+     *
+     * If the sequence parameter sets are marked with different profiles, then
+     * the stream may need examination to determine which profile, if any, the
+     * entire stream conforms to. If the entire stream is not examined, or the
+     * examination reveals that there is no profile to which the entire stream
+     * conforms, then the entire stream must be split into two or more
+     * sub-streams with separate configuration records in which these rules can
+     * be met.
+     *
+     * Note: set the profile to the highest value for the sake of simplicity.
+     */
+    hvcc->general_profile_idc = FFMAX(hvcc->general_profile_idc, ptl->profile_idc);
+
+    /*
+     * Each bit in general_profile_compatibility_flags may only be set if all
+     * the parameter sets set that bit.
+     */
+    hvcc->general_profile_compatibility_flags &= ptl->profile_compatibility_flags;
+
+    /*
+     * Each bit in general_constraint_indicator_flags may only be set if all
+     * the parameter sets set that bit.
+     */
+    hvcc->general_constraint_indicator_flags &= ptl->constraint_indicator_flags;
+}
+
+static void hvcc_parse_ptl(GetBitContext *gb,
+                           HEVCDecoderConfigurationRecord *hvcc,
+                           unsigned int max_sub_layers_minus1)
+{
+    unsigned int i;
+    HVCCProfileTierLevel general_ptl;
+    uint8_t sub_layer_profile_present_flag[MAX_SUB_LAYERS];
+    uint8_t sub_layer_level_present_flag[MAX_SUB_LAYERS];
+
+    general_ptl.profile_space               = get_bits(gb, 2);
+    general_ptl.tier_flag                   = get_bits1(gb);
+    general_ptl.profile_idc                 = get_bits(gb, 5);
+    general_ptl.profile_compatibility_flags = get_bits_long(gb, 32);
+    general_ptl.constraint_indicator_flags  = get_bits64(gb, 48);
+    general_ptl.level_idc                   = get_bits(gb, 8);
+    hvcc_update_ptl(hvcc, &general_ptl);
+
+    for (i = 0; i < max_sub_layers_minus1; i++) {
+        sub_layer_profile_present_flag[i] = get_bits1(gb);
+        sub_layer_level_present_flag[i]   = get_bits1(gb);
+    }
+
+    if (max_sub_layers_minus1 > 0)
+        for (i = max_sub_layers_minus1; i < 8; i++)
+            skip_bits(gb, 2); // reserved_zero_2bits[i]
+
+    for (i = 0; i < max_sub_layers_minus1; i++) {
+        if (sub_layer_profile_present_flag[i]) {
+            /*
+             * sub_layer_profile_space[i]                     u(2)
+             * sub_layer_tier_flag[i]                         u(1)
+             * sub_layer_profile_idc[i]                       u(5)
+             * sub_layer_profile_compatibility_flag[i][0..31] u(32)
+             * sub_layer_progressive_source_flag[i]           u(1)
+             * sub_layer_interlaced_source_flag[i]            u(1)
+             * sub_layer_non_packed_constraint_flag[i]        u(1)
+             * sub_layer_frame_only_constraint_flag[i]        u(1)
+             * sub_layer_reserved_zero_44bits[i]              u(44)
+             */
+            skip_bits_long(gb, 32);
+            skip_bits_long(gb, 32);
+            skip_bits     (gb, 24);
+        }
+
+        if (sub_layer_level_present_flag[i])
+            skip_bits(gb, 8);
+    }
+}
+
+static void skip_sub_layer_hrd_parameters(GetBitContext *gb,
+                                          unsigned int cpb_cnt_minus1,
+                                          uint8_t sub_pic_hrd_params_present_flag)
+{
+    unsigned int i;
+
+    for (i = 0; i <= cpb_cnt_minus1; i++) {
+        get_ue_golomb_long(gb); // bit_rate_value_minus1
+        get_ue_golomb_long(gb); // cpb_size_value_minus1
+
+        if (sub_pic_hrd_params_present_flag) {
+            get_ue_golomb_long(gb); // cpb_size_du_value_minus1
+            get_ue_golomb_long(gb); // bit_rate_du_value_minus1
+        }
+
+        skip_bits1(gb); // cbr_flag
+    }
+}
+
+static void skip_hrd_parameters(GetBitContext *gb, uint8_t cprms_present_flag,
+                                unsigned int max_sub_layers_minus1)
+{
+    unsigned int i;
+    uint8_t sub_pic_hrd_params_present_flag = 0;
+    uint8_t nal_hrd_parameters_present_flag = 0;
+    uint8_t vcl_hrd_parameters_present_flag = 0;
+
+    if (cprms_present_flag) {
+        nal_hrd_parameters_present_flag = get_bits1(gb);
+        vcl_hrd_parameters_present_flag = get_bits1(gb);
+
+        if (nal_hrd_parameters_present_flag ||
+            vcl_hrd_parameters_present_flag) {
+            sub_pic_hrd_params_present_flag = get_bits1(gb);
+
+            if (sub_pic_hrd_params_present_flag)
+                /*
+                 * tick_divisor_minus2                          u(8)
+                 * du_cpb_removal_delay_increment_length_minus1 u(5)
+                 * sub_pic_cpb_params_in_pic_timing_sei_flag    u(1)
+                 * dpb_output_delay_du_length_minus1            u(5)
+                 */
+                skip_bits(gb, 19);
+
+            /*
+             * bit_rate_scale u(4)
+             * cpb_size_scale u(4)
+             */
+            skip_bits(gb, 8);
+
+            if (sub_pic_hrd_params_present_flag)
+                skip_bits(gb, 4); // cpb_size_du_scale
+
+            /*
+             * initial_cpb_removal_delay_length_minus1 u(5)
+             * au_cpb_removal_delay_length_minus1      u(5)
+             * dpb_output_delay_length_minus1          u(5)
+             */
+            skip_bits(gb, 15);
+        }
+    }
+
+    for (i = 0; i <= max_sub_layers_minus1; i++) {
+        unsigned int cpb_cnt_minus1            = 0;
+        uint8_t low_delay_hrd_flag             = 0;
+        uint8_t fixed_pic_rate_within_cvs_flag = 0;
+        uint8_t fixed_pic_rate_general_flag    = get_bits1(gb);
+
+        if (!fixed_pic_rate_general_flag)
+            fixed_pic_rate_within_cvs_flag = get_bits1(gb);
+
+        if (fixed_pic_rate_within_cvs_flag)
+            get_ue_golomb_long(gb); // elemental_duration_in_tc_minus1
+        else
+            low_delay_hrd_flag = get_bits1(gb);
+
+        if (!low_delay_hrd_flag)
+            cpb_cnt_minus1 = get_ue_golomb_long(gb);
+
+        if (nal_hrd_parameters_present_flag)
+            skip_sub_layer_hrd_parameters(gb, cpb_cnt_minus1,
+                                          sub_pic_hrd_params_present_flag);
+
+        if (vcl_hrd_parameters_present_flag)
+            skip_sub_layer_hrd_parameters(gb, cpb_cnt_minus1,
+                                          sub_pic_hrd_params_present_flag);
+    }
+}
+
+static void skip_timing_info(GetBitContext *gb)
+{
+    skip_bits_long(gb, 32); // num_units_in_tick
+    skip_bits_long(gb, 32); // time_scale
+
+    if (get_bits1(gb))          // poc_proportional_to_timing_flag
+        get_ue_golomb_long(gb); // num_ticks_poc_diff_one_minus1
+}
+
+static void hvcc_parse_vui(GetBitContext *gb,
+                           HEVCDecoderConfigurationRecord *hvcc,
+                           unsigned int max_sub_layers_minus1)
+{
+    unsigned int min_spatial_segmentation_idc;
+
+    if (get_bits1(gb))              // aspect_ratio_info_present_flag
+        if (get_bits(gb, 8) == 255) // aspect_ratio_idc
+            skip_bits_long(gb, 32); // sar_width u(16), sar_height u(16)
+
+    if (get_bits1(gb))  // overscan_info_present_flag
+        skip_bits1(gb); // overscan_appropriate_flag
+
+    if (get_bits1(gb)) {  // video_signal_type_present_flag
+        skip_bits(gb, 4); // video_format u(3), video_full_range_flag u(1)
+
+        if (get_bits1(gb)) // colour_description_present_flag
+            /*
+             * colour_primaries         u(8)
+             * transfer_characteristics u(8)
+             * matrix_coeffs            u(8)
+             */
+            skip_bits(gb, 24);
+    }
+
+    if (get_bits1(gb)) {        // chroma_loc_info_present_flag
+        get_ue_golomb_long(gb); // chroma_sample_loc_type_top_field
+        get_ue_golomb_long(gb); // chroma_sample_loc_type_bottom_field
+    }
+
+    /*
+     * neutral_chroma_indication_flag u(1)
+     * field_seq_flag                 u(1)
+     * frame_field_info_present_flag  u(1)
+     */
+    skip_bits(gb, 3);
+
+    if (get_bits1(gb)) {        // default_display_window_flag
+        get_ue_golomb_long(gb); // def_disp_win_left_offset
+        get_ue_golomb_long(gb); // def_disp_win_right_offset
+        get_ue_golomb_long(gb); // def_disp_win_top_offset
+        get_ue_golomb_long(gb); // def_disp_win_bottom_offset
+    }
+
+    if (get_bits1(gb)) { // vui_timing_info_present_flag
+        skip_timing_info(gb);
+
+        if (get_bits1(gb)) // vui_hrd_parameters_present_flag
+            skip_hrd_parameters(gb, 1, max_sub_layers_minus1);
+    }
+
+    if (get_bits1(gb)) { // bitstream_restriction_flag
+        /*
+         * tiles_fixed_structure_flag              u(1)
+         * motion_vectors_over_pic_boundaries_flag u(1)
+         * restricted_ref_pic_lists_flag           u(1)
+         */
+        skip_bits(gb, 3);
+
+        min_spatial_segmentation_idc = get_ue_golomb_long(gb);
+
+        /*
+         * unsigned int(12) min_spatial_segmentation_idc;
+         *
+         * The min_spatial_segmentation_idc indication must indicate a level of
+         * spatial segmentation equal to or less than the lowest level of
+         * spatial segmentation indicated in all the parameter sets.
+         */
+        hvcc->min_spatial_segmentation_idc = FFMIN(hvcc->min_spatial_segmentation_idc,
+                                                   min_spatial_segmentation_idc);
+
+        get_ue_golomb_long(gb); // max_bytes_per_pic_denom
+        get_ue_golomb_long(gb); // max_bits_per_min_cu_denom
+        get_ue_golomb_long(gb); // log2_max_mv_length_horizontal
+        get_ue_golomb_long(gb); // log2_max_mv_length_vertical
+    }
+}
+
+static void skip_sub_layer_ordering_info(GetBitContext *gb)
+{
+    get_ue_golomb_long(gb); // max_dec_pic_buffering_minus1
+    get_ue_golomb_long(gb); // max_num_reorder_pics
+    get_ue_golomb_long(gb); // max_latency_increase_plus1
+}
+
+static int hvcc_parse_vps(GetBitContext *gb,
+                          HEVCDecoderConfigurationRecord *hvcc)
+{
+    unsigned int vps_max_sub_layers_minus1;
+
+    /*
+     * vps_video_parameter_set_id u(4)
+     * vps_reserved_three_2bits   u(2)
+     * vps_max_layers_minus1      u(6)
+     */
+    skip_bits(gb, 12);
+
+    vps_max_sub_layers_minus1 = get_bits(gb, 3);
+
+    /*
+     * numTemporalLayers greater than 1 indicates that the stream to which this
+     * configuration record applies is temporally scalable and the contained
+     * number of temporal layers (also referred to as temporal sub-layer or
+     * sub-layer in ISO/IEC 23008-2) is equal to numTemporalLayers. Value 1
+     * indicates that the stream is not temporally scalable. Value 0 indicates
+     * that it is unknown whether the stream is temporally scalable.
+     */
+    hvcc->numTemporalLayers = FFMAX(hvcc->numTemporalLayers,
+                                    vps_max_sub_layers_minus1 + 1);
+
+    /*
+     * vps_temporal_id_nesting_flag u(1)
+     * vps_reserved_0xffff_16bits   u(16)
+     */
+    skip_bits(gb, 17);
+
+    hvcc_parse_ptl(gb, hvcc, vps_max_sub_layers_minus1);
+
+    /* nothing useful for hvcC past this point */
+    return 0;
+}
+
+static void skip_scaling_list_data(GetBitContext *gb)
+{
+    int i, j, k, num_coeffs;
+
+    for (i = 0; i < 4; i++)
+        for (j = 0; j < (i == 3 ? 2 : 6); j++)
+            if (!get_bits1(gb))         // scaling_list_pred_mode_flag[i][j]
+                get_ue_golomb_long(gb); // scaling_list_pred_matrix_id_delta[i][j]
+            else {
+                num_coeffs = FFMIN(64, 1 << (4 + (i << 1)));
+
+                if (i > 1)
+                    get_se_golomb_long(gb); // scaling_list_dc_coef_minus8[i-2][j]
+
+                for (k = 0; k < num_coeffs; k++)
+                    get_se_golomb_long(gb); // scaling_list_delta_coef
+            }
+}
+
+static int parse_rps(GetBitContext *gb, unsigned int rps_idx,
+                     unsigned int num_rps,
+                     unsigned int num_delta_pocs[MAX_SHORT_TERM_RPS_COUNT])
+{
+    unsigned int i;
+
+    if (rps_idx && get_bits1(gb)) { // inter_ref_pic_set_prediction_flag
+        /* this should only happen for slice headers, and this isn't one */
+        if (rps_idx >= num_rps)
+            return AVERROR_INVALIDDATA;
+
+        skip_bits1        (gb); // delta_rps_sign
+        get_ue_golomb_long(gb); // abs_delta_rps_minus1
+
+        num_delta_pocs[rps_idx] = 0;
+
+        /*
+         * From libavcodec/hevc_ps.c:
+         *
+         * if (is_slice_header) {
+         *    //foo
+         * } else
+         *     rps_ridx = &sps->st_rps[rps - sps->st_rps - 1];
+         *
+         * where:
+         * rps:             &sps->st_rps[rps_idx]
+         * sps->st_rps:     &sps->st_rps[0]
+         * is_slice_header: rps_idx == num_rps
+         *
+         * thus:
+         * if (num_rps != rps_idx)
+         *     rps_ridx = &sps->st_rps[rps_idx - 1];
+         *
+         * NumDeltaPocs[RefRpsIdx]: num_delta_pocs[rps_idx - 1]
+         */
+        for (i = 0; i < num_delta_pocs[rps_idx - 1]; i++) {
+            uint8_t use_delta_flag = 0;
+            uint8_t used_by_curr_pic_flag = get_bits1(gb);
+            if (!used_by_curr_pic_flag)
+                use_delta_flag = get_bits1(gb);
+
+            if (used_by_curr_pic_flag || use_delta_flag)
+                num_delta_pocs[rps_idx]++;
+        }
+    } else {
+        unsigned int num_negative_pics = get_ue_golomb_long(gb);
+        unsigned int num_positive_pics = get_ue_golomb_long(gb);
+
+        num_delta_pocs[rps_idx] = num_negative_pics + num_positive_pics;
+
+        for (i = 0; i < num_negative_pics; i++) {
+            get_ue_golomb_long(gb); // delta_poc_s0_minus1[rps_idx]
+            skip_bits1        (gb); // used_by_curr_pic_s0_flag[rps_idx]
+        }
+
+        for (i = 0; i < num_positive_pics; i++) {
+            get_ue_golomb_long(gb); // delta_poc_s1_minus1[rps_idx]
+            skip_bits1        (gb); // used_by_curr_pic_s1_flag[rps_idx]
+        }
+    }
+
+    return 0;
+}
+
+static int hvcc_parse_sps(GetBitContext *gb,
+                          HEVCDecoderConfigurationRecord *hvcc)
+{
+    unsigned int i, sps_max_sub_layers_minus1, log2_max_pic_order_cnt_lsb_minus4;
+    unsigned int num_short_term_ref_pic_sets, num_delta_pocs[MAX_SHORT_TERM_RPS_COUNT];
+
+    skip_bits(gb, 4); // sps_video_parameter_set_id
+
+    sps_max_sub_layers_minus1 = get_bits (gb, 3);
+
+    /*
+     * numTemporalLayers greater than 1 indicates that the stream to which this
+     * configuration record applies is temporally scalable and the contained
+     * number of temporal layers (also referred to as temporal sub-layer or
+     * sub-layer in ISO/IEC 23008-2) is equal to numTemporalLayers. Value 1
+     * indicates that the stream is not temporally scalable. Value 0 indicates
+     * that it is unknown whether the stream is temporally scalable.
+     */
+    hvcc->numTemporalLayers = FFMAX(hvcc->numTemporalLayers,
+                                    sps_max_sub_layers_minus1 + 1);
+
+    hvcc->temporalIdNested = get_bits1(gb);
+
+    hvcc_parse_ptl(gb, hvcc, sps_max_sub_layers_minus1);
+
+    get_ue_golomb_long(gb); // sps_seq_parameter_set_id
+
+    hvcc->chromaFormat = get_ue_golomb_long(gb);
+
+    if (hvcc->chromaFormat == 3)
+        skip_bits1(gb); // separate_colour_plane_flag
+
+    get_ue_golomb_long(gb); // pic_width_in_luma_samples
+    get_ue_golomb_long(gb); // pic_height_in_luma_samples
+
+    if (get_bits1(gb)) {        // conformance_window_flag
+        get_ue_golomb_long(gb); // conf_win_left_offset
+        get_ue_golomb_long(gb); // conf_win_right_offset
+        get_ue_golomb_long(gb); // conf_win_top_offset
+        get_ue_golomb_long(gb); // conf_win_bottom_offset
+    }
+
+    hvcc->bitDepthLumaMinus8          = get_ue_golomb_long(gb);
+    hvcc->bitDepthChromaMinus8        = get_ue_golomb_long(gb);
+    log2_max_pic_order_cnt_lsb_minus4 = get_ue_golomb_long(gb);
+
+    /* sps_sub_layer_ordering_info_present_flag */
+    i = get_bits1(gb) ? 0 : sps_max_sub_layers_minus1;
+    for (; i <= sps_max_sub_layers_minus1; i++)
+        skip_sub_layer_ordering_info(gb);
+
+    get_ue_golomb_long(gb); // log2_min_luma_coding_block_size_minus3
+    get_ue_golomb_long(gb); // log2_diff_max_min_luma_coding_block_size
+    get_ue_golomb_long(gb); // log2_min_transform_block_size_minus2
+    get_ue_golomb_long(gb); // log2_diff_max_min_transform_block_size
+    get_ue_golomb_long(gb); // max_transform_hierarchy_depth_inter
+    get_ue_golomb_long(gb); // max_transform_hierarchy_depth_intra
+
+    if (get_bits1(gb) && // scaling_list_enabled_flag
+        get_bits1(gb))   // sps_scaling_list_data_present_flag
+        skip_scaling_list_data(gb);
+
+    skip_bits1(gb); // amp_enabled_flag
+    skip_bits1(gb); // sample_adaptive_offset_enabled_flag
+
+    if (get_bits1(gb)) {           // pcm_enabled_flag
+        skip_bits         (gb, 4); // pcm_sample_bit_depth_luma_minus1
+        skip_bits         (gb, 4); // pcm_sample_bit_depth_chroma_minus1
+        get_ue_golomb_long(gb);    // log2_min_pcm_luma_coding_block_size_minus3
+        get_ue_golomb_long(gb);    // log2_diff_max_min_pcm_luma_coding_block_size
+        skip_bits1        (gb);    // pcm_loop_filter_disabled_flag
+    }
+
+    num_short_term_ref_pic_sets = get_ue_golomb_long(gb);
+    if (num_short_term_ref_pic_sets > MAX_SHORT_TERM_RPS_COUNT)
+        return AVERROR_INVALIDDATA;
+
+    for (i = 0; i < num_short_term_ref_pic_sets; i++) {
+        int ret = parse_rps(gb, i, num_short_term_ref_pic_sets, num_delta_pocs);
+        if (ret < 0)
+            return ret;
+    }
+
+    if (get_bits1(gb)) {                               // long_term_ref_pics_present_flag
+        for (i = 0; i < get_ue_golomb_long(gb); i++) { // num_long_term_ref_pics_sps
+            int len = FFMIN(log2_max_pic_order_cnt_lsb_minus4 + 4, 16);
+            skip_bits (gb, len); // lt_ref_pic_poc_lsb_sps[i]
+            skip_bits1(gb);      // used_by_curr_pic_lt_sps_flag[i]
+        }
+    }
+
+    skip_bits1(gb); // sps_temporal_mvp_enabled_flag
+    skip_bits1(gb); // strong_intra_smoothing_enabled_flag
+
+    if (get_bits1(gb)) // vui_parameters_present_flag
+        hvcc_parse_vui(gb, hvcc, sps_max_sub_layers_minus1);
+
+    /* nothing useful for hvcC past this point */
+    return 0;
+}
+
+static int hvcc_parse_pps(GetBitContext *gb,
+                          HEVCDecoderConfigurationRecord *hvcc)
+{
+    uint8_t tiles_enabled_flag, entropy_coding_sync_enabled_flag;
+
+    get_ue_golomb_long(gb); // pps_pic_parameter_set_id
+    get_ue_golomb_long(gb); // pps_seq_parameter_set_id
+
+    /*
+     * dependent_slice_segments_enabled_flag u(1)
+     * output_flag_present_flag              u(1)
+     * num_extra_slice_header_bits           u(3)
+     * sign_data_hiding_enabled_flag         u(1)
+     * cabac_init_present_flag               u(1)
+     */
+    skip_bits(gb, 7);
+
+    get_ue_golomb_long(gb); // num_ref_idx_l0_default_active_minus1
+    get_ue_golomb_long(gb); // num_ref_idx_l1_default_active_minus1
+    get_se_golomb_long(gb); // init_qp_minus26
+
+    /*
+     * constrained_intra_pred_flag u(1)
+     * transform_skip_enabled_flag u(1)
+     */
+    skip_bits(gb, 2);
+
+    if (get_bits1(gb))          // cu_qp_delta_enabled_flag
+        get_ue_golomb_long(gb); // diff_cu_qp_delta_depth
+
+    get_se_golomb_long(gb); // pps_cb_qp_offset
+    get_se_golomb_long(gb); // pps_cr_qp_offset
+
+    /*
+     * weighted_pred_flag               u(1)
+     * weighted_bipred_flag             u(1)
+     * transquant_bypass_enabled_flag   u(1)
+     */
+    skip_bits(gb, 3);
+
+    tiles_enabled_flag               = get_bits1(gb);
+    entropy_coding_sync_enabled_flag = get_bits1(gb);
+
+    if (entropy_coding_sync_enabled_flag && tiles_enabled_flag)
+        hvcc->parallelismType = 0; // mixed-type parallel decoding
+    else if (entropy_coding_sync_enabled_flag)
+        hvcc->parallelismType = 3; // wavefront-based parallel decoding
+    else if (tiles_enabled_flag)
+        hvcc->parallelismType = 2; // tile-based parallel decoding
+    else
+        hvcc->parallelismType = 1; // slice-based parallel decoding
+
+    /* nothing useful for hvcC past this point */
+    return 0;
+}
+
+static uint8_t *nal_unit_extract_rbsp(const uint8_t *src, uint32_t src_len,
+                                      uint32_t *dst_len)
+{
+    uint8_t *dst;
+    uint32_t i, len;
+
+    dst = av_malloc(src_len);
+    if (!dst)
+        return NULL;
+
+    /* NAL unit header (2 bytes) */
+    i = len = 0;
+    while (i < 2 && i < src_len)
+        dst[len++] = src[i++];
+
+    while (i + 2 < src_len)
+        if (!src[i] && !src[i + 1] && src[i + 2] == 3) {
+            dst[len++] = src[i++];
+            dst[len++] = src[i++];
+            i++; // remove emulation_prevention_three_byte
+        } else
+            dst[len++] = src[i++];
+
+    while (i < src_len)
+        dst[len++] = src[i++];
+
+    *dst_len = len;
+    return dst;
+}
+
+
+
+static void nal_unit_parse_header(GetBitContext *gb, uint8_t *nal_type)
+{
+    skip_bits1(gb); // forbidden_zero_bit
+
+    *nal_type = get_bits(gb, 6);
+
+    /*
+     * nuh_layer_id          u(6)
+     * nuh_temporal_id_plus1 u(3)
+     */
+    skip_bits(gb, 9);
+}
+
+static int hvcc_array_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
+                                   uint8_t nal_type, int ps_array_completeness,
+                                   HEVCDecoderConfigurationRecord *hvcc)
+{
+    int ret;
+    uint8_t index;
+    uint16_t numNalus;
+    HVCCNALUnitArray *array;
+
+    for (index = 0; index < hvcc->numOfArrays; index++)
+        if (hvcc->array[index].NAL_unit_type == nal_type)
+            break;
+
+    if (index >= hvcc->numOfArrays) {
+        uint8_t i;
+
+        ret = av_reallocp_array(&hvcc->array, index + 1, sizeof(HVCCNALUnitArray));
+        if (ret < 0)
+            return ret;
+
+        for (i = hvcc->numOfArrays; i <= index; i++)
+            memset(&hvcc->array[i], 0, sizeof(HVCCNALUnitArray));
+        hvcc->numOfArrays = index + 1;
+    }
+
+    array    = &hvcc->array[index];
+    numNalus = array->numNalus;
+
+    ret = av_reallocp_array(&array->nalUnit, numNalus + 1, sizeof(uint8_t*));
+    if (ret < 0)
+        return ret;
+
+    ret = av_reallocp_array(&array->nalUnitLength, numNalus + 1, sizeof(uint16_t));
+    if (ret < 0)
+        return ret;
+
+    array->nalUnit      [numNalus] = nal_buf;
+    array->nalUnitLength[numNalus] = nal_size;
+    array->NAL_unit_type           = nal_type;
+    array->numNalus++;
+
+    /*
+     * When the sample entry name is ‘hvc1’, the default and mandatory value of
+     * array_completeness is 1 for arrays of all types of parameter sets, and 0
+     * for all other arrays. When the sample entry name is ‘hev1’, the default
+     * value of array_completeness is 0 for all arrays.
+     */
+    if (nal_type == NAL_VPS || nal_type == NAL_SPS || nal_type == NAL_PPS)
+        array->array_completeness = ps_array_completeness;
+
+    return 0;
+}
+
+static int hvcc_add_nal_unit(uint8_t *nal_buf, uint32_t nal_size,
+                             int ps_array_completeness,
+                             HEVCDecoderConfigurationRecord *hvcc)
+{
+    int ret = 0;
+    GetBitContext gbc;
+    uint8_t nal_type;
+    uint8_t *rbsp_buf;
+    uint32_t rbsp_size;
+
+    rbsp_buf = nal_unit_extract_rbsp(nal_buf, nal_size, &rbsp_size);
+    if (!rbsp_buf) {
+        ret = AVERROR(ENOMEM);
+        goto end;
+    }
+
+    ret = init_get_bits8(&gbc, rbsp_buf, rbsp_size);
+    if (ret < 0)
+        goto end;
+
+    nal_unit_parse_header(&gbc, &nal_type);
+
+    /*
+     * Note: only 'declarative' SEI messages are allowed in
+     * hvcC. Perhaps the SEI playload type should be checked
+     * and non-declarative SEI messages discarded?
+     */
+    switch (nal_type) {
+    case NAL_VPS:
+    case NAL_SPS:
+    case NAL_PPS:
+    case NAL_SEI_PREFIX:
+    case NAL_SEI_SUFFIX:
+        ret = hvcc_array_add_nal_unit(nal_buf, nal_size, nal_type,
+                                      ps_array_completeness, hvcc);
+        if (ret < 0)
+            goto end;
+        else if (nal_type == NAL_VPS)
+            ret = hvcc_parse_vps(&gbc, hvcc);
+        else if (nal_type == NAL_SPS)
+            ret = hvcc_parse_sps(&gbc, hvcc);
+        else if (nal_type == NAL_PPS)
+            ret = hvcc_parse_pps(&gbc, hvcc);
+        if (ret < 0)
+            goto end;
+        break;
+    default:
+        ret = AVERROR_INVALIDDATA;
+        goto end;
+    }
+
+end:
+    av_free(rbsp_buf);
+    return ret;
+}
+
+static void hvcc_init(HEVCDecoderConfigurationRecord *hvcc)
+{
+    memset(hvcc, 0, sizeof(HEVCDecoderConfigurationRecord));
+    hvcc->configurationVersion = 1;
+    hvcc->lengthSizeMinusOne   = 3; // 4 bytes
+
+    /*
+     * The following fields have all their valid bits set by default,
+     * the ProfileTierLevel parsing code will unset them when needed.
+     */
+    hvcc->general_profile_compatibility_flags = 0xffffffff;
+    hvcc->general_constraint_indicator_flags  = 0xffffffffffff;
+
+    /*
+     * Initialize this field with an invalid value which can be used to detect
+     * whether we didn't see any VUI (in wich case it should be reset to zero).
+     */
+    hvcc->min_spatial_segmentation_idc = MAX_SPATIAL_SEGMENTATION + 1;
+}
+
+static void hvcc_close(HEVCDecoderConfigurationRecord *hvcc)
+{
+    uint8_t i;
+
+    for (i = 0; i < hvcc->numOfArrays; i++) {
+        hvcc->array[i].numNalus = 0;
+        av_freep(&hvcc->array[i].nalUnit);
+        av_freep(&hvcc->array[i].nalUnitLength);
+    }
+
+    hvcc->numOfArrays = 0;
+    av_freep(&hvcc->array);
+}
+
+static int hvcc_write(AVIOContext *pb, HEVCDecoderConfigurationRecord *hvcc)
+{
+    uint8_t i;
+    uint16_t j, vps_count = 0, sps_count = 0, pps_count = 0;
+
+    /*
+     * We only support writing HEVCDecoderConfigurationRecord version 1.
+     */
+    hvcc->configurationVersion = 1;
+
+    /*
+     * If min_spatial_segmentation_idc is invalid, reset to 0 (unspecified).
+     */
+    if (hvcc->min_spatial_segmentation_idc > MAX_SPATIAL_SEGMENTATION)
+        hvcc->min_spatial_segmentation_idc = 0;
+
+    /*
+     * parallelismType indicates the type of parallelism that is used to meet
+     * the restrictions imposed by min_spatial_segmentation_idc when the value
+     * of min_spatial_segmentation_idc is greater than 0.
+     */
+    if (!hvcc->min_spatial_segmentation_idc)
+        hvcc->parallelismType = 0;
+
+    /*
+     * It's unclear how to properly compute these fields, so
+     * let's always set them to values meaning 'unspecified'.
+     */
+    hvcc->avgFrameRate      = 0;
+    hvcc->constantFrameRate = 0;
+
+    av_dlog(NULL,  "configurationVersion:                %"PRIu8"\n",
+            hvcc->configurationVersion);
+    av_dlog(NULL,  "general_profile_space:               %"PRIu8"\n",
+            hvcc->general_profile_space);
+    av_dlog(NULL,  "general_tier_flag:                   %"PRIu8"\n",
+            hvcc->general_tier_flag);
+    av_dlog(NULL,  "general_profile_idc:                 %"PRIu8"\n",
+            hvcc->general_profile_idc);
+    av_dlog(NULL, "general_profile_compatibility_flags: 0x%08"PRIx32"\n",
+            hvcc->general_profile_compatibility_flags);
+    av_dlog(NULL, "general_constraint_indicator_flags:  0x%012"PRIx64"\n",
+            hvcc->general_constraint_indicator_flags);
+    av_dlog(NULL,  "general_level_idc:                   %"PRIu8"\n",
+            hvcc->general_level_idc);
+    av_dlog(NULL,  "min_spatial_segmentation_idc:        %"PRIu16"\n",
+            hvcc->min_spatial_segmentation_idc);
+    av_dlog(NULL,  "parallelismType:                     %"PRIu8"\n",
+            hvcc->parallelismType);
+    av_dlog(NULL,  "chromaFormat:                        %"PRIu8"\n",
+            hvcc->chromaFormat);
+    av_dlog(NULL,  "bitDepthLumaMinus8:                  %"PRIu8"\n",
+            hvcc->bitDepthLumaMinus8);
+    av_dlog(NULL,  "bitDepthChromaMinus8:                %"PRIu8"\n",
+            hvcc->bitDepthChromaMinus8);
+    av_dlog(NULL,  "avgFrameRate:                        %"PRIu16"\n",
+            hvcc->avgFrameRate);
+    av_dlog(NULL,  "constantFrameRate:                   %"PRIu8"\n",
+            hvcc->constantFrameRate);
+    av_dlog(NULL,  "numTemporalLayers:                   %"PRIu8"\n",
+            hvcc->numTemporalLayers);
+    av_dlog(NULL,  "temporalIdNested:                    %"PRIu8"\n",
+            hvcc->temporalIdNested);
+    av_dlog(NULL,  "lengthSizeMinusOne:                  %"PRIu8"\n",
+            hvcc->lengthSizeMinusOne);
+    av_dlog(NULL,  "numOfArrays:                         %"PRIu8"\n",
+            hvcc->numOfArrays);
+    for (i = 0; i < hvcc->numOfArrays; i++) {
+        av_dlog(NULL, "array_completeness[%"PRIu8"]:               %"PRIu8"\n",
+                i, hvcc->array[i].array_completeness);
+        av_dlog(NULL, "NAL_unit_type[%"PRIu8"]:                    %"PRIu8"\n",
+                i, hvcc->array[i].NAL_unit_type);
+        av_dlog(NULL, "numNalus[%"PRIu8"]:                         %"PRIu16"\n",
+                i, hvcc->array[i].numNalus);
+        for (j = 0; j < hvcc->array[i].numNalus; j++)
+            av_dlog(NULL,
+                    "nalUnitLength[%"PRIu8"][%"PRIu16"]:                 %"PRIu16"\n",
+                    i, j, hvcc->array[i].nalUnitLength[j]);
+    }
+
+    /*
+     * We need at least one of each: VPS, SPS and PPS.
+     */
+    for (i = 0; i < hvcc->numOfArrays; i++)
+        switch (hvcc->array[i].NAL_unit_type) {
+        case NAL_VPS:
+            vps_count += hvcc->array[i].numNalus;
+            break;
+        case NAL_SPS:
+            sps_count += hvcc->array[i].numNalus;
+            break;
+        case NAL_PPS:
+            pps_count += hvcc->array[i].numNalus;
+            break;
+        default:
+            break;
+        }
+    if (!vps_count || vps_count > MAX_VPS_COUNT ||
+        !sps_count || sps_count > MAX_SPS_COUNT ||
+        !pps_count || pps_count > MAX_PPS_COUNT)
+        return AVERROR_INVALIDDATA;
+
+    /* unsigned int(8) configurationVersion = 1; */
+    avio_w8(pb, hvcc->configurationVersion);
+
+    /*
+     * unsigned int(2) general_profile_space;
+     * unsigned int(1) general_tier_flag;
+     * unsigned int(5) general_profile_idc;
+     */
+    avio_w8(pb, hvcc->general_profile_space << 6 |
+                hvcc->general_tier_flag     << 5 |
+                hvcc->general_profile_idc);
+
+    /* unsigned int(32) general_profile_compatibility_flags; */
+    avio_wb32(pb, hvcc->general_profile_compatibility_flags);
+
+    /* unsigned int(48) general_constraint_indicator_flags; */
+    avio_wb32(pb, hvcc->general_constraint_indicator_flags >> 16);
+    avio_wb16(pb, hvcc->general_constraint_indicator_flags);
+
+    /* unsigned int(8) general_level_idc; */
+    avio_w8(pb, hvcc->general_level_idc);
+
+    /*
+     * bit(4) reserved = ‘1111’b;
+     * unsigned int(12) min_spatial_segmentation_idc;
+     */
+    avio_wb16(pb, hvcc->min_spatial_segmentation_idc | 0xf000);
+
+    /*
+     * bit(6) reserved = ‘111111’b;
+     * unsigned int(2) parallelismType;
+     */
+    avio_w8(pb, hvcc->parallelismType | 0xfc);
+
+    /*
+     * bit(6) reserved = ‘111111’b;
+     * unsigned int(2) chromaFormat;
+     */
+    avio_w8(pb, hvcc->chromaFormat | 0xfc);
+
+    /*
+     * bit(5) reserved = ‘11111’b;
+     * unsigned int(3) bitDepthLumaMinus8;
+     */
+    avio_w8(pb, hvcc->bitDepthLumaMinus8 | 0xf8);
+
+    /*
+     * bit(5) reserved = ‘11111’b;
+     * unsigned int(3) bitDepthChromaMinus8;
+     */
+    avio_w8(pb, hvcc->bitDepthChromaMinus8 | 0xf8);
+
+    /* bit(16) avgFrameRate; */
+    avio_wb16(pb, hvcc->avgFrameRate);
+
+    /*
+     * bit(2) constantFrameRate;
+     * bit(3) numTemporalLayers;
+     * bit(1) temporalIdNested;
+     * unsigned int(2) lengthSizeMinusOne;
+     */
+    avio_w8(pb, hvcc->constantFrameRate << 6 |
+                hvcc->numTemporalLayers << 3 |
+                hvcc->temporalIdNested  << 2 |
+                hvcc->lengthSizeMinusOne);
+
+    /* unsigned int(8) numOfArrays; */
+    avio_w8(pb, hvcc->numOfArrays);
+
+    for (i = 0; i < hvcc->numOfArrays; i++) {
+        /*
+         * bit(1) array_completeness;
+         * unsigned int(1) reserved = 0;
+         * unsigned int(6) NAL_unit_type;
+         */
+        avio_w8(pb, hvcc->array[i].array_completeness << 7 |
+                    hvcc->array[i].NAL_unit_type & 0x3f);
+
+        /* unsigned int(16) numNalus; */
+        avio_wb16(pb, hvcc->array[i].numNalus);
+
+        for (j = 0; j < hvcc->array[i].numNalus; j++) {
+            /* unsigned int(16) nalUnitLength; */
+            avio_wb16(pb, hvcc->array[i].nalUnitLength[j]);
+
+            /* bit(8*nalUnitLength) nalUnit; */
+            avio_write(pb, hvcc->array[i].nalUnit[j],
+                       hvcc->array[i].nalUnitLength[j]);
+        }
+    }
+
+    return 0;
+}
+
+int ff_hevc_annexb2mp4(AVIOContext *pb, const uint8_t *buf_in,
+                       int size, int filter_ps, int *ps_count)
+{
+    int num_ps = 0, ret = 0;
+    uint8_t *buf, *end, *start = NULL;
+
+    if (!filter_ps) {
+        ret = ff_avc_parse_nal_units(pb, buf_in, size);
+        goto end;
+    }
+
+    ret = ff_avc_parse_nal_units_buf(buf_in, &start, &size);
+    if (ret < 0)
+        goto end;
+
+    ret = 0;
+    buf = start;
+    end = start + size;
+
+    while (end - buf > 4) {
+        uint32_t len = FFMIN(AV_RB32(buf), end - buf - 4);
+        uint8_t type = (buf[4] >> 1) & 0x3f;
+
+        buf += 4;
+
+        switch (type) {
+        case NAL_VPS:
+        case NAL_SPS:
+        case NAL_PPS:
+            num_ps++;
+            break;
+        default:
+            ret += 4 + len;
+            avio_wb32(pb, len);
+            avio_write(pb, buf, len);
+            break;
+        }
+
+        buf += len;
+    }
+
+end:
+    av_free(start);
+    if (ps_count)
+        *ps_count = num_ps;
+    return ret;
+}
+
+int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out,
+                           int *size, int filter_ps, int *ps_count)
+{
+    AVIOContext *pb;
+    int ret;
+
+    ret = avio_open_dyn_buf(&pb);
+    if (ret < 0)
+        return ret;
+
+    ret   = ff_hevc_annexb2mp4(pb, buf_in, *size, filter_ps, ps_count);
+    *size = avio_close_dyn_buf(pb, buf_out);
+
+    return ret;
+}
+
+int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data,
+                       int size, int ps_array_completeness)
+{
+    int ret = 0;
+    uint8_t *buf, *end, *start = NULL;
+    HEVCDecoderConfigurationRecord hvcc;
+
+    hvcc_init(&hvcc);
+
+    if (size < 6) {
+        /* We can't write a valid hvcC from the provided data */
+        ret = AVERROR_INVALIDDATA;
+        goto end;
+    } else if (*data == 1) {
+        /* Data is already hvcC-formatted */
+        avio_write(pb, data, size);
+        goto end;
+    } else if (!(AV_RB24(data) == 1 || AV_RB32(data) == 1)) {
+        /* Not a valid Annex B start code prefix */
+        ret = AVERROR_INVALIDDATA;
+        goto end;
+    }
+
+    ret = ff_avc_parse_nal_units_buf(data, &start, &size);
+    if (ret < 0)
+        goto end;
+
+    buf = start;
+    end = start + size;
+
+    while (end - buf > 4) {
+        uint32_t len = FFMIN(AV_RB32(buf), end - buf - 4);
+        uint8_t type = (buf[4] >> 1) & 0x3f;
+
+        buf += 4;
+
+        switch (type) {
+        case NAL_VPS:
+        case NAL_SPS:
+        case NAL_PPS:
+        case NAL_SEI_PREFIX:
+        case NAL_SEI_SUFFIX:
+            ret = hvcc_add_nal_unit(buf, len, ps_array_completeness, &hvcc);
+            if (ret < 0)
+                goto end;
+            break;
+        default:
+            break;
+        }
+
+        buf += len;
+    }
+
+    ret = hvcc_write(pb, &hvcc);
+
+end:
+    hvcc_close(&hvcc);
+    av_free(start);
+    return ret;
+}
diff --git a/deps/libav/libavformat/hevc.h b/deps/libav/libavformat/hevc.h
new file mode 100644
index 0000000..03c43bd
--- /dev/null
+++ b/deps/libav/libavformat/hevc.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2014 Tim Walker <tdskywalker at gmail.com>
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file
+ * internal header for HEVC (de)muxer utilities
+ */
+
+#ifndef AVFORMAT_HEVC_H
+#define AVFORMAT_HEVC_H
+
+#include <stdint.h>
+#include "avio.h"
+
+/**
+ * Writes Annex B formatted HEVC NAL units to the provided AVIOContext.
+ *
+ * The NAL units are converted to an MP4-compatible format (start code prefixes
+ * are replaced by 4-byte size fields, as per ISO/IEC 14496-15).
+ *
+ * If filter_ps is non-zero, any HEVC parameter sets found in the input will be
+ * discarded, and *ps_count will be set to the number of discarded PS NAL units.
+ *
+ * @param pb address of the AVIOContext where the data shall be written
+ * @param buf_in address of the buffer holding the input data
+ * @param size size (in bytes) of the input buffer
+ * @param filter_ps whether to write parameter set NAL units to the output (0)
+ *        or to discard them (non-zero)
+ * @param ps_count address of the variable where the number of discarded
+ *        parameter set NAL units shall be written, may be NULL
+ * @return the amount (in bytes) of data written in case of success, a negative
+ *         value corresponding to an AVERROR code in case of failure
+ */
+int ff_hevc_annexb2mp4(AVIOContext *pb, const uint8_t *buf_in,
+                       int size, int filter_ps, int *ps_count);
+
+/**
+ * Writes Annex B formatted HEVC NAL units to a data buffer.
+ *
+ * The NAL units are converted to an MP4-compatible format (start code prefixes
+ * are replaced by 4-byte size fields, as per ISO/IEC 14496-15).
+ *
+ * If filter_ps is non-zero, any HEVC parameter sets found in the input will be
+ * discarded, and *ps_count will be set to the number of discarded PS NAL units.
+ *
+ * On output, *size holds the size (in bytes) of the output data buffer.
+ *
+ * @param buf_in address of the buffer holding the input data
+ * @param size address of the variable holding the size (in bytes) of the input
+ *        buffer (on input) and of the output buffer (on output)
+ * @param buf_out address of the variable holding the address of the output
+ *        buffer
+ * @param filter_ps whether to write parameter set NAL units to the output (0)
+ *        or to discard them (non-zero)
+ * @param ps_count address of the variable where the number of discarded
+ *        parameter set NAL units shall be written, may be NULL
+ * @return the amount (in bytes) of data written in case of success, a negative
+ *         value corresponding to an AVERROR code in case of failure
+ */
+int ff_hevc_annexb2mp4_buf(const uint8_t *buf_in, uint8_t **buf_out,
+                           int *size, int filter_ps, int *ps_count);
+
+/**
+ * Writes HEVC extradata (parameter sets, declarative SEI NAL units) to the
+ * provided AVIOContext.
+ *
+ * If the extradata is Annex B format, it gets converted to hvcC format before
+ * writing.
+ *
+ * @param pb address of the AVIOContext where the hvcC shall be written
+ * @param data address of the buffer holding the data needed to write the hvcC
+ * @param size size (in bytes) of the data buffer
+ * @param ps_array_completeness whether all parameter sets are in the hvcC (1)
+ *        or there may be additional parameter sets in the bitstream (0)
+ * @return 0 in case of success, a negative value corresponding to an AVERROR
+ *         code in case of failure
+ */
+int ff_isom_write_hvcc(AVIOContext *pb, const uint8_t *data,
+                       int size, int ps_array_completeness);
+
+#endif /* AVFORMAT_HEVC_H */
diff --git a/deps/libav/libavformat/hnm.c b/deps/libav/libavformat/hnm.c
index ee34a14..54ac6c2 100644
--- a/deps/libav/libavformat/hnm.c
+++ b/deps/libav/libavformat/hnm.c
@@ -20,6 +20,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <inttypes.h>
+
 #include "libavutil/intreadwrite.h"
 #include "avformat.h"
 #include "internal.h"
@@ -149,8 +151,9 @@ static int hnm_read_packet(AVFormatContext *s, AVPacket *pkt)
     avio_skip(pb, 2);
 
     if (chunk_size > hnm->superchunk_remaining) {
-        av_log(s, AV_LOG_ERROR, "invalid chunk size: %u, offset: %u\n",
-               chunk_size, (int) avio_tell(pb));
+        av_log(s, AV_LOG_ERROR,
+               "invalid chunk size: %"PRIu32", offset: %"PRId64"\n",
+               chunk_size, avio_tell(pb));
         avio_skip(pb, hnm->superchunk_remaining - 8);
         hnm->superchunk_remaining = 0;
     }
@@ -172,8 +175,8 @@ static int hnm_read_packet(AVFormatContext *s, AVPacket *pkt)
         break;
 
     default:
-        av_log(s, AV_LOG_WARNING, "unknown chunk found: %d, offset: %d\n",
-               chunk_id, (int) avio_tell(pb));
+        av_log(s, AV_LOG_WARNING, "unknown chunk found: %"PRIu16", offset: %"PRId64"\n",
+               chunk_id, avio_tell(pb));
         avio_skip(pb, chunk_size - 8);
         hnm->superchunk_remaining -= chunk_size;
         break;
diff --git a/deps/libav/libavformat/http.c b/deps/libav/libavformat/http.c
index 96f56f8..948930a 100644
--- a/deps/libav/libavformat/http.c
+++ b/deps/libav/libavformat/http.c
@@ -49,19 +49,35 @@ typedef struct {
     unsigned char buffer[BUFFER_SIZE], *buf_ptr, *buf_end;
     int line_count;
     int http_code;
-    int64_t chunksize;      /**< Used if "Transfer-Encoding: chunked" otherwise -1. */
-    int64_t off, filesize;
+    /* Used if "Transfer-Encoding: chunked" otherwise -1. */
+    int64_t chunksize;
+    int64_t off, end_off, filesize;
     char *location;
     HTTPAuthState auth_state;
     HTTPAuthState proxy_auth_state;
     char *headers;
-    int willclose;          /**< Set if the server correctly handles Connection: close and will close the connection after feeding us the content. */
+    char *mime_type;
+    char *user_agent;
+    char *content_type;
+    /* Set if the server correctly handles Connection: close and will close
+     * the connection after feeding us the content. */
+    int willclose;
     int chunked_post;
-    int end_chunked_post;   /**< A flag which indicates if the end of chunked encoding has been sent. */
-    int end_header;         /**< A flag which indicates we have finished to read POST reply. */
-    int multiple_requests;  /**< A flag which indicates if we use persistent connections. */
+    /* A flag which indicates if the end of chunked encoding has been sent. */
+    int end_chunked_post;
+    /* A flag which indicates we have finished to read POST reply. */
+    int end_header;
+    /* A flag which indicates if we use persistent connections. */
+    int multiple_requests;
     uint8_t *post_data;
     int post_datalen;
+    int icy;
+    /* how much data was read since the last ICY metadata packet */
+    int icy_data_read;
+    /* after how many bytes of read data a new metadata packet will be found */
+    int icy_metaint;
+    char *icy_metadata_headers;
+    char *icy_metadata_packet;
 #if CONFIG_ZLIB
     int compressed;
     z_stream inflate_stream;
@@ -74,16 +90,26 @@ typedef struct {
 #define OFFSET(x) offsetof(HTTPContext, x)
 #define D AV_OPT_FLAG_DECODING_PARAM
 #define E AV_OPT_FLAG_ENCODING_PARAM
+#define DEFAULT_USER_AGENT "Lavf/" AV_STRINGIFY(LIBAVFORMAT_VERSION)
 static const AVOption options[] = {
 {"chunked_post", "use chunked transfer-encoding for posts", OFFSET(chunked_post), AV_OPT_TYPE_INT, {.i64 = 1}, 0, 1, E },
-{"headers", "custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
+{"headers", "set custom HTTP headers, can override built in default headers", OFFSET(headers), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
+{"content_type", "set a specific content type for the POST messages", OFFSET(content_type), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
+{"user_agent", "override User-Agent header", OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = DEFAULT_USER_AGENT}, 0, 0, D },
+{"user-agent", "override User-Agent header, for compatibility with ffmpeg", OFFSET(user_agent), AV_OPT_TYPE_STRING, {.str = DEFAULT_USER_AGENT}, 0, 0, D },
 {"multiple_requests", "use persistent connections", OFFSET(multiple_requests), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, D|E },
-{"post_data", "custom HTTP post data", OFFSET(post_data), AV_OPT_TYPE_BINARY, .flags = D|E },
+{"post_data", "set custom HTTP post data", OFFSET(post_data), AV_OPT_TYPE_BINARY, .flags = D|E },
+{"mime_type", "export the MIME type", OFFSET(mime_type), AV_OPT_TYPE_STRING, {0}, 0, 0, AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY  },
+{"icy", "request ICY metadata", OFFSET(icy), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, D },
+{"icy_metadata_headers", "return ICY metadata headers", OFFSET(icy_metadata_headers), AV_OPT_TYPE_STRING, {0}, 0, 0, AV_OPT_FLAG_EXPORT },
+{"icy_metadata_packet", "return current ICY metadata packet", OFFSET(icy_metadata_packet), AV_OPT_TYPE_STRING, {0}, 0, 0, AV_OPT_FLAG_EXPORT },
 {"auth_type", "HTTP authentication type", OFFSET(auth_state.auth_type), AV_OPT_TYPE_INT, {.i64 = HTTP_AUTH_NONE}, HTTP_AUTH_NONE, HTTP_AUTH_BASIC, D|E, "auth_type" },
 {"none", "No auth method set, autodetect", 0, AV_OPT_TYPE_CONST, {.i64 = HTTP_AUTH_NONE}, 0, 0, D|E, "auth_type" },
 {"basic", "HTTP basic authentication", 0, AV_OPT_TYPE_CONST, {.i64 = HTTP_AUTH_BASIC}, 0, 0, D|E, "auth_type" },
 {"send_expect_100", "Force sending an Expect: 100-continue header for POST", OFFSET(send_expect_100), AV_OPT_TYPE_INT, {.i64 = 0}, 0, 1, E },
 {"location", "The actual location of the data received", OFFSET(location), AV_OPT_TYPE_STRING, { 0 }, 0, 0, D|E },
+{"offset", "initial byte offset", OFFSET(off), AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, D },
+{"end_offset", "try to limit the request to bytes preceding this offset", OFFSET(end_off), AV_OPT_TYPE_INT64, {.i64 = 0}, 0, INT64_MAX, D },
 {NULL}
 };
 #define HTTP_CLASS(flavor)\
@@ -219,6 +245,7 @@ int ff_http_do_new_request(URLContext *h, const char *uri)
     int ret;
 
     s->off = 0;
+    s->icy_data_read = 0;
     av_free(s->location);
     s->location = av_strdup(uri);
     if (!s->location)
@@ -264,7 +291,7 @@ static int http_getc(HTTPContext *s)
         if (len < 0) {
             return len;
         } else if (len == 0) {
-            return -1;
+            return AVERROR_EOF;
         } else {
             s->buf_ptr = s->buffer;
             s->buf_end = s->buffer + len;
@@ -297,11 +324,110 @@ static int http_get_line(HTTPContext *s, char *line, int line_size)
     }
 }
 
+static int check_http_code(URLContext *h, int http_code, const char *end)
+{
+    HTTPContext *s = h->priv_data;
+    /* error codes are 4xx and 5xx, but regard 401 as a success, so we
+     * don't abort until all headers have been parsed. */
+    if (http_code >= 400 && http_code < 600 &&
+        (http_code != 401 || s->auth_state.auth_type != HTTP_AUTH_NONE) &&
+        (http_code != 407 || s->proxy_auth_state.auth_type != HTTP_AUTH_NONE)) {
+        end += strspn(end, SPACE_CHARS);
+        av_log(h, AV_LOG_WARNING, "HTTP error %d %s\n", http_code, end);
+        return AVERROR(EIO);
+    }
+    return 0;
+}
+
+static int parse_location(HTTPContext *s, const char *p)
+{
+    char redirected_location[MAX_URL_SIZE], *new_loc;
+    ff_make_absolute_url(redirected_location, sizeof(redirected_location),
+                         s->location, p);
+    new_loc = av_strdup(redirected_location);
+    if (!new_loc)
+        return AVERROR(ENOMEM);
+    av_free(s->location);
+    s->location = new_loc;
+    return 0;
+}
+
+/* "bytes $from-$to/$document_size" */
+static void parse_content_range(URLContext *h, const char *p)
+{
+    HTTPContext *s = h->priv_data;
+    const char *slash;
+
+    if (!strncmp(p, "bytes ", 6)) {
+        p += 6;
+        s->off = strtoll(p, NULL, 10);
+        if ((slash = strchr(p, '/')) && strlen(slash) > 0)
+            s->filesize = strtoll(slash+1, NULL, 10);
+    }
+    h->is_streamed = 0; /* we _can_ in fact seek */
+}
+
+static int parse_content_encoding(URLContext *h, const char *p)
+{
+    HTTPContext *s = h->priv_data;
+
+    if (!av_strncasecmp(p, "gzip", 4) ||
+        !av_strncasecmp(p, "deflate", 7)) {
+#if CONFIG_ZLIB
+        s->compressed = 1;
+        inflateEnd(&s->inflate_stream);
+        if (inflateInit2(&s->inflate_stream, 32 + 15) != Z_OK) {
+            av_log(h, AV_LOG_WARNING, "Error during zlib initialisation: %s\n",
+                   s->inflate_stream.msg);
+            return AVERROR(ENOSYS);
+        }
+        if (zlibCompileFlags() & (1 << 17)) {
+            av_log(h, AV_LOG_WARNING,
+                   "Your zlib was compiled without gzip support.\n");
+            return AVERROR(ENOSYS);
+        }
+#else
+        av_log(h, AV_LOG_WARNING,
+               "Compressed (%s) content, need zlib with gzip support\n", p);
+        return AVERROR(ENOSYS);
+#endif
+    } else if (!av_strncasecmp(p, "identity", 8)) {
+        // The normal, no-encoding case (although servers shouldn't include
+        // the header at all if this is the case).
+    } else {
+        av_log(h, AV_LOG_WARNING, "Unknown content coding: %s\n", p);
+        return AVERROR(ENOSYS);
+    }
+    return 0;
+}
+
+// Concat all Icy- header lines
+static int parse_icy(HTTPContext *s, const char *tag, const char *p)
+{
+    int len = 4 + strlen(p) + strlen(tag);
+    int is_first = !s->icy_metadata_headers;
+    int ret;
+
+    if (s->icy_metadata_headers)
+        len += strlen(s->icy_metadata_headers);
+
+    if ((ret = av_reallocp(&s->icy_metadata_headers, len)) < 0)
+        return ret;
+
+    if (is_first)
+        *s->icy_metadata_headers = '\0';
+
+    av_strlcatf(s->icy_metadata_headers, len, "%s: %s\n", tag, p);
+
+    return 0;
+}
+
 static int process_line(URLContext *h, char *line, int line_count,
                         int *new_location)
 {
     HTTPContext *s = h->priv_data;
     char *tag, *p, *end;
+    int ret;
 
     /* end of header */
     if (line[0] == '\0') {
@@ -319,16 +445,8 @@ static int process_line(URLContext *h, char *line, int line_count,
 
         av_dlog(NULL, "http_code=%d\n", s->http_code);
 
-        /* error codes are 4xx and 5xx, but regard 401 as a success, so we
-         * don't abort until all headers have been parsed. */
-        if (s->http_code >= 400 && s->http_code < 600 && (s->http_code != 401
-            || s->auth_state.auth_type != HTTP_AUTH_NONE) &&
-            (s->http_code != 407 || s->proxy_auth_state.auth_type != HTTP_AUTH_NONE)) {
-            end += strspn(end, SPACE_CHARS);
-            av_log(h, AV_LOG_WARNING, "HTTP error %d %s\n",
-                   s->http_code, end);
-            return -1;
-        }
+        if ((ret = check_http_code(h, s->http_code, end)) < 0)
+            return ret;
     } else {
         while (*p != '\0' && *p != ':')
             p++;
@@ -341,66 +459,40 @@ static int process_line(URLContext *h, char *line, int line_count,
         while (av_isspace(*p))
             p++;
         if (!av_strcasecmp(tag, "Location")) {
-            char redirected_location[MAX_URL_SIZE], *new_loc;
-            ff_make_absolute_url(redirected_location, sizeof(redirected_location),
-                                 s->location, p);
-            new_loc = av_strdup(redirected_location);
-            if (!new_loc)
-                return AVERROR(ENOMEM);
-            av_free(s->location);
-            s->location = new_loc;
+            if ((ret = parse_location(s, p)) < 0)
+                return ret;
             *new_location = 1;
-        } else if (!av_strcasecmp (tag, "Content-Length") && s->filesize == -1) {
+        } else if (!av_strcasecmp(tag, "Content-Length") && s->filesize == -1) {
             s->filesize = strtoll(p, NULL, 10);
-        } else if (!av_strcasecmp (tag, "Content-Range")) {
-            /* "bytes $from-$to/$document_size" */
-            const char *slash;
-            if (!strncmp (p, "bytes ", 6)) {
-                p += 6;
-                s->off = strtoll(p, NULL, 10);
-                if ((slash = strchr(p, '/')) && strlen(slash) > 0)
-                    s->filesize = strtoll(slash+1, NULL, 10);
-            }
-            h->is_streamed = 0; /* we _can_ in fact seek */
-        } else if (!av_strcasecmp(tag, "Accept-Ranges") && !strncmp(p, "bytes", 5)) {
+        } else if (!av_strcasecmp(tag, "Content-Range")) {
+            parse_content_range(h, p);
+        } else if (!av_strcasecmp(tag, "Accept-Ranges") &&
+                   !strncmp(p, "bytes", 5)) {
             h->is_streamed = 0;
-        } else if (!av_strcasecmp (tag, "Transfer-Encoding") && !av_strncasecmp(p, "chunked", 7)) {
+        } else if (!av_strcasecmp(tag, "Transfer-Encoding") &&
+                   !av_strncasecmp(p, "chunked", 7)) {
             s->filesize = -1;
             s->chunksize = 0;
-        } else if (!av_strcasecmp (tag, "WWW-Authenticate")) {
+        } else if (!av_strcasecmp(tag, "WWW-Authenticate")) {
             ff_http_auth_handle_header(&s->auth_state, tag, p);
-        } else if (!av_strcasecmp (tag, "Authentication-Info")) {
+        } else if (!av_strcasecmp(tag, "Authentication-Info")) {
             ff_http_auth_handle_header(&s->auth_state, tag, p);
-        } else if (!av_strcasecmp (tag, "Proxy-Authenticate")) {
+        } else if (!av_strcasecmp(tag, "Proxy-Authenticate")) {
             ff_http_auth_handle_header(&s->proxy_auth_state, tag, p);
-        } else if (!av_strcasecmp (tag, "Connection")) {
+        } else if (!av_strcasecmp(tag, "Connection")) {
             if (!strcmp(p, "close"))
                 s->willclose = 1;
-        } else if (!av_strcasecmp (tag, "Content-Encoding")) {
-            if (!av_strncasecmp(p, "gzip", 4) || !av_strncasecmp(p, "deflate", 7)) {
-#if CONFIG_ZLIB
-                s->compressed = 1;
-                inflateEnd(&s->inflate_stream);
-                if (inflateInit2(&s->inflate_stream, 32 + 15) != Z_OK) {
-                    av_log(h, AV_LOG_WARNING, "Error during zlib initialisation: %s\n",
-                           s->inflate_stream.msg);
-                    return AVERROR(ENOSYS);
-                }
-                if (zlibCompileFlags() & (1 << 17)) {
-                    av_log(h, AV_LOG_WARNING, "Your zlib was compiled without gzip support.\n");
-                    return AVERROR(ENOSYS);
-                }
-#else
-                av_log(h, AV_LOG_WARNING, "Compressed (%s) content, need zlib with gzip support\n", p);
-                return AVERROR(ENOSYS);
-#endif
-            } else if (!av_strncasecmp(p, "identity", 8)) {
-                // The normal, no-encoding case (although servers shouldn't include
-                // the header at all if this is the case).
-            } else {
-                av_log(h, AV_LOG_WARNING, "Unknown content coding: %s\n", p);
-                return AVERROR(ENOSYS);
-            }
+        } else if (!av_strcasecmp (tag, "Content-Type")) {
+            av_free(s->mime_type);
+            s->mime_type = av_strdup(p);
+        } else if (!av_strcasecmp (tag, "Icy-MetaInt")) {
+            s->icy_metaint = strtoll(p, NULL, 10);
+        } else if (!av_strncasecmp(tag, "Icy-", 4)) {
+            if ((ret = parse_icy(s, tag, p)) < 0)
+                return ret;
+        } else if (!av_strcasecmp(tag, "Content-Encoding")) {
+            if ((ret = parse_content_encoding(h, p)) < 0)
+                return ret;
         }
     }
     return 1;
@@ -482,14 +574,23 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
 
     /* set default headers if needed */
     if (!has_header(s->headers, "\r\nUser-Agent: "))
-       len += av_strlcatf(headers + len, sizeof(headers) - len,
-                          "User-Agent: %s\r\n", LIBAVFORMAT_IDENT);
+        len += av_strlcatf(headers + len, sizeof(headers) - len,
+                           "User-Agent: %s\r\n", s->user_agent);
     if (!has_header(s->headers, "\r\nAccept: "))
         len += av_strlcpy(headers + len, "Accept: */*\r\n",
                           sizeof(headers) - len);
-    if (!has_header(s->headers, "\r\nRange: ") && !post)
+    // Note: we send this on purpose even when s->off is 0 when we're probing,
+    // since it allows us to detect more reliably if a (non-conforming)
+    // server supports seeking by analysing the reply headers.
+    if (!has_header(s->headers, "\r\nRange: ") && !post) {
         len += av_strlcatf(headers + len, sizeof(headers) - len,
-                           "Range: bytes=%"PRId64"-\r\n", s->off);
+                           "Range: bytes=%"PRId64"-", s->off);
+        if (s->end_off)
+            len += av_strlcatf(headers + len, sizeof(headers) - len,
+                               "%"PRId64, s->end_off - 1);
+        len += av_strlcpy(headers + len, "\r\n",
+                          sizeof(headers) - len);
+    }
     if (send_expect_100 && !has_header(s->headers, "\r\nExpect: "))
         len += av_strlcatf(headers + len, sizeof(headers) - len,
                            "Expect: 100-continue\r\n");
@@ -511,6 +612,14 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
         len += av_strlcatf(headers + len, sizeof(headers) - len,
                            "Content-Length: %d\r\n", s->post_datalen);
 
+    if (!has_header(s->headers, "\r\nContent-Type: ") && s->content_type)
+        len += av_strlcatf(headers + len, sizeof(headers) - len,
+                           "Content-Type: %s\r\n", s->content_type);
+    if (!has_header(s->headers, "\r\nIcy-MetaData: ") && s->icy) {
+        len += av_strlcatf(headers + len, sizeof(headers) - len,
+                           "Icy-MetaData: %d\r\n", 1);
+    }
+
     /* now add in custom headers */
     if (s->headers)
         av_strlcpy(headers + len, s->headers, sizeof(headers) - len);
@@ -543,6 +652,7 @@ static int http_connect(URLContext *h, const char *path, const char *local_path,
     s->buf_end = s->buffer;
     s->line_count = 0;
     s->off = 0;
+    s->icy_data_read = 0;
     s->filesize = -1;
     s->willclose = 0;
     s->end_chunked_post = 0;
@@ -620,7 +730,7 @@ static int http_buf_read_compressed(URLContext *h, uint8_t *buf, int size)
 }
 #endif
 
-static int http_read(URLContext *h, uint8_t *buf, int size)
+static int http_read_stream(URLContext *h, uint8_t *buf, int size)
 {
     HTTPContext *s = h->priv_data;
     int err, new_location;
@@ -662,6 +772,70 @@ static int http_read(URLContext *h, uint8_t *buf, int size)
     return http_buf_read(h, buf, size);
 }
 
+static int http_read_stream_all(URLContext *h, uint8_t *buf, int size)
+{
+    int pos = 0;
+    while (pos < size) {
+        int len = http_read_stream(h, buf + pos, size - pos);
+        if (len < 0)
+            return len;
+        pos += len;
+    }
+    return pos;
+}
+
+static int store_icy(URLContext *h, int size)
+{
+    HTTPContext *s = h->priv_data;
+    /* until next metadata packet */
+    int remaining = s->icy_metaint - s->icy_data_read;
+
+    if (remaining < 0)
+        return AVERROR_INVALIDDATA;
+
+    if (!remaining) {
+        // The metadata packet is variable sized. It has a 1 byte header
+        // which sets the length of the packet (divided by 16). If it's 0,
+        // the metadata doesn't change. After the packet, icy_metaint bytes
+        // of normal data follow.
+        uint8_t ch;
+        int len = http_read_stream_all(h, &ch, 1);
+        if (len < 0)
+            return len;
+        if (ch > 0) {
+            char data[255 * 16 + 1];
+            int ret;
+            len = ch * 16;
+            ret = http_read_stream_all(h, data, len);
+            if (ret < 0)
+                return ret;
+            data[len + 1] = 0;
+            if ((ret = av_opt_set(s, "icy_metadata_packet", data, 0)) < 0)
+                return ret;
+        }
+        s->icy_data_read = 0;
+        remaining = s->icy_metaint;
+    }
+
+    return FFMIN(size, remaining);
+}
+
+static int http_read(URLContext *h, uint8_t *buf, int size)
+{
+    HTTPContext *s = h->priv_data;
+
+    if (s->icy_metaint > 0) {
+        size = store_icy(h, size);
+        if (size < 0)
+            return size;
+    }
+
+    size = http_read_stream(h, buf, size);
+    if (size > 0)
+        s->icy_data_read += size;
+    return size;
+}
+
 /* used only when posting data */
 static int http_write(URLContext *h, const uint8_t *buf, int size)
 {
@@ -732,13 +906,16 @@ static int64_t http_seek(URLContext *h, int64_t off, int whence)
     URLContext *old_hd = s->hd;
     int64_t old_off = s->off;
     uint8_t old_buf[BUFFER_SIZE];
-    int old_buf_size;
+    int old_buf_size, ret;
     AVDictionary *options = NULL;
 
     if (whence == AVSEEK_SIZE)
         return s->filesize;
+    else if ((whence == SEEK_CUR && off == 0) ||
+             (whence == SEEK_SET && off == s->off))
+        return s->off;
     else if ((s->filesize == -1 && whence == SEEK_END) || h->is_streamed)
-        return -1;
+        return AVERROR(ENOSYS);
 
     /* we save the old context in case the seek fails */
     old_buf_size = s->buf_end - s->buf_ptr;
@@ -752,14 +929,14 @@ static int64_t http_seek(URLContext *h, int64_t off, int whence)
 
     /* if it fails, continue on old connection */
     av_dict_copy(&options, s->chained_options, 0);
-    if (http_open_cnx(h, &options) < 0) {
+    if ((ret = http_open_cnx(h, &options)) < 0) {
         av_dict_free(&options);
         memcpy(s->buffer, old_buf, old_buf_size);
         s->buf_ptr = s->buffer;
         s->buf_end = s->buffer + old_buf_size;
         s->hd = old_hd;
         s->off = old_off;
-        return -1;
+        return ret;
     }
     av_dict_free(&options);
     ffurl_close(old_hd);
diff --git a/deps/libav/libavformat/iff.c b/deps/libav/libavformat/iff.c
index 79f5f16..6be0fb7 100644
--- a/deps/libav/libavformat/iff.c
+++ b/deps/libav/libavformat/iff.c
@@ -29,6 +29,8 @@
  * http://wiki.multimedia.cx/index.php?title=IFF
  */
 
+#include <inttypes.h>
+
 #include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/dict.h"
@@ -167,7 +169,7 @@ static int iff_read_header(AVFormatContext *s)
 
         case ID_CMAP:
             if (data_size < 3 || data_size > 768 || data_size % 3) {
-                 av_log(s, AV_LOG_ERROR, "Invalid CMAP chunk size %d\n",
+                 av_log(s, AV_LOG_ERROR, "Invalid CMAP chunk size %"PRIu32"\n",
                         data_size);
                  return AVERROR_INVALIDDATA;
             }
diff --git a/deps/libav/libavformat/isom.c b/deps/libav/libavformat/isom.c
index 9b32b7d..b3f3f95 100644
--- a/deps/libav/libavformat/isom.c
+++ b/deps/libav/libavformat/isom.c
@@ -33,6 +33,7 @@ const AVCodecTag ff_mp4_obj_type[] = {
     { AV_CODEC_ID_MOV_TEXT    , 0x08 },
     { AV_CODEC_ID_MPEG4       , 0x20 },
     { AV_CODEC_ID_H264        , 0x21 },
+    { AV_CODEC_ID_HEVC        , 0x23 },
     { AV_CODEC_ID_AAC         , 0x40 },
     { AV_CODEC_ID_MP4ALS      , 0x40 }, /* 14496-3 ALS */
     { AV_CODEC_ID_MPEG2VIDEO  , 0x61 }, /* MPEG2 Main */
@@ -81,7 +82,10 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
     { AV_CODEC_ID_RAWVIDEO, MKTAG('A', 'B', 'G', 'R') },
     { AV_CODEC_ID_RAWVIDEO, MKTAG('b', '1', '6', 'g') },
     { AV_CODEC_ID_RAWVIDEO, MKTAG('b', '4', '8', 'r') },
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('N', 'O', '1', '6') },
     { AV_CODEC_ID_RAWVIDEO, MKTAG('D', 'V', 'O', 'O') }, /* Digital Voodoo SD 8 Bit */
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('R', '4', '2', '0') }, /* Radius DV YUV PAL */
+    { AV_CODEC_ID_RAWVIDEO, MKTAG('R', '4', '1', '1') }, /* Radius DV YUV NTSC */
 
     { AV_CODEC_ID_R10K,   MKTAG('R', '1', '0', 'k') }, /* UNCOMPRESSED 10BIT RGB */
     { AV_CODEC_ID_R10K,   MKTAG('R', '1', '0', 'g') }, /* UNCOMPRESSED 10BIT RGB */
@@ -136,8 +140,8 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
 
     { AV_CODEC_ID_RAWVIDEO, MKTAG('W', 'R', 'A', 'W') },
 
-    { AV_CODEC_ID_HEVC, MKTAG('h', 'v', 'c', '1') }, /* HEVC/H.265 which indicates parameter sets shall not be in ES */
     { AV_CODEC_ID_HEVC, MKTAG('h', 'e', 'v', '1') }, /* HEVC/H.265 which indicates parameter sets may be in ES */
+    { AV_CODEC_ID_HEVC, MKTAG('h', 'v', 'c', '1') }, /* HEVC/H.265 which indicates parameter sets shall not be in ES */
 
     { AV_CODEC_ID_H264, MKTAG('a', 'v', 'c', '1') }, /* AVC-1/H.264 */
     { AV_CODEC_ID_H264, MKTAG('a', 'i', '5', 'p') }, /* AVC-Intra  50M 720p24/30/60 */
@@ -153,6 +157,7 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
     { AV_CODEC_ID_H264, MKTAG('a', 'i', '1', '5') }, /* AVC-Intra 100M 1080i50 */
     { AV_CODEC_ID_H264, MKTAG('a', 'i', '1', '6') }, /* AVC-Intra 100M 1080i60 */
     { AV_CODEC_ID_H264, MKTAG('A', 'V', 'i', 'n') }, /* AVC-Intra with implicit SPS/PPS */
+    { AV_CODEC_ID_H264, MKTAG('a', 'i', 'v', 'x') }, /* XAVC 4:2:2 10bit */
 
     { AV_CODEC_ID_MPEG1VIDEO, MKTAG('m', '1', 'v', '1') }, /* Apple MPEG-1 Camcorder */
     { AV_CODEC_ID_MPEG1VIDEO, MKTAG('m', 'p', 'e', 'g') }, /* MPEG */
@@ -173,6 +178,7 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
     { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '4', 'p') }, /* MPEG2 IMX PAL 625/50 40mb/s produced by FCP */
     { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '3', 'n') }, /* MPEG2 IMX NTSC 525/60 30mb/s produced by FCP */
     { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'x', '3', 'p') }, /* MPEG2 IMX PAL 625/50 30mb/s produced by FCP */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', '1') }, /* XDCAM HD422 720p30 CBR */
     { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', '4') }, /* XDCAM HD422 720p24 CBR */
     { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', '5') }, /* XDCAM HD422 720p25 CBR */
     { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', '5', '9') }, /* XDCAM HD422 720p60 CBR */
@@ -200,6 +206,7 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
     { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'h', 'd') }, /* XDCAM HD 540p */
     { AV_CODEC_ID_MPEG2VIDEO, MKTAG('x', 'd', 'h', '2') }, /* XDCAM HD422 540p */
     { AV_CODEC_ID_MPEG2VIDEO, MKTAG('A', 'V', 'm', 'p') }, /* AVID IMX PAL */
+    { AV_CODEC_ID_MPEG2VIDEO, MKTAG('m', 'p', '2', 'v') }, /* FCP5 */
 
     { AV_CODEC_ID_JPEG2000, MKTAG('m', 'j', 'p', '2') }, /* JPEG 2000 produced by FCP */
 
@@ -207,6 +214,7 @@ const AVCodecTag ff_codec_movvideo_tags[] = {
     { AV_CODEC_ID_TIFF,  MKTAG('t', 'i', 'f', 'f') }, /* TIFF embedded in MOV */
     { AV_CODEC_ID_GIF,   MKTAG('g', 'i', 'f', ' ') }, /* embedded gif files as frames (usually one "click to play movie" frame) */
     { AV_CODEC_ID_PNG,   MKTAG('p', 'n', 'g', ' ') },
+    { AV_CODEC_ID_PNG,   MKTAG('M', 'N', 'G', ' ') },
 
     { AV_CODEC_ID_VC1, MKTAG('v', 'c', '-', '1') }, /* SMPTE RP 2025 */
     { AV_CODEC_ID_CAVS, MKTAG('a', 'v', 's', '2') },
@@ -263,6 +271,7 @@ const AVCodecTag ff_codec_movaudio_tags[] = {
     { AV_CODEC_ID_PCM_MULAW,       MKTAG('u', 'l', 'a', 'w') },
     { AV_CODEC_ID_PCM_S16BE,       MKTAG('t', 'w', 'o', 's') },
     { AV_CODEC_ID_PCM_S16LE,       MKTAG('s', 'o', 'w', 't') },
+    { AV_CODEC_ID_PCM_S16BE,       MKTAG('l', 'p', 'c', 'm') },
     { AV_CODEC_ID_PCM_S16LE,       MKTAG('l', 'p', 'c', 'm') },
     { AV_CODEC_ID_PCM_S24BE,       MKTAG('i', 'n', '2', '4') },
     { AV_CODEC_ID_PCM_S24LE,       MKTAG('i', 'n', '2', '4') },
@@ -277,6 +286,7 @@ const AVCodecTag ff_codec_movaudio_tags[] = {
     { AV_CODEC_ID_QDM2,            MKTAG('Q', 'D', 'M', '2') },
     { AV_CODEC_ID_QDMC,            MKTAG('Q', 'D', 'M', 'C') },
     { AV_CODEC_ID_SPEEX,           MKTAG('s', 'p', 'e', 'x') }, /* Flash Media Server */
+    { AV_CODEC_ID_SPEEX,           MKTAG('S', 'P', 'X', 'N') }, /* ZygoAudio (quality 10 mode) */
     { AV_CODEC_ID_WMAV2,           MKTAG('W', 'M', 'A', '2') },
     { AV_CODEC_ID_NONE, 0 },
 };
@@ -346,7 +356,7 @@ int ff_mov_lang_to_iso639(unsigned code, char to[4])
     memset(to, 0, 4);
     /* is it the mangled iso code? */
     /* see http://www.geocities.com/xhelmboyx/quicktime/formats/mp4-layout.txt */
-    if (code > 138) {
+    if (code >= 0x400 && code != 0x7fff) {
         for (i = 2; i >= 0; i--) {
             to[i] = 0x60 + (code & 0x1f);
             code >>= 5;
diff --git a/deps/libav/libavformat/jvdec.c b/deps/libav/libavformat/jvdec.c
index 006acec..84d55da 100644
--- a/deps/libav/libavformat/jvdec.c
+++ b/deps/libav/libavformat/jvdec.c
@@ -184,16 +184,22 @@ static int read_packet(AVFormatContext *s, AVPacket *pkt)
         case JV_VIDEO:
             jv->state++;
             if (jvf->video_size || jvf->palette_size) {
+                int ret;
                 int size = jvf->video_size + jvf->palette_size;
                 if (av_new_packet(pkt, size + JV_PREAMBLE_SIZE))
                     return AVERROR(ENOMEM);
 
                 AV_WL32(pkt->data, jvf->video_size);
                 pkt->data[4] = jvf->video_type;
-                if (avio_read(pb, pkt->data + JV_PREAMBLE_SIZE, size) < 0)
-                    return AVERROR(EIO);
-
-                pkt->size         = size + JV_PREAMBLE_SIZE;
+                ret = avio_read(pb, pkt->data + JV_PREAMBLE_SIZE, size);
+                if (ret < 0)
+                    return ret;
+                if (ret < size) {
+                    memset(pkt->data + JV_PREAMBLE_SIZE + ret, 0,
+                           FF_INPUT_BUFFER_PADDING_SIZE);
+                    pkt->flags |= AV_PKT_FLAG_CORRUPT;
+                }
+                pkt->size         = ret + JV_PREAMBLE_SIZE;
                 pkt->stream_index = 1;
                 pkt->pts          = jv->pts;
                 if (jvf->video_type != 1)
diff --git a/deps/libav/libavformat/lxfdec.c b/deps/libav/libavformat/lxfdec.c
index 859fc71..192d4b0 100644
--- a/deps/libav/libavformat/lxfdec.c
+++ b/deps/libav/libavformat/lxfdec.c
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <inttypes.h>
+
 #include "libavutil/intreadwrite.h"
 #include "libavcodec/bytestream.h"
 #include "avformat.h"
@@ -128,12 +130,12 @@ static int get_packet_header(AVFormatContext *s)
     version     = bytestream_get_le32(&p);
     header_size = bytestream_get_le32(&p);
     if (version > 1)
-        avpriv_request_sample(s, "Unknown format version %i\n", version);
+        avpriv_request_sample(s, "Unknown format version %"PRIu32"\n", version);
 
     if (header_size < (version ? 72 : 60) ||
         header_size > LXF_MAX_PACKET_HEADER_SIZE ||
         (header_size & 3)) {
-        av_log(s, AV_LOG_ERROR, "Invalid header size 0x%x\n", header_size);
+        av_log(s, AV_LOG_ERROR, "Invalid header size 0x%"PRIx32"\n", header_size);
         return AVERROR_INVALIDDATA;
     }
 
@@ -299,7 +301,8 @@ static int lxf_read_packet(AVFormatContext *s, AVPacket *pkt)
     stream = lxf->packet_type;
 
     if (stream > 1) {
-        av_log(s, AV_LOG_WARNING, "got packet with illegal stream index %u\n", stream);
+        av_log(s, AV_LOG_WARNING,
+               "got packet with illegal stream index %"PRIu32"\n", stream);
         return AVERROR(EAGAIN);
     }
 
diff --git a/deps/libav/libavformat/matroskadec.c b/deps/libav/libavformat/matroskadec.c
index bcd7d1a..d82d94c 100644
--- a/deps/libav/libavformat/matroskadec.c
+++ b/deps/libav/libavformat/matroskadec.c
@@ -28,28 +28,34 @@
  * @see specs available on the Matroska project page: http://www.matroska.org/
  */
 
+#include "config.h"
+
+#include <inttypes.h>
 #include <stdio.h>
+#if CONFIG_BZLIB
+#include <bzlib.h>
+#endif
+#if CONFIG_ZLIB
+#include <zlib.h>
+#endif
+
+#include "libavutil/avstring.h"
+#include "libavutil/dict.h"
+#include "libavutil/intfloat.h"
+#include "libavutil/intreadwrite.h"
+#include "libavutil/lzo.h"
+
+#include "libavcodec/bytestream.h"
+#include "libavcodec/mpeg4audio.h"
+
 #include "avformat.h"
-#include "internal.h"
 #include "avio_internal.h"
+#include "internal.h"
+#include "isom.h"
+#include "matroska.h"
 /* For ff_codec_get_id(). */
 #include "riff.h"
-#include "isom.h"
 #include "rmsipr.h"
-#include "matroska.h"
-#include "libavcodec/bytestream.h"
-#include "libavcodec/mpeg4audio.h"
-#include "libavutil/intfloat.h"
-#include "libavutil/intreadwrite.h"
-#include "libavutil/avstring.h"
-#include "libavutil/lzo.h"
-#include "libavutil/dict.h"
-#if CONFIG_ZLIB
-#include <zlib.h>
-#endif
-#if CONFIG_BZLIB
-#include <bzlib.h>
-#endif
 
 typedef enum {
     EBML_NONE,
@@ -161,7 +167,7 @@ typedef struct {
     EbmlBin bin;
 
     AVStream *stream;
-} MatroskaAttachement;
+} MatroskaAttachment;
 
 typedef struct {
     uint64_t start;
@@ -270,134 +276,134 @@ typedef struct {
 } MatroskaBlock;
 
 static EbmlSyntax ebml_header[] = {
-    { EBML_ID_EBMLREADVERSION,        EBML_UINT, 0, offsetof(Ebml,version), {.u=EBML_VERSION} },
-    { EBML_ID_EBMLMAXSIZELENGTH,      EBML_UINT, 0, offsetof(Ebml,max_size), {.u=8} },
-    { EBML_ID_EBMLMAXIDLENGTH,        EBML_UINT, 0, offsetof(Ebml,id_length), {.u=4} },
-    { EBML_ID_DOCTYPE,                EBML_STR,  0, offsetof(Ebml,doctype), {.s="(none)"} },
-    { EBML_ID_DOCTYPEREADVERSION,     EBML_UINT, 0, offsetof(Ebml,doctype_version), {.u=1} },
-    { EBML_ID_EBMLVERSION,            EBML_NONE },
-    { EBML_ID_DOCTYPEVERSION,         EBML_NONE },
+    { EBML_ID_EBMLREADVERSION,    EBML_UINT, 0, offsetof(Ebml, version),         { .u = EBML_VERSION } },
+    { EBML_ID_EBMLMAXSIZELENGTH,  EBML_UINT, 0, offsetof(Ebml, max_size),        { .u = 8 } },
+    { EBML_ID_EBMLMAXIDLENGTH,    EBML_UINT, 0, offsetof(Ebml, id_length),       { .u = 4 } },
+    { EBML_ID_DOCTYPE,            EBML_STR,  0, offsetof(Ebml, doctype),         { .s = "(none)" } },
+    { EBML_ID_DOCTYPEREADVERSION, EBML_UINT, 0, offsetof(Ebml, doctype_version), { .u = 1 } },
+    { EBML_ID_EBMLVERSION,        EBML_NONE },
+    { EBML_ID_DOCTYPEVERSION,     EBML_NONE },
     { 0 }
 };
 
 static EbmlSyntax ebml_syntax[] = {
-    { EBML_ID_HEADER,                 EBML_NEST, 0, 0, {.n=ebml_header} },
+    { EBML_ID_HEADER, EBML_NEST, 0, 0, { .n = ebml_header } },
     { 0 }
 };
 
 static EbmlSyntax matroska_info[] = {
-    { MATROSKA_ID_TIMECODESCALE,      EBML_UINT,  0, offsetof(MatroskaDemuxContext,time_scale), {.u=1000000} },
-    { MATROSKA_ID_DURATION,           EBML_FLOAT, 0, offsetof(MatroskaDemuxContext,duration) },
-    { MATROSKA_ID_TITLE,              EBML_UTF8,  0, offsetof(MatroskaDemuxContext,title) },
-    { MATROSKA_ID_WRITINGAPP,         EBML_NONE },
-    { MATROSKA_ID_MUXINGAPP,          EBML_NONE },
-    { MATROSKA_ID_DATEUTC,            EBML_NONE },
-    { MATROSKA_ID_SEGMENTUID,         EBML_NONE },
+    { MATROSKA_ID_TIMECODESCALE, EBML_UINT,  0, offsetof(MatroskaDemuxContext, time_scale), { .u = 1000000 } },
+    { MATROSKA_ID_DURATION,      EBML_FLOAT, 0, offsetof(MatroskaDemuxContext, duration) },
+    { MATROSKA_ID_TITLE,         EBML_UTF8,  0, offsetof(MatroskaDemuxContext, title) },
+    { MATROSKA_ID_WRITINGAPP,    EBML_NONE },
+    { MATROSKA_ID_MUXINGAPP,     EBML_NONE },
+    { MATROSKA_ID_DATEUTC,       EBML_NONE },
+    { MATROSKA_ID_SEGMENTUID,    EBML_NONE },
     { 0 }
 };
 
 static EbmlSyntax matroska_track_video[] = {
-    { MATROSKA_ID_VIDEOFRAMERATE,     EBML_FLOAT,0, offsetof(MatroskaTrackVideo,frame_rate) },
-    { MATROSKA_ID_VIDEODISPLAYWIDTH,  EBML_UINT, 0, offsetof(MatroskaTrackVideo,display_width) },
-    { MATROSKA_ID_VIDEODISPLAYHEIGHT, EBML_UINT, 0, offsetof(MatroskaTrackVideo,display_height) },
-    { MATROSKA_ID_VIDEOPIXELWIDTH,    EBML_UINT, 0, offsetof(MatroskaTrackVideo,pixel_width) },
-    { MATROSKA_ID_VIDEOPIXELHEIGHT,   EBML_UINT, 0, offsetof(MatroskaTrackVideo,pixel_height) },
-    { MATROSKA_ID_VIDEOCOLORSPACE,    EBML_UINT, 0, offsetof(MatroskaTrackVideo,fourcc) },
-    { MATROSKA_ID_VIDEOPIXELCROPB,    EBML_NONE },
-    { MATROSKA_ID_VIDEOPIXELCROPT,    EBML_NONE },
-    { MATROSKA_ID_VIDEOPIXELCROPL,    EBML_NONE },
-    { MATROSKA_ID_VIDEOPIXELCROPR,    EBML_NONE },
-    { MATROSKA_ID_VIDEODISPLAYUNIT,   EBML_NONE },
-    { MATROSKA_ID_VIDEOFLAGINTERLACED,EBML_NONE },
-    { MATROSKA_ID_VIDEOSTEREOMODE,    EBML_NONE },
-    { MATROSKA_ID_VIDEOASPECTRATIO,   EBML_NONE },
+    { MATROSKA_ID_VIDEOFRAMERATE,      EBML_FLOAT, 0, offsetof(MatroskaTrackVideo, frame_rate) },
+    { MATROSKA_ID_VIDEODISPLAYWIDTH,   EBML_UINT,  0, offsetof(MatroskaTrackVideo, display_width) },
+    { MATROSKA_ID_VIDEODISPLAYHEIGHT,  EBML_UINT,  0, offsetof(MatroskaTrackVideo, display_height) },
+    { MATROSKA_ID_VIDEOPIXELWIDTH,     EBML_UINT,  0, offsetof(MatroskaTrackVideo, pixel_width) },
+    { MATROSKA_ID_VIDEOPIXELHEIGHT,    EBML_UINT,  0, offsetof(MatroskaTrackVideo, pixel_height) },
+    { MATROSKA_ID_VIDEOCOLORSPACE,     EBML_UINT,  0, offsetof(MatroskaTrackVideo, fourcc) },
+    { MATROSKA_ID_VIDEOPIXELCROPB,     EBML_NONE },
+    { MATROSKA_ID_VIDEOPIXELCROPT,     EBML_NONE },
+    { MATROSKA_ID_VIDEOPIXELCROPL,     EBML_NONE },
+    { MATROSKA_ID_VIDEOPIXELCROPR,     EBML_NONE },
+    { MATROSKA_ID_VIDEODISPLAYUNIT,    EBML_NONE },
+    { MATROSKA_ID_VIDEOFLAGINTERLACED, EBML_NONE },
+    { MATROSKA_ID_VIDEOSTEREOMODE,     EBML_NONE },
+    { MATROSKA_ID_VIDEOASPECTRATIO,    EBML_NONE },
     { 0 }
 };
 
 static EbmlSyntax matroska_track_audio[] = {
-    { MATROSKA_ID_AUDIOSAMPLINGFREQ,  EBML_FLOAT,0, offsetof(MatroskaTrackAudio,samplerate), {.f=8000.0} },
-    { MATROSKA_ID_AUDIOOUTSAMPLINGFREQ,EBML_FLOAT,0,offsetof(MatroskaTrackAudio,out_samplerate) },
-    { MATROSKA_ID_AUDIOBITDEPTH,      EBML_UINT, 0, offsetof(MatroskaTrackAudio,bitdepth) },
-    { MATROSKA_ID_AUDIOCHANNELS,      EBML_UINT, 0, offsetof(MatroskaTrackAudio,channels), {.u=1} },
+    { MATROSKA_ID_AUDIOSAMPLINGFREQ,    EBML_FLOAT, 0, offsetof(MatroskaTrackAudio, samplerate), { .f = 8000.0 } },
+    { MATROSKA_ID_AUDIOOUTSAMPLINGFREQ, EBML_FLOAT, 0, offsetof(MatroskaTrackAudio, out_samplerate) },
+    { MATROSKA_ID_AUDIOBITDEPTH,        EBML_UINT,  0, offsetof(MatroskaTrackAudio, bitdepth) },
+    { MATROSKA_ID_AUDIOCHANNELS,        EBML_UINT,  0, offsetof(MatroskaTrackAudio, channels),   { .u = 1 } },
     { 0 }
 };
 
 static EbmlSyntax matroska_track_encoding_compression[] = {
-    { MATROSKA_ID_ENCODINGCOMPALGO,   EBML_UINT, 0, offsetof(MatroskaTrackCompression,algo), {.u=0} },
-    { MATROSKA_ID_ENCODINGCOMPSETTINGS,EBML_BIN, 0, offsetof(MatroskaTrackCompression,settings) },
+    { MATROSKA_ID_ENCODINGCOMPALGO,     EBML_UINT, 0, offsetof(MatroskaTrackCompression, algo), { .u = 0 } },
+    { MATROSKA_ID_ENCODINGCOMPSETTINGS, EBML_BIN,  0, offsetof(MatroskaTrackCompression, settings) },
     { 0 }
 };
 
 static EbmlSyntax matroska_track_encoding[] = {
-    { MATROSKA_ID_ENCODINGSCOPE,      EBML_UINT, 0, offsetof(MatroskaTrackEncoding,scope), {.u=1} },
-    { MATROSKA_ID_ENCODINGTYPE,       EBML_UINT, 0, offsetof(MatroskaTrackEncoding,type), {.u=0} },
-    { MATROSKA_ID_ENCODINGCOMPRESSION,EBML_NEST, 0, offsetof(MatroskaTrackEncoding,compression), {.n=matroska_track_encoding_compression} },
-    { MATROSKA_ID_ENCODINGORDER,      EBML_NONE },
+    { MATROSKA_ID_ENCODINGSCOPE,       EBML_UINT, 0, offsetof(MatroskaTrackEncoding, scope),       { .u = 1 } },
+    { MATROSKA_ID_ENCODINGTYPE,        EBML_UINT, 0, offsetof(MatroskaTrackEncoding, type),        { .u = 0 } },
+    { MATROSKA_ID_ENCODINGCOMPRESSION, EBML_NEST, 0, offsetof(MatroskaTrackEncoding, compression), { .n = matroska_track_encoding_compression } },
+    { MATROSKA_ID_ENCODINGORDER,       EBML_NONE },
     { 0 }
 };
 
 static EbmlSyntax matroska_track_encodings[] = {
-    { MATROSKA_ID_TRACKCONTENTENCODING, EBML_NEST, sizeof(MatroskaTrackEncoding), offsetof(MatroskaTrack,encodings), {.n=matroska_track_encoding} },
+    { MATROSKA_ID_TRACKCONTENTENCODING, EBML_NEST, sizeof(MatroskaTrackEncoding), offsetof(MatroskaTrack, encodings), { .n = matroska_track_encoding } },
     { 0 }
 };
 
 static EbmlSyntax matroska_track[] = {
-    { MATROSKA_ID_TRACKNUMBER,          EBML_UINT, 0, offsetof(MatroskaTrack,num) },
-    { MATROSKA_ID_TRACKNAME,            EBML_UTF8, 0, offsetof(MatroskaTrack,name) },
-    { MATROSKA_ID_TRACKUID,             EBML_UINT, 0, offsetof(MatroskaTrack,uid) },
-    { MATROSKA_ID_TRACKTYPE,            EBML_UINT, 0, offsetof(MatroskaTrack,type) },
-    { MATROSKA_ID_CODECID,              EBML_STR,  0, offsetof(MatroskaTrack,codec_id) },
-    { MATROSKA_ID_CODECPRIVATE,         EBML_BIN,  0, offsetof(MatroskaTrack,codec_priv) },
-    { MATROSKA_ID_TRACKLANGUAGE,        EBML_UTF8, 0, offsetof(MatroskaTrack,language), {.s="eng"} },
-    { MATROSKA_ID_TRACKDEFAULTDURATION, EBML_UINT, 0, offsetof(MatroskaTrack,default_duration) },
-    { MATROSKA_ID_TRACKTIMECODESCALE,   EBML_FLOAT,0, offsetof(MatroskaTrack,time_scale), {.f=1.0} },
-    { MATROSKA_ID_TRACKFLAGDEFAULT,     EBML_UINT, 0, offsetof(MatroskaTrack,flag_default), {.u=1} },
-    { MATROSKA_ID_TRACKFLAGFORCED,      EBML_UINT, 0, offsetof(MatroskaTrack,flag_forced), {.u=0} },
-    { MATROSKA_ID_TRACKVIDEO,           EBML_NEST, 0, offsetof(MatroskaTrack,video), {.n=matroska_track_video} },
-    { MATROSKA_ID_TRACKAUDIO,           EBML_NEST, 0, offsetof(MatroskaTrack,audio), {.n=matroska_track_audio} },
-    { MATROSKA_ID_TRACKCONTENTENCODINGS,EBML_NEST, 0, 0, {.n=matroska_track_encodings} },
-    { MATROSKA_ID_TRACKFLAGENABLED,     EBML_NONE },
-    { MATROSKA_ID_TRACKFLAGLACING,      EBML_NONE },
-    { MATROSKA_ID_CODECNAME,            EBML_NONE },
-    { MATROSKA_ID_CODECDECODEALL,       EBML_NONE },
-    { MATROSKA_ID_CODECINFOURL,         EBML_NONE },
-    { MATROSKA_ID_CODECDOWNLOADURL,     EBML_NONE },
-    { MATROSKA_ID_TRACKMINCACHE,        EBML_NONE },
-    { MATROSKA_ID_TRACKMAXCACHE,        EBML_NONE },
-    { MATROSKA_ID_TRACKMAXBLKADDID,     EBML_NONE },
+    { MATROSKA_ID_TRACKNUMBER,           EBML_UINT,  0, offsetof(MatroskaTrack, num) },
+    { MATROSKA_ID_TRACKNAME,             EBML_UTF8,  0, offsetof(MatroskaTrack, name) },
+    { MATROSKA_ID_TRACKUID,              EBML_UINT,  0, offsetof(MatroskaTrack, uid) },
+    { MATROSKA_ID_TRACKTYPE,             EBML_UINT,  0, offsetof(MatroskaTrack, type) },
+    { MATROSKA_ID_CODECID,               EBML_STR,   0, offsetof(MatroskaTrack, codec_id) },
+    { MATROSKA_ID_CODECPRIVATE,          EBML_BIN,   0, offsetof(MatroskaTrack, codec_priv) },
+    { MATROSKA_ID_TRACKLANGUAGE,         EBML_UTF8,  0, offsetof(MatroskaTrack, language),     { .s = "eng"  } },
+    { MATROSKA_ID_TRACKDEFAULTDURATION,  EBML_UINT,  0, offsetof(MatroskaTrack, default_duration) },
+    { MATROSKA_ID_TRACKTIMECODESCALE,    EBML_FLOAT, 0, offsetof(MatroskaTrack, time_scale),   { .f = 1.0  } },
+    { MATROSKA_ID_TRACKFLAGDEFAULT,      EBML_UINT,  0, offsetof(MatroskaTrack, flag_default), { .u = 1  } },
+    { MATROSKA_ID_TRACKFLAGFORCED,       EBML_UINT,  0, offsetof(MatroskaTrack, flag_forced),  { .u = 0   } },
+    { MATROSKA_ID_TRACKVIDEO,            EBML_NEST,  0, offsetof(MatroskaTrack, video),        { .n = matroska_track_video } },
+    { MATROSKA_ID_TRACKAUDIO,            EBML_NEST,  0, offsetof(MatroskaTrack, audio),        { .n = matroska_track_audio } },
+    { MATROSKA_ID_TRACKCONTENTENCODINGS, EBML_NEST,  0, 0,                                     { .n = matroska_track_encodings } },
+    { MATROSKA_ID_TRACKFLAGENABLED,      EBML_NONE },
+    { MATROSKA_ID_TRACKFLAGLACING,       EBML_NONE },
+    { MATROSKA_ID_CODECNAME,             EBML_NONE },
+    { MATROSKA_ID_CODECDECODEALL,        EBML_NONE },
+    { MATROSKA_ID_CODECINFOURL,          EBML_NONE },
+    { MATROSKA_ID_CODECDOWNLOADURL,      EBML_NONE },
+    { MATROSKA_ID_TRACKMINCACHE,         EBML_NONE },
+    { MATROSKA_ID_TRACKMAXCACHE,         EBML_NONE },
+    { MATROSKA_ID_TRACKMAXBLKADDID,      EBML_NONE },
     { 0 }
 };
 
 static EbmlSyntax matroska_tracks[] = {
-    { MATROSKA_ID_TRACKENTRY,         EBML_NEST, sizeof(MatroskaTrack), offsetof(MatroskaDemuxContext,tracks), {.n=matroska_track} },
+    { MATROSKA_ID_TRACKENTRY, EBML_NEST, sizeof(MatroskaTrack), offsetof(MatroskaDemuxContext, tracks), { .n = matroska_track } },
     { 0 }
 };
 
 static EbmlSyntax matroska_attachment[] = {
-    { MATROSKA_ID_FILEUID,            EBML_UINT, 0, offsetof(MatroskaAttachement,uid) },
-    { MATROSKA_ID_FILENAME,           EBML_UTF8, 0, offsetof(MatroskaAttachement,filename) },
-    { MATROSKA_ID_FILEMIMETYPE,       EBML_STR,  0, offsetof(MatroskaAttachement,mime) },
-    { MATROSKA_ID_FILEDATA,           EBML_BIN,  0, offsetof(MatroskaAttachement,bin) },
-    { MATROSKA_ID_FILEDESC,           EBML_NONE },
+    { MATROSKA_ID_FILEUID,      EBML_UINT, 0, offsetof(MatroskaAttachment, uid) },
+    { MATROSKA_ID_FILENAME,     EBML_UTF8, 0, offsetof(MatroskaAttachment, filename) },
+    { MATROSKA_ID_FILEMIMETYPE, EBML_STR,  0, offsetof(MatroskaAttachment, mime) },
+    { MATROSKA_ID_FILEDATA,     EBML_BIN,  0, offsetof(MatroskaAttachment, bin) },
+    { MATROSKA_ID_FILEDESC,     EBML_NONE },
     { 0 }
 };
 
 static EbmlSyntax matroska_attachments[] = {
-    { MATROSKA_ID_ATTACHEDFILE,       EBML_NEST, sizeof(MatroskaAttachement), offsetof(MatroskaDemuxContext,attachments), {.n=matroska_attachment} },
+    { MATROSKA_ID_ATTACHEDFILE, EBML_NEST, sizeof(MatroskaAttachment), offsetof(MatroskaDemuxContext, attachments), { .n = matroska_attachment } },
     { 0 }
 };
 
 static EbmlSyntax matroska_chapter_display[] = {
-    { MATROSKA_ID_CHAPSTRING,         EBML_UTF8, 0, offsetof(MatroskaChapter,title) },
-    { MATROSKA_ID_CHAPLANG,           EBML_NONE },
+    { MATROSKA_ID_CHAPSTRING, EBML_UTF8, 0, offsetof(MatroskaChapter, title) },
+    { MATROSKA_ID_CHAPLANG,   EBML_NONE },
     { 0 }
 };
 
 static EbmlSyntax matroska_chapter_entry[] = {
-    { MATROSKA_ID_CHAPTERTIMESTART,   EBML_UINT, 0, offsetof(MatroskaChapter,start), {.u=AV_NOPTS_VALUE} },
-    { MATROSKA_ID_CHAPTERTIMEEND,     EBML_UINT, 0, offsetof(MatroskaChapter,end), {.u=AV_NOPTS_VALUE} },
-    { MATROSKA_ID_CHAPTERUID,         EBML_UINT, 0, offsetof(MatroskaChapter,uid) },
-    { MATROSKA_ID_CHAPTERDISPLAY,     EBML_NEST, 0, 0, {.n=matroska_chapter_display} },
+    { MATROSKA_ID_CHAPTERTIMESTART,   EBML_UINT, 0, offsetof(MatroskaChapter, start), { .u = AV_NOPTS_VALUE } },
+    { MATROSKA_ID_CHAPTERTIMEEND,     EBML_UINT, 0, offsetof(MatroskaChapter, end),   { .u = AV_NOPTS_VALUE } },
+    { MATROSKA_ID_CHAPTERUID,         EBML_UINT, 0, offsetof(MatroskaChapter, uid) },
+    { MATROSKA_ID_CHAPTERDISPLAY,     EBML_NEST, 0,                        0,         { .n = matroska_chapter_display } },
     { MATROSKA_ID_CHAPTERFLAGHIDDEN,  EBML_NONE },
     { MATROSKA_ID_CHAPTERFLAGENABLED, EBML_NONE },
     { MATROSKA_ID_CHAPTERPHYSEQUIV,   EBML_NONE },
@@ -406,7 +412,7 @@ static EbmlSyntax matroska_chapter_entry[] = {
 };
 
 static EbmlSyntax matroska_chapter[] = {
-    { MATROSKA_ID_CHAPTERATOM,        EBML_NEST, sizeof(MatroskaChapter), offsetof(MatroskaDemuxContext,chapters), {.n=matroska_chapter_entry} },
+    { MATROSKA_ID_CHAPTERATOM,        EBML_NEST, sizeof(MatroskaChapter), offsetof(MatroskaDemuxContext, chapters), { .n = matroska_chapter_entry } },
     { MATROSKA_ID_EDITIONUID,         EBML_NONE },
     { MATROSKA_ID_EDITIONFLAGHIDDEN,  EBML_NONE },
     { MATROSKA_ID_EDITIONFLAGDEFAULT, EBML_NONE },
@@ -415,143 +421,143 @@ static EbmlSyntax matroska_chapter[] = {
 };
 
 static EbmlSyntax matroska_chapters[] = {
-    { MATROSKA_ID_EDITIONENTRY,       EBML_NEST, 0, 0, {.n=matroska_chapter} },
+    { MATROSKA_ID_EDITIONENTRY, EBML_NEST, 0, 0, { .n = matroska_chapter } },
     { 0 }
 };
 
 static EbmlSyntax matroska_index_pos[] = {
-    { MATROSKA_ID_CUETRACK,           EBML_UINT, 0, offsetof(MatroskaIndexPos,track) },
-    { MATROSKA_ID_CUECLUSTERPOSITION, EBML_UINT, 0, offsetof(MatroskaIndexPos,pos)   },
+    { MATROSKA_ID_CUETRACK,           EBML_UINT, 0, offsetof(MatroskaIndexPos, track) },
+    { MATROSKA_ID_CUECLUSTERPOSITION, EBML_UINT, 0, offsetof(MatroskaIndexPos, pos) },
     { MATROSKA_ID_CUEBLOCKNUMBER,     EBML_NONE },
     { 0 }
 };
 
 static EbmlSyntax matroska_index_entry[] = {
-    { MATROSKA_ID_CUETIME,            EBML_UINT, 0, offsetof(MatroskaIndex,time) },
-    { MATROSKA_ID_CUETRACKPOSITION,   EBML_NEST, sizeof(MatroskaIndexPos), offsetof(MatroskaIndex,pos), {.n=matroska_index_pos} },
+    { MATROSKA_ID_CUETIME,          EBML_UINT, 0,                        offsetof(MatroskaIndex, time) },
+    { MATROSKA_ID_CUETRACKPOSITION, EBML_NEST, sizeof(MatroskaIndexPos), offsetof(MatroskaIndex, pos), { .n = matroska_index_pos } },
     { 0 }
 };
 
 static EbmlSyntax matroska_index[] = {
-    { MATROSKA_ID_POINTENTRY,         EBML_NEST, sizeof(MatroskaIndex), offsetof(MatroskaDemuxContext,index), {.n=matroska_index_entry} },
+    { MATROSKA_ID_POINTENTRY, EBML_NEST, sizeof(MatroskaIndex), offsetof(MatroskaDemuxContext, index), { .n = matroska_index_entry } },
     { 0 }
 };
 
 static EbmlSyntax matroska_simpletag[] = {
-    { MATROSKA_ID_TAGNAME,            EBML_UTF8, 0, offsetof(MatroskaTag,name) },
-    { MATROSKA_ID_TAGSTRING,          EBML_UTF8, 0, offsetof(MatroskaTag,string) },
-    { MATROSKA_ID_TAGLANG,            EBML_STR,  0, offsetof(MatroskaTag,lang), {.s="und"} },
-    { MATROSKA_ID_TAGDEFAULT,         EBML_UINT, 0, offsetof(MatroskaTag,def) },
-    { MATROSKA_ID_TAGDEFAULT_BUG,     EBML_UINT, 0, offsetof(MatroskaTag,def) },
-    { MATROSKA_ID_SIMPLETAG,          EBML_NEST, sizeof(MatroskaTag), offsetof(MatroskaTag,sub), {.n=matroska_simpletag} },
+    { MATROSKA_ID_TAGNAME,        EBML_UTF8, 0,                   offsetof(MatroskaTag, name) },
+    { MATROSKA_ID_TAGSTRING,      EBML_UTF8, 0,                   offsetof(MatroskaTag, string) },
+    { MATROSKA_ID_TAGLANG,        EBML_STR,  0,                   offsetof(MatroskaTag, lang), { .s = "und" } },
+    { MATROSKA_ID_TAGDEFAULT,     EBML_UINT, 0,                   offsetof(MatroskaTag, def) },
+    { MATROSKA_ID_TAGDEFAULT_BUG, EBML_UINT, 0,                   offsetof(MatroskaTag, def) },
+    { MATROSKA_ID_SIMPLETAG,      EBML_NEST, sizeof(MatroskaTag), offsetof(MatroskaTag, sub),  { .n = matroska_simpletag } },
     { 0 }
 };
 
 static EbmlSyntax matroska_tagtargets[] = {
-    { MATROSKA_ID_TAGTARGETS_TYPE,      EBML_STR,  0, offsetof(MatroskaTagTarget,type) },
-    { MATROSKA_ID_TAGTARGETS_TYPEVALUE, EBML_UINT, 0, offsetof(MatroskaTagTarget,typevalue), {.u=50} },
-    { MATROSKA_ID_TAGTARGETS_TRACKUID,  EBML_UINT, 0, offsetof(MatroskaTagTarget,trackuid) },
-    { MATROSKA_ID_TAGTARGETS_CHAPTERUID,EBML_UINT, 0, offsetof(MatroskaTagTarget,chapteruid) },
-    { MATROSKA_ID_TAGTARGETS_ATTACHUID, EBML_UINT, 0, offsetof(MatroskaTagTarget,attachuid) },
+    { MATROSKA_ID_TAGTARGETS_TYPE,       EBML_STR,  0, offsetof(MatroskaTagTarget, type) },
+    { MATROSKA_ID_TAGTARGETS_TYPEVALUE,  EBML_UINT, 0, offsetof(MatroskaTagTarget, typevalue), { .u = 50 } },
+    { MATROSKA_ID_TAGTARGETS_TRACKUID,   EBML_UINT, 0, offsetof(MatroskaTagTarget, trackuid) },
+    { MATROSKA_ID_TAGTARGETS_CHAPTERUID, EBML_UINT, 0, offsetof(MatroskaTagTarget, chapteruid) },
+    { MATROSKA_ID_TAGTARGETS_ATTACHUID,  EBML_UINT, 0, offsetof(MatroskaTagTarget, attachuid) },
     { 0 }
 };
 
 static EbmlSyntax matroska_tag[] = {
-    { MATROSKA_ID_SIMPLETAG,          EBML_NEST, sizeof(MatroskaTag), offsetof(MatroskaTags,tag), {.n=matroska_simpletag} },
-    { MATROSKA_ID_TAGTARGETS,         EBML_NEST, 0, offsetof(MatroskaTags,target), {.n=matroska_tagtargets} },
+    { MATROSKA_ID_SIMPLETAG,  EBML_NEST, sizeof(MatroskaTag), offsetof(MatroskaTags, tag),    { .n = matroska_simpletag } },
+    { MATROSKA_ID_TAGTARGETS, EBML_NEST, 0,                   offsetof(MatroskaTags, target), { .n = matroska_tagtargets } },
     { 0 }
 };
 
 static EbmlSyntax matroska_tags[] = {
-    { MATROSKA_ID_TAG,                EBML_NEST, sizeof(MatroskaTags), offsetof(MatroskaDemuxContext,tags), {.n=matroska_tag} },
+    { MATROSKA_ID_TAG, EBML_NEST, sizeof(MatroskaTags), offsetof(MatroskaDemuxContext, tags), { .n = matroska_tag } },
     { 0 }
 };
 
 static EbmlSyntax matroska_seekhead_entry[] = {
-    { MATROSKA_ID_SEEKID,             EBML_UINT, 0, offsetof(MatroskaSeekhead,id) },
-    { MATROSKA_ID_SEEKPOSITION,       EBML_UINT, 0, offsetof(MatroskaSeekhead,pos), {.u=-1} },
+    { MATROSKA_ID_SEEKID,       EBML_UINT, 0, offsetof(MatroskaSeekhead, id) },
+    { MATROSKA_ID_SEEKPOSITION, EBML_UINT, 0, offsetof(MatroskaSeekhead, pos), { .u = -1 } },
     { 0 }
 };
 
 static EbmlSyntax matroska_seekhead[] = {
-    { MATROSKA_ID_SEEKENTRY,          EBML_NEST, sizeof(MatroskaSeekhead), offsetof(MatroskaDemuxContext,seekhead), {.n=matroska_seekhead_entry} },
+    { MATROSKA_ID_SEEKENTRY, EBML_NEST, sizeof(MatroskaSeekhead), offsetof(MatroskaDemuxContext, seekhead), { .n = matroska_seekhead_entry } },
     { 0 }
 };
 
 static EbmlSyntax matroska_segment[] = {
-    { MATROSKA_ID_INFO,           EBML_NEST, 0, 0, {.n=matroska_info       } },
-    { MATROSKA_ID_TRACKS,         EBML_NEST, 0, 0, {.n=matroska_tracks     } },
-    { MATROSKA_ID_ATTACHMENTS,    EBML_NEST, 0, 0, {.n=matroska_attachments} },
-    { MATROSKA_ID_CHAPTERS,       EBML_NEST, 0, 0, {.n=matroska_chapters   } },
-    { MATROSKA_ID_CUES,           EBML_NEST, 0, 0, {.n=matroska_index      } },
-    { MATROSKA_ID_TAGS,           EBML_NEST, 0, 0, {.n=matroska_tags       } },
-    { MATROSKA_ID_SEEKHEAD,       EBML_NEST, 0, 0, {.n=matroska_seekhead   } },
-    { MATROSKA_ID_CLUSTER,        EBML_STOP },
+    { MATROSKA_ID_INFO,        EBML_NEST, 0, 0, { .n = matroska_info } },
+    { MATROSKA_ID_TRACKS,      EBML_NEST, 0, 0, { .n = matroska_tracks } },
+    { MATROSKA_ID_ATTACHMENTS, EBML_NEST, 0, 0, { .n = matroska_attachments } },
+    { MATROSKA_ID_CHAPTERS,    EBML_NEST, 0, 0, { .n = matroska_chapters } },
+    { MATROSKA_ID_CUES,        EBML_NEST, 0, 0, { .n = matroska_index } },
+    { MATROSKA_ID_TAGS,        EBML_NEST, 0, 0, { .n = matroska_tags } },
+    { MATROSKA_ID_SEEKHEAD,    EBML_NEST, 0, 0, { .n = matroska_seekhead } },
+    { MATROSKA_ID_CLUSTER,     EBML_STOP },
     { 0 }
 };
 
 static EbmlSyntax matroska_segments[] = {
-    { MATROSKA_ID_SEGMENT,        EBML_NEST, 0, 0, {.n=matroska_segment    } },
+    { MATROSKA_ID_SEGMENT, EBML_NEST, 0, 0, { .n = matroska_segment } },
     { 0 }
 };
 
 static EbmlSyntax matroska_blockgroup[] = {
-    { MATROSKA_ID_BLOCK,          EBML_BIN,  0, offsetof(MatroskaBlock,bin) },
-    { MATROSKA_ID_SIMPLEBLOCK,    EBML_BIN,  0, offsetof(MatroskaBlock,bin) },
-    { MATROSKA_ID_BLOCKDURATION,  EBML_UINT, 0, offsetof(MatroskaBlock,duration), {.u=AV_NOPTS_VALUE} },
-    { MATROSKA_ID_BLOCKREFERENCE, EBML_UINT, 0, offsetof(MatroskaBlock,reference) },
+    { MATROSKA_ID_BLOCK,          EBML_BIN,  0, offsetof(MatroskaBlock, bin) },
+    { MATROSKA_ID_SIMPLEBLOCK,    EBML_BIN,  0, offsetof(MatroskaBlock, bin) },
+    { MATROSKA_ID_BLOCKDURATION,  EBML_UINT, 0, offsetof(MatroskaBlock, duration), { .u = AV_NOPTS_VALUE } },
+    { MATROSKA_ID_BLOCKREFERENCE, EBML_UINT, 0, offsetof(MatroskaBlock, reference) },
     { MATROSKA_ID_CODECSTATE,     EBML_NONE },
-    { 1,                          EBML_UINT, 0, offsetof(MatroskaBlock,non_simple), {.u=1} },
+    {                          1, EBML_UINT, 0, offsetof(MatroskaBlock, non_simple), { .u = 1 } },
     { 0 }
 };
 
 static EbmlSyntax matroska_cluster[] = {
-    { MATROSKA_ID_CLUSTERTIMECODE,EBML_UINT,0, offsetof(MatroskaCluster,timecode) },
-    { MATROSKA_ID_BLOCKGROUP,     EBML_NEST, sizeof(MatroskaBlock), offsetof(MatroskaCluster,blocks), {.n=matroska_blockgroup} },
-    { MATROSKA_ID_SIMPLEBLOCK,    EBML_PASS, sizeof(MatroskaBlock), offsetof(MatroskaCluster,blocks), {.n=matroska_blockgroup} },
-    { MATROSKA_ID_CLUSTERPOSITION,EBML_NONE },
-    { MATROSKA_ID_CLUSTERPREVSIZE,EBML_NONE },
+    { MATROSKA_ID_CLUSTERTIMECODE, EBML_UINT, 0,                     offsetof(MatroskaCluster, timecode) },
+    { MATROSKA_ID_BLOCKGROUP,      EBML_NEST, sizeof(MatroskaBlock), offsetof(MatroskaCluster, blocks), { .n = matroska_blockgroup } },
+    { MATROSKA_ID_SIMPLEBLOCK,     EBML_PASS, sizeof(MatroskaBlock), offsetof(MatroskaCluster, blocks), { .n = matroska_blockgroup } },
+    { MATROSKA_ID_CLUSTERPOSITION, EBML_NONE },
+    { MATROSKA_ID_CLUSTERPREVSIZE, EBML_NONE },
     { 0 }
 };
 
 static EbmlSyntax matroska_clusters[] = {
-    { MATROSKA_ID_CLUSTER,        EBML_NEST, 0, 0, {.n=matroska_cluster} },
-    { MATROSKA_ID_INFO,           EBML_NONE },
-    { MATROSKA_ID_CUES,           EBML_NONE },
-    { MATROSKA_ID_TAGS,           EBML_NONE },
-    { MATROSKA_ID_SEEKHEAD,       EBML_NONE },
+    { MATROSKA_ID_CLUSTER,  EBML_NEST, 0, 0, { .n = matroska_cluster } },
+    { MATROSKA_ID_INFO,     EBML_NONE },
+    { MATROSKA_ID_CUES,     EBML_NONE },
+    { MATROSKA_ID_TAGS,     EBML_NONE },
+    { MATROSKA_ID_SEEKHEAD, EBML_NONE },
     { 0 }
 };
 
 static EbmlSyntax matroska_cluster_incremental_parsing[] = {
-    { MATROSKA_ID_CLUSTERTIMECODE,EBML_UINT,0, offsetof(MatroskaCluster,timecode) },
-    { MATROSKA_ID_BLOCKGROUP,     EBML_NEST, sizeof(MatroskaBlock), offsetof(MatroskaCluster,blocks), {.n=matroska_blockgroup} },
-    { MATROSKA_ID_SIMPLEBLOCK,    EBML_PASS, sizeof(MatroskaBlock), offsetof(MatroskaCluster,blocks), {.n=matroska_blockgroup} },
-    { MATROSKA_ID_CLUSTERPOSITION,EBML_NONE },
-    { MATROSKA_ID_CLUSTERPREVSIZE,EBML_NONE },
-    { MATROSKA_ID_INFO,           EBML_NONE },
-    { MATROSKA_ID_CUES,           EBML_NONE },
-    { MATROSKA_ID_TAGS,           EBML_NONE },
-    { MATROSKA_ID_SEEKHEAD,       EBML_NONE },
-    { MATROSKA_ID_CLUSTER,        EBML_STOP },
+    { MATROSKA_ID_CLUSTERTIMECODE, EBML_UINT, 0,                     offsetof(MatroskaCluster, timecode) },
+    { MATROSKA_ID_BLOCKGROUP,      EBML_NEST, sizeof(MatroskaBlock), offsetof(MatroskaCluster, blocks), { .n = matroska_blockgroup } },
+    { MATROSKA_ID_SIMPLEBLOCK,     EBML_PASS, sizeof(MatroskaBlock), offsetof(MatroskaCluster, blocks), { .n = matroska_blockgroup } },
+    { MATROSKA_ID_CLUSTERPOSITION, EBML_NONE },
+    { MATROSKA_ID_CLUSTERPREVSIZE, EBML_NONE },
+    { MATROSKA_ID_INFO,            EBML_NONE },
+    { MATROSKA_ID_CUES,            EBML_NONE },
+    { MATROSKA_ID_TAGS,            EBML_NONE },
+    { MATROSKA_ID_SEEKHEAD,        EBML_NONE },
+    { MATROSKA_ID_CLUSTER,         EBML_STOP },
     { 0 }
 };
 
 static EbmlSyntax matroska_cluster_incremental[] = {
-    { MATROSKA_ID_CLUSTERTIMECODE,EBML_UINT,0, offsetof(MatroskaCluster,timecode) },
-    { MATROSKA_ID_BLOCKGROUP,     EBML_STOP },
-    { MATROSKA_ID_SIMPLEBLOCK,    EBML_STOP },
-    { MATROSKA_ID_CLUSTERPOSITION,EBML_NONE },
-    { MATROSKA_ID_CLUSTERPREVSIZE,EBML_NONE },
+    { MATROSKA_ID_CLUSTERTIMECODE, EBML_UINT, 0, offsetof(MatroskaCluster, timecode) },
+    { MATROSKA_ID_BLOCKGROUP,      EBML_STOP },
+    { MATROSKA_ID_SIMPLEBLOCK,     EBML_STOP },
+    { MATROSKA_ID_CLUSTERPOSITION, EBML_NONE },
+    { MATROSKA_ID_CLUSTERPREVSIZE, EBML_NONE },
     { 0 }
 };
 
 static EbmlSyntax matroska_clusters_incremental[] = {
-    { MATROSKA_ID_CLUSTER,        EBML_NEST, 0, 0, {.n=matroska_cluster_incremental} },
-    { MATROSKA_ID_INFO,           EBML_NONE },
-    { MATROSKA_ID_CUES,           EBML_NONE },
-    { MATROSKA_ID_TAGS,           EBML_NONE },
-    { MATROSKA_ID_SEEKHEAD,       EBML_NONE },
+    { MATROSKA_ID_CLUSTER,  EBML_NEST, 0, 0, { .n = matroska_cluster_incremental } },
+    { MATROSKA_ID_INFO,     EBML_NONE },
+    { MATROSKA_ID_CUES,     EBML_NONE },
+    { MATROSKA_ID_TAGS,     EBML_NONE },
+    { MATROSKA_ID_SEEKHEAD, EBML_NONE },
     { 0 }
 };
 
@@ -576,11 +582,12 @@ static int matroska_resync(MatroskaDemuxContext *matroska, int64_t last_pos)
             id == MATROSKA_ID_CUES     || id == MATROSKA_ID_TAGS        ||
             id == MATROSKA_ID_SEEKHEAD || id == MATROSKA_ID_ATTACHMENTS ||
             id == MATROSKA_ID_CLUSTER  || id == MATROSKA_ID_CHAPTERS) {
-                matroska->current_id = id;
-                return 0;
+            matroska->current_id = id;
+            return 0;
         }
         id = (id << 8) | avio_r8(pb);
     }
+
 eof:
     matroska->done = 1;
     return AVERROR_EOF;
@@ -692,13 +699,13 @@ static int ebml_read_uint(AVIOContext *pb, int size, uint64_t *num)
  */
 static int ebml_read_float(AVIOContext *pb, int size, double *num)
 {
-    if (size == 0) {
+    if (size == 0)
         *num = 0;
-    } else if (size == 4) {
+    else if (size == 4)
         *num = av_int2float(avio_rb32(pb));
-    } else if (size == 8){
+    else if (size == 8)
         *num = av_int2double(avio_rb64(pb));
-    } else
+    else
         return AVERROR_INVALIDDATA;
 
     return 0;
@@ -765,8 +772,8 @@ static int ebml_read_master(MatroskaDemuxContext *matroska, uint64_t length)
         return AVERROR(ENOSYS);
     }
 
-    level = &matroska->levels[matroska->num_levels++];
-    level->start = avio_tell(pb);
+    level         = &matroska->levels[matroska->num_levels++];
+    level->start  = avio_tell(pb);
     level->length = length;
 
     return 0;
@@ -798,7 +805,7 @@ static int matroska_ebmlnum_sint(MatroskaDemuxContext *matroska,
         return res;
 
     /* make signed (weird way) */
-    *num = unum - ((1LL << (7*res - 1)) - 1);
+    *num = unum - ((1LL << (7 * res - 1)) - 1);
 
     return res;
 }
@@ -810,15 +817,15 @@ static int ebml_parse_id(MatroskaDemuxContext *matroska, EbmlSyntax *syntax,
                          uint32_t id, void *data)
 {
     int i;
-    for (i=0; syntax[i].id; i++)
+    for (i = 0; syntax[i].id; i++)
         if (id == syntax[i].id)
             break;
     if (!syntax[i].id && id == MATROSKA_ID_CLUSTER &&
-        matroska->num_levels > 0 &&
-        matroska->levels[matroska->num_levels-1].length == 0xffffffffffffff)
+        matroska->num_levels > 0                   &&
+        matroska->levels[matroska->num_levels - 1].length == 0xffffffffffffff)
         return 0;  // we reached the end of an unknown size cluster
     if (!syntax[i].id && id != EBML_ID_VOID && id != EBML_ID_CRC32) {
-        av_log(matroska->ctx, AV_LOG_INFO, "Unknown entry 0x%X\n", id);
+        av_log(matroska->ctx, AV_LOG_INFO, "Unknown entry 0x%"PRIX32"\n", id);
         if (matroska->ctx->error_recognition & AV_EF_EXPLODE)
             return AVERROR_INVALIDDATA;
     }
@@ -833,7 +840,7 @@ static int ebml_parse(MatroskaDemuxContext *matroska, EbmlSyntax *syntax,
         int res = ebml_read_num(matroska, matroska->ctx->pb, 4, &id);
         if (res < 0)
             return res;
-        matroska->current_id = id | 1 << 7*res;
+        matroska->current_id = id | 1 << 7 * res;
     }
     return ebml_parse_id(matroska, syntax, matroska->current_id, data);
 }
@@ -843,19 +850,19 @@ static int ebml_parse_nest(MatroskaDemuxContext *matroska, EbmlSyntax *syntax,
 {
     int i, res = 0;
 
-    for (i=0; syntax[i].id; i++)
+    for (i = 0; syntax[i].id; i++)
         switch (syntax[i].type) {
         case EBML_UINT:
-            *(uint64_t *)((char *)data+syntax[i].data_offset) = syntax[i].def.u;
+            *(uint64_t *) ((char *) data + syntax[i].data_offset) = syntax[i].def.u;
             break;
         case EBML_FLOAT:
-            *(double   *)((char *)data+syntax[i].data_offset) = syntax[i].def.f;
+            *(double *) ((char *) data + syntax[i].data_offset) = syntax[i].def.f;
             break;
         case EBML_STR:
         case EBML_UTF8:
             // the default may be NULL
             if (syntax[i].def.s) {
-                uint8_t **dst = (uint8_t**)((uint8_t*)data + syntax[i].data_offset);
+                uint8_t **dst = (uint8_t **) ((uint8_t *) data + syntax[i].data_offset);
                 *dst = av_strdup(syntax[i].def.s);
                 if (!*dst)
                     return AVERROR(ENOMEM);
@@ -887,7 +894,7 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska,
     uint64_t length;
     int res;
 
-    data = (char *)data + syntax->data_offset;
+    data = (char *) data + syntax->data_offset;
     if (syntax->list_elem_size) {
         EbmlList *list = data;
         if ((res = av_reallocp_array(&list->elem,
@@ -896,7 +903,7 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska,
             list->nb_elem = 0;
             return res;
         }
-        data = (char*)list->elem + list->nb_elem*syntax->list_elem_size;
+        data = (char *) list->elem + list->nb_elem * syntax->list_elem_size;
         memset(data, 0, syntax->list_elem_size);
         list->nb_elem++;
     }
@@ -914,19 +921,31 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska,
     }
 
     switch (syntax->type) {
-    case EBML_UINT:  res = ebml_read_uint  (pb, length, data);  break;
-    case EBML_FLOAT: res = ebml_read_float (pb, length, data);  break;
+    case EBML_UINT:
+        res = ebml_read_uint(pb, length, data);
+        break;
+    case EBML_FLOAT:
+        res = ebml_read_float(pb, length, data);
+        break;
     case EBML_STR:
-    case EBML_UTF8:  res = ebml_read_ascii (pb, length, data);  break;
-    case EBML_BIN:   res = ebml_read_binary(pb, length, data);  break;
-    case EBML_NEST:  if ((res=ebml_read_master(matroska, length)) < 0)
-                         return res;
-                     if (id == MATROSKA_ID_SEGMENT)
-                         matroska->segment_start = avio_tell(matroska->ctx->pb);
-                     return ebml_parse_nest(matroska, syntax->def.n, data);
-    case EBML_PASS:  return ebml_parse_id(matroska, syntax->def.n, id, data);
-    case EBML_STOP:  return 1;
-    default:         return avio_skip(pb,length)<0 ? AVERROR(EIO) : 0;
+    case EBML_UTF8:
+        res = ebml_read_ascii(pb, length, data);
+        break;
+    case EBML_BIN:
+        res = ebml_read_binary(pb, length, data);
+        break;
+    case EBML_NEST:
+        if ((res = ebml_read_master(matroska, length)) < 0)
+            return res;
+        if (id == MATROSKA_ID_SEGMENT)
+            matroska->segment_start = avio_tell(matroska->ctx->pb);
+        return ebml_parse_nest(matroska, syntax->def.n, data);
+    case EBML_PASS:
+        return ebml_parse_id(matroska, syntax->def.n, id, data);
+    case EBML_STOP:
+        return 1;
+    default:
+        return avio_skip(pb, length) < 0 ? AVERROR(EIO) : 0;
     }
     if (res == AVERROR_INVALIDDATA)
         av_log(matroska->ctx, AV_LOG_ERROR, "Invalid element\n");
@@ -938,27 +957,32 @@ static int ebml_parse_elem(MatroskaDemuxContext *matroska,
 static void ebml_free(EbmlSyntax *syntax, void *data)
 {
     int i, j;
-    for (i=0; syntax[i].id; i++) {
-        void *data_off = (char *)data + syntax[i].data_offset;
+    for (i = 0; syntax[i].id; i++) {
+        void *data_off = (char *) data + syntax[i].data_offset;
         switch (syntax[i].type) {
         case EBML_STR:
-        case EBML_UTF8:  av_freep(data_off);                      break;
-        case EBML_BIN:   av_freep(&((EbmlBin *)data_off)->data);  break;
+        case EBML_UTF8:
+            av_freep(data_off);
+            break;
+        case EBML_BIN:
+            av_freep(&((EbmlBin *) data_off)->data);
+            break;
         case EBML_NEST:
             if (syntax[i].list_elem_size) {
                 EbmlList *list = data_off;
                 char *ptr = list->elem;
-                for (j=0; j<list->nb_elem; j++, ptr+=syntax[i].list_elem_size)
+                for (j = 0; j < list->nb_elem;
+                     j++, ptr += syntax[i].list_elem_size)
                     ebml_free(syntax[i].def.n, ptr);
                 av_free(list->elem);
             } else
                 ebml_free(syntax[i].def.n, data_off);
-        default:  break;
+        default:
+            break;
         }
     }
 }
 
-
 /*
  * Autodetecting...
  */
@@ -978,14 +1002,14 @@ static int matroska_probe(AVProbeData *p)
         len_mask >>= 1;
     }
     if (size > 8)
-      return 0;
+        return 0;
     total &= (len_mask - 1);
     while (n < size)
         total = (total << 8) | p->buf[4 + n++];
 
     /* Does the probe data contain the whole header? */
     if (p->buf_size < 4 + size + total)
-      return 0;
+        return 0;
 
     /* The header should contain a known document type. For now,
      * we don't parse the whole header but simply check for the
@@ -995,8 +1019,8 @@ static int matroska_probe(AVProbeData *p)
         int probelen = strlen(matroska_doctypes[i]);
         if (total < probelen)
             continue;
-        for (n = 4+size; n <= 4+size+total-probelen; n++)
-            if (!memcmp(p->buf+n, matroska_doctypes[i], probelen))
+        for (n = 4 + size; n <= 4 + size + total - probelen; n++)
+            if (!memcmp(p->buf + n, matroska_doctypes[i], probelen))
                 return AVPROBE_SCORE_MAX;
     }
 
@@ -1010,7 +1034,7 @@ static MatroskaTrack *matroska_find_track_by_num(MatroskaDemuxContext *matroska,
     MatroskaTrack *tracks = matroska->tracks.elem;
     int i;
 
-    for (i=0; i < matroska->tracks.nb_elem; i++)
+    for (i = 0; i < matroska->tracks.nb_elem; i++)
         if (tracks[i].num == num)
             return &tracks[i];
 
@@ -1018,13 +1042,13 @@ static MatroskaTrack *matroska_find_track_by_num(MatroskaDemuxContext *matroska,
     return NULL;
 }
 
-static int matroska_decode_buffer(uint8_t** buf, int* buf_size,
+static int matroska_decode_buffer(uint8_t **buf, int *buf_size,
                                   MatroskaTrack *track)
 {
     MatroskaTrackEncoding *encodings = track->encodings.elem;
-    uint8_t* data = *buf;
+    uint8_t *data = *buf;
     int isize = *buf_size;
-    uint8_t* pkt_data = NULL;
+    uint8_t *pkt_data = NULL;
     uint8_t av_unused *newpktdata;
     int pkt_size = isize;
     int result = 0;
@@ -1034,7 +1058,8 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size,
         return AVERROR_INVALIDDATA;
 
     switch (encodings[0].compression.algo) {
-    case MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP: {
+    case MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP:
+    {
         int header_size = encodings[0].compression.settings.size;
         uint8_t *header = encodings[0].compression.settings.data;
 
@@ -1053,15 +1078,15 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size,
 #if CONFIG_LZO
     case MATROSKA_TRACK_ENCODING_COMP_LZO:
         do {
-            olen = pkt_size *= 3;
+            olen       = pkt_size *= 3;
             newpktdata = av_realloc(pkt_data, pkt_size + AV_LZO_OUTPUT_PADDING);
             if (!newpktdata) {
                 result = AVERROR(ENOMEM);
                 goto failed;
             }
             pkt_data = newpktdata;
-            result = av_lzo1x_decode(pkt_data, &olen, data, &isize);
-        } while (result==AV_LZO_OUTPUT_FULL && pkt_size<10000000);
+            result   = av_lzo1x_decode(pkt_data, &olen, data, &isize);
+        } while (result == AV_LZO_OUTPUT_FULL && pkt_size < 10000000);
         if (result) {
             result = AVERROR_INVALIDDATA;
             goto failed;
@@ -1070,24 +1095,25 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size,
         break;
 #endif
 #if CONFIG_ZLIB
-    case MATROSKA_TRACK_ENCODING_COMP_ZLIB: {
-        z_stream zstream = {0};
+    case MATROSKA_TRACK_ENCODING_COMP_ZLIB:
+    {
+        z_stream zstream = { 0 };
         if (inflateInit(&zstream) != Z_OK)
             return -1;
-        zstream.next_in = data;
+        zstream.next_in  = data;
         zstream.avail_in = isize;
         do {
-            pkt_size *= 3;
+            pkt_size  *= 3;
             newpktdata = av_realloc(pkt_data, pkt_size);
             if (!newpktdata) {
                 inflateEnd(&zstream);
                 goto failed;
             }
-            pkt_data = newpktdata;
+            pkt_data          = newpktdata;
             zstream.avail_out = pkt_size - zstream.total_out;
-            zstream.next_out = pkt_data + zstream.total_out;
-            result = inflate(&zstream, Z_NO_FLUSH);
-        } while (result==Z_OK && pkt_size<10000000);
+            zstream.next_out  = pkt_data + zstream.total_out;
+            result            = inflate(&zstream, Z_NO_FLUSH);
+        } while (result == Z_OK && pkt_size < 10000000);
         pkt_size = zstream.total_out;
         inflateEnd(&zstream);
         if (result != Z_STREAM_END) {
@@ -1101,24 +1127,25 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size,
     }
 #endif
 #if CONFIG_BZLIB
-    case MATROSKA_TRACK_ENCODING_COMP_BZLIB: {
-        bz_stream bzstream = {0};
+    case MATROSKA_TRACK_ENCODING_COMP_BZLIB:
+    {
+        bz_stream bzstream = { 0 };
         if (BZ2_bzDecompressInit(&bzstream, 0, 0) != BZ_OK)
             return -1;
-        bzstream.next_in = data;
+        bzstream.next_in  = data;
         bzstream.avail_in = isize;
         do {
-            pkt_size *= 3;
+            pkt_size  *= 3;
             newpktdata = av_realloc(pkt_data, pkt_size);
             if (!newpktdata) {
                 BZ2_bzDecompressEnd(&bzstream);
                 goto failed;
             }
-            pkt_data = newpktdata;
+            pkt_data           = newpktdata;
             bzstream.avail_out = pkt_size - bzstream.total_out_lo32;
-            bzstream.next_out = pkt_data + bzstream.total_out_lo32;
-            result = BZ2_bzDecompress(&bzstream);
-        } while (result==BZ_OK && pkt_size<10000000);
+            bzstream.next_out  = pkt_data + bzstream.total_out_lo32;
+            result             = BZ2_bzDecompress(&bzstream);
+        } while (result == BZ_OK && pkt_size < 10000000);
         pkt_size = bzstream.total_out_lo32;
         BZ2_bzDecompressEnd(&bzstream);
         if (result != BZ_STREAM_END) {
@@ -1135,10 +1162,11 @@ static int matroska_decode_buffer(uint8_t** buf, int* buf_size,
         return AVERROR_INVALIDDATA;
     }
 
-    *buf = pkt_data;
+    *buf      = pkt_data;
     *buf_size = pkt_size;
     return 0;
- failed:
+
+failed:
     av_free(pkt_data);
     return result;
 }
@@ -1147,27 +1175,37 @@ static void matroska_fix_ass_packet(MatroskaDemuxContext *matroska,
                                     AVPacket *pkt, uint64_t display_duration)
 {
     AVBufferRef *line;
-    char *layer, *ptr = pkt->data, *end = ptr+pkt->size;
-    for (; *ptr!=',' && ptr<end-1; ptr++);
+    char *layer, *ptr = pkt->data, *end = ptr + pkt->size;
+
+    for (; *ptr != ',' && ptr < end - 1; ptr++)
+        ;
     if (*ptr == ',')
         layer = ++ptr;
-    for (; *ptr!=',' && ptr<end-1; ptr++);
+    for (; *ptr != ',' && ptr < end - 1; ptr++)
+        ;
     if (*ptr == ',') {
         int64_t end_pts = pkt->pts + display_duration;
         int sc = matroska->time_scale * pkt->pts / 10000000;
         int ec = matroska->time_scale * end_pts  / 10000000;
         int sh, sm, ss, eh, em, es, len;
-        sh = sc/360000;  sc -= 360000*sh;
-        sm = sc/  6000;  sc -=   6000*sm;
-        ss = sc/   100;  sc -=    100*ss;
-        eh = ec/360000;  ec -= 360000*eh;
-        em = ec/  6000;  ec -=   6000*em;
-        es = ec/   100;  ec -=    100*es;
+        sh     = sc / 360000;
+        sc    -= 360000 * sh;
+        sm     = sc / 6000;
+        sc    -= 6000 * sm;
+        ss     = sc / 100;
+        sc    -= 100 * ss;
+        eh     = ec / 360000;
+        ec    -= 360000 * eh;
+        em     = ec / 6000;
+        ec    -= 6000 * em;
+        es     = ec / 100;
+        ec    -= 100 * es;
         *ptr++ = '\0';
-        len = 50 + end-ptr + FF_INPUT_BUFFER_PADDING_SIZE;
+        len    = 50 + end - ptr + FF_INPUT_BUFFER_PADDING_SIZE;
         if (!(line = av_buffer_alloc(len)))
             return;
-        snprintf(line->data, len,"Dialogue: %s,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,%s\r\n",
+        snprintf(line->data, len,
+                 "Dialogue: %s,%d:%02d:%02d.%02d,%d:%02d:%02d.%02d,%s\r\n",
                  layer, sh, sm, ss, sc, eh, em, es, ec, ptr);
         av_buffer_unref(&pkt->buf);
         pkt->buf  = line;
@@ -1197,20 +1235,22 @@ static void matroska_convert_tag(AVFormatContext *s, EbmlList *list,
     char key[1024];
     int i;
 
-    for (i=0; i < list->nb_elem; i++) {
-        const char *lang = tags[i].lang && strcmp(tags[i].lang, "und") ?
-                           tags[i].lang : NULL;
+    for (i = 0; i < list->nb_elem; i++) {
+        const char *lang = tags[i].lang &&
+                           strcmp(tags[i].lang, "und") ? tags[i].lang : NULL;
 
         if (!tags[i].name) {
             av_log(s, AV_LOG_WARNING, "Skipping invalid tag with no TagName.\n");
             continue;
         }
-        if (prefix)  snprintf(key, sizeof(key), "%s/%s", prefix, tags[i].name);
-        else         av_strlcpy(key, tags[i].name, sizeof(key));
+        if (prefix)
+            snprintf(key, sizeof(key), "%s/%s", prefix, tags[i].name);
+        else
+            av_strlcpy(key, tags[i].name, sizeof(key));
         if (tags[i].def || !lang) {
-        av_dict_set(metadata, key, tags[i].string, 0);
-        if (tags[i].sub.nb_elem)
-            matroska_convert_tag(s, &tags[i].sub, metadata, key);
+            av_dict_set(metadata, key, tags[i].string, 0);
+            if (tags[i].sub.nb_elem)
+                matroska_convert_tag(s, &tags[i].sub, metadata, key);
         }
         if (lang) {
             av_strlcat(key, "-", sizeof(key));
@@ -1229,24 +1269,24 @@ static void matroska_convert_tags(AVFormatContext *s)
     MatroskaTags *tags = matroska->tags.elem;
     int i, j;
 
-    for (i=0; i < matroska->tags.nb_elem; i++) {
+    for (i = 0; i < matroska->tags.nb_elem; i++) {
         if (tags[i].target.attachuid) {
-            MatroskaAttachement *attachment = matroska->attachments.elem;
-            for (j=0; j<matroska->attachments.nb_elem; j++)
-                if (attachment[j].uid == tags[i].target.attachuid
-                    && attachment[j].stream)
+            MatroskaAttachment *attachment = matroska->attachments.elem;
+            for (j = 0; j < matroska->attachments.nb_elem; j++)
+                if (attachment[j].uid == tags[i].target.attachuid &&
+                    attachment[j].stream)
                     matroska_convert_tag(s, &tags[i].tag,
                                          &attachment[j].stream->metadata, NULL);
         } else if (tags[i].target.chapteruid) {
             MatroskaChapter *chapter = matroska->chapters.elem;
-            for (j=0; j<matroska->chapters.nb_elem; j++)
-                if (chapter[j].uid == tags[i].target.chapteruid
-                    && chapter[j].chapter)
+            for (j = 0; j < matroska->chapters.nb_elem; j++)
+                if (chapter[j].uid == tags[i].target.chapteruid &&
+                    chapter[j].chapter)
                     matroska_convert_tag(s, &tags[i].tag,
                                          &chapter[j].chapter->metadata, NULL);
         } else if (tags[i].target.trackuid) {
             MatroskaTrack *track = matroska->tracks.elem;
-            for (j=0; j<matroska->tracks.nb_elem; j++)
+            for (j = 0; j < matroska->tracks.nb_elem; j++)
                 if (track[j].uid == tags[i].target.trackuid && track[j].stream)
                     matroska_convert_tag(s, &tags[i].tag,
                                          &track[j].stream->metadata, NULL);
@@ -1257,20 +1297,21 @@ static void matroska_convert_tags(AVFormatContext *s)
     }
 }
 
-static int matroska_parse_seekhead_entry(MatroskaDemuxContext *matroska, int idx)
+static int matroska_parse_seekhead_entry(MatroskaDemuxContext *matroska,
+                                         int idx)
 {
     EbmlList *seekhead_list = &matroska->seekhead;
+    uint32_t level_up       = matroska->level_up;
+    uint32_t saved_id       = matroska->current_id;
     MatroskaSeekhead *seekhead = seekhead_list->elem;
-    uint32_t level_up = matroska->level_up;
     int64_t before_pos = avio_tell(matroska->ctx->pb);
-    uint32_t saved_id = matroska->current_id;
     MatroskaLevel level;
     int64_t offset;
     int ret = 0;
 
-    if (idx >= seekhead_list->nb_elem
-            || seekhead[idx].id == MATROSKA_ID_SEEKHEAD
-            || seekhead[idx].id == MATROSKA_ID_CLUSTER)
+    if (idx >= seekhead_list->nb_elem            ||
+        seekhead[idx].id == MATROSKA_ID_SEEKHEAD ||
+        seekhead[idx].id == MATROSKA_ID_CLUSTER)
         return 0;
 
     /* seek */
@@ -1284,25 +1325,25 @@ static int matroska_parse_seekhead_entry(MatroskaDemuxContext *matroska, int idx
                    "cannot parse further.\n", EBML_MAX_DEPTH);
             ret = AVERROR_INVALIDDATA;
         } else {
-            level.start = 0;
-            level.length = (uint64_t)-1;
+            level.start  = 0;
+            level.length = (uint64_t) -1;
             matroska->levels[matroska->num_levels] = level;
             matroska->num_levels++;
-            matroska->current_id = 0;
+            matroska->current_id                   = 0;
 
             ret = ebml_parse(matroska, matroska_segment, matroska);
 
             /* remove dummy level */
             while (matroska->num_levels) {
                 uint64_t length = matroska->levels[--matroska->num_levels].length;
-                if (length == (uint64_t)-1)
+                if (length == (uint64_t) -1)
                     break;
             }
         }
     }
     /* seek back */
     avio_seek(matroska->ctx->pb, before_pos, SEEK_SET);
-    matroska->level_up = level_up;
+    matroska->level_up   = level_up;
     matroska->current_id = saved_id;
 
     return ret;
@@ -1335,7 +1376,8 @@ static void matroska_execute_seekhead(MatroskaDemuxContext *matroska)
     }
 }
 
-static void matroska_parse_cues(MatroskaDemuxContext *matroska) {
+static void matroska_parse_cues(MatroskaDemuxContext *matroska)
+{
     EbmlList *seekhead_list = &matroska->seekhead;
     MatroskaSeekhead *seekhead = seekhead_list->elem;
     EbmlList *index_list;
@@ -1351,21 +1393,22 @@ static void matroska_parse_cues(MatroskaDemuxContext *matroska) {
     matroska_parse_seekhead_entry(matroska, i);
 
     index_list = &matroska->index;
-    index = index_list->elem;
-    if (index_list->nb_elem
-        && index[0].time > 1E14/matroska->time_scale) {
+    index      = index_list->elem;
+    if (index_list->nb_elem &&
+        index[0].time > 1E14 / matroska->time_scale) {
         av_log(matroska->ctx, AV_LOG_WARNING, "Working around broken index.\n");
         index_scale = matroska->time_scale;
     }
     for (i = 0; i < index_list->nb_elem; i++) {
-        EbmlList *pos_list = &index[i].pos;
+        EbmlList *pos_list    = &index[i].pos;
         MatroskaIndexPos *pos = pos_list->elem;
         for (j = 0; j < pos_list->nb_elem; j++) {
-            MatroskaTrack *track = matroska_find_track_by_num(matroska, pos[j].track);
+            MatroskaTrack *track = matroska_find_track_by_num(matroska,
+                                                              pos[j].track);
             if (track && track->stream)
                 av_add_index_entry(track->stream,
                                    pos[j].pos + matroska->segment_start,
-                                   index[i].time/index_scale, 0, 0,
+                                   index[i].time / index_scale, 0, 0,
                                    AVINDEX_KEYFRAME);
         }
     }
@@ -1373,10 +1416,10 @@ static void matroska_parse_cues(MatroskaDemuxContext *matroska) {
 
 static int matroska_aac_profile(char *codec_id)
 {
-    static const char * const aac_profiles[] = { "MAIN", "LC", "SSR" };
+    static const char *const aac_profiles[] = { "MAIN", "LC", "SSR" };
     int profile;
 
-    for (profile=0; profile<FF_ARRAY_ELEMS(aac_profiles); profile++)
+    for (profile = 0; profile < FF_ARRAY_ELEMS(aac_profiles); profile++)
         if (strstr(codec_id, aac_profiles[profile]))
             break;
     return profile + 1;
@@ -1386,7 +1429,7 @@ static int matroska_aac_sri(int samplerate)
 {
     int sri;
 
-    for (sri=0; sri<FF_ARRAY_ELEMS(avpriv_mpeg4audio_sample_rates); sri++)
+    for (sri = 0; sri < FF_ARRAY_ELEMS(avpriv_mpeg4audio_sample_rates); sri++)
         if (avpriv_mpeg4audio_sample_rates[sri] == samplerate)
             break;
     return sri;
@@ -1395,9 +1438,9 @@ static int matroska_aac_sri(int samplerate)
 static int matroska_read_header(AVFormatContext *s)
 {
     MatroskaDemuxContext *matroska = s->priv_data;
-    EbmlList *attachements_list = &matroska->attachments;
-    MatroskaAttachement *attachements;
-    EbmlList *chapters_list = &matroska->chapters;
+    EbmlList *attachments_list = &matroska->attachments;
+    EbmlList *chapters_list    = &matroska->chapters;
+    MatroskaAttachment *attachments;
     MatroskaChapter *chapters;
     MatroskaTrack *tracks;
     uint64_t max_start = 0;
@@ -1409,9 +1452,11 @@ static int matroska_read_header(AVFormatContext *s)
     matroska->ctx = s;
 
     /* First read the EBML header. */
-    if (ebml_parse(matroska, ebml_syntax, &ebml)
-        || ebml.version > EBML_VERSION       || ebml.max_size > sizeof(uint64_t)
-        || ebml.id_length > sizeof(uint32_t) || ebml.doctype_version > 2) {
+    if (ebml_parse(matroska, ebml_syntax, &ebml) ||
+        ebml.version         > EBML_VERSION      ||
+        ebml.max_size        > sizeof(uint64_t)  ||
+        ebml.id_length       > sizeof(uint32_t)  ||
+        ebml.doctype_version > 2) {
         av_log(matroska->ctx, AV_LOG_ERROR,
                "EBML header using unsupported features\n"
                "(EBML version %"PRIu64", doctype %s, doc version %"PRIu64")\n",
@@ -1447,12 +1492,12 @@ static int matroska_read_header(AVFormatContext *s)
     if (!matroska->time_scale)
         matroska->time_scale = 1000000;
     if (matroska->duration)
-        matroska->ctx->duration = matroska->duration * matroska->time_scale
-                                  * 1000 / AV_TIME_BASE;
+        matroska->ctx->duration = matroska->duration * matroska->time_scale *
+                                  1000 / AV_TIME_BASE;
     av_dict_set(&s->metadata, "title", matroska->title, 0);
 
     tracks = matroska->tracks.elem;
-    for (i=0; i < matroska->tracks.nb_elem; i++) {
+    for (i = 0; i < matroska->tracks.nb_elem; i++) {
         MatroskaTrack *track = &tracks[i];
         enum AVCodecID codec_id = AV_CODEC_ID_NONE;
         EbmlList *encodings_list = &track->encodings;
@@ -1476,7 +1521,7 @@ static int matroska_read_header(AVFormatContext *s)
 
         if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
             if (!track->default_duration && track->video.frame_rate > 0)
-                track->default_duration = 1000000000/track->video.frame_rate;
+                track->default_duration = 1000000000 / track->video.frame_rate;
             if (!track->video.display_width)
                 track->video.display_width = track->video.pixel_width;
             if (!track->video.display_height)
@@ -1492,19 +1537,19 @@ static int matroska_read_header(AVFormatContext *s)
             if (encodings[0].type ||
                 (
 #if CONFIG_ZLIB
-                 encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_ZLIB &&
+                 encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_ZLIB  &&
 #endif
 #if CONFIG_BZLIB
                  encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_BZLIB &&
 #endif
 #if CONFIG_LZO
-                 encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_LZO &&
+                 encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_LZO   &&
 #endif
                  encodings[0].compression.algo != MATROSKA_TRACK_ENCODING_COMP_HEADERSTRIP)) {
                 encodings[0].scope = 0;
                 av_log(matroska->ctx, AV_LOG_ERROR,
                        "Unsupported encoding type");
-            } else if (track->codec_priv.size && encodings[0].scope&2) {
+            } else if (track->codec_priv.size && encodings[0].scope & 2) {
                 uint8_t *codec_priv = track->codec_priv.data;
                 int ret = matroska_decode_buffer(&track->codec_priv.data,
                                                  &track->codec_priv.size,
@@ -1521,10 +1566,10 @@ static int matroska_read_header(AVFormatContext *s)
             }
         }
 
-        for(j=0; ff_mkv_codec_tags[j].id != AV_CODEC_ID_NONE; j++){
-            if(!strncmp(ff_mkv_codec_tags[j].str, track->codec_id,
-                        strlen(ff_mkv_codec_tags[j].str))){
-                codec_id= ff_mkv_codec_tags[j].id;
+        for (j = 0; ff_mkv_codec_tags[j].id != AV_CODEC_ID_NONE; j++) {
+            if (!strncmp(ff_mkv_codec_tags[j].str, track->codec_id,
+                         strlen(ff_mkv_codec_tags[j].str))) {
+                codec_id = ff_mkv_codec_tags[j].id;
                 break;
             }
         }
@@ -1533,96 +1578,119 @@ static int matroska_read_header(AVFormatContext *s)
         if (st == NULL)
             return AVERROR(ENOMEM);
 
-        if (!strcmp(track->codec_id, "V_MS/VFW/FOURCC")
-            && track->codec_priv.size >= 40
-            && track->codec_priv.data != NULL) {
-            track->ms_compat = 1;
+        if (!strcmp(track->codec_id, "V_MS/VFW/FOURCC") &&
+            track->codec_priv.size >= 40                &&
+            track->codec_priv.data != NULL) {
+            track->ms_compat    = 1;
             track->video.fourcc = AV_RL32(track->codec_priv.data + 16);
-            codec_id = ff_codec_get_id(ff_codec_bmp_tags, track->video.fourcc);
-            extradata_offset = 40;
-        } else if (!strcmp(track->codec_id, "A_MS/ACM")
-                   && track->codec_priv.size >= 14
-                   && track->codec_priv.data != NULL) {
+            codec_id            = ff_codec_get_id(ff_codec_bmp_tags,
+                                                  track->video.fourcc);
+            extradata_offset    = 40;
+        } else if (!strcmp(track->codec_id, "A_MS/ACM") &&
+                   track->codec_priv.size >= 14         &&
+                   track->codec_priv.data != NULL) {
             int ret;
-            ffio_init_context(&b, track->codec_priv.data, track->codec_priv.size,
+            ffio_init_context(&b, track->codec_priv.data,
+                              track->codec_priv.size,
                               0, NULL, NULL, NULL, NULL);
             ret = ff_get_wav_header(&b, st->codec, track->codec_priv.size);
             if (ret < 0)
                 return ret;
-            codec_id = st->codec->codec_id;
+            codec_id         = st->codec->codec_id;
             extradata_offset = FFMIN(track->codec_priv.size, 18);
-        } else if (!strcmp(track->codec_id, "V_QUICKTIME")
-                   && (track->codec_priv.size >= 86)
-                   && (track->codec_priv.data != NULL)) {
+        } else if (!strcmp(track->codec_id, "V_QUICKTIME") &&
+                   (track->codec_priv.size >= 86)          &&
+                   (track->codec_priv.data != NULL)) {
             track->video.fourcc = AV_RL32(track->codec_priv.data);
-            codec_id=ff_codec_get_id(ff_codec_movvideo_tags, track->video.fourcc);
+            codec_id            = ff_codec_get_id(ff_codec_movvideo_tags,
+                                                  track->video.fourcc);
         } else if (codec_id == AV_CODEC_ID_PCM_S16BE) {
             switch (track->audio.bitdepth) {
-            case  8:  codec_id = AV_CODEC_ID_PCM_U8;     break;
-            case 24:  codec_id = AV_CODEC_ID_PCM_S24BE;  break;
-            case 32:  codec_id = AV_CODEC_ID_PCM_S32BE;  break;
+            case  8:
+                codec_id = AV_CODEC_ID_PCM_U8;
+                break;
+            case 24:
+                codec_id = AV_CODEC_ID_PCM_S24BE;
+                break;
+            case 32:
+                codec_id = AV_CODEC_ID_PCM_S32BE;
+                break;
             }
         } else if (codec_id == AV_CODEC_ID_PCM_S16LE) {
             switch (track->audio.bitdepth) {
-            case  8:  codec_id = AV_CODEC_ID_PCM_U8;     break;
-            case 24:  codec_id = AV_CODEC_ID_PCM_S24LE;  break;
-            case 32:  codec_id = AV_CODEC_ID_PCM_S32LE;  break;
+            case  8:
+                codec_id = AV_CODEC_ID_PCM_U8;
+                break;
+            case 24:
+                codec_id = AV_CODEC_ID_PCM_S24LE;
+                break;
+            case 32:
+                codec_id = AV_CODEC_ID_PCM_S32LE;
+                break;
             }
-        } else if (codec_id==AV_CODEC_ID_PCM_F32LE && track->audio.bitdepth==64) {
+        } else if (codec_id == AV_CODEC_ID_PCM_F32LE &&
+                   track->audio.bitdepth == 64) {
             codec_id = AV_CODEC_ID_PCM_F64LE;
         } else if (codec_id == AV_CODEC_ID_AAC && !track->codec_priv.size) {
             int profile = matroska_aac_profile(track->codec_id);
-            int sri = matroska_aac_sri(track->audio.samplerate);
-            extradata = av_mallocz(5 + FF_INPUT_BUFFER_PADDING_SIZE);
+            int sri     = matroska_aac_sri(track->audio.samplerate);
+            extradata   = av_mallocz(5 + FF_INPUT_BUFFER_PADDING_SIZE);
             if (extradata == NULL)
                 return AVERROR(ENOMEM);
-            extradata[0] = (profile << 3) | ((sri&0x0E) >> 1);
-            extradata[1] = ((sri&0x01) << 7) | (track->audio.channels<<3);
+            extradata[0] = (profile << 3) | ((sri & 0x0E) >> 1);
+            extradata[1] = ((sri & 0x01) << 7) | (track->audio.channels << 3);
             if (strstr(track->codec_id, "SBR")) {
-                sri = matroska_aac_sri(track->audio.out_samplerate);
-                extradata[2] = 0x56;
-                extradata[3] = 0xE5;
-                extradata[4] = 0x80 | (sri<<3);
+                sri            = matroska_aac_sri(track->audio.out_samplerate);
+                extradata[2]   = 0x56;
+                extradata[3]   = 0xE5;
+                extradata[4]   = 0x80 | (sri << 3);
                 extradata_size = 5;
             } else
                 extradata_size = 2;
         } else if (codec_id == AV_CODEC_ID_ALAC && track->codec_priv.size) {
             /* Only ALAC's magic cookie is stored in Matroska's track headers.
-               Create the "atom size", "tag", and "tag version" fields the
-               decoder expects manually. */
+             * Create the "atom size", "tag", and "tag version" fields the
+             * decoder expects manually. */
             extradata_size = 12 + track->codec_priv.size;
-            extradata = av_mallocz(extradata_size + FF_INPUT_BUFFER_PADDING_SIZE);
+            extradata      = av_mallocz(extradata_size +
+                                        FF_INPUT_BUFFER_PADDING_SIZE);
             if (extradata == NULL)
                 return AVERROR(ENOMEM);
             AV_WB32(extradata, extradata_size);
             memcpy(&extradata[4], "alac", 4);
             AV_WB32(&extradata[8], 0);
             memcpy(&extradata[12], track->codec_priv.data,
-                                   track->codec_priv.size);
+                   track->codec_priv.size);
         } else if (codec_id == AV_CODEC_ID_TTA) {
             extradata_size = 30;
-            extradata = av_mallocz(extradata_size);
+            extradata      = av_mallocz(extradata_size);
             if (extradata == NULL)
                 return AVERROR(ENOMEM);
             ffio_init_context(&b, extradata, extradata_size, 1,
-                          NULL, NULL, NULL, NULL);
+                              NULL, NULL, NULL, NULL);
             avio_write(&b, "TTA1", 4);
             avio_wl16(&b, 1);
             avio_wl16(&b, track->audio.channels);
             avio_wl16(&b, track->audio.bitdepth);
             avio_wl32(&b, track->audio.out_samplerate);
-            avio_wl32(&b, matroska->ctx->duration * track->audio.out_samplerate);
-        } else if (codec_id == AV_CODEC_ID_RV10 || codec_id == AV_CODEC_ID_RV20 ||
-                   codec_id == AV_CODEC_ID_RV30 || codec_id == AV_CODEC_ID_RV40) {
+            avio_wl32(&b, matroska->ctx->duration *
+                      track->audio.out_samplerate);
+        } else if (codec_id == AV_CODEC_ID_RV10 ||
+                   codec_id == AV_CODEC_ID_RV20 ||
+                   codec_id == AV_CODEC_ID_RV30 ||
+                   codec_id == AV_CODEC_ID_RV40) {
             extradata_offset = 26;
         } else if (codec_id == AV_CODEC_ID_RA_144) {
             track->audio.out_samplerate = 8000;
-            track->audio.channels = 1;
-        } else if (codec_id == AV_CODEC_ID_RA_288 || codec_id == AV_CODEC_ID_COOK ||
-                   codec_id == AV_CODEC_ID_ATRAC3 || codec_id == AV_CODEC_ID_SIPR) {
+            track->audio.channels       = 1;
+        } else if (codec_id == AV_CODEC_ID_RA_288 ||
+                   codec_id == AV_CODEC_ID_COOK   ||
+                   codec_id == AV_CODEC_ID_ATRAC3 ||
+                   codec_id == AV_CODEC_ID_SIPR) {
             int flavor;
-            ffio_init_context(&b, track->codec_priv.data,track->codec_priv.size,
-                          0, NULL, NULL, NULL, NULL);
+            ffio_init_context(&b, track->codec_priv.data,
+                              track->codec_priv.size,
+                              0, NULL, NULL, NULL, NULL);
             avio_skip(&b, 22);
             flavor                       = avio_rb16(&b);
             track->audio.coded_framesize = avio_rb32(&b);
@@ -1630,11 +1698,14 @@ static int matroska_read_header(AVFormatContext *s)
             track->audio.sub_packet_h    = avio_rb16(&b);
             track->audio.frame_size      = avio_rb16(&b);
             track->audio.sub_packet_size = avio_rb16(&b);
-            if (flavor <= 0 || track->audio.coded_framesize <= 0 ||
-                track->audio.sub_packet_h <= 0 || track->audio.frame_size <= 0 ||
+            if (flavor                       <= 0 ||
+                track->audio.coded_framesize <= 0 ||
+                track->audio.sub_packet_h    <= 0 ||
+                track->audio.frame_size      <= 0 ||
                 track->audio.sub_packet_size <= 0)
                 return AVERROR_INVALIDDATA;
-            track->audio.buf = av_malloc(track->audio.frame_size * track->audio.sub_packet_h);
+            track->audio.buf = av_malloc(track->audio.frame_size *
+                                         track->audio.sub_packet_h);
             if (codec_id == AV_CODEC_ID_RA_288) {
                 st->codec->block_align = track->audio.coded_framesize;
                 track->codec_priv.size = 0;
@@ -1642,10 +1713,10 @@ static int matroska_read_header(AVFormatContext *s)
                 if (codec_id == AV_CODEC_ID_SIPR && flavor < 4) {
                     const int sipr_bit_rate[4] = { 6504, 8496, 5000, 16000 };
                     track->audio.sub_packet_size = ff_sipr_subpk_size[flavor];
-                    st->codec->bit_rate = sipr_bit_rate[flavor];
+                    st->codec->bit_rate          = sipr_bit_rate[flavor];
                 }
                 st->codec->block_align = track->audio.sub_packet_size;
-                extradata_offset = 78;
+                extradata_offset       = 78;
             }
         }
         track->codec_priv.size -= extradata_offset;
@@ -1656,10 +1727,11 @@ static int matroska_read_header(AVFormatContext *s)
 
         if (track->time_scale < 0.01)
             track->time_scale = 1.0;
-        avpriv_set_pts_info(st, 64, matroska->time_scale*track->time_scale, 1000*1000*1000); /* 64 bit pts in ns */
+        avpriv_set_pts_info(st, 64, matroska->time_scale * track->time_scale,
+                            1000 * 1000 * 1000);    /* 64 bit pts in ns */
 
         st->codec->codec_id = codec_id;
-        st->start_time = 0;
+        st->start_time      = 0;
         if (strcmp(track->language, "und"))
             av_dict_set(&st->metadata, "language", track->language, 0);
         av_dict_set(&st->metadata, "title", track->name, 0);
@@ -1670,13 +1742,13 @@ static int matroska_read_header(AVFormatContext *s)
             st->disposition |= AV_DISPOSITION_FORCED;
 
         if (!st->codec->extradata) {
-            if(extradata){
-                st->codec->extradata = extradata;
+            if (extradata) {
+                st->codec->extradata      = extradata;
                 st->codec->extradata_size = extradata_size;
-            } else if(track->codec_priv.data && track->codec_priv.size > 0){
+            } else if (track->codec_priv.data && track->codec_priv.size > 0) {
                 st->codec->extradata = av_mallocz(track->codec_priv.size +
                                                   FF_INPUT_BUFFER_PADDING_SIZE);
-                if(st->codec->extradata == NULL)
+                if (st->codec->extradata == NULL)
                     return AVERROR(ENOMEM);
                 st->codec->extradata_size = track->codec_priv.size;
                 memcpy(st->codec->extradata,
@@ -1688,12 +1760,12 @@ static int matroska_read_header(AVFormatContext *s)
         if (track->type == MATROSKA_TRACK_TYPE_VIDEO) {
             st->codec->codec_type = AVMEDIA_TYPE_VIDEO;
             st->codec->codec_tag  = track->video.fourcc;
-            st->codec->width  = track->video.pixel_width;
-            st->codec->height = track->video.pixel_height;
+            st->codec->width      = track->video.pixel_width;
+            st->codec->height     = track->video.pixel_height;
             av_reduce(&st->sample_aspect_ratio.num,
                       &st->sample_aspect_ratio.den,
                       st->codec->height * track->video.display_width,
-                      st->codec-> width * track->video.display_height,
+                      st->codec->width  * track->video.display_height,
                       255);
             if (st->codec->codec_id != AV_CODEC_ID_H264 &&
                 st->codec->codec_id != AV_CODEC_ID_HEVC)
@@ -1703,11 +1775,11 @@ static int matroska_read_header(AVFormatContext *s)
                           1000000000, track->default_duration, 30000);
             }
         } else if (track->type == MATROSKA_TRACK_TYPE_AUDIO) {
-            st->codec->codec_type = AVMEDIA_TYPE_AUDIO;
+            st->codec->codec_type  = AVMEDIA_TYPE_AUDIO;
             st->codec->sample_rate = track->audio.out_samplerate;
-            st->codec->channels = track->audio.channels;
+            st->codec->channels    = track->audio.channels;
             if (st->codec->codec_id != AV_CODEC_ID_AAC)
-            st->need_parsing = AVSTREAM_PARSE_HEADERS;
+                st->need_parsing = AVSTREAM_PARSE_HEADERS;
         } else if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE) {
             st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
             if (st->codec->codec_id == AV_CODEC_ID_SSA)
@@ -1715,46 +1787,48 @@ static int matroska_read_header(AVFormatContext *s)
         }
     }
 
-    attachements = attachements_list->elem;
-    for (j=0; j<attachements_list->nb_elem; j++) {
-        if (!(attachements[j].filename && attachements[j].mime &&
-              attachements[j].bin.data && attachements[j].bin.size > 0)) {
+    attachments = attachments_list->elem;
+    for (j = 0; j < attachments_list->nb_elem; j++) {
+        if (!(attachments[j].filename && attachments[j].mime &&
+              attachments[j].bin.data && attachments[j].bin.size > 0)) {
             av_log(matroska->ctx, AV_LOG_ERROR, "incomplete attachment\n");
         } else {
             AVStream *st = avformat_new_stream(s, NULL);
             if (st == NULL)
                 break;
-            av_dict_set(&st->metadata, "filename",attachements[j].filename, 0);
-            av_dict_set(&st->metadata, "mimetype", attachements[j].mime, 0);
-            st->codec->codec_id = AV_CODEC_ID_NONE;
+            av_dict_set(&st->metadata, "filename", attachments[j].filename, 0);
+            av_dict_set(&st->metadata, "mimetype", attachments[j].mime, 0);
+            st->codec->codec_id   = AV_CODEC_ID_NONE;
             st->codec->codec_type = AVMEDIA_TYPE_ATTACHMENT;
-            st->codec->extradata  = av_malloc(attachements[j].bin.size);
-            if(st->codec->extradata == NULL)
+            st->codec->extradata  = av_malloc(attachments[j].bin.size);
+            if (st->codec->extradata == NULL)
                 break;
-            st->codec->extradata_size = attachements[j].bin.size;
-            memcpy(st->codec->extradata, attachements[j].bin.data, attachements[j].bin.size);
+            st->codec->extradata_size = attachments[j].bin.size;
+            memcpy(st->codec->extradata, attachments[j].bin.data,
+                   attachments[j].bin.size);
 
-            for (i=0; ff_mkv_mime_tags[i].id != AV_CODEC_ID_NONE; i++) {
-                if (!strncmp(ff_mkv_mime_tags[i].str, attachements[j].mime,
+            for (i = 0; ff_mkv_mime_tags[i].id != AV_CODEC_ID_NONE; i++) {
+                if (!strncmp(ff_mkv_mime_tags[i].str, attachments[j].mime,
                              strlen(ff_mkv_mime_tags[i].str))) {
                     st->codec->codec_id = ff_mkv_mime_tags[i].id;
                     break;
                 }
             }
-            attachements[j].stream = st;
+            attachments[j].stream = st;
         }
     }
 
     chapters = chapters_list->elem;
-    for (i=0; i<chapters_list->nb_elem; i++)
-        if (chapters[i].start != AV_NOPTS_VALUE && chapters[i].uid
-            && (max_start==0 || chapters[i].start > max_start)) {
+    for (i = 0; i < chapters_list->nb_elem; i++)
+        if (chapters[i].start != AV_NOPTS_VALUE && chapters[i].uid &&
+            (max_start == 0 || chapters[i].start > max_start)) {
             chapters[i].chapter =
-            avpriv_new_chapter(s, chapters[i].uid, (AVRational){1, 1000000000},
-                           chapters[i].start, chapters[i].end,
-                           chapters[i].title);
+                avpriv_new_chapter(s, chapters[i].uid,
+                                   (AVRational) { 1, 1000000000 },
+                                   chapters[i].start, chapters[i].end,
+                                   chapters[i].title);
             av_dict_set(&chapters[i].chapter->metadata,
-                             "title", chapters[i].title, 0);
+                        "title", chapters[i].title, 0);
             max_start = chapters[i].start;
         }
 
@@ -1778,7 +1852,8 @@ static int matroska_deliver_packet(MatroskaDemuxContext *matroska,
             memmove(&matroska->packets[0], &matroska->packets[1],
                     (matroska->num_packets - 1) * sizeof(AVPacket *));
             newpackets = av_realloc(matroska->packets,
-                            (matroska->num_packets - 1) * sizeof(AVPacket *));
+                                    (matroska->num_packets - 1) *
+                                    sizeof(AVPacket *));
             if (newpackets)
                 matroska->packets = newpackets;
         } else {
@@ -1810,7 +1885,7 @@ static void matroska_clear_queue(MatroskaDemuxContext *matroska)
 }
 
 static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf,
-                                int* buf_size, int type,
+                                int *buf_size, int type,
                                 uint32_t **lace_buf, int *laces)
 {
     int res = 0, n, size = *buf_size;
@@ -1818,7 +1893,7 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf,
     uint32_t *lace_size;
 
     if (!type) {
-        *laces = 1;
+        *laces    = 1;
         *lace_buf = av_mallocz(sizeof(int));
         if (!*lace_buf)
             return AVERROR(ENOMEM);
@@ -1828,15 +1903,16 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf,
     }
 
     assert(size > 0);
-    *laces = *data + 1;
-    data += 1;
-    size -= 1;
+    *laces    = *data + 1;
+    data     += 1;
+    size     -= 1;
     lace_size = av_mallocz(*laces * sizeof(int));
     if (!lace_size)
         return AVERROR(ENOMEM);
 
     switch (type) {
-    case 0x1: /* Xiph lacing */ {
+    case 0x1: /* Xiph lacing */
+    {
         uint8_t temp;
         uint32_t total = 0;
         for (n = 0; res == 0 && n < *laces - 1; n++) {
@@ -1845,10 +1921,10 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf,
                     res = AVERROR_EOF;
                     break;
                 }
-                temp = *data;
+                temp          = *data;
                 lace_size[n] += temp;
-                data += 1;
-                size -= 1;
+                data         += 1;
+                size         -= 1;
                 if (temp != 0xff)
                     break;
             }
@@ -1872,7 +1948,8 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf,
             lace_size[n] = size / *laces;
         break;
 
-    case 0x3: /* EBML lacing */ {
+    case 0x3: /* EBML lacing */
+    {
         uint64_t num;
         uint64_t total;
         n = matroska_ebmlnum_uint(matroska, data, size, &num);
@@ -1895,10 +1972,10 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf,
                 res = r;
                 break;
             }
-            data += r;
-            size -= r;
+            data        += r;
+            size        -= r;
             lace_size[n] = lace_size[n - 1] + snum;
-            total += lace_size[n];
+            total       += lace_size[n];
         }
         if (size <= total) {
             res = AVERROR_INVALIDDATA;
@@ -1917,18 +1994,16 @@ static int matroska_parse_laces(MatroskaDemuxContext *matroska, uint8_t **buf,
 }
 
 static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska,
-                                   MatroskaTrack *track,
-                                   AVStream *st,
-                                   uint8_t *data, int size,
-                                   uint64_t timecode, uint64_t duration,
-                                   int64_t pos)
+                                   MatroskaTrack *track, AVStream *st,
+                                   uint8_t *data, int size, uint64_t timecode,
+                                   uint64_t duration, int64_t pos)
 {
     int a = st->codec->block_align;
     int sps = track->audio.sub_packet_size;
     int cfs = track->audio.coded_framesize;
-    int h = track->audio.sub_packet_h;
-    int y = track->audio.sub_packet_cnt;
-    int w = track->audio.frame_size;
+    int h   = track->audio.sub_packet_h;
+    int y   = track->audio.sub_packet_cnt;
+    int w   = track->audio.frame_size;
     int x;
 
     if (!track->audio.pkt_cnt) {
@@ -1940,44 +2015,47 @@ static int matroska_parse_rm_audio(MatroskaDemuxContext *matroska,
                        "Corrupt int4 RM-style audio packet size\n");
                 return AVERROR_INVALIDDATA;
             }
-            for (x=0; x<h/2; x++)
-                memcpy(track->audio.buf+x*2*w+y*cfs,
-                       data+x*cfs, cfs);
+            for (x = 0; x < h / 2; x++)
+                memcpy(track->audio.buf + x * 2 * w + y * cfs,
+                       data + x * cfs, cfs);
         } else if (st->codec->codec_id == AV_CODEC_ID_SIPR) {
             if (size < w) {
                 av_log(matroska->ctx, AV_LOG_ERROR,
                        "Corrupt sipr RM-style audio packet size\n");
                 return AVERROR_INVALIDDATA;
             }
-            memcpy(track->audio.buf + y*w, data, w);
+            memcpy(track->audio.buf + y * w, data, w);
         } else {
             if (size < sps * w / sps) {
                 av_log(matroska->ctx, AV_LOG_ERROR,
                        "Corrupt generic RM-style audio packet size\n");
                 return AVERROR_INVALIDDATA;
             }
-            for (x=0; x<w/sps; x++)
-                memcpy(track->audio.buf+sps*(h*x+((h+1)/2)*(y&1)+(y>>1)), data+x*sps, sps);
+            for (x = 0; x < w / sps; x++)
+                memcpy(track->audio.buf +
+                       sps * (h * x + ((h + 1) / 2) * (y & 1) + (y >> 1)),
+                       data + x * sps, sps);
         }
 
         if (++track->audio.sub_packet_cnt >= h) {
             if (st->codec->codec_id == AV_CODEC_ID_SIPR)
                 ff_rm_reorder_sipr_data(track->audio.buf, h, w);
             track->audio.sub_packet_cnt = 0;
-            track->audio.pkt_cnt = h*w / a;
+            track->audio.pkt_cnt        = h * w / a;
         }
     }
 
     while (track->audio.pkt_cnt) {
         AVPacket *pkt = av_mallocz(sizeof(AVPacket));
         av_new_packet(pkt, a);
-        memcpy(pkt->data, track->audio.buf
-               + a * (h*w / a - track->audio.pkt_cnt--), a);
-        pkt->pts = track->audio.buf_timecode;
+        memcpy(pkt->data,
+               track->audio.buf + a * (h * w / a - track->audio.pkt_cnt--),
+               a);
+        pkt->pts                  = track->audio.buf_timecode;
         track->audio.buf_timecode = AV_NOPTS_VALUE;
-        pkt->pos = pos;
-        pkt->stream_index = st->index;
-        dynarray_add(&matroska->packets,&matroska->num_packets,pkt);
+        pkt->pos                  = pos;
+        pkt->stream_index         = st->index;
+        dynarray_add(&matroska->packets, &matroska->num_packets, pkt);
     }
 
     return 0;
@@ -2020,8 +2098,8 @@ static int matroska_parse_wavpack(MatroskaTrack *track, uint8_t *src,
                 goto fail;
             }
             blocksize = AV_RL32(src);
-            src    += 4;
-            srclen -= 4;
+            src      += 4;
+            srclen   -= 4;
         } else
             blocksize = srclen;
 
@@ -2038,16 +2116,16 @@ static int matroska_parse_wavpack(MatroskaTrack *track, uint8_t *src,
         dst     = tmp;
         dstlen += blocksize + 32;
 
-        AV_WL32(dst + offset,      MKTAG('w', 'v', 'p', 'k')); // tag
-        AV_WL32(dst + offset + 4,  blocksize + 24);            // blocksize - 8
-        AV_WL16(dst + offset + 8,  ver);                       // version
-        AV_WL16(dst + offset + 10, 0);                         // track/index_no
-        AV_WL32(dst + offset + 12, 0);                         // total samples
-        AV_WL32(dst + offset + 16, 0);                         // block index
-        AV_WL32(dst + offset + 20, samples);                   // number of samples
-        AV_WL32(dst + offset + 24, flags);                     // flags
-        AV_WL32(dst + offset + 28, crc);                       // crc
-        memcpy (dst + offset + 32, src, blocksize);            // block data
+        AV_WL32(dst + offset, MKTAG('w', 'v', 'p', 'k'));   // tag
+        AV_WL32(dst + offset +  4, blocksize + 24);         // blocksize - 8
+        AV_WL16(dst + offset +  8, ver);                    // version
+        AV_WL16(dst + offset + 10, 0);                      // track/index_no
+        AV_WL32(dst + offset + 12, 0);                      // total samples
+        AV_WL32(dst + offset + 16, 0);                      // block index
+        AV_WL32(dst + offset + 20, samples);                // number of samples
+        AV_WL32(dst + offset + 24, flags);                  // flags
+        AV_WL32(dst + offset + 28, crc);                    // crc
+        memcpy(dst + offset + 32, src, blocksize);          // block data
 
         src    += blocksize;
         srclen -= blocksize;
@@ -2065,8 +2143,7 @@ fail:
 }
 
 static int matroska_parse_frame(MatroskaDemuxContext *matroska,
-                                MatroskaTrack *track,
-                                AVStream *st,
+                                MatroskaTrack *track, AVStream *st,
                                 uint8_t *data, int pkt_size,
                                 uint64_t timecode, uint64_t duration,
                                 int64_t pos, int is_keyframe)
@@ -2086,7 +2163,8 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
         uint8_t *wv_data;
         res = matroska_parse_wavpack(track, pkt_data, &wv_data, &pkt_size);
         if (res < 0) {
-            av_log(matroska->ctx, AV_LOG_ERROR, "Error parsing a wavpack block.\n");
+            av_log(matroska->ctx, AV_LOG_ERROR,
+                   "Error parsing a wavpack block.\n");
             goto fail;
         }
         if (pkt_data != data)
@@ -2115,7 +2193,7 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
     if (pkt_data != data)
         av_free(pkt_data);
 
-    pkt->flags = is_keyframe;
+    pkt->flags        = is_keyframe;
     pkt->stream_index = st->index;
 
     if (track->ms_compat)
@@ -2131,18 +2209,19 @@ static int matroska_parse_frame(MatroskaDemuxContext *matroska,
     if (st->codec->codec_id == AV_CODEC_ID_SSA)
         matroska_fix_ass_packet(matroska, pkt, duration);
 
-    if (matroska->prev_pkt &&
-        timecode != AV_NOPTS_VALUE &&
-        matroska->prev_pkt->pts == timecode &&
-        matroska->prev_pkt->stream_index == st->index &&
+    if (matroska->prev_pkt                                 &&
+        timecode                         != AV_NOPTS_VALUE &&
+        matroska->prev_pkt->pts          == timecode       &&
+        matroska->prev_pkt->stream_index == st->index      &&
         st->codec->codec_id == AV_CODEC_ID_SSA)
         matroska_merge_packets(matroska->prev_pkt, pkt);
     else {
-        dynarray_add(&matroska->packets,&matroska->num_packets,pkt);
+        dynarray_add(&matroska->packets, &matroska->num_packets, pkt);
         matroska->prev_pkt = pkt;
     }
 
     return 0;
+
 fail:
     if (pkt_data != data)
         av_freep(&pkt_data);
@@ -2182,23 +2261,25 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
         return res;
 
     block_time = AV_RB16(data);
-    data += 2;
-    flags = *data++;
-    size -= 3;
+    data      += 2;
+    flags      = *data++;
+    size      -= 3;
     if (is_keyframe == -1)
         is_keyframe = flags & 0x80 ? AV_PKT_FLAG_KEY : 0;
 
-    if (cluster_time != (uint64_t)-1
-        && (block_time >= 0 || cluster_time >= -block_time)) {
+    if (cluster_time != (uint64_t) -1 &&
+        (block_time >= 0 || cluster_time >= -block_time)) {
         timecode = cluster_time + block_time;
-        if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE
-            && timecode < track->end_timecode)
+        if (track->type == MATROSKA_TRACK_TYPE_SUBTITLE &&
+            timecode < track->end_timecode)
             is_keyframe = 0;  /* overlapping subtitles are not key frame */
         if (is_keyframe)
-            av_add_index_entry(st, cluster_pos, timecode, 0,0,AVINDEX_KEYFRAME);
+            av_add_index_entry(st, cluster_pos, timecode, 0, 0,
+                               AVINDEX_KEYFRAME);
     }
 
-    if (matroska->skip_to_keyframe && track->type != MATROSKA_TRACK_TYPE_SUBTITLE) {
+    if (matroska->skip_to_keyframe &&
+        track->type != MATROSKA_TRACK_TYPE_SUBTITLE) {
         if (!is_keyframe || timecode < matroska->skip_to_timecode)
             return res;
         matroska->skip_to_keyframe = 0;
@@ -2217,7 +2298,7 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
                    "Incorrect block_duration, possibly corrupted container");
         }
     } else {
-        duration = track->default_duration / matroska->time_scale;
+        duration       = track->default_duration / matroska->time_scale;
         block_duration = duration * laces;
     }
 
@@ -2227,21 +2308,19 @@ static int matroska_parse_block(MatroskaDemuxContext *matroska, uint8_t *data,
 
     for (n = 0; n < laces; n++) {
         if ((st->codec->codec_id == AV_CODEC_ID_RA_288 ||
-             st->codec->codec_id == AV_CODEC_ID_COOK ||
-             st->codec->codec_id == AV_CODEC_ID_SIPR ||
+             st->codec->codec_id == AV_CODEC_ID_COOK   ||
+             st->codec->codec_id == AV_CODEC_ID_SIPR   ||
              st->codec->codec_id == AV_CODEC_ID_ATRAC3) &&
-             st->codec->block_align && track->audio.sub_packet_size) {
-
+            st->codec->block_align && track->audio.sub_packet_size) {
             res = matroska_parse_rm_audio(matroska, track, st, data,
                                           lace_size[n],
                                           timecode, duration, pos);
             if (res)
                 goto end;
-
         } else {
             res = matroska_parse_frame(matroska, track, st, data, lace_size[n],
-                                      timecode, duration,
-                                      pos, !n? is_keyframe : 0);
+                                       timecode, duration, pos,
+                                       !n ? is_keyframe : 0);
             if (res)
                 goto end;
         }
@@ -2271,8 +2350,8 @@ static int matroska_parse_cluster_incremental(MatroskaDemuxContext *matroska)
         ebml_free(matroska_cluster, &matroska->current_cluster);
         memset(&matroska->current_cluster, 0, sizeof(MatroskaCluster));
         matroska->current_cluster_num_blocks = 0;
-        matroska->current_cluster_pos = avio_tell(matroska->ctx->pb);
-        matroska->prev_pkt = NULL;
+        matroska->current_cluster_pos        = avio_tell(matroska->ctx->pb);
+        matroska->prev_pkt                   = NULL;
         /* sizeof the ID which was already read */
         if (matroska->current_id)
             matroska->current_cluster_pos -= 4;
@@ -2288,26 +2367,26 @@ static int matroska_parse_cluster_incremental(MatroskaDemuxContext *matroska)
 
     if (!res &&
         matroska->current_cluster_num_blocks <
-            matroska->current_cluster.blocks.nb_elem) {
+        matroska->current_cluster.blocks.nb_elem) {
         blocks_list = &matroska->current_cluster.blocks;
-        blocks = blocks_list->elem;
+        blocks      = blocks_list->elem;
 
         matroska->current_cluster_num_blocks = blocks_list->nb_elem;
-        i = blocks_list->nb_elem - 1;
+        i                                    = blocks_list->nb_elem - 1;
         if (blocks[i].bin.size > 0 && blocks[i].bin.data) {
             int is_keyframe = blocks[i].non_simple ? !blocks[i].reference : -1;
             if (!blocks[i].non_simple)
                 blocks[i].duration = AV_NOPTS_VALUE;
-            res = matroska_parse_block(matroska,
-                                       blocks[i].bin.data, blocks[i].bin.size,
-                                       blocks[i].bin.pos,
+            res = matroska_parse_block(matroska, blocks[i].bin.data,
+                                       blocks[i].bin.size, blocks[i].bin.pos,
                                        matroska->current_cluster.timecode,
                                        blocks[i].duration, is_keyframe,
                                        matroska->current_cluster_pos);
         }
     }
 
-    if (res < 0)  matroska->done = 1;
+    if (res < 0)
+        matroska->done = 1;
     return res;
 }
 
@@ -2318,25 +2397,25 @@ static int matroska_parse_cluster(MatroskaDemuxContext *matroska)
     MatroskaBlock *blocks;
     int i, res;
     int64_t pos;
+
     if (!matroska->contains_ssa)
         return matroska_parse_cluster_incremental(matroska);
     pos = avio_tell(matroska->ctx->pb);
     matroska->prev_pkt = NULL;
     if (matroska->current_id)
         pos -= 4;  /* sizeof the ID which was already read */
-    res = ebml_parse(matroska, matroska_clusters, &cluster);
+    res         = ebml_parse(matroska, matroska_clusters, &cluster);
     blocks_list = &cluster.blocks;
-    blocks = blocks_list->elem;
-    for (i=0; i<blocks_list->nb_elem && !res; i++)
+    blocks      = blocks_list->elem;
+    for (i = 0; i < blocks_list->nb_elem && !res; i++)
         if (blocks[i].bin.size > 0 && blocks[i].bin.data) {
             int is_keyframe = blocks[i].non_simple ? !blocks[i].reference : -1;
             if (!blocks[i].non_simple)
                 blocks[i].duration = AV_NOPTS_VALUE;
-            res=matroska_parse_block(matroska,
-                                     blocks[i].bin.data, blocks[i].bin.size,
-                                     blocks[i].bin.pos,  cluster.timecode,
-                                     blocks[i].duration, is_keyframe,
-                                     pos);
+            res = matroska_parse_block(matroska, blocks[i].bin.data,
+                                       blocks[i].bin.size, blocks[i].bin.pos,
+                                       cluster.timecode, blocks[i].duration,
+                                       is_keyframe, pos);
         }
     ebml_free(matroska_cluster, &cluster);
     return res;
@@ -2382,7 +2461,8 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
     timestamp = FFMAX(timestamp, st->index_entries[0].timestamp);
 
     if ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) {
-        avio_seek(s->pb, st->index_entries[st->nb_index_entries-1].pos, SEEK_SET);
+        avio_seek(s->pb, st->index_entries[st->nb_index_entries - 1].pos,
+                  SEEK_SET);
         matroska->current_id = 0;
         while ((index = av_index_search_timestamp(st, timestamp, flags)) < 0) {
             matroska_clear_queue(matroska);
@@ -2396,26 +2476,29 @@ static int matroska_read_seek(AVFormatContext *s, int stream_index,
         return 0;
 
     index_min = index;
-    for (i=0; i < matroska->tracks.nb_elem; i++) {
-        tracks[i].audio.pkt_cnt = 0;
+    for (i = 0; i < matroska->tracks.nb_elem; i++) {
+        tracks[i].audio.pkt_cnt        = 0;
         tracks[i].audio.sub_packet_cnt = 0;
-        tracks[i].audio.buf_timecode = AV_NOPTS_VALUE;
-        tracks[i].end_timecode = 0;
-        if (tracks[i].type == MATROSKA_TRACK_TYPE_SUBTITLE
-            && !tracks[i].stream->discard != AVDISCARD_ALL) {
-            index_sub = av_index_search_timestamp(tracks[i].stream, st->index_entries[index].timestamp, AVSEEK_FLAG_BACKWARD);
-            if (index_sub >= 0
-                && st->index_entries[index_sub].pos < st->index_entries[index_min].pos
-                && st->index_entries[index].timestamp - st->index_entries[index_sub].timestamp < 30000000000/matroska->time_scale)
+        tracks[i].audio.buf_timecode   = AV_NOPTS_VALUE;
+        tracks[i].end_timecode         = 0;
+        if (tracks[i].type == MATROSKA_TRACK_TYPE_SUBTITLE &&
+            !tracks[i].stream->discard != AVDISCARD_ALL) {
+            index_sub = av_index_search_timestamp(
+                tracks[i].stream, st->index_entries[index].timestamp,
+                AVSEEK_FLAG_BACKWARD);
+            if (index_sub >= 0 &&
+                st->index_entries[index_sub].pos < st->index_entries[index_min].pos &&
+                st->index_entries[index].timestamp -
+                st->index_entries[index_sub].timestamp < 30000000000 / matroska->time_scale)
                 index_min = index_sub;
         }
     }
 
     avio_seek(s->pb, st->index_entries[index_min].pos, SEEK_SET);
-    matroska->current_id = 0;
+    matroska->current_id       = 0;
     matroska->skip_to_keyframe = !(flags & AVSEEK_FLAG_ANY);
     matroska->skip_to_timecode = st->index_entries[index].timestamp;
-    matroska->done = 0;
+    matroska->done             = 0;
     ff_update_cur_dts(s, st, st->index_entries[index].timestamp);
     return 0;
 }
@@ -2428,7 +2511,7 @@ static int matroska_read_close(AVFormatContext *s)
 
     matroska_clear_queue(matroska);
 
-    for (n=0; n < matroska->tracks.nb_elem; n++)
+    for (n = 0; n < matroska->tracks.nb_elem; n++)
         if (tracks[n].type == MATROSKA_TRACK_TYPE_AUDIO)
             av_free(tracks[n].audio.buf);
     ebml_free(matroska_cluster, &matroska->current_cluster);
diff --git a/deps/libav/libavformat/matroskaenc.c b/deps/libav/libavformat/matroskaenc.c
index cc645a5..fad1ec4 100644
--- a/deps/libav/libavformat/matroskaenc.c
+++ b/deps/libav/libavformat/matroskaenc.c
@@ -22,6 +22,7 @@
 #include <stdint.h>
 
 #include "avc.h"
+#include "hevc.h"
 #include "avformat.h"
 #include "avlanguage.h"
 #include "flacenc.h"
@@ -500,6 +501,8 @@ static int mkv_write_codecprivate(AVFormatContext *s, AVIOContext *pb, AVCodecCo
             ret = put_wv_codecpriv(dyn_cp, codec);
         else if (codec->codec_id == AV_CODEC_ID_H264)
             ret = ff_isom_write_avcc(dyn_cp, codec->extradata, codec->extradata_size);
+        else if (codec->codec_id == AV_CODEC_ID_HEVC)
+            ret = ff_isom_write_hvcc(dyn_cp, codec->extradata, codec->extradata_size, 0);
         else if (codec->codec_id == AV_CODEC_ID_ALAC) {
             if (codec->extradata_size < 36) {
                 av_log(s, AV_LOG_ERROR,
@@ -805,7 +808,8 @@ static int mkv_write_tag(AVFormatContext *s, AVDictionary *m, unsigned int eleme
     end_ebml_master(s->pb, targets);
 
     while ((t = av_dict_get(m, "", t, AV_DICT_IGNORE_SUFFIX)))
-        if (av_strcasecmp(t->key, "title"))
+        if (av_strcasecmp(t->key, "title") &&
+            av_strcasecmp(t->key, "encoding_tool"))
             mkv_write_simpletag(s->pb, t);
 
     end_ebml_master(s->pb, tag);
@@ -965,7 +969,10 @@ static int mkv_write_header(AVFormatContext *s)
             segment_uid[i] = av_lfg_get(&lfg);
 
         put_ebml_string(pb, MATROSKA_ID_MUXINGAPP , LIBAVFORMAT_IDENT);
-        put_ebml_string(pb, MATROSKA_ID_WRITINGAPP, LIBAVFORMAT_IDENT);
+        if ((tag = av_dict_get(s->metadata, "encoding_tool", NULL, 0)))
+            put_ebml_string(pb, MATROSKA_ID_WRITINGAPP, tag->value);
+        else
+            put_ebml_string(pb, MATROSKA_ID_WRITINGAPP, LIBAVFORMAT_IDENT);
         put_ebml_binary(pb, MATROSKA_ID_SEGMENTUID, segment_uid, 16);
     }
 
@@ -1160,6 +1167,10 @@ static void mkv_write_block(AVFormatContext *s, AVIOContext *pb,
     if (codec->codec_id == AV_CODEC_ID_H264 && codec->extradata_size > 0 &&
         (AV_RB24(codec->extradata) == 1 || AV_RB32(codec->extradata) == 1))
         ff_avc_parse_nal_units_buf(pkt->data, &data, &size);
+    else if (codec->codec_id == AV_CODEC_ID_HEVC && codec->extradata_size > 6 &&
+             (AV_RB24(codec->extradata) == 1 || AV_RB32(codec->extradata) == 1))
+        /* extradata is Annex B, assume the bitstream is too and convert it */
+        ff_hevc_annexb2mp4_buf(pkt->data, &data, &size, 0, NULL);
     else if (codec->codec_id == AV_CODEC_ID_WAVPACK) {
         int ret = mkv_strip_wavpack(pkt->data, &data, &size);
         if (ret < 0) {
diff --git a/deps/libav/libavformat/mov.c b/deps/libav/libavformat/mov.c
index dc5b42b..6375847 100644
--- a/deps/libav/libavformat/mov.c
+++ b/deps/libav/libavformat/mov.c
@@ -23,6 +23,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <inttypes.h>
 #include <limits.h>
 #include <stdint.h>
 
@@ -298,7 +299,7 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     if (parse)
         parse(c, pb, str_size, key);
     else {
-        if (data_type == 3 || (data_type == 0 && langcode < 0x800)) { // MAC Encoded
+        if (data_type == 3 || (data_type == 0 && (langcode < 0x400 || langcode == 0x7fff))) { // MAC Encoded
             mov_read_mac_string(c, pb, str_size, str, sizeof(str));
         } else {
             avio_read(pb, str, str_size);
@@ -650,7 +651,7 @@ static int mov_read_ftyp(MOVContext *c, AVIOContext *pb, MOVAtom atom)
     av_log(c->fc, AV_LOG_DEBUG, "ISO: File Type Major Brand: %.4s\n",(char *)&type);
     av_dict_set(&c->fc->metadata, "major_brand", type, 0);
     minor_ver = avio_rb32(pb); /* minor version */
-    snprintf(minor_ver_str, sizeof(minor_ver_str), "%d", minor_ver);
+    snprintf(minor_ver_str, sizeof(minor_ver_str), "%"PRIu32"", minor_ver);
     av_dict_set(&c->fc->metadata, "minor_version", minor_ver_str, 0);
 
     comp_brand_size = atom.size - 8;
@@ -1441,7 +1442,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
             avio_rb16(pb); /* reserved */
             dref_id = avio_rb16(pb);
         } else {
-            av_log(c->fc, AV_LOG_ERROR, "invalid size %d in stsd\n", size);
+            av_log(c->fc, AV_LOG_ERROR, "invalid size %"PRIu32" in stsd\n", size);
             return AVERROR_INVALIDDATA;
         }
 
@@ -1454,7 +1455,7 @@ int ff_mov_read_stsd_entries(MOVContext *c, AVIOContext *pb, int entries)
 
         id = mov_codec_id(st, format);
 
-        av_dlog(c->fc, "size=%d 4CC= %c%c%c%c codec_type=%d\n", size,
+        av_dlog(c->fc, "size=%"PRIu32" 4CC= %"PRIu8"%"PRIu8"%"PRIu8"%"PRIu8" codec_type=%d\n", size,
                 (format >> 0) & 0xff, (format >> 8) & 0xff, (format >> 16) & 0xff,
                 (format >> 24) & 0xff, st->codec->codec_type);
 
diff --git a/deps/libav/libavformat/movenc.c b/deps/libav/libavformat/movenc.c
index 43a1647..2ae3475 100644
--- a/deps/libav/libavformat/movenc.c
+++ b/deps/libav/libavformat/movenc.c
@@ -39,6 +39,7 @@
 #include "libavutil/mathematics.h"
 #include "libavutil/opt.h"
 #include "libavutil/dict.h"
+#include "hevc.h"
 #include "rtpenc.h"
 #include "mov_chan.h"
 
@@ -685,6 +686,16 @@ static int mov_write_avcc_tag(AVIOContext *pb, MOVTrack *track)
     return update_size(pb, pos);
 }
 
+static int mov_write_hvcc_tag(AVIOContext *pb, MOVTrack *track)
+{
+    int64_t pos = avio_tell(pb);
+
+    avio_wb32(pb, 0);
+    ffio_wfourcc(pb, "hvcC");
+    ff_isom_write_hvcc(pb, track->vos_data, track->vos_len, 0);
+    return update_size(pb, pos);
+}
+
 /* also used by all avid codecs (dv, imx, meridien) and their variants */
 static int mov_write_avid_tag(AVIOContext *pb, MOVTrack *track)
 {
@@ -741,6 +752,7 @@ static int mp4_get_codec_tag(AVFormatContext *s, MOVTrack *track)
         return 0;
 
     if      (track->enc->codec_id == AV_CODEC_ID_H264)      tag = MKTAG('a','v','c','1');
+    else if (track->enc->codec_id == AV_CODEC_ID_HEVC)      tag = MKTAG('h','e','v','1');
     else if (track->enc->codec_id == AV_CODEC_ID_AC3)       tag = MKTAG('a','c','-','3');
     else if (track->enc->codec_id == AV_CODEC_ID_DIRAC)     tag = MKTAG('d','r','a','c');
     else if (track->enc->codec_id == AV_CODEC_ID_MOV_TEXT)  tag = MKTAG('t','x','3','g');
@@ -1035,6 +1047,8 @@ static int mov_write_video_tag(AVIOContext *pb, MOVTrack *track)
         mov_write_svq3_tag(pb);
     else if (track->enc->codec_id == AV_CODEC_ID_DNXHD)
         mov_write_avid_tag(pb, track);
+    else if (track->enc->codec_id == AV_CODEC_ID_HEVC)
+        mov_write_hvcc_tag(pb, track);
     else if (track->enc->codec_id == AV_CODEC_ID_H264) {
         mov_write_avcc_tag(pb, track);
         if (track->mode == MODE_IPOD)
@@ -1858,7 +1872,8 @@ static int mov_write_ilst_tag(AVIOContext *pb, MOVMuxContext *mov,
     mov_write_string_metadata(s, pb, "\251wrt", "composer" , 1);
     mov_write_string_metadata(s, pb, "\251alb", "album"    , 1);
     mov_write_string_metadata(s, pb, "\251day", "date"     , 1);
-    mov_write_string_tag(pb, "\251too", LIBAVFORMAT_IDENT, 0, 1);
+    if (!mov_write_string_metadata(s, pb, "\251too", "encoding_tool", 1))
+        mov_write_string_tag(pb, "\251too", LIBAVFORMAT_IDENT, 0, 1);
     mov_write_string_metadata(s, pb, "\251cmt", "comment"  , 1);
     mov_write_string_metadata(s, pb, "\251gen", "genre"    , 1);
     mov_write_string_metadata(s, pb, "\251cpy", "copyright", 1);
@@ -2925,6 +2940,15 @@ int ff_mov_write_packet(AVFormatContext *s, AVPacket *pkt)
         } else {
             size = ff_avc_parse_nal_units(pb, pkt->data, pkt->size);
         }
+    } else if (enc->codec_id == AV_CODEC_ID_HEVC && trk->vos_len > 6 &&
+               (AV_RB24(trk->vos_data) == 1 || AV_RB32(trk->vos_data) == 1)) {
+        /* extradata is Annex B, assume the bitstream is too and convert it */
+        if (trk->hint_track >= 0 && trk->hint_track < mov->nb_streams) {
+            ff_hevc_annexb2mp4_buf(pkt->data, &reformatted_data, &size, 0, NULL);
+            avio_write(pb, reformatted_data, size);
+        } else {
+            size = ff_hevc_annexb2mp4(pb, pkt->data, pkt->size, 0, NULL);
+        }
     } else {
         avio_write(pb, pkt->data, size);
     }
@@ -3315,15 +3339,13 @@ static int mov_write_header(AVFormatContext *s)
 
     enable_tracks(s);
 
-    if (mov->mode == MODE_ISM) {
+    if (mov->flags & FF_MOV_FLAG_FRAGMENT) {
         /* If no fragmentation options have been set, set a default. */
         if (!(mov->flags & (FF_MOV_FLAG_FRAG_KEYFRAME |
                             FF_MOV_FLAG_FRAG_CUSTOM)) &&
             !mov->max_fragment_duration && !mov->max_fragment_size)
             mov->flags |= FF_MOV_FLAG_FRAG_KEYFRAME;
-    }
-
-    if (!(mov->flags & FF_MOV_FLAG_FRAGMENT)) {
+    } else {
         if (mov->flags & FF_MOV_FLAG_FASTSTART)
             mov->reserved_moov_pos = avio_tell(pb);
         mov_write_mdat_tag(pb, mov);
diff --git a/deps/libav/libavformat/mpegts.c b/deps/libav/libavformat/mpegts.c
index 3f828b4..5a3561f 100644
--- a/deps/libav/libavformat/mpegts.c
+++ b/deps/libav/libavformat/mpegts.c
@@ -28,7 +28,6 @@
 #include "libavutil/opt.h"
 #include "libavcodec/bytestream.h"
 #include "libavcodec/get_bits.h"
-#include "libavcodec/mathops.h"
 #include "avformat.h"
 #include "mpegts.h"
 #include "internal.h"
@@ -45,6 +44,13 @@
 
 #define MAX_MP4_DESCR_COUNT 16
 
+#define MOD_UNLIKELY(modulus, dividend, divisor, prev_dividend) \
+    do { \
+        if ((prev_dividend) == 0 || (dividend) - (prev_dividend) != (divisor)) \
+            (modulus) = (dividend) % (divisor); \
+        (prev_dividend) = (dividend); \
+    } while (0)
+
 enum MpegTSFilterType {
     MPEGTS_PES,
     MPEGTS_SECTION,
@@ -134,6 +140,8 @@ struct MpegTSContext {
 static const AVOption options[] = {
     {"compute_pcr", "Compute exact PCR for each transport stream packet.", offsetof(MpegTSContext, mpeg2ts_compute_pcr), AV_OPT_TYPE_INT,
      {.i64 = 0}, 0, 1, AV_OPT_FLAG_DECODING_PARAM },
+    {"ts_packetsize", "Output option carrying the raw packet size.", offsetof(MpegTSContext, raw_packet_size), AV_OPT_TYPE_INT,
+     {.i64 = 0}, 0, 0, AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_EXPORT | AV_OPT_FLAG_READONLY },
     { NULL },
 };
 
diff --git a/deps/libav/libavformat/mvi.c b/deps/libav/libavformat/mvi.c
index 69b0aed..03a1f40 100644
--- a/deps/libav/libavformat/mvi.c
+++ b/deps/libav/libavformat/mvi.c
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <inttypes.h>
+
 #include "libavutil/channel_layout.h"
 #include "avformat.h"
 #include "internal.h"
@@ -95,7 +97,8 @@ static int read_header(AVFormatContext *s)
 
     mvi->audio_frame_size   = ((uint64_t)mvi->audio_data_size << MVI_FRAC_BITS) / frames_count;
     if (mvi->audio_frame_size <= 1 << MVI_FRAC_BITS - 1) {
-        av_log(s, AV_LOG_ERROR, "Invalid audio_data_size (%d) or frames_count (%d)\n",
+        av_log(s, AV_LOG_ERROR,
+               "Invalid audio_data_size (%"PRIu32") or frames_count (%u)\n",
                mvi->audio_data_size, frames_count);
         return AVERROR_INVALIDDATA;
     }
diff --git a/deps/libav/libavformat/mxf.c b/deps/libav/libavformat/mxf.c
index 040d8a2..01018d3 100644
--- a/deps/libav/libavformat/mxf.c
+++ b/deps/libav/libavformat/mxf.c
@@ -41,6 +41,8 @@ const MXFCodecUL ff_mxf_codec_uls[] = {
     { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x02,0x01,0x02,0x00 }, 13,    AV_CODEC_ID_DVVIDEO }, /* DV25 IEC PAL */
     { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x07,0x04,0x01,0x02,0x02,0x03,0x01,0x01,0x00 }, 14,   AV_CODEC_ID_JPEG2000 }, /* JPEG2000 Codestream */
     { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x01,0x7F,0x00,0x00,0x00 }, 13,   AV_CODEC_ID_RAWVIDEO }, /* Uncompressed */
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x01,0x01,0x02,0x01,0x00 }, 15,   AV_CODEC_ID_RAWVIDEO }, /* Uncompressed 422 8-bit */
+    { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x71,0x00,0x00,0x00 }, 13,      AV_CODEC_ID_DNXHD }, /* SMPTE VC-3/DNxHD */
     { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x01,0x04,0x01,0x02,0x02,0x03,0x02,0x00,0x00 }, 14,      AV_CODEC_ID_DNXHD }, /* SMPTE VC-3/DNxHD */
     { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x02,0x01,0x32,0x00,0x00 }, 14,       AV_CODEC_ID_H264 }, /* H.264/MPEG-4 AVC Intra */
     { { 0x06,0x0E,0x2B,0x34,0x04,0x01,0x01,0x0A,0x04,0x01,0x02,0x01,0x01,0x02,0x02,0x00 }, 15,       AV_CODEC_ID_V210 }, /* V210 */
@@ -104,3 +106,43 @@ int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum AVPixelFormat *
 
     return -1;
 }
+
+static const MXFSamplesPerFrame mxf_spf[] = {
+    { { 1001, 24000 }, { 2002, 0,    0,    0,    0,    0 } }, // FILM 23.976
+    { { 1, 24},        { 2000, 0,    0,    0,    0,    0 } }, // FILM 24
+    { { 1001, 30000 }, { 1602, 1601, 1602, 1601, 1602, 0 } }, // NTSC 29.97
+    { { 1001, 60000 }, { 801,  801,  801,  801,  800,  0 } }, // NTSC 59.94
+    { { 1, 25 },       { 1920, 0,    0,    0,    0,    0 } }, // PAL 25
+    { { 1, 50 },       { 960,  0,    0,    0,    0,    0 } }, // PAL 50
+};
+
+static const AVRational mxf_time_base[] = {
+    { 1001, 24000 },
+    { 1, 24},
+    { 1001, 30000 },
+    { 1001, 60000 },
+    { 1, 25 },
+    { 1, 50 },
+    { 0, 0}
+};
+
+const MXFSamplesPerFrame *ff_mxf_get_samples_per_frame(AVFormatContext *s,
+                                                       AVRational time_base)
+{
+    int idx = av_find_nearest_q_idx(time_base, mxf_time_base);
+    AVRational diff = av_sub_q(time_base, mxf_time_base[idx]);
+
+    diff.num = abs(diff.num);
+
+    if (av_cmp_q(diff, (AVRational){1, 1000}) >= 0)
+        return NULL;
+
+    if (av_cmp_q(time_base, mxf_time_base[idx]))
+        av_log(s, AV_LOG_WARNING,
+               "%d/%d input time base matched %d/%d container time base\n",
+               time_base.num, time_base.den,
+               mxf_spf[idx].time_base.num,
+               mxf_spf[idx].time_base.den);
+
+    return &mxf_spf[idx];
+}
diff --git a/deps/libav/libavformat/mxf.h b/deps/libav/libavformat/mxf.h
index 773f30f..265b0cf 100644
--- a/deps/libav/libavformat/mxf.h
+++ b/deps/libav/libavformat/mxf.h
@@ -21,6 +21,7 @@
 #ifndef AVFORMAT_MXF_H
 #define AVFORMAT_MXF_H
 
+#include "avformat.h"
 #include "libavcodec/avcodec.h"
 #include <stdint.h>
 
@@ -66,11 +67,17 @@ typedef struct MXFCodecUL {
     int id;
 } MXFCodecUL;
 
+typedef struct MXFSamplesPerFrame {
+    struct AVRational time_base;
+    int samples_per_frame[6];
+} MXFSamplesPerFrame;
+
 extern const MXFCodecUL ff_mxf_data_definition_uls[];
 extern const MXFCodecUL ff_mxf_codec_uls[];
 extern const MXFCodecUL ff_mxf_pixel_format_uls[];
 
 int ff_mxf_decode_pixel_layout(const char pixel_layout[16], enum AVPixelFormat *pix_fmt);
+const MXFSamplesPerFrame *ff_mxf_get_samples_per_frame(AVFormatContext *s, AVRational time_base);
 
 #define PRINT_KEY(pc, s, x) av_dlog(pc, "%s %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X %02X\n", s, \
                              (x)[0], (x)[1], (x)[2], (x)[3], (x)[4], (x)[5], (x)[6], (x)[7], (x)[8], (x)[9], (x)[10], (x)[11], (x)[12], (x)[13], (x)[14], (x)[15])
diff --git a/deps/libav/libavformat/mxfdec.c b/deps/libav/libavformat/mxfdec.c
index 158e866..734c50a 100644
--- a/deps/libav/libavformat/mxfdec.c
+++ b/deps/libav/libavformat/mxfdec.c
@@ -43,7 +43,7 @@
  * Only tracks with associated descriptors will be decoded. "Highly Desirable" SMPTE 377M D.1
  */
 
-#include <stdint.h>
+#include <inttypes.h>
 
 #include "libavutil/aes.h"
 #include "libavutil/mathematics.h"
@@ -122,6 +122,8 @@ typedef struct {
     uint8_t track_number[4];
     AVRational edit_rate;
     int intra_only;
+    uint64_t sample_count;
+    int64_t original_duration; /* st->duration in SampleRate/EditRate units */
 } MXFTrack;
 
 typedef struct {
@@ -204,6 +206,7 @@ typedef struct {
     struct AVAES *aesc;
     uint8_t *local_tags;
     int local_tags_count;
+    uint64_t last_partition;
     uint64_t footer_partition;
     KLVPacket current_klv_data;
     int current_klv_index;
@@ -243,6 +246,7 @@ static const uint8_t mxf_klv_key[]                         = { 0x06,0x0e,0x2b,0x
 static const uint8_t mxf_crypto_source_container_ul[]      = { 0x06,0x0e,0x2b,0x34,0x01,0x01,0x01,0x09,0x06,0x01,0x01,0x02,0x02,0x00,0x00,0x00 };
 static const uint8_t mxf_encrypted_triplet_key[]           = { 0x06,0x0e,0x2b,0x34,0x02,0x04,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x7e,0x01,0x00 };
 static const uint8_t mxf_encrypted_essence_container[]     = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x07,0x0d,0x01,0x03,0x01,0x02,0x0b,0x01,0x00 };
+static const uint8_t mxf_random_index_pack_key[]           = { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0D,0x01,0x02,0x01,0x01,0x11,0x01,0x00 };
 static const uint8_t mxf_sony_mpeg4_extradata[]            = { 0x06,0x0e,0x2b,0x34,0x04,0x01,0x01,0x01,0x0e,0x06,0x06,0x02,0x02,0x01,0x00,0x00 };
 
 #define IS_KLV_KEY(x, y) (!memcmp(x, y, sizeof(y)))
@@ -522,7 +526,7 @@ static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size
             /* only nag once */
             if (!mxf->op)
                 av_log(mxf->fc, AV_LOG_WARNING,
-                       "\"OPAtom\" with %u ECs - assuming %s\n",
+                       "\"OPAtom\" with %"PRIu32" ECs - assuming %s\n",
                        nb_essence_containers,
                        op == OP1a ? "OP1a" : "OPAtom");
 
@@ -535,14 +539,15 @@ static int mxf_read_partition_pack(void *arg, AVIOContext *pb, int tag, int size
     }
 
     if (partition->kag_size <= 0 || partition->kag_size > (1 << 20)) {
-        av_log(mxf->fc, AV_LOG_WARNING, "invalid KAGSize %i - guessing ", partition->kag_size);
+        av_log(mxf->fc, AV_LOG_WARNING, "invalid KAGSize %"PRId32" - guessing ",
+               partition->kag_size);
 
         if (mxf->op == OPSonyOpt)
             partition->kag_size = 512;
         else
             partition->kag_size = 1;
 
-        av_log(mxf->fc, AV_LOG_WARNING, "%i\n", partition->kag_size);
+        av_log(mxf->fc, AV_LOG_WARNING, "%"PRId32"\n", partition->kag_size);
     }
 
     return 0;
@@ -1424,7 +1429,7 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
         }
         st->id = source_track->track_id;
         st->priv_data = source_track;
-        st->duration = component->duration;
+        source_track->original_duration = st->duration = component->duration;
         if (st->duration == -1)
             st->duration = AV_NOPTS_VALUE;
         st->start_time = component->start_position;
@@ -1439,6 +1444,10 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
         }
         avpriv_set_pts_info(st, 64, material_track->edit_rate.den, material_track->edit_rate.num);
 
+        /* ensure SourceTrack EditRate == MaterialTrack EditRate since only
+         * the former is accessible via st->priv_data */
+        source_track->edit_rate = material_track->edit_rate;
+
         PRINT_KEY(mxf->fc, "data definition   ul", source_track->sequence->data_definition_ul);
         codec_ul = mxf_get_codec_ul(ff_mxf_data_definition_uls, &source_track->sequence->data_definition_ul);
         st->codec->codec_type = codec_ul->id;
@@ -1569,6 +1578,12 @@ static int mxf_parse_structural_metadata(MXFContext *mxf)
                 avpriv_set_pts_info(st, 64, 1, 48000);
             }
 
+            /* if duration is set, rescale it from EditRate to SampleRate */
+            if (st->duration != AV_NOPTS_VALUE)
+                st->duration = av_rescale_q(st->duration,
+                                            av_inv_q(material_track->edit_rate),
+                                            st->time_base);
+
             /* TODO: implement AV_CODEC_ID_RAWAUDIO */
             if (st->codec->codec_id == AV_CODEC_ID_PCM_S16LE) {
                 if (descriptor->bits_per_sample > 16 && descriptor->bits_per_sample <= 24)
@@ -1606,6 +1621,129 @@ fail_and_free:
     return ret;
 }
 
+static int mxf_read_utf16_string(AVIOContext *pb, int size, char** str)
+{
+    int ret;
+    size_t buf_size;
+
+    if (size < 0)
+        return AVERROR(EINVAL);
+
+    buf_size = size + size / 2 + 1;
+    *str = av_malloc(buf_size);
+    if (!*str)
+        return AVERROR(ENOMEM);
+
+    if ((ret = avio_get_str16be(pb, size, *str, buf_size)) < 0) {
+        av_freep(str);
+        return ret;
+    }
+
+    return ret;
+}
+
+static int mxf_uid_to_str(UID uid, char **str)
+{
+    int i;
+    char *p;
+    p = *str = av_mallocz(sizeof(UID) * 2 + 4 + 1);
+    if (!p)
+        return AVERROR(ENOMEM);
+    for (i = 0; i < sizeof(UID); i++) {
+        snprintf(p, 2 + 1, "%.2x", uid[i]);
+        p += 2;
+        if (i == 3 || i == 5 || i == 7 || i == 9) {
+            snprintf(p, 1 + 1, "-");
+            p++;
+        }
+    }
+    return 0;
+}
+
+static int mxf_timestamp_to_str(uint64_t timestamp, char **str)
+{
+    struct tm time = { 0 };
+    time.tm_year = (timestamp >> 48) - 1900;
+    time.tm_mon  = (timestamp >> 40 & 0xFF) - 1;
+    time.tm_mday = (timestamp >> 32 & 0xFF);
+    time.tm_hour = (timestamp >> 24 & 0xFF);
+    time.tm_min  = (timestamp >> 16 & 0xFF);
+    time.tm_sec  = (timestamp >> 8  & 0xFF);
+
+    /* msvcrt versions of strftime calls the invalid parameter handler
+     * (aborting the process if one isn't set) if the parameters are out
+     * of range. */
+    time.tm_mon  = av_clip(time.tm_mon,  0, 11);
+    time.tm_mday = av_clip(time.tm_mday, 1, 31);
+    time.tm_hour = av_clip(time.tm_hour, 0, 23);
+    time.tm_min  = av_clip(time.tm_min,  0, 59);
+    time.tm_sec  = av_clip(time.tm_sec,  0, 59);
+
+    *str = av_mallocz(32);
+    if (!*str)
+        return AVERROR(ENOMEM);
+    strftime(*str, 32, "%Y-%m-%d %H:%M:%S", &time);
+
+    return 0;
+}
+
+#define SET_STR_METADATA(pb, name, str) do { \
+    if ((ret = mxf_read_utf16_string(pb, size, &str)) < 0) \
+        return ret; \
+    av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
+} while (0)
+
+#define SET_UID_METADATA(pb, name, var, str) do { \
+    avio_read(pb, var, 16); \
+    if ((ret = mxf_uid_to_str(var, &str)) < 0) \
+        return ret; \
+    av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
+} while (0)
+
+#define SET_TS_METADATA(pb, name, var, str) do { \
+    var = avio_rb64(pb); \
+    if ((ret = mxf_timestamp_to_str(var, &str)) < 0) \
+        return ret; \
+    av_dict_set(&s->metadata, name, str, AV_DICT_DONT_STRDUP_VAL); \
+} while (0)
+
+static int mxf_read_identification_metadata(void *arg, AVIOContext *pb, int tag, int size, UID _uid, int64_t klv_offset)
+{
+    MXFContext *mxf = arg;
+    AVFormatContext *s = mxf->fc;
+    int ret;
+    UID uid = { 0 };
+    char *str = NULL;
+    uint64_t ts;
+    switch (tag) {
+    case 0x3C01:
+        SET_STR_METADATA(pb, "company_name", str);
+        break;
+    case 0x3C02:
+        SET_STR_METADATA(pb, "product_name", str);
+        break;
+    case 0x3C04:
+        SET_STR_METADATA(pb, "product_version", str);
+        break;
+    case 0x3C05:
+        SET_UID_METADATA(pb, "product_uid", uid, str);
+        break;
+    case 0x3C06:
+        SET_TS_METADATA(pb, "modification_date", ts, str);
+        break;
+    case 0x3C08:
+        SET_STR_METADATA(pb, "application_platform", str);
+        break;
+    case 0x3C09:
+        SET_UID_METADATA(pb, "generation_uid", uid, str);
+        break;
+    case 0x3C0A:
+        SET_UID_METADATA(pb, "uid", uid, str);
+        break;
+    }
+    return 0;
+}
+
 static const MXFMetadataReadTableEntry mxf_metadata_read_table[] = {
     { { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x05,0x01,0x00 }, mxf_read_primer_pack },
     { { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x02,0x01,0x00 }, mxf_read_partition_pack },
@@ -1618,6 +1756,7 @@ static const MXFMetadataReadTableEntry mxf_metadata_read_table[] = {
     { { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x03,0x04,0x00 }, mxf_read_partition_pack },
     { { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x02,0x00 }, mxf_read_partition_pack },
     { { 0x06,0x0E,0x2B,0x34,0x02,0x05,0x01,0x01,0x0d,0x01,0x02,0x01,0x01,0x04,0x04,0x00 }, mxf_read_partition_pack },
+    { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0D,0x01,0x01,0x01,0x01,0x01,0x30,0x00 }, mxf_read_identification_metadata },
     { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x18,0x00 }, mxf_read_content_storage, 0, AnyType },
     { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x37,0x00 }, mxf_read_source_package, sizeof(MXFPackage), SourcePackage },
     { { 0x06,0x0E,0x2B,0x34,0x02,0x53,0x01,0x01,0x0d,0x01,0x01,0x01,0x01,0x01,0x36,0x00 }, mxf_read_material_package, sizeof(MXFPackage), MaterialPackage },
@@ -1723,25 +1862,30 @@ static int mxf_parse_handle_essence(MXFContext *mxf)
     if (mxf->parsing_backward) {
         return mxf_seek_to_previous_partition(mxf);
     } else {
-        if (!mxf->footer_partition) {
-            av_dlog(mxf->fc, "no footer\n");
+        uint64_t offset = mxf->footer_partition ? mxf->footer_partition
+                                                : mxf->last_partition;
+
+        if (!offset) {
+            av_dlog(mxf->fc, "no last partition\n");
             return 0;
         }
 
-        av_dlog(mxf->fc, "seeking to footer\n");
+        av_dlog(mxf->fc, "seeking to last partition\n");
 
         /* remember where we were so we don't end up seeking further back than this */
         mxf->last_forward_tell = avio_tell(pb);
 
         if (!pb->seekable) {
-            av_log(mxf->fc, AV_LOG_INFO, "file is not seekable - not parsing footer\n");
+            av_log(mxf->fc, AV_LOG_INFO, "file is not seekable - not parsing last partition\n");
             return -1;
         }
 
-        /* seek to footer partition and parse backward */
-        if ((ret = avio_seek(pb, mxf->run_in + mxf->footer_partition, SEEK_SET)) < 0) {
-            av_log(mxf->fc, AV_LOG_ERROR, "failed to seek to footer @ 0x%"PRIx64" (%"PRId64") - partial file?\n",
-                   mxf->run_in + mxf->footer_partition, ret);
+        /* seek to last partition and parse backward */
+        if ((ret = avio_seek(pb, mxf->run_in + offset, SEEK_SET)) < 0) {
+            av_log(mxf->fc, AV_LOG_ERROR,
+                   "failed to seek to last partition @ 0x%" PRIx64
+                   " (%"PRId64") - partial file?\n",
+                   mxf->run_in + offset, ret);
             return ret;
         }
 
@@ -1871,6 +2015,34 @@ static void mxf_handle_small_eubc(AVFormatContext *s)
     mxf->edit_units_per_packet = 1920;
 }
 
+static void mxf_read_random_index_pack(AVFormatContext *s)
+{
+    MXFContext *mxf = s->priv_data;
+    uint32_t length;
+    int64_t file_size;
+    KLVPacket klv;
+
+    if (!s->pb->seekable)
+        return;
+
+    file_size = avio_size(s->pb);
+    avio_seek(s->pb, file_size - 4, SEEK_SET);
+    length = avio_rb32(s->pb);
+    if (length <= 32 || length >= FFMIN(file_size, INT_MAX))
+        goto end;
+    avio_seek(s->pb, file_size - length, SEEK_SET);
+    if (klv_read_packet(&klv, s->pb) < 0 ||
+        !IS_KLV_KEY(klv.key, mxf_random_index_pack_key) ||
+        klv.length != length - 20)
+        goto end;
+
+    avio_skip(s->pb, klv.length - 12);
+    mxf->last_partition = avio_rb64(s->pb);
+
+end:
+    avio_seek(s->pb, mxf->run_in, SEEK_SET);
+}
+
 static int mxf_read_header(AVFormatContext *s)
 {
     MXFContext *mxf = s->priv_data;
@@ -1889,7 +2061,10 @@ static int mxf_read_header(AVFormatContext *s)
     mxf->fc = s;
     mxf->run_in = avio_tell(s->pb);
 
+    mxf_read_random_index_pack(s);
+
     while (!s->pb->eof_reached) {
+
         const MXFMetadataReadTableEntry *metadata;
 
         if (klv_read_packet(&klv, s->pb) < 0) {
@@ -2037,21 +2212,79 @@ static int64_t mxf_set_current_edit_unit(MXFContext *mxf, int64_t current_offset
     return next_ofs;
 }
 
+static int mxf_compute_sample_count(MXFContext *mxf, int stream_index,
+                                    uint64_t *sample_count)
+{
+    int i, total = 0, size = 0;
+    AVStream *st = mxf->fc->streams[stream_index];
+    MXFTrack *track = st->priv_data;
+    AVRational time_base = av_inv_q(track->edit_rate);
+    AVRational sample_rate = av_inv_q(st->time_base);
+    const MXFSamplesPerFrame *spf = NULL;
+
+    if ((sample_rate.num / sample_rate.den) == 48000)
+        spf = ff_mxf_get_samples_per_frame(mxf->fc, time_base);
+    if (!spf) {
+        int remainder = (sample_rate.num * time_base.num) %
+                        (time_base.den * sample_rate.den);
+        *sample_count = av_q2d(av_mul_q((AVRational){mxf->current_edit_unit, 1},
+                                        av_mul_q(sample_rate, time_base)));
+        if (remainder)
+            av_log(mxf->fc, AV_LOG_WARNING,
+                   "seeking detected on stream #%d with time base (%d/%d) and "
+                   "sample rate (%d/%d), audio pts won't be accurate.\n",
+                   stream_index, time_base.num, time_base.den,
+                   sample_rate.num, sample_rate.den);
+        return 0;
+    }
+
+    while (spf->samples_per_frame[size]) {
+        total += spf->samples_per_frame[size];
+        size++;
+    }
+
+    if (!size)
+        return 0;
+
+    *sample_count = (mxf->current_edit_unit / size) * (uint64_t)total;
+    for (i = 0; i < mxf->current_edit_unit % size; i++) {
+        *sample_count += spf->samples_per_frame[i];
+    }
+
+    return 0;
+}
+
+static int mxf_set_audio_pts(MXFContext *mxf, AVCodecContext *codec,
+                             AVPacket *pkt)
+{
+    MXFTrack *track = mxf->fc->streams[pkt->stream_index]->priv_data;
+    int64_t bits_per_sample = av_get_bits_per_sample(codec->codec_id);
+
+    pkt->pts = track->sample_count;
+
+    if (codec->channels <= 0 || codec->channels * bits_per_sample < 8)
+        return AVERROR_INVALIDDATA;
+
+    track->sample_count += pkt->size / (codec->channels * bits_per_sample / 8);
+    return 0;
+}
+
 static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt)
 {
     KLVPacket klv;
     MXFContext *mxf = s->priv_data;
+    int ret;
 
     while (!s->pb->eof_reached) {
-        if (klv_read_packet(&klv, s->pb) < 0)
-            return -1;
+        if ((ret = klv_read_packet(&klv, s->pb)) < 0)
+            return ret;
         PRINT_KEY(s, "read packet", klv.key);
         av_dlog(s, "size %"PRIu64" offset %#"PRIx64"\n", klv.length, klv.offset);
         if (IS_KLV_KEY(klv.key, mxf_encrypted_triplet_key)) {
-            int res = mxf_decrypt_triplet(s, pkt, &klv);
-            if (res < 0) {
+            ret = mxf_decrypt_triplet(s, pkt, &klv);
+            if (ret < 0) {
                 av_log(s, AV_LOG_ERROR, "invalid encoded triplet\n");
-                return -1;
+                return ret;
             }
             return 0;
         }
@@ -2061,9 +2294,12 @@ static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt)
             int64_t next_ofs, next_klv;
             AVStream *st;
             MXFTrack *track;
+            AVCodecContext *codec;
 
             if (index < 0) {
-                av_log(s, AV_LOG_ERROR, "error getting stream index %d\n", AV_RB32(klv.key+12));
+                av_log(s, AV_LOG_ERROR,
+                       "error getting stream index %"PRIu32"\n",
+                       AV_RB32(klv.key + 12));
                 goto skip;
             }
 
@@ -2090,19 +2326,23 @@ static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt)
 
             /* check for 8 channels AES3 element */
             if (klv.key[12] == 0x06 && klv.key[13] == 0x01 && klv.key[14] == 0x10) {
-                if (mxf_get_d10_aes3_packet(s->pb, s->streams[index], pkt, klv.length) < 0) {
+                ret = mxf_get_d10_aes3_packet(s->pb, s->streams[index],
+                                              pkt, klv.length);
+                if (ret < 0) {
                     av_log(s, AV_LOG_ERROR, "error reading D-10 aes3 frame\n");
-                    return -1;
+                    return ret;
                 }
             } else {
-                int ret = av_get_packet(s->pb, pkt, klv.length);
+                ret = av_get_packet(s->pb, pkt, klv.length);
                 if (ret < 0)
                     return ret;
             }
             pkt->stream_index = index;
             pkt->pos = klv.offset;
 
-            if (s->streams[index]->codec->codec_type == AVMEDIA_TYPE_VIDEO && next_ofs >= 0) {
+            codec = s->streams[index]->codec;
+
+            if (codec->codec_type == AVMEDIA_TYPE_VIDEO && next_ofs >= 0) {
                 /* mxf->current_edit_unit good - see if we have an
                  * index table to derive timestamps from */
                 MXFIndexTable *t = &mxf->index_tables[0];
@@ -2117,6 +2357,10 @@ static int mxf_read_packet_old(AVFormatContext *s, AVPacket *pkt)
                      * < PTS if low_delay = 0 (Sony IMX30) */
                     pkt->pts = mxf->current_edit_unit;
                 }
+            } else if (codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+                ret = mxf_set_audio_pts(mxf, codec, pkt);
+                if (ret < 0)
+                    return ret;
             }
 
             /* seek for truncated packets */
@@ -2174,13 +2418,18 @@ static int mxf_read_packet(AVFormatContext *s, AVPacket *pkt)
         if ((ret = av_get_packet(s->pb, pkt, size)) != size)
             return ret < 0 ? ret : AVERROR_EOF;
 
+    pkt->stream_index = 0;
+
     if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && t->ptses &&
         mxf->current_edit_unit >= 0 && mxf->current_edit_unit < t->nb_ptses) {
         pkt->dts = mxf->current_edit_unit + t->first_dts;
         pkt->pts = t->ptses[mxf->current_edit_unit];
+    } else if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+        int ret = mxf_set_audio_pts(mxf, st->codec, pkt);
+        if (ret < 0)
+            return ret;
     }
 
-    pkt->stream_index = 0;
     mxf->current_edit_unit += edit_units;
 
     return 0;
@@ -2263,8 +2512,14 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
     int64_t seconds;
     MXFContext* mxf = s->priv_data;
     int64_t seekpos;
-    int ret;
+    int i, ret;
     MXFIndexTable *t;
+    MXFTrack *source_track = st->priv_data;
+
+    /* if audio then truncate sample_time to EditRate */
+    if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO)
+        sample_time = av_rescale_q(sample_time, st->time_base,
+                                   av_inv_q(source_track->edit_rate));
 
     if (mxf->nb_index_tables <= 0) {
     if (!s->bit_rate)
@@ -2293,7 +2548,7 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
         } else {
             /* no IndexEntryArray (one or more CBR segments)
              * make sure we don't seek past the end */
-            sample_time = FFMIN(sample_time, st->duration - 1);
+            sample_time = FFMIN(sample_time, source_track->original_duration - 1);
         }
 
         if ((ret = mxf_edit_unit_absolute_offset(mxf, t, sample_time, &sample_time, &seekpos, 1)) << 0)
@@ -2303,6 +2558,20 @@ static int mxf_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
         mxf->current_edit_unit = sample_time;
         avio_seek(s->pb, seekpos, SEEK_SET);
     }
+
+    // Update all tracks sample count
+    for (i = 0; i < s->nb_streams; i++) {
+        AVStream *cur_st = s->streams[i];
+        MXFTrack *cur_track = cur_st->priv_data;
+        uint64_t current_sample_count = 0;
+        if (cur_st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
+            ret = mxf_compute_sample_count(mxf, i, &current_sample_count);
+            if (ret < 0)
+                return ret;
+
+            cur_track->sample_count = current_sample_count;
+        }
+    }
     return 0;
 }
 
diff --git a/deps/libav/libavformat/omadec.c b/deps/libav/libavformat/omadec.c
index 6c27458..9d9c726 100644
--- a/deps/libav/libavformat/omadec.c
+++ b/deps/libav/libavformat/omadec.c
@@ -40,6 +40,8 @@
  * Supported decoders: ATRAC3, ATRAC3+, MP3, LPCM
  */
 
+#include <inttypes.h>
+
 #include "libavutil/channel_layout.h"
 #include "avformat.h"
 #include "internal.h"
@@ -219,7 +221,7 @@ static int decrypt_init(AVFormatContext *s, ID3v2ExtraMeta *em, uint8_t *header)
 
     if (geob->datasize < 64) {
         av_log(s, AV_LOG_ERROR,
-               "Invalid GEOB data size: %u\n", geob->datasize);
+               "Invalid GEOB data size: %"PRIu32"\n", geob->datasize);
         return AVERROR_INVALIDDATA;
     }
 
@@ -243,7 +245,7 @@ static int decrypt_init(AVFormatContext *s, ID3v2ExtraMeta *em, uint8_t *header)
         return AVERROR_INVALIDDATA;
     }
     oc->rid = AV_RB32(&gdata[OMA_ENC_HEADER_SIZE + 28]);
-    av_log(s, AV_LOG_DEBUG, "RID: %.8x\n", oc->rid);
+    av_log(s, AV_LOG_DEBUG, "RID: %.8"PRIx32"\n", oc->rid);
 
     memcpy(oc->iv, &header[0x58], 8);
     hex_log(s, AV_LOG_DEBUG, "IV", oc->iv, 8);
@@ -372,7 +374,7 @@ static int oma_read_header(AVFormatContext *s)
         channel_id = (codec_params >> 10) & 7;
         if (!channel_id) {
             av_log(s, AV_LOG_ERROR,
-                   "Invalid ATRAC-X channel id: %d\n", channel_id);
+                   "Invalid ATRAC-X channel id: %"PRIu32"\n", channel_id);
             return AVERROR_INVALIDDATA;
         }
         st->codec->channel_layout = ff_oma_chid_to_native_layout[channel_id - 1];
diff --git a/deps/libav/libavformat/riff.c b/deps/libav/libavformat/riff.c
index 545ecaf..c18fea5 100644
--- a/deps/libav/libavformat/riff.c
+++ b/deps/libav/libavformat/riff.c
@@ -232,6 +232,7 @@ const AVCodecTag ff_codec_bmp_tags[] = {
     { AV_CODEC_ID_VP6F,         MKTAG('V', 'P', '6', 'F') },
     { AV_CODEC_ID_VP6F,         MKTAG('F', 'L', 'V', '4') },
     { AV_CODEC_ID_VP8,          MKTAG('V', 'P', '8', '0') },
+    { AV_CODEC_ID_VP9,          MKTAG('V', 'P', '9', '0') },
     { AV_CODEC_ID_ASV1,         MKTAG('A', 'S', 'V', '1') },
     { AV_CODEC_ID_ASV2,         MKTAG('A', 'S', 'V', '2') },
     { AV_CODEC_ID_VCR1,         MKTAG('V', 'C', 'R', '1') },
@@ -282,6 +283,7 @@ const AVCodecTag ff_codec_bmp_tags[] = {
     { AV_CODEC_ID_JPEG2000,     MKTAG('M', 'J', '2', 'C') },
     { AV_CODEC_ID_JPEG2000,     MKTAG('L', 'J', '2', 'C') },
     { AV_CODEC_ID_JPEG2000,     MKTAG('L', 'J', '2', 'K') },
+    { AV_CODEC_ID_JPEG2000,     MKTAG('I', 'P', 'J', '2') },
     { AV_CODEC_ID_VMNC,         MKTAG('V', 'M', 'n', 'c') },
     { AV_CODEC_ID_TARGA,        MKTAG('t', 'g', 'a', ' ') },
     { AV_CODEC_ID_PNG,          MKTAG('M', 'P', 'N', 'G') },
diff --git a/deps/libav/libavformat/rmdec.c b/deps/libav/libavformat/rmdec.c
index d61f569..487e74f 100644
--- a/deps/libav/libavformat/rmdec.c
+++ b/deps/libav/libavformat/rmdec.c
@@ -19,6 +19,8 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include <inttypes.h>
+
 #include "libavutil/avstring.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/internal.h"
@@ -269,7 +271,7 @@ static int rm_read_audio_stream_info(AVFormatContext *s, AVIOContext *pb,
         case DEINT_ID_VBRF:
             break;
         default:
-            av_log(NULL,0,"Unknown interleaver %X\n", ast->deint_id);
+            av_log(NULL, 0 ,"Unknown interleaver %"PRIX32"\n", ast->deint_id);
             return AVERROR_INVALIDDATA;
         }
 
diff --git a/deps/libav/libavformat/rpl.c b/deps/libav/libavformat/rpl.c
index 0b22d8a..b72b8d0 100644
--- a/deps/libav/libavformat/rpl.c
+++ b/deps/libav/libavformat/rpl.c
@@ -19,7 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <stdint.h>
+#include <inttypes.h>
 #include <stdlib.h>
 
 #include "libavutil/avstring.h"
@@ -224,7 +224,7 @@ static int rpl_read_header(AVFormatContext *s)
         }
         if (ast->codec->codec_id == AV_CODEC_ID_NONE) {
             av_log(s, AV_LOG_WARNING,
-                   "RPL audio format %i not supported yet!\n",
+                   "RPL audio format %"PRId32" not supported yet!\n",
                    audio_format);
         }
         avpriv_set_pts_info(ast, 32, 1, ast->codec->bit_rate);
diff --git a/deps/libav/libavformat/rtmppkt.c b/deps/libav/libavformat/rtmppkt.c
index 81621b1..306a243 100644
--- a/deps/libav/libavformat/rtmppkt.c
+++ b/deps/libav/libavformat/rtmppkt.c
@@ -169,6 +169,7 @@ static int rtmp_packet_read_one_chunk(URLContext *h, RTMPPacket *p,
 
     uint8_t buf[16];
     int channel_id, timestamp, size;
+    uint32_t ts_field; // non-extended timestamp or delta field
     uint32_t extra = 0;
     enum RTMPPacketType type;
     int written = 0;
@@ -193,14 +194,14 @@ static int rtmp_packet_read_one_chunk(URLContext *h, RTMPPacket *p,
     type  = prev_pkt[channel_id].type;
     extra = prev_pkt[channel_id].extra;
 
-    hdr >>= 6;
+    hdr >>= 6; // header size indicator
     if (hdr == RTMP_PS_ONEBYTE) {
-        timestamp = prev_pkt[channel_id].ts_delta;
+        ts_field = prev_pkt[channel_id].ts_field;
     } else {
         if (ffurl_read_complete(h, buf, 3) != 3)
             return AVERROR(EIO);
         written += 3;
-        timestamp = AV_RB24(buf);
+        ts_field = AV_RB24(buf);
         if (hdr != RTMP_PS_FOURBYTES) {
             if (ffurl_read_complete(h, buf, 3) != 3)
                 return AVERROR(EIO);
@@ -217,11 +218,13 @@ static int rtmp_packet_read_one_chunk(URLContext *h, RTMPPacket *p,
                 extra = AV_RL32(buf);
             }
         }
-        if (timestamp == 0xFFFFFF) {
-            if (ffurl_read_complete(h, buf, 4) != 4)
-                return AVERROR(EIO);
-            timestamp = AV_RB32(buf);
-        }
+    }
+    if (ts_field == 0xFFFFFF) {
+        if (ffurl_read_complete(h, buf, 4) != 4)
+            return AVERROR(EIO);
+        timestamp = AV_RB32(buf);
+    } else {
+        timestamp = ts_field;
     }
     if (hdr != RTMP_PS_TWELVEBYTES)
         timestamp += prev_pkt[channel_id].timestamp;
@@ -232,8 +235,7 @@ static int rtmp_packet_read_one_chunk(URLContext *h, RTMPPacket *p,
             return ret;
         p->read = written;
         p->offset = 0;
-        prev_pkt[channel_id].ts_delta   = timestamp -
-                                          prev_pkt[channel_id].timestamp;
+        prev_pkt[channel_id].ts_field   = ts_field;
         prev_pkt[channel_id].timestamp  = timestamp;
     } else {
         // previous packet in this channel hasn't completed reading
@@ -242,7 +244,7 @@ static int rtmp_packet_read_one_chunk(URLContext *h, RTMPPacket *p,
         p->size          = prev->size;
         p->channel_id    = prev->channel_id;
         p->type          = prev->type;
-        p->ts_delta      = prev->ts_delta;
+        p->ts_field      = prev->ts_field;
         p->extra         = prev->extra;
         p->offset        = prev->offset;
         p->read          = prev->read + written;
@@ -303,22 +305,34 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt,
     int written = 0;
     int ret;
     RTMPPacket *prev_pkt;
+    int use_delta; // flag if using timestamp delta, not RTMP_PS_TWELVEBYTES
+    uint32_t timestamp; // full 32-bit timestamp or delta value
 
     if ((ret = ff_rtmp_check_alloc_array(prev_pkt_ptr, nb_prev_pkt,
                                          pkt->channel_id)) < 0)
         return ret;
     prev_pkt = *prev_pkt_ptr;
 
-    pkt->ts_delta = pkt->timestamp - prev_pkt[pkt->channel_id].timestamp;
-
     //if channel_id = 0, this is first presentation of prev_pkt, send full hdr.
-    if (prev_pkt[pkt->channel_id].channel_id &&
+    use_delta = prev_pkt[pkt->channel_id].channel_id &&
         pkt->extra == prev_pkt[pkt->channel_id].extra &&
-        pkt->timestamp >= prev_pkt[pkt->channel_id].timestamp) {
+        pkt->timestamp >= prev_pkt[pkt->channel_id].timestamp;
+
+    timestamp = pkt->timestamp;
+    if (use_delta) {
+        timestamp -= prev_pkt[pkt->channel_id].timestamp;
+    }
+    if (timestamp >= 0xFFFFFF) {
+        pkt->ts_field = 0xFFFFFF;
+    } else {
+        pkt->ts_field = timestamp;
+    }
+
+    if (use_delta) {
         if (pkt->type == prev_pkt[pkt->channel_id].type &&
             pkt->size == prev_pkt[pkt->channel_id].size) {
             mode = RTMP_PS_FOURBYTES;
-            if (pkt->ts_delta == prev_pkt[pkt->channel_id].ts_delta)
+            if (pkt->ts_field == prev_pkt[pkt->channel_id].ts_field)
                 mode = RTMP_PS_ONEBYTE;
         } else {
             mode = RTMP_PS_EIGHTBYTES;
@@ -335,29 +349,22 @@ int ff_rtmp_packet_write(URLContext *h, RTMPPacket *pkt,
         bytestream_put_le16(&p, pkt->channel_id - 64);
     }
     if (mode != RTMP_PS_ONEBYTE) {
-        uint32_t timestamp = pkt->timestamp;
-        if (mode != RTMP_PS_TWELVEBYTES)
-            timestamp = pkt->ts_delta;
-        bytestream_put_be24(&p, timestamp >= 0xFFFFFF ? 0xFFFFFF : timestamp);
+        bytestream_put_be24(&p, pkt->ts_field);
         if (mode != RTMP_PS_FOURBYTES) {
             bytestream_put_be24(&p, pkt->size);
             bytestream_put_byte(&p, pkt->type);
             if (mode == RTMP_PS_TWELVEBYTES)
                 bytestream_put_le32(&p, pkt->extra);
         }
-        if (timestamp >= 0xFFFFFF)
-            bytestream_put_be32(&p, timestamp);
     }
+    if (pkt->ts_field == 0xFFFFFF)
+        bytestream_put_be32(&p, timestamp);
     // save history
     prev_pkt[pkt->channel_id].channel_id = pkt->channel_id;
     prev_pkt[pkt->channel_id].type       = pkt->type;
     prev_pkt[pkt->channel_id].size       = pkt->size;
     prev_pkt[pkt->channel_id].timestamp  = pkt->timestamp;
-    if (mode != RTMP_PS_TWELVEBYTES) {
-        prev_pkt[pkt->channel_id].ts_delta   = pkt->ts_delta;
-    } else {
-        prev_pkt[pkt->channel_id].ts_delta   = pkt->timestamp;
-    }
+    prev_pkt[pkt->channel_id].ts_field   = pkt->ts_field;
     prev_pkt[pkt->channel_id].extra      = pkt->extra;
 
     if ((ret = ffurl_write(h, pkt_hdr, p - pkt_hdr)) < 0)
@@ -391,7 +398,7 @@ int ff_rtmp_packet_create(RTMPPacket *pkt, int channel_id, RTMPPacketType type,
     pkt->type       = type;
     pkt->timestamp  = timestamp;
     pkt->extra      = 0;
-    pkt->ts_delta   = 0;
+    pkt->ts_field   = 0;
 
     return 0;
 }
diff --git a/deps/libav/libavformat/rtmppkt.h b/deps/libav/libavformat/rtmppkt.h
index 7121d7e..e973684 100644
--- a/deps/libav/libavformat/rtmppkt.h
+++ b/deps/libav/libavformat/rtmppkt.h
@@ -78,7 +78,7 @@ typedef struct RTMPPacket {
     int            channel_id; ///< RTMP channel ID (nothing to do with audio/video channels though)
     RTMPPacketType type;       ///< packet payload type
     uint32_t       timestamp;  ///< packet full timestamp
-    uint32_t       ts_delta;   ///< timestamp increment to the previous one in milliseconds (latter only for media packets)
+    uint32_t       ts_field;   ///< 24-bit timestamp or increment to the previous one, in milliseconds (latter only for media packets). Clipped to a maximum of 0xFFFFFF, indicating an extended timestamp field.
     uint32_t       extra;      ///< probably an additional channel ID used during streaming data
     uint8_t        *data;      ///< packet payload
     int            size;       ///< packet payload size
diff --git a/deps/libav/libavformat/smacker.c b/deps/libav/libavformat/smacker.c
index 5af5e50..2fa531b 100644
--- a/deps/libav/libavformat/smacker.c
+++ b/deps/libav/libavformat/smacker.c
@@ -23,6 +23,8 @@
  * Based on http://wiki.multimedia.cx/index.php?title=Smacker
  */
 
+#include <inttypes.h>
+
 #include "libavutil/bswap.h"
 #include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
@@ -139,7 +141,7 @@ static int smacker_read_header(AVFormatContext *s)
     smk->pad = avio_rl32(pb);
     /* setup data */
     if(smk->frames > 0xFFFFFF) {
-        av_log(s, AV_LOG_ERROR, "Too many frames: %i\n", smk->frames);
+        av_log(s, AV_LOG_ERROR, "Too many frames: %"PRIu32"\n", smk->frames);
         return -1;
     }
     smk->frm_size = av_malloc(smk->frames * 4);
@@ -214,7 +216,9 @@ static int smacker_read_header(AVFormatContext *s)
                                       FF_INPUT_BUFFER_PADDING_SIZE);
     st->codec->extradata_size = smk->treesize + 16;
     if(!st->codec->extradata){
-        av_log(s, AV_LOG_ERROR, "Cannot allocate %i bytes of extradata\n", smk->treesize + 16);
+        av_log(s, AV_LOG_ERROR,
+               "Cannot allocate %"PRIu32" bytes of extradata\n",
+               smk->treesize + 16);
         av_free(smk->frm_size);
         av_free(smk->frm_flags);
         return -1;
diff --git a/deps/libav/libavformat/smjpegdec.c b/deps/libav/libavformat/smjpegdec.c
index 623df71..a9ed28e 100644
--- a/deps/libav/libavformat/smjpegdec.c
+++ b/deps/libav/libavformat/smjpegdec.c
@@ -24,6 +24,8 @@
  * This is a demuxer for Loki SDL Motion JPEG files
  */
 
+#include <inttypes.h>
+
 #include "avformat.h"
 #include "internal.h"
 #include "riff.h"
@@ -52,7 +54,7 @@ static int smjpeg_read_header(AVFormatContext *s)
     avio_skip(pb, 8); // magic
     version = avio_rb32(pb);
     if (version)
-        avpriv_request_sample(s, "Unknown version %d", version);
+        avpriv_request_sample(s, "Unknown version %"PRIu32, version);
 
     duration = avio_rb32(pb); // in msec
 
@@ -124,7 +126,7 @@ static int smjpeg_read_header(AVFormatContext *s)
         case SMJPEG_HEND:
             return 0;
         default:
-            av_log(s, AV_LOG_ERROR, "unknown header %x\n", htype);
+            av_log(s, AV_LOG_ERROR, "unknown header %"PRIx32"\n", htype);
             return AVERROR_INVALIDDATA;
         }
     }
@@ -164,7 +166,7 @@ static int smjpeg_read_packet(AVFormatContext *s, AVPacket *pkt)
         ret = AVERROR_EOF;
         break;
     default:
-        av_log(s, AV_LOG_ERROR, "unknown chunk %x\n", dtype);
+        av_log(s, AV_LOG_ERROR, "unknown chunk %"PRIx32"\n", dtype);
         ret = AVERROR_INVALIDDATA;
         break;
     }
diff --git a/deps/libav/libavformat/spdifenc.c b/deps/libav/libavformat/spdifenc.c
index c350f72..f3acf48 100644
--- a/deps/libav/libavformat/spdifenc.c
+++ b/deps/libav/libavformat/spdifenc.c
@@ -44,6 +44,8 @@
  *      dependent from data-type (spaces between packets are filled by zeros)
  */
 
+#include <inttypes.h>
+
 #include "avformat.h"
 #include "avio_internal.h"
 #include "spdif.h"
@@ -274,7 +276,7 @@ static int spdif_header_dts(AVFormatContext *s, AVPacket *pkt)
         av_log(s, AV_LOG_ERROR, "stray DTS-HD frame\n");
         return AVERROR_INVALIDDATA;
     default:
-        av_log(s, AV_LOG_ERROR, "bad DTS syncword 0x%x\n", syncword_dts);
+        av_log(s, AV_LOG_ERROR, "bad DTS syncword 0x%"PRIx32"\n", syncword_dts);
         return AVERROR_INVALIDDATA;
     }
     blocks++;
@@ -369,8 +371,8 @@ static int spdif_header_aac(AVFormatContext *s, AVPacket *pkt)
         ctx->data_type = IEC61937_MPEG2_AAC_LSF_4096;
         break;
     default:
-        av_log(s, AV_LOG_ERROR, "%i samples in AAC frame not supported\n",
-               hdr.samples);
+        av_log(s, AV_LOG_ERROR,
+               "%"PRIu32" samples in AAC frame not supported\n", hdr.samples);
         return AVERROR(EINVAL);
     }
     //TODO Data type dependent info (LC profile/SBR)
diff --git a/deps/libav/libavformat/utils.c b/deps/libav/libavformat/utils.c
index fca588b..3f400e3 100644
--- a/deps/libav/libavformat/utils.c
+++ b/deps/libav/libavformat/utils.c
@@ -2395,7 +2395,8 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
             /* check max_analyze_duration */
             if (av_rescale_q(pkt->dts - st->info->fps_first_dts, st->time_base,
                              AV_TIME_BASE_Q) >= ic->max_analyze_duration) {
-                av_log(ic, AV_LOG_WARNING, "max_analyze_duration reached\n");
+                av_log(ic, AV_LOG_WARNING, "max_analyze_duration %d reached\n",
+                       ic->max_analyze_duration);
                 break;
             }
         }
diff --git a/deps/libav/libavformat/wtv.c b/deps/libav/libavformat/wtv.c
index 0c24fd7..c85f374 100644
--- a/deps/libav/libavformat/wtv.c
+++ b/deps/libav/libavformat/wtv.c
@@ -25,6 +25,8 @@
  * @author Peter Ross <pross at xvid.org>
  */
 
+#include <inttypes.h>
+
 #include "libavutil/channel_layout.h"
 #include "libavutil/intreadwrite.h"
 #include "libavutil/intfloat.h"
@@ -37,7 +39,7 @@
 
 /* Macros for formating GUIDs */
 #define PRI_PRETTY_GUID \
-    "%08x-%04x-%04x-%02x%02x%02x%02x%02x%02x%02x%02x"
+    "%08"PRIx32"-%04"PRIx16"-%04"PRIx16"-%02x%02x%02x%02x%02x%02x%02x%02x"
 #define ARG_PRETTY_GUID(g) \
     AV_RL32(g),AV_RL16(g+4),AV_RL16(g+6),g[8],g[9],g[10],g[11],g[12],g[13],g[14],g[15]
 #define LEN_PRETTY_GUID 34
@@ -501,7 +503,7 @@ static void get_tag(AVFormatContext *s, AVIOContext *pb, const char *key, int ty
         return;
 
     if (type == 0 && length == 4) {
-        snprintf(buf, buf_size, "%"PRIi32, avio_rl32(pb));
+        snprintf(buf, buf_size, "%u", avio_rl32(pb));
     } else if (type == 1) {
         avio_get_str16le(pb, length, buf, buf_size);
         if (!strlen(buf)) {
diff --git a/deps/libav/libavformat/xmv.c b/deps/libav/libavformat/xmv.c
index 2b2fd45..bcb17f8 100644
--- a/deps/libav/libavformat/xmv.c
+++ b/deps/libav/libavformat/xmv.c
@@ -25,7 +25,7 @@
  * Microsoft XMV demuxer
  */
 
-#include <stdint.h>
+#include <inttypes.h>
 
 #include "libavutil/intreadwrite.h"
 
@@ -158,7 +158,7 @@ static int xmv_read_header(AVFormatContext *s)
 
     file_version = avio_rl32(pb);
     if ((file_version != 4) && (file_version != 2))
-        avpriv_request_sample(s, "Uncommon version %d", file_version);
+        avpriv_request_sample(s, "Uncommon version %"PRIu32"", file_version);
 
 
     /* Video track */
@@ -228,7 +228,7 @@ static int xmv_read_header(AVFormatContext *s)
 
         if (!track->channels || !track->sample_rate ||
              track->channels >= UINT16_MAX / XMV_BLOCK_ALIGN_SIZE) {
-            av_log(s, AV_LOG_ERROR, "Invalid parameters for audio track %d.\n",
+            av_log(s, AV_LOG_ERROR, "Invalid parameters for audio track %"PRIu16".\n",
                    audio_track);
             ret = AVERROR_INVALIDDATA;
             goto fail;
diff --git a/deps/libav/libavresample/avresample.h b/deps/libav/libavresample/avresample.h
index d26f2ca..3358628 100644
--- a/deps/libav/libavresample/avresample.h
+++ b/deps/libav/libavresample/avresample.h
@@ -172,6 +172,14 @@ AVAudioResampleContext *avresample_alloc_context(void);
 int avresample_open(AVAudioResampleContext *avr);
 
 /**
+ * Check whether an AVAudioResampleContext is open or closed.
+ *
+ * @param avr AVAudioResampleContext to check
+ * @return 1 if avr is open, 0 if avr is closed.
+ */
+int avresample_is_open(AVAudioResampleContext *avr);
+
+/**
  * Close AVAudioResampleContext.
  *
  * This closes the context, but it does not change the parameters. The context
diff --git a/deps/libav/libavresample/utils.c b/deps/libav/libavresample/utils.c
index 2dd3d06..63d6530 100644
--- a/deps/libav/libavresample/utils.c
+++ b/deps/libav/libavresample/utils.c
@@ -36,6 +36,11 @@ int avresample_open(AVAudioResampleContext *avr)
 {
     int ret;
 
+    if (avresample_is_open(avr)) {
+        av_log(avr, AV_LOG_ERROR, "The resampling context is already open.\n");
+        return AVERROR(EINVAL);
+    }
+
     /* set channel mixing parameters */
     avr->in_channels = av_get_channel_layout_nb_channels(avr->in_channel_layout);
     if (avr->in_channels <= 0 || avr->in_channels > AVRESAMPLE_MAX_CHANNELS) {
@@ -254,6 +259,11 @@ error:
     return ret;
 }
 
+int avresample_is_open(AVAudioResampleContext *avr)
+{
+    return !!avr->out_fifo;
+}
+
 void avresample_close(AVAudioResampleContext *avr)
 {
     ff_audio_data_free(&avr->in_buffer);
diff --git a/deps/libav/libavresample/version.h b/deps/libav/libavresample/version.h
index fce5770..ca836e4 100644
--- a/deps/libav/libavresample/version.h
+++ b/deps/libav/libavresample/version.h
@@ -28,7 +28,7 @@
 #include "libavutil/version.h"
 
 #define LIBAVRESAMPLE_VERSION_MAJOR  1
-#define LIBAVRESAMPLE_VERSION_MINOR  1
+#define LIBAVRESAMPLE_VERSION_MINOR  2
 #define LIBAVRESAMPLE_VERSION_MICRO  0
 
 #define LIBAVRESAMPLE_VERSION_INT  AV_VERSION_INT(LIBAVRESAMPLE_VERSION_MAJOR, \
diff --git a/deps/libav/libavutil/Makefile b/deps/libav/libavutil/Makefile
index e0e32b4..f663f18 100644
--- a/deps/libav/libavutil/Makefile
+++ b/deps/libav/libavutil/Makefile
@@ -16,6 +16,7 @@ HEADERS = adler32.h                                                     \
           common.h                                                      \
           cpu.h                                                         \
           crc.h                                                         \
+          downmix_info.h                                                \
           error.h                                                       \
           eval.h                                                        \
           fifo.h                                                        \
@@ -67,6 +68,7 @@ OBJS = adler32.o                                                        \
        cpu.o                                                            \
        crc.o                                                            \
        des.o                                                            \
+       downmix_info.o                                                   \
        error.o                                                          \
        eval.o                                                           \
        fifo.o                                                           \
diff --git a/deps/libav/libavutil/aarch64/asm.S b/deps/libav/libavutil/aarch64/asm.S
index 94e5a84..6c93d11 100644
--- a/deps/libav/libavutil/aarch64/asm.S
+++ b/deps/libav/libavutil/aarch64/asm.S
@@ -36,11 +36,14 @@ ELF     .size   \name, . - \name
         .align          \align
     .if \export
         .global EXTERN_ASM\name
+ELF     .type   EXTERN_ASM\name, %function
+        .func   EXTERN_ASM\name
 EXTERN_ASM\name:
-    .endif
+    .else
 ELF     .type   \name, %function
         .func   \name
 \name:
+    .endif
 .endm
 
 .macro  const   name, align=2
@@ -61,3 +64,7 @@ ELF     .size   \name, . - \name
         ldr             \rd, =\val
 #endif
 .endm
+
+#define GLUE(a, b) a ## b
+#define JOIN(a, b) GLUE(a, b)
+#define X(s) JOIN(EXTERN_ASM, s)
diff --git a/deps/libav/libavutil/arm/asm.S b/deps/libav/libavutil/arm/asm.S
index f4523ea..5884e17 100644
--- a/deps/libav/libavutil/arm/asm.S
+++ b/deps/libav/libavutil/arm/asm.S
@@ -53,6 +53,7 @@
         .syntax unified
 T       .thumb
 ELF     .eabi_attribute 25, 1           @ Tag_ABI_align_preserved
+ELF     .section .note.GNU-stack,"",%progbits @ Mark stack as non-executable
 
 .macro  function name, export=0, align=2
         .set            .Lpic_idx, 0
@@ -215,6 +216,13 @@ T       ldr             \rt, [\rn]
 T       add             \rn, \rn, \rm
 .endm
 
+.macro  ldrc_pre        cc,  rt,  rn,  rm:vararg
+A       ldr\cc          \rt, [\rn, \rm]!
+T       itt             \cc
+T       add\cc          \rn, \rn, \rm
+T       ldr\cc          \rt, [\rn]
+.endm
+
 .macro  ldrd_reg        rt,  rt2, rn,  rm
 A       ldrd            \rt, \rt2, [\rn, \rm]
 T       add             \rt, \rn, \rm
diff --git a/deps/libav/libavutil/arm/float_dsp_init_arm.c b/deps/libav/libavutil/arm/float_dsp_init_arm.c
index 39a5e95..ff0105c 100644
--- a/deps/libav/libavutil/arm/float_dsp_init_arm.c
+++ b/deps/libav/libavutil/arm/float_dsp_init_arm.c
@@ -1,6 +1,4 @@
 /*
- * ARM optimized DSP utils
- *
  * This file is part of Libav.
  *
  * Libav is free software; you can redistribute it and/or
diff --git a/deps/libav/libavutil/atomic.c b/deps/libav/libavutil/atomic.c
index e4fa957..8374039 100644
--- a/deps/libav/libavutil/atomic.c
+++ b/deps/libav/libavutil/atomic.c
@@ -97,8 +97,11 @@ void *avpriv_atomic_ptr_cas(void * volatile *ptr, void *oldval, void *newval)
     return *ptr;
 }
 
-#else
+#else /* HAVE_THREADS */
 
+/* This should never trigger, unless a new threading implementation
+ * without correct atomics dependencies in configure or a corresponding
+ * atomics implementation is added. */
 #error "Threading is enabled, but there is no implementation of atomic operations available"
 
 #endif /* HAVE_PTHREADS */
diff --git a/deps/libav/libavcodec/bfin/config_bfin.h b/deps/libav/libavutil/bfin/asm.h
similarity index 59%
rename from deps/libav/libavcodec/bfin/config_bfin.h
rename to deps/libav/libavutil/bfin/asm.h
index e714070..6bfa0f3 100644
--- a/deps/libav/libavcodec/bfin/config_bfin.h
+++ b/deps/libav/libavutil/bfin/asm.h
@@ -17,49 +17,38 @@
  * License along with Libav; if not, write to the Free Software
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
-/*
-   low level assembler interface wrapper
-
-DEFUN(put_pixels_clamped,mL1,
-        (int16_t *block, uint8_t *dest, int line_size)):
-
-      body
 
-      rts;
-*/
-
-#ifndef AVCODEC_BFIN_CONFIG_BFIN_H
-#define AVCODEC_BFIN_CONFIG_BFIN_H
+#ifndef AVUTIL_BFIN_ASM_H
+#define AVUTIL_BFIN_ASM_H
 
 #include "config.h"
 
-#ifndef DEFUN
-
 #define mL3 .text
-#ifndef mL1
+
 #if defined(__FDPIC__) && CONFIG_SRAM
 #define mL1 .l1.text
+#define SECTION_L1_DATA_A .section .l1.data.A,"aw", at progbits
+#define SECTION_L1_DATA_B .section .l1.data.B,"aw", at progbits
 #else
 #define mL1 mL3
-#endif
+#define SECTION_L1_DATA_A
+#define SECTION_L1_DATA_B .data
 #endif
 
-#define DEFUN(fname,where,interface) \
-        .section where;              \
-        .global _ff_bfin_ ## fname ; \
-        .type _ff_bfin_ ## fname, STT_FUNC; \
-        .align 8;                    \
-        _ff_bfin_ ## fname
+#define DEFUN(fname, where, interface)          \
+    .section where;                             \
+    .global _ff_bfin_ ## fname;                 \
+    .type _ff_bfin_ ## fname, STT_FUNC;         \
+    .align 8;                                   \
+    _ff_bfin_ ## fname
 
 #define DEFUN_END(fname) \
-        .size _ff_bfin_ ## fname, . - _ff_bfin_ ## fname
+    .size _ff_bfin_ ## fname, . - _ff_bfin_ ## fname
 
 #ifdef __FDPIC__
-#define RELOC(reg,got,obj) reg = [got + obj at GOT17M4]
+#define RELOC(reg, got, obj) reg = [got + obj at GOT17M4]
 #else
-#define RELOC(reg,got,obj) reg.L = obj; reg.H = obj
-#endif
-
+#define RELOC(reg, got, obj) reg.L = obj; reg.H = obj
 #endif
 
-#endif /* AVCODEC_BFIN_CONFIG_BFIN_H */
+#endif /* AVUTIL_BFIN_ASM_H */
diff --git a/deps/libav/libavdevice/avdevice.c b/deps/libav/libavutil/bfin/attributes.h
similarity index 67%
copy from deps/libav/libavdevice/avdevice.c
copy to deps/libav/libavutil/bfin/attributes.h
index 5a5c762..659f9a9 100644
--- a/deps/libav/libavdevice/avdevice.c
+++ b/deps/libav/libavutil/bfin/attributes.h
@@ -1,4 +1,6 @@
 /*
+ * Copyright (C) 2007 Marc Hoffman <mmh at pleasantst.com>
+ *
  * This file is part of Libav.
  *
  * Libav is free software; you can redistribute it and/or
@@ -16,21 +18,17 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include "avdevice.h"
-#include "config.h"
+#ifndef AVUTIL_BFIN_ATTRIBUTES_H
+#define AVUTIL_BFIN_ATTRIBUTES_H
 
-unsigned avdevice_version(void)
-{
-    return LIBAVDEVICE_VERSION_INT;
-}
+#include "config.h"
 
-const char * avdevice_configuration(void)
-{
-    return LIBAV_CONFIGURATION;
-}
+#if defined(__FDPIC__) && CONFIG_SRAM
+#define attribute_l1_text   __attribute__((l1_text))
+#define attribute_l1_data_b __attribute__((l1_data_B))
+#else
+#define attribute_l1_text
+#define attribute_l1_data_b
+#endif
 
-const char * avdevice_license(void)
-{
-#define LICENSE_PREFIX "libavdevice license: "
-    return LICENSE_PREFIX LIBAV_LICENSE + sizeof(LICENSE_PREFIX) - 1;
-}
+#endif /* AVUTIL_BFIN_ATTRIBUTES_H */
diff --git a/deps/libav/libavutil/cpu.c b/deps/libav/libavutil/cpu.c
index 8c2cfb8..d651eb2 100644
--- a/deps/libav/libavutil/cpu.c
+++ b/deps/libav/libavutil/cpu.c
@@ -87,8 +87,11 @@ int av_parse_cpu_flags(const char *s)
 #define CPUFLAG_SSE42    (AV_CPU_FLAG_SSE42    | CPUFLAG_SSE4)
 #define CPUFLAG_AVX      (AV_CPU_FLAG_AVX      | CPUFLAG_SSE42)
 #define CPUFLAG_XOP      (AV_CPU_FLAG_XOP      | CPUFLAG_AVX)
+#define CPUFLAG_FMA3     (AV_CPU_FLAG_FMA3     | CPUFLAG_AVX)
 #define CPUFLAG_FMA4     (AV_CPU_FLAG_FMA4     | CPUFLAG_AVX)
 #define CPUFLAG_AVX2     (AV_CPU_FLAG_AVX2     | CPUFLAG_AVX)
+#define CPUFLAG_BMI1     (AV_CPU_FLAG_BMI1)
+#define CPUFLAG_BMI2     (AV_CPU_FLAG_BMI2     | CPUFLAG_BMI1)
     static const AVOption cpuflags_opts[] = {
         { "flags"   , NULL, 0, AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit = "flags" },
 #if   ARCH_PPC
@@ -107,8 +110,11 @@ int av_parse_cpu_flags(const char *s)
         { "sse4.2"  , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_SSE42        },    .unit = "flags" },
         { "avx"     , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVX          },    .unit = "flags" },
         { "xop"     , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_XOP          },    .unit = "flags" },
+        { "fma3"    , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_FMA3         },    .unit = "flags" },
         { "fma4"    , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_FMA4         },    .unit = "flags" },
         { "avx2"    , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_AVX2         },    .unit = "flags" },
+        { "bmi1"    , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_BMI1         },    .unit = "flags" },
+        { "bmi2"    , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_BMI2         },    .unit = "flags" },
         { "3dnow"   , NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_3DNOW        },    .unit = "flags" },
         { "3dnowext", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = CPUFLAG_3DNOWEXT     },    .unit = "flags" },
         { "cmov",     NULL, 0, AV_OPT_TYPE_CONST, { .i64 = AV_CPU_FLAG_CMOV     },    .unit = "flags" },
@@ -204,11 +210,14 @@ static const struct {
     { AV_CPU_FLAG_SSE42,     "sse4.2"     },
     { AV_CPU_FLAG_AVX,       "avx"        },
     { AV_CPU_FLAG_XOP,       "xop"        },
+    { AV_CPU_FLAG_FMA3,      "fma3"       },
     { AV_CPU_FLAG_FMA4,      "fma4"       },
     { AV_CPU_FLAG_3DNOW,     "3dnow"      },
     { AV_CPU_FLAG_3DNOWEXT,  "3dnowext"   },
     { AV_CPU_FLAG_CMOV,      "cmov"       },
     { AV_CPU_FLAG_AVX2,      "avx2"       },
+    { AV_CPU_FLAG_BMI1,      "bmi1"       },
+    { AV_CPU_FLAG_BMI2,      "bmi2"       },
 #endif
     { 0 }
 };
diff --git a/deps/libav/libavutil/cpu.h b/deps/libav/libavutil/cpu.h
index 29036e3..517c520 100644
--- a/deps/libav/libavutil/cpu.h
+++ b/deps/libav/libavutil/cpu.h
@@ -49,6 +49,9 @@
 #define AV_CPU_FLAG_FMA4         0x0800 ///< Bulldozer FMA4 functions
 #define AV_CPU_FLAG_CMOV         0x1000 ///< i686 cmov
 #define AV_CPU_FLAG_AVX2         0x8000 ///< AVX2 functions: requires OS support even if YMM registers aren't used
+#define AV_CPU_FLAG_FMA3        0x10000 ///< Haswell FMA3 functions
+#define AV_CPU_FLAG_BMI1        0x20000 ///< Bit Manipulation Instruction Set 1
+#define AV_CPU_FLAG_BMI2        0x40000 ///< Bit Manipulation Instruction Set 2
 
 #define AV_CPU_FLAG_ALTIVEC      0x0001 ///< standard
 
diff --git a/deps/libav/libavutil/dict.c b/deps/libav/libavutil/dict.c
index 9ac4831..3b95aba 100644
--- a/deps/libav/libavutil/dict.c
+++ b/deps/libav/libavutil/dict.c
@@ -35,40 +35,47 @@ int av_dict_count(const AVDictionary *m)
     return m ? m->count : 0;
 }
 
-AVDictionaryEntry *
-av_dict_get(AVDictionary *m, const char *key, const AVDictionaryEntry *prev, int flags)
+AVDictionaryEntry *av_dict_get(AVDictionary *m, const char *key,
+                               const AVDictionaryEntry *prev, int flags)
 {
     unsigned int i, j;
 
-    if(!m)
+    if (!m)
         return NULL;
 
-    if(prev) i= prev - m->elems + 1;
-    else     i= 0;
+    if (prev)
+        i = prev - m->elems + 1;
+    else
+        i = 0;
 
-    for(; i<m->count; i++){
-        const char *s= m->elems[i].key;
-        if(flags & AV_DICT_MATCH_CASE) for(j=0;         s[j]  ==         key[j]  && key[j]; j++);
-        else                               for(j=0; av_toupper(s[j]) == av_toupper(key[j]) && key[j]; j++);
-        if(key[j])
+    for (; i < m->count; i++) {
+        const char *s = m->elems[i].key;
+        if (flags & AV_DICT_MATCH_CASE)
+            for (j = 0; s[j] == key[j] && key[j]; j++)
+                ;
+        else
+            for (j = 0; av_toupper(s[j]) == av_toupper(key[j]) && key[j]; j++)
+                ;
+        if (key[j])
             continue;
-        if(s[j] && !(flags & AV_DICT_IGNORE_SUFFIX))
+        if (s[j] && !(flags & AV_DICT_IGNORE_SUFFIX))
             continue;
         return &m->elems[i];
     }
     return NULL;
 }
 
-int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags)
+int av_dict_set(AVDictionary **pm, const char *key, const char *value,
+                int flags)
 {
-    AVDictionary      *m = *pm;
+    AVDictionary *m = *pm;
     AVDictionaryEntry *tag = av_dict_get(m, key, NULL, flags);
     char *oldval = NULL;
 
-    if(!m)
+    if (!m)
         m = *pm = av_mallocz(sizeof(*m));
 
-    if(tag) {
+    if (tag) {
         if (flags & AV_DICT_DONT_OVERWRITE)
             return 0;
         if (flags & AV_DICT_APPEND)
@@ -78,17 +85,18 @@ int av_dict_set(AVDictionary **pm, const char *key, const char *value, int flags
         av_free(tag->key);
         *tag = m->elems[--m->count];
     } else {
-        AVDictionaryEntry *tmp = av_realloc(m->elems, (m->count+1) * sizeof(*m->elems));
-        if(tmp) {
+        AVDictionaryEntry *tmp = av_realloc(m->elems,
+                                            (m->count + 1) * sizeof(*m->elems));
+        if (tmp)
             m->elems = tmp;
-        } else
+        else
             return AVERROR(ENOMEM);
     }
     if (value) {
-        if (flags & AV_DICT_DONT_STRDUP_KEY) {
-            m->elems[m->count].key  = key;
-        } else
-        m->elems[m->count].key  = av_strdup(key  );
+        if (flags & AV_DICT_DONT_STRDUP_KEY)
+            m->elems[m->count].key = key;
+        else
+            m->elems[m->count].key = av_strdup(key);
         if (flags & AV_DICT_DONT_STRDUP_VAL) {
             m->elems[m->count].value = value;
         } else if (oldval && flags & AV_DICT_APPEND) {
@@ -161,7 +169,7 @@ void av_dict_free(AVDictionary **pm)
     AVDictionary *m = *pm;
 
     if (m) {
-        while(m->count--) {
+        while (m->count--) {
             av_free(m->elems[m->count].key);
             av_free(m->elems[m->count].value);
         }
diff --git a/deps/libav/libavutil/stereo3d.c b/deps/libav/libavutil/downmix_info.c
similarity index 60%
copy from deps/libav/libavutil/stereo3d.c
copy to deps/libav/libavutil/downmix_info.c
index 850fd75..51505c8 100644
--- a/deps/libav/libavutil/stereo3d.c
+++ b/deps/libav/libavutil/downmix_info.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013 Vittorio Giovara <vittorio.giovara at gmail.com>
+ * Copyright (c) 2014 Tim Walker <tdskywalker at gmail.com>
  *
  * This file is part of Libav.
  *
@@ -18,23 +18,21 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
-#include <stdint.h>
+#include "downmix_info.h"
+#include "frame.h"
 
-#include "mem.h"
-#include "stereo3d.h"
-
-AVStereo3D *av_stereo3d_alloc(void)
+AVDownmixInfo *av_downmix_info_update_side_data(AVFrame *frame)
 {
-    return av_mallocz(sizeof(AVStereo3D));
-}
+    AVFrameSideData *side_data;
+
+    side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_DOWNMIX_INFO);
+
+    if (!side_data)
+        side_data = av_frame_new_side_data(frame, AV_FRAME_DATA_DOWNMIX_INFO,
+                                           sizeof(AVDownmixInfo));
 
-AVStereo3D *av_stereo3d_create_side_data(AVFrame *frame)
-{
-    AVFrameSideData *side_data = av_frame_new_side_data(frame,
-                                                        AV_FRAME_DATA_STEREO3D,
-                                                        sizeof(AVStereo3D));
     if (!side_data)
         return NULL;
 
-    return (AVStereo3D *)side_data->data;
+    return (AVDownmixInfo*)side_data->data;
 }
diff --git a/deps/libav/libavutil/downmix_info.h b/deps/libav/libavutil/downmix_info.h
new file mode 100644
index 0000000..69969f6
--- /dev/null
+++ b/deps/libav/libavutil/downmix_info.h
@@ -0,0 +1,114 @@
+/*
+ * Copyright (c) 2014 Tim Walker <tdskywalker at gmail.com>
+ *
+ * This file is part of Libav.
+ *
+ * Libav is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * Libav is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with Libav; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef AVUTIL_DOWNMIX_INFO_H
+#define AVUTIL_DOWNMIX_INFO_H
+
+#include "frame.h"
+
+/**
+ * @file
+ * audio downmix medatata
+ */
+
+/**
+ * @addtogroup lavu_audio
+ * @{
+ */
+
+/**
+ * @defgroup downmix_info Audio downmix metadata
+ * @{
+ */
+
+/**
+ * Possible downmix types.
+ */
+enum AVDownmixType {
+    AV_DOWNMIX_TYPE_UNKNOWN, /**< Not indicated. */
+    AV_DOWNMIX_TYPE_LORO,    /**< Lo/Ro 2-channel downmix (Stereo). */
+    AV_DOWNMIX_TYPE_LTRT,    /**< Lt/Rt 2-channel downmix, Dolby Surround compatible. */
+    AV_DOWNMIX_TYPE_DPLII,   /**< Lt/Rt 2-channel downmix, Dolby Pro Logic II compatible. */
+    AV_DOWNMIX_TYPE_NB       /**< Number of downmix types. Not part of ABI. */
+};
+
+/**
+ * This structure describes optional metadata relevant to a downmix procedure.
+ *
+ * All fields are set by the decoder to the value indicated in the audio
+ * bitstream (if present), or to a "sane" default otherwise.
+ */
+typedef struct AVDownmixInfo {
+    /**
+     * Type of downmix preferred by the mastering engineer.
+     */
+    enum AVDownmixType preferred_downmix_type;
+
+    /**
+     * Absolute scale factor representing the nominal level of the center
+     * channel during a regular downmix.
+     */
+    double center_mix_level;
+
+    /**
+     * Absolute scale factor representing the nominal level of the center
+     * channel during an Lt/Rt compatible downmix.
+     */
+    double center_mix_level_ltrt;
+
+    /**
+     * Absolute scale factor representing the nominal level of the surround
+     * channels during a regular downmix.
+     */
+    double surround_mix_level;
+
+    /**
+     * Absolute scale factor representing the nominal level of the surround
+     * channels during an Lt/Rt compatible downmix.
+     */
+    double surround_mix_level_ltrt;
+
+    /**
+     * Absolute scale factor representing the level at which the LFE data is
+     * mixed into L/R channels during downmixing.
+     */
+    double lfe_mix_level;
+} AVDownmixInfo;
+
+/**
+ * Get a frame's AV_FRAME_DATA_DOWNMIX_INFO side data for editing.
+ *
+ * The side data is created and added to the frame if it's absent.
+ *
+ * @param frame the frame for which the side data is to be obtained.
+ *
+ * @return the AVDownmixInfo structure to be edited by the caller.
+ */
+AVDownmixInfo *av_downmix_info_update_side_data(AVFrame *frame);
+
+/**
+ * @}
+ */
+
+/**
+ * @}
+ */
+
+#endif /* AVUTIL_DOWNMIX_INFO_H */
diff --git a/deps/libav/libavutil/float_dsp.h b/deps/libav/libavutil/float_dsp.h
index b215dad..0eb02f8 100644
--- a/deps/libav/libavutil/float_dsp.h
+++ b/deps/libav/libavutil/float_dsp.h
@@ -113,7 +113,7 @@ typedef struct AVFloatDSPContext {
      *             constraints: 32-byte aligned
      * @param src1 second input vector
      *             constraints: 32-byte aligned
-     * @param src1 third input vector
+     * @param src2 third input vector
      *             constraints: 32-byte aligned
      * @param len  number of elements in the input
      *             constraints: multiple of 16
@@ -132,8 +132,6 @@ typedef struct AVFloatDSPContext {
      *             constraints: 32-byte aligned
      * @param src1 second input vector
      *             constraints: 32-byte aligned
-     * @param src1 third input vector
-     *             constraints: 32-byte aligned
      * @param len  number of elements in the input
      *             constraints: multiple of 16
      */
diff --git a/deps/libav/libavutil/frame.c b/deps/libav/libavutil/frame.c
index 2529ae5..f81bbbd 100644
--- a/deps/libav/libavutil/frame.c
+++ b/deps/libav/libavutil/frame.c
@@ -191,15 +191,11 @@ int av_frame_ref(AVFrame *dst, const AVFrame *src)
         if (ret < 0)
             return ret;
 
-        if (src->nb_samples) {
-            int ch = av_get_channel_layout_nb_channels(src->channel_layout);
-            av_samples_copy(dst->extended_data, src->extended_data, 0, 0,
-                            dst->nb_samples, ch, dst->format);
-        } else {
-            av_image_copy(dst->data, dst->linesize, src->data, src->linesize,
-                          dst->format, dst->width, dst->height);
-        }
-        return 0;
+        ret = av_frame_copy(dst, src);
+        if (ret < 0)
+            av_frame_unref(dst);
+
+        return ret;
     }
 
     /* ref the buffers */
@@ -335,13 +331,10 @@ int av_frame_make_writable(AVFrame *frame)
     if (ret < 0)
         return ret;
 
-    if (tmp.nb_samples) {
-        int ch = av_get_channel_layout_nb_channels(tmp.channel_layout);
-        av_samples_copy(tmp.extended_data, frame->extended_data, 0, 0,
-                        frame->nb_samples, ch, frame->format);
-    } else {
-        av_image_copy(tmp.data, tmp.linesize, frame->data, frame->linesize,
-                      frame->format, frame->width, frame->height);
+    ret = av_frame_copy(&tmp, frame);
+    if (ret < 0) {
+        av_frame_unref(&tmp);
+        return ret;
     }
 
     ret = av_frame_copy_props(&tmp, frame);
@@ -477,3 +470,59 @@ AVFrameSideData *av_frame_get_side_data(const AVFrame *frame,
     }
     return NULL;
 }
+
+static int frame_copy_video(AVFrame *dst, const AVFrame *src)
+{
+    const uint8_t *src_data[4];
+    int i, planes;
+
+    if (dst->width  != src->width ||
+        dst->height != src->height)
+        return AVERROR(EINVAL);
+
+    planes = av_pix_fmt_count_planes(dst->format);
+    for (i = 0; i < planes; i++)
+        if (!dst->data[i] || !src->data[i])
+            return AVERROR(EINVAL);
+
+    memcpy(src_data, src->data, sizeof(src_data));
+    av_image_copy(dst->data, dst->linesize,
+                  src_data, src->linesize,
+                  dst->format, dst->width, dst->height);
+
+    return 0;
+}
+
+static int frame_copy_audio(AVFrame *dst, const AVFrame *src)
+{
+    int planar   = av_sample_fmt_is_planar(dst->format);
+    int channels = av_get_channel_layout_nb_channels(dst->channel_layout);
+    int planes   = planar ? channels : 1;
+    int i;
+
+    if (dst->nb_samples     != src->nb_samples ||
+        dst->channel_layout != src->channel_layout)
+        return AVERROR(EINVAL);
+
+    for (i = 0; i < planes; i++)
+        if (!dst->extended_data[i] || !src->extended_data[i])
+            return AVERROR(EINVAL);
+
+    av_samples_copy(dst->extended_data, src->extended_data, 0, 0,
+                    dst->nb_samples, channels, dst->format);
+
+    return 0;
+}
+
+int av_frame_copy(AVFrame *dst, const AVFrame *src)
+{
+    if (dst->format != src->format || dst->format < 0)
+        return AVERROR(EINVAL);
+
+    if (dst->width > 0 && dst->height > 0)
+        return frame_copy_video(dst, src);
+    else if (dst->nb_samples > 0 && dst->channel_layout)
+        return frame_copy_audio(dst, src);
+
+    return AVERROR(EINVAL);
+}
diff --git a/deps/libav/libavutil/frame.h b/deps/libav/libavutil/frame.h
index 5b04291..6b168e2 100644
--- a/deps/libav/libavutil/frame.h
+++ b/deps/libav/libavutil/frame.h
@@ -64,6 +64,11 @@ enum AVFrameSideDataType {
      * The data is the AVMatrixEncoding enum defined in libavutil/channel_layout.h.
      */
     AV_FRAME_DATA_MATRIXENCODING,
+    /**
+     * Metadata relevant to a downmix procedure.
+     * The data is the AVDownmixInfo struct defined in libavutil/downmix_info.h.
+     */
+    AV_FRAME_DATA_DOWNMIX_INFO,
 };
 
 typedef struct AVFrameSideData {
@@ -423,7 +428,7 @@ AVFrame *av_frame_alloc(void);
 void av_frame_free(AVFrame **frame);
 
 /**
- * Setup a new reference to the data described by an given frame.
+ * Set up a new reference to the data described by the source frame.
  *
  * Copy frame properties from src to dst and create a new reference for each
  * AVBufferRef from src.
@@ -501,6 +506,19 @@ int av_frame_is_writable(AVFrame *frame);
 int av_frame_make_writable(AVFrame *frame);
 
 /**
+ * Copy the frame data from src to dst.
+ *
+ * This function does not allocate anything, dst must be already initialized and
+ * allocated with the same parameters as src.
+ *
+ * This function only copies the frame data (i.e. the contents of the data /
+ * extended data arrays), not any other properties.
+ *
+ * @return >= 0 on success, a negative AVERROR on error.
+ */
+int av_frame_copy(AVFrame *dst, const AVFrame *src);
+
+/**
  * Copy only "metadata" fields from src to dst.
  *
  * Metadata for the purpose of this function are those fields that do not affect
diff --git a/deps/libav/libavutil/opt.c b/deps/libav/libavutil/opt.c
index ede4a49..9f9f1f2 100644
--- a/deps/libav/libavutil/opt.c
+++ b/deps/libav/libavutil/opt.c
@@ -213,7 +213,7 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
     const AVOption *o = av_opt_find2(obj, name, NULL, 0, search_flags, &target_obj);
     if (!o || !target_obj)
         return AVERROR_OPTION_NOT_FOUND;
-    if (!val)
+    if (!val || o->flags & AV_OPT_FLAG_READONLY)
         return AVERROR(EINVAL);
 
     dst = ((uint8_t*)target_obj) + o->offset;
@@ -235,7 +235,7 @@ int av_opt_set(void *obj, const char *name, const char *val, int search_flags)
 #define OPT_EVAL_NUMBER(name, opttype, vartype)\
     int av_opt_eval_ ## name(void *obj, const AVOption *o, const char *val, vartype *name ## _out)\
     {\
-        if (!o || o->type != opttype)\
+        if (!o || o->type != opttype || o->flags & AV_OPT_FLAG_READONLY)\
             return AVERROR(EINVAL);\
         return set_string_number(obj, obj, o, val, name ## _out);\
     }
@@ -256,6 +256,9 @@ static int set_number(void *obj, const char *name, double num, int den, int64_t
     if (!o || !target_obj)
         return AVERROR_OPTION_NOT_FOUND;
 
+    if (o->flags & AV_OPT_FLAG_READONLY)
+        return AVERROR(EINVAL);
+
     dst = ((uint8_t*)target_obj) + o->offset;
     return write_number(obj, o, dst, num, den, intnum);
 }
@@ -286,7 +289,7 @@ int av_opt_set_bin(void *obj, const char *name, const uint8_t *val, int len, int
     if (!o || !target_obj)
         return AVERROR_OPTION_NOT_FOUND;
 
-    if (o->type != AV_OPT_TYPE_BINARY)
+    if (o->type != AV_OPT_TYPE_BINARY || o->flags & AV_OPT_FLAG_READONLY)
         return AVERROR(EINVAL);
 
     ptr = av_malloc(len);
@@ -479,6 +482,8 @@ static void opt_list(void *obj, void *av_log_obj, const char *unit,
         av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_VIDEO_PARAM   ) ? 'V' : '.');
         av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_AUDIO_PARAM   ) ? 'A' : '.');
         av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_SUBTITLE_PARAM) ? 'S' : '.');
+        av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_EXPORT)         ? 'X' : '.');
+        av_log(av_log_obj, AV_LOG_INFO, "%c", (opt->flags & AV_OPT_FLAG_READONLY)       ? 'R' : '.');
 
         if (opt->help)
             av_log(av_log_obj, AV_LOG_INFO, " %s", opt->help);
@@ -505,6 +510,9 @@ void av_opt_set_defaults(void *s)
 {
     const AVOption *opt = NULL;
     while ((opt = av_opt_next(s, opt)) != NULL) {
+        if (opt->flags & AV_OPT_FLAG_READONLY)
+            continue;
+
         switch (opt->type) {
             case AV_OPT_TYPE_CONST:
                 /* Nothing to be done here */
diff --git a/deps/libav/libavutil/opt.h b/deps/libav/libavutil/opt.h
index 0181379..b90feaa 100644
--- a/deps/libav/libavutil/opt.h
+++ b/deps/libav/libavutil/opt.h
@@ -262,10 +262,21 @@ typedef struct AVOption {
     int flags;
 #define AV_OPT_FLAG_ENCODING_PARAM  1   ///< a generic parameter which can be set by the user for muxing or encoding
 #define AV_OPT_FLAG_DECODING_PARAM  2   ///< a generic parameter which can be set by the user for demuxing or decoding
+#if FF_API_OPT_TYPE_METADATA
 #define AV_OPT_FLAG_METADATA        4   ///< some data extracted or inserted into the file like title, comment, ...
+#endif
 #define AV_OPT_FLAG_AUDIO_PARAM     8
 #define AV_OPT_FLAG_VIDEO_PARAM     16
 #define AV_OPT_FLAG_SUBTITLE_PARAM  32
+/**
+ * The option is inteded for exporting values to the caller.
+ */
+#define AV_OPT_FLAG_EXPORT          64
+/**
+ * The option may not be set through the AVOptions API, only read.
+ * This flag only makes sense when AV_OPT_FLAG_EXPORT is also set.
+ */
+#define AV_OPT_FLAG_READONLY        128
 //FIXME think about enc-audio, ... style flags
 
     /**
diff --git a/deps/libav/libavutil/timer.h b/deps/libav/libavutil/timer.h
index d2c5001..0d93d7c 100644
--- a/deps/libav/libavutil/timer.h
+++ b/deps/libav/libavutil/timer.h
@@ -32,6 +32,10 @@
 
 #include "config.h"
 
+#if HAVE_MACH_MACH_TIME_H
+#include <mach/mach_time.h>
+#endif
+
 #include "log.h"
 
 #if   ARCH_ARM
@@ -44,8 +48,12 @@
 #   include "x86/timer.h"
 #endif
 
-#if !defined(AV_READ_TIME) && HAVE_GETHRTIME
-#   define AV_READ_TIME gethrtime
+#if !defined(AV_READ_TIME)
+#   if HAVE_GETHRTIME
+#       define AV_READ_TIME gethrtime
+#   elif HAVE_MACH_ABSOLUTE_TIME
+#       define AV_READ_TIME mach_absolute_time
+#   endif
 #endif
 
 #ifdef AV_READ_TIME
@@ -68,7 +76,7 @@
             tskip_count++;                                                \
         if (((tcount + tskip_count) & (tcount + tskip_count - 1)) == 0) { \
             av_log(NULL, AV_LOG_ERROR,                                    \
-                   "%"PRIu64" decicycles in %s, %d runs, %d skips\n",     \
+                   "%"PRIu64" UNITS in %s, %d runs, %d skips\n",          \
                    tsum * 10 / tcount, id, tcount, tskip_count);          \
         }                                                                 \
     }
diff --git a/deps/libav/libavutil/version.h b/deps/libav/libavutil/version.h
index e95d77c..cd0981c 100644
--- a/deps/libav/libavutil/version.h
+++ b/deps/libav/libavutil/version.h
@@ -54,7 +54,7 @@
  */
 
 #define LIBAVUTIL_VERSION_MAJOR 53
-#define LIBAVUTIL_VERSION_MINOR  2
+#define LIBAVUTIL_VERSION_MINOR  5
 #define LIBAVUTIL_VERSION_MICRO  0
 
 #define LIBAVUTIL_VERSION_INT   AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
@@ -108,6 +108,9 @@
 #ifndef FF_API_XVMC
 #define FF_API_XVMC                     (LIBAVUTIL_VERSION_MAJOR < 54)
 #endif
+#ifndef FF_API_OPT_TYPE_METADATA
+#define FF_API_OPT_TYPE_METADATA        (LIBAVUTIL_VERSION_MAJOR < 54)
+#endif
 
 /**
  * @}
diff --git a/deps/libav/libavutil/x86/cpu.c b/deps/libav/libavutil/x86/cpu.c
index 0e06d5d..8be6d94 100644
--- a/deps/libav/libavutil/x86/cpu.c
+++ b/deps/libav/libavutil/x86/cpu.c
@@ -131,19 +131,27 @@ int ff_get_cpu_flags_x86(void)
         if ((ecx & 0x18000000) == 0x18000000) {
             /* Check for OS support */
             xgetbv(0, eax, edx);
-            if ((eax & 0x6) == 0x6)
+            if ((eax & 0x6) == 0x6) {
                 rval |= AV_CPU_FLAG_AVX;
+                if (ecx & 0x00001000)
+                    rval |= AV_CPU_FLAG_FMA3;
+            }
         }
-#if HAVE_AVX2
+#endif /* HAVE_AVX */
+#endif /* HAVE_SSE */
+    }
     if (max_std_level >= 7) {
         cpuid(7, eax, ebx, ecx, edx);
-        if (ebx&0x00000020)
+#if HAVE_AVX2
+        if (ebx & 0x00000020)
             rval |= AV_CPU_FLAG_AVX2;
-        /* TODO: BMI1/2 */
-    }
 #endif /* HAVE_AVX2 */
-#endif /* HAVE_AVX */
-#endif /* HAVE_SSE */
+        /* BMI1/2 don't need OS support */
+        if (ebx & 0x00000008) {
+            rval |= AV_CPU_FLAG_BMI1;
+            if (ebx & 0x00000100)
+                rval |= AV_CPU_FLAG_BMI2;
+        }
     }
 
     cpuid(0x80000000, max_ext_level, ebx, ecx, edx);
diff --git a/deps/libav/libavutil/x86/cpu.h b/deps/libav/libavutil/x86/cpu.h
index 5303c5a..50da30e 100644
--- a/deps/libav/libavutil/x86/cpu.h
+++ b/deps/libav/libavutil/x86/cpu.h
@@ -37,6 +37,8 @@
 #define X86_SSE4(flags)             CPUEXT(flags, SSE4)
 #define X86_SSE42(flags)            CPUEXT(flags, SSE42)
 #define X86_AVX(flags)              CPUEXT(flags, AVX)
+#define X86_XOP(flags)              CPUEXT(flags, XOP)
+#define X86_FMA3(flags)             CPUEXT(flags, FMA3)
 #define X86_FMA4(flags)             CPUEXT(flags, FMA4)
 #define X86_AVX2(flags)             CPUEXT(flags, AVX2)
 
@@ -51,6 +53,8 @@
 #define EXTERNAL_SSE4(flags)        CPUEXT_SUFFIX(flags, _EXTERNAL, SSE4)
 #define EXTERNAL_SSE42(flags)       CPUEXT_SUFFIX(flags, _EXTERNAL, SSE42)
 #define EXTERNAL_AVX(flags)         CPUEXT_SUFFIX(flags, _EXTERNAL, AVX)
+#define EXTERNAL_XOP(flags)         CPUEXT_SUFFIX(flags, _EXTERNAL, XOP)
+#define EXTERNAL_FMA3(flags)        CPUEXT_SUFFIX(flags, _EXTERNAL, FMA3)
 #define EXTERNAL_FMA4(flags)        CPUEXT_SUFFIX(flags, _EXTERNAL, FMA4)
 #define EXTERNAL_AVX2(flags)        CPUEXT_SUFFIX(flags, _EXTERNAL, AVX2)
 
@@ -65,6 +69,8 @@
 #define INLINE_SSE4(flags)          CPUEXT_SUFFIX(flags, _INLINE, SSE4)
 #define INLINE_SSE42(flags)         CPUEXT_SUFFIX(flags, _INLINE, SSE42)
 #define INLINE_AVX(flags)           CPUEXT_SUFFIX(flags, _INLINE, AVX)
+#define INLINE_XOP(flags)           CPUEXT_SUFFIX(flags, _INLINE, XOP)
+#define INLINE_FMA3(flags)          CPUEXT_SUFFIX(flags, _INLINE, FMA3)
 #define INLINE_FMA4(flags)          CPUEXT_SUFFIX(flags, _INLINE, FMA4)
 #define INLINE_AVX2(flags)          CPUEXT_SUFFIX(flags, _INLINE, AVX2)
 
diff --git a/deps/libav/libavutil/x86/float_dsp.asm b/deps/libav/libavutil/x86/float_dsp.asm
index 10330ff..d962499 100644
--- a/deps/libav/libavutil/x86/float_dsp.asm
+++ b/deps/libav/libavutil/x86/float_dsp.asm
@@ -27,17 +27,21 @@ SECTION .text
 ;-----------------------------------------------------------------------------
 %macro VECTOR_FMUL 0
 cglobal vector_fmul, 4,4,2, dst, src0, src1, len
-    lea       lenq, [lend*4 - 2*mmsize]
+    lea       lenq, [lend*4 - 64]
 ALIGN 16
 .loop:
-    mova      m0,   [src0q + lenq]
-    mova      m1,   [src0q + lenq + mmsize]
-    mulps     m0, m0, [src1q + lenq]
-    mulps     m1, m1, [src1q + lenq + mmsize]
-    mova      [dstq + lenq], m0
-    mova      [dstq + lenq + mmsize], m1
+%assign a 0
+%rep 32/mmsize
+    mova      m0,   [src0q + lenq + (a+0)*mmsize]
+    mova      m1,   [src0q + lenq + (a+1)*mmsize]
+    mulps     m0, m0, [src1q + lenq + (a+0)*mmsize]
+    mulps     m1, m1, [src1q + lenq + (a+1)*mmsize]
+    mova      [dstq + lenq + (a+0)*mmsize], m0
+    mova      [dstq + lenq + (a+1)*mmsize], m1
+%assign a a+2
+%endrep
 
-    sub       lenq, 2*mmsize
+    sub       lenq, 64
     jge       .loop
     REP_RET
 %endmacro
@@ -68,15 +72,19 @@ cglobal vector_fmac_scalar, 4,4,3, dst, src, mul, len
     vinsertf128  m0, m0, xmm0, 1
 %endif
 %endif
-    lea    lenq, [lend*4-2*mmsize]
+    lea    lenq, [lend*4-64]
 .loop:
-    mulps    m1, m0, [srcq+lenq       ]
-    mulps    m2, m0, [srcq+lenq+mmsize]
-    addps    m1, m1, [dstq+lenq       ]
-    addps    m2, m2, [dstq+lenq+mmsize]
-    mova  [dstq+lenq       ], m1
-    mova  [dstq+lenq+mmsize], m2
-    sub    lenq, 2*mmsize
+%assign a 0
+%rep 32/mmsize
+    mulps    m1, m0, [srcq+lenq+(a+0)*mmsize]
+    mulps    m2, m0, [srcq+lenq+(a+1)*mmsize]
+    addps    m1, m1, [dstq+lenq+(a+0)*mmsize]
+    addps    m2, m2, [dstq+lenq+(a+1)*mmsize]
+    mova  [dstq+lenq+(a+0)*mmsize], m1
+    mova  [dstq+lenq+(a+1)*mmsize], m2
+%assign a a+2
+%endrep
+    sub    lenq, 64
     jge .loop
     REP_RET
 %endmacro
diff --git a/deps/libav/library.mak b/deps/libav/library.mak
index 3876fe3..af33206 100644
--- a/deps/libav/library.mak
+++ b/deps/libav/library.mak
@@ -42,10 +42,10 @@ install-libs-$(CONFIG_STATIC): install-lib$(NAME)-static
 install-libs-$(CONFIG_SHARED): install-lib$(NAME)-shared
 
 define RULES
-$(EXAMPLES) $(TOOLS): THISLIB = $(FULLNAME:%=$(LD_LIB))
-$(TESTPROGS):         THISLIB = $(SUBDIR)$(LIBNAME)
+$(TOOLS):     THISLIB = $(FULLNAME:%=$(LD_LIB))
+$(TESTPROGS): THISLIB = $(SUBDIR)$(LIBNAME)
 
-$(EXAMPLES) $(TESTPROGS) $(TOOLS): %$(EXESUF): %.o $(EXEOBJS)
+$(TESTPROGS) $(TOOLS): %$(EXESUF): %.o $(EXEOBJS)
 	$$(LD) $(LDFLAGS) $$(LD_O) $$(filter %.o,$$^) $$(THISLIB) $(FFEXTRALIBS) $$(ELIBS)
 
 $(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
@@ -57,7 +57,7 @@ $(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(OBJS) $(SUBDIR)lib$(NAME).ver $(DEP_LIBS)
 	$(SLIB_EXTRA_CMD)
 
 clean::
-	$(RM) $(addprefix $(SUBDIR),*-example$(EXESUF) *-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
+	$(RM) $(addprefix $(SUBDIR),*-test$(EXESUF) $(CLEANFILES) $(CLEANSUFFIXES) $(LIBSUFFIXES)) \
 	    $(CLEANSUFFIXES:%=$(SUBDIR)$(ARCH)/%)
 
 distclean:: clean
@@ -100,8 +100,7 @@ endef
 
 $(eval $(RULES))
 
-$(EXAMPLES) $(TOOLS): $(DEP_LIBS) $(SUBDIR)$($(CONFIG_SHARED:yes=S)LIBNAME)
-$(TESTPROGS):         $(DEP_LIBS) $(SUBDIR)$(LIBNAME)
+$(TOOLS):     $(DEP_LIBS) $(SUBDIR)$($(CONFIG_SHARED:yes=S)LIBNAME)
+$(TESTPROGS): $(DEP_LIBS) $(SUBDIR)$(LIBNAME)
 
-examples: $(EXAMPLES)
 testprogs: $(TESTPROGS)
diff --git a/deps/libav/libswscale/bfin/internal_bfin.S b/deps/libav/libswscale/bfin/internal_bfin.S
index b007f07..dca8448 100644
--- a/deps/libav/libswscale/bfin/internal_bfin.S
+++ b/deps/libav/libswscale/bfin/internal_bfin.S
@@ -93,23 +93,9 @@ huge variation on the reference codes on Blackfin I guess it must have
 to do with the memory system.
 */
 
-#define mL3 .text
-#if defined(__FDPIC__) && CONFIG_SRAM
-#define mL1 .l1.text
-#else
-#define mL1 mL3
-#endif
-#define MEM mL1
-
-#define DEFUN(fname,where,interface) \
-        .section where;              \
-        .global _ff_bfin_ ## fname;  \
-        .type _ff_bfin_ ## fname, STT_FUNC; \
-        .align 8;                    \
-        _ff_bfin_ ## fname
+#include "libavutil/bfin/asm.h"
 
-#define DEFUN_END(fname) \
-        .size _ff_bfin_ ## fname, . - _ff_bfin_ ## fname
+#define MEM mL1
 
 
 .text
diff --git a/deps/libav/libswscale/bfin/swscale_bfin.c b/deps/libav/libswscale/bfin/swscale_bfin.c
index 43c23b4..97270b8 100644
--- a/deps/libav/libswscale/bfin/swscale_bfin.c
+++ b/deps/libav/libswscale/bfin/swscale_bfin.c
@@ -24,21 +24,18 @@
 
 #include "config.h"
 #include "libavutil/attributes.h"
+#include "libavutil/bfin/attributes.h"
 #include "libswscale/swscale_internal.h"
 
-#if defined (__FDPIC__) && CONFIG_SRAM
-#define L1CODE __attribute__((l1_text))
-#else
-#define L1CODE
-#endif
-
 int ff_bfin_uyvytoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
                        uint8_t *vdst, int width, int height,
-                       int lumStride, int chromStride, int srcStride) L1CODE;
+                       int lumStride, int chromStride,
+                       int srcStride) attribute_l1_text;
 
 int ff_bfin_yuyvtoyv12(const uint8_t *src, uint8_t *ydst, uint8_t *udst,
                        uint8_t *vdst, int width, int height,
-                       int lumStride, int chromStride, int srcStride) L1CODE;
+                       int lumStride, int chromStride,
+                       int srcStride) attribute_l1_text;
 
 static int uyvytoyv12_unscaled(SwsContext *c, const uint8_t *src[],
                                int srcStride[], int srcSliceY, int srcSliceH,
diff --git a/deps/libav/libswscale/bfin/yuv2rgb_bfin.c b/deps/libav/libswscale/bfin/yuv2rgb_bfin.c
index 603a33a..295dc28 100644
--- a/deps/libav/libswscale/bfin/yuv2rgb_bfin.c
+++ b/deps/libav/libswscale/bfin/yuv2rgb_bfin.c
@@ -25,25 +25,20 @@
 
 #include "config.h"
 #include "libavutil/attributes.h"
+#include "libavutil/bfin/attributes.h"
 #include "libswscale/swscale_internal.h"
 
-#if defined(__FDPIC__) && CONFIG_SRAM
-#define L1CODE __attribute__((l1_text))
-#else
-#define L1CODE
-#endif
-
 void ff_bfin_yuv2rgb555_line(const uint8_t *Y, const uint8_t *U,
                              const uint8_t *V, uint8_t *out,
-                             int w, uint32_t *coeffs) L1CODE;
+                             int w, uint32_t *coeffs) attribute_l1_text;
 
 void ff_bfin_yuv2rgb565_line(const uint8_t *Y, const uint8_t *U,
                              const uint8_t *V, uint8_t *out,
-                             int w, uint32_t *coeffs) L1CODE;
+                             int w, uint32_t *coeffs) attribute_l1_text;
 
 void ff_bfin_yuv2rgb24_line(const uint8_t *Y, const uint8_t *U,
                             const uint8_t *V, uint8_t *out,
-                            int w, uint32_t *coeffs) L1CODE;
+                            int w, uint32_t *coeffs) attribute_l1_text;
 
 typedef void (*ltransform)(const uint8_t *Y, const uint8_t *U, const uint8_t *V,
                            uint8_t *out, int w, uint32_t *coeffs);
diff --git a/deps/libav/libswscale/sparc/Makefile b/deps/libav/libswscale/sparc/Makefile
deleted file mode 100644
index 2351ba4..0000000
--- a/deps/libav/libswscale/sparc/Makefile
+++ /dev/null
@@ -1 +0,0 @@
-VIS-OBJS += sparc/yuv2rgb_vis.o                                         \
diff --git a/deps/libav/libswscale/sparc/yuv2rgb_vis.c b/deps/libav/libswscale/sparc/yuv2rgb_vis.c
deleted file mode 100644
index cd8a8b0..0000000
--- a/deps/libav/libswscale/sparc/yuv2rgb_vis.c
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * VIS optimized software YUV to RGB converter
- * Copyright (c) 2007 Denes Balatoni <dbalatoni at programozo.hu>
- *
- * This file is part of Libav.
- *
- * Libav is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * Libav is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with Libav; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#include <inttypes.h>
-#include <stdlib.h>
-
-#include "libavutil/attributes.h"
-#include "libswscale/swscale.h"
-#include "libswscale/swscale_internal.h"
-
-#define YUV2RGB_INIT                               \
-    "wr %%g0, 0x10, %%gsr \n\t"                    \
-    "ldd [%5],      %%f32 \n\t"                    \
-    "ldd [%5 +  8], %%f34 \n\t"                    \
-    "ldd [%5 + 16], %%f36 \n\t"                    \
-    "ldd [%5 + 24], %%f38 \n\t"                    \
-    "ldd [%5 + 32], %%f40 \n\t"                    \
-    "ldd [%5 + 40], %%f42 \n\t"                    \
-    "ldd [%5 + 48], %%f44 \n\t"                    \
-    "ldd [%5 + 56], %%f46 \n\t"                    \
-    "ldd [%5 + 64], %%f48 \n\t"                    \
-    "ldd [%5 + 72], %%f50 \n\t"
-
-#define YUV2RGB_KERNEL                             \
-    /* ^^^^ f0=Y f3=u f5=v */                      \
-    "fmul8x16 %%f3,  %%f48,  %%f6 \n\t"            \
-    "fmul8x16 %%f19, %%f48, %%f22 \n\t"            \
-    "fmul8x16 %%f5,  %%f44,  %%f8 \n\t"            \
-    "fmul8x16 %%f21, %%f44, %%f24 \n\t"            \
-    "fmul8x16 %%f0,  %%f42,  %%f0 \n\t"            \
-    "fmul8x16 %%f16, %%f42, %%f16 \n\t"            \
-    "fmul8x16 %%f3,  %%f50,  %%f2 \n\t"            \
-    "fmul8x16 %%f19, %%f50, %%f18 \n\t"            \
-    "fmul8x16 %%f5,  %%f46,  %%f4 \n\t"            \
-    "fmul8x16 %%f21, %%f46, %%f20 \n\t"            \
-                                                   \
-    "fpsub16 %%f6,  %%f34,  %%f6 \n\t" /* 1 */     \
-    "fpsub16 %%f22, %%f34, %%f22 \n\t" /* 1 */     \
-    "fpsub16 %%f8,  %%f38,  %%f8 \n\t" /* 3 */     \
-    "fpsub16 %%f24, %%f38, %%f24 \n\t" /* 3 */     \
-    "fpsub16 %%f0,  %%f32,  %%f0 \n\t" /* 0 */     \
-    "fpsub16 %%f16, %%f32, %%f16 \n\t" /* 0 */     \
-    "fpsub16 %%f2,  %%f36,  %%f2 \n\t" /* 2 */     \
-    "fpsub16 %%f18, %%f36, %%f18 \n\t" /* 2 */     \
-    "fpsub16 %%f4,  %%f40,  %%f4 \n\t" /* 4 */     \
-    "fpsub16 %%f20, %%f40, %%f20 \n\t" /* 4 */     \
-                                                   \
-    "fpadd16 %%f0,  %%f8,  %%f8  \n\t" /* Gt */    \
-    "fpadd16 %%f16, %%f24, %%f24 \n\t" /* Gt */    \
-    "fpadd16 %%f0,  %%f4,  %%f4  \n\t" /* R */     \
-    "fpadd16 %%f16, %%f20, %%f20 \n\t" /* R */     \
-    "fpadd16 %%f0,  %%f6,  %%f6  \n\t" /* B */     \
-    "fpadd16 %%f16, %%f22, %%f22 \n\t" /* B */     \
-    "fpadd16 %%f8,  %%f2,  %%f2  \n\t" /* G */     \
-    "fpadd16 %%f24, %%f18, %%f18 \n\t" /* G */     \
-                                                   \
-    "fpack16 %%f4,  %%f4  \n\t"                    \
-    "fpack16 %%f20, %%f20 \n\t"                    \
-    "fpack16 %%f6,  %%f6  \n\t"                    \
-    "fpack16 %%f22, %%f22 \n\t"                    \
-    "fpack16 %%f2,  %%f2  \n\t"                    \
-    "fpack16 %%f18, %%f18 \n\t"
-
-// FIXME: must be changed to set alpha to 255 instead of 0
-static int vis_420P_ARGB32(SwsContext *c, uint8_t *src[], int srcStride[],
-                           int srcSliceY, int srcSliceH,
-                           uint8_t *dst[], int dstStride[])
-{
-    int y, out1, out2, out3, out4, out5, out6;
-
-    for (y = 0; y < srcSliceH; ++y)
-        __asm__ volatile (
-            YUV2RGB_INIT
-            "wr %%g0, 0xd2, %%asi        \n\t"  /* ASI_FL16_P */
-            "1:                          \n\t"
-            "ldda [%1]     %%asi, %%f2   \n\t"
-            "ldda [%1 + 2] %%asi, %%f18  \n\t"
-            "ldda [%2]     %%asi, %%f4   \n\t"
-            "ldda [%2 + 2] %%asi, %%f20  \n\t"
-            "ld [%0], %%f0               \n\t"
-            "ld [%0+4], %%f16            \n\t"
-            "fpmerge %%f3,  %%f3,  %%f2  \n\t"
-            "fpmerge %%f19, %%f19, %%f18 \n\t"
-            "fpmerge %%f5,  %%f5,  %%f4  \n\t"
-            "fpmerge %%f21, %%f21, %%f20 \n\t"
-            YUV2RGB_KERNEL
-            "fzero %%f0                  \n\t"
-            "fpmerge %%f4,  %%f6,  %%f8  \n\t"  // r, b, t1
-            "fpmerge %%f20, %%f22, %%f24 \n\t"  // r, b, t1
-            "fpmerge %%f0,  %%f2,  %%f10 \n\t"  // 0, g, t2
-            "fpmerge %%f0,  %%f18, %%f26 \n\t"  // 0, g, t2
-            "fpmerge %%f10, %%f8,  %%f4  \n\t"  // t2, t1, msb
-            "fpmerge %%f26, %%f24, %%f20 \n\t"  // t2, t1, msb
-            "fpmerge %%f11, %%f9,  %%f6  \n\t"  // t2, t1, lsb
-            "fpmerge %%f27, %%f25, %%f22 \n\t"  // t2, t1, lsb
-            "std %%f4,  [%3]             \n\t"
-            "std %%f20, [%3 + 16]        \n\t"
-            "std %%f6,  [%3 +  8]        \n\t"
-            "std %%f22, [%3 + 24]        \n\t"
-
-            "add %0, 8, %0   \n\t"
-            "add %1, 4, %1   \n\t"
-            "add %2, 4, %2   \n\t"
-            "subcc %4, 8, %4 \n\t"
-            "bne 1b          \n\t"
-            "add %3, 32, %3  \n\t"              // delay slot
-            : "=r" (out1), "=r" (out2), "=r" (out3), "=r" (out4), "=r" (out5), "=r" (out6)
-            : "0" (src[0] + (y + srcSliceY) * srcStride[0]), "1" (src[1] + ((y + srcSliceY) >> 1) * srcStride[1]),
-            "2" (src[2] + ((y + srcSliceY) >> 1) * srcStride[2]), "3" (dst[0] + (y + srcSliceY) * dstStride[0]),
-            "4" (c->dstW),
-            "5" (c->sparc_coeffs)
-            );
-
-    return srcSliceH;
-}
-
-// FIXME: must be changed to set alpha to 255 instead of 0
-static int vis_422P_ARGB32(SwsContext *c, uint8_t *src[], int srcStride[],
-                           int srcSliceY, int srcSliceH,
-                           uint8_t *dst[], int dstStride[])
-{
-    int y, out1, out2, out3, out4, out5, out6;
-
-    for (y = 0; y < srcSliceH; ++y)
-        __asm__ volatile (
-            YUV2RGB_INIT
-            "wr %%g0, 0xd2, %%asi        \n\t" /* ASI_FL16_P */
-            "1:                          \n\t"
-            "ldda [%1]     %%asi, %%f2   \n\t"
-            "ldda [%1 + 2] %%asi, %%f18  \n\t"
-            "ldda [%2]     %%asi, %%f4   \n\t"
-            "ldda [%2 + 2] %%asi, %%f20  \n\t"
-            "ld [%0],     %%f0           \n\t"
-            "ld [%0 + 4], %%f16          \n\t"
-            "fpmerge %%f3,  %%f3,  %%f2  \n\t"
-            "fpmerge %%f19, %%f19, %%f18 \n\t"
-            "fpmerge %%f5,  %%f5,  %%f4  \n\t"
-            "fpmerge %%f21, %%f21, %%f20 \n\t"
-            YUV2RGB_KERNEL
-            "fzero %%f0 \n\t"
-            "fpmerge %%f4,  %%f6,  %%f8  \n\t"  // r,b,t1
-            "fpmerge %%f20, %%f22, %%f24 \n\t"  // r,b,t1
-            "fpmerge %%f0,  %%f2,  %%f10 \n\t"  // 0,g,t2
-            "fpmerge %%f0,  %%f18, %%f26 \n\t"  // 0,g,t2
-            "fpmerge %%f10, %%f8,  %%f4  \n\t"  // t2,t1,msb
-            "fpmerge %%f26, %%f24, %%f20 \n\t"  // t2,t1,msb
-            "fpmerge %%f11, %%f9,  %%f6  \n\t"  // t2,t1,lsb
-            "fpmerge %%f27, %%f25, %%f22 \n\t"  // t2,t1,lsb
-            "std %%f4,  [%3]             \n\t"
-            "std %%f20, [%3 + 16]        \n\t"
-            "std %%f6,  [%3 + 8]         \n\t"
-            "std %%f22, [%3 + 24]        \n\t"
-
-            "add %0, 8, %0   \n\t"
-            "add %1, 4, %1   \n\t"
-            "add %2, 4, %2   \n\t"
-            "subcc %4, 8, %4 \n\t"
-            "bne 1b          \n\t"
-            "add %3, 32, %3  \n\t" //delay slot
-            : "=r" (out1), "=r" (out2), "=r" (out3), "=r" (out4), "=r" (out5), "=r" (out6)
-            : "0" (src[0] + (y + srcSliceY) * srcStride[0]), "1" (src[1] + (y + srcSliceY) * srcStride[1]),
-            "2" (src[2] + (y + srcSliceY) * srcStride[2]), "3" (dst[0] + (y + srcSliceY) * dstStride[0]),
-            "4" (c->dstW),
-            "5" (c->sparc_coeffs)
-            );
-
-    return srcSliceH;
-}
-
-av_cold SwsFunc ff_yuv2rgb_init_vis(SwsContext *c)
-{
-    c->sparc_coeffs[5] = c->yCoeff;
-    c->sparc_coeffs[6] = c->vgCoeff;
-    c->sparc_coeffs[7] = c->vrCoeff;
-    c->sparc_coeffs[8] = c->ubCoeff;
-    c->sparc_coeffs[9] = c->ugCoeff;
-
-    c->sparc_coeffs[0] = (((int16_t)c->yOffset * (int16_t)c->yCoeff  >> 11) & 0xffff) * 0x0001000100010001ULL;
-    c->sparc_coeffs[1] = (((int16_t)c->uOffset * (int16_t)c->ubCoeff >> 11) & 0xffff) * 0x0001000100010001ULL;
-    c->sparc_coeffs[2] = (((int16_t)c->uOffset * (int16_t)c->ugCoeff >> 11) & 0xffff) * 0x0001000100010001ULL;
-    c->sparc_coeffs[3] = (((int16_t)c->vOffset * (int16_t)c->vgCoeff >> 11) & 0xffff) * 0x0001000100010001ULL;
-    c->sparc_coeffs[4] = (((int16_t)c->vOffset * (int16_t)c->vrCoeff >> 11) & 0xffff) * 0x0001000100010001ULL;
-
-    if (c->dstFormat == AV_PIX_FMT_RGB32 && c->srcFormat == AV_PIX_FMT_YUV422P && (c->dstW & 7) == 0) {
-        av_log(c, AV_LOG_INFO,
-               "SPARC VIS accelerated YUV422P -> RGB32 (WARNING: alpha value is wrong)\n");
-        return vis_422P_ARGB32;
-    } else if (c->dstFormat == AV_PIX_FMT_RGB32 && c->srcFormat == AV_PIX_FMT_YUV420P && (c->dstW & 7) == 0) {
-        av_log(c, AV_LOG_INFO,
-               "SPARC VIS accelerated YUV420P -> RGB32 (WARNING: alpha value is wrong)\n");
-        return vis_420P_ARGB32;
-    }
-    return NULL;
-}
diff --git a/deps/libav/libswscale/swscale_internal.h b/deps/libav/libswscale/swscale_internal.h
index 5737724..228107a 100644
--- a/deps/libav/libswscale/swscale_internal.h
+++ b/deps/libav/libswscale/swscale_internal.h
@@ -450,10 +450,6 @@ typedef struct SwsContext {
     DECLARE_ALIGNED(4, uint32_t, gmask);
 #endif
 
-#if HAVE_VIS
-    DECLARE_ALIGNED(8, uint64_t, sparc_coeffs)[10];
-#endif
-
     /* function pointers for swscale() */
     yuv2planar1_fn yuv2plane1;
     yuv2planarX_fn yuv2planeX;
@@ -571,7 +567,6 @@ void updateMMXDitherTables(SwsContext *c, int dstY, int lumBufIndex, int chrBufI
                            int lastInLumBuf, int lastInChrBuf);
 
 SwsFunc ff_yuv2rgb_init_x86(SwsContext *c);
-SwsFunc ff_yuv2rgb_init_vis(SwsContext *c);
 SwsFunc ff_yuv2rgb_init_ppc(SwsContext *c);
 SwsFunc ff_yuv2rgb_init_bfin(SwsContext *c);
 
diff --git a/deps/libav/libswscale/yuv2rgb.c b/deps/libav/libswscale/yuv2rgb.c
index f939bbe..c8497dc 100644
--- a/deps/libav/libswscale/yuv2rgb.c
+++ b/deps/libav/libswscale/yuv2rgb.c
@@ -564,8 +564,6 @@ SwsFunc ff_yuv2rgb_get_func_ptr(SwsContext *c)
         t = ff_yuv2rgb_init_bfin(c);
     if (ARCH_PPC)
         t = ff_yuv2rgb_init_ppc(c);
-    if (HAVE_VIS)
-        t = ff_yuv2rgb_init_vis(c);
     if (ARCH_X86)
         t = ff_yuv2rgb_init_x86(c);
 
diff --git a/deps/libav/tests/fate/filter-video.mak b/deps/libav/tests/fate/filter-video.mak
index 8920701..2869932 100644
--- a/deps/libav/tests/fate/filter-video.mak
+++ b/deps/libav/tests/fate/filter-video.mak
@@ -56,6 +56,14 @@ FATE_FILTER_VSYNTH-$(call ALLYES, SETPTS_FILTER  SETTB_FILTER) += fate-filter-se
 fate-filter-setpts: tests/data/filtergraphs/setpts
 fate-filter-setpts: CMD = framecrc -c:v pgmyuv -i $(SRC) -filter_script $(TARGET_PATH)/tests/data/filtergraphs/setpts
 
+FATE_SHUFFLEPLANES += fate-filter-shuffleplanes-dup-luma
+fate-filter-shuffleplanes-dup-luma: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf format=yuva444p,shuffleplanes=0:0:0:0
+
+FATE_SHUFFLEPLANES += fate-filter-shuffleplanes-swapuv
+fate-filter-shuffleplanes-swapuv: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf shuffleplanes=0:2:1
+
+FATE_FILTER_VSYNTH-$(CONFIG_SHUFFLEPLANES_FILTER) += $(FATE_SHUFFLEPLANES)
+
 FATE_FILTER_VSYNTH-$(CONFIG_TRANSPOSE_FILTER) += fate-filter-transpose
 fate-filter-transpose: CMD = framecrc -c:v pgmyuv -i $(SRC) -vf transpose
 
diff --git a/deps/libav/tests/fate/utvideo.mak b/deps/libav/tests/fate/utvideo.mak
index 161674f..e1ef7ec 100644
--- a/deps/libav/tests/fate/utvideo.mak
+++ b/deps/libav/tests/fate/utvideo.mak
@@ -28,7 +28,7 @@ fate-utvideo_yuv422_median: CMD = framecrc -i $(TARGET_SAMPLES)/utvideo/utvideo_
 FATE_SAMPLES_AVCONV-$(call DEMDEC, AVI, UTVIDEO) += $(FATE_UTVIDEO)
 fate-utvideo: $(FATE_UTVIDEO)
 
-fate-utvideoenc%: CMD = framemd5 -f image2 -vcodec pgmyuv -i $(TARGET_PATH)/tests/vsynth1/%02d.pgm -vcodec utvideo -f avi -sws_flags +accurate_rnd+bitexact ${OPTS}
+fate-utvideoenc%: CMD = framemd5 -f image2 -vcodec pgmyuv -i $(TARGET_PATH)/tests/vsynth1/%02d.pgm -vcodec utvideo -slices 1 -f avi -sws_flags +accurate_rnd+bitexact ${OPTS}
 
 FATE_UTVIDEOENC += fate-utvideoenc_rgba_left
 fate-utvideoenc_rgba_left: OPTS = -pix_fmt rgba -pred left
diff --git a/deps/libav/tests/ref/fate/filter-shuffleplanes-dup-luma b/deps/libav/tests/ref/fate/filter-shuffleplanes-dup-luma
new file mode 100644
index 0000000..52041fa
--- /dev/null
+++ b/deps/libav/tests/ref/fate/filter-shuffleplanes-dup-luma
@@ -0,0 +1,51 @@
+#tb 0: 1/25
+0,          0,          0,        1,   405504, 0x76625893
+0,          1,          1,        1,   405504, 0x348f0b97
+0,          2,          2,        1,   405504, 0x3de02149
+0,          3,          3,        1,   405504, 0x8f5b309a
+0,          4,          4,        1,   405504, 0xf6faac89
+0,          5,          5,        1,   405504, 0x8f562eb6
+0,          6,          6,        1,   405504, 0xeb369913
+0,          7,          7,        1,   405504, 0xa78f1ff6
+0,          8,          8,        1,   405504, 0x8a1f1db6
+0,          9,          9,        1,   405504, 0xde649414
+0,         10,         10,        1,   405504, 0x154073e5
+0,         11,         11,        1,   405504, 0xedd73de2
+0,         12,         12,        1,   405504, 0x603df766
+0,         13,         13,        1,   405504, 0x53bd93be
+0,         14,         14,        1,   405504, 0xa4e31e4e
+0,         15,         15,        1,   405504, 0x9496c889
+0,         16,         16,        1,   405504, 0xe780a133
+0,         17,         17,        1,   405504, 0xea0d6297
+0,         18,         18,        1,   405504, 0x36f1fa5c
+0,         19,         19,        1,   405504, 0x6b6b1138
+0,         20,         20,        1,   405504, 0x4f604471
+0,         21,         21,        1,   405504, 0x60ae7fac
+0,         22,         22,        1,   405504, 0x200ae239
+0,         23,         23,        1,   405504, 0x8f2417b7
+0,         24,         24,        1,   405504, 0x360e40dc
+0,         25,         25,        1,   405504, 0xef67325e
+0,         26,         26,        1,   405504, 0x4cc83a45
+0,         27,         27,        1,   405504, 0x5064bad4
+0,         28,         28,        1,   405504, 0xecfe4d14
+0,         29,         29,        1,   405504, 0x0a848f79
+0,         30,         30,        1,   405504, 0xa92ff299
+0,         31,         31,        1,   405504, 0xa6ce59e7
+0,         32,         32,        1,   405504, 0x9b519b8e
+0,         33,         33,        1,   405504, 0xf2d1a500
+0,         34,         34,        1,   405504, 0x51b13a4f
+0,         35,         35,        1,   405504, 0xbe4e20dd
+0,         36,         36,        1,   405504, 0x1a7af6c9
+0,         37,         37,        1,   405504, 0x34d76fc1
+0,         38,         38,        1,   405504, 0x8f00b0f8
+0,         39,         39,        1,   405504, 0xe1eb6bec
+0,         40,         40,        1,   405504, 0xd01880ea
+0,         41,         41,        1,   405504, 0xa659a20a
+0,         42,         42,        1,   405504, 0xfed88666
+0,         43,         43,        1,   405504, 0xd239109c
+0,         44,         44,        1,   405504, 0x54233dd0
+0,         45,         45,        1,   405504, 0x3cc1a86a
+0,         46,         46,        1,   405504, 0x0744316d
+0,         47,         47,        1,   405504, 0xcc1c8360
+0,         48,         48,        1,   405504, 0x0af419f7
+0,         49,         49,        1,   405504, 0x80e5d952
diff --git a/deps/libav/tests/ref/fate/filter-shuffleplanes-swapuv b/deps/libav/tests/ref/fate/filter-shuffleplanes-swapuv
new file mode 100644
index 0000000..95da149
--- /dev/null
+++ b/deps/libav/tests/ref/fate/filter-shuffleplanes-swapuv
@@ -0,0 +1,51 @@
+#tb 0: 1/25
+0,          0,          0,        1,   152064, 0x68b189ef
+0,          1,          1,        1,   152064, 0x5cc66551
+0,          2,          2,        1,   152064, 0x88f0f64a
+0,          3,          3,        1,   152064, 0x195780b0
+0,          4,          4,        1,   152064, 0xeff7b652
+0,          5,          5,        1,   152064, 0x6548a8e6
+0,          6,          6,        1,   152064, 0x48667c23
+0,          7,          7,        1,   152064, 0x7ca88bac
+0,          8,          8,        1,   152064, 0xa3dc8026
+0,          9,          9,        1,   152064, 0x51233915
+0,         10,         10,        1,   152064, 0xf8ef4760
+0,         11,         11,        1,   152064, 0x5d51fcd5
+0,         12,         12,        1,   152064, 0x5c56ad61
+0,         13,         13,        1,   152064, 0x96b7a223
+0,         14,         14,        1,   152064, 0xb6ed8ddd
+0,         15,         15,        1,   152064, 0xf7f80f05
+0,         16,         16,        1,   152064, 0x695d4e18
+0,         17,         17,        1,   152064, 0x9af438c8
+0,         18,         18,        1,   152064, 0x3fcc6acc
+0,         19,         19,        1,   152064, 0xd0ccdbff
+0,         20,         20,        1,   152064, 0xe4f5f570
+0,         21,         21,        1,   152064, 0x342c2412
+0,         22,         22,        1,   152064, 0x45a51d59
+0,         23,         23,        1,   152064, 0x58d768ef
+0,         24,         24,        1,   152064, 0xebacf9d6
+0,         25,         25,        1,   152064, 0x23ff9936
+0,         26,         26,        1,   152064, 0x7e9196b5
+0,         27,         27,        1,   152064, 0xe862d887
+0,         28,         28,        1,   152064, 0xaf1aa455
+0,         29,         29,        1,   152064, 0xcfca650e
+0,         30,         30,        1,   152064, 0xe3506aca
+0,         31,         31,        1,   152064, 0xd7f0c51e
+0,         32,         32,        1,   152064, 0x1358fc8d
+0,         33,         33,        1,   152064, 0xeeb77a30
+0,         34,         34,        1,   152064, 0xa7c34378
+0,         35,         35,        1,   152064, 0x8d6794fb
+0,         36,         36,        1,   152064, 0x9c6a37ab
+0,         37,         37,        1,   152064, 0xad9b01f8
+0,         38,         38,        1,   152064, 0xa913594c
+0,         39,         39,        1,   152064, 0xb6f34edd
+0,         40,         40,        1,   152064, 0x4c4a5925
+0,         41,         41,        1,   152064, 0x262a9e08
+0,         42,         42,        1,   152064, 0x1fbdbfa9
+0,         43,         43,        1,   152064, 0xc94620ec
+0,         44,         44,        1,   152064, 0x33310471
+0,         45,         45,        1,   152064, 0x02bd7e73
+0,         46,         46,        1,   152064, 0x308c53ff
+0,         47,         47,        1,   152064, 0x11b4c5c2
+0,         48,         48,        1,   152064, 0x4fefb483
+0,         49,         49,        1,   152064, 0x9edbd8ea
diff --git a/deps/libav/tests/ref/seek/lavf-mxf b/deps/libav/tests/ref/seek/lavf-mxf
index 5f2cf5d..010d6bf 100644
--- a/deps/libav/tests/ref/seek/lavf-mxf
+++ b/deps/libav/tests/ref/seek/lavf-mxf
@@ -30,7 +30,7 @@ ret: 0         st: 0 flags:1  ts: 2.400000
 ret: 0         st: 0 flags:1 dts: 0.840000 pts: 0.960000 pos: 460800 size: 24712
 ret:-1         st: 1 flags:0  ts: 1.306667
 ret: 0         st: 1 flags:1  ts: 0.200833
-ret: 0         st: 0 flags:1 dts: 0.840000 pts: 0.960000 pos: 460800 size: 24712
+ret: 0         st: 0 flags:1 dts:-0.040000 pts: 0.000000 pos:   6144 size: 24801
 ret: 0         st:-1 flags:0  ts:-0.904994
 ret: 0         st: 0 flags:1 dts:-0.040000 pts: 0.000000 pos:   6144 size: 24801
 ret: 0         st:-1 flags:1  ts: 1.989173
diff --git a/deps/libav/tests/ref/seek/lavf-mxf_d10 b/deps/libav/tests/ref/seek/lavf-mxf_d10
index e091c77..17cca29 100644
--- a/deps/libav/tests/ref/seek/lavf-mxf_d10
+++ b/deps/libav/tests/ref/seek/lavf-mxf_d10
@@ -34,7 +34,7 @@ ret: 0         st: 0 flags:1 dts: 0.960000 pts: 0.960000 pos:5117952 size:150000
 ret: 0         st: 1 flags:0  ts: 1.306667
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:5117952 size:150000
 ret: 0         st: 1 flags:1  ts: 0.200833
-ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:5117952 size:150000
+ret: 0         st: 0 flags:1 dts: 0.200000 pts: 0.200000 pos:1071104 size:150000
 ret: 0         st:-1 flags:0  ts:-0.904994
 ret: 0         st: 0 flags:1 dts: 0.000000 pts: 0.000000 pos:   6144 size:150000
 ret: 0         st:-1 flags:1  ts: 1.989173
diff --git a/deps/libav/tools/qt-faststart.c b/deps/libav/tools/qt-faststart.c
index f33d6fa..ed6de1b 100644
--- a/deps/libav/tools/qt-faststart.c
+++ b/deps/libav/tools/qt-faststart.c
@@ -37,12 +37,14 @@
 #define ftello(x)       _ftelli64(x)
 #endif
 
+#define MIN(a,b) ((a) > (b) ? (b) : (a))
+
 #define BE_16(x) ((((uint8_t*)(x))[0] <<  8) | ((uint8_t*)(x))[1])
 
-#define BE_32(x) ((((uint8_t*)(x))[0] << 24) |  \
-                  (((uint8_t*)(x))[1] << 16) |  \
-                  (((uint8_t*)(x))[2] <<  8) |  \
-                   ((uint8_t*)(x))[3])
+#define BE_32(x) (((uint32_t)(((uint8_t*)(x))[0]) << 24) |  \
+                             (((uint8_t*)(x))[1]  << 16) |  \
+                             (((uint8_t*)(x))[2]  <<  8) |  \
+                              ((uint8_t*)(x))[3])
 
 #define BE_64(x) (((uint64_t)(((uint8_t*)(x))[0]) << 56) |  \
                   ((uint64_t)(((uint8_t*)(x))[1]) << 48) |  \
@@ -77,7 +79,7 @@
 #define CO64_ATOM QT_ATOM('c', 'o', '6', '4')
 
 #define ATOM_PREAMBLE_SIZE    8
-#define COPY_BUFFER_SIZE   1024
+#define COPY_BUFFER_SIZE  65536
 
 int main(int argc, char *argv[])
 {
@@ -87,7 +89,7 @@ int main(int argc, char *argv[])
     uint32_t atom_type   = 0;
     uint64_t atom_size   = 0;
     uint64_t atom_offset = 0;
-    uint64_t last_offset;
+    int64_t last_offset;
     unsigned char *moov_atom = NULL;
     unsigned char *ftyp_atom = NULL;
     uint64_t moov_atom_size;
@@ -95,12 +97,13 @@ int main(int argc, char *argv[])
     uint64_t i, j;
     uint32_t offset_count;
     uint64_t current_offset;
-    uint64_t start_offset = 0;
+    int64_t start_offset = 0;
     unsigned char copy_buffer[COPY_BUFFER_SIZE];
     int bytes_to_copy;
 
     if (argc != 3) {
-        printf("Usage: qt-faststart <infile.mov> <outfile.mov>\n");
+        printf("Usage: qt-faststart <infile.mov> <outfile.mov>\n"
+               "Note: alternatively you can use -movflags +faststart in avconv\n");
         return 0;
     }
 
@@ -121,7 +124,7 @@ int main(int argc, char *argv[])
         if (fread(atom_bytes, ATOM_PREAMBLE_SIZE, 1, infile) != 1) {
             break;
         }
-        atom_size = (uint32_t) BE_32(&atom_bytes[0]);
+        atom_size = BE_32(&atom_bytes[0]);
         atom_type = BE_32(&atom_bytes[4]);
 
         /* keep ftyp atom */
@@ -134,22 +137,27 @@ int main(int argc, char *argv[])
                        atom_size);
                 goto error_out;
             }
-            fseeko(infile, -ATOM_PREAMBLE_SIZE, SEEK_CUR);
-            if (fread(ftyp_atom, atom_size, 1, infile) != 1) {
+            if (fseeko(infile, -ATOM_PREAMBLE_SIZE, SEEK_CUR) ||
+                fread(ftyp_atom, atom_size, 1, infile) != 1 ||
+                (start_offset = ftello(infile)) < 0) {
                 perror(argv[1]);
                 goto error_out;
             }
-            start_offset = ftello(infile);
         } else {
+            int ret;
             /* 64-bit special case */
             if (atom_size == 1) {
                 if (fread(atom_bytes, ATOM_PREAMBLE_SIZE, 1, infile) != 1) {
                     break;
                 }
                 atom_size = BE_64(&atom_bytes[0]);
-                fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE * 2, SEEK_CUR);
+                ret = fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE * 2, SEEK_CUR);
             } else {
-                fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE, SEEK_CUR);
+                ret = fseeko(infile, atom_size - ATOM_PREAMBLE_SIZE, SEEK_CUR);
+            }
+            if (ret) {
+                perror(argv[1]);
+                goto error_out;
             }
         }
         printf("%c%c%c%c %10"PRIu64" %"PRIu64"\n",
@@ -190,8 +198,15 @@ int main(int argc, char *argv[])
 
     /* moov atom was, in fact, the last atom in the chunk; load the whole
      * moov atom */
-    fseeko(infile, -atom_size, SEEK_END);
+    if (fseeko(infile, -atom_size, SEEK_END)) {
+        perror(argv[1]);
+        goto error_out;
+    }
     last_offset    = ftello(infile);
+    if (last_offset < 0) {
+        perror(argv[1]);
+        goto error_out;
+    }
     moov_atom_size = atom_size;
     moov_atom      = malloc(moov_atom_size);
     if (!moov_atom) {
@@ -225,6 +240,10 @@ int main(int argc, char *argv[])
                 goto error_out;
             }
             offset_count = BE_32(&moov_atom[i + 8]);
+            if (i + 12 + offset_count * UINT64_C(4) > moov_atom_size) {
+                printf(" bad atom size/element count\n");
+                goto error_out;
+            }
             for (j = 0; j < offset_count; j++) {
                 current_offset  = BE_32(&moov_atom[i + 12 + j * 4]);
                 current_offset += moov_atom_size;
@@ -242,6 +261,10 @@ int main(int argc, char *argv[])
                 goto error_out;
             }
             offset_count = BE_32(&moov_atom[i + 8]);
+            if (i + 12 + offset_count * UINT64_C(8) > moov_atom_size) {
+                printf(" bad atom size/element count\n");
+                goto error_out;
+            }
             for (j = 0; j < offset_count; j++) {
                 current_offset  = BE_64(&moov_atom[i + 12 + j * 8]);
                 current_offset += moov_atom_size;
@@ -266,7 +289,11 @@ int main(int argc, char *argv[])
     }
 
     if (start_offset > 0) { /* seek after ftyp atom */
-        fseeko(infile, start_offset, SEEK_SET);
+        if (fseeko(infile, start_offset, SEEK_SET)) {
+            perror(argv[1]);
+            goto error_out;
+        }
+
         last_offset -= start_offset;
     }
 
@@ -295,10 +322,7 @@ int main(int argc, char *argv[])
     /* copy the remainder of the infile, from offset 0 -> last_offset - 1 */
     printf(" copying rest of file...\n");
     while (last_offset) {
-        if (last_offset > COPY_BUFFER_SIZE)
-            bytes_to_copy = COPY_BUFFER_SIZE;
-        else
-            bytes_to_copy = last_offset;
+        bytes_to_copy = MIN(COPY_BUFFER_SIZE, last_offset);
 
         if (fread(copy_buffer, bytes_to_copy, 1, infile) != 1) {
             perror(argv[1]);

-- 
libgroove packaging



More information about the pkg-multimedia-commits mailing list