[SCM] FFmpeg packaging branch, upstream.unstripped, updated. upstream.unstripped/0.svn20090119-unstripped-1-g6d5999c

siretart at users.alioth.debian.org siretart at users.alioth.debian.org
Tue Feb 3 10:26:00 UTC 2009


The following commit has been merged in the upstream.unstripped branch:
commit 6d5999cb8a87dadee203c35a48ddb9e45743fbba
Author: Reinhard Tartler <siretart at tauware.de>
Date:   Tue Feb 3 11:25:00 2009 +0100

    Imported Upstream version 0.svn20090128-unstripped

diff --git a/.svnrevision b/.svnrevision
index b3c1ca2..1bb7aaf 100644
--- a/.svnrevision
+++ b/.svnrevision
@@ -1 +1 @@
-16681
+16838
diff --git a/Changelog b/Changelog
index 577980f..e3240eb 100644
--- a/Changelog
+++ b/Changelog
@@ -144,6 +144,8 @@ version <next>
 - RV30 and RV40 decoder
 - QCELP / PureVoice decoder
 - hybrid WavPack support
+- R3D REDCODE demuxer
+- ALSA support for playback and record
 
 version 0.4.9-pre1:
 
diff --git a/Doxyfile b/Doxyfile
index 31daf5d..ea3b021 100644
--- a/Doxyfile
+++ b/Doxyfile
@@ -836,7 +836,7 @@ INCLUDE_FILE_PATTERNS  =
 # omitted =1 is assumed.
 
 PREDEFINED             = __attribute__(x)="" "RENAME(x)=x ## _TMPL" "DEF(x)=x ## _TMPL" \
-                         HAVE_AV_CONFIG_H HAVE_MMX HAVE_MMX2 HAVE_3DNOW \
+                         HAVE_AV_CONFIG_H HAVE_MMX HAVE_MMX2 HAVE_AMD3DNOW \
                          ATTR_ALIGN(x)=""
 
 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
diff --git a/MAINTAINERS b/MAINTAINERS
index 8b2ac15..5bf4159 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -127,7 +127,7 @@ Codecs:
   dxa.c                                 Kostya Shishkov
   dv.c                                  Roman Shaposhnik
   ffv1.c                                Michael Niedermayer
-  flac.c                                Alex Beregszaszi
+  flacdec.c                             Alex Beregszaszi, Justin Ruggles
   flacenc.c                             Justin Ruggles
   flashsv*                              Benjamin Larsson
   flicvideo.c                           Mike Melanson
@@ -162,7 +162,7 @@ Codecs:
   pcx.c                                 Ivo van Poorten
   ptx.c                                 Ivo van Poorten
   qcelp*                                Reynaldo H. Verdejo Pinochet
-  qdm2.c, qdm2data.h                    Roberto Togni
+  qdm2.c, qdm2data.h                    Roberto Togni, Benjamin Larsson
   qdrw.c                                Kostya Shishkov
   qpeg.c                                Kostya Shishkov
   qtrle.c                               Mike Melanson
@@ -249,6 +249,7 @@ Muxers/Demuxers:
   iff.c                                 Jaikrishnan Menon
   ipmovie.c                             Mike Melanson
   img2.c                                Michael Niedermayer
+  iss.c                                 Stefan Gehrer
   libnut.c                              Oded Shimon
   lmlm4.c                               Ivo van Poorten
   matroska.c                            Aurelien Jacobs
@@ -271,6 +272,7 @@ Muxers/Demuxers:
   oggparseogm.c                         Mans Rullgard
   psxstr.c                              Mike Melanson
   pva.c                                 Ivo van Poorten
+  r3d.c                                 Baptiste Coudurier
   raw.c                                 Michael Niedermayer
   rl2.c                                 Sascha Sommer
   rm.c                                  Roberto Togni
diff --git a/Makefile b/Makefile
index 2c94537..9a08730 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,8 @@ FFLIBS-$(CONFIG_SWSCALE)  += swscale
 
 FFLIBS := avdevice avformat avcodec avutil
 
+DATA_FILES := $(wildcard $(SRC_DIR)/ffpresets/*.ffpreset)
+
 include common.mak
 
 FF_LDFLAGS   := $(FFLDFLAGS)
@@ -35,7 +37,7 @@ ALL_TARGETS-$(BUILD_DOC)    += documentation
 
 INSTALL_TARGETS-$(CONFIG_VHOOK) += install-vhook
 ifneq ($(PROGS),)
-INSTALL_TARGETS-yes             += install-progs
+INSTALL_TARGETS-yes             += install-progs install-data
 INSTALL_TARGETS-$(BUILD_DOC)    += install-man
 endif
 INSTALL_PROGS_TARGETS-$(BUILD_SHARED) = install-libs
@@ -129,6 +131,10 @@ install-progs: $(PROGS) $(INSTALL_PROGS_TARGETS-yes)
 	install -d "$(BINDIR)"
 	install -c -m 755 $(PROGS) "$(BINDIR)"
 
+install-data: $(DATA_FILES)
+	install -d "$(DATADIR)"
+	install -m 644 $(DATA_FILES) "$(DATADIR)"
+
 install-man: $(MANPAGES)
 	install -d "$(MANDIR)/man1"
 	install -m 644 $(MANPAGES) "$(MANDIR)/man1"
@@ -137,11 +143,14 @@ install-vhook: videohook
 	install -d "$(SHLIBDIR)/vhook"
 	install -m 755 $(HOOKS) "$(SHLIBDIR)/vhook"
 
-uninstall: uninstall-progs uninstall-man uninstall-vhook
+uninstall: uninstall-progs uninstall-data uninstall-man uninstall-vhook
 
 uninstall-progs:
 	rm -f $(addprefix "$(BINDIR)/", $(ALLPROGS))
 
+uninstall-data:
+	rm -rf "$(DATADIR)"
+
 uninstall-man:
 	rm -f $(addprefix "$(MANDIR)/man1/",$(ALLMANPAGES))
 
diff --git a/common.mak b/common.mak
index 6d007cc..4be056c 100644
--- a/common.mak
+++ b/common.mak
@@ -48,8 +48,8 @@ ifeq ($(wildcard $(SVN_ENTRIES)),$(SVN_ENTRIES))
 $(BUILD_ROOT_REL)/version.h: $(SVN_ENTRIES)
 endif
 
-$(BUILD_ROOT_REL)/version.h:
-	$(SRC_PATH)/version.sh $(SRC_PATH) $@ $(EXTRA_VERSION)
+$(BUILD_ROOT_REL)/version.h: $(SRC_PATH_BARE)/version.sh
+	$< $(SRC_PATH) $@ $(EXTRA_VERSION)
 
 install: install-libs install-headers
 
diff --git a/configure b/configure
index b80bb38..fc8529f 100755
--- a/configure
+++ b/configure
@@ -64,18 +64,22 @@ show_help(){
   echo "  --disable-logging        do not log configure debug information"
   echo "  --prefix=PREFIX          install in PREFIX [$prefix]"
   echo "  --bindir=DIR             install binaries in DIR [PREFIX/bin]"
+  echo "  --datadir=DIR            install data files in DIR [PREFIX/share/ffmpeg]"
   echo "  --libdir=DIR             install libs in DIR [PREFIX/lib]"
   echo "  --shlibdir=DIR           install shared libs in DIR [PREFIX/lib]"
   echo "  --incdir=DIR             install includes in DIR [PREFIX/include]"
   echo "  --mandir=DIR             install man page in DIR [PREFIX/share/man]"
-  echo "  --enable-static          build static libraries [yes]"
+  echo
+  echo "Configuration options:"
   echo "  --disable-static         do not build static libraries [no]"
   echo "  --enable-shared          build shared libraries [no]"
-  echo "  --disable-shared         do not build shared libraries [yes]"
   echo "  --enable-gpl             allow use of GPL code, the resulting libs"
   echo "                           and binaries will be under GPL [no]"
   echo "  --enable-nonfree         allow use of nonfree code, the resulting libs"
   echo "                           and binaries will be unredistributable [no]"
+  echo "  --disable-ffmpeg         disable ffmpeg build"
+  echo "  --disable-ffplay         disable ffplay build"
+  echo "  --disable-ffserver       disable ffserver build"
   echo "  --enable-postproc        enable GPLed postprocessing support [no]"
   echo "  --enable-swscale         enable GPLed software scaler support [no]"
   echo "  --enable-avfilter        video filter support (replaces vhook) [no]"
@@ -84,13 +88,62 @@ show_help(){
   echo "  --enable-beosthreads     use BeOS threads [no]"
   echo "  --enable-os2threads      use OS/2 threads [no]"
   echo "  --enable-pthreads        use pthreads [no]"
-  echo "  --enable-vdpau           enable VDPAU support [no]"
   echo "  --enable-w32threads      use Win32 threads [no]"
   echo "  --enable-x11grab         enable X11 grabbing [no]"
+  echo "  --enable-vdpau           enable VDPAU support [no]"
   echo "  --enable-xvmc            enable XvMC support [no]"
+  echo "  --disable-network        disable network support [no]"
+  echo "  --disable-ipv6           disable IPv6 support [no]"
+  echo "  --disable-mpegaudio-hp   faster (but less accurate) MPEG audio decoding [no]"
+  echo "  --enable-gray            enable full grayscale support (slower color)"
+  echo "  --disable-fastdiv        disable table-based division"
+  echo "  --enable-small           optimize for size instead of speed"
+  echo "  --disable-aandct         disable AAN DCT code"
+  echo "  --disable-fft            disable FFT code"
+  echo "  --disable-golomb         disable Golomb code"
+  echo "  --disable-mdct           disable MDCT code"
+  echo "  --enable-hardcoded-tables use hardcoded tables instead of runtime generation"
+  echo "  --enable-memalign-hack   emulate memalign, interferes with memory debuggers"
+  echo "  --enable-beos-netserver  enable BeOS netserver"
+  echo "  --disable-encoder=NAME   disable encoder NAME"
+  echo "  --enable-encoder=NAME    enable encoder NAME"
+  echo "  --disable-encoders       disable all encoders"
+  echo "  --disable-decoder=NAME   disable decoder NAME"
+  echo "  --enable-decoder=NAME    enable decoder NAME"
+  echo "  --disable-decoders       disable all decoders"
+  echo "  --disable-muxer=NAME     disable muxer NAME"
+  echo "  --enable-muxer=NAME      enable muxer NAME"
+  echo "  --disable-muxers         disable all muxers"
+  echo "  --disable-demuxer=NAME   disable demuxer NAME"
+  echo "  --enable-demuxer=NAME    enable demuxer NAME"
+  echo "  --disable-demuxers       disable all demuxers"
+  echo "  --enable-parser=NAME     enable parser NAME"
+  echo "  --disable-parser=NAME    disable parser NAME"
+  echo "  --disable-parsers        disable all parsers"
+  echo "  --enable-bsf=NAME        enable bitstream filter NAME"
+  echo "  --disable-bsf=NAME       disable bitstream filter NAME"
+  echo "  --disable-bsfs           disable all bitstream filters"
+  echo "  --enable-protocol=NAME   enable protocol NAME"
+  echo "  --disable-protocol=NAME  disable protocol NAME"
+  echo "  --disable-protocols      disable all protocols"
+  echo "  --disable-indevs         disable input devices"
+  echo "  --disable-outdevs        disable output devices"
+  echo "  --disable-devices        disable all devices"
+  echo "  --enable-filter=NAME     enable filter NAME"
+  echo "  --disable-filter=NAME    disable filter NAME"
+  echo "  --disable-filters        disable all filters"
+  echo "  --list-decoders          show all available decoders"
+  echo "  --list-encoders          show all available encoders"
+  echo "  --list-muxers            show all available muxers"
+  echo "  --list-demuxers          show all available demuxers"
+  echo "  --list-parsers           show all available parsers"
+  echo "  --list-protocols         show all available protocols"
+  echo "  --list-bsfs              show all available bitstream filters"
+  echo "  --list-indevs            show all available input devices"
+  echo "  --list-outdevs           show all available output devices"
+  echo "  --list-filters           show all available filters"
   echo
   echo "External library support:"
-  echo "  --enable-mlib            enable Sun medialib [no]"
   echo "  --enable-avisynth        enable reading of AVISynth script files [no]"
   echo "  --enable-bzlib           enable bzlib [autodetect]"
   echo "  --enable-libamr-nb       enable libamr-nb floating point audio codec [no]"
@@ -113,6 +166,7 @@ show_help(){
   echo "  --enable-libx264         enable H.264 encoding via x264 [no]"
   echo "  --enable-libxvid         enable Xvid encoding via xvidcore,"
   echo "                           native MPEG-4/Xvid encoder exists [no]"
+  echo "  --enable-mlib            enable Sun medialib [no]"
   echo "  --enable-zlib            enable zlib [autodetect]"
   echo ""
   echo "Advanced options (experts only):"
@@ -123,7 +177,7 @@ show_help(){
   echo "  --target-exec=CMD        command to run executables on target"
   echo "  --target-path=DIR        path to view of build directory on target"
   echo "  --nm=NM                  use nm tool"
-  echo "  --cc=CC                  use C compiler CC [$cc]"
+  echo "  --cc=CC                  use C compiler CC [$cc_default]"
   echo "  --host-cc=HOSTCC         use host C compiler HOSTCC"
   echo "  --host-cflags=HCFLAGS    use HCFLAGS when compiling for host"
   echo "  --host-ldflags=HLDFLAGS  use HLDFLAGS when linking for host"
@@ -139,6 +193,7 @@ show_help(){
   echo "  --enable-powerpc-perf    enable performance report on PPC"
   echo "                           (requires enabling PMC)"
   echo "  --disable-altivec        disable AltiVec optimizations"
+  echo "  --disable-amd3dnow       disable 3DNow! optimizations"
   echo "  --disable-mmx            disable MMX optimizations"
   echo "  --disable-mmx2           disable MMX2 optimizations"
   echo "  --disable-sse            disable SSE optimizations"
@@ -151,59 +206,6 @@ show_help(){
   echo "  --disable-mmi            disable MMI optimizations"
   echo "  --disable-neon           disable neon optimizations"
   echo "  --disable-vis            disable VIS optimizations"
-  echo "  --disable-network        disable network support [no]"
-  echo "  --disable-ipv6           disable IPv6 support [no]"
-  echo "  --disable-mpegaudio-hp   faster (but less accurate)"
-  echo "                           MPEG audio decoding [no]"
-  echo "  --disable-aandct         disable AAN DCT code"
-  echo "  --disable-fft            disable FFT code"
-  echo "  --disable-golomb         disable Golomb code"
-  echo "  --disable-mdct           disable MDCT code"
-  echo "  --enable-gray            enable full grayscale support (slower color)"
-  echo "  --disable-ffmpeg         disable ffmpeg build"
-  echo "  --disable-ffplay         disable ffplay build"
-  echo "  --disable-ffserver       disable ffserver build"
-  echo "  --enable-small           optimize for size instead of speed"
-  echo "  --enable-hardcoded-tables use hardcoded tables instead of runtime generation"
-  echo "  --enable-memalign-hack   emulate memalign, interferes with memory debuggers"
-  echo "  --enable-beos-netserver  enable BeOS netserver"
-  echo "  --disable-encoder=NAME   disable encoder NAME"
-  echo "  --enable-encoder=NAME    enable encoder NAME"
-  echo "  --disable-encoders       disable all encoders"
-  echo "  --disable-decoder=NAME   disable decoder NAME"
-  echo "  --enable-decoder=NAME    enable decoder NAME"
-  echo "  --disable-decoders       disable all decoders"
-  echo "  --disable-muxer=NAME     disable muxer NAME"
-  echo "  --enable-muxer=NAME      enable muxer NAME"
-  echo "  --disable-muxers         disable all muxers"
-  echo "  --disable-demuxer=NAME   disable demuxer NAME"
-  echo "  --enable-demuxer=NAME    enable demuxer NAME"
-  echo "  --disable-demuxers       disable all demuxers"
-  echo "  --enable-parser=NAME     enable parser NAME"
-  echo "  --disable-parser=NAME    disable parser NAME"
-  echo "  --disable-parsers        disable all parsers"
-  echo "  --enable-bsf=NAME        enable bitstream filter NAME"
-  echo "  --disable-bsf=NAME       disable bitstream filter NAME"
-  echo "  --disable-bsfs           disable all bitstream filters"
-  echo "  --enable-protocol=NAME   enable protocol NAME"
-  echo "  --disable-protocol=NAME  disable protocol NAME"
-  echo "  --disable-protocols      disable all protocols"
-  echo "  --disable-indevs         disable input devices"
-  echo "  --disable-outdevs        disable output devices"
-  echo "  --disable-devices        disable all devices"
-  echo "  --enable-filter=NAME     enable filter NAME"
-  echo "  --disable-filter=NAME    disable filter NAME"
-  echo "  --disable-filters        disable all filters"
-  echo "  --list-decoders          show all available decoders"
-  echo "  --list-encoders          show all available encoders"
-  echo "  --list-muxers            show all available muxers"
-  echo "  --list-demuxers          show all available demuxers"
-  echo "  --list-parsers           show all available parsers"
-  echo "  --list-protocols         show all available protocols"
-  echo "  --list-bsfs              show all available bitstream filters"
-  echo "  --list-indevs            show all available input devices"
-  echo "  --list-outdevs           show all available output devices"
-  echo "  --list-filters           show all available filters"
   echo
   echo "Developer options (useful when working on FFmpeg itself):"
   echo "  --disable-debug          disable debugging symbols"
@@ -263,6 +265,10 @@ tolower(){
     echo "$@" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz
 }
 
+c_escape(){
+    echo "$*" | sed 's/["\\]/\\\0/g'
+}
+
 set_all(){
     value=$1
     shift
@@ -813,6 +819,7 @@ ARCH_LIST='
 
 ARCH_EXT_LIST='
     altivec
+    amd3dnow
     armv5te
     armv6
     armv6t2
@@ -822,6 +829,7 @@ ARCH_EXT_LIST='
     mmx
     mmx2
     neon
+    ppc4xx
     sse
     ssse3
     vis
@@ -830,6 +838,7 @@ ARCH_EXT_LIST='
 HAVE_LIST="
     $ARCH_EXT_LIST
     $THREADS_LIST
+    alsa_asoundlib_h
     altivec_h
     arpa_inet_h
     bswap
@@ -911,6 +920,7 @@ CMDLINE_SELECT="
 
 PATHS_LIST='
     bindir
+    datadir
     incdir
     libdir
     mandir
@@ -942,6 +952,7 @@ CMDLINE_SET="
 
 # architecture extensions
 altivec_deps="ppc"
+amd3dnow_deps="mmx"
 armv5te_deps="arm"
 armv6_deps="arm"
 armv6t2_deps="arm"
@@ -949,10 +960,11 @@ armvfp_deps="arm"
 iwmmxt_deps="arm"
 mmi_deps="mips"
 mmx_deps="x86"
-mmx2_deps="x86 mmx"
+mmx2_deps="mmx"
 neon_deps="arm"
+ppc4xx_deps="ppc"
 sse_deps="mmx"
-ssse3_deps="x86 sse"
+ssse3_deps="sse"
 vis_deps="sparc"
 
 # common features
@@ -1016,6 +1028,7 @@ svq3_decoder_suggest="zlib"
 tiff_decoder_suggest="zlib"
 tiff_encoder_suggest="zlib"
 tscc_decoder_select="zlib"
+vc1_vdpau_decoder_deps="vdpau"
 vorbis_decoder_select="fft mdct"
 vorbis_encoder_select="fft mdct"
 wmav1_decoder_select="fft mdct"
@@ -1024,6 +1037,7 @@ wmav2_decoder_select="fft mdct"
 wmav2_encoder_select="fft mdct"
 wmv1_encoder_select="aandct"
 wmv2_encoder_select="aandct"
+wmv3_vdpau_decoder_deps="vdpau"
 zlib_decoder_select="zlib"
 zlib_encoder_select="zlib"
 zmbv_decoder_select="zlib"
@@ -1056,6 +1070,10 @@ vdpau_deps="vdpau_vdpau_h vdpau_vdpau_x11_h"
 
 # demuxers / muxers
 ac3_demuxer_deps="ac3_parser"
+alsa_demuxer_deps="alsa_asoundlib_h snd_pcm_htimestamp"
+alsa_demuxer_extralibs="-lasound"
+alsa_muxer_deps="alsa_asoundlib_h"
+alsa_muxer_extralibs="-lasound"
 audio_beos_demuxer_deps="audio_beos"
 audio_beos_demuxer_extralibs="-lmedia -lbe"
 audio_beos_muxer_deps="audio_beos"
@@ -1106,6 +1124,7 @@ logfile="config.err"
 # installation paths
 prefix_default="/usr/local"
 bindir_default='${prefix}/bin'
+datadir_default='${prefix}/share/ffmpeg'
 incdir_default='${prefix}/include'
 libdir_default='${prefix}/lib'
 mandir_default='${prefix}/share/man'
@@ -1475,11 +1494,13 @@ case $target_os in
         SHFLAGS='-shared -Wl,--output-def,$$(@:$(SLIBSUF)=.def) -Wl,--enable-runtime-pseudo-reloc -Wl,--enable-auto-image-base'
         objformat="win32"
         enable dos_paths
-        check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
-            die "ERROR: MinGW runtime version must be >= 3.15."
-        enabled_any avisynth vfwcap_demuxer &&
-            { check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
-              die "ERROR: avisynth and vfwcap_demuxer require w32api version 3.13 or later."; }
+        if ! enabled x86_64; then
+            check_cpp_condition _mingw.h "(__MINGW32_MAJOR_VERSION > 3) || (__MINGW32_MAJOR_VERSION == 3 && __MINGW32_MINOR_VERSION >= 15)" ||
+                die "ERROR: MinGW runtime version must be >= 3.15."
+            enabled_any avisynth vfwcap_demuxer &&
+                { check_cpp_condition w32api.h "(__W32API_MAJOR_VERSION > 3) || (__W32API_MAJOR_VERSION == 3 && __W32API_MINOR_VERSION >= 13)" ||
+                  die "ERROR: avisynth and vfwcap_demuxer require w32api version 3.13 or later."; }
+            fi
         ;;
     cygwin*)
         target_os=cygwin
@@ -1544,7 +1565,7 @@ case $target_os in
         ;;
 
     *)
-        target_os="${target_os}-UNKNOWN"
+        die "Unknown OS '$target_os'."
         ;;
 esac
 
@@ -1770,6 +1791,7 @@ fi
 # check for assembler specific support
 
 enabled ppc && check_asm dcbzl '"dcbzl 0, 1"'
+enabled ppc && check_asm ppc4xx '"maclhw r10, r11, r12"'
 
 # check for SIMD availability
 
@@ -2029,6 +2051,9 @@ check_header dev/ic/bt8xx.h
 check_header sys/soundcard.h
 check_header soundcard.h
 
+check_header alsa/asoundlib.h &&
+check_lib2 alsa/asoundlib.h snd_pcm_htimestamp -lasound
+
 # deal with the X11 frame grabber
 enabled x11grab                         &&
 check_header X11/Xlib.h                 &&
@@ -2149,7 +2174,10 @@ echo "big-endian                ${bigendian-no}"
 if enabled x86; then
     echo "yasm                      ${yasm-no}"
     echo "MMX enabled               ${mmx-no}"
+    echo "MMX2 enabled              ${mmx2-no}"
+    echo "3DNow! enabled            ${amd3dnow-no}"
     echo "SSE enabled               ${sse-no}"
+    echo "SSSE3 enabled             ${ssse3-no}"
     echo "CMOV enabled              ${cmov-no}"
     echo "CMOV is fast              ${fast_cmov-no}"
     echo "EBX available             ${ebx_available-no}"
@@ -2168,7 +2196,12 @@ if enabled mips; then
 fi
 if enabled ppc; then
     echo "AltiVec enabled           ${altivec-no}"
+    echo "PPC 4xx optimizations     ${ppc4xx-no}"
     echo "dcbzl available           ${dcbzl-no}"
+    echo "performance report        ${powerpc_perf-no}"
+fi
+if enabled sparc; then
+    echo "VIS enabled               ${vis-no}"
 fi
 echo "gprof enabled             ${gprof-no}"
 echo "debug symbols             ${debug-no}"
@@ -2242,6 +2275,7 @@ echo "/* Automatically generated by configure - do not modify! */" > $TMPH
 echo "#ifndef FFMPEG_CONFIG_H" >> $TMPH
 echo "#define FFMPEG_CONFIG_H" >> $TMPH
 echo "#define FFMPEG_CONFIGURATION \"$FFMPEG_CONFIGURATION\"" >> $TMPH
+echo "#define FFMPEG_DATADIR \"$(eval c_escape $datadir)\"" >> $TMPH
 
 echo "FFMPEG_CONFIGURATION=$FFMPEG_CONFIGURATION" >> config.mak
 echo "prefix=$prefix" >> config.mak
@@ -2249,6 +2283,7 @@ echo "LIBDIR=\$(DESTDIR)$libdir" >> config.mak
 echo "SHLIBDIR=\$(DESTDIR)$shlibdir" >> config.mak
 echo "INCDIR=\$(DESTDIR)$incdir" >> config.mak
 echo "BINDIR=\$(DESTDIR)$bindir" >> config.mak
+echo "DATADIR=\$(DESTDIR)$datadir" >> config.mak
 echo "MANDIR=\$(DESTDIR)$mandir" >> config.mak
 echo "CC=$cc" >> config.mak
 echo "YASM=$yasmexe" >> config.mak
diff --git a/doc/ffmpeg-doc.texi b/doc/ffmpeg-doc.texi
index 499c36f..bb093f7 100644
--- a/doc/ffmpeg-doc.texi
+++ b/doc/ffmpeg-doc.texi
@@ -801,10 +801,10 @@ The argument passed to the preset options identifies the preset file
 to use according to the following rules.
 
 First ffmpeg searches for a file named @var{arg}.ffpreset in the
-directories @file{$HOME/.ffmpeg}, @file{/usr/local/share/ffmpeg} and
- at file{/usr/share/ffmpeg} in that order. For example, if the argument
-is @code{libx264-max}, it will search for the file
- at file{libx264-max.ffpreset}.
+directories @file{$HOME/.ffmpeg}, and in the datadir defined at
+configuration time (usually @file{PREFIX/share/ffmpeg}) in that
+order. For example, if the argument is @code{libx264-max}, it will
+search for the file @file{libx264-max.ffpreset}.
 
 If no such file is found, then ffmpeg will search for a file named
 @var{codec_name}- at var{arg}.ffpreset in the above-mentioned
diff --git a/doc/general.texi b/doc/general.texi
index 17d2cd5..fae6389 100644
--- a/doc/general.texi
+++ b/doc/general.texi
@@ -123,6 +123,8 @@ library:
 @item raw MPEG-4 video          @tab X @tab X
 @item raw PCM 8/16/32 bits, 32/64-bit floating point, mu-law/A-law @tab X  @tab  X
 @item raw Shorten audio         @tab    @tab  X
+ at item R3D REDCODE               @tab   @tab X
+    @tab File format used by RED Digital cameras, contains JPEG 2000 frames and PCM audio.
 @item RealMedia                 @tab X @tab X
 @item RL2                       @tab   @tab X
     @tab Audio and video format used in some games by Entertainment Software Partners.
diff --git a/ffmpeg.c b/ffmpeg.c
index cdb5e20..42ac417 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2100,7 +2100,10 @@ static int av_encode(AVFormatContext **output_files,
 
         /* read a frame from it and output it in the fifo */
         is = input_files[file_index];
-        if (av_read_frame(is, &pkt) < 0) {
+        ret= av_read_frame(is, &pkt);
+        if(ret == AVERROR(EAGAIN) && strcmp(is->iformat->name, "ffm"))
+            continue;
+        if (ret < 0) {
             file_table[file_index].eof_reached = 1;
             if (opt_shortest)
                 break;
@@ -3697,19 +3700,18 @@ static int opt_preset(const char *opt, const char *arg)
     FILE *f=NULL;
     char filename[1000], tmp[1000], tmp2[1000], line[1000];
     int i;
-    const char *base[3]= { getenv("HOME"),
-                           "/usr/local/share",
-                           "/usr/share",
+    const char *base[2]= { getenv("HOME"),
+                           FFMPEG_DATADIR,
                          };
 
-    for(i=!base[0]; i<3 && !f; i++){
-        snprintf(filename, sizeof(filename), "%s/%sffmpeg/%s.ffpreset", base[i], i ? "" : ".", arg);
+    for(i=!base[0]; i<2 && !f; i++){
+        snprintf(filename, sizeof(filename), "%s%s/%s.ffpreset", base[i], i ? "" : "/.ffmpeg", arg);
         f= fopen(filename, "r");
         if(!f){
             char *codec_name= *opt == 'v' ? video_codec_name :
                               *opt == 'a' ? audio_codec_name :
                                             subtitle_codec_name;
-            snprintf(filename, sizeof(filename), "%s/%sffmpeg/%s-%s.ffpreset", base[i],  i ? "" : ".", codec_name, arg);
+            snprintf(filename, sizeof(filename), "%s%s/%s-%s.ffpreset", base[i],  i ? "" : "/.ffmpeg", codec_name, arg);
             f= fopen(filename, "r");
         }
     }
@@ -3918,8 +3920,9 @@ int main(int argc, char **argv)
     }
 
     ti = getutime();
-    av_encode(output_files, nb_output_files, input_files, nb_input_files,
-              stream_maps, nb_stream_maps);
+    if (av_encode(output_files, nb_output_files, input_files, nb_input_files,
+                  stream_maps, nb_stream_maps) < 0)
+        av_exit(1);
     ti = getutime() - ti;
     if (do_benchmark) {
         printf("bench: utime=%0.3fs\n", ti / 1000000.0);
diff --git a/ffplay.c b/ffplay.c
index 88e6b1a..877c9f6 100644
--- a/ffplay.c
+++ b/ffplay.c
@@ -2019,10 +2019,8 @@ static int decode_thread(void *arg)
             else
                 av_read_play(ic);
         }
-#if CONFIG_RTSP_DEMUXER || CONFIG_MMSH_PROTOCOL
-        if (is->paused &&
-                (!strcmp(ic->iformat->name, "rtsp") ||
-                 (ic->pb && !strcmp(url_fileno(ic->pb)->prot->name, "mmsh")))) {
+#if CONFIG_RTSP_DEMUXER
+        if (is->paused && !strcmp(ic->iformat->name, "rtsp")) {
             /* wait 10 ms to avoid trying to get another packet */
             /* XXX: horrible */
             SDL_Delay(10);
diff --git a/ffpresets/libx264-default.ffpreset b/ffpresets/libx264-default.ffpreset
index f0a62ee..ec20174 100644
--- a/ffpresets/libx264-default.ffpreset
+++ b/ffpresets/libx264-default.ffpreset
@@ -3,7 +3,7 @@ flags=+loop
 cmp=+chroma
 partitions=+parti8x8+parti4x4+partp8x8+partb8x8
 me_method=hex
-subq=5
+subq=6
 me_range=16
 g=250
 keyint_min=25
diff --git a/ffserver.c b/ffserver.c
index 79d1e3a..d2bdcc3 100644
--- a/ffserver.c
+++ b/ffserver.c
@@ -4485,7 +4485,7 @@ int main(int argc, char **argv)
 
     unsetenv("http_proxy");             /* Kill the http_proxy */
 
-    av_init_random(av_gettime() + (getpid() << 16), &random_state);
+    av_random_init(&random_state, av_gettime() + (getpid() << 16));
 
     memset(&sigact, 0, sizeof(sigact));
     sigact.sa_handler = handle_child_exit;
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index fa8b71b..9abedfc 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -82,7 +82,7 @@ OBJS-$(CONFIG_FFV1_DECODER)            += ffv1.o rangecoder.o
 OBJS-$(CONFIG_FFV1_ENCODER)            += ffv1.o rangecoder.o
 OBJS-$(CONFIG_FFVHUFF_DECODER)         += huffyuv.o
 OBJS-$(CONFIG_FFVHUFF_ENCODER)         += huffyuv.o
-OBJS-$(CONFIG_FLAC_DECODER)            += flac.o
+OBJS-$(CONFIG_FLAC_DECODER)            += flacdec.o
 OBJS-$(CONFIG_FLAC_ENCODER)            += flacenc.o lpc.o
 OBJS-$(CONFIG_FLASHSV_DECODER)         += flashsv.o
 OBJS-$(CONFIG_FLASHSV_ENCODER)         += flashsvenc.o
@@ -218,6 +218,7 @@ OBJS-$(CONFIG_TXD_DECODER)             += txd.o s3tc.o
 OBJS-$(CONFIG_ULTI_DECODER)            += ulti.o
 OBJS-$(CONFIG_VB_DECODER)              += vb.o
 OBJS-$(CONFIG_VC1_DECODER)             += vc1.o vc1data.o vc1dsp.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o error_resilience.o mpegvideo.o
+OBJS-$(CONFIG_VC1_VDPAU_DECODER)       += vdpauvideo.o vc1.o vc1data.o vc1dsp.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o error_resilience.o mpegvideo.o
 OBJS-$(CONFIG_VCR1_DECODER)            += vcr1.o
 OBJS-$(CONFIG_VCR1_ENCODER)            += vcr1.o
 OBJS-$(CONFIG_VMDAUDIO_DECODER)        += vmdav.o
@@ -241,6 +242,7 @@ OBJS-$(CONFIG_WMV1_ENCODER)            += mpegvideo_enc.o motion_est.o ratecontr
 OBJS-$(CONFIG_WMV2_DECODER)            += wmv2dec.o wmv2.o msmpeg4.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o mpeg12data.o mpegvideo.o error_resilience.o
 OBJS-$(CONFIG_WMV2_ENCODER)            += wmv2enc.o wmv2.o msmpeg4.o msmpeg4data.o mpegvideo_enc.o motion_est.o ratecontrol.o h263.o mpeg12data.o mpegvideo.o error_resilience.o
 OBJS-$(CONFIG_WMV3_DECODER)            += vc1.o vc1data.o vc1dsp.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o error_resilience.o mpegvideo.o
+OBJS-$(CONFIG_WMV3_VDPAU_DECODER)      += vdpauvideo.o vc1.o vc1data.o vc1dsp.o msmpeg4data.o h263dec.o h263.o intrax8.o intrax8dsp.o error_resilience.o mpegvideo.o
 OBJS-$(CONFIG_WNV1_DECODER)            += wnv1.o
 OBJS-$(CONFIG_WS_SND1_DECODER)         += ws-snd1.o
 OBJS-$(CONFIG_XAN_DPCM_DECODER)        += dpcm.o
diff --git a/libavcodec/aac_ac3_parser.c b/libavcodec/aac_ac3_parser.c
index 82d7c04..fedabdf 100644
--- a/libavcodec/aac_ac3_parser.c
+++ b/libavcodec/aac_ac3_parser.c
@@ -1,7 +1,7 @@
 /*
  * Common AAC and AC-3 parser
- * Copyright (c) 2003 Fabrice Bellard.
- * Copyright (c) 2003 Michael Niedermayer.
+ * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2003 Michael Niedermayer
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/aac_ac3_parser.h b/libavcodec/aac_ac3_parser.h
index b8613d8..c4b81a8 100644
--- a/libavcodec/aac_ac3_parser.h
+++ b/libavcodec/aac_ac3_parser.h
@@ -1,7 +1,7 @@
 /*
  * Common AAC and AC-3 parser prototypes
- * Copyright (c) 2003 Fabrice Bellard.
- * Copyright (c) 2003 Michael Niedermayer.
+ * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2003 Michael Niedermayer
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/aac_parser.c b/libavcodec/aac_parser.c
index e38b5ec..de33731 100644
--- a/libavcodec/aac_parser.c
+++ b/libavcodec/aac_parser.c
@@ -1,7 +1,7 @@
 /*
  * Audio and Video frame extraction
- * Copyright (c) 2003 Fabrice Bellard.
- * Copyright (c) 2003 Michael Niedermayer.
+ * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2003 Michael Niedermayer
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/aactab.h b/libavcodec/aactab.h
index 2a8491b..67b700d 100644
--- a/libavcodec/aactab.h
+++ b/libavcodec/aactab.h
@@ -66,9 +66,9 @@ extern const uint16_t  ff_aac_spectral_sizes[11];
 extern const float *ff_aac_codebook_vectors[];
 
 #if CONFIG_HARDCODED_TABLES
-extern const float ff_aac_pow2sf_tab[316];
+extern const float ff_aac_pow2sf_tab[428];
 #else
-extern       float ff_aac_pow2sf_tab[316];
+extern       float ff_aac_pow2sf_tab[428];
 #endif /* CONFIG_HARDCODED_TABLES */
 
 #endif /* AVCODEC_AACTAB_H */
diff --git a/libavcodec/ac3.c b/libavcodec/ac3.c
index cb1a147..057abd0 100644
--- a/libavcodec/ac3.c
+++ b/libavcodec/ac3.c
@@ -1,6 +1,6 @@
 /*
  * Common code between the AC-3 encoder and decoder
- * Copyright (c) 2000 Fabrice Bellard.
+ * Copyright (c) 2000 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/ac3.h b/libavcodec/ac3.h
index cbbb718..e42509c 100644
--- a/libavcodec/ac3.h
+++ b/libavcodec/ac3.h
@@ -1,6 +1,6 @@
 /*
  * Common code between the AC-3 encoder and decoder
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
+ * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/ac3_parser.c b/libavcodec/ac3_parser.c
index f47f97d..63c0a48 100644
--- a/libavcodec/ac3_parser.c
+++ b/libavcodec/ac3_parser.c
@@ -1,7 +1,7 @@
 /*
  * AC-3 parser
- * Copyright (c) 2003 Fabrice Bellard.
- * Copyright (c) 2003 Michael Niedermayer.
+ * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2003 Michael Niedermayer
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/ac3_parser.h b/libavcodec/ac3_parser.h
index 0f8fc6d..0d235df 100644
--- a/libavcodec/ac3_parser.h
+++ b/libavcodec/ac3_parser.h
@@ -1,7 +1,7 @@
 /*
  * AC-3 parser prototypes
- * Copyright (c) 2003 Fabrice Bellard.
- * Copyright (c) 2003 Michael Niedermayer.
+ * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2003 Michael Niedermayer
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c
index 74c8748..766b262 100644
--- a/libavcodec/ac3dec.c
+++ b/libavcodec/ac3dec.c
@@ -3,7 +3,7 @@
  * This code was developed as part of Google Summer of Code 2006.
  * E-AC-3 support was added as part of Google Summer of Code 2007.
  *
- * Copyright (c) 2006 Kartikey Mahendra BHATT (bhattkm at gmail dot com).
+ * Copyright (c) 2006 Kartikey Mahendra BHATT (bhattkm at gmail dot com)
  * Copyright (c) 2007-2008 Bartlomiej Wolowiec <bartek.wolowiec at gmail.com>
  * Copyright (c) 2007 Justin Ruggles <justin.ruggles at gmail.com>
  *
diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c
index 434869c..43c59e0 100644
--- a/libavcodec/ac3enc.c
+++ b/libavcodec/ac3enc.c
@@ -1,6 +1,6 @@
 /*
  * The simplest AC-3 encoder
- * Copyright (c) 2000 Fabrice Bellard.
+ * Copyright (c) 2000 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/ac3tab.h b/libavcodec/ac3tab.h
index a46e29d..c76b187 100644
--- a/libavcodec/ac3tab.h
+++ b/libavcodec/ac3tab.h
@@ -1,6 +1,6 @@
 /*
  * AC-3 tables
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
+ * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/adxdec.c b/libavcodec/adxdec.c
index aa0e896..0ce3d1f 100644
--- a/libavcodec/adxdec.c
+++ b/libavcodec/adxdec.c
@@ -24,7 +24,7 @@
 #include "adx.h"
 
 /**
- * @file adx.c
+ * @file adxdec.c
  * SEGA CRI adx codecs.
  *
  * Reference documents:
diff --git a/libavcodec/adxenc.c b/libavcodec/adxenc.c
index 1ba8608..21df9d4 100644
--- a/libavcodec/adxenc.c
+++ b/libavcodec/adxenc.c
@@ -24,7 +24,7 @@
 #include "adx.h"
 
 /**
- * @file adx.c
+ * @file adxenc.c
  * SEGA CRI adx codecs.
  *
  * Reference documents:
diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c
index 6c61d44..f369c0a 100644
--- a/libavcodec/allcodecs.c
+++ b/libavcodec/allcodecs.c
@@ -1,6 +1,6 @@
 /*
  * Provides registration of all codecs, parsers and bitstream filters for libavcodec.
- * Copyright (c) 2002 Fabrice Bellard.
+ * Copyright (c) 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
@@ -157,6 +157,7 @@ void avcodec_register_all(void)
     REGISTER_DECODER (ULTI, ulti);
     REGISTER_DECODER (VB, vb);
     REGISTER_DECODER (VC1, vc1);
+    REGISTER_DECODER (VC1_VDPAU, vc1_vdpau);
     REGISTER_DECODER (VCR1, vcr1);
     REGISTER_DECODER (VMDVIDEO, vmdvideo);
     REGISTER_DECODER (VMNC, vmnc);
@@ -169,6 +170,7 @@ void avcodec_register_all(void)
     REGISTER_ENCDEC  (WMV1, wmv1);
     REGISTER_ENCDEC  (WMV2, wmv2);
     REGISTER_DECODER (WMV3, wmv3);
+    REGISTER_DECODER (WMV3_VDPAU, wmv3_vdpau);
     REGISTER_DECODER (WNV1, wnv1);
     REGISTER_DECODER (XAN_WC3, xan_wc3);
     REGISTER_DECODER (XL, xl);
diff --git a/libavcodec/arm/dsputil_arm.c b/libavcodec/arm/dsputil_arm.c
index cb6f6d0..c8a277e 100644
--- a/libavcodec/arm/dsputil_arm.c
+++ b/libavcodec/arm/dsputil_arm.c
@@ -1,6 +1,6 @@
 /*
  * ARM optimized DSP utils
- * Copyright (c) 2001 Lionel Ulmer.
+ * Copyright (c) 2001 Lionel Ulmer
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/arm/dsputil_arm_s.S b/libavcodec/arm/dsputil_arm_s.S
index 9425d33..f10d616 100644
--- a/libavcodec/arm/dsputil_arm_s.S
+++ b/libavcodec/arm/dsputil_arm_s.S
@@ -90,18 +90,25 @@ function ff_prefetch_arm, export=1
         add \Rd1, \Rn1, \Rd1, lsr #1
 .endm
 
+.macro  JMP_ALIGN tmp, reg
+        ands \tmp, \reg, #3
+        bic  \reg, \reg, #3
+        beq  1f
+        subs \tmp, \tmp, #1
+        beq  2f
+        subs \tmp, \tmp, #1
+        beq  3f
+        b    4f
+.endm
+
 @ ----------------------------------------------------------------
-        .align 8
+        .align 5
 function put_pixels16_arm, export=1
         @ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
         @ block = word aligned, pixles = unaligned
         pld [r1]
         stmfd sp!, {r4-r11, lr} @ R14 is also called LR
-        adr r5, 5f
-        ands r4, r1, #3
-        bic r1, r1, #3
-        add r5, r5, r4, lsl #2
-        ldrne pc, [r5]
+        JMP_ALIGN r5, r1
 1:
         ldmia r1, {r4-r7}
         add r1, r1, r2
@@ -111,7 +118,7 @@ function put_pixels16_arm, export=1
         add r0, r0, r2
         bne 1b
         ldmfd sp!, {r4-r11, pc}
-        .align 8
+        .align 5
 2:
         ldmia r1, {r4-r8}
         add r1, r1, r2
@@ -122,7 +129,7 @@ function put_pixels16_arm, export=1
         add r0, r0, r2
         bne 2b
         ldmfd sp!, {r4-r11, pc}
-        .align 8
+        .align 5
 3:
         ldmia r1, {r4-r8}
         add r1, r1, r2
@@ -133,7 +140,7 @@ function put_pixels16_arm, export=1
         add r0, r0, r2
         bne 3b
         ldmfd sp!, {r4-r11, pc}
-        .align 8
+        .align 5
 4:
         ldmia r1, {r4-r8}
         add r1, r1, r2
@@ -144,26 +151,16 @@ function put_pixels16_arm, export=1
         add r0, r0, r2
         bne 4b
         ldmfd sp!, {r4-r11,pc}
-        .align 8
-5:
-        .word 1b
-        .word 2b
-        .word 3b
-        .word 4b
         .endfunc
 
 @ ----------------------------------------------------------------
-        .align 8
+        .align 5
 function put_pixels8_arm, export=1
         @ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
         @ block = word aligned, pixles = unaligned
         pld [r1]
         stmfd sp!, {r4-r5,lr} @ R14 is also called LR
-        adr r5, 5f
-        ands r4, r1, #3
-        bic r1, r1, #3
-        add r5, r5, r4, lsl #2
-        ldrne pc, [r5]
+        JMP_ALIGN r5, r1
 1:
         ldmia r1, {r4-r5}
         add r1, r1, r2
@@ -173,7 +170,7 @@ function put_pixels8_arm, export=1
         add r0, r0, r2
         bne 1b
         ldmfd sp!, {r4-r5,pc}
-        .align 8
+        .align 5
 2:
         ldmia r1, {r4-r5, r12}
         add r1, r1, r2
@@ -184,7 +181,7 @@ function put_pixels8_arm, export=1
         add r0, r0, r2
         bne 2b
         ldmfd sp!, {r4-r5,pc}
-        .align 8
+        .align 5
 3:
         ldmia r1, {r4-r5, r12}
         add r1, r1, r2
@@ -195,7 +192,7 @@ function put_pixels8_arm, export=1
         add r0, r0, r2
         bne 3b
         ldmfd sp!, {r4-r5,pc}
-        .align 8
+        .align 5
 4:
         ldmia r1, {r4-r5, r12}
         add r1, r1, r2
@@ -206,27 +203,17 @@ function put_pixels8_arm, export=1
         add r0, r0, r2
         bne 4b
         ldmfd sp!, {r4-r5,pc}
-        .align 8
-5:
-        .word 1b
-        .word 2b
-        .word 3b
-        .word 4b
         .endfunc
 
 @ ----------------------------------------------------------------
-        .align 8
+        .align 5
 function put_pixels8_x2_arm, export=1
         @ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
         @ block = word aligned, pixles = unaligned
         pld [r1]
         stmfd sp!, {r4-r10,lr} @ R14 is also called LR
-        adr r5, 5f
-        ands r4, r1, #3
-        ldr r12, [r5]
-        add r5, r5, r4, lsl #2
-        bic r1, r1, #3
-        ldrne pc, [r5]
+        ldr r12, =0xfefefefe
+        JMP_ALIGN r5, r1
 1:
         ldmia r1, {r4-r5, r10}
         add r1, r1, r2
@@ -238,7 +225,7 @@ function put_pixels8_x2_arm, export=1
         add r0, r0, r2
         bne 1b
         ldmfd sp!, {r4-r10,pc}
-        .align 8
+        .align 5
 2:
         ldmia r1, {r4-r5, r10}
         add r1, r1, r2
@@ -251,7 +238,7 @@ function put_pixels8_x2_arm, export=1
         add r0, r0, r2
         bne 2b
         ldmfd sp!, {r4-r10,pc}
-        .align 8
+        .align 5
 3:
         ldmia r1, {r4-r5, r10}
         add r1, r1, r2
@@ -264,7 +251,7 @@ function put_pixels8_x2_arm, export=1
         add r0, r0, r2
         bne 3b
         ldmfd sp!, {r4-r10,pc}
-        .align 8
+        .align 5
 4:
         ldmia r1, {r4-r5, r10}
         add r1, r1, r2
@@ -276,26 +263,16 @@ function put_pixels8_x2_arm, export=1
         add r0, r0, r2
         bne 4b
         ldmfd sp!, {r4-r10,pc} @@ update PC with LR content.
-        .align 8
-5:
-        .word 0xFEFEFEFE
-        .word 2b
-        .word 3b
-        .word 4b
         .endfunc
 
-        .align 8
+        .align 5
 function put_no_rnd_pixels8_x2_arm, export=1
         @ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
         @ block = word aligned, pixles = unaligned
         pld [r1]
         stmfd sp!, {r4-r10,lr} @ R14 is also called LR
-        adr r5, 5f
-        ands r4, r1, #3
-        ldr r12, [r5]
-        add r5, r5, r4, lsl #2
-        bic r1, r1, #3
-        ldrne pc, [r5]
+        ldr r12, =0xfefefefe
+        JMP_ALIGN r5, r1
 1:
         ldmia r1, {r4-r5, r10}
         add r1, r1, r2
@@ -307,7 +284,7 @@ function put_no_rnd_pixels8_x2_arm, export=1
         add r0, r0, r2
         bne 1b
         ldmfd sp!, {r4-r10,pc}
-        .align 8
+        .align 5
 2:
         ldmia r1, {r4-r5, r10}
         add r1, r1, r2
@@ -320,7 +297,7 @@ function put_no_rnd_pixels8_x2_arm, export=1
         add r0, r0, r2
         bne 2b
         ldmfd sp!, {r4-r10,pc}
-        .align 8
+        .align 5
 3:
         ldmia r1, {r4-r5, r10}
         add r1, r1, r2
@@ -333,7 +310,7 @@ function put_no_rnd_pixels8_x2_arm, export=1
         add r0, r0, r2
         bne 3b
         ldmfd sp!, {r4-r10,pc}
-        .align 8
+        .align 5
 4:
         ldmia r1, {r4-r5, r10}
         add r1, r1, r2
@@ -345,29 +322,19 @@ function put_no_rnd_pixels8_x2_arm, export=1
         add r0, r0, r2
         bne 4b
         ldmfd sp!, {r4-r10,pc} @@ update PC with LR content.
-        .align 8
-5:
-        .word 0xFEFEFEFE
-        .word 2b
-        .word 3b
-        .word 4b
         .endfunc
 
 
 @ ----------------------------------------------------------------
-        .align 8
+        .align 5
 function put_pixels8_y2_arm, export=1
         @ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
         @ block = word aligned, pixles = unaligned
         pld [r1]
         stmfd sp!, {r4-r11,lr} @ R14 is also called LR
-        adr r5, 5f
-        ands r4, r1, #3
         mov r3, r3, lsr #1
-        ldr r12, [r5]
-        add r5, r5, r4, lsl #2
-        bic r1, r1, #3
-        ldrne pc, [r5]
+        ldr r12, =0xfefefefe
+        JMP_ALIGN r5, r1
 1:
         ldmia r1, {r4-r5}
         add r1, r1, r2
@@ -386,7 +353,7 @@ function put_pixels8_y2_arm, export=1
         add r0, r0, r2
         bne 6b
         ldmfd sp!, {r4-r11,pc}
-        .align 8
+        .align 5
 2:
         ldmia r1, {r4-r6}
         add r1, r1, r2
@@ -409,7 +376,7 @@ function put_pixels8_y2_arm, export=1
         add r0, r0, r2
         bne 6b
         ldmfd sp!, {r4-r11,pc}
-        .align 8
+        .align 5
 3:
         ldmia r1, {r4-r6}
         add r1, r1, r2
@@ -432,7 +399,7 @@ function put_pixels8_y2_arm, export=1
         add r0, r0, r2
         bne 6b
         ldmfd sp!, {r4-r11,pc}
-        .align 8
+        .align 5
 4:
         ldmia r1, {r4-r6}
         add r1, r1, r2
@@ -455,28 +422,17 @@ function put_pixels8_y2_arm, export=1
         add r0, r0, r2
         bne 6b
         ldmfd sp!, {r4-r11,pc}
-
-        .align 8
-5:
-        .word 0xFEFEFEFE
-        .word 2b
-        .word 3b
-        .word 4b
         .endfunc
 
-        .align 8
+        .align 5
 function put_no_rnd_pixels8_y2_arm, export=1
         @ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
         @ block = word aligned, pixles = unaligned
         pld [r1]
         stmfd sp!, {r4-r11,lr} @ R14 is also called LR
-        adr r5, 5f
-        ands r4, r1, #3
         mov r3, r3, lsr #1
-        ldr r12, [r5]
-        add r5, r5, r4, lsl #2
-        bic r1, r1, #3
-        ldrne pc, [r5]
+        ldr r12, =0xfefefefe
+        JMP_ALIGN r5, r1
 1:
         ldmia r1, {r4-r5}
         add r1, r1, r2
@@ -495,7 +451,7 @@ function put_no_rnd_pixels8_y2_arm, export=1
         add r0, r0, r2
         bne 6b
         ldmfd sp!, {r4-r11,pc}
-        .align 8
+        .align 5
 2:
         ldmia r1, {r4-r6}
         add r1, r1, r2
@@ -518,7 +474,7 @@ function put_no_rnd_pixels8_y2_arm, export=1
         add r0, r0, r2
         bne 6b
         ldmfd sp!, {r4-r11,pc}
-        .align 8
+        .align 5
 3:
         ldmia r1, {r4-r6}
         add r1, r1, r2
@@ -541,7 +497,7 @@ function put_no_rnd_pixels8_y2_arm, export=1
         add r0, r0, r2
         bne 6b
         ldmfd sp!, {r4-r11,pc}
-        .align 8
+        .align 5
 4:
         ldmia r1, {r4-r6}
         add r1, r1, r2
@@ -564,16 +520,12 @@ function put_no_rnd_pixels8_y2_arm, export=1
         add r0, r0, r2
         bne 6b
         ldmfd sp!, {r4-r11,pc}
-        .align 8
-5:
-        .word 0xFEFEFEFE
-        .word 2b
-        .word 3b
-        .word 4b
         .endfunc
 
+        .ltorg
+
 @ ----------------------------------------------------------------
-.macro  RND_XY2_IT align
+.macro  RND_XY2_IT align, rnd
         @ l1=  (a & 0x03030303) + (b & 0x03030303) ?(+ 0x02020202)
         @ h1= ((a & 0xFCFCFCFCUL) >> 2) + ((b & 0xFCFCFCFCUL) >> 2)
 .if \align == 0
@@ -596,37 +548,37 @@ function put_no_rnd_pixels8_y2_arm, export=1
 .elseif \align == 3
         ADJ_ALIGN_DOUBLEWORD_D 3, r4, r5, r5, r6, r7
 .endif
-        ldr r14, [r12, #0]      @ 0x03030303
+        ldr r14, =0x03030303
         tst r3, #1
         and r8, r4, r14
         and r9, r5, r14
         and r10, r6, r14
         and r11, r7, r14
-        ldreq r14, [r12, #16]   @ 0x02020202/0x01010101
+        andeq r14, r14, r14, \rnd #1
         add r8, r8, r10
         add r9, r9, r11
+        ldr r12, =0xfcfcfcfc >> 2
         addeq r8, r8, r14
         addeq r9, r9, r14
-        ldr r14, [r12, #20]     @ 0xFCFCFCFC >> 2
-        and r4, r14, r4, lsr #2
-        and r5, r14, r5, lsr #2
-        and r6, r14, r6, lsr #2
-        and r7, r14, r7, lsr #2
+        and r4, r12, r4, lsr #2
+        and r5, r12, r5, lsr #2
+        and r6, r12, r6, lsr #2
+        and r7, r12, r7, lsr #2
         add r10, r4, r6
         add r11, r5, r7
         subs r3, r3, #1
 .endm
 
-.macro RND_XY2_EXPAND align
-        RND_XY2_IT \align
+.macro RND_XY2_EXPAND align, rnd
+        RND_XY2_IT \align, \rnd
 6:      stmfd sp!, {r8-r11}
-        RND_XY2_IT \align
+        RND_XY2_IT \align, \rnd
         ldmfd sp!, {r4-r7}
         add r4, r4, r8
         add r5, r5, r9
+        ldr r14, =0x0f0f0f0f
         add r6, r6, r10
         add r7, r7, r11
-        ldr r14, [r12, #24]     @ 0x0F0F0F0F
         and r4, r14, r4, lsr #2
         and r5, r14, r5, lsr #2
         add r4, r4, r6
@@ -637,78 +589,53 @@ function put_no_rnd_pixels8_y2_arm, export=1
         ldmfd sp!, {r4-r11,pc}
 .endm
 
-        .align 8
+        .align 5
 function put_pixels8_xy2_arm, export=1
         @ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
         @ block = word aligned, pixles = unaligned
         pld [r1]
         stmfd sp!, {r4-r11,lr} @ R14 is also called LR
-        adrl r12, 5f
-        ands r4, r1, #3
-        add r5, r12, r4, lsl #2
-        bic r1, r1, #3
-        ldrne pc, [r5]
+        JMP_ALIGN r5, r1
 1:
-        RND_XY2_EXPAND 0
+        RND_XY2_EXPAND 0, lsl
 
-        .align 8
+        .align 5
 2:
-        RND_XY2_EXPAND 1
+        RND_XY2_EXPAND 1, lsl
 
-        .align 8
+        .align 5
 3:
-        RND_XY2_EXPAND 2
+        RND_XY2_EXPAND 2, lsl
 
-        .align 8
+        .align 5
 4:
-        RND_XY2_EXPAND 3
-
-5:
-        .word 0x03030303
-        .word 2b
-        .word 3b
-        .word 4b
-        .word 0x02020202
-        .word 0xFCFCFCFC >> 2
-        .word 0x0F0F0F0F
+        RND_XY2_EXPAND 3, lsl
         .endfunc
 
-        .align 8
+        .align 5
 function put_no_rnd_pixels8_xy2_arm, export=1
         @ void func(uint8_t *block, const uint8_t *pixels, int line_size, int h)
         @ block = word aligned, pixles = unaligned
         pld [r1]
         stmfd sp!, {r4-r11,lr} @ R14 is also called LR
-        adrl r12, 5f
-        ands r4, r1, #3
-        add r5, r12, r4, lsl #2
-        bic r1, r1, #3
-        ldrne pc, [r5]
+        JMP_ALIGN r5, r1
 1:
-        RND_XY2_EXPAND 0
+        RND_XY2_EXPAND 0, lsr
 
-        .align 8
+        .align 5
 2:
-        RND_XY2_EXPAND 1
+        RND_XY2_EXPAND 1, lsr
 
-        .align 8
+        .align 5
 3:
-        RND_XY2_EXPAND 2
+        RND_XY2_EXPAND 2, lsr
 
-        .align 8
+        .align 5
 4:
-        RND_XY2_EXPAND 3
-
-5:
-        .word 0x03030303
-        .word 2b
-        .word 3b
-        .word 4b
-        .word 0x01010101
-        .word 0xFCFCFCFC >> 2
-        .word 0x0F0F0F0F
+        RND_XY2_EXPAND 3, lsr
         .endfunc
 
+        .align 5
 @ void ff_add_pixels_clamped_ARM(int16_t *block, uint8_t *dest, int stride)
 function ff_add_pixels_clamped_ARM, export=1
         push            {r4-r10}
diff --git a/libavcodec/arm/dsputil_neon.c b/libavcodec/arm/dsputil_neon.c
index e50e160..d46fa61 100644
--- a/libavcodec/arm/dsputil_neon.c
+++ b/libavcodec/arm/dsputil_neon.c
@@ -92,6 +92,48 @@ void ff_h264_v_loop_filter_chroma_neon(uint8_t *pix, int stride, int alpha,
 void ff_h264_h_loop_filter_chroma_neon(uint8_t *pix, int stride, int alpha,
                                        int beta, int8_t *tc0);
 
+void ff_weight_h264_pixels_16x16_neon(uint8_t *ds, int stride, int log2_den,
+                                      int weight, int offset);
+void ff_weight_h264_pixels_16x8_neon(uint8_t *ds, int stride, int log2_den,
+                                     int weight, int offset);
+void ff_weight_h264_pixels_8x16_neon(uint8_t *ds, int stride, int log2_den,
+                                     int weight, int offset);
+void ff_weight_h264_pixels_8x8_neon(uint8_t *ds, int stride, int log2_den,
+                                    int weight, int offset);
+void ff_weight_h264_pixels_8x4_neon(uint8_t *ds, int stride, int log2_den,
+                                    int weight, int offset);
+void ff_weight_h264_pixels_4x8_neon(uint8_t *ds, int stride, int log2_den,
+                                    int weight, int offset);
+void ff_weight_h264_pixels_4x4_neon(uint8_t *ds, int stride, int log2_den,
+                                    int weight, int offset);
+void ff_weight_h264_pixels_4x2_neon(uint8_t *ds, int stride, int log2_den,
+                                    int weight, int offset);
+
+void ff_biweight_h264_pixels_16x16_neon(uint8_t *dst, uint8_t *src, int stride,
+                                        int log2_den, int weightd, int weights,
+                                        int offset);
+void ff_biweight_h264_pixels_16x8_neon(uint8_t *dst, uint8_t *src, int stride,
+                                       int log2_den, int weightd, int weights,
+                                       int offset);
+void ff_biweight_h264_pixels_8x16_neon(uint8_t *dst, uint8_t *src, int stride,
+                                       int log2_den, int weightd, int weights,
+                                       int offset);
+void ff_biweight_h264_pixels_8x8_neon(uint8_t *dst, uint8_t *src, int stride,
+                                      int log2_den, int weightd, int weights,
+                                      int offset);
+void ff_biweight_h264_pixels_8x4_neon(uint8_t *dst, uint8_t *src, int stride,
+                                      int log2_den, int weightd, int weights,
+                                      int offset);
+void ff_biweight_h264_pixels_4x8_neon(uint8_t *dst, uint8_t *src, int stride,
+                                      int log2_den, int weightd, int weights,
+                                      int offset);
+void ff_biweight_h264_pixels_4x4_neon(uint8_t *dst, uint8_t *src, int stride,
+                                      int log2_den, int weightd, int weights,
+                                      int offset);
+void ff_biweight_h264_pixels_4x2_neon(uint8_t *dst, uint8_t *src, int stride,
+                                      int log2_den, int weightd, int weights,
+                                      int offset);
+
 void ff_h264_idct_add_neon(uint8_t *dst, DCTELEM *block, int stride);
 void ff_h264_idct_dc_add_neon(uint8_t *dst, DCTELEM *block, int stride);
 void ff_h264_idct_add16_neon(uint8_t *dst, const int *block_offset,
@@ -176,6 +218,24 @@ void ff_dsputil_init_neon(DSPContext *c, AVCodecContext *avctx)
     c->h264_v_loop_filter_chroma = ff_h264_v_loop_filter_chroma_neon;
     c->h264_h_loop_filter_chroma = ff_h264_h_loop_filter_chroma_neon;
 
+    c->weight_h264_pixels_tab[0] = ff_weight_h264_pixels_16x16_neon;
+    c->weight_h264_pixels_tab[1] = ff_weight_h264_pixels_16x8_neon;
+    c->weight_h264_pixels_tab[2] = ff_weight_h264_pixels_8x16_neon;
+    c->weight_h264_pixels_tab[3] = ff_weight_h264_pixels_8x8_neon;
+    c->weight_h264_pixels_tab[4] = ff_weight_h264_pixels_8x4_neon;
+    c->weight_h264_pixels_tab[5] = ff_weight_h264_pixels_4x8_neon;
+    c->weight_h264_pixels_tab[6] = ff_weight_h264_pixels_4x4_neon;
+    c->weight_h264_pixels_tab[7] = ff_weight_h264_pixels_4x2_neon;
+
+    c->biweight_h264_pixels_tab[0] = ff_biweight_h264_pixels_16x16_neon;
+    c->biweight_h264_pixels_tab[1] = ff_biweight_h264_pixels_16x8_neon;
+    c->biweight_h264_pixels_tab[2] = ff_biweight_h264_pixels_8x16_neon;
+    c->biweight_h264_pixels_tab[3] = ff_biweight_h264_pixels_8x8_neon;
+    c->biweight_h264_pixels_tab[4] = ff_biweight_h264_pixels_8x4_neon;
+    c->biweight_h264_pixels_tab[5] = ff_biweight_h264_pixels_4x8_neon;
+    c->biweight_h264_pixels_tab[6] = ff_biweight_h264_pixels_4x4_neon;
+    c->biweight_h264_pixels_tab[7] = ff_biweight_h264_pixels_4x2_neon;
+
     c->h264_idct_add = ff_h264_idct_add_neon;
     c->h264_idct_dc_add = ff_h264_idct_dc_add_neon;
     c->h264_idct_add16      = ff_h264_idct_add16_neon;
diff --git a/libavcodec/arm/h264dsp_neon.S b/libavcodec/arm/h264dsp_neon.S
index e57cb6f..15054a0 100644
--- a/libavcodec/arm/h264dsp_neon.S
+++ b/libavcodec/arm/h264dsp_neon.S
@@ -1368,3 +1368,303 @@ function ff_put_h264_qpel16_mc33_neon, export=1
         sub             r1,  r1,  #1
         b               put_h264_qpel16_mc11
         .endfunc
+
+@ Biweighted prediction
+
+        .macro  biweight_16 macs, macd
+        vdup.8          d0,  r4
+        vdup.8          d1,  r5
+        vmov            q2,  q8
+        vmov            q3,  q8
+1:      subs            ip,  ip,  #2
+        vld1.8          {d20-d21},[r0,:128], r2
+        \macd           q2,  d0,  d20
+        pld             [r0]
+        \macd           q3,  d0,  d21
+        vld1.8          {d22-d23},[r1,:128], r2
+        \macs           q2,  d1,  d22
+        pld             [r1]
+        \macs           q3,  d1,  d23
+        vmov            q12, q8
+        vld1.8          {d28-d29},[r0,:128], r2
+        vmov            q13, q8
+        \macd           q12, d0,  d28
+        pld             [r0]
+        \macd           q13, d0,  d29
+        vld1.8          {d30-d31},[r1,:128], r2
+        \macs           q12, d1,  d30
+        pld             [r1]
+        \macs           q13, d1,  d31
+        vshl.s16        q2,  q2,  q9
+        vshl.s16        q3,  q3,  q9
+        vqmovun.s16     d4,  q2
+        vqmovun.s16     d5,  q3
+        vshl.s16        q12, q12, q9
+        vshl.s16        q13, q13, q9
+        vqmovun.s16     d24, q12
+        vqmovun.s16     d25, q13
+        vmov            q3,  q8
+        vst1.8          {d4- d5}, [r6,:128], r2
+        vmov            q2,  q8
+        vst1.8          {d24-d25},[r6,:128], r2
+        bne             1b
+        pop             {r4-r6, pc}
+        .endm
+
+        .macro  biweight_8 macs, macd
+        vdup.8          d0,  r4
+        vdup.8          d1,  r5
+        vmov            q1,  q8
+        vmov            q10, q8
+1:      subs            ip,  ip,  #2
+        vld1.8          {d4},[r0,:64], r2
+        \macd           q1,  d0,  d4
+        pld             [r0]
+        vld1.8          {d5},[r1,:64], r2
+        \macs           q1,  d1,  d5
+        pld             [r1]
+        vld1.8          {d6},[r0,:64], r2
+        \macd           q10, d0,  d6
+        pld             [r0]
+        vld1.8          {d7},[r1,:64], r2
+        \macs           q10, d1,  d7
+        pld             [r1]
+        vshl.s16        q1,  q1,  q9
+        vqmovun.s16     d2,  q1
+        vshl.s16        q10, q10, q9
+        vqmovun.s16     d4,  q10
+        vmov            q10, q8
+        vst1.8          {d2},[r6,:64], r2
+        vmov            q1,  q8
+        vst1.8          {d4},[r6,:64], r2
+        bne             1b
+        pop             {r4-r6, pc}
+        .endm
+
+        .macro  biweight_4 macs, macd
+        vdup.8          d0,  r4
+        vdup.8          d1,  r5
+        vmov            q1,  q8
+        vmov            q10, q8
+1:      subs            ip,  ip,  #4
+        vld1.32         {d4[0]},[r0,:32], r2
+        vld1.32         {d4[1]},[r0,:32], r2
+        \macd           q1,  d0,  d4
+        pld             [r0]
+        vld1.32         {d5[0]},[r1,:32], r2
+        vld1.32         {d5[1]},[r1,:32], r2
+        \macs           q1,  d1,  d5
+        pld             [r1]
+        blt             2f
+        vld1.32         {d6[0]},[r0,:32], r2
+        vld1.32         {d6[1]},[r0,:32], r2
+        \macd           q10, d0,  d6
+        pld             [r0]
+        vld1.32         {d7[0]},[r1,:32], r2
+        vld1.32         {d7[1]},[r1,:32], r2
+        \macs           q10, d1,  d7
+        pld             [r1]
+        vshl.s16        q1,  q1,  q9
+        vqmovun.s16     d2,  q1
+        vshl.s16        q10, q10, q9
+        vqmovun.s16     d4,  q10
+        vmov            q10, q8
+        vst1.32         {d2[0]},[r6,:32], r2
+        vst1.32         {d2[1]},[r6,:32], r2
+        vmov            q1,  q8
+        vst1.32         {d4[0]},[r6,:32], r2
+        vst1.32         {d4[1]},[r6,:32], r2
+        bne             1b
+        pop             {r4-r6, pc}
+2:      vshl.s16        q1,  q1,  q9
+        vqmovun.s16     d2,  q1
+        vst1.32         {d2[0]},[r6,:32], r2
+        vst1.32         {d2[1]},[r6,:32], r2
+        pop             {r4-r6, pc}
+        .endm
+
+        .macro  biweight_func w
+function biweight_h264_pixels_\w\()_neon
+        push            {r4-r6, lr}
+        add             r4,  sp,  #16
+        ldm             r4,  {r4-r6}
+        lsr             lr,  r4,  #31
+        add             r6,  r6,  #1
+        eors            lr,  lr,  r5,  lsr #30
+        orr             r6,  r6,  #1
+        vdup.16         q9,  r3
+        lsl             r6,  r6,  r3
+        vmvn            q9,  q9
+        vdup.16         q8,  r6
+        mov             r6,  r0
+        beq             10f
+        subs            lr,  lr,  #1
+        beq             20f
+        subs            lr,  lr,  #1
+        beq             30f
+        b               40f
+10:     biweight_\w     vmlal.u8, vmlal.u8
+20:     rsb             r4,  r4,  #0
+        biweight_\w     vmlal.u8, vmlsl.u8
+30:     rsb             r4,  r4,  #0
+        rsb             r5,  r5,  #0
+        biweight_\w     vmlsl.u8, vmlsl.u8
+40:     rsb             r5,  r5,  #0
+        biweight_\w     vmlsl.u8, vmlal.u8
+        .endfunc
+        .endm
+
+        .macro  biweight_entry w, h, b=1
+function ff_biweight_h264_pixels_\w\()x\h\()_neon, export=1
+        mov             ip,  #\h
+.if \b
+        b               biweight_h264_pixels_\w\()_neon
+.endif
+        .endfunc
+        .endm
+
+        biweight_entry  16, 8
+        biweight_entry  16, 16, b=0
+        biweight_func   16
+
+        biweight_entry  8,  16
+        biweight_entry  8,  4
+        biweight_entry  8,  8,  b=0
+        biweight_func   8
+
+        biweight_entry  4,  8
+        biweight_entry  4,  2
+        biweight_entry  4,  4,  b=0
+        biweight_func   4
+
+@ Weighted prediction
+
+        .macro  weight_16 mac
+        vdup.8          d0,  r3
+        vmov            q2,  q8
+        vmov            q3,  q8
+1:      subs            ip,  ip,  #2
+        vld1.8          {d20-d21},[r0,:128], r1
+        \mac            q2,  d0,  d20
+        pld             [r0]
+        \mac            q3,  d0,  d21
+        vmov            q12, q8
+        vld1.8          {d28-d29},[r0,:128], r1
+        vmov            q13, q8
+        \mac            q12, d0,  d28
+        pld             [r0]
+        \mac            q13, d0,  d29
+        vshl.s16        q2,  q2,  q9
+        vshl.s16        q3,  q3,  q9
+        vqmovun.s16     d4,  q2
+        vqmovun.s16     d5,  q3
+        vshl.s16        q12, q12, q9
+        vshl.s16        q13, q13, q9
+        vqmovun.s16     d24, q12
+        vqmovun.s16     d25, q13
+        vmov            q3,  q8
+        vst1.8          {d4- d5}, [r4,:128], r1
+        vmov            q2,  q8
+        vst1.8          {d24-d25},[r4,:128], r1
+        bne             1b
+        pop             {r4, pc}
+        .endm
+
+        .macro  weight_8 mac
+        vdup.8          d0,  r3
+        vmov            q1,  q8
+        vmov            q10, q8
+1:      subs            ip,  ip,  #2
+        vld1.8          {d4},[r0,:64], r1
+        \mac            q1,  d0,  d4
+        pld             [r0]
+        vld1.8          {d6},[r0,:64], r1
+        \mac            q10, d0,  d6
+        pld             [r0]
+        vshl.s16        q1,  q1,  q9
+        vqmovun.s16     d2,  q1
+        vshl.s16        q10, q10, q9
+        vqmovun.s16     d4,  q10
+        vmov            q10, q8
+        vst1.8          {d2},[r4,:64], r1
+        vmov            q1,  q8
+        vst1.8          {d4},[r4,:64], r1
+        bne             1b
+        pop             {r4, pc}
+        .endm
+
+        .macro  weight_4 mac
+        vdup.8          d0,  r3
+        vmov            q1,  q8
+        vmov            q10, q8
+1:      subs            ip,  ip,  #4
+        vld1.32         {d4[0]},[r0,:32], r1
+        vld1.32         {d4[1]},[r0,:32], r1
+        \mac            q1,  d0,  d4
+        pld             [r0]
+        blt             2f
+        vld1.32         {d6[0]},[r0,:32], r1
+        vld1.32         {d6[1]},[r0,:32], r1
+        \mac            q10, d0,  d6
+        pld             [r0]
+        vshl.s16        q1,  q1,  q9
+        vqmovun.s16     d2,  q1
+        vshl.s16        q10, q10, q9
+        vqmovun.s16     d4,  q10
+        vmov            q10, q8
+        vst1.32         {d2[0]},[r4,:32], r1
+        vst1.32         {d2[1]},[r4,:32], r1
+        vmov            q1,  q8
+        vst1.32         {d4[0]},[r4,:32], r1
+        vst1.32         {d4[1]},[r4,:32], r1
+        bne             1b
+        pop             {r4, pc}
+2:      vshl.s16        q1,  q1,  q9
+        vqmovun.s16     d2,  q1
+        vst1.32         {d2[0]},[r4,:32], r1
+        vst1.32         {d2[1]},[r4,:32], r1
+        pop             {r4, pc}
+        .endm
+
+        .macro  weight_func w
+function weight_h264_pixels_\w\()_neon
+        push            {r4, lr}
+        ldr             r4,  [sp, #8]
+        vdup.16         q9,  r2
+        mov             lr,  #1
+        lsl             r4,  r4,  r2
+        subs            r2,  r2,  #1
+        vneg.s16        q9,  q9
+        addge           r4,  r4,  lr,  lsl r2
+        cmp             r3,  #0
+        vdup.16         q8,  r4
+        mov             r4,  r0
+        blt             10f
+        weight_\w       vmlal.u8
+10:     rsb             r3,  r3,  #0
+        weight_\w       vmlsl.u8
+        .endfunc
+        .endm
+
+        .macro  weight_entry w, h, b=1
+function ff_weight_h264_pixels_\w\()x\h\()_neon, export=1
+        mov             ip,  #\h
+.if \b
+        b               weight_h264_pixels_\w\()_neon
+.endif
+        .endfunc
+        .endm
+
+        weight_entry    16, 8
+        weight_entry    16, 16, b=0
+        weight_func     16
+
+        weight_entry    8,  16
+        weight_entry    8,  4
+        weight_entry    8,  8,  b=0
+        weight_func     8
+
+        weight_entry    4,  8
+        weight_entry    4,  2
+        weight_entry    4,  4,  b=0
+        weight_func     4
diff --git a/libavcodec/arm/mathops.h b/libavcodec/arm/mathops.h
index 7a9d632..de2d530 100644
--- a/libavcodec/arm/mathops.h
+++ b/libavcodec/arm/mathops.h
@@ -33,7 +33,7 @@ static inline av_const int MULL(int a, int b, unsigned shift)
             "mov   %0, %0,     lsr %4 \n\t"
             "add   %1, %0, %1, lsl %5 \n\t"
             : "=&r"(lo), "=&r"(hi)
-            : "r"(b), "r"(a), "i"(shift), "i"(32-shift));
+            : "r"(b), "r"(a), "ir"(shift), "ir"(32-shift));
     return hi;
 }
 
@@ -90,4 +90,22 @@ static inline av_const MUL16(int ra, int rb)
 
 #endif
 
+#define mid_pred mid_pred
+static inline av_const int mid_pred(int a, int b, int c)
+{
+    int m;
+    __asm__ volatile (
+        "mov   %0, %2  \n\t"
+        "cmp   %1, %2  \n\t"
+        "movgt %0, %1  \n\t"
+        "movgt %1, %2  \n\t"
+        "cmp   %1, %3  \n\t"
+        "movle %1, %3  \n\t"
+        "cmp   %0, %1  \n\t"
+        "movgt %0, %1  \n\t"
+        : "=&r"(m), "+r"(a)
+        : "r"(b), "r"(c));
+    return m;
+}
+
 #endif /* AVCODEC_ARM_MATHOPS_H */
diff --git a/libavcodec/arm/simple_idct_arm.S b/libavcodec/arm/simple_idct_arm.S
index 16ade1f..9e5e621 100644
--- a/libavcodec/arm/simple_idct_arm.S
+++ b/libavcodec/arm/simple_idct_arm.S
@@ -1,6 +1,6 @@
 /*
  * simple_idct_arm.S
- * Copyright (C) 2002 Frederic 'dilb' Boulay.
+ * Copyright (C) 2002 Frederic 'dilb' Boulay
  *
  * Author: Frederic Boulay <dilb at handhelds.org>
  *
diff --git a/libavcodec/audioconvert.c b/libavcodec/audioconvert.c
index 8c6a6b8..618366a 100644
--- a/libavcodec/audioconvert.c
+++ b/libavcodec/audioconvert.c
@@ -25,9 +25,9 @@
  * @author Michael Niedermayer <michaelni at gmx.at>
  */
 
+#include "libavutil/avstring.h"
 #include "avcodec.h"
 #include "audioconvert.h"
-#include <libavutil/avstring.h>
 
 typedef struct SampleFmtInfo {
     const char *name;
@@ -187,7 +187,7 @@ int av_audio_convert(AVAudioConvert *ctx,
     for(ch=0; ch<ctx->out_channels; ch++){
         const int is=  in_stride[ch];
         const int os= out_stride[ch];
-        uint8_t *pi=  in[ch];
+        const uint8_t *pi=  in[ch];
         uint8_t *po= out[ch];
         uint8_t *end= po + os*len;
         if(!out[ch])
@@ -203,31 +203,31 @@ if(ctx->fmt_pair == ofmt + SAMPLE_FMT_NB*ifmt){\
 //FIXME put things below under ifdefs so we do not waste space for cases no codec will need
 //FIXME rounding and clipping ?
 
-             CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_U8 ,  *(uint8_t*)pi)
-        else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_U8 , (*(uint8_t*)pi - 0x80)<<8)
-        else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_U8 , (*(uint8_t*)pi - 0x80)<<24)
-        else CONV(SAMPLE_FMT_FLT, float  , SAMPLE_FMT_U8 , (*(uint8_t*)pi - 0x80)*(1.0 / (1<<7)))
-        else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_U8 , (*(uint8_t*)pi - 0x80)*(1.0 / (1<<7)))
-        else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_S16, (*(int16_t*)pi>>8) + 0x80)
-        else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_S16,  *(int16_t*)pi)
-        else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_S16,  *(int16_t*)pi<<16)
-        else CONV(SAMPLE_FMT_FLT, float  , SAMPLE_FMT_S16,  *(int16_t*)pi*(1.0 / (1<<15)))
-        else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_S16,  *(int16_t*)pi*(1.0 / (1<<15)))
-        else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_S32, (*(int32_t*)pi>>24) + 0x80)
-        else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_S32,  *(int32_t*)pi>>16)
-        else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_S32,  *(int32_t*)pi)
-        else CONV(SAMPLE_FMT_FLT, float  , SAMPLE_FMT_S32,  *(int32_t*)pi*(1.0 / (1<<31)))
-        else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_S32,  *(int32_t*)pi*(1.0 / (1<<31)))
-        else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_FLT, lrintf(*(float*)pi * (1<<7)) + 0x80)
-        else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_FLT, lrintf(*(float*)pi * (1<<15)))
-        else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_FLT, lrintf(*(float*)pi * (1<<31)))
-        else CONV(SAMPLE_FMT_FLT, float  , SAMPLE_FMT_FLT, *(float*)pi)
-        else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_FLT, *(float*)pi)
-        else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_DBL, lrint(*(double*)pi * (1<<7)) + 0x80)
-        else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_DBL, lrint(*(double*)pi * (1<<15)))
-        else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_DBL, lrint(*(double*)pi * (1<<31)))
-        else CONV(SAMPLE_FMT_FLT, float  , SAMPLE_FMT_DBL, *(double*)pi)
-        else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_DBL, *(double*)pi)
+             CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_U8 ,  *(const uint8_t*)pi)
+        else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80)<<8)
+        else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80)<<24)
+        else CONV(SAMPLE_FMT_FLT, float  , SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80)*(1.0 / (1<<7)))
+        else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_U8 , (*(const uint8_t*)pi - 0x80)*(1.0 / (1<<7)))
+        else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_S16, (*(const int16_t*)pi>>8) + 0x80)
+        else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_S16,  *(const int16_t*)pi)
+        else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_S16,  *(const int16_t*)pi<<16)
+        else CONV(SAMPLE_FMT_FLT, float  , SAMPLE_FMT_S16,  *(const int16_t*)pi*(1.0 / (1<<15)))
+        else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_S16,  *(const int16_t*)pi*(1.0 / (1<<15)))
+        else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_S32, (*(const int32_t*)pi>>24) + 0x80)
+        else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_S32,  *(const int32_t*)pi>>16)
+        else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_S32,  *(const int32_t*)pi)
+        else CONV(SAMPLE_FMT_FLT, float  , SAMPLE_FMT_S32,  *(const int32_t*)pi*(1.0 / (1<<31)))
+        else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_S32,  *(const int32_t*)pi*(1.0 / (1<<31)))
+        else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_FLT, lrintf(*(const float*)pi * (1<<7)) + 0x80)
+        else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_FLT, lrintf(*(const float*)pi * (1<<15)))
+        else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_FLT, lrintf(*(const float*)pi * (1<<31)))
+        else CONV(SAMPLE_FMT_FLT, float  , SAMPLE_FMT_FLT, *(const float*)pi)
+        else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_FLT, *(const float*)pi)
+        else CONV(SAMPLE_FMT_U8 , uint8_t, SAMPLE_FMT_DBL, lrint(*(const double*)pi * (1<<7)) + 0x80)
+        else CONV(SAMPLE_FMT_S16, int16_t, SAMPLE_FMT_DBL, lrint(*(const double*)pi * (1<<15)))
+        else CONV(SAMPLE_FMT_S32, int32_t, SAMPLE_FMT_DBL, lrint(*(const double*)pi * (1<<31)))
+        else CONV(SAMPLE_FMT_FLT, float  , SAMPLE_FMT_DBL, *(const double*)pi)
+        else CONV(SAMPLE_FMT_DBL, double , SAMPLE_FMT_DBL, *(const double*)pi)
         else return -1;
     }
     return 0;
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index edd4a7b..6aa41b5 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -26,7 +26,7 @@
  * external API header
  */
 
-
+#include <errno.h>
 #include "libavutil/avutil.h"
 
 #define LIBAVCODEC_VERSION_MAJOR 52
diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c
index a43f031..7de6bba 100644
--- a/libavcodec/bitstream.c
+++ b/libavcodec/bitstream.c
@@ -1,6 +1,6 @@
 /*
  * Common bit i/o utils
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  *
  * alternative bitstream reader & writer by Michael Niedermayer <michaelni at gmx.at>
diff --git a/libavcodec/bitstream.h b/libavcodec/bitstream.h
index 0f81106..9af01af 100644
--- a/libavcodec/bitstream.h
+++ b/libavcodec/bitstream.h
@@ -198,10 +198,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
     if (n >= bit_left) {
 #if !HAVE_FAST_UNALIGNED
         if (3 & (intptr_t) s->buf_ptr) {
-            s->buf_ptr[0] = bit_buf      ;
-            s->buf_ptr[1] = bit_buf >>  8;
-            s->buf_ptr[2] = bit_buf >> 16;
-            s->buf_ptr[3] = bit_buf >> 24;
+            AV_WL32(s->buf_ptr, bit_buf);
         } else
 #endif
         *(uint32_t *)s->buf_ptr = le2me_32(bit_buf);
@@ -219,10 +216,7 @@ static inline void put_bits(PutBitContext *s, int n, unsigned int value)
         bit_buf |= value >> (n - bit_left);
 #if !HAVE_FAST_UNALIGNED
         if (3 & (intptr_t) s->buf_ptr) {
-            s->buf_ptr[0] = bit_buf >> 24;
-            s->buf_ptr[1] = bit_buf >> 16;
-            s->buf_ptr[2] = bit_buf >>  8;
-            s->buf_ptr[3] = bit_buf      ;
+            AV_WB32(s->buf_ptr, bit_buf);
         } else
 #endif
         *(uint32_t *)s->buf_ptr = be2me_32(bit_buf);
diff --git a/libavcodec/bytestream.h b/libavcodec/bytestream.h
index 0f2178a..b56f6ce 100644
--- a/libavcodec/bytestream.h
+++ b/libavcodec/bytestream.h
@@ -22,6 +22,7 @@
 #ifndef AVCODEC_BYTESTREAM_H
 #define AVCODEC_BYTESTREAM_H
 
+#include <string.h>
 #include "libavutil/common.h"
 #include "libavutil/intreadwrite.h"
 
diff --git a/libavcodec/cavsdec.c b/libavcodec/cavsdec.c
index dbf7252..a964be7 100644
--- a/libavcodec/cavsdec.c
+++ b/libavcodec/cavsdec.c
@@ -20,7 +20,7 @@
  */
 
 /**
- * @file cavs.c
+ * @file cavsdec.c
  * Chinese AVS video (AVS1-P2, JiZhun profile) decoder
  * @author Stefan Gehrer <stefan.gehrer at gmx.de>
  */
diff --git a/libavcodec/colorspace.h b/libavcodec/colorspace.h
index 7221517..5f886f7 100644
--- a/libavcodec/colorspace.h
+++ b/libavcodec/colorspace.h
@@ -1,6 +1,6 @@
 /*
  * Colorspace conversion defines
- * Copyright (c) 2001, 2002, 2003 Fabrice Bellard.
+ * Copyright (c) 2001, 2002, 2003 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/cook.c b/libavcodec/cook.c
index 1affe03..98c0568 100644
--- a/libavcodec/cook.c
+++ b/libavcodec/cook.c
@@ -1053,7 +1053,7 @@ static int cook_decode_init(AVCodecContext *avctx)
     q->bit_rate = avctx->bit_rate;
 
     /* Initialize RNG. */
-    av_init_random(1, &q->random_state);
+    av_random_init(&q->random_state, 1);
 
     /* Initialize extradata related variables. */
     q->samples_per_channel = q->samples_per_frame / q->nb_channels;
diff --git a/libavcodec/dcadata.h b/libavcodec/dcadata.h
index 8b777ef..2c15bba 100644
--- a/libavcodec/dcadata.h
+++ b/libavcodec/dcadata.h
@@ -21,7 +21,7 @@
  */
 
 /**
- * @file dcadata.c
+ * @file dcadata.h
  */
 
 #ifndef AVCODEC_DCADATA_H
diff --git a/libavcodec/dnxhddata.c b/libavcodec/dnxhddata.c
index a6cc174..2625a9b 100644
--- a/libavcodec/dnxhddata.c
+++ b/libavcodec/dnxhddata.c
@@ -1,6 +1,6 @@
 /*
  * VC3/DNxHD data.
- * Copyright (c) 2007 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>.
+ * Copyright (c) 2007 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/dnxhddata.h b/libavcodec/dnxhddata.h
index 8dbc48b..32c77db 100644
--- a/libavcodec/dnxhddata.h
+++ b/libavcodec/dnxhddata.h
@@ -1,6 +1,6 @@
 /*
  * VC3/DNxHD decoder.
- * Copyright (c) 2007 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>.
+ * Copyright (c) 2007 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/dnxhddec.c b/libavcodec/dnxhddec.c
index 4bf98de..861a030 100644
--- a/libavcodec/dnxhddec.c
+++ b/libavcodec/dnxhddec.c
@@ -1,6 +1,6 @@
 /*
  * VC3/DNxHD decoder.
- * Copyright (c) 2007 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>.
+ * Copyright (c) 2007 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/dpcm.c b/libavcodec/dpcm.c
index be976e8..227bf78 100644
--- a/libavcodec/dpcm.c
+++ b/libavcodec/dpcm.c
@@ -1,6 +1,6 @@
 /*
  * Assorted DPCM codecs
- * Copyright (c) 2003 The ffmpeg Project.
+ * Copyright (c) 2003 The ffmpeg Project
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
index d53bbed..2c48517 100644
--- a/libavcodec/dsputil.c
+++ b/libavcodec/dsputil.c
@@ -1,6 +1,6 @@
 /*
  * DSP utils
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  *
  * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni at gmx.at>
diff --git a/libavcodec/dsputil.h b/libavcodec/dsputil.h
index 62415b7..165aef7 100644
--- a/libavcodec/dsputil.h
+++ b/libavcodec/dsputil.h
@@ -1,6 +1,6 @@
 /*
  * DSP utils
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
+ * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  *
  * This file is part of FFmpeg.
@@ -674,6 +674,11 @@ typedef struct FFTContext {
     void (*imdct_half)(struct MDCTContext *s, FFTSample *output, const FFTSample *input);
 } FFTContext;
 
+/**
+ * Sets up a complex FFT.
+ * @param nbits           log2 of the length of the input array
+ * @param inverse         if 0 perform the forward transform, if 1 perform the inverse
+ */
 int ff_fft_init(FFTContext *s, int nbits, int inverse);
 void ff_fft_permute_c(FFTContext *s, FFTComplex *z);
 void ff_fft_permute_sse(FFTContext *s, FFTComplex *z);
@@ -683,10 +688,17 @@ void ff_fft_calc_3dn(FFTContext *s, FFTComplex *z);
 void ff_fft_calc_3dn2(FFTContext *s, FFTComplex *z);
 void ff_fft_calc_altivec(FFTContext *s, FFTComplex *z);
 
+/**
+ * Do the permutation needed BEFORE calling ff_fft_calc().
+ */
 static inline void ff_fft_permute(FFTContext *s, FFTComplex *z)
 {
     s->fft_permute(s, z);
 }
+/**
+ * Do a complex FFT with the parameters defined in ff_fft_init(). The
+ * input data must be permuted before. No 1.0/sqrt(n) normalization is done.
+ */
 static inline void ff_fft_calc(FFTContext *s, FFTComplex *z)
 {
     s->fft_calc(s, z);
diff --git a/libavcodec/dv.c b/libavcodec/dv.c
index 2eb4a41..6568e86 100644
--- a/libavcodec/dv.c
+++ b/libavcodec/dv.c
@@ -1,10 +1,10 @@
 /*
  * DV decoder
- * Copyright (c) 2002 Fabrice Bellard.
- * Copyright (c) 2004 Roman Shaposhnik.
+ * Copyright (c) 2002 Fabrice Bellard
+ * Copyright (c) 2004 Roman Shaposhnik
  *
  * DV encoder
- * Copyright (c) 2003 Roman Shaposhnik.
+ * Copyright (c) 2003 Roman Shaposhnik
  *
  * 50 Mbps (DVCPRO50) support
  * Copyright (c) 2006 Daniel Maas <dmaas at maasdigital.com>
diff --git a/libavcodec/dvbsub.c b/libavcodec/dvbsub.c
index ed548e2..3788d55 100644
--- a/libavcodec/dvbsub.c
+++ b/libavcodec/dvbsub.c
@@ -1,6 +1,6 @@
 /*
  * DVB subtitle encoding for ffmpeg
- * Copyright (c) 2005 Fabrice Bellard.
+ * Copyright (c) 2005 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/dvbsub_parser.c b/libavcodec/dvbsub_parser.c
index 0a83de3..96381df 100644
--- a/libavcodec/dvbsub_parser.c
+++ b/libavcodec/dvbsub_parser.c
@@ -1,6 +1,6 @@
 /*
  * DVB subtitle parser for FFmpeg
- * Copyright (c) 2005 Ian Caulfield.
+ * Copyright (c) 2005 Ian Caulfield
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c
index 689c068..2a05390 100644
--- a/libavcodec/dvbsubdec.c
+++ b/libavcodec/dvbsubdec.c
@@ -1,6 +1,6 @@
 /*
  * DVB subtitle decoding for ffmpeg
- * Copyright (c) 2005 Ian Caulfield.
+ * Copyright (c) 2005 Ian Caulfield
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/dvdata.h b/libavcodec/dvdata.h
index f53fbea..fec406a 100644
--- a/libavcodec/dvdata.h
+++ b/libavcodec/dvdata.h
@@ -1,6 +1,6 @@
 /*
  * Constants for DV codec
- * Copyright (c) 2002 Fabrice Bellard.
+ * Copyright (c) 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/dvdsub_parser.c b/libavcodec/dvdsub_parser.c
index ed6ed36..c3686d1 100644
--- a/libavcodec/dvdsub_parser.c
+++ b/libavcodec/dvdsub_parser.c
@@ -1,6 +1,6 @@
 /*
  * DVD subtitle decoding for ffmpeg
- * Copyright (c) 2005 Fabrice Bellard.
+ * Copyright (c) 2005 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
index dac152b..31e7a47 100644
--- a/libavcodec/dvdsubdec.c
+++ b/libavcodec/dvdsubdec.c
@@ -1,6 +1,6 @@
 /*
  * DVD subtitle decoding for ffmpeg
- * Copyright (c) 2005 Fabrice Bellard.
+ * Copyright (c) 2005 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/dvdsubenc.c b/libavcodec/dvdsubenc.c
index 5f6bc21..4dc58e7 100644
--- a/libavcodec/dvdsubenc.c
+++ b/libavcodec/dvdsubenc.c
@@ -1,6 +1,6 @@
 /*
  * DVD subtitle encoding for ffmpeg
- * Copyright (c) 2005 Wolfram Gloger.
+ * Copyright (c) 2005 Wolfram Gloger
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/elbg.c b/libavcodec/elbg.c
index fed25fc..59ae4b9 100644
--- a/libavcodec/elbg.c
+++ b/libavcodec/elbg.c
@@ -19,7 +19,7 @@
  */
 
 /**
- * @file cbook_gen.c
+ * @file elbg.c
  * Codebook Generator using the ELBG algorithm
  */
 
diff --git a/libavcodec/elbg.h b/libavcodec/elbg.h
index 9be0440..cbc1f98 100644
--- a/libavcodec/elbg.h
+++ b/libavcodec/elbg.h
@@ -35,7 +35,7 @@
  * @param numCB Number of points in the codebook.
  * @param num_steps The maximum number of steps. One step is already a good compromise between time and quality.
  * @param closest_cb Return the closest codebook to each point. Must be allocated.
- * @param rand_state A random number generator state. Should be already initialised by av_init_random.
+ * @param rand_state A random number generator state. Should be already initialised by av_random_init.
  */
 void ff_do_elbg(int *points, int dim, int numpoints, int *codebook,
                 int numCB, int num_steps, int *closest_cb,
diff --git a/libavcodec/fft.c b/libavcodec/fft.c
index 099ecbe..e342c05 100644
--- a/libavcodec/fft.c
+++ b/libavcodec/fft.c
@@ -1,7 +1,7 @@
 /*
  * FFT/IFFT transforms
  * Copyright (c) 2008 Loren Merritt
- * Copyright (c) 2002 Fabrice Bellard.
+ * Copyright (c) 2002 Fabrice Bellard
  * Partly based on libdjbfft by D. J. Bernstein
  *
  * This file is part of FFmpeg.
@@ -58,11 +58,7 @@ static int split_radix_permutation(int i, int n, int inverse)
     else                  return split_radix_permutation(i, m, inverse)*4 - 1;
 }
 
-/**
- * The size of the FFT is 2^nbits. If inverse is TRUE, inverse FFT is
- * done
- */
-int ff_fft_init(FFTContext *s, int nbits, int inverse)
+av_cold int ff_fft_init(FFTContext *s, int nbits, int inverse)
 {
     int i, j, m, n;
     float alpha, c1, s1, s2;
@@ -185,9 +181,6 @@ int ff_fft_init(FFTContext *s, int nbits, int inverse)
     return -1;
 }
 
-/**
- * Do the permutation needed BEFORE calling ff_fft_calc()
- */
 void ff_fft_permute_c(FFTContext *s, FFTComplex *z)
 {
     int j, k, np;
@@ -374,11 +367,6 @@ static void (*fft_dispatch[])(FFTComplex*) = {
     fft2048, fft4096, fft8192, fft16384, fft32768, fft65536,
 };
 
-/**
- * Do a complex FFT with the parameters defined in ff_fft_init(). The
- * input data must be permuted before with s->revtab table. No
- * 1.0/sqrt(n) normalization is done.
- */
 void ff_fft_calc_c(FFTContext *s, FFTComplex *z)
 {
     fft_dispatch[s->nbits-2](z);
diff --git a/libavcodec/flac.h b/libavcodec/flac.h
index e110f48..02b41e1 100644
--- a/libavcodec/flac.h
+++ b/libavcodec/flac.h
@@ -29,6 +29,19 @@
 
 #include "avcodec.h"
 
+#define FLAC_STREAMINFO_SIZE 34
+
+enum {
+    FLAC_METADATA_TYPE_STREAMINFO = 0,
+    FLAC_METADATA_TYPE_PADDING,
+    FLAC_METADATA_TYPE_APPLICATION,
+    FLAC_METADATA_TYPE_SEEKTABLE,
+    FLAC_METADATA_TYPE_VORBIS_COMMENT,
+    FLAC_METADATA_TYPE_CUESHEET,
+    FLAC_METADATA_TYPE_PICTURE,
+    FLAC_METADATA_TYPE_INVALID = 127
+};
+
 /**
  * Data needed from the Streaminfo header for use by the raw FLAC demuxer
  * and/or the FLAC decoder.
@@ -40,6 +53,7 @@
     int samplerate;         /**< sample rate                             */\
     int channels;           /**< number of channels                      */\
     int bps;                /**< bits-per-sample                         */\
+    int64_t samples;        /**< total number of samples                 */\
 
 typedef struct FLACStreaminfo {
     FLACSTREAMINFO
diff --git a/libavcodec/flac.c b/libavcodec/flacdec.c
similarity index 59%
rename from libavcodec/flac.c
rename to libavcodec/flacdec.c
index 4028507..ee3a3f2 100644
--- a/libavcodec/flac.c
+++ b/libavcodec/flacdec.c
@@ -20,7 +20,7 @@
  */
 
 /**
- * @file flac.c
+ * @file flacdec.c
  * FLAC (Free Lossless Audio Codec) decoder
  * @author Alex Beregszaszi
  *
@@ -47,7 +47,6 @@
 
 #define MAX_CHANNELS 8
 #define MAX_BLOCKSIZE 65535
-#define FLAC_STREAMINFO_SIZE 34
 
 enum decorrelation_type {
     INDEPENDENT,
@@ -73,10 +72,9 @@ typedef struct FLACContext {
     unsigned int allocated_bitstream_size;
 } FLACContext;
 
-#define METADATA_TYPE_STREAMINFO 0
-
 static const int sample_rate_table[] =
-{ 0, 0, 0, 0,
+{ 0,
+  88200, 176400, 192000,
   8000, 16000, 22050, 24000, 32000, 44100, 48000, 96000,
   0, 0, 0, 0 };
 
@@ -88,7 +86,8 @@ static const int blocksize_table[] = {
 256<<0, 256<<1, 256<<2, 256<<3, 256<<4, 256<<5, 256<<6, 256<<7
 };
 
-static int64_t get_utf8(GetBitContext *gb){
+static int64_t get_utf8(GetBitContext *gb)
+{
     int64_t val;
     GET_UTF8(val, get_bits(gb, 8), return -1;)
     return val;
@@ -97,7 +96,7 @@ static int64_t get_utf8(GetBitContext *gb){
 static void allocate_buffers(FLACContext *s);
 static int metadata_parse(FLACContext *s);
 
-static av_cold int flac_decode_init(AVCodecContext * avctx)
+static av_cold int flac_decode_init(AVCodecContext *avctx)
 {
     FLACContext *s = avctx->priv_data;
     s->avctx = avctx;
@@ -105,7 +104,8 @@ static av_cold int flac_decode_init(AVCodecContext * avctx)
     if (avctx->extradata_size > 4) {
         /* initialize based on the demuxer-supplied streamdata header */
         if (avctx->extradata_size == FLAC_STREAMINFO_SIZE) {
-            ff_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s, avctx->extradata);
+            ff_flac_parse_streaminfo(avctx, (FLACStreaminfo *)s,
+                                     avctx->extradata);
             allocate_buffers(s);
         } else {
             init_get_bits(&s->gb, avctx->extradata, avctx->extradata_size*8);
@@ -119,29 +119,34 @@ static av_cold int flac_decode_init(AVCodecContext * avctx)
 
 static void dump_headers(AVCodecContext *avctx, FLACStreaminfo *s)
 {
-    av_log(avctx, AV_LOG_DEBUG, "  Blocksize: %d .. %d\n", s->min_blocksize, s->max_blocksize);
+    av_log(avctx, AV_LOG_DEBUG, "  Blocksize: %d .. %d\n", s->min_blocksize,
+           s->max_blocksize);
     av_log(avctx, AV_LOG_DEBUG, "  Max Framesize: %d\n", s->max_framesize);
     av_log(avctx, AV_LOG_DEBUG, "  Samplerate: %d\n", s->samplerate);
     av_log(avctx, AV_LOG_DEBUG, "  Channels: %d\n", s->channels);
     av_log(avctx, AV_LOG_DEBUG, "  Bits: %d\n", s->bps);
 }
 
-static void allocate_buffers(FLACContext *s){
+static void allocate_buffers(FLACContext *s)
+{
     int i;
 
     assert(s->max_blocksize);
 
-    if(s->max_framesize == 0 && s->max_blocksize){
-        s->max_framesize= (s->channels * s->bps * s->max_blocksize + 7)/ 8; //FIXME header overhead
+    if (s->max_framesize == 0 && s->max_blocksize) {
+        // FIXME header overhead
+        s->max_framesize= (s->channels * s->bps * s->max_blocksize + 7)/ 8;
     }
 
-    for (i = 0; i < s->channels; i++)
-    {
-        s->decoded[i] = av_realloc(s->decoded[i], sizeof(int32_t)*s->max_blocksize);
+    for (i = 0; i < s->channels; i++) {
+        s->decoded[i] = av_realloc(s->decoded[i],
+                                   sizeof(int32_t)*s->max_blocksize);
     }
 
-    if(s->allocated_bitstream_size < s->max_framesize)
-        s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize);
+    if (s->allocated_bitstream_size < s->max_framesize)
+        s->bitstream= av_fast_realloc(s->bitstream,
+                                      &s->allocated_bitstream_size,
+                                      s->max_framesize);
 }
 
 void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
@@ -164,7 +169,8 @@ void ff_flac_parse_streaminfo(AVCodecContext *avctx, struct FLACStreaminfo *s,
     avctx->channels = s->channels;
     avctx->sample_rate = s->samplerate;
 
-    skip_bits(&gb, 36); /* total num of samples */
+    s->samples  = get_bits_long(&gb, 32) << 4;
+    s->samples |= get_bits_long(&gb, 4);
 
     skip_bits(&gb, 64); /* md5 sum */
     skip_bits(&gb, 64); /* md5 sum */
@@ -187,28 +193,25 @@ static int metadata_parse(FLACContext *s)
     if (show_bits_long(&s->gb, 32) == MKBETAG('f','L','a','C')) {
         skip_bits(&s->gb, 32);
 
-        av_log(s->avctx, AV_LOG_DEBUG, "STREAM HEADER\n");
         do {
             metadata_last = get_bits1(&s->gb);
             metadata_type = get_bits(&s->gb, 7);
             metadata_size = get_bits_long(&s->gb, 24);
 
-            if(get_bits_count(&s->gb) + 8*metadata_size > s->gb.size_in_bits){
+            if (get_bits_count(&s->gb) + 8*metadata_size > s->gb.size_in_bits) {
                 skip_bits_long(&s->gb, initial_pos - get_bits_count(&s->gb));
                 break;
             }
 
-            av_log(s->avctx, AV_LOG_DEBUG,
-                   " metadata block: flag = %d, type = %d, size = %d\n",
-                   metadata_last, metadata_type, metadata_size);
             if (metadata_size) {
                 switch (metadata_type) {
-                case METADATA_TYPE_STREAMINFO:
-                    ff_flac_parse_streaminfo(s->avctx, (FLACStreaminfo *)s, s->gb.buffer+get_bits_count(&s->gb)/8);
+                case FLAC_METADATA_TYPE_STREAMINFO:
+                    ff_flac_parse_streaminfo(s->avctx, (FLACStreaminfo *)s,
+                                             s->gb.buffer+get_bits_count(&s->gb)/8);
                     streaminfo_updated = 1;
 
                 default:
-                    for (i=0; i<metadata_size; i++)
+                    for (i = 0; i < metadata_size; i++)
                         skip_bits(&s->gb, 8);
                 }
             }
@@ -227,8 +230,9 @@ static int decode_residuals(FLACContext *s, int channel, int pred_order)
     int sample = 0, samples;
 
     method_type = get_bits(&s->gb, 2);
-    if (method_type > 1){
-        av_log(s->avctx, AV_LOG_DEBUG, "illegal residual coding method %d\n", method_type);
+    if (method_type > 1) {
+        av_log(s->avctx, AV_LOG_ERROR, "illegal residual coding method %d\n",
+               method_type);
         return -1;
     }
 
@@ -236,34 +240,27 @@ static int decode_residuals(FLACContext *s, int channel, int pred_order)
 
     samples= s->blocksize >> rice_order;
     if (pred_order > samples) {
-        av_log(s->avctx, AV_LOG_ERROR, "invalid predictor order: %i > %i\n", pred_order, samples);
+        av_log(s->avctx, AV_LOG_ERROR, "invalid predictor order: %i > %i\n",
+               pred_order, samples);
         return -1;
     }
 
     sample=
     i= pred_order;
-    for (partition = 0; partition < (1 << rice_order); partition++)
-    {
+    for (partition = 0; partition < (1 << rice_order); partition++) {
         tmp = get_bits(&s->gb, method_type == 0 ? 4 : 5);
-        if (tmp == (method_type == 0 ? 15 : 31))
-        {
-            av_log(s->avctx, AV_LOG_DEBUG, "fixed len partition\n");
+        if (tmp == (method_type == 0 ? 15 : 31)) {
             tmp = get_bits(&s->gb, 5);
             for (; i < samples; i++, sample++)
                 s->decoded[channel][sample] = get_sbits(&s->gb, tmp);
-        }
-        else
-        {
-//            av_log(s->avctx, AV_LOG_DEBUG, "rice coded partition k=%d\n", tmp);
-            for (; i < samples; i++, sample++){
+        } else {
+            for (; i < samples; i++, sample++) {
                 s->decoded[channel][sample] = get_sr_golomb_flac(&s->gb, tmp, INT_MAX, 0);
             }
         }
         i= 0;
     }
 
-//    av_log(s->avctx, AV_LOG_DEBUG, "partitions: %d, samples: %d\n", 1 << rice_order, sample);
-
     return 0;
 }
 
@@ -273,52 +270,45 @@ static int decode_subframe_fixed(FLACContext *s, int channel, int pred_order)
     int32_t *decoded = s->decoded[channel];
     int a, b, c, d, i;
 
-//    av_log(s->avctx, AV_LOG_DEBUG, "  SUBFRAME FIXED\n");
-
     /* warm up samples */
-//    av_log(s->avctx, AV_LOG_DEBUG, "   warm up samples: %d\n", pred_order);
-
-    for (i = 0; i < pred_order; i++)
-    {
+    for (i = 0; i < pred_order; i++) {
         decoded[i] = get_sbits(&s->gb, s->curr_bps);
-//        av_log(s->avctx, AV_LOG_DEBUG, "    %d: %d\n", i, s->decoded[channel][i]);
     }
 
     if (decode_residuals(s, channel, pred_order) < 0)
         return -1;
 
-    if(pred_order > 0)
+    if (pred_order > 0)
         a = decoded[pred_order-1];
-    if(pred_order > 1)
+    if (pred_order > 1)
         b = a - decoded[pred_order-2];
-    if(pred_order > 2)
+    if (pred_order > 2)
         c = b - decoded[pred_order-2] + decoded[pred_order-3];
-    if(pred_order > 3)
+    if (pred_order > 3)
         d = c - decoded[pred_order-2] + 2*decoded[pred_order-3] - decoded[pred_order-4];
 
-    switch(pred_order)
-    {
-        case 0:
-            break;
-        case 1:
-            for (i = pred_order; i < blocksize; i++)
-                decoded[i] = a += decoded[i];
-            break;
-        case 2:
-            for (i = pred_order; i < blocksize; i++)
-                decoded[i] = a += b += decoded[i];
-            break;
-        case 3:
-            for (i = pred_order; i < blocksize; i++)
-                decoded[i] = a += b += c += decoded[i];
-            break;
-        case 4:
-            for (i = pred_order; i < blocksize; i++)
-                decoded[i] = a += b += c += d += decoded[i];
-            break;
-        default:
-            av_log(s->avctx, AV_LOG_ERROR, "illegal pred order %d\n", pred_order);
-            return -1;
+    switch (pred_order) {
+    case 0:
+        break;
+    case 1:
+        for (i = pred_order; i < blocksize; i++)
+            decoded[i] = a += decoded[i];
+        break;
+    case 2:
+        for (i = pred_order; i < blocksize; i++)
+            decoded[i] = a += b += decoded[i];
+        break;
+    case 3:
+        for (i = pred_order; i < blocksize; i++)
+            decoded[i] = a += b += c += decoded[i];
+        break;
+    case 4:
+        for (i = pred_order; i < blocksize; i++)
+            decoded[i] = a += b += c += d += decoded[i];
+        break;
+    default:
+        av_log(s->avctx, AV_LOG_ERROR, "illegal pred order %d\n", pred_order);
+        return -1;
     }
 
     return 0;
@@ -331,35 +321,25 @@ static int decode_subframe_lpc(FLACContext *s, int channel, int pred_order)
     int coeffs[pred_order];
     int32_t *decoded = s->decoded[channel];
 
-//    av_log(s->avctx, AV_LOG_DEBUG, "  SUBFRAME LPC\n");
-
     /* warm up samples */
-//    av_log(s->avctx, AV_LOG_DEBUG, "   warm up samples: %d\n", pred_order);
-
-    for (i = 0; i < pred_order; i++)
-    {
+    for (i = 0; i < pred_order; i++) {
         decoded[i] = get_sbits(&s->gb, s->curr_bps);
-//        av_log(s->avctx, AV_LOG_DEBUG, "    %d: %d\n", i, decoded[i]);
     }
 
     coeff_prec = get_bits(&s->gb, 4) + 1;
-    if (coeff_prec == 16)
-    {
-        av_log(s->avctx, AV_LOG_DEBUG, "invalid coeff precision\n");
+    if (coeff_prec == 16) {
+        av_log(s->avctx, AV_LOG_ERROR, "invalid coeff precision\n");
         return -1;
     }
-//    av_log(s->avctx, AV_LOG_DEBUG, "   qlp coeff prec: %d\n", coeff_prec);
     qlevel = get_sbits(&s->gb, 5);
-//    av_log(s->avctx, AV_LOG_DEBUG, "   quant level: %d\n", qlevel);
-    if(qlevel < 0){
-        av_log(s->avctx, AV_LOG_DEBUG, "qlevel %d not supported, maybe buggy stream\n", qlevel);
+    if (qlevel < 0) {
+        av_log(s->avctx, AV_LOG_ERROR, "qlevel %d not supported, maybe buggy stream\n",
+               qlevel);
         return -1;
     }
 
-    for (i = 0; i < pred_order; i++)
-    {
+    for (i = 0; i < pred_order; i++) {
         coeffs[i] = get_sbits(&s->gb, coeff_prec);
-//        av_log(s->avctx, AV_LOG_DEBUG, "    %d: %d\n", i, coeffs[i]);
     }
 
     if (decode_residuals(s, channel, pred_order) < 0)
@@ -367,21 +347,18 @@ static int decode_subframe_lpc(FLACContext *s, int channel, int pred_order)
 
     if (s->bps > 16) {
         int64_t sum;
-        for (i = pred_order; i < s->blocksize; i++)
-        {
+        for (i = pred_order; i < s->blocksize; i++) {
             sum = 0;
             for (j = 0; j < pred_order; j++)
                 sum += (int64_t)coeffs[j] * decoded[i-j-1];
             decoded[i] += sum >> qlevel;
         }
     } else {
-        for (i = pred_order; i < s->blocksize-1; i += 2)
-        {
+        for (i = pred_order; i < s->blocksize-1; i += 2) {
             int c;
             int d = decoded[i-pred_order];
             int s0 = 0, s1 = 0;
-            for (j = pred_order-1; j > 0; j--)
-            {
+            for (j = pred_order-1; j > 0; j--) {
                 c = coeffs[j];
                 s0 += c*d;
                 d = decoded[i-j];
@@ -393,8 +370,7 @@ static int decode_subframe_lpc(FLACContext *s, int channel, int pred_order)
             s1 += c*d;
             decoded[i+1] += s1 >> qlevel;
         }
-        if (i < s->blocksize)
-        {
+        if (i < s->blocksize) {
             int sum = 0;
             for (j = 0; j < pred_order; j++)
                 sum += coeffs[j] * decoded[i-j-1];
@@ -411,78 +387,47 @@ static inline int decode_subframe(FLACContext *s, int channel)
     int i, tmp;
 
     s->curr_bps = s->bps;
-    if(channel == 0){
-        if(s->decorrelation == RIGHT_SIDE)
+    if (channel == 0) {
+        if (s->decorrelation == RIGHT_SIDE)
             s->curr_bps++;
-    }else{
-        if(s->decorrelation == LEFT_SIDE || s->decorrelation == MID_SIDE)
+    } else {
+        if (s->decorrelation == LEFT_SIDE || s->decorrelation == MID_SIDE)
             s->curr_bps++;
     }
 
-    if (get_bits1(&s->gb))
-    {
+    if (get_bits1(&s->gb)) {
         av_log(s->avctx, AV_LOG_ERROR, "invalid subframe padding\n");
         return -1;
     }
     type = get_bits(&s->gb, 6);
-//    wasted = get_bits1(&s->gb);
-
-//    if (wasted)
-//    {
-//        while (!get_bits1(&s->gb))
-//            wasted++;
-//        if (wasted)
-//            wasted++;
-//        s->curr_bps -= wasted;
-//    }
-#if 0
-    wasted= 16 - av_log2(show_bits(&s->gb, 17));
-    skip_bits(&s->gb, wasted+1);
-    s->curr_bps -= wasted;
-#else
-    if (get_bits1(&s->gb))
-    {
+
+    if (get_bits1(&s->gb)) {
         wasted = 1;
         while (!get_bits1(&s->gb))
             wasted++;
         s->curr_bps -= wasted;
-        av_log(s->avctx, AV_LOG_DEBUG, "%d wasted bits\n", wasted);
     }
-#endif
+
 //FIXME use av_log2 for types
-    if (type == 0)
-    {
-        av_log(s->avctx, AV_LOG_DEBUG, "coding type: constant\n");
+    if (type == 0) {
         tmp = get_sbits(&s->gb, s->curr_bps);
         for (i = 0; i < s->blocksize; i++)
             s->decoded[channel][i] = tmp;
-    }
-    else if (type == 1)
-    {
-        av_log(s->avctx, AV_LOG_DEBUG, "coding type: verbatim\n");
+    } else if (type == 1) {
         for (i = 0; i < s->blocksize; i++)
             s->decoded[channel][i] = get_sbits(&s->gb, s->curr_bps);
-    }
-    else if ((type >= 8) && (type <= 12))
-    {
-//        av_log(s->avctx, AV_LOG_DEBUG, "coding type: fixed\n");
+    } else if ((type >= 8) && (type <= 12)) {
         if (decode_subframe_fixed(s, channel, type & ~0x8) < 0)
             return -1;
-    }
-    else if (type >= 32)
-    {
-//        av_log(s->avctx, AV_LOG_DEBUG, "coding type: lpc\n");
+    } else if (type >= 32) {
         if (decode_subframe_lpc(s, channel, (type & ~0x20)+1) < 0)
             return -1;
-    }
-    else
-    {
+    } else {
         av_log(s->avctx, AV_LOG_ERROR, "invalid coding type\n");
         return -1;
     }
 
-    if (wasted)
-    {
+    if (wasted) {
         int i;
         for (i = 0; i < s->blocksize; i++)
             s->decoded[channel][i] <<= wasted;
@@ -505,39 +450,32 @@ static int decode_frame(FLACContext *s, int alloc_data_size)
         decorrelation = INDEPENDENT;
     else if (assignment >=8 && assignment < 11 && s->channels == 2)
         decorrelation = LEFT_SIDE + assignment - 8;
-    else
-    {
-        av_log(s->avctx, AV_LOG_ERROR, "unsupported channel assignment %d (channels=%d)\n", assignment, s->channels);
+    else {
+        av_log(s->avctx, AV_LOG_ERROR, "unsupported channel assignment %d (channels=%d)\n",
+               assignment, s->channels);
         return -1;
     }
 
     sample_size_code = get_bits(&s->gb, 3);
-    if(sample_size_code == 0)
+    if (sample_size_code == 0)
         bps= s->bps;
-    else if((sample_size_code != 3) && (sample_size_code != 7))
+    else if ((sample_size_code != 3) && (sample_size_code != 7))
         bps = sample_size_table[sample_size_code];
-    else
-    {
-        av_log(s->avctx, AV_LOG_ERROR, "invalid sample size code (%d)\n", sample_size_code);
+    else {
+        av_log(s->avctx, AV_LOG_ERROR, "invalid sample size code (%d)\n",
+               sample_size_code);
         return -1;
     }
 
-    if (get_bits1(&s->gb))
-    {
+    if (get_bits1(&s->gb)) {
         av_log(s->avctx, AV_LOG_ERROR, "broken stream, invalid padding\n");
         return -1;
     }
 
-    if(get_utf8(&s->gb) < 0){
+    if (get_utf8(&s->gb) < 0) {
         av_log(s->avctx, AV_LOG_ERROR, "utf8 fscked\n");
         return -1;
     }
-#if 0
-    if (/*((blocksize_code == 6) || (blocksize_code == 7)) &&*/
-        (s->min_blocksize != s->max_blocksize)){
-    }else{
-    }
-#endif
 
     if (blocksize_code == 0)
         blocksize = s->min_blocksize;
@@ -548,17 +486,18 @@ static int decode_frame(FLACContext *s, int alloc_data_size)
     else
         blocksize = blocksize_table[blocksize_code];
 
-    if(blocksize > s->max_blocksize){
-        av_log(s->avctx, AV_LOG_ERROR, "blocksize %d > %d\n", blocksize, s->max_blocksize);
+    if (blocksize > s->max_blocksize) {
+        av_log(s->avctx, AV_LOG_ERROR, "blocksize %d > %d\n", blocksize,
+               s->max_blocksize);
         return -1;
     }
 
-    if(blocksize * s->channels * sizeof(int16_t) > alloc_data_size)
+    if (blocksize * s->channels * sizeof(int16_t) > alloc_data_size)
         return -1;
 
-    if (sample_rate_code == 0){
+    if (sample_rate_code == 0)
         samplerate= s->samplerate;
-    }else if ((sample_rate_code > 3) && (sample_rate_code < 12))
+    else if (sample_rate_code < 12)
         samplerate = sample_rate_table[sample_rate_code];
     else if (sample_rate_code == 12)
         samplerate = get_bits(&s->gb, 8) * 1000;
@@ -566,15 +505,16 @@ static int decode_frame(FLACContext *s, int alloc_data_size)
         samplerate = get_bits(&s->gb, 16);
     else if (sample_rate_code == 14)
         samplerate = get_bits(&s->gb, 16) * 10;
-    else{
-        av_log(s->avctx, AV_LOG_ERROR, "illegal sample rate code %d\n", sample_rate_code);
+    else {
+        av_log(s->avctx, AV_LOG_ERROR, "illegal sample rate code %d\n",
+               sample_rate_code);
         return -1;
     }
 
     skip_bits(&s->gb, 8);
     crc8 = av_crc(av_crc_get_table(AV_CRC_8_ATM), 0,
                   s->gb.buffer, get_bits_count(&s->gb)/8);
-    if(crc8){
+    if (crc8) {
         av_log(s->avctx, AV_LOG_ERROR, "header crc mismatch crc=%2X\n", crc8);
         return -1;
     }
@@ -587,9 +527,7 @@ static int decode_frame(FLACContext *s, int alloc_data_size)
 //    dump_headers(s->avctx, (FLACStreaminfo *)s);
 
     /* subframes */
-    for (i = 0; i < s->channels; i++)
-    {
-//        av_log(s->avctx, AV_LOG_DEBUG, "decoded: %x residual: %x\n", s->decoded[i], s->residual[i]);
+    for (i = 0; i < s->channels; i++) {
         if (decode_subframe(s, i) < 0)
             return -1;
     }
@@ -613,105 +551,61 @@ static int flac_decode_frame(AVCodecContext *avctx,
 
     *data_size=0;
 
-    if(s->max_framesize == 0){
+    if (s->max_framesize == 0) {
         s->max_framesize= FFMAX(4, buf_size); // should hopefully be enough for the first header
         s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->max_framesize);
     }
 
-    if(1 && s->max_framesize){//FIXME truncated
-            if(s->bitstream_size < 4 || AV_RL32(s->bitstream) != MKTAG('f','L','a','C'))
-                buf_size= FFMIN(buf_size, s->max_framesize - FFMIN(s->bitstream_size, s->max_framesize));
-            input_buf_size= buf_size;
+    if (1 && s->max_framesize) { //FIXME truncated
+        if (s->bitstream_size < 4 || AV_RL32(s->bitstream) != MKTAG('f','L','a','C'))
+            buf_size= FFMIN(buf_size, s->max_framesize - FFMIN(s->bitstream_size, s->max_framesize));
+        input_buf_size= buf_size;
 
-            if(s->bitstream_size + buf_size < buf_size || s->bitstream_index + s->bitstream_size + buf_size < s->bitstream_index)
-                return -1;
+        if (s->bitstream_size + buf_size < buf_size || s->bitstream_index + s->bitstream_size + buf_size < s->bitstream_index)
+            return -1;
 
-            if(s->allocated_bitstream_size < s->bitstream_size + buf_size)
-                s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->bitstream_size + buf_size);
+        if (s->allocated_bitstream_size < s->bitstream_size + buf_size)
+            s->bitstream= av_fast_realloc(s->bitstream, &s->allocated_bitstream_size, s->bitstream_size + buf_size);
 
-            if(s->bitstream_index + s->bitstream_size + buf_size > s->allocated_bitstream_size){
-//                printf("memmove\n");
-                memmove(s->bitstream, &s->bitstream[s->bitstream_index], s->bitstream_size);
-                s->bitstream_index=0;
-            }
-            memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size], buf, buf_size);
-            buf= &s->bitstream[s->bitstream_index];
-            buf_size += s->bitstream_size;
-            s->bitstream_size= buf_size;
-
-            if(buf_size < s->max_framesize && input_buf_size){
-//                printf("wanna more data ...\n");
-                return input_buf_size;
-            }
+        if (s->bitstream_index + s->bitstream_size + buf_size > s->allocated_bitstream_size) {
+            memmove(s->bitstream, &s->bitstream[s->bitstream_index],
+                    s->bitstream_size);
+            s->bitstream_index=0;
+        }
+        memcpy(&s->bitstream[s->bitstream_index + s->bitstream_size],
+               buf, buf_size);
+        buf= &s->bitstream[s->bitstream_index];
+        buf_size += s->bitstream_size;
+        s->bitstream_size= buf_size;
+
+        if (buf_size < s->max_framesize && input_buf_size) {
+            return input_buf_size;
+        }
     }
 
     init_get_bits(&s->gb, buf, buf_size*8);
 
-    if(metadata_parse(s))
+    if (metadata_parse(s))
         goto end;
 
-        tmp = show_bits(&s->gb, 16);
-        if((tmp & 0xFFFE) != 0xFFF8){
-            av_log(s->avctx, AV_LOG_ERROR, "FRAME HEADER not here\n");
-            while(get_bits_count(&s->gb)/8+2 < buf_size && (show_bits(&s->gb, 16) & 0xFFFE) != 0xFFF8)
-                skip_bits(&s->gb, 8);
-            goto end; // we may not have enough bits left to decode a frame, so try next time
-        }
-        skip_bits(&s->gb, 16);
-        if (decode_frame(s, alloc_data_size) < 0){
-            av_log(s->avctx, AV_LOG_ERROR, "decode_frame() failed\n");
-            s->bitstream_size=0;
-            s->bitstream_index=0;
-            return -1;
-        }
-
-
-#if 0
-    /* fix the channel order here */
-    if (s->order == MID_SIDE)
-    {
-        short *left = samples;
-        short *right = samples + s->blocksize;
-        for (i = 0; i < s->blocksize; i += 2)
-        {
-            uint32_t x = s->decoded[0][i];
-            uint32_t y = s->decoded[0][i+1];
-
-            right[i] = x - (y / 2);
-            left[i] = right[i] + y;
-        }
-        *data_size = 2 * s->blocksize;
-    }
-    else
-    {
-    for (i = 0; i < s->channels; i++)
-    {
-        switch(s->order)
-        {
-            case INDEPENDENT:
-                for (j = 0; j < s->blocksize; j++)
-                    samples[(s->blocksize*i)+j] = s->decoded[i][j];
-                break;
-            case LEFT_SIDE:
-            case RIGHT_SIDE:
-                if (i == 0)
-                    for (j = 0; j < s->blocksize; j++)
-                        samples[(s->blocksize*i)+j] = s->decoded[0][j];
-                else
-                    for (j = 0; j < s->blocksize; j++)
-                        samples[(s->blocksize*i)+j] = s->decoded[0][j] - s->decoded[i][j];
-                break;
-//            case MID_SIDE:
-//                av_log(s->avctx, AV_LOG_DEBUG, "mid-side unsupported\n");
-        }
-        *data_size += s->blocksize;
+    tmp = show_bits(&s->gb, 16);
+    if ((tmp & 0xFFFE) != 0xFFF8) {
+        av_log(s->avctx, AV_LOG_ERROR, "FRAME HEADER not here\n");
+        while (get_bits_count(&s->gb)/8+2 < buf_size && (show_bits(&s->gb, 16) & 0xFFFE) != 0xFFF8)
+            skip_bits(&s->gb, 8);
+        goto end; // we may not have enough bits left to decode a frame, so try next time
     }
+    skip_bits(&s->gb, 16);
+    if (decode_frame(s, alloc_data_size) < 0) {
+        av_log(s->avctx, AV_LOG_ERROR, "decode_frame() failed\n");
+        s->bitstream_size=0;
+        s->bitstream_index=0;
+        return -1;
     }
-#else
+
 #define DECORRELATE(left, right)\
             assert(s->channels == 2);\
-            for (i = 0; i < s->blocksize; i++)\
-            {\
+            for (i = 0; i < s->blocksize; i++) {\
                 int a= s->decoded[0][i];\
                 int b= s->decoded[1][i];\
                 *samples++ = ((left)  << (24 - s->bps)) >> 8;\
@@ -719,42 +613,37 @@ static int flac_decode_frame(AVCodecContext *avctx,
             }\
             break;
 
-    switch(s->decorrelation)
-    {
-        case INDEPENDENT:
-            for (j = 0; j < s->blocksize; j++)
-            {
-                for (i = 0; i < s->channels; i++)
-                    *samples++ = (s->decoded[i][j] << (24 - s->bps)) >> 8;
-            }
-            break;
-        case LEFT_SIDE:
-            DECORRELATE(a,a-b)
-        case RIGHT_SIDE:
-            DECORRELATE(a+b,b)
-        case MID_SIDE:
-            DECORRELATE( (a-=b>>1) + b, a)
+    switch (s->decorrelation) {
+    case INDEPENDENT:
+        for (j = 0; j < s->blocksize; j++) {
+            for (i = 0; i < s->channels; i++)
+                *samples++ = (s->decoded[i][j] << (24 - s->bps)) >> 8;
+        }
+        break;
+    case LEFT_SIDE:
+        DECORRELATE(a,a-b)
+    case RIGHT_SIDE:
+        DECORRELATE(a+b,b)
+    case MID_SIDE:
+        DECORRELATE( (a-=b>>1) + b, a)
     }
-#endif
 
     *data_size = (int8_t *)samples - (int8_t *)data;
-//    av_log(s->avctx, AV_LOG_DEBUG, "data size: %d\n", *data_size);
 
-//    s->last_blocksize = s->blocksize;
 end:
     i= (get_bits_count(&s->gb)+7)/8;
-    if(i > buf_size){
+    if (i > buf_size) {
         av_log(s->avctx, AV_LOG_ERROR, "overread: %d\n", i - buf_size);
         s->bitstream_size=0;
         s->bitstream_index=0;
         return -1;
     }
 
-    if(s->bitstream_size){
+    if (s->bitstream_size) {
         s->bitstream_index += i;
         s->bitstream_size  -= i;
         return input_buf_size;
-    }else
+    } else
         return i;
 }
 
@@ -763,8 +652,7 @@ static av_cold int flac_decode_close(AVCodecContext *avctx)
     FLACContext *s = avctx->priv_data;
     int i;
 
-    for (i = 0; i < s->channels; i++)
-    {
+    for (i = 0; i < s->channels; i++) {
         av_freep(&s->decoded[i]);
     }
     av_freep(&s->bitstream);
@@ -772,7 +660,8 @@ static av_cold int flac_decode_close(AVCodecContext *avctx)
     return 0;
 }
 
-static void flac_flush(AVCodecContext *avctx){
+static void flac_flush(AVCodecContext *avctx)
+{
     FLACContext *s = avctx->priv_data;
 
     s->bitstream_size=
diff --git a/libavcodec/g726.c b/libavcodec/g726.c
index 1c52836..fe1cc3d 100644
--- a/libavcodec/g726.c
+++ b/libavcodec/g726.c
@@ -1,6 +1,6 @@
 /*
  * G.726 ADPCM audio codec
- * Copyright (c) 2004 Roman Shaposhnik.
+ * Copyright (c) 2004 Roman Shaposhnik
  *
  * This is a very straightforward rendition of the G.726
  * Section 4 "Computational Details".
diff --git a/libavcodec/gif.c b/libavcodec/gif.c
index 715f0aa..fe038a6 100644
--- a/libavcodec/gif.c
+++ b/libavcodec/gif.c
@@ -1,8 +1,8 @@
 /*
  * GIF encoder.
- * Copyright (c) 2000 Fabrice Bellard.
- * Copyright (c) 2002 Francois Revol.
- * Copyright (c) 2006 Baptiste Coudurier.
+ * Copyright (c) 2000 Fabrice Bellard
+ * Copyright (c) 2002 Francois Revol
+ * Copyright (c) 2006 Baptiste Coudurier
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/gifdec.c b/libavcodec/gifdec.c
index ee805a8..d24550c 100644
--- a/libavcodec/gifdec.c
+++ b/libavcodec/gifdec.c
@@ -1,7 +1,7 @@
 /*
  * GIF decoder
- * Copyright (c) 2003 Fabrice Bellard.
- * Copyright (c) 2006 Baptiste Coudurier.
+ * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2006 Baptiste Coudurier
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/h263.c b/libavcodec/h263.c
index dc3ae07..7733417 100644
--- a/libavcodec/h263.c
+++ b/libavcodec/h263.c
@@ -1,8 +1,8 @@
 /*
  * H263/MPEG4 backend for ffmpeg encoder and decoder
- * Copyright (c) 2000,2001 Fabrice Bellard.
+ * Copyright (c) 2000,2001 Fabrice Bellard
  * H263+ support.
- * Copyright (c) 2001 Juan J. Sierralta P.
+ * Copyright (c) 2001 Juan J. Sierralta P
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  *
  * ac prediction encoding, B-frame support, error resilience, optimizations,
@@ -895,6 +895,8 @@ static inline void mpeg4_encode_blocks(MpegEncContext * s, DCTELEM block[6][64],
     }
 }
 
+static const int dquant_code[5]= {1,0,9,2,3};
+
 void mpeg4_encode_mb(MpegEncContext * s,
                     DCTELEM block[6][64],
                     int motion_x, int motion_y)
@@ -904,7 +906,6 @@ void mpeg4_encode_mb(MpegEncContext * s,
     PutBitContext * const tex_pb = s->data_partitioning && s->pict_type!=FF_B_TYPE ? &s->tex_pb : &s->pb;
     PutBitContext * const dc_pb  = s->data_partitioning && s->pict_type!=FF_I_TYPE ? &s->pb2    : &s->pb;
     const int interleaved_stats= (s->flags&CODEC_FLAG_PASS1) && !s->data_partitioning ? 1 : 0;
-    const int dquant_code[5]= {1,0,9,2,3};
 
     //    printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
     if (!s->mb_intra) {
@@ -1268,7 +1269,6 @@ void h263_encode_mb(MpegEncContext * s,
     int16_t rec_intradc[6];
     int16_t *dc_ptr[6];
     const int interleaved_stats= (s->flags&CODEC_FLAG_PASS1);
-    const int dquant_code[5]= {1,0,9,2,3};
 
     //printf("**mb x=%d y=%d\n", s->mb_x, s->mb_y);
     if (!s->mb_intra) {
diff --git a/libavcodec/h263data.h b/libavcodec/h263data.h
index 089f4fb..9bae094 100644
--- a/libavcodec/h263data.h
+++ b/libavcodec/h263data.h
@@ -1,7 +1,7 @@
 /*
  * copyright (c) 2000,2001 Fabrice Bellard
  * H263+ support
- * copyright (c) 2001 Juan J. Sierralta P.
+ * copyright (c) 2001 Juan J. Sierralta P
  * copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  *
  * This file is part of FFmpeg.
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 2792ba2..03d758d 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -1,6 +1,6 @@
 /*
  * H.263 decoder
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  *
  * This file is part of FFmpeg.
@@ -734,7 +734,7 @@ AVCodec h263_decoder = {
     ff_h263_decode_frame,
     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1 | CODEC_CAP_TRUNCATED | CODEC_CAP_DELAY,
     .flush= ff_mpeg_flush,
-    .long_name= NULL_IF_CONFIG_SMALL("H.263"),
+    .long_name= NULL_IF_CONFIG_SMALL("H.263 / H.263-1996, H.263+ / H.263-1998"),
 };
 
 AVCodec msmpeg4v1_decoder = {
@@ -799,7 +799,7 @@ AVCodec h263i_decoder = {
     ff_h263_decode_end,
     ff_h263_decode_frame,
     CODEC_CAP_DRAW_HORIZ_BAND | CODEC_CAP_DR1,
-    .long_name = NULL_IF_CONFIG_SMALL("H.263i"),
+    .long_name = NULL_IF_CONFIG_SMALL("Intel H.263"),
 };
 
 AVCodec flv_decoder = {
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index 8b023f6..b029a6e 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -3563,14 +3563,14 @@ static void init_scan_tables(H264Context *h){
         }
     }
     if(s->dsp.h264_idct8_add == ff_h264_idct8_add_c){
-        memcpy(h->zigzag_scan8x8,       zigzag_scan8x8,       64*sizeof(uint8_t));
+        memcpy(h->zigzag_scan8x8,       ff_zigzag_direct,     64*sizeof(uint8_t));
         memcpy(h->zigzag_scan8x8_cavlc, zigzag_scan8x8_cavlc, 64*sizeof(uint8_t));
         memcpy(h->field_scan8x8,        field_scan8x8,        64*sizeof(uint8_t));
         memcpy(h->field_scan8x8_cavlc,  field_scan8x8_cavlc,  64*sizeof(uint8_t));
     }else{
         for(i=0; i<64; i++){
 #define T(x) (x>>3) | ((x&7)<<3)
-            h->zigzag_scan8x8[i]       = T(zigzag_scan8x8[i]);
+            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]);
@@ -3579,7 +3579,7 @@ static void init_scan_tables(H264Context *h){
     }
     if(h->sps.transform_bypass){ //FIXME same ugly
         h->zigzag_scan_q0          = zigzag_scan;
-        h->zigzag_scan8x8_q0       = zigzag_scan8x8;
+        h->zigzag_scan8x8_q0       = ff_zigzag_direct;
         h->zigzag_scan8x8_cavlc_q0 = zigzag_scan8x8_cavlc;
         h->field_scan_q0           = field_scan;
         h->field_scan8x8_q0        = field_scan8x8;
@@ -6981,7 +6981,7 @@ static void decode_scaling_list(H264Context *h, uint8_t *factors, int size,
                                 const uint8_t *jvt_list, const uint8_t *fallback_list){
     MpegEncContext * const s = &h->s;
     int i, last = 8, next = 8;
-    const uint8_t *scan = size == 16 ? zigzag_scan : zigzag_scan8x8;
+    const uint8_t *scan = size == 16 ? zigzag_scan : ff_zigzag_direct;
     if(!get_bits1(&s->gb)) /* matrix not written, we use the predicted one */
         memcpy(factors, fallback_list, size*sizeof(uint8_t));
     else
diff --git a/libavcodec/h264data.h b/libavcodec/h264data.h
index 20ea3bb..d28d4d4 100644
--- a/libavcodec/h264data.h
+++ b/libavcodec/h264data.h
@@ -286,25 +286,6 @@ static const uint8_t chroma_dc_scan[4]={
  (0+1*2)*16, (1+1*2)*16,  //FIXME
 };
 
-static const uint8_t zigzag_scan8x8[64]={
- 0+0*8, 1+0*8, 0+1*8, 0+2*8,
- 1+1*8, 2+0*8, 3+0*8, 2+1*8,
- 1+2*8, 0+3*8, 0+4*8, 1+3*8,
- 2+2*8, 3+1*8, 4+0*8, 5+0*8,
- 4+1*8, 3+2*8, 2+3*8, 1+4*8,
- 0+5*8, 0+6*8, 1+5*8, 2+4*8,
- 3+3*8, 4+2*8, 5+1*8, 6+0*8,
- 7+0*8, 6+1*8, 5+2*8, 4+3*8,
- 3+4*8, 2+5*8, 1+6*8, 0+7*8,
- 1+7*8, 2+6*8, 3+5*8, 4+4*8,
- 5+3*8, 6+2*8, 7+1*8, 7+2*8,
- 6+3*8, 5+4*8, 4+5*8, 3+6*8,
- 2+7*8, 3+7*8, 4+6*8, 5+5*8,
- 6+4*8, 7+3*8, 7+4*8, 6+5*8,
- 5+6*8, 4+7*8, 5+7*8, 6+6*8,
- 7+5*8, 7+6*8, 6+7*8, 7+7*8,
-};
-
 // zigzag_scan8x8_cavlc[i] = zigzag_scan8x8[(i/4) + 16*(i%4)]
 static const uint8_t zigzag_scan8x8_cavlc[64]={
  0+0*8, 1+1*8, 1+2*8, 2+2*8,
diff --git a/libavcodec/h264idct.c b/libavcodec/h264idct.c
index 57d1b75..8aae501 100644
--- a/libavcodec/h264idct.c
+++ b/libavcodec/h264idct.c
@@ -20,7 +20,7 @@
  */
 
 /**
- * @file h264-idct.c
+ * @file h264idct.c
  * H.264 IDCT.
  * @author Michael Niedermayer <michaelni at gmx.at>
  */
diff --git a/libavcodec/imgconvert.c b/libavcodec/imgconvert.c
index ac76b78..17c8473 100644
--- a/libavcodec/imgconvert.c
+++ b/libavcodec/imgconvert.c
@@ -1,6 +1,6 @@
 /*
  * Misc image conversion routines
- * Copyright (c) 2001, 2002, 2003 Fabrice Bellard.
+ * Copyright (c) 2001, 2002, 2003 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
@@ -276,6 +276,12 @@ static const PixFmtInfo pix_fmt_info[PIX_FMT_NB] = {
     [PIX_FMT_VDPAU_H264] = {
         .name = "vdpau_h264",
     },
+    [PIX_FMT_VDPAU_WMV3] = {
+        .name = "vdpau_wmv3",
+    },
+    [PIX_FMT_VDPAU_VC1] = {
+        .name = "vdpau_vc1",
+    },
     [PIX_FMT_UYYVYY411] = {
         .name = "uyyvyy411",
         .nb_channels = 1,
diff --git a/libavcodec/imgconvert_template.c b/libavcodec/imgconvert_template.c
index 7b4dbf9..d33bc7e 100644
--- a/libavcodec/imgconvert_template.c
+++ b/libavcodec/imgconvert_template.c
@@ -1,6 +1,6 @@
 /*
  * templates for image conversion routines
- * Copyright (c) 2001, 2002, 2003 Fabrice Bellard.
+ * Copyright (c) 2001, 2002, 2003 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/imgresample.c b/libavcodec/imgresample.c
index 6e89725..f3bb49d 100644
--- a/libavcodec/imgresample.c
+++ b/libavcodec/imgresample.c
@@ -1,6 +1,6 @@
 /*
  * High quality image resampling with polyphase filters
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/imx_dump_header_bsf.c b/libavcodec/imx_dump_header_bsf.c
index 5a84440..d850ec1 100644
--- a/libavcodec/imx_dump_header_bsf.c
+++ b/libavcodec/imx_dump_header_bsf.c
@@ -1,6 +1,6 @@
 /*
  * imx dump header bitstream filter
- * Copyright (c) 2007 Baptiste Coudurier.
+ * Copyright (c) 2007 Baptiste Coudurier
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/indeo3.c b/libavcodec/indeo3.c
index eea27f9..6173c6f 100644
--- a/libavcodec/indeo3.c
+++ b/libavcodec/indeo3.c
@@ -252,6 +252,10 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
 
         if(cmd == 0) {
             strip++;
+            if(strip >= strip_tbl + FF_ARRAY_ELEMS(strip_tbl)) {
+                av_log(s->avctx, AV_LOG_WARNING, "out of range strip\n");
+                break;
+            }
             memcpy(strip, strip-1, sizeof(*strip));
             strip->split_flag = 1;
             strip->split_direction = 0;
@@ -259,6 +263,10 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
             continue;
         } else if(cmd == 1) {
             strip++;
+            if(strip >= strip_tbl + FF_ARRAY_ELEMS(strip_tbl)) {
+                av_log(s->avctx, AV_LOG_WARNING, "out of range strip\n");
+                break;
+            }
             memcpy(strip, strip-1, sizeof(*strip));
             strip->split_flag = 1;
             strip->split_direction = 1;
@@ -929,9 +937,6 @@ static void iv_Decode_Chunk(Indeo3DecodeContext *s,
             }
         }
 
-        if(strip < strip_tbl)
-            return;
-
         for( ; strip >= strip_tbl; strip--) {
             if(strip->split_flag != 0) {
                 strip->split_flag = 0;
diff --git a/libavcodec/lcldec.c b/libavcodec/lcldec.c
index 2f16b73..f8630fa 100644
--- a/libavcodec/lcldec.c
+++ b/libavcodec/lcldec.c
@@ -20,7 +20,7 @@
  */
 
 /**
- * @file lcl.c
+ * @file lcldec.c
  * LCL (LossLess Codec Library) Video Codec
  * Decoder for MSZH and ZLIB codecs
  * Experimental encoder for ZLIB RGB24
diff --git a/libavcodec/lclenc.c b/libavcodec/lclenc.c
index 680a511..517c26c 100644
--- a/libavcodec/lclenc.c
+++ b/libavcodec/lclenc.c
@@ -20,7 +20,7 @@
  */
 
 /**
- * @file lcl.c
+ * @file lclenc.c
  * LCL (LossLess Codec Library) Video Codec
  * Decoder for MSZH and ZLIB codecs
  * Experimental encoder for ZLIB RGB24
diff --git a/libavcodec/libfaad.c b/libavcodec/libfaad.c
index 7cf39e2..0eea71b 100644
--- a/libavcodec/libfaad.c
+++ b/libavcodec/libfaad.c
@@ -1,7 +1,7 @@
 /*
  * Faad decoder
- * Copyright (c) 2003 Zdenek Kabelac.
- * Copyright (c) 2004 Thomas Raivio.
+ * Copyright (c) 2003 Zdenek Kabelac
+ * Copyright (c) 2004 Thomas Raivio
  *
  * This file is part of FFmpeg.
  *
@@ -21,7 +21,7 @@
  */
 
 /**
- * @file faad.c
+ * @file libfaad.c
  * AAC decoder.
  *
  * still a bit unfinished - but it plays something
diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c
index c91f653..295f555 100644
--- a/libavcodec/libmp3lame.c
+++ b/libavcodec/libmp3lame.c
@@ -20,7 +20,7 @@
  */
 
 /**
- * @file mp3lameaudio.c
+ * @file libmp3lame.c
  * Interface to libmp3lame for mp3 encoding.
  */
 
diff --git a/libavcodec/libtheoraenc.c b/libavcodec/libtheoraenc.c
index abfa462..e19cc4c 100644
--- a/libavcodec/libtheoraenc.c
+++ b/libavcodec/libtheoraenc.c
@@ -19,7 +19,7 @@
  */
 
 /*!
- * \file theoraenc.c
+ * \file libtheoraenc.c
  * \brief Theora encoder using libtheora.
  * \author Paul Richards <paul.richards at gmail.com>
  *
diff --git a/libavcodec/libvorbis.c b/libavcodec/libvorbis.c
index 03c9f88..57c0f5b 100644
--- a/libavcodec/libvorbis.c
+++ b/libavcodec/libvorbis.c
@@ -19,7 +19,7 @@
  */
 
 /**
- * @file oggvorbis.c
+ * @file libvorbis.c
  * Ogg Vorbis codec support via libvorbisenc.
  * @author Mark Hills <mark at pogo.org.uk>
  */
diff --git a/libavcodec/libxvidff.c b/libavcodec/libxvidff.c
index 1251fdd..3041511 100644
--- a/libavcodec/libxvidff.c
+++ b/libavcodec/libxvidff.c
@@ -20,7 +20,7 @@
  */
 
 /**
- * @file xvidmpeg4.c
+ * @file libxvidff.c
  * Interface to xvidcore for MPEG-4 compliant encoding.
  * @author Adam Thayer (krevnik at comcast.net)
  */
diff --git a/libavcodec/ljpegenc.c b/libavcodec/ljpegenc.c
index bb33aba..b975345 100644
--- a/libavcodec/ljpegenc.c
+++ b/libavcodec/ljpegenc.c
@@ -1,6 +1,6 @@
 /*
  * lossless JPEG encoder
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  * Copyright (c) 2003 Alex Beregszaszi
  * Copyright (c) 2003-2004 Michael Niedermayer
  *
diff --git a/libavcodec/lzw.c b/libavcodec/lzw.c
index 7bdc89a..23034aa 100644
--- a/libavcodec/lzw.c
+++ b/libavcodec/lzw.c
@@ -1,7 +1,7 @@
 /*
  * LZW decoder
- * Copyright (c) 2003 Fabrice Bellard.
- * Copyright (c) 2006 Konstantin Shishkov.
+ * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2006 Konstantin Shishkov
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/lzw.h b/libavcodec/lzw.h
index e8ff46c..3d40e15 100644
--- a/libavcodec/lzw.h
+++ b/libavcodec/lzw.h
@@ -1,7 +1,7 @@
 /*
  * LZW decoder
- * Copyright (c) 2003 Fabrice Bellard.
- * Copyright (c) 2006 Konstantin Shishkov.
+ * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2006 Konstantin Shishkov
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/mathops.h b/libavcodec/mathops.h
index 33e8cd6..1365903 100644
--- a/libavcodec/mathops.h
+++ b/libavcodec/mathops.h
@@ -1,6 +1,6 @@
 /*
  * simple math operations
- * Copyright (c) 2001, 2002 Fabrice Bellard.
+ * Copyright (c) 2001, 2002 Fabrice Bellard
  * Copyright (c) 2006 Michael Niedermayer <michaelni at gmx.at> et al
  *
  * This file is part of FFmpeg.
diff --git a/libavcodec/mdct.c b/libavcodec/mdct.c
index 661f09c..97895d0 100644
--- a/libavcodec/mdct.c
+++ b/libavcodec/mdct.c
@@ -1,6 +1,6 @@
 /*
  * MDCT/IMDCT transforms
- * Copyright (c) 2002 Fabrice Bellard.
+ * Copyright (c) 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/mjpeg.c b/libavcodec/mjpeg.c
index 11a84ba..ad597c0 100644
--- a/libavcodec/mjpeg.c
+++ b/libavcodec/mjpeg.c
@@ -1,6 +1,6 @@
 /*
  * MJPEG encoder and decoder
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  * Copyright (c) 2003 Alex Beregszaszi
  * Copyright (c) 2003-2004 Michael Niedermayer
  *
diff --git a/libavcodec/mjpeg.h b/libavcodec/mjpeg.h
index f8741cc..cc19274 100644
--- a/libavcodec/mjpeg.h
+++ b/libavcodec/mjpeg.h
@@ -1,6 +1,6 @@
 /*
  * MJPEG encoder and decoder
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  * Copyright (c) 2003 Alex Beregszaszi
  * Copyright (c) 2003-2004 Michael Niedermayer
  *
diff --git a/libavcodec/mjpeg_parser.c b/libavcodec/mjpeg_parser.c
index aad112e..6bbf999 100644
--- a/libavcodec/mjpeg_parser.c
+++ b/libavcodec/mjpeg_parser.c
@@ -1,6 +1,6 @@
 /*
  * MJPEG parser
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  * Copyright (c) 2003 Alex Beregszaszi
  * Copyright (c) 2003-2004 Michael Niedermayer
  *
diff --git a/libavcodec/mjpega_dump_header_bsf.c b/libavcodec/mjpega_dump_header_bsf.c
index c27927a..f3b6ec7 100644
--- a/libavcodec/mjpega_dump_header_bsf.c
+++ b/libavcodec/mjpega_dump_header_bsf.c
@@ -1,6 +1,6 @@
 /*
  * MJPEG A dump header bitstream filter
- * Copyright (c) 2006 Baptiste Coudurier.
+ * Copyright (c) 2006 Baptiste Coudurier
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 08c64a1..eae2b3a 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -1,6 +1,6 @@
 /*
  * MJPEG decoder
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  * Copyright (c) 2003 Alex Beregszaszi
  * Copyright (c) 2003-2004 Michael Niedermayer
  *
diff --git a/libavcodec/mjpegdec.h b/libavcodec/mjpegdec.h
index e90d864..b308c91 100644
--- a/libavcodec/mjpegdec.h
+++ b/libavcodec/mjpegdec.h
@@ -1,6 +1,6 @@
 /*
  * MJPEG decoder
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  * Copyright (c) 2003 Alex Beregszaszi
  * Copyright (c) 2003-2004 Michael Niedermayer
  *
diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 9268af0..0bf350b 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -1,6 +1,6 @@
 /*
  * MJPEG encoder
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  * Copyright (c) 2003 Alex Beregszaszi
  * Copyright (c) 2003-2004 Michael Niedermayer
  *
diff --git a/libavcodec/mjpegenc.h b/libavcodec/mjpegenc.h
index 4c904c3..15cefa9 100644
--- a/libavcodec/mjpegenc.h
+++ b/libavcodec/mjpegenc.h
@@ -1,6 +1,6 @@
 /*
  * MJPEG encoder
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  * Copyright (c) 2003 Alex Beregszaszi
  * Copyright (c) 2003-2004 Michael Niedermayer
  *
diff --git a/libavcodec/mlib/dsputil_mlib.c b/libavcodec/mlib/dsputil_mlib.c
index 9337a5a..6be0ba4 100644
--- a/libavcodec/mlib/dsputil_mlib.c
+++ b/libavcodec/mlib/dsputil_mlib.c
@@ -1,6 +1,6 @@
 /*
  * Sun mediaLib optimized DSP utils
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/motion-test.c b/libavcodec/motion-test.c
index 439c4d0..285bac1 100644
--- a/libavcodec/motion-test.c
+++ b/libavcodec/motion-test.c
@@ -19,7 +19,7 @@
  */
 
 /**
- * @file motion_test.c
+ * @file motion-test.c
  * motion test.
  */
 
diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c
index b960e88..2ea01c7 100644
--- a/libavcodec/motion_est.c
+++ b/libavcodec/motion_est.c
@@ -1,6 +1,6 @@
 /*
  * Motion estimation
- * Copyright (c) 2000,2001 Fabrice Bellard.
+ * Copyright (c) 2000,2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer
  *
  * new motion estimation (X1/EPZS) by Michael Niedermayer <michaelni at gmx.at>
diff --git a/libavcodec/mpc7.c b/libavcodec/mpc7.c
index a22baac..01b8a70 100644
--- a/libavcodec/mpc7.c
+++ b/libavcodec/mpc7.c
@@ -53,7 +53,7 @@ static av_cold int mpc7_decode_init(AVCodecContext * avctx)
         return -1;
     }
     memset(c->oldDSCF, 0, sizeof(c->oldDSCF));
-    av_init_random(0xDEADBEEF, &c->rnd);
+    av_random_init(&c->rnd, 0xDEADBEEF);
     dsputil_init(&c->dsp, avctx);
     c->dsp.bswap_buf((uint32_t*)buf, (const uint32_t*)avctx->extradata, 4);
     ff_mpc_init();
diff --git a/libavcodec/mpc8.c b/libavcodec/mpc8.c
index 29f2e5f..cafefe6 100644
--- a/libavcodec/mpc8.c
+++ b/libavcodec/mpc8.c
@@ -100,7 +100,7 @@ static av_cold int mpc8_decode_init(AVCodecContext * avctx)
         return -1;
     }
     memset(c->oldDSCF, 0, sizeof(c->oldDSCF));
-    av_init_random(0xDEADBEEF, &c->rnd);
+    av_random_init(&c->rnd, 0xDEADBEEF);
     dsputil_init(&c->dsp, avctx);
 
     ff_mpc_init();
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 92eef72..8bac5a1 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -1,6 +1,6 @@
 /*
  * MPEG-1/2 decoder
- * Copyright (c) 2000,2001 Fabrice Bellard.
+ * Copyright (c) 2000,2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  *
  * This file is part of FFmpeg.
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 6ef7e1b..c805258 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -1,6 +1,6 @@
 /*
  * MPEG1/2 encoder
- * Copyright (c) 2000,2001 Fabrice Bellard.
+ * Copyright (c) 2000,2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  *
  * This file is part of FFmpeg.
diff --git a/libavcodec/mpeg4video_parser.c b/libavcodec/mpeg4video_parser.c
index 9accc91..54c04d2 100644
--- a/libavcodec/mpeg4video_parser.c
+++ b/libavcodec/mpeg4video_parser.c
@@ -1,7 +1,7 @@
 /*
  * MPEG4 Video frame extraction
- * Copyright (c) 2003 Fabrice Bellard.
- * Copyright (c) 2003 Michael Niedermayer.
+ * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2003 Michael Niedermayer
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/mpeg4video_parser.h b/libavcodec/mpeg4video_parser.h
index aaa6299..822a24c 100644
--- a/libavcodec/mpeg4video_parser.h
+++ b/libavcodec/mpeg4video_parser.h
@@ -1,7 +1,7 @@
 /*
  * MPEG4 video parser prototypes
- * Copyright (c) 2003 Fabrice Bellard.
- * Copyright (c) 2003 Michael Niedermayer.
+ * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2003 Michael Niedermayer
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/mpegaudio.c b/libavcodec/mpegaudio.c
index 663427a..b27eddd 100644
--- a/libavcodec/mpegaudio.c
+++ b/libavcodec/mpegaudio.c
@@ -1,6 +1,6 @@
 /*
  * MPEG Audio common code
- * Copyright (c) 2001, 2002 Fabrice Bellard.
+ * Copyright (c) 2001, 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/mpegaudio.h b/libavcodec/mpegaudio.h
index 96bea31..f32e6ab 100644
--- a/libavcodec/mpegaudio.h
+++ b/libavcodec/mpegaudio.h
@@ -90,23 +90,30 @@ typedef int32_t MPA_INT;
 
 struct GranuleDef;
 
+#define MPA_DECODE_HEADER \
+    int frame_size; \
+    int error_protection; \
+    int layer; \
+    int sample_rate; \
+    int sample_rate_index; /* between 0 and 8 */ \
+    int bit_rate; \
+    int nb_channels; \
+    int mode; \
+    int mode_ext; \
+    int lsf;
+
+typedef struct MPADecodeHeader {
+  MPA_DECODE_HEADER
+} MPADecodeHeader;
+
 typedef struct MPADecodeContext {
+    MPA_DECODE_HEADER
     DECLARE_ALIGNED_8(uint8_t, last_buf[2*BACKSTEP_SIZE + EXTRABYTES]);
     int last_buf_size;
-    int frame_size;
     /* next header (used in free format parsing) */
     uint32_t free_format_next_header;
-    int error_protection;
-    int layer;
-    int sample_rate;
-    int sample_rate_index; /* between 0 and 8 */
-    int bit_rate;
     GetBitContext gb;
     GetBitContext in_gb;
-    int nb_channels;
-    int mode;
-    int mode_ext;
-    int lsf;
     DECLARE_ALIGNED_16(MPA_INT, synth_buf[MPA_MAX_CHANNELS][512 * 2]);
     int synth_buf_offset[MPA_MAX_CHANNELS];
     DECLARE_ALIGNED_16(int32_t, sb_samples[MPA_MAX_CHANNELS][36][SBLIMIT]);
diff --git a/libavcodec/mpegaudio_parser.c b/libavcodec/mpegaudio_parser.c
index 55d865f..646da8b 100644
--- a/libavcodec/mpegaudio_parser.c
+++ b/libavcodec/mpegaudio_parser.c
@@ -1,7 +1,7 @@
 /*
  * MPEG Audio parser
- * Copyright (c) 2003 Fabrice Bellard.
- * Copyright (c) 2003 Michael Niedermayer.
+ * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2003 Michael Niedermayer
  *
  * This file is part of FFmpeg.
  *
@@ -46,8 +46,7 @@ typedef struct MpegAudioParseContext {
    header, otherwise the coded frame size in bytes */
 int ff_mpa_decode_header(AVCodecContext *avctx, uint32_t head, int *sample_rate, int *channels, int *frame_size, int *bit_rate)
 {
-    MPADecodeContext s1, *s = &s1;
-    s1.avctx = avctx;
+    MPADecodeHeader s1, *s = &s1;
 
     if (ff_mpa_check_header(head) != 0)
         return -1;
@@ -145,7 +144,7 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
 
 #if 0
                     /* free format: prepare to compute frame size */
-                    if (ff_mpegaudio_decode_header(s, header) == 1) {
+                    if (ff_mpegaudio_decode_header((MPADecodeHeader *)s, header) == 1) {
                         s->frame_size = -1;
                     }
 #endif
@@ -200,7 +199,7 @@ static int mpegaudio_parse(AVCodecParserContext *s1,
                             s->free_format_frame_size -= padding;
                         dprintf(avctx, "free frame size=%d padding=%d\n",
                                 s->free_format_frame_size, padding);
-                        ff_mpegaudio_decode_header(s, header1);
+                        ff_mpegaudio_decode_header((MPADecodeHeader *)s, header1);
                         goto next_data;
                     }
                     p++;
diff --git a/libavcodec/mpegaudiodata.c b/libavcodec/mpegaudiodata.c
index ee8fd9f..60139e5 100644
--- a/libavcodec/mpegaudiodata.c
+++ b/libavcodec/mpegaudiodata.c
@@ -99,36 +99,6 @@ const int ff_mpa_quant_bits[17] = {
 
 /* encoding tables which give the quantization index. Note how it is
    possible to store them efficiently ! */
-static const unsigned char alloc_table_0[] = {
- 4,  0,  2,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
- 4,  0,  2,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
- 4,  0,  2,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16,
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16,
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16,
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16,
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16,
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16,
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16,
- 4,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 16,
- 3,  0,  1,  2,  3,  4,  5, 16,
- 3,  0,  1,  2,  3,  4,  5, 16,
- 3,  0,  1,  2,  3,  4,  5, 16,
- 3,  0,  1,  2,  3,  4,  5, 16,
- 3,  0,  1,  2,  3,  4,  5, 16,
- 3,  0,  1,  2,  3,  4,  5, 16,
- 3,  0,  1,  2,  3,  4,  5, 16,
- 3,  0,  1,  2,  3,  4,  5, 16,
- 3,  0,  1,  2,  3,  4,  5, 16,
- 3,  0,  1,  2,  3,  4,  5, 16,
- 3,  0,  1,  2,  3,  4,  5, 16,
- 3,  0,  1,  2,  3,  4,  5, 16,
- 2,  0,  1, 16,
- 2,  0,  1, 16,
- 2,  0,  1, 16,
- 2,  0,  1, 16,
-};
-
 static const unsigned char alloc_table_1[] = {
  4,  0,  2,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
  4,  0,  2,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15, 16,
@@ -162,17 +132,6 @@ static const unsigned char alloc_table_1[] = {
  2,  0,  1, 16,
 };
 
-static const unsigned char alloc_table_2[] = {
- 4,  0,  1,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
- 4,  0,  1,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
- 3,  0,  1,  3,  4,  5,  6,  7,
- 3,  0,  1,  3,  4,  5,  6,  7,
- 3,  0,  1,  3,  4,  5,  6,  7,
- 3,  0,  1,  3,  4,  5,  6,  7,
- 3,  0,  1,  3,  4,  5,  6,  7,
- 3,  0,  1,  3,  4,  5,  6,  7,
-};
-
 static const unsigned char alloc_table_3[] = {
  4,  0,  1,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
  4,  0,  1,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
@@ -222,4 +181,4 @@ static const unsigned char alloc_table_4[] = {
 };
 
 const unsigned char * const ff_mpa_alloc_tables[5] =
-{ alloc_table_0, alloc_table_1, alloc_table_2, alloc_table_3, alloc_table_4, };
+{ alloc_table_1, alloc_table_1, alloc_table_3, alloc_table_3, alloc_table_4, };
diff --git a/libavcodec/mpegaudiodec.c b/libavcodec/mpegaudiodec.c
index 58e4511..080da05 100644
--- a/libavcodec/mpegaudiodec.c
+++ b/libavcodec/mpegaudiodec.c
@@ -1,6 +1,6 @@
 /*
  * MPEG Audio decoder
- * Copyright (c) 2001, 2002 Fabrice Bellard.
+ * Copyright (c) 2001, 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
@@ -2277,7 +2277,7 @@ retry:
         goto retry;
     }
 
-    if (ff_mpegaudio_decode_header(s, header) == 1) {
+    if (ff_mpegaudio_decode_header((MPADecodeHeader *)s, header) == 1) {
         /* free format: prepare to compute frame size */
         s->frame_size = -1;
         return -1;
@@ -2342,7 +2342,7 @@ static int decode_frame_adu(AVCodecContext * avctx,
         return buf_size;
     }
 
-    ff_mpegaudio_decode_header(s, header);
+    ff_mpegaudio_decode_header((MPADecodeHeader *)s, header);
     /* update codec info */
     avctx->sample_rate = s->sample_rate;
     avctx->channels = s->nb_channels;
@@ -2491,7 +2491,7 @@ static int decode_frame_mp3on4(AVCodecContext * avctx,
         if (ff_mpa_check_header(header) < 0) // Bad header, discard block
             break;
 
-        ff_mpegaudio_decode_header(m, header);
+        ff_mpegaudio_decode_header((MPADecodeHeader *)m, header);
         out_size += mp_decode_frame(m, outptr, buf, fsize);
         buf += fsize;
         len -= fsize;
diff --git a/libavcodec/mpegaudiodecheader.c b/libavcodec/mpegaudiodecheader.c
index efea499..807d624 100644
--- a/libavcodec/mpegaudiodecheader.c
+++ b/libavcodec/mpegaudiodecheader.c
@@ -1,6 +1,6 @@
 /*
  * MPEG Audio header decoder
- * Copyright (c) 2001, 2002 Fabrice Bellard.
+ * Copyright (c) 2001, 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
@@ -30,7 +30,7 @@
 #include "mpegaudiodata.h"
 
 
-int ff_mpegaudio_decode_header(MPADecodeContext *s, uint32_t header)
+int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header)
 {
     int sample_rate, frame_size, mpeg25, padding;
     int sample_rate_index, bitrate_index;
diff --git a/libavcodec/mpegaudiodecheader.h b/libavcodec/mpegaudiodecheader.h
index 6f668e0..b7775f6 100644
--- a/libavcodec/mpegaudiodecheader.h
+++ b/libavcodec/mpegaudiodecheader.h
@@ -1,6 +1,6 @@
 /*
  * MPEG Audio header decoder
- * Copyright (c) 2001, 2002 Fabrice Bellard.
+ * Copyright (c) 2001, 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
@@ -34,6 +34,6 @@
 /* header decoding. MUST check the header before because no
    consistency check is done there. Return 1 if free format found and
    that the frame size must be computed externally */
-int ff_mpegaudio_decode_header(MPADecodeContext *s, uint32_t header);
+int ff_mpegaudio_decode_header(MPADecodeHeader *s, uint32_t header);
 
 #endif /* AVCODEC_MPEGAUDIODECHEADER_H */
diff --git a/libavcodec/mpegaudioenc.c b/libavcodec/mpegaudioenc.c
index 767f823..bacb25e 100644
--- a/libavcodec/mpegaudioenc.c
+++ b/libavcodec/mpegaudioenc.c
@@ -1,6 +1,6 @@
 /*
  * The simplest mpeg audio layer 2 encoder
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/mpegaudiotab.h b/libavcodec/mpegaudiotab.h
index c82c1b9..443dded 100644
--- a/libavcodec/mpegaudiotab.h
+++ b/libavcodec/mpegaudiotab.h
@@ -2,7 +2,7 @@
  * mpeg audio layer 2 tables. Most of them come from the mpeg audio
  * specification.
  *
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 4b76e59..de50b75 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -1,6 +1,6 @@
 /*
  * The simplest mpeg encoder (well, it was the simplest!)
- * Copyright (c) 2000,2001 Fabrice Bellard.
+ * Copyright (c) 2000,2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  *
  * 4MV & hq & B-frame encoding stuff by Michael Niedermayer <michaelni at gmx.at>
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index da08bb6..00a3e26 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -1,6 +1,6 @@
 /*
  * Generic DCT based hybrid video encoder
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
+ * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer
  *
  * This file is part of FFmpeg.
diff --git a/libavcodec/mpegvideo_common.h b/libavcodec/mpegvideo_common.h
index 5651981..701b3c9 100644
--- a/libavcodec/mpegvideo_common.h
+++ b/libavcodec/mpegvideo_common.h
@@ -1,6 +1,6 @@
 /*
  * The simplest mpeg encoder (well, it was the simplest!)
- * Copyright (c) 2000,2001 Fabrice Bellard.
+ * Copyright (c) 2000,2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  *
  * 4MV & hq & B-frame encoding stuff by Michael Niedermayer <michaelni at gmx.at>
@@ -30,6 +30,7 @@
 #ifndef AVCODEC_MPEGVIDEO_COMMON_H
 #define AVCODEC_MPEGVIDEO_COMMON_H
 
+#include <string.h>
 #include "avcodec.h"
 #include "dsputil.h"
 #include "mpegvideo.h"
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index e381598..23b3d93 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -1,6 +1,6 @@
 /*
  * The simplest mpeg encoder (well, it was the simplest!)
- * Copyright (c) 2000,2001 Fabrice Bellard.
+ * Copyright (c) 2000,2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  *
  * 4MV & hq & B-frame encoding stuff by Michael Niedermayer <michaelni at gmx.at>
@@ -3724,7 +3724,7 @@ AVCodec h263_encoder = {
     MPV_encode_picture,
     MPV_encode_end,
     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
-    .long_name= NULL_IF_CONFIG_SMALL("H.263"),
+    .long_name= NULL_IF_CONFIG_SMALL("H.263 / H.263-1996"),
 };
 
 AVCodec h263p_encoder = {
@@ -3736,7 +3736,7 @@ AVCodec h263p_encoder = {
     MPV_encode_picture,
     MPV_encode_end,
     .pix_fmts= (enum PixelFormat[]){PIX_FMT_YUV420P, PIX_FMT_NONE},
-    .long_name= NULL_IF_CONFIG_SMALL("H.263+ / H.263 version 2"),
+    .long_name= NULL_IF_CONFIG_SMALL("H.263+ / H.263-1998 / H.263 version 2"),
 };
 
 AVCodec flv_encoder = {
diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c
index 30f149d..180c6fa 100644
--- a/libavcodec/mpegvideo_parser.c
+++ b/libavcodec/mpegvideo_parser.c
@@ -1,6 +1,6 @@
 /*
  * MPEG1 / MPEG2 video parser
- * Copyright (c) 2000,2001 Fabrice Bellard.
+ * Copyright (c) 2000,2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  *
  * This file is part of FFmpeg.
diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c
index c5aa306..6bb4550 100644
--- a/libavcodec/msmpeg4.c
+++ b/libavcodec/msmpeg4.c
@@ -1,6 +1,6 @@
 /*
  * MSMPEG4 backend for ffmpeg encoder and decoder
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  *
  * msmpeg4v1 & v2 stuff by Michael Niedermayer <michaelni at gmx.at>
diff --git a/libavcodec/nellymoserdec.c b/libavcodec/nellymoserdec.c
index c0a856e..e2a4191 100644
--- a/libavcodec/nellymoserdec.c
+++ b/libavcodec/nellymoserdec.c
@@ -128,7 +128,7 @@ static av_cold int decode_init(AVCodecContext * avctx) {
     NellyMoserDecodeContext *s = avctx->priv_data;
 
     s->avctx = avctx;
-    av_init_random(0, &s->random_state);
+    av_random_init(&s->random_state, 0);
     ff_mdct_init(&s->imdct_ctx, 8, 1);
 
     dsputil_init(&s->dsp, avctx);
diff --git a/libavcodec/options.c b/libavcodec/options.c
index 953dfe6..b753e71 100644
--- a/libavcodec/options.c
+++ b/libavcodec/options.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  *
  * This file is part of FFmpeg.
diff --git a/libavcodec/parser.c b/libavcodec/parser.c
index b7b6b8d..6a801ec 100644
--- a/libavcodec/parser.c
+++ b/libavcodec/parser.c
@@ -1,7 +1,7 @@
 /*
  * Audio and Video frame extraction
- * Copyright (c) 2003 Fabrice Bellard.
- * Copyright (c) 2003 Michael Niedermayer.
+ * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2003 Michael Niedermayer
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/parser.h b/libavcodec/parser.h
index 3b6978f..6274bb2 100644
--- a/libavcodec/parser.h
+++ b/libavcodec/parser.h
@@ -1,7 +1,7 @@
 /*
  * AVCodecParser prototypes and definitions
- * Copyright (c) 2003 Fabrice Bellard.
- * Copyright (c) 2003 Michael Niedermayer.
+ * Copyright (c) 2003 Fabrice Bellard
+ * Copyright (c) 2003 Michael Niedermayer
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c
index 9952809..8ff0059 100644
--- a/libavcodec/pcm.c
+++ b/libavcodec/pcm.c
@@ -1,6 +1,6 @@
 /*
  * PCM codecs
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/png.c b/libavcodec/png.c
index c95ba3e..534dc68 100644
--- a/libavcodec/png.c
+++ b/libavcodec/png.c
@@ -1,6 +1,6 @@
 /*
  * PNG image format
- * Copyright (c) 2003 Fabrice Bellard.
+ * Copyright (c) 2003 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/png.h b/libavcodec/png.h
index 17b1466..97e81f5 100644
--- a/libavcodec/png.h
+++ b/libavcodec/png.h
@@ -1,6 +1,6 @@
 /*
  * PNG image format
- * Copyright (c) 2003 Fabrice Bellard.
+ * Copyright (c) 2003 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 77ac0d1..a343152 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -1,6 +1,6 @@
 /*
  * PNG image format
- * Copyright (c) 2003 Fabrice Bellard.
+ * Copyright (c) 2003 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/pngenc.c b/libavcodec/pngenc.c
index f7a1e86..40dadc8 100644
--- a/libavcodec/pngenc.c
+++ b/libavcodec/pngenc.c
@@ -1,6 +1,6 @@
 /*
  * PNG image format
- * Copyright (c) 2003 Fabrice Bellard.
+ * Copyright (c) 2003 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/pnm.c b/libavcodec/pnm.c
index a3b4919..ba169d1 100644
--- a/libavcodec/pnm.c
+++ b/libavcodec/pnm.c
@@ -1,6 +1,6 @@
 /*
  * PNM image format
- * Copyright (c) 2002, 2003 Fabrice Bellard.
+ * Copyright (c) 2002, 2003 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/pnm.h b/libavcodec/pnm.h
index 8aa4276..ef0cd86 100644
--- a/libavcodec/pnm.h
+++ b/libavcodec/pnm.h
@@ -1,6 +1,6 @@
 /*
  * PNM image format
- * Copyright (c) 2002, 2003 Fabrice Bellard.
+ * Copyright (c) 2002, 2003 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/pnm_parser.c b/libavcodec/pnm_parser.c
index f5212f0..687f0ca 100644
--- a/libavcodec/pnm_parser.c
+++ b/libavcodec/pnm_parser.c
@@ -1,6 +1,6 @@
 /*
  * PNM image parser
- * Copyright (c) 2002, 2003 Fabrice Bellard.
+ * Copyright (c) 2002, 2003 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/pnmenc.c b/libavcodec/pnmenc.c
index 3ff1209..c3316ea 100644
--- a/libavcodec/pnmenc.c
+++ b/libavcodec/pnmenc.c
@@ -1,6 +1,6 @@
 /*
  * PNM image format
- * Copyright (c) 2002, 2003 Fabrice Bellard.
+ * Copyright (c) 2002, 2003 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/ppc/dsputil_ppc.c b/libavcodec/ppc/dsputil_ppc.c
index ce04cf6..e9864af 100644
--- a/libavcodec/ppc/dsputil_ppc.c
+++ b/libavcodec/ppc/dsputil_ppc.c
@@ -24,7 +24,6 @@
 
 #include "dsputil_ppc.h"
 
-#if HAVE_ALTIVEC
 #include "dsputil_altivec.h"
 
 void fdct_altivec(int16_t *block);
@@ -41,8 +40,6 @@ void snow_init_altivec(DSPContext* c, AVCodecContext *avctx);
 void float_init_altivec(DSPContext* c, AVCodecContext *avctx);
 void int_init_altivec(DSPContext* c, AVCodecContext *avctx);
 
-#endif
-
 int mm_flags = 0;
 
 int mm_support(void)
diff --git a/libavcodec/ppc/dsputil_ppc.h b/libavcodec/ppc/dsputil_ppc.h
index d9740ce..3583acf 100644
--- a/libavcodec/ppc/dsputil_ppc.h
+++ b/libavcodec/ppc/dsputil_ppc.h
@@ -21,6 +21,8 @@
 #ifndef AVCODEC_PPC_DSPUTIL_PPC_H
 #define AVCODEC_PPC_DSPUTIL_PPC_H
 
+#include "config.h"
+
 #if CONFIG_POWERPC_PERF
 void powerpc_display_perf_report(void);
 /* the 604* have 2, the G3* have 4, the G4s have 6,
diff --git a/libavcodec/ppc/fft_altivec.c b/libavcodec/ppc/fft_altivec.c
index 19123d0..fb840ae 100644
--- a/libavcodec/ppc/fft_altivec.c
+++ b/libavcodec/ppc/fft_altivec.c
@@ -2,7 +2,7 @@
  * FFT/IFFT transforms
  * AltiVec-enabled
  * Copyright (c) 2003 Romain Dolbeau <romain at dolbeau.org>
- * Based on code Copyright (c) 2002 Fabrice Bellard.
+ * Based on code Copyright (c) 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/ppc/imgresample_altivec.c b/libavcodec/ppc/imgresample_altivec.c
index fdbca5c..efe4ea2 100644
--- a/libavcodec/ppc/imgresample_altivec.c
+++ b/libavcodec/ppc/imgresample_altivec.c
@@ -1,6 +1,6 @@
 /*
  * High quality image resampling with polyphase filters
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/ppc/mathops.h b/libavcodec/ppc/mathops.h
index beba351..adf04cb 100644
--- a/libavcodec/ppc/mathops.h
+++ b/libavcodec/ppc/mathops.h
@@ -1,6 +1,6 @@
 /*
  * simple math operations
- * Copyright (c) 2001, 2002 Fabrice Bellard.
+ * Copyright (c) 2001, 2002 Fabrice Bellard
  * Copyright (c) 2006 Michael Niedermayer <michaelni at gmx.at> et al
  *
  * This file is part of FFmpeg.
@@ -23,7 +23,9 @@
 #ifndef AVCODEC_PPC_MATHOPS_H
 #define AVCODEC_PPC_MATHOPS_H
 
-#if ARCH_PPC_405
+#include "config.h"
+
+#if HAVE_PPC4XX
 /* signed 16x16 -> 32 multiply add accumulate */
 #define MAC16(rt, ra, rb) \
     __asm__ ("maclhw %0, %2, %3" : "=r" (rt) : "0" (rt), "r" (ra), "r" (rb));
diff --git a/libavcodec/ps2/dsputil_mmi.c b/libavcodec/ps2/dsputil_mmi.c
index 513d74d..15b5b56 100644
--- a/libavcodec/ps2/dsputil_mmi.c
+++ b/libavcodec/ps2/dsputil_mmi.c
@@ -1,6 +1,6 @@
 /*
  * MMI optimized DSP utils
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  *
  * MMI optimization by Leon van Stuivenberg
  * clear_blocks_mmi() by BroadQ
diff --git a/libavcodec/ps2/mpegvideo_mmi.c b/libavcodec/ps2/mpegvideo_mmi.c
index f3baf59..68c3b0d 100644
--- a/libavcodec/ps2/mpegvideo_mmi.c
+++ b/libavcodec/ps2/mpegvideo_mmi.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000,2001 Fabrice Bellard.
+ * Copyright (c) 2000,2001 Fabrice Bellard
  *
  * MMI optimization by Leon van Stuivenberg
  *
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index e178993..82eba38 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004 Roman Shaposhnik.
+ * Copyright (c) 2004 Roman Shaposhnik
  *
  * Many thanks to Steven M. Schultz for providing clever ideas and
  * to Michael Niedermayer <michaelni at gmx.at> for writing initial
diff --git a/libavcodec/ratecontrol.h b/libavcodec/ratecontrol.h
index a101775..5baa1cb 100644
--- a/libavcodec/ratecontrol.h
+++ b/libavcodec/ratecontrol.h
@@ -1,6 +1,6 @@
 /*
  * Ratecontrol
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
+ * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer
  *
  * This file is part of FFmpeg.
diff --git a/libavcodec/raw.c b/libavcodec/raw.c
index de10f28..37ca54f 100644
--- a/libavcodec/raw.c
+++ b/libavcodec/raw.c
@@ -1,6 +1,6 @@
 /*
  * Raw Video Codec
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/raw.h b/libavcodec/raw.h
index 2fbf2d6..dff1c09 100644
--- a/libavcodec/raw.h
+++ b/libavcodec/raw.h
@@ -1,6 +1,6 @@
 /*
  * Raw Video Codec
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index 4590b96..cf1565d 100644
--- a/libavcodec/rawdec.c
+++ b/libavcodec/rawdec.c
@@ -1,6 +1,6 @@
 /*
  * Raw Video Decoder
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/rawenc.c b/libavcodec/rawenc.c
index 24f2580..ccee4b3 100644
--- a/libavcodec/rawenc.c
+++ b/libavcodec/rawenc.c
@@ -1,6 +1,6 @@
 /*
  * Raw Video Encoder
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/rectangle.h b/libavcodec/rectangle.h
index 563c988..bc994f8 100644
--- a/libavcodec/rectangle.h
+++ b/libavcodec/rectangle.h
@@ -28,7 +28,10 @@
 #ifndef AVCODEC_RECTANGLE_H
 #define AVCODEC_RECTANGLE_H
 
+#include <assert.h>
+#include "config.h"
 #include "libavutil/common.h"
+#include "dsputil.h"
 
 /**
  * fill a rectangle.
diff --git a/libavcodec/resample.c b/libavcodec/resample.c
index c4a5dbd..9043390 100644
--- a/libavcodec/resample.c
+++ b/libavcodec/resample.c
@@ -1,6 +1,6 @@
 /*
  * samplerate conversion for both audio and video
- * Copyright (c) 2000 Fabrice Bellard.
+ * Copyright (c) 2000 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/roqvideo.h b/libavcodec/roqvideo.h
index 03c03ed..2b69838 100644
--- a/libavcodec/roqvideo.h
+++ b/libavcodec/roqvideo.h
@@ -39,6 +39,8 @@ typedef struct {
     int d[2];
 } motion_vect;
 
+struct RoqTempData;
+
 typedef struct RoqContext {
 
     AVCodecContext *avctx;
@@ -69,6 +71,7 @@ typedef struct RoqContext {
 
     AVFrame *frame_to_enc;
     uint8_t *out_buf;
+    struct RoqTempData *tmpData;
 } RoqContext;
 
 #define RoQ_INFO              0x1001
diff --git a/libavcodec/roqvideoenc.c b/libavcodec/roqvideoenc.c
index a5622cd..828f995 100644
--- a/libavcodec/roqvideoenc.c
+++ b/libavcodec/roqvideoenc.c
@@ -220,7 +220,7 @@ typedef struct
 /**
  * Temporary vars
  */
-typedef struct
+typedef struct RoqTempData
 {
     CelEvaluation *cel_evals;
 
@@ -881,14 +881,14 @@ static void generate_new_codebooks(RoqContext *enc, RoqTempdata *tempData)
 
 static void roq_encode_video(RoqContext *enc)
 {
-    RoqTempdata tempData;
+    RoqTempdata *tempData = enc->tmpData;
     int i;
 
-    memset(&tempData, 0, sizeof(tempData));
+    memset(tempData, 0, sizeof(*tempData));
 
-    create_cel_evals(enc, &tempData);
+    create_cel_evals(enc, tempData);
 
-    generate_new_codebooks(enc, &tempData);
+    generate_new_codebooks(enc, tempData);
 
     if (enc->framesSinceKeyframe >= 1) {
         motion_search(enc, 8);
@@ -897,19 +897,19 @@ static void roq_encode_video(RoqContext *enc)
 
  retry_encode:
     for (i=0; i<enc->width*enc->height/64; i++)
-        gather_data_for_cel(tempData.cel_evals + i, enc, &tempData);
+        gather_data_for_cel(tempData->cel_evals + i, enc, tempData);
 
     /* Quake 3 can't handle chunks bigger than 65536 bytes */
-    if (tempData.mainChunkSize/8 > 65536) {
+    if (tempData->mainChunkSize/8 > 65536) {
         enc->lambda *= .8;
         goto retry_encode;
     }
 
-    remap_codebooks(enc, &tempData);
+    remap_codebooks(enc, tempData);
 
-    write_codebooks(enc, &tempData);
+    write_codebooks(enc, tempData);
 
-    reconstruct_and_encode_image(enc, &tempData, enc->width, enc->height,
+    reconstruct_and_encode_image(enc, tempData, enc->width, enc->height,
                                  enc->width*enc->height/64);
 
     enc->avctx->coded_frame = enc->current_frame;
@@ -919,8 +919,8 @@ static void roq_encode_video(RoqContext *enc)
     FFSWAP(motion_vect *, enc->last_motion4, enc->this_motion4);
     FFSWAP(motion_vect *, enc->last_motion8, enc->this_motion8);
 
-    av_free(tempData.cel_evals);
-    av_free(tempData.closest_cb2);
+    av_free(tempData->cel_evals);
+    av_free(tempData->closest_cb2);
 
     enc->framesSinceKeyframe++;
 }
@@ -929,7 +929,7 @@ static int roq_encode_init(AVCodecContext *avctx)
 {
     RoqContext *enc = avctx->priv_data;
 
-    av_init_random(1, &enc->randctx);
+    av_random_init(&enc->randctx, 1);
 
     enc->framesSinceKeyframe = 0;
     if ((avctx->width & 0xf) || (avctx->height & 0xf)) {
@@ -955,6 +955,8 @@ static int roq_encode_init(AVCodecContext *avctx)
     enc->last_frame    = &enc->frames[0];
     enc->current_frame = &enc->frames[1];
 
+    enc->tmpData      = av_malloc(sizeof(RoqTempdata));
+
     enc->this_motion4 =
         av_mallocz((enc->width*enc->height/16)*sizeof(motion_vect));
 
@@ -1050,6 +1052,7 @@ static int roq_encode_end(AVCodecContext *avctx)
     avctx->release_buffer(avctx, enc->last_frame);
     avctx->release_buffer(avctx, enc->current_frame);
 
+    av_free(enc->tmpData);
     av_free(enc->this_motion4);
     av_free(enc->last_motion4);
     av_free(enc->this_motion8);
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index cba319c..b125a1e 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -1,6 +1,6 @@
 /*
  * RV10 codec
- * Copyright (c) 2000,2001 Fabrice Bellard.
+ * Copyright (c) 2000,2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer
  *
  * This file is part of FFmpeg.
diff --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index e3f014a..bc02bbc 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003 The FFmpeg Project.
+ * Copyright (c) 2003 The FFmpeg Project
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 7499957..a94594e 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -1,6 +1,6 @@
 /*
  * utils for libavcodec
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  *
  * This file is part of FFmpeg.
diff --git a/libavcodec/vc1.c b/libavcodec/vc1.c
index dee0adc..c2c2931 100644
--- a/libavcodec/vc1.c
+++ b/libavcodec/vc1.c
@@ -35,6 +35,7 @@
 #include "unary.h"
 #include "simple_idct.h"
 #include "mathops.h"
+#include "vdpau_internal.h"
 
 #undef NDEBUG
 #include <assert.h>
@@ -1173,12 +1174,7 @@ static int vc1_parse_frame_header(VC1Context *v, GetBitContext* gb)
     v->k_y = v->mvrange + 8; //k_y can be 8 9 10 11
     v->range_x = 1 << (v->k_x - 1);
     v->range_y = 1 << (v->k_y - 1);
-    if (v->profile == PROFILE_ADVANCED)
-    {
-        if (v->postprocflag) v->postproc = get_bits1(gb);
-    }
-    else
-        if (v->multires && v->s.pict_type != FF_B_TYPE) v->respic = get_bits(gb, 2);
+    if (v->multires && v->s.pict_type != FF_B_TYPE) v->respic = get_bits(gb, 2);
 
     if(v->res_x8 && (v->s.pict_type == FF_I_TYPE || v->s.pict_type == FF_BI_TYPE)){
         v->x8_type = get_bits1(gb);
@@ -1406,7 +1402,7 @@ static int vc1_parse_frame_header_adv(VC1Context *v, GetBitContext* gb)
     if (v->quantizer_mode == QUANT_FRAME_EXPLICIT)
         v->pquantizer = get_bits1(gb);
     if(v->postprocflag)
-        v->postproc = get_bits1(gb);
+        v->postproc = get_bits(gb, 2);
 
     if(v->s.pict_type == FF_I_TYPE || v->s.pict_type == FF_P_TYPE) v->use_ic = 0;
 
@@ -3107,6 +3103,8 @@ static int vc1_decode_p_block(VC1Context *v, DCTELEM block[64], int n, int mquan
     return pat;
 }
 
+static const int size_table  [6] = { 0, 2, 3, 4,  5,  8 };
+static const int offset_table[6] = { 0, 1, 3, 7, 15, 31 };
 
 /** Decode one P-frame MB (in Simple/Main profile)
  */
@@ -3120,8 +3118,6 @@ static int vc1_decode_p_mb(VC1Context *v)
     int mqdiff, mquant; /* MB quantization */
     int ttmb = v->ttfrm; /* MB Transform type */
 
-    static const int size_table[6] = { 0, 2, 3, 4, 5, 8 },
-      offset_table[6] = { 0, 1, 3, 7, 15, 31 };
     int mb_has_coeffs = 1; /* last_flag */
     int dmv_x, dmv_y; /* Differential MV components */
     int index, index1; /* LUT indexes */
@@ -3415,9 +3411,6 @@ static void vc1_decode_b_mb(VC1Context *v)
     int cbp = 0; /* cbp decoding stuff */
     int mqdiff, mquant; /* MB quantization */
     int ttmb = v->ttfrm; /* MB Transform type */
-
-    static const int size_table[6] = { 0, 2, 3, 4, 5, 8 },
-      offset_table[6] = { 0, 1, 3, 7, 15, 31 };
     int mb_has_coeffs = 0; /* last_flag */
     int index, index1; /* LUT indexes */
     int val, sign; /* temp values */
@@ -4130,6 +4123,7 @@ static int vc1_decode_frame(AVCodecContext *avctx,
     MpegEncContext *s = &v->s;
     AVFrame *pict = data;
     uint8_t *buf2 = NULL;
+    const uint8_t *buf_vdpau = buf;
 
     /* no supplementary picture */
     if (buf_size == 0) {
@@ -4151,6 +4145,13 @@ static int vc1_decode_frame(AVCodecContext *avctx,
         s->current_picture_ptr= &s->picture[i];
     }
 
+    if (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU){
+        if (v->profile < PROFILE_ADVANCED)
+            avctx->pix_fmt = PIX_FMT_VDPAU_WMV3;
+        else
+            avctx->pix_fmt = PIX_FMT_VDPAU_VC1;
+    }
+
     //for advanced profile we may need to parse and unescape data
     if (avctx->codec_id == CODEC_ID_VC1) {
         int buf_size2 = 0;
@@ -4167,6 +4168,8 @@ static int vc1_decode_frame(AVCodecContext *avctx,
                 if(size <= 0) continue;
                 switch(AV_RB32(start)){
                 case VC1_CODE_FRAME:
+                    if (s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
+                        buf_vdpau = start;
                     buf_size2 = vc1_unescape_buffer(start + 4, size, buf2);
                     break;
                 case VC1_CODE_ENTRYPOINT: /* it should be before frame data */
@@ -4255,14 +4258,19 @@ static int vc1_decode_frame(AVCodecContext *avctx,
     s->me.qpel_put= s->dsp.put_qpel_pixels_tab;
     s->me.qpel_avg= s->dsp.avg_qpel_pixels_tab;
 
-    ff_er_frame_start(s);
+    if ((CONFIG_VC1_VDPAU_DECODER || CONFIG_WMV3_VDPAU_DECODER)
+        &&s->avctx->codec->capabilities&CODEC_CAP_HWACCEL_VDPAU)
+        ff_vdpau_vc1_decode_picture(s, buf_vdpau, (buf + buf_size) - buf_vdpau);
+    else {
+        ff_er_frame_start(s);
 
-    v->bits = buf_size * 8;
-    vc1_decode_blocks(v);
+        v->bits = buf_size * 8;
+        vc1_decode_blocks(v);
 //av_log(s->avctx, AV_LOG_INFO, "Consumed %i/%i bits\n", get_bits_count(&s->gb), buf_size*8);
 //  if(get_bits_count(&s->gb) > buf_size * 8)
 //      return -1;
-    ff_er_frame_end(s);
+        ff_er_frame_end(s);
+    }
 
     MPV_frame_end(s);
 
@@ -4336,3 +4344,35 @@ AVCodec wmv3_decoder = {
     NULL,
     .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9"),
 };
+
+#if CONFIG_WMV3_VDPAU_DECODER
+AVCodec wmv3_vdpau_decoder = {
+    "wmv3_vdpau",
+    CODEC_TYPE_VIDEO,
+    CODEC_ID_WMV3,
+    sizeof(VC1Context),
+    vc1_decode_init,
+    NULL,
+    vc1_decode_end,
+    vc1_decode_frame,
+    CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU,
+    NULL,
+    .long_name = NULL_IF_CONFIG_SMALL("Windows Media Video 9 VDPAU"),
+};
+#endif
+
+#if CONFIG_VC1_VDPAU_DECODER
+AVCodec vc1_vdpau_decoder = {
+    "vc1_vdpau",
+    CODEC_TYPE_VIDEO,
+    CODEC_ID_VC1,
+    sizeof(VC1Context),
+    vc1_decode_init,
+    NULL,
+    vc1_decode_end,
+    vc1_decode_frame,
+    CODEC_CAP_DR1 | CODEC_CAP_DELAY | CODEC_CAP_HWACCEL_VDPAU,
+    NULL,
+    .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-1 VDPAU"),
+};
+#endif
diff --git a/libavcodec/vdpau.h b/libavcodec/vdpau.h
index a28ad7f..53dbd7c 100644
--- a/libavcodec/vdpau.h
+++ b/libavcodec/vdpau.h
@@ -70,8 +70,9 @@ struct vdpau_render_state {
 
     /** picture parameter information for all supported codecs */
     union VdpPictureInfo {
-        VdpPictureInfoMPEG1Or2 mpeg;
         VdpPictureInfoH264     h264;
+        VdpPictureInfoMPEG1Or2 mpeg;
+        VdpPictureInfoVC1       vc1;
     } info;
 
     /** Describe size/location of the compressed video data. */
diff --git a/libavcodec/vdpau_internal.h b/libavcodec/vdpau_internal.h
index 4f993af..ce0e00a 100644
--- a/libavcodec/vdpau_internal.h
+++ b/libavcodec/vdpau_internal.h
@@ -2,7 +2,7 @@
  * Video Decode and Presentation API for UNIX (VDPAU) is used for
  * HW decode acceleration for MPEG-1/2, H.264 and VC-1.
  *
- * Copyright (C) 2008 NVIDIA.
+ * Copyright (C) 2008 NVIDIA
  *
  * This file is part of FFmpeg.
  *
@@ -36,4 +36,7 @@ void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf,
 void ff_vdpau_h264_set_reference_frames(MpegEncContext *s);
 void ff_vdpau_h264_picture_complete(MpegEncContext *s);
 
+void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
+                                 int buf_size);
+
 #endif /* AVCODEC_VDPAU_INTERNAL_H */
diff --git a/libavcodec/vdpauvideo.c b/libavcodec/vdpauvideo.c
index b5b91cb..8eb806a 100644
--- a/libavcodec/vdpauvideo.c
+++ b/libavcodec/vdpauvideo.c
@@ -2,7 +2,7 @@
  * Video Decode and Presentation API for UNIX (VDPAU) is used for
  * HW decode acceleration for MPEG-1/2, H.264 and VC-1.
  *
- * Copyright (c) 2008 NVIDIA.
+ * Copyright (c) 2008 NVIDIA
  *
  * This file is part of FFmpeg.
  *
@@ -24,6 +24,7 @@
 #include <limits.h>
 #include "avcodec.h"
 #include "h264.h"
+#include "vc1.h"
 
 #undef NDEBUG
 #include <assert.h>
@@ -232,4 +233,73 @@ void ff_vdpau_mpeg_picture_complete(MpegEncContext *s, const uint8_t *buf,
     render->bitstream_buffers_used               = 0;
 }
 
+void ff_vdpau_vc1_decode_picture(MpegEncContext *s, const uint8_t *buf,
+                                 int buf_size)
+{
+    VC1Context *v = s->avctx->priv_data;
+    struct vdpau_render_state * render, * last, * next;
+
+    render = (struct vdpau_render_state*)s->current_picture.data[0];
+    assert(render);
+
+    /*  fill LvPictureInfoVC1 struct */
+    render->info.vc1.frame_coding_mode  = v->fcm;
+    render->info.vc1.postprocflag       = v->postprocflag;
+    render->info.vc1.pulldown           = v->broadcast;
+    render->info.vc1.interlace          = v->interlace;
+    render->info.vc1.tfcntrflag         = v->tfcntrflag;
+    render->info.vc1.finterpflag        = v->finterpflag;
+    render->info.vc1.psf                = v->psf;
+    render->info.vc1.dquant             = v->dquant;
+    render->info.vc1.panscan_flag       = v->panscanflag;
+    render->info.vc1.refdist_flag       = v->refdist_flag;
+    render->info.vc1.quantizer          = v->quantizer_mode;
+    render->info.vc1.extended_mv        = v->extended_mv;
+    render->info.vc1.extended_dmv       = v->extended_dmv;
+    render->info.vc1.overlap            = v->overlap;
+    render->info.vc1.vstransform        = v->vstransform;
+    render->info.vc1.loopfilter         = v->s.loop_filter;
+    render->info.vc1.fastuvmc           = v->fastuvmc;
+    render->info.vc1.range_mapy_flag    = v->range_mapy_flag;
+    render->info.vc1.range_mapy         = v->range_mapy;
+    render->info.vc1.range_mapuv_flag   = v->range_mapuv_flag;
+    render->info.vc1.range_mapuv        = v->range_mapuv;
+    /* Specific to simple/main profile only */
+    render->info.vc1.multires           = v->multires;
+    render->info.vc1.syncmarker         = v->s.resync_marker;
+    render->info.vc1.rangered           = v->rangered;
+    render->info.vc1.maxbframes         = v->s.max_b_frames;
+
+    render->info.vc1.deblockEnable      = v->postprocflag & 1;
+    render->info.vc1.pquant             = v->pq;
+
+    render->info.vc1.forward_reference  = VDP_INVALID_HANDLE;
+    render->info.vc1.backward_reference = VDP_INVALID_HANDLE;
+
+    if (v->bi_type)
+        render->info.vc1.picture_type = 4;
+    else
+        render->info.vc1.picture_type = s->pict_type - 1 + s->pict_type / 3;
+
+    switch(s->pict_type){
+    case  FF_B_TYPE:
+        next = (struct vdpau_render_state*)s->next_picture.data[0];
+        assert(next);
+        render->info.vc1.backward_reference = next->surface;
+        // no break here, going to set forward prediction
+    case  FF_P_TYPE:
+        last = (struct vdpau_render_state*)s->last_picture.data[0];
+        if (!last) // FIXME: Does this test make sense?
+            last = render; // predict second field from the first
+        render->info.vc1.forward_reference = last->surface;
+    }
+
+    ff_vdpau_add_data_chunk(s, buf, buf_size);
+
+    render->info.vc1.slice_count          = 1;
+
+    ff_draw_horiz_band(s, 0, s->avctx->height);
+    render->bitstream_buffers_used        = 0;
+}
+
 /* @}*/
diff --git a/libavcodec/vmdav.c b/libavcodec/vmdav.c
index 48f76bf..975efe5 100644
--- a/libavcodec/vmdav.c
+++ b/libavcodec/vmdav.c
@@ -20,7 +20,7 @@
  */
 
 /**
- * @file vmdvideo.c
+ * @file vmdav.c
  * Sierra VMD audio & video decoders
  * by Vladimir "VAG" Gneushev (vagsoft at mail.ru)
  * for more information on the Sierra VMD format, visit:
@@ -456,13 +456,13 @@ static av_cold int vmdaudio_decode_init(AVCodecContext *avctx)
 }
 
 static void vmdaudio_decode_audio(VmdAudioContext *s, unsigned char *data,
-    const uint8_t *buf, int stereo)
+    const uint8_t *buf, int buf_size, int stereo)
 {
     int i;
     int chan = 0;
     int16_t *out = (int16_t*)data;
 
-    for(i = 0; i < s->block_align; i++) {
+    for(i = 0; i < buf_size; i++) {
         if(buf[i] & 0x80)
             s->predictors[chan] -= vmdaudio_table[buf[i] & 0x7F];
         else
@@ -474,7 +474,7 @@ static void vmdaudio_decode_audio(VmdAudioContext *s, unsigned char *data,
 }
 
 static int vmdaudio_loadsound(VmdAudioContext *s, unsigned char *data,
-    const uint8_t *buf, int silence)
+    const uint8_t *buf, int silence, int data_size)
 {
     int bytes_decoded = 0;
     int i;
@@ -485,30 +485,30 @@ static int vmdaudio_loadsound(VmdAudioContext *s, unsigned char *data,
 
         /* stereo handling */
         if (silence) {
-            memset(data, 0, s->block_align * 2);
+            memset(data, 0, data_size * 2);
         } else {
             if (s->bits == 16)
-                vmdaudio_decode_audio(s, data, buf, 1);
+                vmdaudio_decode_audio(s, data, buf, data_size, 1);
             else {
                 /* copy the data but convert it to signed */
-                for (i = 0; i < s->block_align; i++){
+                for (i = 0; i < data_size; i++){
                     *data++ = buf[i] + 0x80;
                     *data++ = buf[i] + 0x80;
                 }
             }
         }
     } else {
-        bytes_decoded = s->block_align * 2;
+        bytes_decoded = data_size * 2;
 
         /* mono handling */
         if (silence) {
-            memset(data, 0, s->block_align * 2);
+            memset(data, 0, data_size * 2);
         } else {
             if (s->bits == 16) {
-                vmdaudio_decode_audio(s, data, buf, 0);
+                vmdaudio_decode_audio(s, data, buf, data_size, 0);
             } else {
                 /* copy the data but convert it to signed */
-                for (i = 0; i < s->block_align; i++){
+                for (i = 0; i < data_size; i++){
                     *data++ = buf[i] + 0x80;
                     *data++ = buf[i] + 0x80;
                 }
@@ -516,7 +516,7 @@ static int vmdaudio_loadsound(VmdAudioContext *s, unsigned char *data,
         }
     }
 
-    return s->block_align * 2;
+    return data_size * 2;
 }
 
 static int vmdaudio_decode_frame(AVCodecContext *avctx,
@@ -534,15 +534,26 @@ static int vmdaudio_decode_frame(AVCodecContext *avctx,
 
     if (buf[6] == 1) {
         /* the chunk contains audio */
-        *data_size = vmdaudio_loadsound(s, output_samples, p, 0);
+        *data_size = vmdaudio_loadsound(s, output_samples, p, 0, buf_size - 16);
     } else if (buf[6] == 2) {
-        /* the chunk may contain audio */
-        p += 4;
-        *data_size = vmdaudio_loadsound(s, output_samples, p, (buf_size == 16));
-        output_samples += (s->block_align * s->bits / 8);
+        /* initial chunk, may contain audio and silence */
+        uint32_t flags = AV_RB32(p);
+        int raw_block_size = s->block_align * s->bits / 8;
+        int silent_chunks;
+        if(flags == 0xFFFFFFFF)
+            silent_chunks = 32;
+        else
+            silent_chunks = av_log2(flags + 1);
+        if(*data_size < (s->block_align*silent_chunks + buf_size - 20) * 2)
+            return -1;
+        *data_size = 0;
+        memset(output_samples, 0, raw_block_size * silent_chunks);
+        output_samples += raw_block_size * silent_chunks;
+        *data_size = raw_block_size * silent_chunks;
+        *data_size += vmdaudio_loadsound(s, output_samples, p + 4, 0, buf_size - 20);
     } else if (buf[6] == 3) {
         /* silent chunk */
-        *data_size = vmdaudio_loadsound(s, output_samples, p, 1);
+        *data_size = vmdaudio_loadsound(s, output_samples, p, 1, 0);
     }
 
     return buf_size;
diff --git a/libavcodec/vp5.c b/libavcodec/vp5.c
index e47db0d..3eecb56 100644
--- a/libavcodec/vp5.c
+++ b/libavcodec/vp5.c
@@ -64,7 +64,8 @@ static int vp5_parse_header(VP56Context *s, const uint8_t *buf, int buf_size,
             avcodec_set_dimensions(s->avctx, 16*cols, 16*rows);
             return 2;
         }
-    }
+    } else if (!s->macroblocks)
+        return 0;
     return 1;
 }
 
diff --git a/libavcodec/wma.c b/libavcodec/wma.c
index 2bbb099..ff01f49 100644
--- a/libavcodec/wma.c
+++ b/libavcodec/wma.c
@@ -1,6 +1,6 @@
 /*
  * WMA compatible codec
- * Copyright (c) 2002-2007 The FFmpeg Project.
+ * Copyright (c) 2002-2007 The FFmpeg Project
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/wma.h b/libavcodec/wma.h
index 0aa109c..fee7562 100644
--- a/libavcodec/wma.h
+++ b/libavcodec/wma.h
@@ -1,6 +1,6 @@
 /*
  * WMA compatible codec
- * Copyright (c) 2002-2007 The FFmpeg Project.
+ * Copyright (c) 2002-2007 The FFmpeg Project
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/wmadec.c b/libavcodec/wmadec.c
index fbd945d..b7521cd 100644
--- a/libavcodec/wmadec.c
+++ b/libavcodec/wmadec.c
@@ -1,6 +1,6 @@
 /*
  * WMA compatible decoder
- * Copyright (c) 2002 The FFmpeg Project.
+ * Copyright (c) 2002 The FFmpeg Project
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/wmv2.c b/libavcodec/wmv2.c
index 015e3f2..e872b44 100644
--- a/libavcodec/wmv2.c
+++ b/libavcodec/wmv2.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002 The FFmpeg Project.
+ * Copyright (c) 2002 The FFmpeg Project
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/wmv2.h b/libavcodec/wmv2.h
index 7ed96ce..4c7be44 100644
--- a/libavcodec/wmv2.h
+++ b/libavcodec/wmv2.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002 The FFmpeg Project.
+ * Copyright (c) 2002 The FFmpeg Project
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
index e5d8269..fd42b2c 100644
--- a/libavcodec/wmv2dec.c
+++ b/libavcodec/wmv2dec.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002 The FFmpeg Project.
+ * Copyright (c) 2002 The FFmpeg Project
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/wmv2enc.c b/libavcodec/wmv2enc.c
index a31a05a..721edeb 100644
--- a/libavcodec/wmv2enc.c
+++ b/libavcodec/wmv2enc.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2002 The FFmpeg Project.
+ * Copyright (c) 2002 The FFmpeg Project
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavcodec/ws-snd1.c b/libavcodec/ws-snd1.c
index 2dc49fc..099f9b6 100644
--- a/libavcodec/ws-snd1.c
+++ b/libavcodec/ws-snd1.c
@@ -23,7 +23,7 @@
 #include "avcodec.h"
 
 /**
- * @file ws-snd.c
+ * @file ws-snd1.c
  * Westwood SNDx codecs.
  *
  * Reference documents about VQA format and its audio codecs
diff --git a/libavcodec/x86/dsputil_mmx.c b/libavcodec/x86/dsputil_mmx.c
index 0167308..a457d55 100644
--- a/libavcodec/x86/dsputil_mmx.c
+++ b/libavcodec/x86/dsputil_mmx.c
@@ -1,6 +1,6 @@
 /*
  * MMX optimized DSP utils
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  *
  * This file is part of FFmpeg.
@@ -2491,12 +2491,12 @@ static void sub_int16_sse2(int16_t * v1, int16_t * v2, int order)
 static int32_t scalarproduct_int16_sse2(int16_t * v1, int16_t * v2, int order, int shift)
 {
     int res = 0;
-    DECLARE_ALIGNED_16(int64_t, sh);
+    DECLARE_ALIGNED_16(xmm_reg, sh);
     x86_reg o = -(order << 1);
 
     v1 += order;
     v2 += order;
-    sh = shift;
+    sh.a = shift;
     __asm__ volatile(
         "pxor      %%xmm7,  %%xmm7        \n\t"
         "1:                               \n\t"
diff --git a/libavcodec/x86/dsputil_mmx_avg_template.c b/libavcodec/x86/dsputil_mmx_avg_template.c
index 616a12b..c00dad5 100644
--- a/libavcodec/x86/dsputil_mmx_avg_template.c
+++ b/libavcodec/x86/dsputil_mmx_avg_template.c
@@ -1,6 +1,6 @@
 /*
  * DSP utils : average functions are compiled twice for 3dnow/mmx2
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer
  *
  * MMX optimization by Nick Kurshev <nickols_k at mail.ru>
diff --git a/libavcodec/x86/dsputil_mmx_rnd_template.c b/libavcodec/x86/dsputil_mmx_rnd_template.c
index 45ed590..ccfd7e5 100644
--- a/libavcodec/x86/dsputil_mmx_rnd_template.c
+++ b/libavcodec/x86/dsputil_mmx_rnd_template.c
@@ -1,6 +1,6 @@
 /*
  * DSP utils mmx functions are compiled twice for rnd/no_rnd
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  * Copyright (c) 2003-2004 Michael Niedermayer <michaelni at gmx.at>
  *
  * MMX optimization by Nick Kurshev <nickols_k at mail.ru>
diff --git a/libavcodec/x86/dsputilenc_mmx.c b/libavcodec/x86/dsputilenc_mmx.c
index d1ee111..1717a01 100644
--- a/libavcodec/x86/dsputilenc_mmx.c
+++ b/libavcodec/x86/dsputilenc_mmx.c
@@ -1,6 +1,6 @@
 /*
  * MMX optimized DSP utils
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer <michaelni at gmx.at>
  *
  * This file is part of FFmpeg.
diff --git a/libavcodec/x86/motion_est_mmx.c b/libavcodec/x86/motion_est_mmx.c
index c866e8a..2d3c866 100644
--- a/libavcodec/x86/motion_est_mmx.c
+++ b/libavcodec/x86/motion_est_mmx.c
@@ -1,6 +1,6 @@
 /*
  * MMX optimized motion estimation
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  * Copyright (c) 2002-2004 Michael Niedermayer
  *
  * mostly by Michael Niedermayer <michaelni at gmx.at>
diff --git a/libavcodec/x86/mpegvideo_mmx.c b/libavcodec/x86/mpegvideo_mmx.c
index 2abd4d5..cbd5a17 100644
--- a/libavcodec/x86/mpegvideo_mmx.c
+++ b/libavcodec/x86/mpegvideo_mmx.c
@@ -1,6 +1,6 @@
 /*
  * The simplest mpeg encoder (well, it was the simplest!)
- * Copyright (c) 2000,2001 Fabrice Bellard.
+ * Copyright (c) 2000,2001 Fabrice Bellard
  *
  * Optimized for ia32 CPUs by Nick Kurshev <nickols_k at mail.ru>
  * h263, mpeg1, mpeg2 dequantizer & draw_edges by Michael Niedermayer <michaelni at gmx.at>
diff --git a/libavdevice/Makefile b/libavdevice/Makefile
index 655c033..8bd706b 100644
--- a/libavdevice/Makefile
+++ b/libavdevice/Makefile
@@ -8,10 +8,12 @@ HEADERS = avdevice.h
 OBJS    = alldevices.o
 
 # input/output devices
+OBJS-$(CONFIG_ALSA_DEMUXER)              += alsa-audio-common.o alsa-audio-dec.o
+OBJS-$(CONFIG_ALSA_MUXER)                += alsa-audio-common.o alsa-audio-enc.o
 OBJS-$(CONFIG_BKTR_DEMUXER)              += bktr.o
 OBJS-$(CONFIG_DV1394_DEMUXER)            += dv1394.o
-OBJS-$(CONFIG_OSS_DEMUXER)               += audio.o
-OBJS-$(CONFIG_OSS_MUXER)                 += audio.o
+OBJS-$(CONFIG_OSS_DEMUXER)               += oss_audio.o
+OBJS-$(CONFIG_OSS_MUXER)                 += oss_audio.o
 OBJS-$(CONFIG_V4L2_DEMUXER)              += v4l2.o
 OBJS-$(CONFIG_V4L_DEMUXER)               += v4l.o
 OBJS-$(CONFIG_VFWCAP_DEMUXER)            += vfwcap.o
diff --git a/libavdevice/alldevices.c b/libavdevice/alldevices.c
index 342e26e..38ce6f1 100644
--- a/libavdevice/alldevices.c
+++ b/libavdevice/alldevices.c
@@ -44,6 +44,7 @@ void avdevice_register_all(void)
     initialized = 1;
 
     /* devices */
+    REGISTER_MUXDEMUX (ALSA, alsa);
     REGISTER_MUXDEMUX (AUDIO_BEOS, audio_beos);
     REGISTER_DEMUXER  (BKTR, bktr);
     REGISTER_DEMUXER  (DV1394, dv1394);
diff --git a/libavdevice/alsa-audio-common.c b/libavdevice/alsa-audio-common.c
new file mode 100644
index 0000000..1cb2640
--- /dev/null
+++ b/libavdevice/alsa-audio-common.c
@@ -0,0 +1,186 @@
+/*
+ * ALSA input and output
+ * Copyright (c) 2007 Luca Abeni ( lucabe72 email it )
+ * Copyright (c) 2007 Benoit Fouet ( benoit fouet free fr )
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file alsa-audio-common.c
+ * ALSA input and output: common code
+ * @author Luca Abeni ( lucabe72 email it )
+ * @author Benoit Fouet ( benoit fouet free fr )
+ * @author Nicolas George ( nicolas george normalesup org )
+ */
+
+#include "libavformat/avformat.h"
+#include <alsa/asoundlib.h>
+
+#include "alsa-audio.h"
+
+static av_cold snd_pcm_format_t codec_id_to_pcm_format(int codec_id)
+{
+    switch(codec_id) {
+        case CODEC_ID_PCM_S16LE: return SND_PCM_FORMAT_S16_LE;
+        case CODEC_ID_PCM_S16BE: return SND_PCM_FORMAT_S16_BE;
+        case CODEC_ID_PCM_S8:    return SND_PCM_FORMAT_S8;
+        default:                 return SND_PCM_FORMAT_UNKNOWN;
+    }
+}
+
+av_cold int ff_alsa_open(AVFormatContext *ctx, int mode,
+                         unsigned int *sample_rate,
+                         int channels, int *codec_id)
+{
+    AlsaData *s = ctx->priv_data;
+    const char *audio_device;
+    int res, flags = 0;
+    snd_pcm_format_t format;
+    snd_pcm_t *h;
+    snd_pcm_hw_params_t *hw_params;
+    snd_pcm_uframes_t buffer_size, period_size;
+
+    if (ctx->filename[0] == 0) audio_device = "default";
+    else                       audio_device = ctx->filename;
+
+    if (*codec_id == CODEC_ID_NONE)
+        *codec_id = DEFAULT_CODEC_ID;
+    format = codec_id_to_pcm_format(*codec_id);
+    if (format == SND_PCM_FORMAT_UNKNOWN) {
+        av_log(ctx, AV_LOG_ERROR, "sample format 0x%04x is not supported\n", *codec_id);
+        return AVERROR(ENOSYS);
+    }
+    s->frame_size = av_get_bits_per_sample(*codec_id) / 8 * channels;
+
+    if (ctx->flags & AVFMT_FLAG_NONBLOCK) {
+        flags = O_NONBLOCK;
+    }
+    res = snd_pcm_open(&h, audio_device, mode, flags);
+    if (res < 0) {
+        av_log(ctx, AV_LOG_ERROR, "cannot open audio device %s (%s)\n",
+               audio_device, snd_strerror(res));
+        return AVERROR_IO;
+    }
+
+    res = snd_pcm_hw_params_malloc(&hw_params);
+    if (res < 0) {
+        av_log(ctx, AV_LOG_ERROR, "cannot allocate hardware parameter structure (%s)\n",
+               snd_strerror(res));
+        goto fail1;
+    }
+
+    res = snd_pcm_hw_params_any(h, hw_params);
+    if (res < 0) {
+        av_log(ctx, AV_LOG_ERROR, "cannot initialize hardware parameter structure (%s)\n",
+               snd_strerror(res));
+        goto fail;
+    }
+
+    res = snd_pcm_hw_params_set_access(h, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED);
+    if (res < 0) {
+        av_log(ctx, AV_LOG_ERROR, "cannot set access type (%s)\n",
+               snd_strerror(res));
+        goto fail;
+    }
+
+    res = snd_pcm_hw_params_set_format(h, hw_params, format);
+    if (res < 0) {
+        av_log(ctx, AV_LOG_ERROR, "cannot set sample format 0x%04x %d (%s)\n",
+               *codec_id, format, snd_strerror(res));
+        goto fail;
+    }
+
+    res = snd_pcm_hw_params_set_rate_near(h, hw_params, sample_rate, 0);
+    if (res < 0) {
+        av_log(ctx, AV_LOG_ERROR, "cannot set sample rate (%s)\n",
+               snd_strerror(res));
+        goto fail;
+    }
+
+    res = snd_pcm_hw_params_set_channels(h, hw_params, channels);
+    if (res < 0) {
+        av_log(ctx, AV_LOG_ERROR, "cannot set channel count to %d (%s)\n",
+               channels, snd_strerror(res));
+        goto fail;
+    }
+
+    snd_pcm_hw_params_get_buffer_size_max(hw_params, &buffer_size);
+    /* TODO: maybe use ctx->max_picture_buffer somehow */
+    res = snd_pcm_hw_params_set_buffer_size_near(h, hw_params, &buffer_size);
+    if (res < 0) {
+        av_log(ctx, AV_LOG_ERROR, "cannot set ALSA buffer size (%s)\n",
+               snd_strerror(res));
+        goto fail;
+    }
+
+    snd_pcm_hw_params_get_period_size_min(hw_params, &period_size, NULL);
+    res = snd_pcm_hw_params_set_period_size_near(h, hw_params, &period_size, NULL);
+    if (res < 0) {
+        av_log(ctx, AV_LOG_ERROR, "cannot set ALSA period size (%s)\n",
+               snd_strerror(res));
+        goto fail;
+    }
+    s->period_size = period_size;
+
+    res = snd_pcm_hw_params(h, hw_params);
+    if (res < 0) {
+        av_log(ctx, AV_LOG_ERROR, "cannot set parameters (%s)\n",
+               snd_strerror(res));
+        goto fail;
+    }
+
+    snd_pcm_hw_params_free(hw_params);
+
+    s->h = h;
+    return 0;
+
+fail:
+    snd_pcm_hw_params_free(hw_params);
+fail1:
+    snd_pcm_close(h);
+    return AVERROR_IO;
+}
+
+av_cold int ff_alsa_close(AVFormatContext *s1)
+{
+    AlsaData *s = s1->priv_data;
+
+    snd_pcm_close(s->h);
+    return 0;
+}
+
+int ff_alsa_xrun_recover(AVFormatContext *s1, int err)
+{
+    AlsaData *s = s1->priv_data;
+    snd_pcm_t *handle = s->h;
+
+    av_log(s1, AV_LOG_WARNING, "ALSA buffer xrun.\n");
+    if (err == -EPIPE) {
+        err = snd_pcm_prepare(handle);
+        if (err < 0) {
+            av_log(s1, AV_LOG_ERROR, "cannot recover from underrun (snd_pcm_prepare failed: %s)\n", snd_strerror(err));
+
+            return AVERROR_IO;
+        }
+    } else if (err == -ESTRPIPE) {
+        av_log(s1, AV_LOG_ERROR, "-ESTRPIPE... Unsupported!\n");
+
+        return -1;
+    }
+    return err;
+}
diff --git a/libavdevice/alsa-audio-dec.c b/libavdevice/alsa-audio-dec.c
new file mode 100644
index 0000000..1be0a6c
--- /dev/null
+++ b/libavdevice/alsa-audio-dec.c
@@ -0,0 +1,175 @@
+/*
+ * ALSA input and output
+ * Copyright (c) 2007 Luca Abeni ( lucabe72 email it )
+ * Copyright (c) 2007 Benoit Fouet ( benoit fouet free fr )
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file alsa-audio-dec.c
+ * ALSA input and output: input
+ * @author Luca Abeni ( lucabe72 email it )
+ * @author Benoit Fouet ( benoit fouet free fr )
+ * @author Nicolas George ( nicolas george normalesup org )
+ *
+ * This avdevice decoder allows to capture audio from an ALSA (Advanced
+ * Linux Sound Architecture) device.
+ *
+ * The filename parameter is the name of an ALSA PCM device capable of
+ * capture, for example "default" or "plughw:1"; see the ALSA documentation
+ * for naming conventions. The empty string is equivalent to "default".
+ *
+ * The capture period is set to the lower value available for the device,
+ * which gives a low latency suitable for real-time capture.
+ *
+ * The PTS are an Unix time in microsecond.
+ *
+ * Due to a bug in the ALSA library
+ * (https://bugtrack.alsa-project.org/alsa-bug/view.php?id=4308), this
+ * decoder does not work with certain ALSA plugins, especially the dsnoop
+ * plugin.
+ */
+
+#include "libavformat/avformat.h"
+#include <alsa/asoundlib.h>
+
+#include "alsa-audio.h"
+
+av_cold static int audio_read_header(AVFormatContext *s1,
+                                     AVFormatParameters *ap)
+{
+    AlsaData *s = s1->priv_data;
+    AVStream *st;
+    int ret;
+    unsigned int sample_rate;
+    int codec_id;
+    snd_pcm_sw_params_t *sw_params;
+
+    if (ap->sample_rate <= 0) {
+        av_log(s1, AV_LOG_ERROR, "Bad sample rate %d\n", ap->sample_rate);
+
+        return AVERROR(EIO);
+    }
+
+    if (ap->channels <= 0) {
+        av_log(s1, AV_LOG_ERROR, "Bad channels number %d\n", ap->channels);
+
+        return AVERROR(EIO);
+    }
+
+    st = av_new_stream(s1, 0);
+    if (!st) {
+        av_log(s1, AV_LOG_ERROR, "Cannot add stream\n");
+
+        return AVERROR(ENOMEM);
+    }
+    sample_rate = ap->sample_rate;
+    codec_id    = ap->audio_codec_id;
+
+    ret = ff_alsa_open(s1, SND_PCM_STREAM_CAPTURE, &sample_rate, ap->channels,
+        &codec_id);
+    if (ret < 0) {
+        return AVERROR(EIO);
+    }
+
+    if (snd_pcm_type(s->h) != SND_PCM_TYPE_HW)
+        av_log(s1, AV_LOG_WARNING,
+               "capture with some ALSA plugins, especially dsnoop, "
+               "may hang.\n");
+
+    ret = snd_pcm_sw_params_malloc(&sw_params);
+    if (ret < 0) {
+        av_log(s1, AV_LOG_ERROR, "cannot allocate software parameters structure (%s)\n",
+               snd_strerror(ret));
+        goto fail;
+    }
+
+    snd_pcm_sw_params_current(s->h, sw_params);
+    snd_pcm_sw_params_set_tstamp_mode(s->h, sw_params, SND_PCM_TSTAMP_ENABLE);
+
+    ret = snd_pcm_sw_params(s->h, sw_params);
+    snd_pcm_sw_params_free(sw_params);
+    if (ret < 0) {
+        av_log(s1, AV_LOG_ERROR, "cannot install ALSA software parameters (%s)\n",
+               snd_strerror(ret));
+        goto fail;
+    }
+
+    /* take real parameters */
+    st->codec->codec_type  = CODEC_TYPE_AUDIO;
+    st->codec->codec_id    = codec_id;
+    st->codec->sample_rate = sample_rate;
+    st->codec->channels    = ap->channels;
+    av_set_pts_info(st, 64, 1, 1000000);  /* 64 bits pts in us */
+
+    return 0;
+
+fail:
+    snd_pcm_close(s->h);
+    return AVERROR(EIO);
+}
+
+static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
+{
+    AlsaData *s  = s1->priv_data;
+    AVStream *st = s1->streams[0];
+    int res;
+    snd_htimestamp_t timestamp;
+    snd_pcm_uframes_t ts_delay;
+
+    if (av_new_packet(pkt, s->period_size) < 0) {
+        return AVERROR(EIO);
+    }
+
+    while ((res = snd_pcm_readi(s->h, pkt->data, pkt->size / s->frame_size)) < 0) {
+        if (res == -EAGAIN) {
+            av_free_packet(pkt);
+
+            return AVERROR(EAGAIN);
+        }
+        if (ff_alsa_xrun_recover(s1, res) < 0) {
+            av_log(s1, AV_LOG_ERROR, "ALSA read error: %s\n",
+                   snd_strerror(res));
+            av_free_packet(pkt);
+
+            return AVERROR(EIO);
+        }
+    }
+
+    snd_pcm_htimestamp(s->h, &ts_delay, &timestamp);
+    ts_delay += res;
+    pkt->pts = timestamp.tv_sec * 1000000LL
+               + (timestamp.tv_nsec * st->codec->sample_rate
+                  - ts_delay * 1000000000LL + st->codec->sample_rate * 500LL)
+               / (st->codec->sample_rate * 1000LL);
+
+    pkt->size = res * s->frame_size;
+
+    return 0;
+}
+
+AVInputFormat alsa_demuxer = {
+    "alsa",
+    NULL_IF_CONFIG_SMALL("ALSA audio input"),
+    sizeof(AlsaData),
+    NULL,
+    audio_read_header,
+    audio_read_packet,
+    ff_alsa_close,
+    .flags = AVFMT_NOFILE,
+};
diff --git a/libavdevice/alsa-audio-enc.c b/libavdevice/alsa-audio-enc.c
new file mode 100644
index 0000000..375ad63
--- /dev/null
+++ b/libavdevice/alsa-audio-enc.c
@@ -0,0 +1,108 @@
+/*
+ * ALSA input and output
+ * Copyright (c) 2007 Luca Abeni ( lucabe72 email it )
+ * Copyright (c) 2007 Benoit Fouet ( benoit fouet free fr )
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file alsa-audio-enc.c
+ * ALSA input and output: output
+ * @author Luca Abeni ( lucabe72 email it )
+ * @author Benoit Fouet ( benoit fouet free fr )
+ *
+ * This avdevice encoder allows to play audio to an ALSA (Advanced Linux
+ * Sound Architecture) device.
+ *
+ * The filename parameter is the name of an ALSA PCM device capable of
+ * capture, for example "default" or "plughw:1"; see the ALSA documentation
+ * for naming conventions. The empty string is equivalent to "default".
+ *
+ * The playback period is set to the lower value available for the device,
+ * which gives a low latency suitable for real-time playback.
+ */
+
+#include "libavformat/avformat.h"
+#include <alsa/asoundlib.h>
+
+#include "alsa-audio.h"
+
+av_cold static int audio_write_header(AVFormatContext *s1)
+{
+    AlsaData *s = s1->priv_data;
+    AVStream *st;
+    unsigned int sample_rate;
+    int codec_id;
+    int res;
+
+    st = s1->streams[0];
+    sample_rate = st->codec->sample_rate;
+    codec_id    = st->codec->codec_id;
+    res = ff_alsa_open(s1, SND_PCM_STREAM_PLAYBACK, &sample_rate,
+        st->codec->channels, &codec_id);
+    if (sample_rate != st->codec->sample_rate) {
+        av_log(s1, AV_LOG_ERROR,
+               "sample rate %d not available, nearest is %d\n",
+               st->codec->sample_rate, sample_rate);
+        goto fail;
+    }
+
+    return res;
+
+fail:
+    snd_pcm_close(s->h);
+    return AVERROR(EIO);
+}
+
+static int audio_write_packet(AVFormatContext *s1, AVPacket *pkt)
+{
+    AlsaData *s = s1->priv_data;
+    int res;
+    int size     = pkt->size;
+    uint8_t *buf = pkt->data;
+
+    while((res = snd_pcm_writei(s->h, buf, size / s->frame_size)) < 0) {
+        if (res == -EAGAIN) {
+
+            return AVERROR(EAGAIN);
+        }
+
+        if (ff_alsa_xrun_recover(s1, res) < 0) {
+            av_log(s1, AV_LOG_ERROR, "ALSA write error: %s\n",
+                   snd_strerror(res));
+
+            return AVERROR(EIO);
+        }
+    }
+
+    return 0;
+}
+
+AVOutputFormat alsa_muxer = {
+    "alsa",
+    NULL_IF_CONFIG_SMALL("ALSA audio output"),
+    "",
+    "",
+    sizeof(AlsaData),
+    DEFAULT_CODEC_ID,
+    CODEC_ID_NONE,
+    audio_write_header,
+    audio_write_packet,
+    ff_alsa_close,
+    .flags = AVFMT_NOFILE,
+};
diff --git a/libavdevice/alsa-audio.h b/libavdevice/alsa-audio.h
new file mode 100644
index 0000000..9547f79
--- /dev/null
+++ b/libavdevice/alsa-audio.h
@@ -0,0 +1,84 @@
+/*
+ * ALSA input and output
+ * Copyright (c) 2007 Luca Abeni ( lucabe72 email it )
+ * Copyright (c) 2007 Benoit Fouet ( benoit fouet free fr )
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+/**
+ * @file alsa-audio.h
+ * ALSA input and output: definitions and structures
+ * @author Luca Abeni ( lucabe72 email it )
+ * @author Benoit Fouet ( benoit fouet free fr )
+ */
+
+#ifndef AVDEVICE_ALSA_AUDIO_H
+#define AVDEVICE_ALSA_AUDIO_H
+
+/* XXX: we make the assumption that the soundcard accepts this format */
+/* XXX: find better solution with "preinit" method, needed also in
+        other formats */
+#ifdef WORDS_BIGENDIAN
+#define DEFAULT_CODEC_ID CODEC_ID_PCM_S16BE
+#else
+#define DEFAULT_CODEC_ID CODEC_ID_PCM_S16LE
+#endif
+
+typedef struct {
+    snd_pcm_t *h;
+    int frame_size;  ///< preferred size for reads and writes
+    int period_size; ///< bytes per sample * channels
+} AlsaData;
+
+/**
+ * Opens an ALSA PCM.
+ *
+ * @param s media file handle
+ * @param mode either SND_PCM_STREAM_CAPTURE or SND_PCM_STREAM_PLAYBACK
+ * @param sample_rate in: requested sample rate;
+ *                    out: actually selected sample rate
+ * @param channels number of channels
+ * @param codec_id in: requested CodecID or CODEC_ID_NONE;
+ *                 out: actually selected CodecID, changed only if
+ *                 CODEC_ID_NONE was requested
+ *
+ * @return 0 if OK, AVERROR_xxx on error
+ */
+int ff_alsa_open(AVFormatContext *s, int mode, unsigned int *sample_rate,
+                 int channels, int *codec_id);
+
+/**
+ * Closes the ALSA PCM.
+ *
+ * @param s1 media file handle
+ *
+ * @return 0
+ */
+int ff_alsa_close(AVFormatContext *s1);
+
+/**
+ * Tries to recover from ALSA buffer underrun.
+ *
+ * @param s1 media file handle
+ * @param err error code reported by the previous ALSA call
+ *
+ * @return 0 if OK, AVERROR_xxx on error
+ */
+int ff_alsa_xrun_recover(AVFormatContext *s1, int err);
+
+#endif /* AVDEVICE_ALSA_AUDIO_H */
diff --git a/libavdevice/beosaudio.cpp b/libavdevice/beosaudio.cpp
index 84e7c77..53edefe 100644
--- a/libavdevice/beosaudio.cpp
+++ b/libavdevice/beosaudio.cpp
@@ -1,6 +1,6 @@
 /*
  * BeOS audio play interface
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavdevice/bktr.c b/libavdevice/bktr.c
index 86590d0..e7321f5 100644
--- a/libavdevice/bktr.c
+++ b/libavdevice/bktr.c
@@ -3,7 +3,7 @@
  * Copyright (c) 2002 Steve O'Hara-Smith
  * based on
  *           Linux video grab interface
- *           Copyright (c) 2000,2001 Gerard Lantau.
+ *           Copyright (c) 2000,2001 Gerard Lantau
  * and
  *           simple_grab.c Copyright (c) 1999 Roger Hardiman
  *
diff --git a/libavdevice/audio.c b/libavdevice/oss_audio.c
similarity index 92%
rename from libavdevice/audio.c
rename to libavdevice/oss_audio.c
index 4344ecb..8f3e678 100644
--- a/libavdevice/audio.c
+++ b/libavdevice/oss_audio.c
@@ -1,6 +1,6 @@
 /*
  * Linux audio play and grab interface
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
@@ -53,8 +53,9 @@ typedef struct {
     int buffer_ptr;
 } AudioData;
 
-static int audio_open(AudioData *s, int is_output, const char *audio_device)
+static int audio_open(AVFormatContext *s1, int is_output, const char *audio_device)
 {
+    AudioData *s = s1->priv_data;
     int audio_fd;
     int tmp, err;
     char *flip = getenv("AUDIO_FLIP_LEFT");
@@ -64,7 +65,7 @@ static int audio_open(AudioData *s, int is_output, const char *audio_device)
     else
         audio_fd = open(audio_device, O_RDONLY);
     if (audio_fd < 0) {
-        av_log(NULL, AV_LOG_ERROR, "%s: %s\n", audio_device, strerror(errno));
+        av_log(s1, AV_LOG_ERROR, "%s: %s\n", audio_device, strerror(errno));
         return AVERROR(EIO);
     }
 
@@ -114,27 +115,27 @@ static int audio_open(AudioData *s, int is_output, const char *audio_device)
         s->codec_id = CODEC_ID_PCM_S16BE;
         break;
     default:
-        av_log(NULL, AV_LOG_ERROR, "Soundcard does not support 16 bit sample format\n");
+        av_log(s1, AV_LOG_ERROR, "Soundcard does not support 16 bit sample format\n");
         close(audio_fd);
         return AVERROR(EIO);
     }
     err=ioctl(audio_fd, SNDCTL_DSP_SETFMT, &tmp);
     if (err < 0) {
-        av_log(NULL, AV_LOG_ERROR, "SNDCTL_DSP_SETFMT: %s\n", strerror(errno));
+        av_log(s1, AV_LOG_ERROR, "SNDCTL_DSP_SETFMT: %s\n", strerror(errno));
         goto fail;
     }
 
     tmp = (s->channels == 2);
     err = ioctl(audio_fd, SNDCTL_DSP_STEREO, &tmp);
     if (err < 0) {
-        av_log(NULL, AV_LOG_ERROR, "SNDCTL_DSP_STEREO: %s\n", strerror(errno));
+        av_log(s1, AV_LOG_ERROR, "SNDCTL_DSP_STEREO: %s\n", strerror(errno));
         goto fail;
     }
 
     tmp = s->sample_rate;
     err = ioctl(audio_fd, SNDCTL_DSP_SPEED, &tmp);
     if (err < 0) {
-        av_log(NULL, AV_LOG_ERROR, "SNDCTL_DSP_SPEED: %s\n", strerror(errno));
+        av_log(s1, AV_LOG_ERROR, "SNDCTL_DSP_SPEED: %s\n", strerror(errno));
         goto fail;
     }
     s->sample_rate = tmp; /* store real sample rate */
@@ -162,7 +163,7 @@ static int audio_write_header(AVFormatContext *s1)
     st = s1->streams[0];
     s->sample_rate = st->codec->sample_rate;
     s->channels = st->codec->channels;
-    ret = audio_open(s, 1, s1->filename);
+    ret = audio_open(s1, 1, s1->filename);
     if (ret < 0) {
         return AVERROR(EIO);
     } else {
@@ -225,7 +226,7 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap)
     s->sample_rate = ap->sample_rate;
     s->channels = ap->channels;
 
-    ret = audio_open(s, 0, s1->filename);
+    ret = audio_open(s1, 0, s1->filename);
     if (ret < 0) {
         av_free(st);
         return AVERROR(EIO);
diff --git a/libavdevice/v4l.c b/libavdevice/v4l.c
index c2c67d0..3382cdb 100644
--- a/libavdevice/v4l.c
+++ b/libavdevice/v4l.c
@@ -1,6 +1,6 @@
 /*
  * Linux video grab interface
- * Copyright (c) 2000,2001 Fabrice Bellard.
+ * Copyright (c) 2000,2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavdevice/v4l2.c b/libavdevice/v4l2.c
index e6e142a..b5f7db2 100644
--- a/libavdevice/v4l2.c
+++ b/libavdevice/v4l2.c
@@ -1,7 +1,7 @@
 /*
  * Video4Linux2 grab interface
- * Copyright (c) 2000,2001 Fabrice Bellard.
- * Copyright (c) 2006 Luca Abeni.
+ * Copyright (c) 2000,2001 Fabrice Bellard
+ * Copyright (c) 2006 Luca Abeni
  *
  * Part of this file is based on the V4L2 video capture example
  * (http://v4l2spec.bytesex.org/v4l2spec/capture.c)
diff --git a/libavdevice/vfwcap.c b/libavdevice/vfwcap.c
index 83e499c..4b6f73b 100644
--- a/libavdevice/vfwcap.c
+++ b/libavdevice/vfwcap.c
@@ -1,6 +1,6 @@
 /*
  * VFW capture interface
- * Copyright (c) 2006-2008 Ramiro Polla.
+ * Copyright (c) 2006-2008 Ramiro Polla
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h
index f0d221c..61ce1ad 100644
--- a/libavfilter/avfilter.h
+++ b/libavfilter/avfilter.h
@@ -23,7 +23,7 @@
 #define AVFILTER_AVFILTER_H
 
 #define LIBAVFILTER_VERSION_MAJOR  0
-#define LIBAVFILTER_VERSION_MINOR  2
+#define LIBAVFILTER_VERSION_MINOR  3
 #define LIBAVFILTER_VERSION_MICRO  0
 
 #define LIBAVFILTER_VERSION_INT AV_VERSION_INT(LIBAVFILTER_VERSION_MAJOR, \
diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c
index ccb275c..72c0fd2 100644
--- a/libavfilter/avfiltergraph.c
+++ b/libavfilter/avfiltergraph.c
@@ -46,6 +46,36 @@ int avfilter_graph_add_filter(AVFilterGraph *graph, AVFilterContext *filter)
     return 0;
 }
 
+int avfilter_graph_check_validity(AVFilterGraph *graph, AVClass *log_ctx)
+{
+    AVFilterContext *filt;
+    int i, j;
+
+    for (i=0; i < graph->filter_count; i++) {
+        filt = graph->filters[i];
+
+        for (j = 0; j < filt->input_count; j++) {
+            if (!filt->inputs[j] || !filt->inputs[j]->src) {
+                av_log(log_ctx, AV_LOG_ERROR,
+                       "Input pad \"%s\" for the filter \"%s\" of type \"%s\" not connected to any source\n",
+                       filt->input_pads[j].name, filt->name, filt->filter->name);
+                return -1;
+            }
+        }
+
+        for (j = 0; j < filt->output_count; j++) {
+            if (!filt->outputs[j] || !filt->outputs[j]->dst) {
+                av_log(log_ctx, AV_LOG_ERROR,
+                       "Output pad \"%s\" for the filter \"%s\" of type \"%s\" not connected to any destination\n",
+                       filt->output_pads[j].name, filt->name, filt->filter->name);
+                return -1;
+            }
+        }
+    }
+
+    return 0;
+}
+
 AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, char *name)
 {
     int i;
diff --git a/libavfilter/avfiltergraph.h b/libavfilter/avfiltergraph.h
index dee8a90..716d919 100644
--- a/libavfilter/avfiltergraph.h
+++ b/libavfilter/avfiltergraph.h
@@ -45,6 +45,16 @@ AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, char *name);
 int avfilter_graph_add_filter(AVFilterGraph *graphctx, AVFilterContext *filter);
 
 /**
+ * Check for the validity of \p graph.
+ *
+ * A graph is considered valid if all its input and output pads are
+ * connected.
+ *
+ * @return 0 in case of success, a negative value otherwise
+ */
+int avfilter_graph_check_validity(AVFilterGraph *graphctx, AVClass *log_ctx);
+
+/**
  * Configure the formats of all the links in the graph.
  */
 int avfilter_graph_config_formats(AVFilterGraph *graphctx);
diff --git a/libavformat/4xm.c b/libavformat/4xm.c
index c792a77..513f518 100644
--- a/libavformat/4xm.c
+++ b/libavformat/4xm.c
@@ -66,6 +66,7 @@ typedef struct AudioTrack {
     int channels;
     int stream_index;
     int adpcm;
+    int64_t audio_pts;
 } AudioTrack;
 
 typedef struct FourxmDemuxContext {
@@ -74,9 +75,7 @@ typedef struct FourxmDemuxContext {
     int video_stream_index;
     int track_count;
     AudioTrack *tracks;
-    int selected_track;
 
-    int64_t audio_pts;
     int64_t video_pts;
     float fps;
 } FourxmDemuxContext;
@@ -99,13 +98,11 @@ static int fourxm_read_header(AVFormatContext *s,
     int header_size;
     FourxmDemuxContext *fourxm = s->priv_data;
     unsigned char *header;
-    int i;
-    int current_track = -1;
+    int i, ret;
     AVStream *st;
 
     fourxm->track_count = 0;
     fourxm->tracks = NULL;
-    fourxm->selected_track = 0;
     fourxm->fps = 1.0;
 
     /* skip the first 3 32-bit numbers */
@@ -114,15 +111,17 @@ static int fourxm_read_header(AVFormatContext *s,
     /* check for LIST-HEAD */
     GET_LIST_HEADER();
     header_size = size - 4;
-    if (fourcc_tag != HEAD_TAG)
+    if (fourcc_tag != HEAD_TAG || header_size < 0)
         return AVERROR_INVALIDDATA;
 
     /* allocate space for the header and load the whole thing */
     header = av_malloc(header_size);
     if (!header)
         return AVERROR(ENOMEM);
-    if (get_buffer(pb, header, header_size) != header_size)
+    if (get_buffer(pb, header, header_size) != header_size){
+        av_free(header);
         return AVERROR(EIO);
+    }
 
     /* take the lazy approach and search for any and all vtrk and strk chunks */
     for (i = 0; i < header_size - 8; i++) {
@@ -134,16 +133,18 @@ static int fourxm_read_header(AVFormatContext *s,
         } else if (fourcc_tag == vtrk_TAG) {
             /* check that there is enough data */
             if (size != vtrk_SIZE) {
-                av_free(header);
-                return AVERROR_INVALIDDATA;
+                ret= AVERROR_INVALIDDATA;
+                goto fail;
             }
-            fourxm->width = AV_RL32(&header[i + 36]);
+            fourxm->width  = AV_RL32(&header[i + 36]);
             fourxm->height = AV_RL32(&header[i + 40]);
 
             /* allocate a new AVStream */
             st = av_new_stream(s, 0);
-            if (!st)
-                return AVERROR(ENOMEM);
+            if (!st){
+                ret= AVERROR(ENOMEM);
+                goto fail;
+            }
             av_set_pts_info(st, 60, 1, fourxm->fps);
 
             fourxm->video_stream_index = st->index;
@@ -153,38 +154,44 @@ static int fourxm_read_header(AVFormatContext *s,
             st->codec->extradata_size = 4;
             st->codec->extradata = av_malloc(4);
             AV_WL32(st->codec->extradata, AV_RL32(&header[i + 16]));
-            st->codec->width = fourxm->width;
+            st->codec->width  = fourxm->width;
             st->codec->height = fourxm->height;
 
             i += 8 + size;
         } else if (fourcc_tag == strk_TAG) {
+            int current_track;
             /* check that there is enough data */
             if (size != strk_SIZE) {
-                av_free(header);
-                return AVERROR_INVALIDDATA;
+                ret= AVERROR_INVALIDDATA;
+                goto fail;
             }
             current_track = AV_RL32(&header[i + 8]);
             if (current_track + 1 > fourxm->track_count) {
                 fourxm->track_count = current_track + 1;
-                if((unsigned)fourxm->track_count >= UINT_MAX / sizeof(AudioTrack))
-                    return -1;
+                if((unsigned)fourxm->track_count >= UINT_MAX / sizeof(AudioTrack)){
+                    ret= -1;
+                    goto fail;
+                }
                 fourxm->tracks = av_realloc(fourxm->tracks,
                     fourxm->track_count * sizeof(AudioTrack));
                 if (!fourxm->tracks) {
-                    av_free(header);
-                    return AVERROR(ENOMEM);
+                    ret=  AVERROR(ENOMEM);
+                    goto fail;
                 }
             }
-            fourxm->tracks[current_track].adpcm = AV_RL32(&header[i + 12]);
-            fourxm->tracks[current_track].channels = AV_RL32(&header[i + 36]);
+            fourxm->tracks[current_track].adpcm       = AV_RL32(&header[i + 12]);
+            fourxm->tracks[current_track].channels    = AV_RL32(&header[i + 36]);
             fourxm->tracks[current_track].sample_rate = AV_RL32(&header[i + 40]);
-            fourxm->tracks[current_track].bits = AV_RL32(&header[i + 44]);
+            fourxm->tracks[current_track].bits        = AV_RL32(&header[i + 44]);
+            fourxm->tracks[current_track].audio_pts   = 0;
             i += 8 + size;
 
             /* allocate a new AVStream */
             st = av_new_stream(s, current_track);
-            if (!st)
-                return AVERROR(ENOMEM);
+            if (!st){
+                ret= AVERROR(ENOMEM);
+                goto fail;
+            }
 
             av_set_pts_info(st, 60, 1, fourxm->tracks[current_track].sample_rate);
 
@@ -192,33 +199,37 @@ static int fourxm_read_header(AVFormatContext *s,
 
             st->codec->codec_type = CODEC_TYPE_AUDIO;
             st->codec->codec_tag = 0;
-            st->codec->channels = fourxm->tracks[current_track].channels;
-            st->codec->sample_rate = fourxm->tracks[current_track].sample_rate;
+            st->codec->channels              = fourxm->tracks[current_track].channels;
+            st->codec->sample_rate           = fourxm->tracks[current_track].sample_rate;
             st->codec->bits_per_coded_sample = fourxm->tracks[current_track].bits;
-            st->codec->bit_rate = st->codec->channels * st->codec->sample_rate *
+            st->codec->bit_rate              = st->codec->channels * st->codec->sample_rate *
                 st->codec->bits_per_coded_sample;
             st->codec->block_align = st->codec->channels * st->codec->bits_per_coded_sample;
-            if (fourxm->tracks[current_track].adpcm)
+            if (fourxm->tracks[current_track].adpcm){
                 st->codec->codec_id = CODEC_ID_ADPCM_4XM;
-            else if (st->codec->bits_per_coded_sample == 8)
+            }else if (st->codec->bits_per_coded_sample == 8){
                 st->codec->codec_id = CODEC_ID_PCM_U8;
-            else
+            }else
                 st->codec->codec_id = CODEC_ID_PCM_S16LE;
         }
     }
 
-    av_free(header);
-
     /* skip over the LIST-MOVI chunk (which is where the stream should be */
     GET_LIST_HEADER();
-    if (fourcc_tag != MOVI_TAG)
-        return AVERROR_INVALIDDATA;
+    if (fourcc_tag != MOVI_TAG){
+        ret= AVERROR_INVALIDDATA;
+        goto fail;
+    }
 
+    av_free(header);
     /* initialize context members */
     fourxm->video_pts = -1;  /* first frame will push to 0 */
-    fourxm->audio_pts = 0;
 
     return 0;
+fail:
+    av_freep(&fourxm->tracks);
+    av_free(header);
+    return ret;
 }
 
 static int fourxm_read_packet(AVFormatContext *s,
@@ -229,7 +240,7 @@ static int fourxm_read_packet(AVFormatContext *s,
     unsigned int fourcc_tag;
     unsigned int size, out_size;
     int ret = 0;
-    int track_number;
+    unsigned int track_number;
     int packet_read = 0;
     unsigned char header[8];
     int audio_frame_count;
@@ -258,8 +269,6 @@ static int fourxm_read_packet(AVFormatContext *s,
         case ifr2_TAG:
         case pfr2_TAG:
         case cfr2_TAG:
-        {
-
             /* allocate 8 more bytes than 'size' to account for fourcc
              * and size */
             if (size + 8 < size || av_new_packet(pkt, size + 8))
@@ -270,40 +279,39 @@ static int fourxm_read_packet(AVFormatContext *s,
             memcpy(pkt->data, header, 8);
             ret = get_buffer(s->pb, &pkt->data[8], size);
 
-            if (ret < 0)
+            if (ret < 0){
                 av_free_packet(pkt);
-            else
+            }else
                 packet_read = 1;
             break;
-        }
 
         case snd__TAG:
             track_number = get_le32(pb);
             out_size= get_le32(pb);
             size-=8;
 
-            if (track_number == fourxm->selected_track) {
+            if (track_number < fourxm->track_count) {
                 ret= av_get_packet(s->pb, pkt, size);
                 if(ret<0)
                     return AVERROR(EIO);
                 pkt->stream_index =
-                    fourxm->tracks[fourxm->selected_track].stream_index;
-                pkt->pts = fourxm->audio_pts;
+                    fourxm->tracks[track_number].stream_index;
+                pkt->pts = fourxm->tracks[track_number].audio_pts;
                 packet_read = 1;
 
                 /* pts accounting */
                 audio_frame_count = size;
-                if (fourxm->tracks[fourxm->selected_track].adpcm)
+                if (fourxm->tracks[track_number].adpcm)
                     audio_frame_count -=
-                        2 * (fourxm->tracks[fourxm->selected_track].channels);
+                        2 * (fourxm->tracks[track_number].channels);
                 audio_frame_count /=
-                      fourxm->tracks[fourxm->selected_track].channels;
-                if (fourxm->tracks[fourxm->selected_track].adpcm)
+                      fourxm->tracks[track_number].channels;
+                if (fourxm->tracks[track_number].adpcm){
                     audio_frame_count *= 2;
-                else
+                }else
                     audio_frame_count /=
-                    (fourxm->tracks[fourxm->selected_track].bits / 8);
-                fourxm->audio_pts += audio_frame_count;
+                    (fourxm->tracks[track_number].bits / 8);
+                fourxm->tracks[track_number].audio_pts += audio_frame_count;
 
             } else {
                 url_fseek(pb, size, SEEK_CUR);
@@ -322,7 +330,7 @@ static int fourxm_read_close(AVFormatContext *s)
 {
     FourxmDemuxContext *fourxm = s->priv_data;
 
-    av_free(fourxm->tracks);
+    av_freep(&fourxm->tracks);
 
     return 0;
 }
diff --git a/libavformat/Makefile b/libavformat/Makefile
index 231afbb..e16a5ea 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -8,7 +8,7 @@ HEADERS = avformat.h avio.h rtsp.h rtspcodes.h
 OBJS = allformats.o cutils.o metadata.o metadata_compat.o options.o os_support.o sdp.o utils.o
 
 # muxers/demuxers
-OBJS-$(CONFIG_AAC_DEMUXER)               += raw.o
+OBJS-$(CONFIG_AAC_DEMUXER)               += raw.o id3v2.o
 OBJS-$(CONFIG_AC3_DEMUXER)               += raw.o
 OBJS-$(CONFIG_AC3_MUXER)                 += raw.o
 OBJS-$(CONFIG_ADTS_MUXER)                += adtsenc.o
@@ -97,7 +97,7 @@ OBJS-$(CONFIG_MP2_MUXER)                 += mp3.o
 OBJS-$(CONFIG_MP3_DEMUXER)               += mp3.o id3v2.o
 OBJS-$(CONFIG_MP3_MUXER)                 += mp3.o
 OBJS-$(CONFIG_MP4_MUXER)                 += movenc.o riff.o isom.o avc.o
-OBJS-$(CONFIG_MPC_DEMUXER)               += mpc.o
+OBJS-$(CONFIG_MPC_DEMUXER)               += mpc.o id3v2.o
 OBJS-$(CONFIG_MPC8_DEMUXER)              += mpc8.o
 OBJS-$(CONFIG_MPEG1SYSTEM_MUXER)         += mpegenc.o
 OBJS-$(CONFIG_MPEG1VCD_MUXER)            += mpegenc.o
@@ -149,6 +149,7 @@ OBJS-$(CONFIG_PCM_U8_DEMUXER)            += raw.o
 OBJS-$(CONFIG_PCM_U8_MUXER)              += raw.o
 OBJS-$(CONFIG_PSP_MUXER)                 += movenc.o riff.o isom.o avc.o
 OBJS-$(CONFIG_PVA_DEMUXER)               += pva.o
+OBJS-$(CONFIG_R3D_DEMUXER)               += r3d.o
 OBJS-$(CONFIG_RAWVIDEO_DEMUXER)          += raw.o
 OBJS-$(CONFIG_RAWVIDEO_MUXER)            += raw.o
 OBJS-$(CONFIG_REDIR_DEMUXER)             += rtsp.o
diff --git a/libavformat/allformats.c b/libavformat/allformats.c
index c7c0cc8..a8183c2 100644
--- a/libavformat/allformats.c
+++ b/libavformat/allformats.c
@@ -19,7 +19,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include "avformat.h"
-#include "rtp_internal.h"
+#include "rtp.h"
 #include "rdt.h"
 
 #define REGISTER_MUXER(X,x) { \
@@ -36,12 +36,6 @@
     extern URLProtocol x##_protocol; \
     if(CONFIG_##X##_PROTOCOL) register_protocol(&x##_protocol); }
 
-/* If you do not call this function, then you can select exactly which
-   formats you want to support */
-
-/**
- * Initialize libavformat and register all the (de)muxers and protocols.
- */
 void av_register_all(void)
 {
     static int initialized;
@@ -160,6 +154,7 @@ void av_register_all(void)
     REGISTER_MUXDEMUX (PCM_U8,    pcm_u8);
     REGISTER_MUXER    (PSP, psp);
     REGISTER_DEMUXER  (PVA, pva);
+    REGISTER_DEMUXER  (R3D, r3d);
     REGISTER_MUXDEMUX (RAWVIDEO, rawvideo);
     REGISTER_DEMUXER  (REDIR, redir);
     REGISTER_DEMUXER  (RL2, rl2);
diff --git a/libavformat/asf-enc.c b/libavformat/asf-enc.c
index 94d208f..64c5200 100644
--- a/libavformat/asf-enc.c
+++ b/libavformat/asf-enc.c
@@ -1,6 +1,6 @@
 /*
  * ASF muxer
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/asf.c b/libavformat/asf.c
index 33cde4c..d0afa56 100644
--- a/libavformat/asf.c
+++ b/libavformat/asf.c
@@ -1,6 +1,6 @@
 /*
  * ASF compatible demuxer
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/asf.h b/libavformat/asf.h
index afb015e..40fb3a2 100644
--- a/libavformat/asf.h
+++ b/libavformat/asf.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/au.c b/libavformat/au.c
index caa7f4d..0d2cc8a 100644
--- a/libavformat/au.c
+++ b/libavformat/au.c
@@ -1,6 +1,6 @@
 /*
  * AU muxer and demuxer
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 1bd67b6..74ffc7d 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -22,8 +22,8 @@
 #define AVFORMAT_AVFORMAT_H
 
 #define LIBAVFORMAT_VERSION_MAJOR 52
-#define LIBAVFORMAT_VERSION_MINOR 24
-#define LIBAVFORMAT_VERSION_MICRO  1
+#define LIBAVFORMAT_VERSION_MINOR 25
+#define LIBAVFORMAT_VERSION_MICRO  0
 
 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                LIBAVFORMAT_VERSION_MINOR, \
@@ -49,6 +49,7 @@ unsigned avformat_version(void);
 
 /*
  * Public Metadata API.
+ * !!WARNING!! This is a work in progress. Don't use outside FFmpeg for now.
  * The metadata API allows libavformat to export metadata tags to a client
  * application using a sequence of key/value pairs.
  * Important concepts to keep in mind:
@@ -487,6 +488,11 @@ typedef struct AVStream {
     AVRational sample_aspect_ratio;
 
     AVMetadata *metadata;
+
+    /* av_read_frame() support */
+    const uint8_t *cur_ptr;
+    int cur_len;
+    AVPacket cur_pkt;
 } AVStream;
 
 #define AV_PROGRAM_RUNNING 1
@@ -573,9 +579,11 @@ typedef struct AVFormatContext {
 
     /* av_read_frame() support */
     AVStream *cur_st;
-    const uint8_t *cur_ptr;
-    int cur_len;
-    AVPacket cur_pkt;
+#if LIBAVFORMAT_VERSION_INT < (53<<16)
+    const uint8_t *cur_ptr_deprecated;
+    int cur_len_deprecated;
+    AVPacket cur_pkt_deprecated;
+#endif
 
     /* av_seek_frame() support */
     int64_t data_offset; /** offset of the first packet */
@@ -750,6 +758,15 @@ void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
  */
 void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload);
 
+/**
+ * Initialize libavformat and register all the muxers, demuxers and
+ * protocols. If you do not call this function, then you can select
+ * exactly which formats you want to support.
+ *
+ * @see av_register_input_format()
+ * @see av_register_output_format()
+ * @see register_protocol()
+ */
 void av_register_all(void);
 
 /** codec tag <-> codec id */
diff --git a/libavformat/avienc.c b/libavformat/avienc.c
index 7c8a1bb..4e8c2f5 100644
--- a/libavformat/avienc.c
+++ b/libavformat/avienc.c
@@ -1,6 +1,6 @@
 /*
  * AVI muxer
- * Copyright (c) 2000 Fabrice Bellard.
+ * Copyright (c) 2000 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/crcenc.c b/libavformat/crcenc.c
index a709c95..b343464 100644
--- a/libavformat/crcenc.c
+++ b/libavformat/crcenc.c
@@ -1,6 +1,6 @@
 /*
  * CRC encoder (for codec/format testing)
- * Copyright (c) 2002 Fabrice Bellard.
+ * Copyright (c) 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/dv.c b/libavformat/dv.c
index eb02e3b..fa529f6 100644
--- a/libavformat/dv.c
+++ b/libavformat/dv.c
@@ -6,7 +6,7 @@
  * of DV technical info.
  *
  * Raw DV format
- * Copyright (c) 2002 Fabrice Bellard.
+ * Copyright (c) 2002 Fabrice Bellard
  *
  * 50 Mbps (DVCPRO50) and 100 Mbps (DVCPRO HD) support
  * Copyright (c) 2006 Daniel Maas <dmaas at maasdigital.com>
diff --git a/libavformat/dv.h b/libavformat/dv.h
index 6bfb4ab..ae16bef 100644
--- a/libavformat/dv.h
+++ b/libavformat/dv.h
@@ -6,7 +6,7 @@
  * of DV technical info.
  *
  * Raw DV format
- * Copyright (c) 2002 Fabrice Bellard.
+ * Copyright (c) 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/dvenc.c b/libavformat/dvenc.c
index 428d4a0..4551cd5 100644
--- a/libavformat/dvenc.c
+++ b/libavformat/dvenc.c
@@ -6,7 +6,7 @@
  * of DV technical info.
  *
  * Raw DV format
- * Copyright (c) 2002 Fabrice Bellard.
+ * Copyright (c) 2002 Fabrice Bellard
  *
  * 50 Mbps (DVCPRO50) support
  * Copyright (c) 2006 Daniel Maas <dmaas at maasdigital.com>
diff --git a/libavformat/dxa.c b/libavformat/dxa.c
index 1ff44cf..35b9fe2 100644
--- a/libavformat/dxa.c
+++ b/libavformat/dxa.c
@@ -1,6 +1,6 @@
 /*
  * DXA demuxer
- * Copyright (c) 2007 Konstantin Shishkov.
+ * Copyright (c) 2007 Konstantin Shishkov
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/ffm.h b/libavformat/ffm.h
index 4a52c40..05d6eb1 100644
--- a/libavformat/ffm.h
+++ b/libavformat/ffm.h
@@ -1,6 +1,6 @@
 /*
  * FFM (ffserver live feed) common header
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/ffmdec.c b/libavformat/ffmdec.c
index e5d98f1..03b7bd8 100644
--- a/libavformat/ffmdec.c
+++ b/libavformat/ffmdec.c
@@ -1,6 +1,6 @@
 /*
  * FFM (ffserver live feed) demuxer
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/ffmenc.c b/libavformat/ffmenc.c
index 4bb28e2..9a55264 100644
--- a/libavformat/ffmenc.c
+++ b/libavformat/ffmenc.c
@@ -1,6 +1,6 @@
 /*
  * FFM (ffserver live feed) muxer
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/flv.h b/libavformat/flv.h
index 89d0d10..c2a037b 100644
--- a/libavformat/flv.h
+++ b/libavformat/flv.h
@@ -2,7 +2,7 @@
  * @file flv.h
  * FLV common header
  *
- * Copyright (c) 2006 The FFmpeg Project.
+ * Copyright (c) 2006 The FFmpeg Project
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 01da9e8..ec9b471 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -1,6 +1,6 @@
 /*
  * FLV demuxer
- * Copyright (c) 2003 The FFmpeg Project.
+ * Copyright (c) 2003 The FFmpeg Project
  *
  * This demuxer will generate a 1 byte extradata for VP6F content.
  * It is composed of:
@@ -309,7 +309,6 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
     int64_t dts, pts = AV_NOPTS_VALUE;
     AVStream *st = NULL;
 
- retry:
  for(;;){
     pos = url_ftell(s->pb);
     url_fskip(s->pb, 4); /* size of previous packet */
@@ -345,7 +344,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
             av_log(s, AV_LOG_ERROR, "skipping flv packet: type %d, size %d, flags %d\n", type, size, flags);
     skip:
         url_fseek(s->pb, next, SEEK_SET);
-        continue;
+        return AVERROR(EAGAIN);
     }
 
     /* skip empty data packets */
@@ -369,7 +368,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
        || st->discard >= AVDISCARD_ALL
        ){
         url_fseek(s->pb, next, SEEK_SET);
-        continue;
+        return AVERROR(EAGAIN);
     }
     if ((flags & FLV_VIDEO_FRAMETYPE_MASK) == FLV_FRAME_KEY)
         av_add_index_entry(st, pos, dts, size, 0, AVINDEX_KEYFRAME);
@@ -420,7 +419,7 @@ static int flv_read_packet(AVFormatContext *s, AVPacket *pkt)
         if (type == 0) {
             if ((ret = flv_get_extradata(s, st, size)) < 0)
                 return ret;
-            goto retry;
+            return AVERROR(EAGAIN);
         }
     }
 
diff --git a/libavformat/flvenc.c b/libavformat/flvenc.c
index 3b63eca..1f0ea5c 100644
--- a/libavformat/flvenc.c
+++ b/libavformat/flvenc.c
@@ -1,6 +1,6 @@
 /*
  * FLV muxer
- * Copyright (c) 2003 The FFmpeg Project.
+ * Copyright (c) 2003 The FFmpeg Project
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/framecrcenc.c b/libavformat/framecrcenc.c
index beb1bde..f59a0c8 100644
--- a/libavformat/framecrcenc.c
+++ b/libavformat/framecrcenc.c
@@ -1,6 +1,6 @@
 /*
  * frame CRC encoder (for codec/format testing)
- * Copyright (c) 2002 Fabrice Bellard.
+ * Copyright (c) 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/framehook.c b/libavformat/framehook.c
index 8dba5bc..494b30b 100644
--- a/libavformat/framehook.c
+++ b/libavformat/framehook.c
@@ -1,6 +1,6 @@
 /*
  * Video processing hooks
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/gif.c b/libavformat/gif.c
index 827570c..0cda974 100644
--- a/libavformat/gif.c
+++ b/libavformat/gif.c
@@ -1,6 +1,6 @@
 /*
  * Animated GIF muxer
- * Copyright (c) 2000 Fabrice Bellard.
+ * Copyright (c) 2000 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/gxf.c b/libavformat/gxf.c
index 30cb4f7..d7aaabf 100644
--- a/libavformat/gxf.c
+++ b/libavformat/gxf.c
@@ -1,6 +1,6 @@
 /*
  * GXF demuxer.
- * Copyright (c) 2006 Reimar Doeffinger.
+ * Copyright (c) 2006 Reimar Doeffinger
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/gxfenc.c b/libavformat/gxfenc.c
index 396555a..dd2d76e 100644
--- a/libavformat/gxfenc.c
+++ b/libavformat/gxfenc.c
@@ -1,6 +1,6 @@
 /*
  * GXF muxer.
- * Copyright (c) 2006 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>.
+ * Copyright (c) 2006 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>
  *
  * This file is part of FFmpeg.
  *
@@ -169,7 +169,7 @@ static void gxf_write_packet_header(ByteIOContext *pb, GXFPktType type)
 static int gxf_write_mpeg_auxiliary(ByteIOContext *pb, GXFStreamContext *ctx)
 {
     char buffer[1024];
-    int size;
+    int size, starting_line;
 
     if (ctx->iframes) {
         ctx->p_per_gop = ctx->pframes / ctx->iframes;
@@ -182,11 +182,18 @@ static int gxf_write_mpeg_auxiliary(ByteIOContext *pb, GXFStreamContext *ctx)
         if (ctx->b_per_gop > 9)
             ctx->b_per_gop = 9; /* ensure value won't take more than one char */
     }
+    if (ctx->codec->height == 512 || ctx->codec->height == 608)
+        starting_line = 7; // VBI
+    else if (ctx->codec->height == 480)
+        starting_line = 20;
+    else
+        starting_line = 23; // default PAL
+
     size = snprintf(buffer, 1024, "Ver 1\nBr %.6f\nIpg 1\nPpi %d\nBpiop %d\n"
-                    "Pix 0\nCf %d\nCg %d\nSl 7\nnl16 %d\nVi 1\nf1 1\n",
+                    "Pix 0\nCf %d\nCg %d\nSl %d\nnl16 %d\nVi 1\nf1 1\n",
                     (float)ctx->codec->bit_rate, ctx->p_per_gop, ctx->b_per_gop,
                     ctx->codec->pix_fmt == PIX_FMT_YUV422P ? 2 : 1, ctx->first_gop_closed == 1,
-                    ctx->codec->height / 16);
+                    starting_line, ctx->codec->height / 16);
     put_byte(pb, TRACK_MPG_AUX);
     put_byte(pb, size + 1);
     put_buffer(pb, (uint8_t *)buffer, size + 1);
@@ -353,13 +360,20 @@ static int gxf_write_flt_packet(ByteIOContext *pb, GXFContext *ctx)
 
 static int gxf_write_umf_material_description(ByteIOContext *pb, GXFContext *ctx)
 {
+    // XXX drop frame
+    uint32_t timecode =
+        ctx->nb_frames / ctx->sample_rate * 3600 % 24 << 27 | // hours
+        ctx->nb_frames / ctx->sample_rate * 60 % 60   << 16 | // minutes
+        ctx->nb_frames / ctx->sample_rate % 60        <<  8 | // seconds
+        ctx->nb_frames % ctx->sample_rate;                    // fields
+
     put_le32(pb, ctx->flags);
     put_le32(pb, ctx->nb_frames); /* length of the longest track */
     put_le32(pb, ctx->nb_frames); /* length of the shortest track */
     put_le32(pb, 0); /* mark in */
     put_le32(pb, ctx->nb_frames); /* mark out */
     put_le32(pb, 0); /* timecode mark in */
-    put_le32(pb, ctx->nb_frames); /* timecode mark out */
+    put_le32(pb, timecode); /* timecode mark out */
     put_le64(pb, ctx->fc->timestamp); /* modification time */
     put_le64(pb, ctx->fc->timestamp); /* creation time */
     put_le16(pb, 0); /* reserved */
@@ -677,11 +691,8 @@ static int gxf_write_trailer(AVFormatContext *s)
     int i;
 
     for (i = 0; i < s->nb_streams; ++i) {
-        if (s->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO) {
+        if (s->streams[i]->codec->codec_type == CODEC_TYPE_AUDIO)
             av_fifo_free(&gxf->streams[i].audio_buffer);
-        } else if (s->streams[i]->codec->codec_type == CODEC_TYPE_VIDEO) {
-            gxf->nb_frames = 2 * s->streams[i]->codec->frame_number;
-        }
     }
 
     gxf_write_eos_packet(pb, gxf);
@@ -756,6 +767,10 @@ static int gxf_write_media_packet(ByteIOContext *pb, GXFContext *ctx, AVPacket *
     gxf_write_media_preamble(pb, ctx, pkt, pkt->size + padding);
     put_buffer(pb, pkt->data, pkt->size);
     gxf_write_padding(pb, padding);
+
+    if (sc->codec->codec_type == CODEC_TYPE_VIDEO)
+        ctx->nb_frames += 2; // count fields
+
     return updatePacketSize(pb, pos);
 }
 
diff --git a/libavformat/http.c b/libavformat/http.c
index 6b3004d..2e6a1db 100644
--- a/libavformat/http.c
+++ b/libavformat/http.c
@@ -1,6 +1,6 @@
 /*
  * HTTP protocol for ffmpeg client
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/id3v2.c b/libavformat/id3v2.c
index c27443b..018fd51 100644
--- a/libavformat/id3v2.c
+++ b/libavformat/id3v2.c
@@ -33,3 +33,15 @@ int ff_id3v2_match(const uint8_t *buf)
             (buf[8] & 0x80) == 0 &&
             (buf[9] & 0x80) == 0;
 }
+
+int ff_id3v2_tag_len(const uint8_t * buf)
+{
+    int len = ((buf[6] & 0x7f) << 21) +
+        ((buf[7] & 0x7f) << 14) +
+        ((buf[8] & 0x7f) << 7) +
+        (buf[9] & 0x7f) +
+        ID3v2_HEADER_SIZE;
+    if (buf[5] & 0x10)
+        len += ID3v2_HEADER_SIZE;
+    return len;
+}
diff --git a/libavformat/id3v2.h b/libavformat/id3v2.h
index f54e290..6d62f11 100644
--- a/libavformat/id3v2.h
+++ b/libavformat/id3v2.h
@@ -32,4 +32,11 @@
  */
 int ff_id3v2_match(const uint8_t *buf);
 
+/**
+ * Gets the length of an ID3v2 tag.
+ * @buf must be ID3v2_HEADER_SIZE bytes long and point to the start of an
+ * already detected ID3v2 tag
+ */
+int ff_id3v2_tag_len(const uint8_t *buf);
+
 #endif /* AVFORMAT_ID3V2_H */
diff --git a/libavformat/img2.c b/libavformat/img2.c
index 7e17794..113f431 100644
--- a/libavformat/img2.c
+++ b/libavformat/img2.c
@@ -1,6 +1,6 @@
 /*
  * Image format
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
+ * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
  * Copyright (c) 2004 Michael Niedermayer
  *
  * This file is part of FFmpeg.
diff --git a/libavformat/isom.c b/libavformat/isom.c
index b5e09c5..39c58c6 100644
--- a/libavformat/isom.c
+++ b/libavformat/isom.c
@@ -1,6 +1,6 @@
 /*
  * ISO Media common code
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  * Copyright (c) 2002 Francois Revol <revol at free.fr>
  * Copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier at free.fr>
  *
@@ -274,7 +274,7 @@ int ff_mov_iso639_to_lang(const char *lang, int mp4)
     return code;
 }
 
-int ff_mov_lang_to_iso639(int code, char *to)
+int ff_mov_lang_to_iso639(unsigned code, char *to)
 {
     int i;
     /* is it the mangled iso code? */
diff --git a/libavformat/isom.h b/libavformat/isom.h
index 64bde46..2cad5b8 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -1,6 +1,6 @@
 /*
  * ISO Media common code
- * copyright (c) 2001 Fabrice Bellard.
+ * copyright (c) 2001 Fabrice Bellard
  * copyright (c) 2002 Francois Revol <revol at free.fr>
  * copyright (c) 2006 Baptiste Coudurier <baptiste.coudurier at free.fr>
  *
@@ -33,7 +33,7 @@ extern const AVCodecTag codec_movaudio_tags[];
 extern const AVCodecTag ff_codec_movsubtitle_tags[];
 
 int ff_mov_iso639_to_lang(const char *lang, int mp4);
-int ff_mov_lang_to_iso639(int code, char *to);
+int ff_mov_lang_to_iso639(unsigned code, char *to);
 
 typedef struct {
     int count;
diff --git a/libavformat/iss.c b/libavformat/iss.c
index 4a16318..0d24c96 100644
--- a/libavformat/iss.c
+++ b/libavformat/iss.c
@@ -51,6 +51,9 @@ static void get_token(ByteIOContext *s, char *buf, int maxlen)
             buf[i++] = c;
     }
 
+    if(!c)
+        get_byte(s);
+
     buf[i] = 0; /* Ensure null terminated, but may be truncated */
 }
 
@@ -109,8 +112,8 @@ static int iss_read_packet(AVFormatContext *s, AVPacket *pkt)
     IssDemuxContext *iss = s->priv_data;
     int ret = av_get_packet(s->pb, pkt, iss->packet_size);
 
-    if(ret < 0)
-        return ret;
+    if(ret != iss->packet_size)
+        return AVERROR(EIO);
 
     pkt->stream_index = 0;
     pkt->pts = url_ftell(s->pb) - iss->sample_start_pos;
diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c
index fdd2e21..07b1a5f 100644
--- a/libavformat/matroskaenc.c
+++ b/libavformat/matroskaenc.c
@@ -788,23 +788,25 @@ static void mkv_write_block(AVFormatContext *s, unsigned int blockid, AVPacket *
     MatroskaMuxContext *mkv = s->priv_data;
     ByteIOContext *pb = s->pb;
     AVCodecContext *codec = s->streams[pkt->stream_index]->codec;
+    uint8_t *data = NULL;
+    int size = pkt->size;
 
     av_log(s, AV_LOG_DEBUG, "Writing block at offset %" PRIu64 ", size %d, "
            "pts %" PRId64 ", dts %" PRId64 ", duration %d, flags %d\n",
            url_ftell(pb), pkt->size, pkt->pts, pkt->dts, pkt->duration, flags);
+    if (codec->codec_id == 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
+        data = pkt->data;
     put_ebml_id(pb, blockid);
-    put_ebml_num(pb, pkt->size+4, 0);
+    put_ebml_num(pb, size+4, 0);
     put_byte(pb, 0x80 | (pkt->stream_index + 1));     // this assumes stream_index is less than 126
     put_be16(pb, pkt->pts - mkv->cluster_pts);
     put_byte(pb, flags);
-    if (codec->codec_id == CODEC_ID_H264 &&
-        codec->extradata_size > 0 && AV_RB32(codec->extradata) == 0x00000001) {
-        /* from x264 or from bytestream h264 */
-        /* nal reformating needed */
-        ff_avc_parse_nal_units(pb, pkt->data, pkt->size);
-    } else {
-        put_buffer(pb, pkt->data, pkt->size);
-    }
+    put_buffer(pb, data, size);
+    if (data != pkt->data)
+        av_free(data);
 }
 
 static int mkv_write_packet(AVFormatContext *s, AVPacket *pkt)
diff --git a/libavformat/mov.c b/libavformat/mov.c
index b510d7c..5dd2ace 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1,6 +1,6 @@
 /*
  * MOV demuxer
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
@@ -439,10 +439,11 @@ static int mov_read_pasp(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
     const int den = get_be32(pb);
     AVStream * const st = c->fc->streams[c->fc->nb_streams-1];
     if (den != 0) {
-        if ((st->sample_aspect_ratio.den && den != st->sample_aspect_ratio.den) ||
-            (st->sample_aspect_ratio.num && num != st->sample_aspect_ratio.num))
+        if ((st->sample_aspect_ratio.den != 1 || st->sample_aspect_ratio.num) && // default
+            (den != st->sample_aspect_ratio.den || num != st->sample_aspect_ratio.num))
             av_log(c->fc, AV_LOG_WARNING,
-                   "sample aspect ratio already set, overriding by 'pasp' atom\n");
+                   "sample aspect ratio already set to %d:%d, overriding by 'pasp' atom\n",
+                   st->sample_aspect_ratio.num, st->sample_aspect_ratio.den);
         st->sample_aspect_ratio.num = num;
         st->sample_aspect_ratio.den = den;
     }
@@ -493,7 +494,7 @@ static int mov_read_mdhd(MOVContext *c, ByteIOContext *pb, MOVAtom atom)
     AVStream *st = c->fc->streams[c->fc->nb_streams-1];
     MOVStreamContext *sc = st->priv_data;
     int version = get_byte(pb);
-    int lang;
+    unsigned lang;
 
     if (version > 1)
         return -1; /* unsupported */
@@ -2013,6 +2014,8 @@ static int mov_read_seek(AVFormatContext *s, int stream_index, int64_t sample_ti
 
     if (stream_index >= s->nb_streams)
         return -1;
+    if (sample_time < 0)
+        sample_time = 0;
 
     st = s->streams[stream_index];
     sample = mov_seek_stream(st, sample_time, flags);
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index e07ded3..c46bcc2 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1,7 +1,7 @@
 /*
  * MOV, 3GP, MP4 muxer
- * Copyright (c) 2003 Thomas Raivio.
- * Copyright (c) 2004 Gildas Bazin <gbazin at videolan dot org>.
+ * Copyright (c) 2003 Thomas Raivio
+ * Copyright (c) 2004 Gildas Bazin <gbazin at videolan dot org>
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/mp3.c b/libavformat/mp3.c
index 9909541..8602206 100644
--- a/libavformat/mp3.c
+++ b/libavformat/mp3.c
@@ -1,6 +1,6 @@
 /*
  * MP3 muxer and demuxer
- * Copyright (c) 2003 Fabrice Bellard.
+ * Copyright (c) 2003 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
@@ -354,15 +354,17 @@ static int mp3_read_probe(AVProbeData *p)
     int max_frames, first_frames = 0;
     int fsize, frames, sample_rate;
     uint32_t header;
-    uint8_t *buf, *buf2, *end;
+    uint8_t *buf, *buf0, *buf2, *end;
     AVCodecContext avctx;
 
-    if(ff_id3v2_match(p->buf))
-        return AVPROBE_SCORE_MAX/2+1; // this must be less than mpeg-ps because some retards put id3v2 tags before mpeg-ps files
+    buf0 = p->buf;
+    if(ff_id3v2_match(buf0)) {
+        buf0 += ff_id3v2_tag_len(buf0);
+    }
 
     max_frames = 0;
-    buf = p->buf;
-    end = buf + p->buf_size - sizeof(uint32_t);
+    buf = buf0;
+    end = p->buf + p->buf_size - sizeof(uint32_t);
 
     for(; buf < end; buf= buf2+1) {
         buf2 = buf;
@@ -375,7 +377,7 @@ static int mp3_read_probe(AVProbeData *p)
             buf2 += fsize;
         }
         max_frames = FFMAX(max_frames, frames);
-        if(buf == p->buf)
+        if(buf == buf0)
             first_frames= frames;
     }
     if   (first_frames>=3) return AVPROBE_SCORE_MAX/2+1;
@@ -393,7 +395,7 @@ static int mp3_parse_vbr_tags(AVFormatContext *s, AVStream *st, int64_t base)
     uint32_t v, spf;
     int frames = -1; /* Total number of frames in file */
     const int64_t xing_offtbl[2][2] = {{32, 17}, {17,9}};
-    MPADecodeContext c;
+    MPADecodeHeader c;
     int vbrtag_size = 0;
 
     v = get_be32(s->pb);
diff --git a/libavformat/mpc.c b/libavformat/mpc.c
index 1a22c11..9dbd239 100644
--- a/libavformat/mpc.c
+++ b/libavformat/mpc.c
@@ -21,6 +21,7 @@
 
 #include "libavcodec/bitstream.h"
 #include "avformat.h"
+#include "id3v2.h"
 
 #define MPC_FRAMESIZE  1152
 #define DELAY_FRAMES   32
@@ -43,10 +44,12 @@ typedef struct {
 static int mpc_probe(AVProbeData *p)
 {
     const uint8_t *d = p->buf;
+    if (ff_id3v2_match(d)) {
+        d += ff_id3v2_tag_len(d);
+    }
+    if (d+3 < p->buf+p->buf_size)
     if (d[0] == 'M' && d[1] == 'P' && d[2] == '+' && (d[3] == 0x17 || d[3] == 0x7))
         return AVPROBE_SCORE_MAX;
-    if (d[0] == 'I' && d[1] == 'D' && d[2] == '3')
-        return AVPROBE_SCORE_MAX / 2;
     return 0;
 }
 
diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c
index ec89d5a..0c43a5e 100644
--- a/libavformat/mpeg.c
+++ b/libavformat/mpeg.c
@@ -1,6 +1,6 @@
 /*
  * MPEG1/2 demuxer
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
+ * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/mpeg.h b/libavformat/mpeg.h
index ff146bb..d09b2e8 100644
--- a/libavformat/mpeg.h
+++ b/libavformat/mpeg.h
@@ -1,6 +1,6 @@
 /*
  * MPEG1/2 muxer and demuxer common defines
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
+ * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/mpegenc.c b/libavformat/mpegenc.c
index 69063a8..0a740af 100644
--- a/libavformat/mpegenc.c
+++ b/libavformat/mpegenc.c
@@ -1,6 +1,6 @@
 /*
  * MPEG1/2 muxer
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
+ * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/mpegts.c b/libavformat/mpegts.c
index ac7737e..5d07e39 100644
--- a/libavformat/mpegts.c
+++ b/libavformat/mpegts.c
@@ -1,6 +1,6 @@
 /*
  * MPEG2 transport stream (aka DVB) demuxer
- * Copyright (c) 2002-2003 Fabrice Bellard.
+ * Copyright (c) 2002-2003 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
@@ -888,7 +888,7 @@ static void mpegts_push_data(MpegTSFilter *filter,
                 pes->pts = AV_NOPTS_VALUE;
                 pes->dts = AV_NOPTS_VALUE;
                 if ((flags & 0xc0) == 0x80) {
-                    pes->pts = get_pts(r);
+                    pes->dts = pes->pts = get_pts(r);
                     r += 5;
                 } else if ((flags & 0xc0) == 0xc0) {
                     pes->pts = get_pts(r);
diff --git a/libavformat/mpegts.h b/libavformat/mpegts.h
index 896836d..4d06b1d 100644
--- a/libavformat/mpegts.h
+++ b/libavformat/mpegts.h
@@ -1,6 +1,6 @@
 /*
  * MPEG2 transport stream defines
- * Copyright (c) 2003 Fabrice Bellard.
+ * Copyright (c) 2003 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index acadc28..ea78721 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -1,6 +1,6 @@
 /*
  * MPEG2 transport stream (aka DVB) muxer
- * Copyright (c) 2003 Fabrice Bellard.
+ * Copyright (c) 2003 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/mpjpeg.c b/libavformat/mpjpeg.c
index ecaad55..b09bac2 100644
--- a/libavformat/mpjpeg.c
+++ b/libavformat/mpjpeg.c
@@ -1,6 +1,6 @@
 /*
  * Multipart JPEG format
- * Copyright (c) 2000, 2001, 2002, 2003 Fabrice Bellard.
+ * Copyright (c) 2000, 2001, 2002, 2003 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/mxf.c b/libavformat/mxf.c
index 5fc0bfc..1893d21 100644
--- a/libavformat/mxf.c
+++ b/libavformat/mxf.c
@@ -1,6 +1,6 @@
 /*
  * MXF
- * Copyright (c) 2006 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>.
+ * Copyright (c) 2006 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/mxf.h b/libavformat/mxf.h
index 39c8c16..7c1e2ee 100644
--- a/libavformat/mxf.h
+++ b/libavformat/mxf.h
@@ -1,6 +1,6 @@
 /*
  * MXF
- * Copyright (c) 2006 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>.
+ * Copyright (c) 2006 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>
  *
  * This file is part of FFmpeg.
  *
@@ -21,6 +21,7 @@
 #ifndef AVFORMAT_MXF_H
 #define AVFORMAT_MXF_H
 
+#include <string.h>
 #include "avformat.h"
 #include "libavcodec/bytestream.h"
 
@@ -42,6 +43,7 @@ enum MXFMetadataSetType {
     ContentStorage,
     SubDescriptor,
     IndexTableSegment,
+    EssenceContainerData,
     TypeBottom,// add metadata type before this
 };
 
diff --git a/libavformat/mxfdec.c b/libavformat/mxfdec.c
index 6dafdc6..ce6de5f 100644
--- a/libavformat/mxfdec.c
+++ b/libavformat/mxfdec.c
@@ -1,6 +1,6 @@
 /*
  * MXF demuxer.
- * Copyright (c) 2006 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>.
+ * Copyright (c) 2006 SmartJog S.A., Baptiste Coudurier <baptiste dot coudurier at smartjog dot com>
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/mxfenc.c b/libavformat/mxfenc.c
index 58cdeef..4f221c0 100644
--- a/libavformat/mxfenc.c
+++ b/libavformat/mxfenc.c
@@ -120,6 +120,7 @@ static const MXFLocalTagPair mxf_local_tag_batch[] = {
     { 0x3C06, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x07,0x02,0x01,0x10,0x02,0x03,0x00,0x00}}, /* Modification Date */
     // Content Storage
     { 0x1901, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x04,0x05,0x01,0x00,0x00}}, /* Package strong reference batch */
+    { 0x1902, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x04,0x05,0x02,0x00,0x00}}, /* Package strong reference batch */
     // Essence Container Data
     { 0x2701, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x02,0x06,0x01,0x01,0x06,0x01,0x00,0x00,0x00}}, /* Linked Package UID */
     { 0x3F07, {0x06,0x0E,0x2B,0x34,0x01,0x01,0x01,0x04,0x01,0x03,0x04,0x04,0x00,0x00,0x00,0x00}}, /* BodySID */
@@ -376,7 +377,7 @@ static void mxf_write_content_storage(AVFormatContext *s)
 
     mxf_write_metadata_key(pb, 0x011800);
     PRINT_KEY(s, "content storage key", pb->buf_ptr - 16);
-    klv_encode_ber_length(pb, 64);
+    klv_encode_ber_length(pb, 92);
 
     // write uid
     mxf_write_local_tag(pb, 16, 0x3C0A);
@@ -388,6 +389,11 @@ static void mxf_write_content_storage(AVFormatContext *s)
     mxf_write_refs_count(pb, 2);
     mxf_write_uuid(pb, MaterialPackage, 0);
     mxf_write_uuid(pb, SourcePackage, 0);
+
+    // write essence container data
+    mxf_write_local_tag(pb, 8 + 16, 0x1902);
+    mxf_write_refs_count(pb, 1);
+    mxf_write_uuid(pb, EssenceContainerData, 0);
 }
 
 static void mxf_write_track(AVFormatContext *s, AVStream *st, enum MXFMetadataSetType type)
@@ -557,6 +563,8 @@ static const UID mxf_wav_descriptor_key       = { 0x06,0x0E,0x2B,0x34,0x02,0x53,
 static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st)
 {
     ByteIOContext *pb = s->pb;
+    int stored_height = (st->codec->height+15)/16*16;
+    AVRational dar;
 
     mxf_write_generic_desc(pb, st, mxf_mpegvideo_descriptor_key);
 
@@ -564,11 +572,16 @@ static void mxf_write_mpegvideo_desc(AVFormatContext *s, AVStream *st)
     put_be32(pb, st->codec->width);
 
     mxf_write_local_tag(pb, 4, 0x3202);
-    put_be32(pb, st->codec->height);
+    put_be32(pb, stored_height);
+
+    av_reduce(&dar.num, &dar.den,
+              st->codec->width*st->codec->sample_aspect_ratio.num,
+              st->codec->height*st->codec->sample_aspect_ratio.den,
+              1024*1024);
 
     mxf_write_local_tag(pb, 8, 0x320E);
-    put_be32(pb, st->codec->height * st->sample_aspect_ratio.den);
-    put_be32(pb, st->codec->width  * st->sample_aspect_ratio.num);
+    put_be32(pb, dar.num);
+    put_be32(pb, dar.den);
 }
 
 static void mxf_write_wav_desc(AVFormatContext *s, AVStream *st)
@@ -652,6 +665,25 @@ static void mxf_write_package(AVFormatContext *s, enum MXFMetadataSetType type)
     }
 }
 
+static int mxf_write_essence_container_data(AVFormatContext *s)
+{
+    ByteIOContext *pb = s->pb;
+
+    mxf_write_metadata_key(pb, 0x012300);
+    klv_encode_ber_length(pb, 64);
+
+    mxf_write_local_tag(pb, 16, 0x3C0A); // Instance UID
+    mxf_write_uuid(pb, EssenceContainerData, 0);
+
+    mxf_write_local_tag(pb, 32, 0x2701); // Linked Package UID
+    mxf_write_umid(pb, SourcePackage, 0);
+
+    mxf_write_local_tag(pb, 4, 0x3F07); // BodySID
+    put_be32(pb, 1);
+
+    return 0;
+}
+
 static int mxf_write_header_metadata_sets(AVFormatContext *s)
 {
     mxf_write_preface(s);
@@ -659,6 +691,7 @@ static int mxf_write_header_metadata_sets(AVFormatContext *s)
     mxf_write_content_storage(s);
     mxf_write_package(s, MaterialPackage);
     mxf_write_package(s, SourcePackage);
+    mxf_write_essence_container_data(s);
     return 0;
 }
 
diff --git a/libavformat/network.h b/libavformat/network.h
index ef08b55..7af7799 100644
--- a/libavformat/network.h
+++ b/libavformat/network.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007 The FFmpeg Project.
+ * Copyright (c) 2007 The FFmpeg Project
  *
  * This file is part of FFmpeg.
  *
@@ -21,6 +21,8 @@
 #ifndef AVFORMAT_NETWORK_H
 #define AVFORMAT_NETWORK_H
 
+#include "config.h"
+
 #if HAVE_WINSOCK2_H
 #include <winsock2.h>
 #include <ws2tcpip.h>
diff --git a/libavformat/nsvdec.c b/libavformat/nsvdec.c
index dbc2d00..5a11724 100644
--- a/libavformat/nsvdec.c
+++ b/libavformat/nsvdec.c
@@ -1,6 +1,6 @@
 /*
  * NSV demuxer
- * Copyright (c) 2004 The FFmpeg Project.
+ * Copyright (c) 2004 The FFmpeg Project
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/nuv.c b/libavformat/nuv.c
index 747f238..fed0d69 100644
--- a/libavformat/nuv.c
+++ b/libavformat/nuv.c
@@ -1,6 +1,6 @@
 /*
  * NuppelVideo demuxer.
- * Copyright (c) 2006 Reimar Doeffinger.
+ * Copyright (c) 2006 Reimar Doeffinger
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/oggparseflac.c b/libavformat/oggparseflac.c
index 802453a..875f184 100644
--- a/libavformat/oggparseflac.c
+++ b/libavformat/oggparseflac.c
@@ -20,10 +20,11 @@
 
 #include <stdlib.h>
 #include "libavcodec/bitstream.h"
+#include "libavcodec/flac.h"
 #include "avformat.h"
 #include "oggdec.h"
 
-#define FLAC_STREAMINFO_SIZE 0x22
+#define OGG_FLAC_METADATA_TYPE_STREAMINFO 0x7F
 
 static int
 flac_header (AVFormatContext * s, int idx)
@@ -32,6 +33,7 @@ flac_header (AVFormatContext * s, int idx)
     struct ogg_stream *os = ogg->streams + idx;
     AVStream *st = s->streams[idx];
     GetBitContext gb;
+    FLACStreaminfo si;
     int mdt;
 
     if (os->buf[os->pstart] == 0xff)
@@ -41,7 +43,8 @@ flac_header (AVFormatContext * s, int idx)
     skip_bits1(&gb); /* metadata_last */
     mdt = get_bits(&gb, 7);
 
-    if (mdt == 0x7f) {
+    if (mdt == OGG_FLAC_METADATA_TYPE_STREAMINFO) {
+        uint8_t *streaminfo_start = os->buf + os->pstart + 5 + 4 + 4 + 4;
         skip_bits_long(&gb, 4*8); /* "FLAC" */
         if(get_bits(&gb, 8) != 1) /* unsupported major version */
             return -1;
@@ -52,23 +55,19 @@ flac_header (AVFormatContext * s, int idx)
         if (get_bits_long(&gb, 32) != FLAC_STREAMINFO_SIZE)
             return -1;
 
-        skip_bits_long(&gb, 16*2+24*2);
-
-        st->codec->sample_rate = get_bits_long(&gb, 20);
-        st->codec->channels = get_bits(&gb, 3) + 1;
+        ff_flac_parse_streaminfo(st->codec, &si, streaminfo_start);
 
         st->codec->codec_type = CODEC_TYPE_AUDIO;
         st->codec->codec_id = CODEC_ID_FLAC;
 
         st->codec->extradata =
             av_malloc(FLAC_STREAMINFO_SIZE + FF_INPUT_BUFFER_PADDING_SIZE);
-        memcpy (st->codec->extradata, os->buf + os->pstart + 5 + 4 + 4 + 4,
-                FLAC_STREAMINFO_SIZE);
+        memcpy(st->codec->extradata, streaminfo_start, FLAC_STREAMINFO_SIZE);
         st->codec->extradata_size = FLAC_STREAMINFO_SIZE;
 
         st->time_base.num = 1;
         st->time_base.den = st->codec->sample_rate;
-    } else if (mdt == 4) {
+    } else if (mdt == FLAC_METADATA_TYPE_VORBIS_COMMENT) {
         vorbis_comment (s, os->buf + os->pstart + 4, os->psize - 4);
     }
 
diff --git a/libavformat/os_support.h b/libavformat/os_support.h
index 165dc23..2425b98 100644
--- a/libavformat/os_support.h
+++ b/libavformat/os_support.h
@@ -27,6 +27,8 @@
  * miscellaneous OS support macros and functions.
  */
 
+#include "config.h"
+
 #ifdef __MINGW32__
 #  include <fcntl.h>
 #  define lseek(f,p,w) _lseeki64((f), (p), (w))
diff --git a/libavformat/r3d.c b/libavformat/r3d.c
new file mode 100644
index 0000000..20f41f5
--- /dev/null
+++ b/libavformat/r3d.c
@@ -0,0 +1,384 @@
+/*
+ * R3D REDCODE demuxer
+ * Copyright (c) 2008 Baptiste Coudurier <baptiste dot coudurier at gmail dot com>
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg 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.
+ *
+ * FFmpeg 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 FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+//#define DEBUG
+
+#include "libavutil/intreadwrite.h"
+#include "avformat.h"
+
+typedef struct {
+    unsigned video_offsets_count;
+    unsigned *video_offsets;
+    unsigned rdvo_offset;
+} R3DContext;
+
+typedef struct {
+    unsigned size;
+    uint32_t tag;
+    uint64_t offset;
+} Atom;
+
+static int read_atom(AVFormatContext *s, Atom *atom)
+{
+    atom->offset = url_ftell(s->pb);
+    atom->size = get_be32(s->pb);
+    if (atom->size < 8)
+        return -1;
+    atom->tag = get_le32(s->pb);
+    dprintf(s, "atom %d %.4s offset %#llx\n",
+            atom->size, (char*)&atom->tag, atom->offset);
+    return atom->size;
+}
+
+static int r3d_read_red1(AVFormatContext *s)
+{
+    AVStream *st = av_new_stream(s, 0);
+    int tmp, tmp2;
+
+    if (!st)
+        return -1;
+    st->codec->codec_type = CODEC_TYPE_VIDEO;
+    st->codec->codec_id = CODEC_ID_JPEG2000;
+
+    tmp  = get_byte(s->pb); // major version
+    tmp2 = get_byte(s->pb); // minor version
+    dprintf(s, "version %d.%d\n", tmp, tmp2);
+
+    tmp = get_be16(s->pb); // unknown
+    dprintf(s, "unknown1 %d\n", tmp);
+
+    tmp = get_be32(s->pb);
+    av_set_pts_info(st, 32, 1, tmp);
+
+    tmp = get_be32(s->pb); // filenum
+    dprintf(s, "filenum %d\n", tmp);
+
+    url_fskip(s->pb, 32); // unknown
+
+    st->codec->width  = get_be32(s->pb);
+    st->codec->height = get_be32(s->pb);
+
+    tmp = get_be16(s->pb); // unknown
+    dprintf(s, "unknown2 %d\n", tmp);
+
+    st->codec->time_base.den = get_be16(s->pb);
+    st->codec->time_base.num = get_be16(s->pb);
+
+    tmp = get_byte(s->pb); // audio channels
+    dprintf(s, "audio channels %d\n", tmp);
+    if (tmp > 0) {
+        AVStream *ast = av_new_stream(s, 1);
+        ast->codec->codec_type = CODEC_TYPE_AUDIO;
+        ast->codec->codec_id = CODEC_ID_PCM_S32BE;
+        ast->codec->channels = tmp;
+        av_set_pts_info(ast, 32, 1, st->time_base.den);
+    }
+
+    st->filename = av_mallocz(258);
+    if (!st->filename)
+        return AVERROR(ENOMEM);
+    get_buffer(s->pb, st->filename, 257);
+
+    dprintf(s, "filename %s\n", st->filename);
+    dprintf(s, "resolution %dx%d\n", st->codec->width, st->codec->height);
+    dprintf(s, "timescale %d\n", st->time_base.den);
+    dprintf(s, "frame rate %d/%d\n",
+            st->codec->time_base.num, st->codec->time_base.den);
+
+    return 0;
+}
+
+static int r3d_read_rdvo(AVFormatContext *s, Atom *atom)
+{
+    R3DContext *r3d = s->priv_data;
+    AVStream *st = s->streams[0];
+    int i;
+
+    r3d->video_offsets_count = (atom->size - 8) / 4;
+    r3d->video_offsets = av_malloc(atom->size);
+    if (!r3d->video_offsets)
+        return AVERROR(ENOMEM);
+
+    for (i = 0; i < r3d->video_offsets_count; i++) {
+        r3d->video_offsets[i] = get_be32(s->pb);
+        if (!r3d->video_offsets[i]) {
+            r3d->video_offsets_count = i;
+            break;
+        }
+        dprintf(s, "video offset %d: %#x\n", i, r3d->video_offsets[i]);
+    }
+
+    if (st->codec->time_base.den)
+        st->duration = (uint64_t)r3d->video_offsets_count*
+            st->time_base.den*st->codec->time_base.num/st->codec->time_base.den;
+    dprintf(s, "duration %lld\n", st->duration);
+
+    return 0;
+}
+
+static void r3d_read_reos(AVFormatContext *s)
+{
+    R3DContext *r3d = s->priv_data;
+    int tmp;
+
+    r3d->rdvo_offset = get_be32(s->pb);
+    get_be32(s->pb); // rdvs offset
+    get_be32(s->pb); // rdao offset
+    get_be32(s->pb); // rdas offset
+
+    tmp = get_be32(s->pb);
+    dprintf(s, "num video chunks %d\n", tmp);
+
+    tmp = get_be32(s->pb);
+    dprintf(s, "num audio chunks %d\n", tmp);
+
+    url_fskip(s->pb, 6*4);
+}
+
+static int r3d_read_header(AVFormatContext *s, AVFormatParameters *ap)
+{
+    R3DContext *r3d = s->priv_data;
+    Atom atom;
+    int ret;
+
+    if (read_atom(s, &atom) < 0) {
+        av_log(s, AV_LOG_ERROR, "error reading atom\n");
+        return -1;
+    }
+    if (atom.tag == MKTAG('R','E','D','1')) {
+        if ((ret = r3d_read_red1(s)) < 0) {
+            av_log(s, AV_LOG_ERROR, "error parsing 'red1' atom\n");
+            return ret;
+        }
+    } else {
+        av_log(s, AV_LOG_ERROR, "could not find 'red1' atom\n");
+        return -1;
+    }
+
+    s->data_offset = url_ftell(s->pb);
+    dprintf(s, "data offset %#llx\n", s->data_offset);
+    if (url_is_streamed(s->pb))
+        return 0;
+    // find REOB/REOF/REOS to load index
+    url_fseek(s->pb, url_fsize(s->pb)-48-8, SEEK_SET);
+    if (read_atom(s, &atom) < 0)
+        av_log(s, AV_LOG_ERROR, "error reading end atom\n");
+
+    if (atom.tag != MKTAG('R','E','O','B') &&
+        atom.tag != MKTAG('R','E','O','F') &&
+        atom.tag != MKTAG('R','E','O','S'))
+        goto out;
+
+    r3d_read_reos(s);
+
+    if (r3d->rdvo_offset) {
+        url_fseek(s->pb, r3d->rdvo_offset, SEEK_SET);
+        if (read_atom(s, &atom) < 0)
+            av_log(s, AV_LOG_ERROR, "error reading 'rdvo' atom\n");
+        if (atom.tag == MKTAG('R','D','V','O')) {
+            if (r3d_read_rdvo(s, &atom) < 0)
+                av_log(s, AV_LOG_ERROR, "error parsing 'rdvo' atom\n");
+        }
+    }
+
+ out:
+    url_fseek(s->pb, s->data_offset, SEEK_SET);
+    return 0;
+}
+
+static int r3d_read_redv(AVFormatContext *s, AVPacket *pkt, Atom *atom)
+{
+    AVStream *st = s->streams[0];
+    int tmp, tmp2;
+    uint64_t pos = url_ftell(s->pb);
+    unsigned dts;
+
+    dts = get_be32(s->pb);
+
+    tmp = get_be32(s->pb);
+    dprintf(s, "frame num %d\n", tmp);
+
+    tmp  = get_byte(s->pb); // major version
+    tmp2 = get_byte(s->pb); // minor version
+    dprintf(s, "version %d.%d\n", tmp, tmp2);
+
+    tmp = get_be16(s->pb); // unknown
+    dprintf(s, "unknown %d\n", tmp);
+
+    if (tmp > 4) {
+        tmp = get_be16(s->pb); // unknown
+        dprintf(s, "unknown %d\n", tmp);
+
+        tmp = get_be16(s->pb); // unknown
+        dprintf(s, "unknown %d\n", tmp);
+
+        tmp = get_be32(s->pb);
+        dprintf(s, "width %d\n", tmp);
+        tmp = get_be32(s->pb);
+        dprintf(s, "height %d\n", tmp);
+
+        tmp = get_be32(s->pb);
+        dprintf(s, "metadata len %d\n", tmp);
+    }
+    tmp = atom->size - 8 - (url_ftell(s->pb) - pos);
+    if (tmp < 0)
+        return -1;
+
+    if (av_get_packet(s->pb, pkt, tmp) != tmp) {
+        av_log(s, AV_LOG_ERROR, "error reading video packet\n");
+        return -1;
+    }
+
+    pkt->stream_index = 0;
+    pkt->dts = dts;
+    if (st->codec->time_base.den)
+        pkt->duration = (uint64_t)st->time_base.den*
+            st->codec->time_base.num/st->codec->time_base.den;
+    dprintf(s, "pkt dts %lld duration %d\n", pkt->dts, pkt->duration);
+
+    return 0;
+}
+
+static int r3d_read_reda(AVFormatContext *s, AVPacket *pkt, Atom *atom)
+{
+    AVStream *st = s->streams[1];
+    int tmp, tmp2, samples, size;
+    uint64_t pos = url_ftell(s->pb);
+    unsigned dts;
+
+    dts = get_be32(s->pb);
+
+    st->codec->sample_rate = get_be32(s->pb);
+
+    samples = get_be32(s->pb);
+
+    tmp = get_be32(s->pb);
+    dprintf(s, "packet num %d\n", tmp);
+
+    tmp = get_be16(s->pb); // unkown
+    dprintf(s, "unknown %d\n", tmp);
+
+    tmp  = get_byte(s->pb); // major version
+    tmp2 = get_byte(s->pb); // minor version
+    dprintf(s, "version %d.%d\n", tmp, tmp2);
+
+    tmp = get_be32(s->pb); // unknown
+    dprintf(s, "unknown %d\n", tmp);
+
+    size = atom->size - 8 - (url_ftell(s->pb) - pos);
+    if (size < 0)
+        return -1;
+    if (av_get_packet(s->pb, pkt, size) != size) {
+        av_log(s, AV_LOG_ERROR, "error reading video packet\n");
+        return -1;
+    }
+
+    pkt->stream_index = 1;
+    pkt->dts = dts;
+    pkt->duration = av_rescale(samples, st->time_base.den, st->codec->sample_rate);
+    dprintf(s, "pkt dts %lld duration %d samples %d sample rate %d\n",
+            pkt->dts, pkt->duration, samples, st->codec->sample_rate);
+
+    return 0;
+}
+
+static int r3d_read_packet(AVFormatContext *s, AVPacket *pkt)
+{
+    Atom atom;
+    int err = 0;
+
+    while (!err) {
+        if (read_atom(s, &atom) < 0) {
+            err = -1;
+            break;
+        }
+        switch (atom.tag) {
+        case MKTAG('R','E','D','V'):
+            if (s->streams[0]->discard == AVDISCARD_ALL)
+                goto skip;
+            if (!(err = r3d_read_redv(s, pkt, &atom)))
+                return 0;
+            break;
+        case MKTAG('R','E','D','A'):
+            if (s->nb_streams < 2)
+                return -1;
+            if (s->streams[1]->discard == AVDISCARD_ALL)
+                goto skip;
+            if (!(err = r3d_read_reda(s, pkt, &atom)))
+                return 0;
+            break;
+        default:
+        skip:
+            url_fskip(s->pb, atom.size-8);
+        }
+    }
+    return err;
+}
+
+static int r3d_probe(AVProbeData *p)
+{
+    if (AV_RL32(p->buf + 4) == MKTAG('R','E','D','1'))
+        return AVPROBE_SCORE_MAX;
+    return 0;
+}
+
+static int r3d_seek(AVFormatContext *s, int stream_index, int64_t sample_time, int flags)
+{
+    AVStream *st = s->streams[0]; // video stream
+    R3DContext *r3d = s->priv_data;
+    int frame_num;
+
+    if (!st->codec->time_base.num || !st->time_base.den)
+        return -1;
+
+    frame_num = sample_time*st->codec->time_base.den/
+        ((int64_t)st->codec->time_base.num*st->time_base.den);
+    dprintf(s, "seek frame num %d timestamp %lld\n", frame_num, sample_time);
+
+    if (frame_num < r3d->video_offsets_count) {
+        url_fseek(s->pb, r3d->video_offsets_count, SEEK_SET);
+    } else {
+        av_log(s, AV_LOG_ERROR, "could not seek to frame %d\n", frame_num);
+        return -1;
+    }
+
+    return 0;
+}
+
+static int r3d_close(AVFormatContext *s)
+{
+    R3DContext *r3d = s->priv_data;
+
+    av_freep(&r3d->video_offsets);
+
+    return 0;
+}
+
+AVInputFormat r3d_demuxer = {
+    "r3d",
+    NULL_IF_CONFIG_SMALL("REDCODE R3D format"),
+    sizeof(R3DContext),
+    r3d_probe,
+    r3d_read_header,
+    r3d_read_packet,
+    r3d_close,
+    r3d_seek,
+};
diff --git a/libavformat/raw.c b/libavformat/raw.c
index f3214ac..06fc1e2 100644
--- a/libavformat/raw.c
+++ b/libavformat/raw.c
@@ -1,6 +1,6 @@
 /*
  * RAW muxer and demuxer
- * Copyright (c) 2001 Fabrice Bellard.
+ * Copyright (c) 2001 Fabrice Bellard
  * Copyright (c) 2005 Alex Beregszaszi
  *
  * This file is part of FFmpeg.
@@ -26,6 +26,7 @@
 #include "libavcodec/bytestream.h"
 #include "avformat.h"
 #include "raw.h"
+#include "id3v2.h"
 
 /* simple formats */
 #if CONFIG_FLAC_MUXER
@@ -288,6 +289,18 @@ static int audio_read_header(AVFormatContext *s,
     st->codec->codec_id = s->iformat->value;
     st->need_parsing = AVSTREAM_PARSE_FULL;
     /* the parameters will be extracted from the compressed bitstream */
+
+    if(st->codec->codec_id == CODEC_ID_FLAC) {
+        /* skip ID3v2 header if found */
+        uint8_t buf[ID3v2_HEADER_SIZE];
+        int ret = get_buffer(s->pb, buf, ID3v2_HEADER_SIZE);
+        if (ret == ID3v2_HEADER_SIZE && ff_id3v2_match(buf)) {
+            int len = ff_id3v2_tag_len(buf);
+            url_fseek(s->pb, len - ID3v2_HEADER_SIZE, SEEK_CUR);
+        } else {
+            url_fseek(s->pb, 0, SEEK_SET);
+        }
+    }
     return 0;
 }
 
@@ -572,8 +585,14 @@ static int eac3_probe(AVProbeData *p)
 #if CONFIG_FLAC_DEMUXER
 static int flac_probe(AVProbeData *p)
 {
-    if(memcmp(p->buf, "fLaC", 4)) return 0;
-    else                          return AVPROBE_SCORE_MAX / 2;
+    uint8_t *bufptr = p->buf;
+    uint8_t *end    = p->buf + p->buf_size;
+
+    if(ff_id3v2_match(bufptr))
+        bufptr += ff_id3v2_tag_len(bufptr);
+
+    if(bufptr > end-4 || memcmp(bufptr, "fLaC", 4)) return 0;
+    else                                            return AVPROBE_SCORE_MAX/2;
 }
 #endif
 
@@ -582,9 +601,15 @@ static int adts_aac_probe(AVProbeData *p)
 {
     int max_frames = 0, first_frames = 0;
     int fsize, frames;
+    uint8_t *buf0 = p->buf;
     uint8_t *buf2;
-    uint8_t *buf = p->buf;
-    uint8_t *end = buf + p->buf_size - 7;
+    uint8_t *buf;
+    uint8_t *end = buf0 + p->buf_size - 7;
+
+    if (ff_id3v2_match(buf0)) {
+        buf0 += ff_id3v2_tag_len(buf0);
+    }
+    buf = buf0;
 
     for(; buf < end; buf= buf2+1) {
         buf2 = buf;
@@ -599,7 +624,7 @@ static int adts_aac_probe(AVProbeData *p)
             buf2 += fsize;
         }
         max_frames = FFMAX(max_frames, frames);
-        if(buf == p->buf)
+        if(buf == buf0)
             first_frames= frames;
     }
     if   (first_frames>=3) return AVPROBE_SCORE_MAX/2+1;
diff --git a/libavformat/rdt.c b/libavformat/rdt.c
index 3680527..b7e0fa5 100644
--- a/libavformat/rdt.c
+++ b/libavformat/rdt.c
@@ -27,13 +27,13 @@
 
 #include "avformat.h"
 #include "libavutil/avstring.h"
-#include "rtp_internal.h"
+#include "rtp.h"
 #include "rdt.h"
 #include "libavutil/base64.h"
 #include "libavutil/md5.h"
 #include "rm.h"
 #include "internal.h"
-#include <libavcodec/bitstream.h>
+#include "libavcodec/bitstream.h"
 
 struct RDTDemuxContext {
     AVFormatContext *ic; /**< the containing (RTSP) demux context */
diff --git a/libavformat/riff.c b/libavformat/riff.c
index 73ebc91..ef367bf 100644
--- a/libavformat/riff.c
+++ b/libavformat/riff.c
@@ -1,6 +1,6 @@
 /*
  * RIFF codec tags
- * Copyright (c) 2000 Fabrice Bellard.
+ * Copyright (c) 2000 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
@@ -34,6 +34,7 @@ const AVCodecTag codec_bmp_tags[] = {
     { CODEC_ID_H264,         MKTAG('V', 'S', 'S', 'H') },
     { CODEC_ID_H263,         MKTAG('H', '2', '6', '3') },
     { CODEC_ID_H263,         MKTAG('X', '2', '6', '3') },
+    { CODEC_ID_H263,         MKTAG('T', '2', '6', '3') },
     { CODEC_ID_H263,         MKTAG('L', '2', '6', '3') },
     { CODEC_ID_H263,         MKTAG('V', 'X', '1', 'K') },
     { CODEC_ID_H263P,        MKTAG('H', '2', '6', '3') },
@@ -70,6 +71,8 @@ const AVCodecTag codec_bmp_tags[] = {
     { CODEC_ID_MPEG4,        MKTAG('D', 'M', 'K', '2') },
     { CODEC_ID_MPEG4,        MKTAG('D', 'I', 'G', 'I') },
     { CODEC_ID_MPEG4,        MKTAG('I', 'N', 'M', 'C') },
+    { CODEC_ID_MPEG4,        MKTAG('E', 'P', 'H', 'V') }, /* Ephv MPEG-4 */
+    { CODEC_ID_MPEG4,        MKTAG('E', 'M', '4', 'A') },
     { CODEC_ID_MSMPEG4V3,    MKTAG('D', 'I', 'V', '3') }, /* default signature when using MSMPEG4 */
     { CODEC_ID_MSMPEG4V3,    MKTAG('M', 'P', '4', '3') },
     { CODEC_ID_MSMPEG4V3,    MKTAG('M', 'P', 'G', '3') },
diff --git a/libavformat/rm.h b/libavformat/rm.h
index 2f45c0f..4d019f7 100644
--- a/libavformat/rm.h
+++ b/libavformat/rm.h
@@ -1,6 +1,6 @@
 /*
  * "Real" compatible muxer and demuxer.
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/rmdec.c b/libavformat/rmdec.c
index de81446..84c1ba3 100644
--- a/libavformat/rmdec.c
+++ b/libavformat/rmdec.c
@@ -1,6 +1,6 @@
 /*
  * "Real" compatible demuxer.
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/rmenc.c b/libavformat/rmenc.c
index 84a265a..bac4c23 100644
--- a/libavformat/rmenc.c
+++ b/libavformat/rmenc.c
@@ -1,6 +1,6 @@
 /*
  * "Real" compatible muxer.
- * Copyright (c) 2000, 2001 Fabrice Bellard.
+ * Copyright (c) 2000, 2001 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/rtp.c b/libavformat/rtp.c
index b1501e6..d284f63 100644
--- a/libavformat/rtp.c
+++ b/libavformat/rtp.c
@@ -1,6 +1,6 @@
 /*
  * RTP input/output format
- * Copyright (c) 2002 Fabrice Bellard.
+ * Copyright (c) 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
@@ -25,7 +25,7 @@
 #include <unistd.h>
 #include "network.h"
 
-#include "rtp_internal.h"
+#include "rtp.h"
 
 //#define DEBUG
 
diff --git a/libavformat/rtp.h b/libavformat/rtp.h
index 7819ceb..98c2dc7 100644
--- a/libavformat/rtp.h
+++ b/libavformat/rtp.h
@@ -1,6 +1,7 @@
 /*
  * RTP definitions
- * Copyright (c) 2002 Fabrice Bellard.
+ * Copyright (c) 2002 Fabrice Bellard
+ * Copyright (c) 2006 Ryan Martell <rdm4 at martellventures.com>
  *
  * This file is part of FFmpeg.
  *
@@ -89,4 +90,108 @@ int rtp_check_and_send_back_rr(RTPDemuxContext *s, int count);
 #define RTCP_TX_RATIO_NUM 5
 #define RTCP_TX_RATIO_DEN 1000
 
+// these statistics are used for rtcp receiver reports...
+typedef struct {
+    uint16_t max_seq;           ///< highest sequence number seen
+    uint32_t cycles;            ///< shifted count of sequence number cycles
+    uint32_t base_seq;          ///< base sequence number
+    uint32_t bad_seq;           ///< last bad sequence number + 1
+    int probation;              ///< sequence packets till source is valid
+    int received;               ///< packets received
+    int expected_prior;         ///< packets expected in last interval
+    int received_prior;         ///< packets received in last interval
+    uint32_t transit;           ///< relative transit time for previous packet
+    uint32_t jitter;            ///< estimated jitter.
+} RTPStatistics;
+
+/**
+ * Packet parsing for "private" payloads in the RTP specs.
+ *
+ * @param s stream context
+ * @param st stream that this packet belongs to
+ * @param pkt packet in which to write the parsed data
+ * @param timestamp pointer in which to write the timestamp of this RTP packet
+ * @param buf pointer to raw RTP packet data
+ * @param len length of buf
+ * @param flags flags from the RTP packet header (PKT_FLAG_*)
+ */
+typedef int (*DynamicPayloadPacketHandlerProc) (PayloadContext *s,
+                                                AVStream *st,
+                                                AVPacket * pkt,
+                                                uint32_t *timestamp,
+                                                const uint8_t * buf,
+                                                int len, int flags);
+
+struct RTPDynamicProtocolHandler_s {
+    // fields from AVRtpDynamicPayloadType_s
+    const char enc_name[50];    /* XXX: still why 50 ? ;-) */
+    enum CodecType codec_type;
+    enum CodecID codec_id;
+
+    // may be null
+    int (*parse_sdp_a_line) (AVFormatContext *s,
+                             int st_index,
+                             PayloadContext *priv_data,
+                             const char *line); ///< Parse the a= line from the sdp field
+    PayloadContext *(*open) (); ///< allocate any data needed by the rtp parsing for this dynamic data.
+    void (*close)(PayloadContext *protocol_data); ///< free any data needed by the rtp parsing for this dynamic data.
+    DynamicPayloadPacketHandlerProc parse_packet; ///< parse handler for this dynamic packet.
+
+    struct RTPDynamicProtocolHandler_s *next;
+};
+
+// moved out of rtp.c, because the h264 decoder needs to know about this structure..
+struct RTPDemuxContext {
+    AVFormatContext *ic;
+    AVStream *st;
+    int payload_type;
+    uint32_t ssrc;
+    uint16_t seq;
+    uint32_t timestamp;
+    uint32_t base_timestamp;
+    uint32_t cur_timestamp;
+    int max_payload_size;
+    struct MpegTSContext *ts;   /* only used for MP2T payloads */
+    int read_buf_index;
+    int read_buf_size;
+    /* used to send back RTCP RR */
+    URLContext *rtp_ctx;
+    char hostname[256];
+
+    RTPStatistics statistics; ///< Statistics for this stream (used by RTCP receiver reports)
+
+    /* rtcp sender statistics receive */
+    int64_t last_rtcp_ntp_time;    // TODO: move into statistics
+    int64_t first_rtcp_ntp_time;   // TODO: move into statistics
+    uint32_t last_rtcp_timestamp;  // TODO: move into statistics
+
+    /* rtcp sender statistics */
+    unsigned int packet_count;     // TODO: move into statistics (outgoing)
+    unsigned int octet_count;      // TODO: move into statistics (outgoing)
+    unsigned int last_octet_count; // TODO: move into statistics (outgoing)
+    int first_packet;
+    /* buffer for output */
+    uint8_t buf[RTP_MAX_PACKET_LENGTH];
+    uint8_t *buf_ptr;
+
+    /* special infos for au headers parsing */
+    RTPPayloadData *rtp_payload_data; // TODO: Move into dynamic payload handlers
+
+    /* dynamic payload stuff */
+    DynamicPayloadPacketHandlerProc parse_packet;     ///< This is also copied from the dynamic protocol handler structure
+    PayloadContext *dynamic_protocol_context;        ///< This is a copy from the values setup from the sdp parsing, in rtsp.c don't free me.
+    int max_frames_per_packet;
+};
+
+extern RTPDynamicProtocolHandler *RTPFirstDynamicPayloadHandler;
+void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler);
+
+int rtsp_next_attr_and_value(const char **p, char *attr, int attr_size, char *value, int value_size); ///< from rtsp.c, but used by rtp dynamic protocol handlers.
+
+void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m);
+const char *ff_rtp_enc_name(int payload_type);
+enum CodecID ff_rtp_codec_id(const char *buf, enum CodecType codec_type);
+
+void av_register_rtp_dynamic_payload_handlers(void);
+
 #endif /* AVFORMAT_RTP_H */
diff --git a/libavformat/rtp_aac.c b/libavformat/rtp_aac.c
index 4cd8e12..e54ff3f 100644
--- a/libavformat/rtp_aac.c
+++ b/libavformat/rtp_aac.c
@@ -20,7 +20,7 @@
 
 #include "avformat.h"
 #include "rtp_aac.h"
-#include "rtp_internal.h"
+#include "rtp.h"
 
 #define MAX_FRAMES_PER_PACKET (s->max_frames_per_packet ? s->max_frames_per_packet : 5)
 #define MAX_AU_HEADERS_SIZE (2 + 2 * MAX_FRAMES_PER_PACKET)
diff --git a/libavformat/rtp_h264.c b/libavformat/rtp_h264.c
index 7d6f96c..4999e0e 100644
--- a/libavformat/rtp_h264.c
+++ b/libavformat/rtp_h264.c
@@ -1,6 +1,6 @@
 /*
  * RTP H264 Protocol (RFC3984)
- * Copyright (c) 2006 Ryan Martell.
+ * Copyright (c) 2006 Ryan Martell
  *
  * This file is part of FFmpeg.
  *
@@ -46,7 +46,7 @@
 #include "network.h"
 #include <assert.h>
 
-#include "rtp_internal.h"
+#include "rtp.h"
 #include "rtp_h264.h"
 
 /**
diff --git a/libavformat/rtp_h264.h b/libavformat/rtp_h264.h
index 07c4b5e..94eac47 100644
--- a/libavformat/rtp_h264.h
+++ b/libavformat/rtp_h264.h
@@ -1,6 +1,6 @@
 /*
  * RTP H264 Protocol (RFC3984)
- * Copyright (c) 2006 Ryan Martell.
+ * Copyright (c) 2006 Ryan Martell
  *
  * This file is part of FFmpeg.
  *
@@ -22,7 +22,7 @@
 #ifndef AVFORMAT_RTP_H264_H
 #define AVFORMAT_RTP_H264_H
 
-#include "rtp_internal.h"
+#include "rtp.h"
 
 extern RTPDynamicProtocolHandler ff_h264_dynamic_handler;
 void ff_rtp_send_h264(AVFormatContext *s1, const uint8_t *buf1, int size);
diff --git a/libavformat/rtp_internal.h b/libavformat/rtp_internal.h
deleted file mode 100644
index 6b7588f..0000000
--- a/libavformat/rtp_internal.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * RTP definitions
- * Copyright (c) 2006 Ryan Martell <rdm4 at martellventures.com>
- *
- * This file is part of FFmpeg.
- *
- * FFmpeg 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.
- *
- * FFmpeg 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 FFmpeg; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-// this is a bit of a misnomer, because rtp & rtsp internal structures and prototypes are in here.
-#ifndef AVFORMAT_RTP_INTERNAL_H
-#define AVFORMAT_RTP_INTERNAL_H
-
-#include <stdint.h>
-#include "libavcodec/avcodec.h"
-#include "rtp.h"
-
-// these statistics are used for rtcp receiver reports...
-typedef struct {
-    uint16_t max_seq;           ///< highest sequence number seen
-    uint32_t cycles;            ///< shifted count of sequence number cycles
-    uint32_t base_seq;          ///< base sequence number
-    uint32_t bad_seq;           ///< last bad sequence number + 1
-    int probation;              ///< sequence packets till source is valid
-    int received;               ///< packets received
-    int expected_prior;         ///< packets expected in last interval
-    int received_prior;         ///< packets received in last interval
-    uint32_t transit;           ///< relative transit time for previous packet
-    uint32_t jitter;            ///< estimated jitter.
-} RTPStatistics;
-
-/**
- * Packet parsing for "private" payloads in the RTP specs.
- *
- * @param s stream context
- * @param st stream that this packet belongs to
- * @param pkt packet in which to write the parsed data
- * @param timestamp pointer in which to write the timestamp of this RTP packet
- * @param buf pointer to raw RTP packet data
- * @param len length of buf
- * @param flags flags from the RTP packet header (PKT_FLAG_*)
- */
-typedef int (*DynamicPayloadPacketHandlerProc) (PayloadContext *s,
-                                                AVStream *st,
-                                                AVPacket * pkt,
-                                                uint32_t *timestamp,
-                                                const uint8_t * buf,
-                                                int len, int flags);
-
-struct RTPDynamicProtocolHandler_s {
-    // fields from AVRtpDynamicPayloadType_s
-    const char enc_name[50];    /* XXX: still why 50 ? ;-) */
-    enum CodecType codec_type;
-    enum CodecID codec_id;
-
-    // may be null
-    int (*parse_sdp_a_line) (AVFormatContext *s,
-                             int st_index,
-                             PayloadContext *priv_data,
-                             const char *line); ///< Parse the a= line from the sdp field
-    PayloadContext *(*open) (); ///< allocate any data needed by the rtp parsing for this dynamic data.
-    void (*close)(PayloadContext *protocol_data); ///< free any data needed by the rtp parsing for this dynamic data.
-    DynamicPayloadPacketHandlerProc parse_packet; ///< parse handler for this dynamic packet.
-
-    struct RTPDynamicProtocolHandler_s *next;
-};
-
-// moved out of rtp.c, because the h264 decoder needs to know about this structure..
-struct RTPDemuxContext {
-    AVFormatContext *ic;
-    AVStream *st;
-    int payload_type;
-    uint32_t ssrc;
-    uint16_t seq;
-    uint32_t timestamp;
-    uint32_t base_timestamp;
-    uint32_t cur_timestamp;
-    int max_payload_size;
-    struct MpegTSContext *ts;   /* only used for MP2T payloads */
-    int read_buf_index;
-    int read_buf_size;
-    /* used to send back RTCP RR */
-    URLContext *rtp_ctx;
-    char hostname[256];
-
-    RTPStatistics statistics; ///< Statistics for this stream (used by RTCP receiver reports)
-
-    /* rtcp sender statistics receive */
-    int64_t last_rtcp_ntp_time;    // TODO: move into statistics
-    int64_t first_rtcp_ntp_time;   // TODO: move into statistics
-    uint32_t last_rtcp_timestamp;  // TODO: move into statistics
-
-    /* rtcp sender statistics */
-    unsigned int packet_count;     // TODO: move into statistics (outgoing)
-    unsigned int octet_count;      // TODO: move into statistics (outgoing)
-    unsigned int last_octet_count; // TODO: move into statistics (outgoing)
-    int first_packet;
-    /* buffer for output */
-    uint8_t buf[RTP_MAX_PACKET_LENGTH];
-    uint8_t *buf_ptr;
-
-    /* special infos for au headers parsing */
-    RTPPayloadData *rtp_payload_data; // TODO: Move into dynamic payload handlers
-
-    /* dynamic payload stuff */
-    DynamicPayloadPacketHandlerProc parse_packet;     ///< This is also copied from the dynamic protocol handler structure
-    PayloadContext *dynamic_protocol_context;        ///< This is a copy from the values setup from the sdp parsing, in rtsp.c don't free me.
-    int max_frames_per_packet;
-};
-
-extern RTPDynamicProtocolHandler *RTPFirstDynamicPayloadHandler;
-void ff_register_dynamic_payload_handler(RTPDynamicProtocolHandler *handler);
-
-int rtsp_next_attr_and_value(const char **p, char *attr, int attr_size, char *value, int value_size); ///< from rtsp.c, but used by rtp dynamic protocol handlers.
-
-void ff_rtp_send_data(AVFormatContext *s1, const uint8_t *buf1, int len, int m);
-const char *ff_rtp_enc_name(int payload_type);
-enum CodecID ff_rtp_codec_id(const char *buf, enum CodecType codec_type);
-
-void av_register_rtp_dynamic_payload_handlers(void);
-
-#endif /* AVFORMAT_RTP_INTERNAL_H */
-
diff --git a/libavformat/rtp_mpv.c b/libavformat/rtp_mpv.c
index 59d8c18..2221dd2 100644
--- a/libavformat/rtp_mpv.c
+++ b/libavformat/rtp_mpv.c
@@ -1,7 +1,7 @@
 /*
  * RTP packetization for MPEG video
- * Copyright (c) 2002 Fabrice Bellard.
- * Copyright (c) 2007 Luca Abeni.
+ * Copyright (c) 2002 Fabrice Bellard
+ * Copyright (c) 2007 Luca Abeni
  *
  * This file is part of FFmpeg.
  *
@@ -22,7 +22,7 @@
 
 #include "libavcodec/mpegvideo.h"
 #include "avformat.h"
-#include "rtp_internal.h"
+#include "rtp.h"
 
 /* NOTE: a single frame must be passed with sequence header if
    needed. XXX: use slices. */
diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c
index 7d8fc2c..f59484e 100644
--- a/libavformat/rtpdec.c
+++ b/libavformat/rtpdec.c
@@ -1,6 +1,6 @@
 /*
  * RTP input format
- * Copyright (c) 2002 Fabrice Bellard.
+ * Copyright (c) 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
@@ -29,7 +29,7 @@
 #include <unistd.h>
 #include "network.h"
 
-#include "rtp_internal.h"
+#include "rtp.h"
 #include "rtp_h264.h"
 
 //#define DEBUG
diff --git a/libavformat/rtpenc.c b/libavformat/rtpenc.c
index 2317f5c..389e3c7 100644
--- a/libavformat/rtpenc.c
+++ b/libavformat/rtpenc.c
@@ -1,6 +1,6 @@
 /*
  * RTP output format
- * Copyright (c) 2002 Fabrice Bellard.
+ * Copyright (c) 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
@@ -26,7 +26,7 @@
 #include <unistd.h>
 #include "network.h"
 
-#include "rtp_internal.h"
+#include "rtp.h"
 #include "rtp_mpv.h"
 #include "rtp_aac.h"
 #include "rtp_h264.h"
diff --git a/libavformat/rtpenc_h264.c b/libavformat/rtpenc_h264.c
index 95d5fff..f488386 100644
--- a/libavformat/rtpenc_h264.c
+++ b/libavformat/rtpenc_h264.c
@@ -1,6 +1,6 @@
 /*
  * RTP packetization for H.264 (RFC3984)
- * Copyright (c) 2008 Luca Abeni.
+ * Copyright (c) 2008 Luca Abeni
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c
index 1933ab0..9a192b1 100644
--- a/libavformat/rtpproto.c
+++ b/libavformat/rtpproto.c
@@ -1,6 +1,6 @@
 /*
  * RTP network protocol
- * Copyright (c) 2002 Fabrice Bellard.
+ * Copyright (c) 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 46a7159..1db4a7f 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1,6 +1,6 @@
 /*
  * RTSP/SDP client
- * Copyright (c) 2002 Fabrice Bellard.
+ * Copyright (c) 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
@@ -34,7 +34,7 @@
 #include "network.h"
 #include "rtsp.h"
 
-#include "rtp_internal.h"
+#include "rtp.h"
 #include "rdt.h"
 
 //#define DEBUG
@@ -325,6 +325,7 @@ typedef struct SDPParseState {
     /* SDP only */
     struct in_addr default_ip;
     int default_ttl;
+    int skip_media; ///< set if an unknown m= line occurs
 } SDPParseState;
 
 static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
@@ -345,6 +346,8 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
 #endif
 
     p = buf;
+    if (s1->skip_media && letter != 'm')
+        return;
     switch(letter) {
     case 'c':
         get_word(buf1, sizeof(buf1), &p);
@@ -383,12 +386,14 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
         break;
     case 'm':
         /* new stream */
+        s1->skip_media = 0;
         get_word(st_type, sizeof(st_type), &p);
         if (!strcmp(st_type, "audio")) {
             codec_type = CODEC_TYPE_AUDIO;
         } else if (!strcmp(st_type, "video")) {
             codec_type = CODEC_TYPE_VIDEO;
         } else {
+            s1->skip_media = 1;
             return;
         }
         rtsp_st = av_mallocz(sizeof(RTSPStream));
diff --git a/libavformat/rtsp.h b/libavformat/rtsp.h
index ec3477b..ce010ec 100644
--- a/libavformat/rtsp.h
+++ b/libavformat/rtsp.h
@@ -1,6 +1,6 @@
 /*
  * RTSP definitions
- * Copyright (c) 2002 Fabrice Bellard.
+ * Copyright (c) 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/sierravmd.c b/libavformat/sierravmd.c
index 83262f8..2aeebc4 100644
--- a/libavformat/sierravmd.c
+++ b/libavformat/sierravmd.c
@@ -82,8 +82,7 @@ static int vmd_read_header(AVFormatContext *s,
     int64_t current_offset;
     int i, j;
     unsigned int total_frames;
-    int64_t pts_inc = 1;
-    int64_t current_video_pts = 0, current_audio_pts = 0;
+    int64_t current_audio_pts = 0;
     unsigned char chunk[BYTES_PER_FRAME_RECORD];
     int num, den;
     int sound_buffers;
@@ -144,7 +143,6 @@ static int vmd_read_header(AVFormatContext *s,
         av_reduce(&den, &num, den, num, (1UL<<31)-1);
         av_set_pts_info(vst, 33, num, den);
         av_set_pts_info(st, 33, num, den);
-        pts_inc = num;
     }
 
     toc_offset = AV_RL32(&vmd->vmd_header[812]);
@@ -187,61 +185,34 @@ static int vmd_read_header(AVFormatContext *s,
             get_buffer(pb, chunk, BYTES_PER_FRAME_RECORD);
             type = chunk[0];
             size = AV_RL32(&chunk[2]);
-            if(!size)
+            if(!size && type != 1)
                 continue;
             switch(type) {
             case 1: /* Audio Chunk */
                 if (!st) break;
                 /* first audio chunk contains several audio buffers */
-                if(current_audio_pts){
-                    vmd->frame_table[total_frames].frame_offset = current_offset;
-                    vmd->frame_table[total_frames].stream_index = vmd->audio_stream_index;
-                    vmd->frame_table[total_frames].frame_size = size;
-                    memcpy(vmd->frame_table[total_frames].frame_record, chunk, BYTES_PER_FRAME_RECORD);
-                    vmd->frame_table[total_frames].pts = current_audio_pts;
-                    total_frames++;
-                    current_audio_pts += pts_inc;
-                }else{
-                    uint32_t flags;
-                    int k;
-                    int noff;
-                    int64_t pos;
-
-                    pos = url_ftell(pb);
-                    url_fseek(pb, current_offset, SEEK_SET);
-                    flags = get_le32(pb);
-                    noff = 4;
-                    url_fseek(pb, pos, SEEK_SET);
-                    av_log(s, AV_LOG_DEBUG, "Sound mapping = %08X (%i bufs)\n", flags, sound_buffers);
-                    for(k = 0; k < sound_buffers - 1; k++){
-                        if(flags & 1) { /* silent block */
-                            vmd->frame_table[total_frames].frame_size = 0;
-                        }else{
-                            vmd->frame_table[total_frames].frame_size = st->codec->block_align + (st->codec->block_align & 1);
-                        }
-                        noff += vmd->frame_table[total_frames].frame_size;
-                        vmd->frame_table[total_frames].frame_offset = current_offset + noff;
-                        vmd->frame_table[total_frames].stream_index = vmd->audio_stream_index;
-                        memcpy(vmd->frame_table[total_frames].frame_record, chunk, BYTES_PER_FRAME_RECORD);
-                        vmd->frame_table[total_frames].pts = current_audio_pts;
-                        total_frames++;
-                        current_audio_pts += pts_inc;
-                        flags >>= 1;
-                    }
-                }
+                vmd->frame_table[total_frames].frame_offset = current_offset;
+                vmd->frame_table[total_frames].stream_index = vmd->audio_stream_index;
+                vmd->frame_table[total_frames].frame_size = size;
+                memcpy(vmd->frame_table[total_frames].frame_record, chunk, BYTES_PER_FRAME_RECORD);
+                vmd->frame_table[total_frames].pts = current_audio_pts;
+                total_frames++;
+                if(!current_audio_pts)
+                    current_audio_pts += sound_buffers;
+                else
+                    current_audio_pts++;
                 break;
             case 2: /* Video Chunk */
                 vmd->frame_table[total_frames].frame_offset = current_offset;
                 vmd->frame_table[total_frames].stream_index = vmd->video_stream_index;
                 vmd->frame_table[total_frames].frame_size = size;
                 memcpy(vmd->frame_table[total_frames].frame_record, chunk, BYTES_PER_FRAME_RECORD);
-                vmd->frame_table[total_frames].pts = current_video_pts;
+                vmd->frame_table[total_frames].pts = i;
                 total_frames++;
                 break;
             }
             current_offset += size;
         }
-        current_video_pts += pts_inc;
     }
 
     av_free(raw_frame_table);
diff --git a/libavformat/siff.c b/libavformat/siff.c
index 9e6c85d..63fc0d6 100644
--- a/libavformat/siff.c
+++ b/libavformat/siff.c
@@ -1,6 +1,6 @@
 /*
  * Beam Software SIFF demuxer
- * Copyright (c) 2007 Konstantin Shishkov.
+ * Copyright (c) 2007 Konstantin Shishkov
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/smacker.c b/libavformat/smacker.c
index eeab64f..8ec28bc 100644
--- a/libavformat/smacker.c
+++ b/libavformat/smacker.c
@@ -1,6 +1,6 @@
 /*
  * Smacker demuxer
- * Copyright (c) 2006 Konstantin Shishkov.
+ * Copyright (c) 2006 Konstantin Shishkov
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/sol.c b/libavformat/sol.c
index 8b680be..aa56664 100644
--- a/libavformat/sol.c
+++ b/libavformat/sol.c
@@ -1,6 +1,6 @@
 /*
  * Sierra SOL demuxer
- * Copyright Konstantin Shishkov.
+ * Copyright Konstantin Shishkov
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/swf.h b/libavformat/swf.h
index 93377dc..0fee1e6 100644
--- a/libavformat/swf.h
+++ b/libavformat/swf.h
@@ -1,7 +1,7 @@
 /*
  * Flash Compatible Streaming Format common header.
- * Copyright (c) 2000 Fabrice Bellard.
- * Copyright (c) 2003 Tinic Uro.
+ * Copyright (c) 2000 Fabrice Bellard
+ * Copyright (c) 2003 Tinic Uro
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/swfdec.c b/libavformat/swfdec.c
index dc85c27..468611c 100644
--- a/libavformat/swfdec.c
+++ b/libavformat/swfdec.c
@@ -1,7 +1,7 @@
 /*
  * Flash Compatible Streaming Format demuxer
- * Copyright (c) 2000 Fabrice Bellard.
- * Copyright (c) 2003 Tinic Uro.
+ * Copyright (c) 2000 Fabrice Bellard
+ * Copyright (c) 2003 Tinic Uro
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/swfenc.c b/libavformat/swfenc.c
index 1431daf..7aead85 100644
--- a/libavformat/swfenc.c
+++ b/libavformat/swfenc.c
@@ -1,7 +1,7 @@
 /*
  * Flash Compatible Streaming Format muxer
- * Copyright (c) 2000 Fabrice Bellard.
- * Copyright (c) 2003 Tinic Uro.
+ * Copyright (c) 2000 Fabrice Bellard
+ * Copyright (c) 2003 Tinic Uro
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index d7eede6..b81ab93 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -1,6 +1,6 @@
 /*
  * TCP protocol
- * Copyright (c) 2002 Fabrice Bellard.
+ * Copyright (c) 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/thp.c b/libavformat/thp.c
index e258720..a5c9476 100644
--- a/libavformat/thp.c
+++ b/libavformat/thp.c
@@ -1,6 +1,6 @@
 /*
  * THP Demuxer
- * Copyright (c) 2007 Marco Gerards.
+ * Copyright (c) 2007 Marco Gerards
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/udp.c b/libavformat/udp.c
index f433e07..26c4383 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -1,6 +1,6 @@
 /*
  * UDP prototype streaming system
- * Copyright (c) 2000, 2001, 2002 Fabrice Bellard.
+ * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/utils.c b/libavformat/utils.c
index d3374b8..4a69baa 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -928,24 +928,24 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
             if (!st->need_parsing || !st->parser) {
                 /* no parsing needed: we just output the packet as is */
                 /* raw data support */
-                *pkt = s->cur_pkt;
+                *pkt = st->cur_pkt; st->cur_pkt.data= NULL;
                 compute_pkt_fields(s, st, NULL, pkt);
                 s->cur_st = NULL;
                 break;
-            } else if (s->cur_len > 0 && st->discard < AVDISCARD_ALL) {
+            } else if (st->cur_len > 0 && st->discard < AVDISCARD_ALL) {
                 len = av_parser_parse(st->parser, st->codec, &pkt->data, &pkt->size,
-                                      s->cur_ptr, s->cur_len,
-                                      s->cur_pkt.pts, s->cur_pkt.dts);
-                s->cur_pkt.pts = AV_NOPTS_VALUE;
-                s->cur_pkt.dts = AV_NOPTS_VALUE;
+                                      st->cur_ptr, st->cur_len,
+                                      st->cur_pkt.pts, st->cur_pkt.dts);
+                st->cur_pkt.pts = AV_NOPTS_VALUE;
+                st->cur_pkt.dts = AV_NOPTS_VALUE;
                 /* increment read pointer */
-                s->cur_ptr += len;
-                s->cur_len -= len;
+                st->cur_ptr += len;
+                st->cur_len -= len;
 
                 /* return packet if any */
                 if (pkt->size) {
+                    pkt->pos = st->cur_pkt.pos;              // Isn't quite accurate but close.
                 got_packet:
-                    pkt->pos = s->cur_pkt.pos;              // Isn't quite accurate but close.
                     pkt->duration = 0;
                     pkt->stream_index = st->index;
                     pkt->pts = st->parser->pts;
@@ -963,12 +963,13 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
                 }
             } else {
                 /* free packet */
-                av_free_packet(&s->cur_pkt);
+                av_free_packet(&st->cur_pkt);
                 s->cur_st = NULL;
             }
         } else {
+            AVPacket cur_pkt;
             /* read next packet */
-            ret = av_read_packet(s, &s->cur_pkt);
+            ret = av_read_packet(s, &cur_pkt);
             if (ret < 0) {
                 if (ret == AVERROR(EAGAIN))
                     return ret;
@@ -987,31 +988,32 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
                 /* no more packets: really terminate parsing */
                 return ret;
             }
+            st = s->streams[cur_pkt.stream_index];
+            st->cur_pkt= cur_pkt;
 
-            if(s->cur_pkt.pts != AV_NOPTS_VALUE &&
-               s->cur_pkt.dts != AV_NOPTS_VALUE &&
-               s->cur_pkt.pts < s->cur_pkt.dts){
+            if(st->cur_pkt.pts != AV_NOPTS_VALUE &&
+               st->cur_pkt.dts != AV_NOPTS_VALUE &&
+               st->cur_pkt.pts < st->cur_pkt.dts){
                 av_log(s, AV_LOG_WARNING, "Invalid timestamps stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d\n",
-                    s->cur_pkt.stream_index,
-                    s->cur_pkt.pts,
-                    s->cur_pkt.dts,
-                    s->cur_pkt.size);
-//                av_free_packet(&s->cur_pkt);
+                    st->cur_pkt.stream_index,
+                    st->cur_pkt.pts,
+                    st->cur_pkt.dts,
+                    st->cur_pkt.size);
+//                av_free_packet(&st->cur_pkt);
 //                return -1;
             }
 
-            st = s->streams[s->cur_pkt.stream_index];
             if(s->debug & FF_FDEBUG_TS)
                 av_log(s, AV_LOG_DEBUG, "av_read_packet stream=%d, pts=%"PRId64", dts=%"PRId64", size=%d,  flags=%d\n",
-                    s->cur_pkt.stream_index,
-                    s->cur_pkt.pts,
-                    s->cur_pkt.dts,
-                    s->cur_pkt.size,
-                    s->cur_pkt.flags);
+                    st->cur_pkt.stream_index,
+                    st->cur_pkt.pts,
+                    st->cur_pkt.dts,
+                    st->cur_pkt.size,
+                    st->cur_pkt.flags);
 
             s->cur_st = st;
-            s->cur_ptr = s->cur_pkt.data;
-            s->cur_len = s->cur_pkt.size;
+            st->cur_ptr = st->cur_pkt.data;
+            st->cur_len = st->cur_pkt.size;
             if (st->need_parsing && !st->parser) {
                 st->parser = av_parser_init(st->codec->codec_id);
                 if (!st->parser) {
@@ -1022,7 +1024,7 @@ static int av_read_frame_internal(AVFormatContext *s, AVPacket *pkt)
                 }
                 if(st->parser && (s->iformat->flags & AVFMT_GENERIC_INDEX)){
                     st->parser->next_frame_offset=
-                    st->parser->cur_offset= s->cur_pkt.pos;
+                    st->parser->cur_offset= st->cur_pkt.pos;
                 }
             }
         }
@@ -1139,15 +1141,7 @@ static void av_read_frame_flush(AVFormatContext *s)
 
     flush_packet_queue(s);
 
-    /* free previous packet */
-    if (s->cur_st) {
-        if (s->cur_st->parser)
-            av_free_packet(&s->cur_pkt);
-        s->cur_st = NULL;
-    }
-    /* fail safe */
-    s->cur_ptr = NULL;
-    s->cur_len = 0;
+    s->cur_st = NULL;
 
     /* for each stream, reset read state */
     for(i = 0; i < s->nb_streams; i++) {
@@ -1156,9 +1150,13 @@ static void av_read_frame_flush(AVFormatContext *s)
         if (st->parser) {
             av_parser_close(st->parser);
             st->parser = NULL;
+            av_free_packet(&st->cur_pkt);
         }
         st->last_IP_pts = AV_NOPTS_VALUE;
         st->cur_dts = AV_NOPTS_VALUE; /* we set the current DTS to an unspecified origin */
+        /* fail safe */
+        st->cur_ptr = NULL;
+        st->cur_len = 0;
     }
 }
 
@@ -1493,7 +1491,10 @@ static int av_seek_frame_generic(AVFormatContext *s,
                 return ret;
         }
         for(i=0;; i++) {
-            int ret = av_read_frame(s, &pkt);
+            int ret;
+            do{
+                ret = av_read_frame(s, &pkt);
+            }while(ret == AVERROR(EAGAIN));
             if(ret<0)
                 break;
             av_free_packet(&pkt);
@@ -1686,9 +1687,6 @@ static void av_estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset
     int64_t end_time;
     int64_t filesize, offset, duration;
 
-    /* free previous packet */
-    if (ic->cur_st && ic->cur_st->parser)
-        av_free_packet(&ic->cur_pkt);
     ic->cur_st = NULL;
 
     /* flush packet queue */
@@ -1699,6 +1697,7 @@ static void av_estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset
         if (st->parser) {
             av_parser_close(st->parser);
             st->parser= NULL;
+            av_free_packet(&st->cur_pkt);
         }
     }
 
@@ -1718,7 +1717,9 @@ static void av_estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset
         if (i == ic->nb_streams)
             break;
 
-        ret = av_read_packet(ic, pkt);
+        do{
+            ret = av_read_packet(ic, pkt);
+        }while(ret == AVERROR(EAGAIN));
         if (ret != 0)
             break;
         read_size += pkt->size;
@@ -1743,7 +1744,9 @@ static void av_estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset
         if (read_size >= DURATION_MAX_READ_SIZE)
             break;
 
-        ret = av_read_packet(ic, pkt);
+        do{
+            ret = av_read_packet(ic, pkt);
+        }while(ret == AVERROR(EAGAIN));
         if (ret != 0)
             break;
         read_size += pkt->size;
@@ -2044,6 +2047,8 @@ int av_find_stream_info(AVFormatContext *ic)
         /* NOTE: a new stream can be added there if no header in file
            (AVFMTCTX_NOHEADER) */
         ret = av_read_frame_internal(ic, &pkt1);
+        if(ret == AVERROR(EAGAIN))
+            continue;
         if (ret < 0) {
             /* EOF or error */
             ret = -1; /* we could not have all the codec parameters before EOF */
@@ -2239,10 +2244,6 @@ void av_close_input_stream(AVFormatContext *s)
     int i;
     AVStream *st;
 
-    /* free previous packet */
-    if (s->cur_st && s->cur_st->parser)
-        av_free_packet(&s->cur_pkt);
-
     if (s->iformat->read_close)
         s->iformat->read_close(s);
     for(i=0;i<s->nb_streams;i++) {
@@ -2250,6 +2251,7 @@ void av_close_input_stream(AVFormatContext *s)
         st = s->streams[i];
         if (st->parser) {
             av_parser_close(st->parser);
+            av_free_packet(&st->cur_pkt);
         }
         av_metadata_free(&st->metadata);
         av_free(st->index_entries);
@@ -2757,6 +2759,17 @@ static void dump_stream_format(AVFormatContext *ic, int i, int index, int is_out
         av_log(NULL, AV_LOG_INFO, "(%s)", st->language);
     av_log(NULL, AV_LOG_DEBUG, ", %d/%d", st->time_base.num/g, st->time_base.den/g);
     av_log(NULL, AV_LOG_INFO, ": %s", buf);
+    if (st->sample_aspect_ratio.num && // default
+        av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)) {
+        AVRational display_aspect_ratio;
+        av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
+                  st->codec->width*st->sample_aspect_ratio.num,
+                  st->codec->height*st->sample_aspect_ratio.den,
+                  1024*1024);
+        av_log(NULL, AV_LOG_INFO, ", PAR %d:%d DAR %d:%d",
+                 st->sample_aspect_ratio.num, st->sample_aspect_ratio.den,
+                 display_aspect_ratio.num, display_aspect_ratio.den);
+    }
     if(st->codec->codec_type == CODEC_TYPE_VIDEO){
         if(st->r_frame_rate.den && st->r_frame_rate.num)
             av_log(NULL, AV_LOG_INFO, ", %5.2f tb(r)", av_q2d(st->r_frame_rate));
diff --git a/libavformat/wav.c b/libavformat/wav.c
index 7aec532..f9a3444 100644
--- a/libavformat/wav.c
+++ b/libavformat/wav.c
@@ -1,6 +1,6 @@
 /*
  * WAV muxer and demuxer
- * Copyright (c) 2001, 2002 Fabrice Bellard.
+ * Copyright (c) 2001, 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/wv.c b/libavformat/wv.c
index 2fc6115..1dda1fd 100644
--- a/libavformat/wv.c
+++ b/libavformat/wv.c
@@ -1,6 +1,6 @@
 /*
  * WavPack demuxer
- * Copyright (c) 2006 Konstantin Shishkov.
+ * Copyright (c) 2006 Konstantin Shishkov
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavformat/yuv4mpeg.c b/libavformat/yuv4mpeg.c
index 6a5e8ee..3fd7927 100644
--- a/libavformat/yuv4mpeg.c
+++ b/libavformat/yuv4mpeg.c
@@ -1,6 +1,6 @@
 /*
  * YUV4MPEG format
- * Copyright (c) 2001, 2002, 2003 Fabrice Bellard.
+ * Copyright (c) 2001, 2002, 2003 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
diff --git a/libavutil/avutil.h b/libavutil/avutil.h
index fdbce40..b02790b 100644
--- a/libavutil/avutil.h
+++ b/libavutil/avutil.h
@@ -124,6 +124,8 @@ enum PixelFormat {
     PIX_FMT_VDPAU_H264,///< H264 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
     PIX_FMT_VDPAU_MPEG1,///< MPEG1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
     PIX_FMT_VDPAU_MPEG2,///< MPEG2 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
+    PIX_FMT_VDPAU_WMV3,///< WMV3 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
+    PIX_FMT_VDPAU_VC1, ///< VC1 HW decoding with VDPAU, data[0] contains a vdpau_render_state struct which contains the bitstream of the slices as well as various fields extracted from headers
     PIX_FMT_NB,        ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions
 };
 
diff --git a/libavutil/base64.c b/libavutil/base64.c
index 97a7746..0e9ce35 100644
--- a/libavutil/base64.c
+++ b/libavutil/base64.c
@@ -100,12 +100,11 @@ char *av_base64_encode(char * buf, int buf_len, const uint8_t * src, int len)
     return ret;
 }
 
-// #define TEST_BASE64
+#ifdef TEST
+#include "log.h"
+#include "mem.h"
 
-#ifdef TEST_BASE64
-#include "avutil.h"
-
-int b64test()
+int main(void)
 {
     int numerr = 0;
     int len;
diff --git a/libavutil/common.h b/libavutil/common.h
index f701d23..e262c59 100644
--- a/libavutil/common.h
+++ b/libavutil/common.h
@@ -26,20 +26,14 @@
 #ifndef AVUTIL_COMMON_H
 #define AVUTIL_COMMON_H
 
+#include <ctype.h>
+#include <errno.h>
 #include <inttypes.h>
-
-#ifdef HAVE_AV_CONFIG_H
-/* only include the following when compiling package */
-#    include "config.h"
-
-#    include <stdlib.h>
-#    include <stdio.h>
-#    include <string.h>
-#    include <ctype.h>
-#    include <limits.h>
-#    include <errno.h>
-#    include <math.h>
-#endif /* HAVE_AV_CONFIG_H */
+#include <limits.h>
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
 
 #define AV_GCC_VERSION_AT_LEAST(x,y) (defined(__GNUC__) && (__GNUC__ > x || __GNUC__ == x && __GNUC_MINOR__ >= y))
 
@@ -83,10 +77,6 @@
 #endif
 #endif
 
-#ifdef HAVE_AV_CONFIG_H
-#    include "internal.h"
-#endif /* HAVE_AV_CONFIG_H */
-
 #ifndef attribute_deprecated
 #if AV_GCC_VERSION_AT_LEAST(3,1)
 #    define attribute_deprecated __attribute__((deprecated))
@@ -103,8 +93,6 @@
 #endif
 #endif
 
-#include "mem.h"
-
 //rounded divison & shift
 #define RSHIFT(a,b) ((a) > 0 ? ((a) + ((1<<(b))>>1))>>(b) : ((a) + ((1<<(b))>>1)-1)>>(b))
 /* assume b>0 */
@@ -268,4 +256,11 @@ static inline av_const float av_clipf(float a, float amin, float amax)
         }\
     }
 
+#include "mem.h"
+
+#ifdef HAVE_AV_CONFIG_H
+#    include "config.h"
+#    include "internal.h"
+#endif /* HAVE_AV_CONFIG_H */
+
 #endif /* AVUTIL_COMMON_H */
diff --git a/libavutil/des.c b/libavutil/des.c
index 51d73a3..b851552 100644
--- a/libavutil/des.c
+++ b/libavutil/des.c
@@ -291,7 +291,10 @@ static uint64_t rand64(void) {
 }
 
 int main(void) {
-    int i, j;
+    int i;
+#ifdef GENTABLES
+    int j;
+#endif
     struct timeval tv;
     uint64_t key;
     uint64_t data;
diff --git a/libavutil/fifo.c b/libavutil/fifo.c
index 518fba2..12c6534 100644
--- a/libavutil/fifo.c
+++ b/libavutil/fifo.c
@@ -74,10 +74,12 @@ int av_fifo_realloc2(AVFifoBuffer *f, unsigned int new_size) {
     return 0;
 }
 
+#if LIBAVUTIL_VERSION_MAJOR < 50
 void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size)
 {
     av_fifo_generic_write(f, (void *)buf, size, NULL);
 }
+#endif
 
 int av_fifo_generic_write(AVFifoBuffer *f, void *src, int size, int (*func)(void*, void*, int))
 {
diff --git a/libavutil/fifo.h b/libavutil/fifo.h
index 93756e9..7901972 100644
--- a/libavutil/fifo.h
+++ b/libavutil/fifo.h
@@ -72,6 +72,7 @@ int av_fifo_read(AVFifoBuffer *f, uint8_t *buf, int buf_size);
  */
 int av_fifo_generic_read(AVFifoBuffer *f, int buf_size, void (*func)(void*, void*, int), void* dest);
 
+#if LIBAVUTIL_VERSION_MAJOR < 50
 /**
  * Writes data into an AVFifoBuffer.
  * @param *f AVFifoBuffer to write to
@@ -79,6 +80,7 @@ int av_fifo_generic_read(AVFifoBuffer *f, int buf_size, void (*func)(void*, void
  * @param size data size
  */
 attribute_deprecated void av_fifo_write(AVFifoBuffer *f, const uint8_t *buf, int size);
+#endif
 
 /**
  * Feeds data from a user supplied callback to an AVFifoBuffer.
diff --git a/libavutil/internal.h b/libavutil/internal.h
index ef1233d..7f42d54 100644
--- a/libavutil/internal.h
+++ b/libavutil/internal.h
@@ -30,6 +30,7 @@
 #    define NDEBUG
 #endif
 
+#include <limits.h>
 #include <stdint.h>
 #include <stddef.h>
 #include <assert.h>
@@ -164,8 +165,6 @@ static inline av_const int FASTDIV(int a, int b)
 
 extern const uint8_t ff_sqrt_tab[256];
 
-static inline int av_log2_16bit(unsigned int v);
-
 static inline av_const unsigned int ff_sqrt(unsigned int a)
 {
     unsigned int b;
@@ -231,7 +230,7 @@ if((y)<(x)){\
 #undef  rand
 #define rand rand_is_forbidden_due_to_state_trashing_use_av_random
 #undef  srand
-#define srand srand_is_forbidden_due_to_state_trashing_use_av_init_random
+#define srand srand_is_forbidden_due_to_state_trashing_use_av_random_init
 #undef  random
 #define random random_is_forbidden_due_to_state_trashing_use_av_random
 #undef  sprintf
@@ -242,11 +241,11 @@ if((y)<(x)){\
 #define exit exit_is_forbidden
 #ifndef LIBAVFORMAT_BUILD
 #undef  printf
-#define printf please_use_av_log
+#define printf please_use_av_log_instead_of_printf
 #undef  fprintf
-#define fprintf please_use_av_log
+#define fprintf please_use_av_log_instead_of_fprintf
 #undef  puts
-#define puts please_use_av_log
+#define puts please_use_av_log_instead_of_puts
 #undef  perror
 #define perror please_use_av_log_instead_of_perror
 #endif
@@ -260,6 +259,23 @@ if((y)<(x)){\
     }\
 }
 
+#if defined(__ICC) || defined(__SUNPRO_C)
+    #define DECLARE_ALIGNED(n,t,v)      t v __attribute__ ((aligned (n)))
+    #define DECLARE_ASM_CONST(n,t,v)    const t __attribute__ ((aligned (n))) v
+#elif defined(__GNUC__)
+    #define DECLARE_ALIGNED(n,t,v)      t v __attribute__ ((aligned (n)))
+    #define DECLARE_ASM_CONST(n,t,v)    static const t v attribute_used __attribute__ ((aligned (n)))
+#elif defined(_MSC_VER)
+    #define DECLARE_ALIGNED(n,t,v)      __declspec(align(n)) t v
+    #define DECLARE_ASM_CONST(n,t,v)    __declspec(align(n)) static const t v
+#elif HAVE_INLINE_ASM
+    #error The asm code needs alignment, but we do not know how to do it for this compiler.
+#else
+    #define DECLARE_ALIGNED(n,t,v)      t v
+    #define DECLARE_ASM_CONST(n,t,v)    static const t v
+#endif
+
+
 #if !HAVE_LLRINT
 static av_always_inline av_const long long llrint(double x)
 {
diff --git a/libavutil/log.c b/libavutil/log.c
index 9248752..5fec332 100644
--- a/libavutil/log.c
+++ b/libavutil/log.c
@@ -25,6 +25,7 @@
  */
 
 #include "avutil.h"
+#include "log.h"
 
 int av_log_level = AV_LOG_INFO;
 
diff --git a/libavutil/mathematics.c b/libavutil/mathematics.c
index eed2241..91ade22 100644
--- a/libavutil/mathematics.c
+++ b/libavutil/mathematics.c
@@ -23,6 +23,8 @@
  * Miscellaneous math routines and tables.
  */
 
+#include <assert.h>
+#include "avutil.h"
 #include "common.h"
 #include "mathematics.h"
 
@@ -53,6 +55,12 @@ int64_t av_gcd(int64_t a, int64_t b){
     else  return a;
 }
 
+#if LIBAVUTIL_VERSION_MAJOR < 50
+int64_t ff_gcd(int64_t a, int64_t b){
+    return av_gcd(a, b);
+}
+#endif
+
 int64_t av_rescale_rnd(int64_t a, int64_t b, int64_t c, enum AVRounding rnd){
     int64_t r=0;
     assert(c > 0);
diff --git a/libavutil/mem.c b/libavutil/mem.c
index 95299a1..251b1fa 100644
--- a/libavutil/mem.c
+++ b/libavutil/mem.c
@@ -1,6 +1,6 @@
 /*
  * default memory allocator for libavutil
- * Copyright (c) 2002 Fabrice Bellard.
+ * Copyright (c) 2002 Fabrice Bellard
  *
  * This file is part of FFmpeg.
  *
@@ -24,18 +24,22 @@
  * default memory allocator for libavutil.
  */
 
-#include "common.h"
-
-/* here we can use OS dependent allocation functions */
-#undef malloc
-#undef free
-#undef realloc
+#include "config.h"
 
+#include <limits.h>
 #include <stdlib.h>
+#include <string.h>
 #if HAVE_MALLOC_H
 #include <malloc.h>
 #endif
 
+#include "mem.h"
+
+/* here we can use OS dependent allocation functions */
+#undef free
+#undef malloc
+#undef realloc
+
 /* you can redefine av_malloc and av_free in your project to use your
    memory allocator. You do not need to suppress this file because the
    linker will do it automatically */
diff --git a/libavutil/mem.h b/libavutil/mem.h
index ec6e3b7..7ce6163 100644
--- a/libavutil/mem.h
+++ b/libavutil/mem.h
@@ -28,22 +28,6 @@
 
 #include "common.h"
 
-#if defined(__ICC) || defined(__SUNPRO_C)
-    #define DECLARE_ALIGNED(n,t,v)      t v __attribute__ ((aligned (n)))
-    #define DECLARE_ASM_CONST(n,t,v)    const t __attribute__ ((aligned (n))) v
-#elif defined(__GNUC__)
-    #define DECLARE_ALIGNED(n,t,v)      t v __attribute__ ((aligned (n)))
-    #define DECLARE_ASM_CONST(n,t,v)    static const t v attribute_used __attribute__ ((aligned (n)))
-#elif defined(_MSC_VER)
-    #define DECLARE_ALIGNED(n,t,v)      __declspec(align(n)) t v
-    #define DECLARE_ASM_CONST(n,t,v)    __declspec(align(n)) static const t v
-#elif HAVE_INLINE_ASM
-    #error The asm code needs alignment, but we do not know how to do it for this compiler.
-#else
-    #define DECLARE_ALIGNED(n,t,v)      t v
-    #define DECLARE_ASM_CONST(n,t,v)    static const t v
-#endif
-
 #if AV_GCC_VERSION_AT_LEAST(3,1)
     #define av_malloc_attrib __attribute__((__malloc__))
 #else
diff --git a/libavutil/random.c b/libavutil/random.c
index bafdf7a..c17686e 100644
--- a/libavutil/random.c
+++ b/libavutil/random.c
@@ -1,6 +1,6 @@
 /*
  * Mersenne Twister Random Algorithm
- * Copyright (c) 2006 Ryan Martell.
+ * Copyright (c) 2006 Ryan Martell
  * Based on A C-program for MT19937, with initialization improved 2002/1/26. Coded by
  * Takuji Nishimura and Makoto Matsumoto.
  *
@@ -55,10 +55,12 @@ void av_random_init(AVRandomState *state, unsigned int seed)
     state->index= index; // will cause it to generate untempered numbers the first iteration
 }
 
+#if LIBAVUTIL_VERSION_MAJOR < 50
 void av_init_random(unsigned int seed, AVRandomState *state)
 {
     av_random_init(state, seed);
 }
+#endif
 
 /** generate AV_RANDOM_N words at one time (which will then be tempered later) (av_random calls this; you shouldn't) */
 void av_random_generate_untempered_numbers(AVRandomState *state)
@@ -88,7 +90,7 @@ int main(void)
     int i, j;
     AVRandomState state;
 
-    av_init_random(0xdeadbeef, &state);
+    av_random_init(&state, 0xdeadbeef);
     for (j = 0; j < 10000; j++) {
         START_TIMER
         for (i = 0; i < 624; i++) {
diff --git a/libavutil/random.h b/libavutil/random.h
index 0bedcd5..1e3c299 100644
--- a/libavutil/random.h
+++ b/libavutil/random.h
@@ -1,6 +1,6 @@
 /*
  * Mersenne Twister Random Algorithm
- * Copyright (c) 2006 Ryan Martell.
+ * Copyright (c) 2006 Ryan Martell
  * Based on A C-program for MT19937, with initialization improved 2002/1/26. Coded by
  * Takuji Nishimura and Makoto Matsumoto.
  *
@@ -26,6 +26,7 @@
 
 #define AV_RANDOM_N 624
 
+#include "avutil.h"
 #include "common.h"
 
 typedef struct {
@@ -34,7 +35,9 @@ typedef struct {
 } AVRandomState;
 
 
+#if LIBAVUTIL_VERSION_MAJOR < 50
 attribute_deprecated void av_init_random(unsigned int seed, AVRandomState *state);
+#endif
 void av_random_init(AVRandomState *state, unsigned int seed); ///< To be inlined, the struct must be visible. So it does not make sense to try and keep it opaque with malloc/free-like calls.
 void av_random_generate_untempered_numbers(AVRandomState *state); ///< Regenerate the untempered numbers (must be done every 624 iterations, or it will loop).
 
diff --git a/libavutil/rational.c b/libavutil/rational.c
index 4c0216e..f7750e9 100644
--- a/libavutil/rational.c
+++ b/libavutil/rational.c
@@ -25,6 +25,7 @@
  * @author Michael Niedermayer <michaelni at gmx.at>
  */
 
+#include <assert.h>
 //#include <math.h>
 #include <limits.h>
 
diff --git a/libavutil/sha1.c b/libavutil/sha1.c
index 72c2726..9eb02c9 100644
--- a/libavutil/sha1.c
+++ b/libavutil/sha1.c
@@ -145,8 +145,6 @@ void av_sha1_final(AVSHA1* ctx, uint8_t digest[20]){
         ((uint32_t*)digest)[i]= be2me_32(ctx->state[i]);
 }
 
-// use the following to test
-// gcc -DTEST -DHAVE_AV_CONFIG_H -I.. sha1.c -O2 -W -Wall -o sha1 && time ./sha1
 #ifdef TEST
 #include <stdio.h>
 #undef printf
diff --git a/libpostproc/postprocess.c b/libpostproc/postprocess.c
index a41f28b..99e525f 100644
--- a/libpostproc/postprocess.c
+++ b/libpostproc/postprocess.c
@@ -80,7 +80,7 @@ try to unroll inner for(x=0 ... loop to avoid these damn if(x ... checks
 #include <stdlib.h>
 #include <string.h>
 //#undef HAVE_MMX2
-//#define HAVE_3DNOW
+//#define HAVE_AMD3DNOW
 //#undef HAVE_MMX
 //#undef ARCH_X86
 //#define DEBUG_BRIGHTNESS
@@ -564,7 +564,7 @@ static av_always_inline void do_a_deblock_C(uint8_t *src, int step, int stride,
 
 #if ARCH_X86
 
-#if (HAVE_MMX && !HAVE_3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT)
+#if (HAVE_MMX && !HAVE_AMD3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT)
 #define COMPILE_MMX
 #endif
 
@@ -572,7 +572,7 @@ static av_always_inline void do_a_deblock_C(uint8_t *src, int step, int stride,
 #define COMPILE_MMX2
 #endif
 
-#if (HAVE_3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT)
+#if (HAVE_AMD3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT)
 #define COMPILE_3DNOW
 #endif
 #endif /* ARCH_X86 */
@@ -581,8 +581,8 @@ static av_always_inline void do_a_deblock_C(uint8_t *src, int step, int stride,
 #define HAVE_MMX 0
 #undef HAVE_MMX2
 #define HAVE_MMX2 0
-#undef HAVE_3DNOW
-#define HAVE_3DNOW 0
+#undef HAVE_AMD3DNOW
+#define HAVE_AMD3DNOW 0
 #undef HAVE_ALTIVEC
 #define HAVE_ALTIVEC 0
 
@@ -625,10 +625,10 @@ static av_always_inline void do_a_deblock_C(uint8_t *src, int step, int stride,
 #undef RENAME
 #undef HAVE_MMX
 #undef HAVE_MMX2
-#undef HAVE_3DNOW
+#undef HAVE_AMD3DNOW
 #define HAVE_MMX 1
 #define HAVE_MMX2 0
-#define HAVE_3DNOW 1
+#define HAVE_AMD3DNOW 1
 #define RENAME(a) a ## _3DNow
 #include "postprocess_template.c"
 #endif
@@ -667,7 +667,7 @@ static inline void postProcess(const uint8_t src[], int srcStride, uint8_t dst[]
 #else //RUNTIME_CPUDETECT
 #if   HAVE_MMX2
             postProcess_MMX2(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
-#elif HAVE_3DNOW
+#elif HAVE_AMD3DNOW
             postProcess_3DNow(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
 #elif HAVE_MMX
             postProcess_MMX(src, srcStride, dst, dstStride, width, height, QPs, QPStride, isColor, c);
diff --git a/libpostproc/postprocess_internal.h b/libpostproc/postprocess_internal.h
index 6db0756..de6f0be 100644
--- a/libpostproc/postprocess_internal.h
+++ b/libpostproc/postprocess_internal.h
@@ -26,6 +26,7 @@
 #ifndef POSTPROCESS_POSTPROCESS_INTERNAL_H
 #define POSTPROCESS_POSTPROCESS_INTERNAL_H
 
+#include <string.h>
 #include "libavutil/avutil.h"
 #include "postprocess.h"
 
diff --git a/libpostproc/postprocess_template.c b/libpostproc/postprocess_template.c
index 3d9b811..f75ad87 100644
--- a/libpostproc/postprocess_template.c
+++ b/libpostproc/postprocess_template.c
@@ -33,7 +33,7 @@
 
 #if   HAVE_MMX2
 #define REAL_PAVGB(a,b) "pavgb " #a ", " #b " \n\t"
-#elif HAVE_3DNOW
+#elif HAVE_AMD3DNOW
 #define REAL_PAVGB(a,b) "pavgusb " #a ", " #b " \n\t"
 #endif
 #define PAVGB(a,b)  REAL_PAVGB(a,b)
@@ -179,7 +179,7 @@ static inline int RENAME(vertClassify)(uint8_t src[], int stride, PPContext *c){
 #if !HAVE_ALTIVEC
 static inline void RENAME(doVertLowPass)(uint8_t *src, int stride, PPContext *c)
 {
-#if HAVE_MMX2 || HAVE_3DNOW
+#if HAVE_MMX2 || HAVE_AMD3DNOW
     src+= stride*3;
     __asm__ volatile(        //"movv %0 %1 %2\n\t"
         "movq %2, %%mm0                         \n\t"  // QP,..., QP
@@ -306,7 +306,7 @@ static inline void RENAME(doVertLowPass)(uint8_t *src, int stride, PPContext *c)
         : "r" (src), "r" ((x86_reg)stride), "m" (c->pQPb)
         : "%"REG_a, "%"REG_c
     );
-#else //HAVE_MMX2 || HAVE_3DNOW
+#else //HAVE_MMX2 || HAVE_AMD3DNOW
     const int l1= stride;
     const int l2= stride + l1;
     const int l3= stride + l2;
@@ -345,7 +345,7 @@ static inline void RENAME(doVertLowPass)(uint8_t *src, int stride, PPContext *c)
 
         src++;
     }
-#endif //HAVE_MMX2 || HAVE_3DNOW
+#endif //HAVE_MMX2 || HAVE_AMD3DNOW
 }
 #endif //HAVE_ALTIVEC
 
@@ -364,7 +364,7 @@ static inline void RENAME(doVertLowPass)(uint8_t *src, int stride, PPContext *c)
  */
 static inline void RENAME(vertRK1Filter)(uint8_t *src, int stride, int QP)
 {
-#if HAVE_MMX2 || HAVE_3DNOW
+#if HAVE_MMX2 || HAVE_AMD3DNOW
     src+= stride*3;
 // FIXME rounding
     __asm__ volatile(
@@ -426,7 +426,7 @@ static inline void RENAME(vertRK1Filter)(uint8_t *src, int stride, int QP)
         : "r" (src), "r" ((x86_reg)stride)
         : "%"REG_a, "%"REG_c
     );
-#else //HAVE_MMX2 || HAVE_3DNOW
+#else //HAVE_MMX2 || HAVE_AMD3DNOW
     const int l1= stride;
     const int l2= stride + l1;
     const int l3= stride + l2;
@@ -449,7 +449,7 @@ static inline void RENAME(vertRK1Filter)(uint8_t *src, int stride, int QP)
         }
     }
 
-#endif //HAVE_MMX2 || HAVE_3DNOW
+#endif //HAVE_MMX2 || HAVE_AMD3DNOW
 }
 #endif //0
 
@@ -462,7 +462,7 @@ static inline void RENAME(vertRK1Filter)(uint8_t *src, int stride, int QP)
  */
 static inline void RENAME(vertX1Filter)(uint8_t *src, int stride, PPContext *co)
 {
-#if HAVE_MMX2 || HAVE_3DNOW
+#if HAVE_MMX2 || HAVE_AMD3DNOW
     src+= stride*3;
 
     __asm__ volatile(
@@ -548,7 +548,7 @@ static inline void RENAME(vertX1Filter)(uint8_t *src, int stride, PPContext *co)
         : "r" (src), "r" ((x86_reg)stride), "m" (co->pQPb)
         : "%"REG_a, "%"REG_c
     );
-#else //HAVE_MMX2 || HAVE_3DNOW
+#else //HAVE_MMX2 || HAVE_AMD3DNOW
 
     const int l1= stride;
     const int l2= stride + l1;
@@ -582,13 +582,13 @@ static inline void RENAME(vertX1Filter)(uint8_t *src, int stride, PPContext *co)
         }
         src++;
     }
-#endif //HAVE_MMX2 || HAVE_3DNOW
+#endif //HAVE_MMX2 || HAVE_AMD3DNOW
 }
 
 #if !HAVE_ALTIVEC
 static inline void RENAME(doVertDefFilter)(uint8_t src[], int stride, PPContext *c)
 {
-#if HAVE_MMX2 || HAVE_3DNOW
+#if HAVE_MMX2 || HAVE_AMD3DNOW
 /*
     uint8_t tmp[16];
     const int l1= stride;
@@ -1101,7 +1101,7 @@ static inline void RENAME(doVertDefFilter)(uint8_t src[], int stride, PPContext
         : "r" ((x86_reg)stride), "m" (c->pQPb)
         : "%"REG_a, "%"REG_c
     );
-#else //HAVE_MMX2 || HAVE_3DNOW
+#else //HAVE_MMX2 || HAVE_AMD3DNOW
     const int l1= stride;
     const int l2= stride + l1;
     const int l3= stride + l2;
@@ -1139,14 +1139,14 @@ static inline void RENAME(doVertDefFilter)(uint8_t src[], int stride, PPContext
         }
         src++;
     }
-#endif //HAVE_MMX2 || HAVE_3DNOW
+#endif //HAVE_MMX2 || HAVE_AMD3DNOW
 }
 #endif //HAVE_ALTIVEC
 
 #if !HAVE_ALTIVEC
 static inline void RENAME(dering)(uint8_t src[], int stride, PPContext *c)
 {
-#if HAVE_MMX2 || HAVE_3DNOW
+#if HAVE_MMX2 || HAVE_AMD3DNOW
     __asm__ volatile(
         "pxor %%mm6, %%mm6                      \n\t"
         "pcmpeqb %%mm7, %%mm7                   \n\t"
@@ -1370,7 +1370,7 @@ DERING_CORE((%0, %1, 8)    ,(%%REGd, %1, 4),%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,
         : : "r" (src), "r" ((x86_reg)stride), "m" (c->pQPb), "m"(c->pQPb2)
         : "%"REG_a, "%"REG_d, "%"REG_c
     );
-#else //HAVE_MMX2 || HAVE_3DNOW
+#else //HAVE_MMX2 || HAVE_AMD3DNOW
     int y;
     int min=255;
     int max=0;
@@ -1487,7 +1487,7 @@ DERING_CORE((%0, %1, 8)    ,(%%REGd, %1, 4),%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,
 //        src[0] = src[7]=src[stride*7]=src[stride*7 + 7]=255;
     }
 #endif
-#endif //HAVE_MMX2 || HAVE_3DNOW
+#endif //HAVE_MMX2 || HAVE_AMD3DNOW
 }
 #endif //HAVE_ALTIVEC
 
@@ -1499,7 +1499,7 @@ DERING_CORE((%0, %1, 8)    ,(%%REGd, %1, 4),%%mm2,%%mm4,%%mm0,%%mm3,%%mm5,%%mm1,
  */
 static inline void RENAME(deInterlaceInterpolateLinear)(uint8_t src[], int stride)
 {
-#if HAVE_MMX2 || HAVE_3DNOW
+#if HAVE_MMX2 || HAVE_AMD3DNOW
     src+= 4*stride;
     __asm__ volatile(
         "lea (%0, %1), %%"REG_a"                \n\t"
@@ -1552,7 +1552,7 @@ static inline void RENAME(deInterlaceInterpolateLinear)(uint8_t src[], int strid
  */
 static inline void RENAME(deInterlaceInterpolateCubic)(uint8_t src[], int stride)
 {
-#if HAVE_MMX2 || HAVE_3DNOW
+#if HAVE_MMX2 || HAVE_AMD3DNOW
     src+= stride*3;
     __asm__ volatile(
         "lea (%0, %1), %%"REG_a"                \n\t"
@@ -1594,7 +1594,7 @@ DEINT_CUBIC((%%REGd, %1), (%0, %1, 8) , (%%REGd, %1, 4), (%%REGc)    , (%%REGc,
         : : "r" (src), "r" ((x86_reg)stride)
         : "%"REG_a, "%"REG_d, "%"REG_c
     );
-#else //HAVE_MMX2 || HAVE_3DNOW
+#else //HAVE_MMX2 || HAVE_AMD3DNOW
     int x;
     src+= stride*3;
     for(x=0; x<8; x++){
@@ -1604,7 +1604,7 @@ DEINT_CUBIC((%%REGd, %1), (%0, %1, 8) , (%%REGd, %1, 4), (%%REGc)    , (%%REGc,
         src[stride*9] = CLIP((-src[stride*6] + 9*src[stride*8] + 9*src[stride*10] - src[stride*12])>>4);
         src++;
     }
-#endif //HAVE_MMX2 || HAVE_3DNOW
+#endif //HAVE_MMX2 || HAVE_AMD3DNOW
 }
 
 /**
@@ -1616,7 +1616,7 @@ DEINT_CUBIC((%%REGd, %1), (%0, %1, 8) , (%%REGd, %1, 4), (%%REGc)    , (%%REGc,
  */
 static inline void RENAME(deInterlaceFF)(uint8_t src[], int stride, uint8_t *tmp)
 {
-#if HAVE_MMX2 || HAVE_3DNOW
+#if HAVE_MMX2 || HAVE_AMD3DNOW
     src+= stride*4;
     __asm__ volatile(
         "lea (%0, %1), %%"REG_a"                \n\t"
@@ -1665,7 +1665,7 @@ DEINT_FF((%%REGd, %1), (%%REGd, %1, 2), (%0, %1, 8) , (%%REGd, %1, 4))
         : : "r" (src), "r" ((x86_reg)stride), "r"(tmp)
         : "%"REG_a, "%"REG_d
     );
-#else //HAVE_MMX2 || HAVE_3DNOW
+#else //HAVE_MMX2 || HAVE_AMD3DNOW
     int x;
     src+= stride*4;
     for(x=0; x<8; x++){
@@ -1683,7 +1683,7 @@ DEINT_FF((%%REGd, %1), (%%REGd, %1, 2), (%0, %1, 8) , (%%REGd, %1, 4))
 
         src++;
     }
-#endif //HAVE_MMX2 || HAVE_3DNOW
+#endif //HAVE_MMX2 || HAVE_AMD3DNOW
 }
 
 /**
@@ -1695,7 +1695,7 @@ DEINT_FF((%%REGd, %1), (%%REGd, %1, 2), (%0, %1, 8) , (%%REGd, %1, 4))
  */
 static inline void RENAME(deInterlaceL5)(uint8_t src[], int stride, uint8_t *tmp, uint8_t *tmp2)
 {
-#if HAVE_MMX2 || HAVE_3DNOW
+#if HAVE_MMX2 || HAVE_AMD3DNOW
     src+= stride*4;
     __asm__ volatile(
         "lea (%0, %1), %%"REG_a"                \n\t"
@@ -1755,7 +1755,7 @@ DEINT_L5(%%mm1, %%mm0, (%%REGd, %1, 2), (%0, %1, 8)    , (%%REGd, %1, 4))
         : : "r" (src), "r" ((x86_reg)stride), "r"(tmp), "r"(tmp2)
         : "%"REG_a, "%"REG_d
     );
-#else //HAVE_MMX2 || HAVE_3DNOW
+#else //HAVE_MMX2 || HAVE_AMD3DNOW
     int x;
     src+= stride*4;
     for(x=0; x<8; x++){
@@ -1784,7 +1784,7 @@ DEINT_L5(%%mm1, %%mm0, (%%REGd, %1, 2), (%0, %1, 8)    , (%%REGd, %1, 4))
 
         src++;
     }
-#endif //HAVE_MMX2 || HAVE_3DNOW
+#endif //HAVE_MMX2 || HAVE_AMD3DNOW
 }
 
 /**
@@ -1796,7 +1796,7 @@ DEINT_L5(%%mm1, %%mm0, (%%REGd, %1, 2), (%0, %1, 8)    , (%%REGd, %1, 4))
  */
 static inline void RENAME(deInterlaceBlendLinear)(uint8_t src[], int stride, uint8_t *tmp)
 {
-#if HAVE_MMX2 || HAVE_3DNOW
+#if HAVE_MMX2 || HAVE_AMD3DNOW
     src+= 4*stride;
     __asm__ volatile(
         "lea (%0, %1), %%"REG_a"                \n\t"
@@ -1843,7 +1843,7 @@ static inline void RENAME(deInterlaceBlendLinear)(uint8_t src[], int stride, uin
         : : "r" (src), "r" ((x86_reg)stride), "r" (tmp)
         : "%"REG_a, "%"REG_d
     );
-#else //HAVE_MMX2 || HAVE_3DNOW
+#else //HAVE_MMX2 || HAVE_AMD3DNOW
     int a, b, c, x;
     src+= 4*stride;
 
@@ -1886,7 +1886,7 @@ static inline void RENAME(deInterlaceBlendLinear)(uint8_t src[], int stride, uin
         src += 4;
         tmp += 4;
     }
-#endif //HAVE_MMX2 || HAVE_3DNOW
+#endif //HAVE_MMX2 || HAVE_AMD3DNOW
 }
 
 /**
@@ -2191,7 +2191,7 @@ static inline void RENAME(tempNoiseReducer)(uint8_t *src, int stride,
 
 #define FAST_L2_DIFF
 //#define L1_DIFF //u should change the thresholds too if u try that one
-#if HAVE_MMX2 || HAVE_3DNOW
+#if HAVE_MMX2 || HAVE_AMD3DNOW
     __asm__ volatile(
         "lea (%2, %2, 2), %%"REG_a"             \n\t" // 3*stride
         "lea (%2, %2, 4), %%"REG_d"             \n\t" // 5*stride
@@ -2479,7 +2479,7 @@ L2_DIFF_CORE((%0, %%REGc)  , (%1, %%REGc))
         :: "r" (src), "r" (tempBlurred), "r"((x86_reg)stride), "m" (tempBlurredPast)
         : "%"REG_a, "%"REG_d, "%"REG_c, "memory"
     );
-#else //HAVE_MMX2 || HAVE_3DNOW
+#else //HAVE_MMX2 || HAVE_AMD3DNOW
 {
     int y;
     int d=0;
@@ -2562,7 +2562,7 @@ Switch between
         }
     }
 }
-#endif //HAVE_MMX2 || HAVE_3DNOW
+#endif //HAVE_MMX2 || HAVE_AMD3DNOW
 }
 #endif //HAVE_ALTIVEC
 
@@ -3411,7 +3411,7 @@ static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[
                 : "%"REG_a, "%"REG_d
             );
 
-#elif HAVE_3DNOW
+#elif HAVE_AMD3DNOW
 //FIXME check if this is faster on an 3dnow chip or if it is faster without the prefetch or ...
 /*          prefetch(srcBlock + (((x>>3)&3) + 5)*srcStride + 32);
             prefetch(srcBlock + (((x>>3)&3) + 9)*srcStride + 32);
@@ -3547,7 +3547,7 @@ static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[
                 : "%"REG_a, "%"REG_d
             );
 
-#elif HAVE_3DNOW
+#elif HAVE_AMD3DNOW
 //FIXME check if this is faster on an 3dnow chip or if it is faster without the prefetch or ...
 /*          prefetch(srcBlock + (((x>>3)&3) + 5)*srcStride + 32);
             prefetch(srcBlock + (((x>>3)&3) + 9)*srcStride + 32);
@@ -3699,7 +3699,7 @@ static void RENAME(postProcess)(const uint8_t src[], int srcStride, uint8_t dst[
                 + dstBlock[x +14*dstStride] + dstBlock[x +15*dstStride];
         }*/
     }
-#if   HAVE_3DNOW
+#if   HAVE_AMD3DNOW
     __asm__ volatile("femms");
 #elif HAVE_MMX
     __asm__ volatile("emms");
diff --git a/libswscale/.svnrevision b/libswscale/.svnrevision
index d0e7cce..4875732 100644
--- a/libswscale/.svnrevision
+++ b/libswscale/.svnrevision
@@ -1 +1 @@
-28341
+28380
diff --git a/libswscale/rgb2rgb.c b/libswscale/rgb2rgb.c
index 5b79fea..99be2a4 100644
--- a/libswscale/rgb2rgb.c
+++ b/libswscale/rgb2rgb.c
@@ -139,11 +139,11 @@ DECLARE_ASM_CONST(8, uint64_t, blue_15mask)  = 0x0000001f0000001fULL;
 //plain C versions
 #undef HAVE_MMX
 #undef HAVE_MMX2
-#undef HAVE_3DNOW
+#undef HAVE_AMD3DNOW
 #undef HAVE_SSE2
 #define HAVE_MMX 0
 #define HAVE_MMX2 0
-#define HAVE_3DNOW 0
+#define HAVE_AMD3DNOW 0
 #define HAVE_SSE2 0
 #define RENAME(a) a ## _C
 #include "rgb2rgb_template.c"
@@ -167,9 +167,9 @@ DECLARE_ASM_CONST(8, uint64_t, blue_15mask)  = 0x0000001f0000001fULL;
 //3DNOW versions
 #undef RENAME
 #undef HAVE_MMX2
-#undef HAVE_3DNOW
+#undef HAVE_AMD3DNOW
 #define HAVE_MMX2 0
-#define HAVE_3DNOW 1
+#define HAVE_AMD3DNOW 1
 #define RENAME(a) a ## _3DNOW
 #include "rgb2rgb_template.c"
 
@@ -183,7 +183,7 @@ DECLARE_ASM_CONST(8, uint64_t, blue_15mask)  = 0x0000001f0000001fULL;
 */
 
 void sws_rgb2rgb_init(int flags){
-#if (HAVE_MMX2 || HAVE_3DNOW || HAVE_MMX)  && CONFIG_GPL
+#if (HAVE_MMX2 || HAVE_AMD3DNOW || HAVE_MMX)  && CONFIG_GPL
     if (flags & SWS_CPU_CAPS_MMX2)
         rgb2rgb_init_MMX2();
     else if (flags & SWS_CPU_CAPS_3DNOW)
@@ -191,7 +191,7 @@ void sws_rgb2rgb_init(int flags){
     else if (flags & SWS_CPU_CAPS_MMX)
         rgb2rgb_init_MMX();
     else
-#endif /* HAVE_MMX2 || HAVE_3DNOW || HAVE_MMX */
+#endif /* HAVE_MMX2 || HAVE_AMD3DNOW || HAVE_MMX */
         rgb2rgb_init_C();
 }
 
diff --git a/libswscale/rgb2rgb_template.c b/libswscale/rgb2rgb_template.c
index b988ca0..f8915e8 100644
--- a/libswscale/rgb2rgb_template.c
+++ b/libswscale/rgb2rgb_template.c
@@ -43,7 +43,7 @@
 #define MMREG_SIZE 8
 #endif
 
-#if HAVE_3DNOW
+#if HAVE_AMD3DNOW
 #define PREFETCH  "prefetch"
 #define PREFETCHW "prefetchw"
 #define PAVGB     "pavgusb"
@@ -56,7 +56,7 @@
 #define PREFETCHW " # nop"
 #endif
 
-#if HAVE_3DNOW
+#if HAVE_AMD3DNOW
 /* On K6 femms is faster than emms. On K7 femms is directly mapped to emms. */
 #define EMMS     "femms"
 #else
@@ -1914,7 +1914,7 @@ static inline void RENAME(planar2x)(const uint8_t *src, uint8_t *dst, long srcWi
         dst+= dstStride;
 
     for (y=1; y<srcHeight; y++){
-#if HAVE_MMX2 || HAVE_3DNOW
+#if HAVE_MMX2 || HAVE_AMD3DNOW
         const long mmxSize= srcWidth&~15;
         __asm__ volatile(
         "mov           %4, %%"REG_a"            \n\t"
@@ -2229,7 +2229,7 @@ static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_
         "1:                                         \n\t"
         PREFETCH"    64(%0, %%"REG_d")              \n\t"
         PREFETCH"    64(%1, %%"REG_d")              \n\t"
-#if HAVE_MMX2 || HAVE_3DNOW
+#if HAVE_MMX2 || HAVE_AMD3DNOW
         "movq          (%0, %%"REG_d"), %%mm0       \n\t"
         "movq          (%1, %%"REG_d"), %%mm1       \n\t"
         "movq         6(%0, %%"REG_d"), %%mm2       \n\t"
@@ -2290,7 +2290,7 @@ static inline void RENAME(rgb24toyv12)(const uint8_t *src, uint8_t *ydst, uint8_
         "packssdw                %%mm1, %%mm0       \n\t" // V1 V0 U1 U0
         "psraw                      $7, %%mm0       \n\t"
 
-#if HAVE_MMX2 || HAVE_3DNOW
+#if HAVE_MMX2 || HAVE_AMD3DNOW
         "movq        12(%0, %%"REG_d"), %%mm4       \n\t"
         "movq        12(%1, %%"REG_d"), %%mm1       \n\t"
         "movq        18(%0, %%"REG_d"), %%mm2       \n\t"
diff --git a/libswscale/swscale.c b/libswscale/swscale.c
index 52b709a..88ac397 100644
--- a/libswscale/swscale.c
+++ b/libswscale/swscale.c
@@ -46,7 +46,7 @@ tested special converters (most are tested actually, but I did not write it down
  YVU9 -> YV12
 
 untested special converters
-  YV12/I420 -> BGR15/BGR24/BGR32 (it is the yuv2rgb stuff, so it should be ok)
+  YV12/I420 -> BGR15/BGR24/BGR32 (it is the yuv2rgb stuff, so it should be OK)
   YV12/I420 -> YV12/I420
   YUY2/BGR15/BGR24/BGR32/RGB24/RGB32 -> same format
   BGR24 -> BGR32 & RGB24 -> RGB32
@@ -83,15 +83,15 @@ unsigned swscale_version(void)
 #undef PAVGB
 
 //#undef HAVE_MMX2
-//#define HAVE_3DNOW
+//#define HAVE_AMD3DNOW
 //#undef HAVE_MMX
 //#undef ARCH_X86
 //#define WORDS_BIGENDIAN
 #define DITHER1XBPP
 
-#define FAST_BGR2YV12 // use 7 bit coeffs instead of 15bit
+#define FAST_BGR2YV12 // use 7 bit coefficients instead of 15 bit
 
-#define RET 0xC3 //near return opcode for X86
+#define RET 0xC3 //near return opcode for x86
 
 #ifdef M_PI
 #define PI M_PI
@@ -194,10 +194,10 @@ Special versions: fast Y 1:1 scaling (no interpolation in y direction)
 TODO
 more intelligent misalignment avoidance for the horizontal scaler
 write special vertical cubic upscale version
-Optimize C code (yv12 / minmax)
-add support for packed pixel yuv input & output
+optimize C code (YV12 / minmax)
+add support for packed pixel YUV input & output
 add support for Y8 output
-optimize bgr24 & bgr32
+optimize BGR24 & BGR32
 add BGR4 output support
 write special BGR->BGR scaler
 */
@@ -257,7 +257,7 @@ DECLARE_ASM_CONST(8, uint64_t, ff_bgr24toUV[2][4]) = {
 
 DECLARE_ASM_CONST(8, uint64_t, ff_bgr24toUVOffset)= 0x0040400000404000ULL;
 
-#endif /* ARCH_X86 */
+#endif /* ARCH_X86 && CONFIG_GPL */
 
 // clipping helper table for C implementations:
 static unsigned char clip_table[768];
@@ -458,6 +458,10 @@ const char *sws_format_name(enum PixelFormat format)
             return "vdpau_mpeg1";
         case PIX_FMT_VDPAU_MPEG2:
             return "vdpau_mpeg2";
+        case PIX_FMT_VDPAU_WMV3:
+            return "vdpau_wmv3";
+        case PIX_FMT_VDPAU_VC1:
+            return "vdpau_vc1";
         default:
             return "Unknown format";
     }
@@ -467,7 +471,7 @@ static inline void yuv2yuvXinC(int16_t *lumFilter, int16_t **lumSrc, int lumFilt
                                int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
                                uint8_t *dest, uint8_t *uDest, uint8_t *vDest, int dstW, int chrDstW)
 {
-    //FIXME Optimize (just quickly writen not opti..)
+    //FIXME Optimize (just quickly written not optimized..)
     int i;
     for (i=0; i<dstW; i++)
     {
@@ -500,7 +504,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
                                 int16_t *chrFilter, int16_t **chrSrc, int chrFilterSize,
                                 uint8_t *dest, uint8_t *uDest, int dstW, int chrDstW, int dstFormat)
 {
-    //FIXME Optimize (just quickly writen not opti..)
+    //FIXME Optimize (just quickly written not optimized..)
     int i;
     for (i=0; i<dstW; i++)
     {
@@ -649,7 +653,7 @@ static inline void yuv2nv12XinC(int16_t *lumFilter, int16_t **lumSrc, int lumFil
         }
 
 #define YSCALE_YUV_2_RGBX_C(type) \
-    YSCALE_YUV_2_PACKEDX_C(type)  /* FIXME fix tables so that cliping is not needed and then use _NOCLIP*/\
+    YSCALE_YUV_2_PACKEDX_C(type)  /* FIXME fix tables so that clipping is not needed and then use _NOCLIP*/\
     r = (type *)c->table_rV[V];   \
     g = (type *)(c->table_gU[U] + c->table_gV[V]); \
     b = (type *)c->table_bU[U];   \
@@ -949,7 +953,7 @@ static inline void yuv2rgbXinC_full(SwsContext *c, int16_t *lumFilter, int16_t *
     }
 }
 
-//Note: we have C, X86, MMX, MMX2, 3DNOW version therse no 3DNOW+MMX2 one
+//Note: we have C, X86, MMX, MMX2, 3DNOW versions, there is no 3DNOW+MMX2 one
 //Plain C versions
 #if !HAVE_MMX || defined (RUNTIME_CPUDETECT) || !CONFIG_GPL
 #define COMPILE_C
@@ -957,13 +961,14 @@ static inline void yuv2rgbXinC_full(SwsContext *c, int16_t *lumFilter, int16_t *
 
 #if ARCH_PPC
 #if (HAVE_ALTIVEC || defined (RUNTIME_CPUDETECT)) && CONFIG_GPL
+#undef COMPILE_C
 #define COMPILE_ALTIVEC
-#endif //HAVE_ALTIVEC
+#endif
 #endif //ARCH_PPC
 
 #if ARCH_X86
 
-#if ((HAVE_MMX && !HAVE_3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT)) && CONFIG_GPL
+#if ((HAVE_MMX && !HAVE_AMD3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT)) && CONFIG_GPL
 #define COMPILE_MMX
 #endif
 
@@ -971,18 +976,18 @@ static inline void yuv2rgbXinC_full(SwsContext *c, int16_t *lumFilter, int16_t *
 #define COMPILE_MMX2
 #endif
 
-#if ((HAVE_3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT)) && CONFIG_GPL
+#if ((HAVE_AMD3DNOW && !HAVE_MMX2) || defined (RUNTIME_CPUDETECT)) && CONFIG_GPL
 #define COMPILE_3DNOW
 #endif
-#endif //ARCH_X86 || ARCH_X86_64
+#endif //ARCH_X86
 
 #undef HAVE_MMX
 #undef HAVE_MMX2
-#undef HAVE_3DNOW
+#undef HAVE_AMD3DNOW
 #undef HAVE_ALTIVEC
 #define HAVE_MMX 0
 #define HAVE_MMX2 0
-#define HAVE_3DNOW 0
+#define HAVE_AMD3DNOW 0
 #define HAVE_ALTIVEC 0
 
 #ifdef COMPILE_C
@@ -1000,12 +1005,12 @@ static inline void yuv2rgbXinC_full(SwsContext *c, int16_t *lumFilter, int16_t *
 
 #if ARCH_X86
 
-//X86 versions
+//x86 versions
 /*
 #undef RENAME
 #undef HAVE_MMX
 #undef HAVE_MMX2
-#undef HAVE_3DNOW
+#undef HAVE_AMD3DNOW
 #define ARCH_X86
 #define RENAME(a) a ## _X86
 #include "swscale_template.c"
@@ -1015,10 +1020,10 @@ static inline void yuv2rgbXinC_full(SwsContext *c, int16_t *lumFilter, int16_t *
 #undef RENAME
 #undef HAVE_MMX
 #undef HAVE_MMX2
-#undef HAVE_3DNOW
+#undef HAVE_AMD3DNOW
 #define HAVE_MMX 1
 #define HAVE_MMX2 0
-#define HAVE_3DNOW 0
+#define HAVE_AMD3DNOW 0
 #define RENAME(a) a ## _MMX
 #include "swscale_template.c"
 #endif
@@ -1028,10 +1033,10 @@ static inline void yuv2rgbXinC_full(SwsContext *c, int16_t *lumFilter, int16_t *
 #undef RENAME
 #undef HAVE_MMX
 #undef HAVE_MMX2
-#undef HAVE_3DNOW
+#undef HAVE_AMD3DNOW
 #define HAVE_MMX 1
 #define HAVE_MMX2 1
-#define HAVE_3DNOW 0
+#define HAVE_AMD3DNOW 0
 #define RENAME(a) a ## _MMX2
 #include "swscale_template.c"
 #endif
@@ -1041,17 +1046,17 @@ static inline void yuv2rgbXinC_full(SwsContext *c, int16_t *lumFilter, int16_t *
 #undef RENAME
 #undef HAVE_MMX
 #undef HAVE_MMX2
-#undef HAVE_3DNOW
+#undef HAVE_AMD3DNOW
 #define HAVE_MMX 1
 #define HAVE_MMX2 0
-#define HAVE_3DNOW 1
+#define HAVE_AMD3DNOW 1
 #define RENAME(a) a ## _3DNow
 #include "swscale_template.c"
 #endif
 
-#endif //ARCH_X86 || ARCH_X86_64
+#endif //ARCH_X86
 
-// minor note: the HAVE_xyz is messed up after that line so don't use it
+// minor note: the HAVE_xyz are messed up after this line so don't use them
 
 static double getSplineCoeff(double a, double b, double c, double d, double dist)
 {
@@ -1081,7 +1086,7 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
         __asm__ volatile("emms\n\t"::: "memory"); //FIXME this should not be required but it IS (even for non-MMX versions)
 #endif
 
-    // Note the +1 is for the MMXscaler which reads over the end
+    // NOTE: the +1 is for the MMX scaler which reads over the end
     *filterPos = av_malloc((dstW+1)*sizeof(int16_t));
 
     if (FFABS(xInc - 0x10000) <10) // unscaled
@@ -1130,7 +1135,7 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
             int j;
 
             (*filterPos)[i]= xx;
-                //Bilinear upscale / linear interpolate / Area averaging
+                //bilinear upscale / linear interpolate / area averaging
                 for (j=0; j<filterSize; j++)
                 {
                     int64_t coeff= fone - FFABS((xx<<16) - xDstInSrc)*(fone>>16);
@@ -1311,7 +1316,7 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
             /* preserve monotonicity because the core can't handle the filter otherwise */
             if (i<dstW-1 && (*filterPos)[i] >= (*filterPos)[i+1]) break;
 
-            // Move filter coeffs left
+            // move filter coefficients left
             for (k=1; k<filter2Size; k++)
                 filter2[i*filter2Size + k - 1]= filter2[i*filter2Size + k];
             filter2[i*filter2Size + k - 1]= 0;
@@ -1337,10 +1342,10 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
         if (minFilterSize < 5)
             filterAlign = 4;
 
-        // we really don't want to waste our time
-        // doing useless computation, so fall-back on
-        // the scalar C code for very small filter.
-        // vectorizing is worth it only if you have
+        // We really don't want to waste our time
+        // doing useless computation, so fall back on
+        // the scalar C code for very small filters.
+        // Vectorizing is worth it only if you have a
         // decent-sized vector.
         if (minFilterSize < 3)
             filterAlign = 1;
@@ -1377,7 +1382,7 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
     }
 
 
-    //FIXME try to align filterpos if possible
+    //FIXME try to align filterPos if possible
 
     //fix borders
     for (i=0; i<dstW; i++)
@@ -1385,7 +1390,7 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
         int j;
         if ((*filterPos)[i] < 0)
         {
-            // Move filter coeffs left to compensate for filterPos
+            // move filter coefficients left to compensate for filterPos
             for (j=1; j<filterSize; j++)
             {
                 int left= FFMAX(j + (*filterPos)[i], 0);
@@ -1398,7 +1403,7 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
         if ((*filterPos)[i] + filterSize > srcW)
         {
             int shift= (*filterPos)[i] + filterSize - srcW;
-            // Move filter coeffs right to compensate for filterPos
+            // move filter coefficients right to compensate for filterPos
             for (j=filterSize-2; j>=0; j--)
             {
                 int right= FFMIN(j + shift, filterSize-1);
@@ -1409,11 +1414,11 @@ static inline int initFilter(int16_t **outFilter, int16_t **filterPos, int *outF
         }
     }
 
-    // Note the +1 is for the MMXscaler which reads over the end
+    // Note the +1 is for the MMX scaler which reads over the end
     /* align at 16 for AltiVec (needed by hScale_altivec_real) */
     *outFilter= av_mallocz(*outFilterSize*(dstW+1)*sizeof(int16_t));
 
-    /* Normalize & Store in outFilter */
+    /* normalize & store in outFilter */
     for (i=0; i<dstW; i++)
     {
         int j;
@@ -1656,7 +1661,7 @@ static SwsFunc getSwsFunc(int flags){
 #else //RUNTIME_CPUDETECT
 #if   HAVE_MMX2
     return swScale_MMX2;
-#elif HAVE_3DNOW
+#elif HAVE_AMD3DNOW
     return swScale_3DNow;
 #elif HAVE_MMX
     return swScale_MMX;
@@ -2071,7 +2076,7 @@ static uint16_t roundToInt16(int64_t f){
 }
 
 /**
- * @param inv_table the yuv2rgb coeffs, normally Inverse_Table_6_9[x]
+ * @param inv_table the yuv2rgb coefficients, normally Inverse_Table_6_9[x]
  * @param fullRange if 1 then the luma range is 0..255 if 0 it is 16..235
  * @return -1 if not supported
  */
@@ -2193,7 +2198,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
     flags &= ~(SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2|SWS_CPU_CAPS_3DNOW|SWS_CPU_CAPS_ALTIVEC|SWS_CPU_CAPS_BFIN);
 #if   HAVE_MMX2
     flags |= SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_MMX2;
-#elif HAVE_3DNOW
+#elif HAVE_AMD3DNOW
     flags |= SWS_CPU_CAPS_MMX|SWS_CPU_CAPS_3DNOW;
 #elif HAVE_MMX
     flags |= SWS_CPU_CAPS_MMX;
@@ -2238,7 +2243,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
                 |SWS_BICUBLIN);
     if(!i || (i & (i-1)))
     {
-        av_log(NULL, AV_LOG_ERROR, "swScaler: Exactly one scaler algorithm must be choosen\n");
+        av_log(NULL, AV_LOG_ERROR, "swScaler: Exactly one scaler algorithm must be chosen\n");
         return NULL;
     }
 
@@ -2250,7 +2255,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
         return NULL;
     }
     if(srcW > VOFW || dstW > VOFW){
-        av_log(NULL, AV_LOG_ERROR, "swScaler: Compile time max width is "AV_STRINGIFY(VOFW)" change VOF/VOFW and recompile\n");
+        av_log(NULL, AV_LOG_ERROR, "swScaler: Compile-time maximum width is "AV_STRINGIFY(VOFW)" change VOF/VOFW and recompile\n");
         return NULL;
     }
 
@@ -2284,14 +2289,14 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
     getSubSampleFactors(&c->chrSrcHSubSample, &c->chrSrcVSubSample, srcFormat);
     getSubSampleFactors(&c->chrDstHSubSample, &c->chrDstVSubSample, dstFormat);
 
-    // reuse chroma for 2 pixles rgb/bgr unless user wants full chroma interpolation
+    // reuse chroma for 2 pixels RGB/BGR unless user wants full chroma interpolation
     if ((isBGR(dstFormat) || isRGB(dstFormat)) && !(flags&SWS_FULL_CHR_H_INT)) c->chrDstHSubSample=1;
 
     // drop some chroma lines if the user wants it
     c->vChrDrop= (flags&SWS_SRC_V_CHR_DROP_MASK)>>SWS_SRC_V_CHR_DROP_SHIFT;
     c->chrSrcVSubSample+= c->vChrDrop;
 
-    // drop every 2. pixel for chroma calculation unless user wants full chroma
+    // drop every other pixel for chroma calculation unless user wants full chroma
     if ((isBGR(srcFormat) || isRGB(srcFormat)) && !(flags&SWS_FULL_CHR_H_INP)
       && srcFormat!=PIX_FMT_RGB8      && srcFormat!=PIX_FMT_BGR8
       && srcFormat!=PIX_FMT_RGB4      && srcFormat!=PIX_FMT_BGR4
@@ -2318,7 +2323,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
 
     sws_setColorspaceDetails(c, Inverse_Table_6_9[SWS_CS_DEFAULT], srcRange, Inverse_Table_6_9[SWS_CS_DEFAULT] /* FIXME*/, dstRange, 0, 1<<16, 1<<16);
 
-    /* unscaled special Cases */
+    /* unscaled special cases */
     if (unscaled && !usesHFilter && !usesVFilter && (srcRange == dstRange || isBGR(dstFormat) || isRGB(dstFormat)))
     {
         /* yv12_to_nv12 */
@@ -2344,7 +2349,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
         if (srcFormat==PIX_FMT_BGR24 && dstFormat==PIX_FMT_YUV420P && !(flags & SWS_ACCURATE_RND))
             c->swScale= bgr24toyv12Wrapper;
 
-        /* rgb/bgr -> rgb/bgr (no dither needed forms) */
+        /* RGB/BGR -> RGB/BGR (no dither needed forms) */
         if (  (isBGR(srcFormat) || isRGB(srcFormat))
            && (isBGR(dstFormat) || isRGB(dstFormat))
            && srcFormat != PIX_FMT_BGR8      && dstFormat != PIX_FMT_BGR8
@@ -2444,7 +2449,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
         if (!c->canMMX2BeUsed && dstW >=srcW && (srcW&15)==0 && (flags&SWS_FAST_BILINEAR))
         {
             if (flags&SWS_PRINT_INFO)
-                av_log(c, AV_LOG_INFO, "output Width is not a multiple of 32 -> no MMX2 scaler\n");
+                av_log(c, AV_LOG_INFO, "output width is not a multiple of 32 -> no MMX2 scaler\n");
         }
         if (usesHFilter) c->canMMX2BeUsed=0;
     }
@@ -2467,7 +2472,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
             c->lumXInc+= 20;
             c->chrXInc+= 20;
         }
-        //we don't use the x86asm scaler if mmx is available
+        //we don't use the x86 asm scaler if MMX is available
         else if (flags & SWS_CPU_CAPS_MMX)
         {
             c->lumXInc = ((srcW-2)<<16)/(dstW-2) - 20;
@@ -2513,7 +2518,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
             initMMX2HScaler(c->chrDstW, c->chrXInc, c->funnyUVCode, c->chrMmx2Filter, c->chrMmx2FilterPos, 4);
         }
 #endif /* defined(COMPILE_MMX2) */
-    } // Init Horizontal stuff
+    } // initialize horizontal stuff
 
 
 
@@ -2553,7 +2558,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
 #endif
     }
 
-    // Calculate Buffer Sizes so that they won't run out while handling these damn slices
+    // calculate buffer sizes so that they won't run out while handling these damn slices
     c->vLumBufSize= c->vLumFilterSize;
     c->vChrBufSize= c->vChrFilterSize;
     for (i=0; i<dstH; i++)
@@ -2573,7 +2578,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
     // allocate pixbufs (we use dynamic allocation because otherwise we would need to
     c->lumPixBuf= av_malloc(c->vLumBufSize*2*sizeof(int16_t*));
     c->chrPixBuf= av_malloc(c->vChrBufSize*2*sizeof(int16_t*));
-    //Note we need at least one pixel more at the end because of the mmx code (just in case someone wanna replace the 4000/8000)
+    //Note we need at least one pixel more at the end because of the MMX code (just in case someone wanna replace the 4000/8000)
     /* align at 16 bytes for AltiVec */
     for (i=0; i<c->vLumBufSize; i++)
         c->lumPixBuf[i]= c->lumPixBuf[i+c->vLumBufSize]= av_mallocz(VOF+1);
@@ -2664,7 +2669,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
         else
         {
 #if ARCH_X86
-            av_log(c, AV_LOG_VERBOSE, "using X86-Asm scaler for horizontal scaling\n");
+            av_log(c, AV_LOG_VERBOSE, "using x86 asm scaler for horizontal scaling\n");
 #else
             if (flags & SWS_FAST_BILINEAR)
                 av_log(c, AV_LOG_VERBOSE, "using FAST_BILINEAR C scaler for horizontal scaling\n");
@@ -2691,22 +2696,22 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
         }
 
         if (dstFormat==PIX_FMT_BGR24)
-            av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR24 Converter\n",
+            av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR24 converter\n",
                    (flags & SWS_CPU_CAPS_MMX2) ? "MMX2" : ((flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C"));
         else if (dstFormat==PIX_FMT_RGB32)
-            av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR32 Converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
+            av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR32 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
         else if (dstFormat==PIX_FMT_BGR565)
-            av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR16 Converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
+            av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR16 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
         else if (dstFormat==PIX_FMT_BGR555)
-            av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR15 Converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
+            av_log(c, AV_LOG_VERBOSE, "using %s YV12->BGR15 converter\n", (flags & SWS_CPU_CAPS_MMX) ? "MMX" : "C");
 
         av_log(c, AV_LOG_VERBOSE, "%dx%d -> %dx%d\n", srcW, srcH, dstW, dstH);
     }
     if (flags & SWS_PRINT_INFO)
     {
-        av_log(c, AV_LOG_DEBUG, "Lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
+        av_log(c, AV_LOG_DEBUG, "lum srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
                c->srcW, c->srcH, c->dstW, c->dstH, c->lumXInc, c->lumYInc);
-        av_log(c, AV_LOG_DEBUG, "Chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
+        av_log(c, AV_LOG_DEBUG, "chr srcW=%d srcH=%d dstW=%d dstH=%d xInc=%d yInc=%d\n",
                c->chrSrcW, c->chrSrcH, c->chrDstW, c->chrDstH, c->chrXInc, c->chrYInc);
     }
 
@@ -2716,7 +2721,7 @@ SwsContext *sws_getContext(int srcW, int srcH, enum PixelFormat srcFormat, int d
 
 /**
  * swscale wrapper, so we don't need to export the SwsContext.
- * assumes planar YUV to be in YUV order instead of YVU
+ * Assumes planar YUV to be in YUV order instead of YVU.
  */
 int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
               int srcSliceH, uint8_t* dst[], int dstStride[]){
@@ -2816,7 +2821,7 @@ int sws_scale(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
 }
 
 /**
- * swscale wrapper, so we don't need to export the SwsContext
+ * swscale wrapper, so we don't need to export the SwsContext.
  */
 int sws_scale_ordered(SwsContext *c, uint8_t* src[], int srcStride[], int srcSliceY,
                       int srcSliceH, uint8_t* dst[], int dstStride[]){
@@ -2882,8 +2887,8 @@ SwsFilter *sws_getDefaultFilter(float lumaGBlur, float chromaGBlur,
 }
 
 /**
- * returns a normalized gaussian curve used to filter stuff
- * quality=3 is high quality, lowwer is lowwer quality
+ * Returns a normalized Gaussian curve used to filter stuff
+ * quality=3 is high quality, lower is lower quality.
  */
 SwsVector *sws_getGaussianVec(double variance, double quality){
     const int length= (int)(variance*quality + 0.5) | 1;
@@ -3150,7 +3155,7 @@ void sws_freeContext(SwsContext *c){
 #endif
     c->funnyYCode=NULL;
     c->funnyUVCode=NULL;
-#endif /* ARCH_X86 */
+#endif /* ARCH_X86 && CONFIG_GPL */
 
     av_freep(&c->lumMmx2Filter);
     av_freep(&c->chrMmx2Filter);
@@ -3164,7 +3169,7 @@ void sws_freeContext(SwsContext *c){
 /**
  * Checks if context is valid or reallocs a new one instead.
  * If context is NULL, just calls sws_getContext() to get a new one.
- * Otherwise, checks if the parameters are the same already saved in context.
+ * Otherwise, checks if the parameters are the ones already saved in context.
  * If that is the case, returns the current context.
  * Otherwise, frees context and gets a new one.
  *
diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h
index b2505c0..38db010 100644
--- a/libswscale/swscale_internal.h
+++ b/libswscale/swscale_internal.h
@@ -52,6 +52,8 @@
 #   define APCK_SIZE 16
 #endif
 
+struct SwsContext;
+
 typedef int (*SwsFunc)(struct SwsContext *context, uint8_t* src[], int srcStride[], int srcSliceY,
              int srcSliceH, uint8_t* dst[], int dstStride[]);
 
diff --git a/libswscale/swscale_template.c b/libswscale/swscale_template.c
index 2144b5a..c0e680c 100644
--- a/libswscale/swscale_template.c
+++ b/libswscale/swscale_template.c
@@ -29,14 +29,14 @@
 #undef EMMS
 #undef SFENCE
 
-#if HAVE_3DNOW
+#if HAVE_AMD3DNOW
 /* On K6 femms is faster than emms. On K7 femms is directly mapped to emms. */
 #define EMMS     "femms"
 #else
 #define EMMS     "emms"
 #endif
 
-#if HAVE_3DNOW
+#if HAVE_AMD3DNOW
 #define PREFETCH  "prefetch"
 #define PREFETCHW "prefetchw"
 #elif HAVE_MMX2
@@ -55,7 +55,7 @@
 
 #if HAVE_MMX2
 #define PAVGB(a,b) "pavgb " #a ", " #b " \n\t"
-#elif HAVE_3DNOW
+#elif HAVE_AMD3DNOW
 #define PAVGB(a,b) "pavgusb " #a ", " #b " \n\t"
 #endif
 
diff --git a/libswscale/yuv2rgb.c b/libswscale/yuv2rgb.c
index 9dedd2a..5aaa572 100644
--- a/libswscale/yuv2rgb.c
+++ b/libswscale/yuv2rgb.c
@@ -55,9 +55,9 @@ DECLARE_ASM_CONST(8, uint64_t, mmx_grnmask) = 0xfcfcfcfcfcfcfcfcULL;
 //MMX versions
 #undef RENAME
 #undef HAVE_MMX2
-#undef HAVE_3DNOW
+#undef HAVE_AMD3DNOW
 #define HAVE_MMX2 0
-#define HAVE_3DNOW 0
+#define HAVE_AMD3DNOW 0
 #define RENAME(a) a ## _MMX
 #include "yuv2rgb_template.c"
 
diff --git a/libswscale/yuv2rgb_template.c b/libswscale/yuv2rgb_template.c
index c66f24e..a850545 100644
--- a/libswscale/yuv2rgb_template.c
+++ b/libswscale/yuv2rgb_template.c
@@ -30,7 +30,7 @@
 #undef EMMS
 #undef SFENCE
 
-#if HAVE_3DNOW
+#if HAVE_AMD3DNOW
 /* On K6 femms is faster than emms. On K7 femms is directly mapped to emms. */
 #define EMMS     "femms"
 #else
diff --git a/tests/libav.regression.ref b/tests/libav.regression.ref
index 1826b89..5969c2c 100644
--- a/tests/libav.regression.ref
+++ b/tests/libav.regression.ref
@@ -27,8 +27,8 @@ af78858062599fcbba049e4a02588a15 *./tests/data/b-libav.mov
 913b6199765b1dcba196706574621c2f *./tests/data/b-libav.dv
 3600000 ./tests/data/b-libav.dv
 ./tests/data/b-libav.dv CRC=0x7787e173
-8a6452b105db3e112fb041a98eda7ea5 *./tests/data/b-libav.gxf
-805992 ./tests/data/b-libav.gxf
+8441d11ebee0465f1a672586485f3506 *./tests/data/b-libav.gxf
+805996 ./tests/data/b-libav.gxf
 ./tests/data/b-libav.gxf CRC=0x9c06676e
 66a6584f9e83e8ea3af822a3ba71fbbe *./tests/data/b-libav.nut
 329264 ./tests/data/b-libav.nut
diff --git a/tests/seek.regression.ref b/tests/seek.regression.ref
index c173300..549088d 100644
--- a/tests/seek.regression.ref
+++ b/tests/seek.regression.ref
@@ -1971,13 +1971,15 @@ ret: 0 st:-1 ts:1.894167 flags:1
 ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:75140 size:10776 flags:1
 ret: 0 st: 0 ts:0.800000 flags:0
 ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:47228 size:9634 flags:1
-ret:-1 st: 0 ts:-0.320000 flags:1
+ret: 0 st: 0 ts:-0.320000 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:44 size:8719 flags:1
 ret:-1 st:-1 ts:2.576668 flags:0
 ret: 0 st:-1 ts:1.470835 flags:1
 ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:75140 size:10776 flags:1
 ret: 0 st: 0 ts:0.360000 flags:0
 ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:23271 size:8524 flags:1
-ret:-1 st: 0 ts:-0.760000 flags:1
+ret: 0 st: 0 ts:-0.760000 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:44 size:8719 flags:1
 ret:-1 st:-1 ts:2.153336 flags:0
 ret: 0 st:-1 ts:1.047503 flags:1
 ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:47228 size:9634 flags:1
@@ -2003,13 +2005,15 @@ ret: 0 st: 0 ts:2.000000 flags:1
 ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:106167 size:11182 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
 ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:47228 size:9634 flags:1
-ret:-1 st:-1 ts:-0.222493 flags:1
+ret: 0 st:-1 ts:-0.222493 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:44 size:8719 flags:1
 ret:-1 st: 0 ts:2.680000 flags:0
 ret: 0 st: 0 ts:1.560000 flags:1
 ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:75140 size:10776 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
 ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:23271 size:8524 flags:1
-ret:-1 st:-1 ts:-0.645825 flags:1
+ret: 0 st:-1 ts:-0.645825 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:44 size:8719 flags:1
 ----------------
 tests/data/a-rv10.rm
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:239 size:10388 flags:1
@@ -2225,13 +2229,15 @@ ret: 0 st:-1 ts:1.894167 flags:1
 ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:517568 size:25636 flags:1
 ret: 0 st: 0 ts:0.800000 flags:0
 ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:326556 size:23552 flags:1
-ret:-1 st: 0 ts:-0.320000 flags:1
+ret: 0 st: 0 ts:-0.320000 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:36 size:22300 flags:1
 ret:-1 st:-1 ts:2.576668 flags:0
 ret: 0 st:-1 ts:1.470835 flags:1
 ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:517568 size:25636 flags:1
 ret: 0 st: 0 ts:0.360000 flags:0
 ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:157040 size:21896 flags:1
-ret:-1 st: 0 ts:-0.760000 flags:1
+ret: 0 st: 0 ts:-0.760000 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:36 size:22300 flags:1
 ret:-1 st:-1 ts:2.153336 flags:0
 ret: 0 st:-1 ts:1.047503 flags:1
 ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:326556 size:23552 flags:1
@@ -2257,13 +2263,15 @@ ret: 0 st: 0 ts:2.000000 flags:1
 ret: 0 st: 0 dts:1.920000 pts:1.920000 pos:722804 size:25888 flags:1
 ret: 0 st:-1 ts:0.883340 flags:0
 ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:326556 size:23552 flags:1
-ret:-1 st:-1 ts:-0.222493 flags:1
+ret: 0 st:-1 ts:-0.222493 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:36 size:22300 flags:1
 ret:-1 st: 0 ts:2.680000 flags:0
 ret: 0 st: 0 ts:1.560000 flags:1
 ret: 0 st: 0 dts:1.440000 pts:1.440000 pos:517568 size:25636 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
 ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:157040 size:21896 flags:1
-ret:-1 st:-1 ts:-0.645825 flags:1
+ret: 0 st:-1 ts:-0.645825 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:36 size:22300 flags:1
 ----------------
 tests/data/a-wmav1.asf
 ret: 0 st: 0 dts:3.100000 pts:3.100000 pos:404 size:743 flags:1
@@ -2899,59 +2907,59 @@ ret:-22 st:-1 ts:0.460008 flags:0
 ret:-22 st:-1 ts:-0.645825 flags:1
 ----------------
 tests/data/b-libav.gxf
-ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:748 size:55076 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:752 size:55076 flags:1
 ret: 0 st:-1 ts:-1.000000 flags:0
-ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:55856 size:65536 flags:1
+ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:55860 size:65536 flags:1
 ret: 0 st:-1 ts:1.894167 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751656 size:54320 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
 ret: 0 st: 0 ts:0.780000 flags:0
-ret: 0 st: 0 dts:0.800000 pts:-184467440737095520.000000 pos:661356 size:22568 flags:0
+ret: 0 st: 0 dts:0.800000 pts:-184467440737095520.000000 pos:661360 size:22568 flags:0
 ret: 0 st: 0 ts:-0.320000 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:748 size:55076 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:752 size:55076 flags:1
 ret: 0 st: 1 ts:2.580000 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751656 size:54320 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
 ret: 0 st: 1 ts:1.480000 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751656 size:54320 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
 ret: 0 st:-1 ts:0.365002 flags:0
-ret: 0 st: 0 dts:0.360000 pts:-184467440737095520.000000 pos:303892 size:23176 flags:0
+ret: 0 st: 0 dts:0.360000 pts:-184467440737095520.000000 pos:303896 size:23176 flags:0
 ret: 0 st:-1 ts:-0.740831 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:748 size:55076 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:752 size:55076 flags:1
 ret: 0 st: 0 ts:2.160000 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751656 size:54320 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
 ret: 0 st: 0 ts:1.040000 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751656 size:54320 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
 ret: 0 st: 1 ts:-0.060000 flags:0
-ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:55856 size:65536 flags:1
+ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:55860 size:65536 flags:1
 ret: 0 st: 1 ts:2.840000 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751656 size:54320 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
 ret: 0 st:-1 ts:1.730004 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751656 size:54320 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
 ret: 0 st:-1 ts:0.624171 flags:1
-ret: 0 st: 0 dts:0.600000 pts:-184467440737095520.000000 pos:476168 size:23728 flags:0
+ret: 0 st: 0 dts:0.600000 pts:-184467440737095520.000000 pos:476172 size:23728 flags:0
 ret: 0 st: 0 ts:-0.480000 flags:0
-ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:55856 size:65536 flags:1
+ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:55860 size:65536 flags:1
 ret: 0 st: 0 ts:2.420000 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751656 size:54320 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
 ret: 0 st: 1 ts:1.300000 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751656 size:54320 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
 ret: 0 st: 1 ts:0.200000 flags:1
-ret: 0 st: 0 dts:0.200000 pts:-184467440737095520.000000 pos:211052 size:20944 flags:0
+ret: 0 st: 0 dts:0.200000 pts:-184467440737095520.000000 pos:211056 size:20944 flags:0
 ret: 0 st:-1 ts:-0.904994 flags:0
-ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:55856 size:65536 flags:1
+ret: 0 st: 1 dts:0.000000 pts:0.000000 pos:55860 size:65536 flags:1
 ret: 0 st:-1 ts:1.989173 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751656 size:54320 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
 ret: 0 st: 0 ts:0.880000 flags:0
-ret: 0 st: 0 dts:0.880000 pts:-184467440737095520.000000 pos:706772 size:22456 flags:0
+ret: 0 st: 0 dts:0.880000 pts:-184467440737095520.000000 pos:706776 size:22456 flags:0
 ret: 0 st: 0 ts:-0.220000 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:748 size:55076 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:752 size:55076 flags:1
 ret: 0 st: 1 ts:2.680000 flags:0
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751656 size:54320 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
 ret: 0 st: 1 ts:1.560000 flags:1
-ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751656 size:54320 flags:1
+ret: 0 st: 0 dts:0.960000 pts:-184467440737095520.000000 pos:751660 size:54320 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
-ret: 0 st: 0 dts:0.480000 pts:-184467440737095520.000000 pos:371516 size:53804 flags:1
+ret: 0 st: 0 dts:0.480000 pts:-184467440737095520.000000 pos:371520 size:53804 flags:1
 ret: 0 st:-1 ts:-0.645825 flags:1
-ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:748 size:55076 flags:1
+ret: 0 st: 0 dts:0.000000 pts:-184467440737095520.000000 pos:752 size:55076 flags:1
 ----------------
 tests/data/b-libav.mkv
 ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:505 size:28088 flags:1
@@ -3045,13 +3053,15 @@ ret: 0 st:-1 ts:1.894167 flags:1
 ret: 0 st: 1 dts:0.952018 pts:0.952018 pos:334735 size:512 flags:1
 ret: 0 st: 0 ts:0.800000 flags:0
 ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:335247 size:27897 flags:1
-ret:-1 st: 0 ts:-0.320000 flags:1
+ret: 0 st: 0 ts:-0.320000 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:36 size:28088 flags:1
 ret:-1 st: 1 ts:2.576667 flags:0
 ret: 0 st: 1 ts:1.470839 flags:1
 ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:335247 size:27897 flags:1
 ret: 0 st:-1 ts:0.365002 flags:0
 ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:166272 size:27412 flags:1
-ret:-1 st:-1 ts:-0.740831 flags:1
+ret: 0 st:-1 ts:-0.740831 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:36 size:28088 flags:1
 ret:-1 st: 0 ts:2.160000 flags:0
 ret: 0 st: 0 ts:1.040000 flags:1
 ret: 0 st: 1 dts:0.952018 pts:0.952018 pos:334735 size:512 flags:1
@@ -3075,13 +3085,15 @@ ret: 0 st:-1 ts:1.989173 flags:1
 ret: 0 st: 1 dts:0.952018 pts:0.952018 pos:334735 size:512 flags:1
 ret: 0 st: 0 ts:0.880000 flags:0
 ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:335247 size:27897 flags:1
-ret:-1 st: 0 ts:-0.240000 flags:1
+ret: 0 st: 0 ts:-0.240000 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:36 size:28088 flags:1
 ret:-1 st: 1 ts:2.671678 flags:0
 ret: 0 st: 1 ts:1.565850 flags:1
 ret: 0 st: 0 dts:0.960000 pts:0.960000 pos:335247 size:27897 flags:1
 ret: 0 st:-1 ts:0.460008 flags:0
 ret: 0 st: 0 dts:0.480000 pts:0.480000 pos:166272 size:27412 flags:1
-ret:-1 st:-1 ts:-0.645825 flags:1
+ret: 0 st:-1 ts:-0.645825 flags:1
+ret: 0 st: 0 dts:0.000000 pts:0.000000 pos:36 size:28088 flags:1
 ----------------
 tests/data/b-libav.mpg
 ret: 0 st: 1 dts:0.500000 pts:0.500000 pos:-1 size:208 flags:1

-- 
FFmpeg packaging



More information about the pkg-multimedia-commits mailing list