Bug 566247 - Add libvpx, VP8 decoding library for WebM. r=ted
authorChris Pearce <chris@pearce.org.nz>
Wed, 09 Jun 2010 11:31:28 +1200
changeset 43343 1a95c30ec47b296a732041a9a5bff2c0d49f5eeb
parent 43342 b71fe75f19bd4fdea7a121d918828e268ccedcc1
child 43344 76e9dd2d932271371d576157ae09cf969902018f
push idunknown
push userunknown
push dateunknown
reviewersted
bugs566247
milestone1.9.3a5pre
Bug 566247 - Add libvpx, VP8 decoding library for WebM. r=ted
config/autoconf.mk.in
configure.in
media/libvpx/LICENSE
media/libvpx/Makefile.in
media/libvpx/PATENTS
media/libvpx/README_MOZILLA
media/libvpx/reduce-warnings-1.patch
media/libvpx/safeseh.asm
media/libvpx/splitmv-bounds.patch
media/libvpx/subpixel-qword.patch
media/libvpx/update.sh
media/libvpx/vp8/common/alloccommon.c
media/libvpx/vp8/common/alloccommon.h
media/libvpx/vp8/common/blockd.c
media/libvpx/vp8/common/blockd.h
media/libvpx/vp8/common/coefupdateprobs.h
media/libvpx/vp8/common/common.h
media/libvpx/vp8/common/common_types.h
media/libvpx/vp8/common/debugmodes.c
media/libvpx/vp8/common/defaultcoefcounts.h
media/libvpx/vp8/common/entropy.c
media/libvpx/vp8/common/entropy.h
media/libvpx/vp8/common/entropymode.c
media/libvpx/vp8/common/entropymode.h
media/libvpx/vp8/common/entropymv.c
media/libvpx/vp8/common/entropymv.h
media/libvpx/vp8/common/extend.c
media/libvpx/vp8/common/extend.h
media/libvpx/vp8/common/filter_c.c
media/libvpx/vp8/common/findnearmv.c
media/libvpx/vp8/common/findnearmv.h
media/libvpx/vp8/common/g_common.h
media/libvpx/vp8/common/generic/systemdependent.c
media/libvpx/vp8/common/header.h
media/libvpx/vp8/common/idct.h
media/libvpx/vp8/common/idctllm.c
media/libvpx/vp8/common/invtrans.c
media/libvpx/vp8/common/invtrans.h
media/libvpx/vp8/common/loopfilter.c
media/libvpx/vp8/common/loopfilter.h
media/libvpx/vp8/common/loopfilter_filters.c
media/libvpx/vp8/common/mbpitch.c
media/libvpx/vp8/common/modecont.c
media/libvpx/vp8/common/modecont.h
media/libvpx/vp8/common/modecontext.c
media/libvpx/vp8/common/mv.h
media/libvpx/vp8/common/onyx.h
media/libvpx/vp8/common/onyxc_int.h
media/libvpx/vp8/common/onyxd.h
media/libvpx/vp8/common/postproc.c
media/libvpx/vp8/common/postproc.h
media/libvpx/vp8/common/ppflags.h
media/libvpx/vp8/common/pragmas.h
media/libvpx/vp8/common/predictdc.c
media/libvpx/vp8/common/predictdc.h
media/libvpx/vp8/common/preproc.h
media/libvpx/vp8/common/quant_common.c
media/libvpx/vp8/common/quant_common.h
media/libvpx/vp8/common/recon.c
media/libvpx/vp8/common/recon.h
media/libvpx/vp8/common/reconinter.c
media/libvpx/vp8/common/reconinter.h
media/libvpx/vp8/common/reconintra.c
media/libvpx/vp8/common/reconintra.h
media/libvpx/vp8/common/reconintra4x4.c
media/libvpx/vp8/common/reconintra4x4.h
media/libvpx/vp8/common/segmentation_common.c
media/libvpx/vp8/common/segmentation_common.h
media/libvpx/vp8/common/setupintrarecon.c
media/libvpx/vp8/common/setupintrarecon.h
media/libvpx/vp8/common/subpixel.h
media/libvpx/vp8/common/swapyv12buffer.c
media/libvpx/vp8/common/swapyv12buffer.h
media/libvpx/vp8/common/systemdependent.h
media/libvpx/vp8/common/textblit.c
media/libvpx/vp8/common/threading.h
media/libvpx/vp8/common/treecoder.c
media/libvpx/vp8/common/treecoder.h
media/libvpx/vp8/common/type_aliases.h
media/libvpx/vp8/common/vpxerrors.h
media/libvpx/vp8/common/x86/idct_x86.h
media/libvpx/vp8/common/x86/idctllm_mmx.asm
media/libvpx/vp8/common/x86/iwalsh_mmx.asm
media/libvpx/vp8/common/x86/iwalsh_sse2.asm
media/libvpx/vp8/common/x86/loopfilter_mmx.asm
media/libvpx/vp8/common/x86/loopfilter_sse2.asm
media/libvpx/vp8/common/x86/loopfilter_x86.c
media/libvpx/vp8/common/x86/loopfilter_x86.h
media/libvpx/vp8/common/x86/postproc_mmx.asm
media/libvpx/vp8/common/x86/postproc_sse2.asm
media/libvpx/vp8/common/x86/postproc_x86.h
media/libvpx/vp8/common/x86/recon_mmx.asm
media/libvpx/vp8/common/x86/recon_sse2.asm
media/libvpx/vp8/common/x86/recon_x86.h
media/libvpx/vp8/common/x86/subpixel_mmx.asm
media/libvpx/vp8/common/x86/subpixel_sse2.asm
media/libvpx/vp8/common/x86/subpixel_x86.h
media/libvpx/vp8/common/x86/vp8_asm_stubs.c
media/libvpx/vp8/common/x86/x86_systemdependent.c
media/libvpx/vp8/decoder/dboolhuff.c
media/libvpx/vp8/decoder/dboolhuff.h
media/libvpx/vp8/decoder/decodemv.c
media/libvpx/vp8/decoder/decodemv.h
media/libvpx/vp8/decoder/decoderthreading.h
media/libvpx/vp8/decoder/decodframe.c
media/libvpx/vp8/decoder/demode.c
media/libvpx/vp8/decoder/demode.h
media/libvpx/vp8/decoder/dequantize.c
media/libvpx/vp8/decoder/dequantize.h
media/libvpx/vp8/decoder/detokenize.c
media/libvpx/vp8/decoder/detokenize.h
media/libvpx/vp8/decoder/generic/dsystemdependent.c
media/libvpx/vp8/decoder/onyxd_if.c
media/libvpx/vp8/decoder/onyxd_int.h
media/libvpx/vp8/decoder/threading.c
media/libvpx/vp8/decoder/treereader.h
media/libvpx/vp8/decoder/x86/dequantize_mmx.asm
media/libvpx/vp8/decoder/x86/dequantize_x86.h
media/libvpx/vp8/decoder/x86/x86_dsystemdependent.c
media/libvpx/vp8/vp8_dx_iface.c
media/libvpx/vpx/internal/vpx_codec_internal.h
media/libvpx/vpx/src/vpx_codec.c
media/libvpx/vpx/src/vpx_decoder.c
media/libvpx/vpx/src/vpx_decoder_compat.c
media/libvpx/vpx/src/vpx_encoder.c
media/libvpx/vpx/src/vpx_image.c
media/libvpx/vpx/vp8.h
media/libvpx/vpx/vp8cx.h
media/libvpx/vpx/vp8dx.h
media/libvpx/vpx/vp8e.h
media/libvpx/vpx/vpx_codec.h
media/libvpx/vpx/vpx_codec_impl_bottom.h
media/libvpx/vpx/vpx_codec_impl_top.h
media/libvpx/vpx/vpx_decoder.h
media/libvpx/vpx/vpx_decoder_compat.h
media/libvpx/vpx/vpx_encoder.h
media/libvpx/vpx/vpx_image.h
media/libvpx/vpx/vpx_integer.h
media/libvpx/vpx_config.asm
media/libvpx/vpx_config.h
media/libvpx/vpx_config_c.c
media/libvpx/vpx_config_generic-gnu.c
media/libvpx/vpx_config_generic-gnu.h
media/libvpx/vpx_config_x86-darwin9-gcc.asm
media/libvpx/vpx_config_x86-darwin9-gcc.c
media/libvpx/vpx_config_x86-darwin9-gcc.h
media/libvpx/vpx_config_x86-linux-gcc.asm
media/libvpx/vpx_config_x86-linux-gcc.c
media/libvpx/vpx_config_x86-linux-gcc.h
media/libvpx/vpx_config_x86-win32-vs8.asm
media/libvpx/vpx_config_x86-win32-vs8.c
media/libvpx/vpx_config_x86-win32-vs8.h
media/libvpx/vpx_config_x86_64-darwin9-gcc.asm
media/libvpx/vpx_config_x86_64-darwin9-gcc.c
media/libvpx/vpx_config_x86_64-darwin9-gcc.h
media/libvpx/vpx_mem/include/vpx_mem_intrnl.h
media/libvpx/vpx_mem/vpx_mem.c
media/libvpx/vpx_mem/vpx_mem.h
media/libvpx/vpx_ports/config.h
media/libvpx/vpx_ports/emms.asm
media/libvpx/vpx_ports/mem.h
media/libvpx/vpx_ports/vpx_timer.h
media/libvpx/vpx_ports/x86.h
media/libvpx/vpx_ports/x86_abi_support.asm
media/libvpx/vpx_ports/x86_abi_support_win32.asm
media/libvpx/vpx_scale/generic/gen_scalers.c
media/libvpx/vpx_scale/generic/scalesystemdependant.c
media/libvpx/vpx_scale/generic/vpxscale.c
media/libvpx/vpx_scale/generic/yv12config.c
media/libvpx/vpx_scale/generic/yv12extend.c
media/libvpx/vpx_scale/scale_mode.h
media/libvpx/vpx_scale/vpxscale.h
media/libvpx/vpx_scale/yv12config.h
media/libvpx/vpx_scale/yv12extend.h
media/libvpx/vpx_version.h
media/libvpx/vpx_x86-darwin9-gcc.c
media/libvpx/yasm2masm-as.sh
media/libvpx/yasm2masm.py
--- a/config/autoconf.mk.in
+++ b/config/autoconf.mk.in
@@ -154,16 +154,19 @@ MOZ_MORK = @MOZ_MORK@
 MOZ_MORKREADER = @MOZ_MORKREADER@
 MOZ_NO_FAST_LOAD = @MOZ_NO_FAST_LOAD@
 MOZ_OGG = @MOZ_OGG@
 MOZ_SYDNEYAUDIO = @MOZ_SYDNEYAUDIO@
 MOZ_WAVE = @MOZ_WAVE@
 MOZ_MEDIA = @MOZ_MEDIA@
 MOZ_VORBIS = @MOZ_VORBIS@
 MOZ_WEBM = @MOZ_WEBM@
+VPX_AS = @VPX_AS@
+VPX_ASFLAGS = @VPX_ASFLAGS@
+VPX_X86_ASM = @VPX_X86_ASM@
 NS_PRINTING = @NS_PRINTING@
 MOZ_CRASHREPORTER = @MOZ_CRASHREPORTER@
 MOZ_HELP_VIEWER = @MOZ_HELP_VIEWER@
 MOC= @MOC@
 MOZ_NSS_PATCH = @MOZ_NSS_PATCH@
 MOZ_WEBGL = @MOZ_WEBGL@
 
 MOZ_JAVAXPCOM = @MOZ_JAVAXPCOM@
--- a/configure.in
+++ b/configure.in
@@ -4907,16 +4907,19 @@ MOZ_NO_ACTIVEX_SUPPORT=1
 MOZ_NO_INSPECTOR_APIS=
 MOZ_NO_FAST_LOAD=
 MOZ_OGG=1
 MOZ_SYDNEYAUDIO=
 MOZ_VORBIS=
 MOZ_WAVE=1
 MOZ_MEDIA=
 MOZ_WEBM=1
+VPX_AS=
+VPX_ASFLAGS=
+VPX_X86_ASM=
 MOZ_PANGO=1
 MOZ_PERMISSIONS=1
 MOZ_PLACES=1
 MOZ_PLAINTEXT_EDITOR_ONLY=
 MOZ_PLUGINS=1
 MOZ_PREF_EXTENSIONS=1
 MOZ_PROFILELOCKING=1
 MOZ_PSM=1
@@ -5893,16 +5896,57 @@ MOZ_ARG_DISABLE_BOOL(vp8,
     MOZ_WEBM=,
     MOZ_WEBM=1)
 
 if test -n "$MOZ_WEBM"; then
     AC_DEFINE(MOZ_WEBM)
     MOZ_SYDNEYAUDIO=1
     MOZ_MEDIA=1
     MOZ_VORBIS=1
+
+    dnl Detect if we can use an assembler to compile optimized assembly for libvpx.
+    dnl For Win32 (MSVC) we must use MASM.
+    if test "$OS_ARCH" = "WINNT" -a "$CPU_ARCH" = "x86" -a "$GNU_CC" != "yes"; then
+        AC_MSG_CHECKING([for MASM assembler])
+        AC_CHECK_PROGS(VPX_AS, ml, "")
+        if test -n "$VPX_AS"; then
+          VPX_X86_ASM=1
+          VPX_AS='$(topsrcdir)/media/libvpx/yasm2masm-as.sh'
+        else
+            AC_MSG_ERROR([Need MASM (ml.exe) in order to assemble libvpx optimized assembly. Either disable webm (reconfigure with --disable-webm) or install MASM. MASM is included in the Windows 7 SDK, or you can download MASM directly from http://www.microsoft.com/downloads/details.aspx?familyid=7a1c9da0-0510-44a2-b042-7ef370530c64&displaylang=en])
+        fi
+    else 
+
+      dnl For Darwin x86, Darwin x86_64, and Linux x86 we can use YASM.
+      AC_MSG_CHECKING([for YASM assembler])
+      AC_CHECK_PROGS(VPX_AS, yasm, "")
+      if test -n "$VPX_AS"; then
+        dnl We have YASM, see if we have assembly on this platform.  
+        case "$OS_ARCH:$OS_TEST" in
+        Linux:x86|Linux:i?86)
+          VPX_ASFLAGS="-f elf32 -rnasm -pnasm"
+          VPX_X86_ASM=1
+        ;;
+        Darwin:i?86)
+          VPX_ASFLAGS="-f macho32 -rnasm -pnasm -DPIC"
+          VPX_X86_ASM=1
+        ;;
+        Darwin:x86_64)
+          VPX_ASFLAGS="-f macho64 -rnasm -pnasm -DPIC"
+          VPX_X86_ASM=1
+        ;;
+        esac
+      fi # end have YASM
+    fi # end !WINNT
+
+    if test -n "$VPX_X86_ASM"; then
+      AC_DEFINE(VPX_X86_ASM)
+    else
+      AC_MSG_WARN([No assembler or assembly support for libvpx, using unoptimized C routines.])
+    fi
 fi
 
 dnl ========================================================
 dnl = Disable Wave decoder support
 dnl ========================================================
 MOZ_ARG_DISABLE_BOOL(wave,
 [  --disable-wave          Disable Wave decoder support],
     MOZ_WAVE=,)
@@ -8760,16 +8804,19 @@ AC_SUBST(MOZ_NSS_PATCH)
 
 AC_SUBST(MOZ_MEDIA)
 AC_SUBST(MOZ_SYDNEYAUDIO)
 AC_SUBST(MOZ_WAVE)
 AC_SUBST(MOZ_VORBIS)
 AC_SUBST(MOZ_WEBM)
 AC_SUBST(MOZ_OGG)
 AC_SUBST(MOZ_ALSA_LIBS)
+AC_SUBST(VPX_AS)
+AC_SUBST(VPX_ASFLAGS)
+AC_SUBST(VPX_X86_ASM)
 
 if test "$USING_HCC"; then
    CC='${topsrcdir}/build/hcc'
    CC="$CC '$_OLDCC'"
    CXX='${topsrcdir}/build/hcpp'
    CXX="$CXX '$_OLDCXX'"
    AC_SUBST(CC)
    AC_SUBST(CXX)
new file mode 100644
--- /dev/null
+++ b/media/libvpx/LICENSE
@@ -0,0 +1,30 @@
+Copyright (c) 2010, Google Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+
+  * Redistributions of source code must retain the above copyright
+    notice, this list of conditions and the following disclaimer.
+
+  * Redistributions in binary form must reproduce the above copyright
+    notice, this list of conditions and the following disclaimer in
+    the documentation and/or other materials provided with the
+    distribution.
+
+  * Neither the name of Google nor the names of its contributors may
+    be used to endorse or promote products derived from this software
+    without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
new file mode 100644
--- /dev/null
+++ b/media/libvpx/Makefile.in
@@ -0,0 +1,202 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Mozilla code.
+#
+# The Initial Developer of the Original Code is the Mozilla Foundation.
+# Portions created by the Initial Developer are Copyright (C) 2010
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#  Chris Pearce <chris@pearce.org.nz>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+
+DEPTH = ../..
+topsrcdir = @top_srcdir@
+srcdir = @srcdir@
+VPATH = @srcdir@
+
+include $(DEPTH)/config/autoconf.mk
+
+DEFINES += -DHAVE_CONFIG_H=vpx_config.h
+
+MODULE = vpx
+LIBRARY_NAME = vpx
+FORCE_STATIC_LIB= 1
+
+LOCAL_INCLUDES += \
+  -I. \
+  -I$(topsrcdir)/media/libvpx \
+  -I$(topsrcdir)/media/libvpx/vp8/ \
+  -I$(topsrcdir)/media/libvpx/vp8/common/ \
+  -I$(topsrcdir)/media/libvpx/vp8/common/x86 \
+  -I$(topsrcdir)/media/libvpx/vp8/decoder \
+  -I$(topsrcdir)/media/libvpx/vp8/decoder/x86 \
+  -I$(topsrcdir)/media/libvpx/vpx_codec \
+  -I$(topsrcdir)/media/libvpx/vpx_mem/ \
+  -I$(topsrcdir)/media/libvpx/vpx_mem/include \
+  -I$(topsrcdir)/media/libvpx/vpx_ports/ \
+  -I$(topsrcdir)/media/libvpx/vpx_scale/ \
+  $(NULL)
+
+VPATH += \
+  $(srcdir)/vpx \
+  $(srcdir)/vpx/src \
+  $(srcdir)/vpx_mem \
+  $(srcdir)/vpx_mem/include \
+  $(srcdir)/vpx_ports \
+  $(srcdir)/vpx_scale \
+  $(srcdir)/vpx_scale/generic \
+  $(srcdir)/vp8 \
+  $(srcdir)/vp8/common \
+  $(srcdir)/vp8/common/generic \
+  $(srcdir)/vp8/common/x86 \
+  $(srcdir)/vp8/decoder \
+  $(srcdir)/vp8/decoder/generic \
+  $(srcdir)/vp8/decoder/x86 \
+  $(NULL)
+
+ASM_SUFFIX=asm
+AS=$(VPX_AS)
+ASFLAGS=$(VPX_ASFLAGS) -I$(topsrcdir)/media/libvpx/ -I$(topsrcdir)/media/libvpx/vpx_ports/
+
+EXPORTS_NAMESPACES = vpx
+
+EXPORTS_vpx = \
+  vp8.h \
+  vp8cx.h \
+  vp8dx.h \
+  vp8e.h \
+  vpx_codec.h \
+  vpx_codec_impl_bottom.h \
+  vpx_codec_impl_top.h \
+  vpx_decoder.h \
+  vpx_decoder_compat.h \
+  vpx_encoder.h\
+  vpx_image.h \
+  vpx_mem_intrnl.h \
+  vpx_mem.h \
+  config.h \
+  mem.h \
+  vpx_integer.h \
+  vpx_timer.h \
+  x86.h \
+  scale_mode.h \
+  vpxscale.h \
+  yv12config.h \
+  yv12extend.h \
+  $(NULL)
+
+CSRCS += \
+  vpx_config_c.c \
+  systemdependent.c \
+  alloccommon.c \
+  blockd.c \
+  debugmodes.c \
+  dsystemdependent.c \
+  entropy.c \
+  entropymode.c \
+  entropymv.c \
+  extend.c \
+  filter_c.c \
+  findnearmv.c \
+  idctllm.c \
+  invtrans.c \
+  loopfilter.c \
+  loopfilter_filters.c \
+  mbpitch.c \
+  modecont.c \
+  modecontext.c \
+  postproc.c \
+  predictdc.c \
+  quant_common.c \
+  recon.c \
+  reconinter.c \
+  reconintra.c \
+  reconintra4x4.c \
+  segmentation_common.c \
+  setupintrarecon.c \
+  swapyv12buffer.c \
+  textblit.c \
+  treecoder.c \
+  dboolhuff.c \
+  decodemv.c \
+  decodframe.c \
+  demode.c \
+  dequantize.c \
+  detokenize.c \
+  onyxd_if.c \
+  threading.c \
+  vp8_dx_iface.c \
+  vpx_codec.c \
+  vpx_decoder.c \
+  vpx_decoder_compat.c \
+  vpx_encoder.c \
+  vpx_image.c \
+  vpx_mem.c \
+  gen_scalers.c \
+  vpxscale.c \
+  scalesystemdependant.c \
+  yv12config.c \
+  yv12extend.c \
+  $(NULL)
+
+ifdef VPX_X86_ASM
+# Building on an x86 platform with a supported assembler, include
+# the optimized assembly in the build.
+CSRCS += \
+  loopfilter_x86.c \
+  vp8_asm_stubs.c \
+  x86_systemdependent.c \
+  x86_dsystemdependent.c \
+  $(NULL)
+
+ASFILES += \
+  idctllm_mmx.asm \
+  iwalsh_mmx.asm \
+  iwalsh_sse2.asm \
+  loopfilter_mmx.asm \
+  loopfilter_sse2.asm \
+  postproc_mmx.asm \
+  postproc_sse2.asm \
+  recon_mmx.asm \
+  recon_sse2.asm \
+  subpixel_mmx.asm \
+  subpixel_sse2.asm \
+  dequantize_mmx.asm \
+  emms.asm \
+  $(NULL)
+
+ifeq ($(OS_ARCH),WINNT)
+ASFILES += \
+  safeseh.asm \
+  $(NULL)
+endif
+
+endif
+ 
+include $(topsrcdir)/config/rules.mk
new file mode 100644
--- /dev/null
+++ b/media/libvpx/PATENTS
@@ -0,0 +1,22 @@
+Additional IP Rights Grant (Patents)
+
+"This implementation" means the copyrightable works distributed by
+Google as part of the WebM Project.
+
+Google hereby grants to you a perpetual, worldwide, non-exclusive,
+no-charge, royalty-free, irrevocable (except as stated in this section)
+patent license to make, have made, use, offer to sell, sell, import,
+transfer, and otherwise run, modify and propagate the contents of this
+implementation of VP8, where such license applies only to those patent
+claims, both currently owned by Google and acquired in the future,
+licensable by Google that are necessarily infringed by this
+implementation of VP8. This grant does not include claims that would be
+infringed only as a consequence of further modification of this
+implementation. If you or your agent or exclusive licensee institute or
+order or agree to the institution of patent litigation against any
+entity (including a cross-claim or counterclaim in a lawsuit) alleging
+that this implementation of VP8 or any code incorporated within this
+implementation of VP8 constitutes direct or contributory patent
+infringement, or inducement of patent infringement, then any patent
+rights granted to you under this License for this implementation of VP8
+shall terminate as of the date such litigation is filed.
new file mode 100644
--- /dev/null
+++ b/media/libvpx/README_MOZILLA
@@ -0,0 +1,2 @@
+Using libvpx pulled from git://review.webmproject.org/libvpx.git
+Commit ID: 0dd78af3e9b089eacc9af280adfb5549fc7ecdcd
new file mode 100644
--- /dev/null
+++ b/media/libvpx/reduce-warnings-1.patch
@@ -0,0 +1,168 @@
+diff --git a/media/libvpx/vp8/common/blockd.h b/media/libvpx/vp8/common/blockd.h
+--- a/media/libvpx/vp8/common/blockd.h
++++ b/media/libvpx/vp8/common/blockd.h
+@@ -90,17 +90,17 @@ typedef enum
+     MB_MODE_COUNT
+ } MB_PREDICTION_MODE;
+ 
+ // Macroblock level features
+ typedef enum
+ {
+     MB_LVL_ALT_Q = 0,               // Use alternate Quantizer ....
+     MB_LVL_ALT_LF = 1,              // Use alternate loop filter value...
+-    MB_LVL_MAX = 2,                 // Number of MB level features supported
++    MB_LVL_MAX = 2                 // Number of MB level features supported
+ 
+ } MB_LVL_FEATURES;
+ 
+ // Segment Feature Masks
+ #define SEGMENT_ALTQ    0x01
+ #define SEGMENT_ALT_LF  0x02
+ 
+ #define VP8_YMODES  (B_PRED + 1)
+diff --git a/media/libvpx/vp8/common/ppflags.h b/media/libvpx/vp8/common/ppflags.h
+--- a/media/libvpx/vp8/common/ppflags.h
++++ b/media/libvpx/vp8/common/ppflags.h
+@@ -15,12 +15,12 @@ enum
+ {
+     VP8D_NOFILTERING    = 0,
+     VP8D_DEBLOCK        = 1,
+     VP8D_DEMACROBLOCK   = 2,
+     VP8D_ADDNOISE       = 4,
+     VP8D_DEBUG_LEVEL1   = 8,
+     VP8D_DEBUG_LEVEL2   = 16,
+     VP8D_DEBUG_LEVEL3   = 32,
+-    VP8D_DEBUG_LEVEL4   = 64,
++    VP8D_DEBUG_LEVEL4   = 64
+ };
+ 
+ #endif
+diff --git a/media/libvpx/vpx/vp8.h b/media/libvpx/vpx/vp8.h
+--- a/media/libvpx/vpx/vp8.h
++++ b/media/libvpx/vpx/vp8.h
+@@ -48,17 +48,17 @@ enum vp8_dec_control_id
+  *
+  * The set of macros define VP8 decoder post processing flags
+  */
+ enum vp8_postproc_level
+ {
+     VP8_NOFILTERING    = 0,
+     VP8_DEBLOCK        = 1,
+     VP8_DEMACROBLOCK   = 2,
+-    VP8_ADDNOISE       = 4,
++    VP8_ADDNOISE       = 4
+ };
+ 
+ /*!\brief post process flags
+  *
+  * This define a structure that describe the post processing settings. For
+  * the best objective measure (using thet PSNR metric) set post_proc_flag
+  * to VP8_DEBLOCK and deblocking_level to 1.
+  */
+diff --git a/media/libvpx/vpx/vpx_codec.h b/media/libvpx/vpx/vpx_codec.h
+--- a/media/libvpx/vpx/vpx_codec.h
++++ b/media/libvpx/vpx/vpx_codec.h
+@@ -57,17 +57,17 @@ extern "C" {
+ #define DEPRECATED
+ #define DECLSPEC_DEPRECATED /**< \copydoc #DEPRECATED */
+ #endif
+ #endif
+ 
+     /*!\brief Decorator indicating a function is potentially unused */
+ #ifdef UNUSED
+ #elif __GNUC__
+-#define UNUSED __attribute__ ((unused));
++#define UNUSED __attribute__ ((unused))
+ #else
+ #define UNUSED
+ #endif
+ 
+     /*!\brief Current ABI version number
+      *
+      * \internal
+      * If this file is altered in any way that changes the ABI, this value
+@@ -123,17 +123,17 @@ extern "C" {
+         /*!\brief An application-supplied parameter is not valid.
+          *
+          */
+         VPX_CODEC_INVALID_PARAM,
+ 
+         /*!\brief An iterator reached the end of list.
+          *
+          */
+-        VPX_CODEC_LIST_END,
++        VPX_CODEC_LIST_END
+ 
+     }
+     vpx_codec_err_t;
+ 
+ 
+     /*! \brief Codec capabilities bitfield
+      *
+      *  Each codec advertises the capabilities it supports as part of its
+diff --git a/media/libvpx/vpx/vpx_decoder_compat.h b/media/libvpx/vpx/vpx_decoder_compat.h
+--- a/media/libvpx/vpx/vpx_decoder_compat.h
++++ b/media/libvpx/vpx/vpx_decoder_compat.h
+@@ -73,17 +73,17 @@ extern "C" {
+         /*!\brief An application-supplied parameter is not valid.
+          *
+          */
+         VPX_DEC_INVALID_PARAM = VPX_CODEC_INVALID_PARAM,
+ 
+         /*!\brief An iterator reached the end of list.
+          *
+          */
+-        VPX_DEC_LIST_END = VPX_CODEC_LIST_END,
++        VPX_DEC_LIST_END = VPX_CODEC_LIST_END
+ 
+     }
+     vpx_dec_err_t;
+ 
+     /*! \brief Decoder capabilities bitfield
+      *
+      *  Each decoder advertises the capabilities it supports as part of its
+      *  ::vpx_dec_iface_t interface structure. Capabilities are extra interfaces
+diff --git a/media/libvpx/vpx/vpx_encoder.h b/media/libvpx/vpx/vpx_encoder.h
+--- a/media/libvpx/vpx/vpx_encoder.h
++++ b/media/libvpx/vpx/vpx_encoder.h
+@@ -166,17 +166,17 @@ extern "C" {
+     } vpx_rational_t; /**< alias for struct vpx_rational */
+ 
+ 
+     /*!\brief Multi-pass Encoding Pass */
+     enum vpx_enc_pass
+     {
+         VPX_RC_ONE_PASS,   /**< Single pass mode */
+         VPX_RC_FIRST_PASS, /**< First pass of multi-pass mode */
+-        VPX_RC_LAST_PASS,  /**< Final pass of multi-pass mode */
++        VPX_RC_LAST_PASS  /**< Final pass of multi-pass mode */
+     };
+ 
+ 
+     /*!\brief Rate control mode */
+     enum vpx_rc_mode
+     {
+         VPX_VBR, /**< Variable Bit Rate (VBR) mode */
+         VPX_CBR  /**< Constant Bit Rate (CBR) mode */
+diff --git a/media/libvpx/vpx/vpx_image.h b/media/libvpx/vpx/vpx_image.h
+--- a/media/libvpx/vpx/vpx_image.h
++++ b/media/libvpx/vpx/vpx_image.h
+@@ -50,17 +50,17 @@ extern "C" {
+         VPX_IMG_FMT_RGB32_LE, /**< 32 bit packed BGR0 */
+         VPX_IMG_FMT_ARGB,     /**< 32 bit packed ARGB, alpha=255 */
+         VPX_IMG_FMT_ARGB_LE,  /**< 32 bit packed BGRA, alpha=255 */
+         VPX_IMG_FMT_RGB565_LE,  /**< 16 bit per pixel, gggbbbbb rrrrrggg */
+         VPX_IMG_FMT_RGB555_LE,  /**< 16 bit per pixel, gggbbbbb 0rrrrrgg */
+         VPX_IMG_FMT_YV12    = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 1, /**< planar YVU */
+         VPX_IMG_FMT_I420    = VPX_IMG_FMT_PLANAR | 2,
+         VPX_IMG_FMT_VPXYV12 = VPX_IMG_FMT_PLANAR | VPX_IMG_FMT_UV_FLIP | 3, /** < planar 4:2:0 format with vpx color space */
+-        VPX_IMG_FMT_VPXI420 = VPX_IMG_FMT_PLANAR | 4,  /** < planar 4:2:0 format with vpx color space */
++        VPX_IMG_FMT_VPXI420 = VPX_IMG_FMT_PLANAR | 4  /** < planar 4:2:0 format with vpx color space */
+     }
+     vpx_img_fmt_t; /**< alias for enum vpx_img_fmt */
+ 
+ #if !defined(VPX_CODEC_DISABLE_COMPAT) || !VPX_CODEC_DISABLE_COMPAT
+ #define IMG_FMT_PLANAR         VPX_IMG_FMT_PLANAR     /**< \deprecated Use #VPX_IMG_FMT_PLANAR */
+ #define IMG_FMT_UV_FLIP        VPX_IMG_FMT_UV_FLIP    /**< \deprecated Use #VPX_IMG_FMT_UV_FLIP */
+ #define IMG_FMT_HAS_ALPHA      VPX_IMG_FMT_HAS_ALPHA  /**< \deprecated Use #VPX_IMG_FMT_HAS_ALPHA */
+ 
new file mode 100644
--- /dev/null
+++ b/media/libvpx/safeseh.asm
@@ -0,0 +1,46 @@
+; ***** BEGIN LICENSE BLOCK *****
+; Version: MPL 1.1/GPL 2.0/LGPL 2.1
+;
+; The contents of this file are subject to the Mozilla Public License Version
+; 1.1 (the "License"); you may not use this file except in compliance with
+; the License. You may obtain a copy of the License at
+; http://www.mozilla.org/MPL/
+;
+; Software distributed under the License is distributed on an "AS IS" basis,
+; WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+; for the specific language governing rights and limitations under the
+; License.
+;
+; The Original Code is Mozilla code.
+;
+; The Initial Developer of the Original Code is the Mozilla Foundation.
+; Portions created by the Initial Developer are Copyright (C) 2010
+; the Initial Developer. All Rights Reserved.
+;
+; Contributor(s):
+;  Chris Pearce <chris@pearce.org.nz>
+;
+; Alternatively, the contents of this file may be used under the terms of
+; either the GNU General Public License Version 2 or later (the "GPL"), or
+; the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+; in which case the provisions of the GPL or the LGPL are applicable instead
+; of those above. If you wish to allow use of your version of this file only
+; under the terms of either the GPL or the LGPL, and not to allow others to
+; use your version of this file under the terms of the MPL, indicate your
+; decision by deleting the provisions above and replace them with the notice
+; and other provisions required by the GPL or the LGPL. If you do not delete
+; the provisions above, a recipient may use your version of this file under
+; the terms of any one of the MPL, the GPL or the LGPL.
+;
+; ***** END LICENSE BLOCK *****
+
+.686p
+.XMM
+.model flat, C
+option casemap :none    ; be case-insensitive
+.code
+public _MyHandler
+_MyHandler:
+  mov	eax,1	; 1 means let default handler handle exception
+  ret
+end
new file mode 100644
--- /dev/null
+++ b/media/libvpx/splitmv-bounds.patch
@@ -0,0 +1,32 @@
+diff --git a/media/libvpx/vp8/decoder/decodemv.c b/media/libvpx/vp8/decoder/decodemv.c
+--- a/media/libvpx/vp8/decoder/decodemv.c
++++ b/media/libvpx/vp8/decoder/decodemv.c
+@@ -264,16 +264,28 @@ void vp8_decode_mode_mvs(VP8D_COMP *pbi)
+ #ifdef VPX_MODE_COUNT
+                             vp8_mv_cont_count[mv_contz][2]++;
+ #endif
+                             break;
+                         default:
+                             break;
+                         }
+ 
++                        /* Clip the MV for this partition so that it does
++                            not extend to far out of image. */
++                        if (mv->col < (xd->mb_to_left_edge - LEFT_TOP_MARGIN))
++                            mv->col = xd->mb_to_left_edge - LEFT_TOP_MARGIN;
++                        else if (mv->col > xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN + 7)
++                            mv->col = xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN + 7;
++
++                        if (mv->row < (xd->mb_to_top_edge - LEFT_TOP_MARGIN))
++                            mv->row = xd->mb_to_top_edge - LEFT_TOP_MARGIN;
++                        else if (mv->row > xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN + 7)
++                            mv->row = xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN + 7;
++
+                         /* Fill (uniform) modes, mvs of jth subset.
+                            Must do it here because ensuing subsets can
+                            refer back to us via "left" or "above". */
+                         do
+                             if (j == L[k])
+                                 mi->bmi[k] = *bmi;
+ 
+                         while (++k < 16);
new file mode 100644
--- /dev/null
+++ b/media/libvpx/subpixel-qword.patch
@@ -0,0 +1,22 @@
+diff --git a/media/libvpx/vp8/common/x86/subpixel_sse2.asm b/media/libvpx/vp8/common/x86/subpixel_sse2.asm
+--- a/media/libvpx/vp8/common/x86/subpixel_sse2.asm
++++ b/media/libvpx/vp8/common/x86/subpixel_sse2.asm
+@@ -1003,17 +1003,17 @@ next_row8x8:
+         paddw       xmm3,       xmm7
+ 
+         movdqa      xmm7,       xmm4
+ 
+         paddw       xmm3,       [rd GLOBAL]         ; xmm3 += round value
+         psraw       xmm3,       VP8_FILTER_SHIFT        ; xmm3 /= 128
+ 
+         packuswb    xmm3,       xmm0
+-        movq        [rdi],      xmm3                 ; store the results in the destination
++        movq        QWORD PTR [rdi], xmm3           ; store the results in the destination
+ 
+         add         rsp,        16                 ; next line
+         add         rdi,        rdx
+ 
+         cmp         rdi,        rcx
+         jne         next_row8x8
+ 
+     ;add rsp, 144
new file mode 100755
--- /dev/null
+++ b/media/libvpx/update.sh
@@ -0,0 +1,240 @@
+#!/bin/bash
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is Mozilla code.
+#
+# The Initial Developer of the Original Code is the Mozilla Foundation.
+# Portions created by the Initial Developer are Copyright (C) 2010
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#  Chris Pearce <chris@pearce.org.nz>
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+if [ $# -lt 1 ]; then
+  echo Usage: update.sh /path/to/libvpx/
+  echo The libvpx dir must contain a directory "objdir" with the following directories configured in it:
+  echo   * objdir/x86-win32-vs8
+  echo   * objdir/x86-linux-gcc
+  echo   * objdir/generic-gnu
+  echo   * objdir/x86-darwin9-gcc
+  echo   * objdir/x86_64-darwin9-gcc
+  echo You can configure these from objdir/$target with the following command:
+  echo $ ..configure --target=$target --disable-vp8-encoder --disable-examples --disable-install-docs
+  echo On Mac, you also need --enable-pic
+  exit -1
+fi
+
+# These are relative to SDK source dir.
+commonFiles=(
+  vp8/common/alloccommon.c
+  vp8/common/blockd.c
+  vp8/common/debugmodes.c
+  vp8/common/entropy.c
+  vp8/common/entropymode.c
+  vp8/common/entropymv.c
+  vp8/common/extend.c
+  vp8/common/filter_c.c
+  vp8/common/findnearmv.c
+  vp8/common/generic/systemdependent.c
+  vp8/common/idctllm.c
+  vp8/common/invtrans.c
+  vp8/common/loopfilter.c
+  vp8/common/loopfilter_filters.c
+  vp8/common/mbpitch.c
+  vp8/common/modecont.c
+  vp8/common/modecontext.c
+  vp8/common/postproc.c
+  vp8/common/predictdc.c
+  vp8/common/quant_common.c
+  vp8/common/recon.c
+  vp8/common/reconinter.c
+  vp8/common/reconintra4x4.c
+  vp8/common/reconintra.c
+  vp8/common/segmentation_common.c
+  vp8/common/setupintrarecon.c
+  vp8/common/swapyv12buffer.c
+  vp8/common/textblit.c
+  vp8/common/treecoder.c
+  vp8/common/x86/loopfilter_x86.c
+  vp8/common/x86/vp8_asm_stubs.c
+  vp8/common/x86/x86_systemdependent.c
+  vp8/decoder/dboolhuff.c
+  vp8/decoder/decodemv.c
+  vp8/decoder/decodframe.c
+  vp8/decoder/demode.c
+  vp8/decoder/dequantize.c
+  vp8/decoder/detokenize.c
+  vp8/decoder/generic/dsystemdependent.c
+  vp8/decoder/onyxd_if.c
+  vp8/decoder/threading.c
+  vp8/decoder/x86/x86_dsystemdependent.c
+  vp8/vp8_dx_iface.c
+  vpx/src/vpx_codec.c
+  vpx/src/vpx_decoder.c
+  vpx/src/vpx_decoder_compat.c
+  vpx/src/vpx_encoder.c
+  vpx/src/vpx_image.c
+  vpx_mem/vpx_mem.c
+  vpx_scale/generic/gen_scalers.c
+  vpx_scale/generic/scalesystemdependant.c
+  vpx_scale/generic/vpxscale.c
+  vpx_scale/generic/yv12config.c
+  vpx_scale/generic/yv12extend.c
+  vp8/common/alloccommon.h
+  vp8/common/blockd.h
+  vp8/common/coefupdateprobs.h
+  vp8/common/common.h
+  vp8/common/common_types.h
+  vp8/common/defaultcoefcounts.h
+  vp8/common/entropy.h
+  vp8/common/entropymode.h
+  vp8/common/entropymv.h
+  vp8/common/extend.h
+  vp8/common/findnearmv.h
+  vp8/common/g_common.h
+  vp8/common/header.h
+  vp8/common/idct.h
+  vp8/common/invtrans.h
+  vp8/common/loopfilter.h
+  vp8/common/modecont.h
+  vp8/common/mv.h
+  vp8/common/onyxc_int.h
+  vp8/common/onyxd.h
+  vp8/common/onyx.h
+  vp8/common/postproc.h
+  vp8/common/ppflags.h
+  vp8/common/pragmas.h
+  vp8/common/predictdc.h
+  vp8/common/preproc.h
+  vp8/common/quant_common.h
+  vp8/common/recon.h
+  vp8/common/reconinter.h
+  vp8/common/reconintra4x4.h
+  vp8/common/reconintra.h
+  vp8/common/segmentation_common.h
+  vp8/common/setupintrarecon.h
+  vp8/common/subpixel.h
+  vp8/common/swapyv12buffer.h
+  vp8/common/systemdependent.h
+  vp8/common/threading.h
+  vp8/common/treecoder.h
+  vp8/common/type_aliases.h
+  vp8/common/vpxerrors.h
+  vp8/common/x86/idct_x86.h
+  vp8/common/x86/loopfilter_x86.h
+  vp8/common/x86/postproc_x86.h
+  vp8/common/x86/recon_x86.h
+  vp8/common/x86/subpixel_x86.h
+  vp8/decoder/dboolhuff.h
+  vp8/decoder/decodemv.h
+  vp8/decoder/decoderthreading.h
+  vp8/decoder/demode.h
+  vp8/decoder/dequantize.h
+  vp8/decoder/detokenize.h
+  vp8/decoder/onyxd_int.h
+  vp8/decoder/treereader.h
+  vp8/decoder/x86/dequantize_x86.h
+  vpx/internal/vpx_codec_internal.h
+  vpx/vp8cx.h
+  vpx/vp8dx.h
+  vpx/vp8e.h
+  vpx/vp8.h
+  vpx/vpx_codec.h
+  vpx/vpx_codec_impl_bottom.h
+  vpx/vpx_codec_impl_top.h
+  vpx/vpx_decoder_compat.h
+  vpx/vpx_decoder.h
+  vpx/vpx_encoder.h
+  vpx/vpx_image.h
+  vpx/vpx_integer.h
+  vpx_mem/include/vpx_mem_intrnl.h
+  vpx_mem/vpx_mem.h
+  vpx_ports/config.h
+  vpx_ports/mem.h
+  vpx_ports/vpx_timer.h
+  vpx_ports/x86.h
+  vpx_scale/scale_mode.h
+  vpx_scale/vpxscale.h
+  vpx_scale/yv12config.h
+  vpx_scale/yv12extend.h
+  vp8/common/x86/idctllm_mmx.asm
+  vp8/common/x86/iwalsh_mmx.asm
+  vp8/common/x86/iwalsh_sse2.asm
+  vp8/common/x86/loopfilter_mmx.asm
+  vp8/common/x86/loopfilter_sse2.asm
+  vp8/common/x86/postproc_mmx.asm
+  vp8/common/x86/postproc_sse2.asm
+  vp8/common/x86/recon_mmx.asm
+  vp8/common/x86/recon_sse2.asm
+  vp8/common/x86/subpixel_mmx.asm
+  vp8/common/x86/subpixel_sse2.asm
+  vp8/decoder/x86/dequantize_mmx.asm
+  vpx_ports/emms.asm
+  vpx_ports/x86_abi_support.asm
+  LICENSE
+  PATENTS
+)
+
+# configure files specific to x86-win32-vs8
+cp $1/objdir/x86-win32-vs8/vpx_config.c vpx_config_x86-win32-vs8.c
+cp $1/objdir/x86-win32-vs8/vpx_config.asm vpx_config_x86-win32-vs8.asm
+cp $1/objdir/x86-win32-vs8/vpx_config.h vpx_config_x86-win32-vs8.h
+
+# Should be same for all platforms...
+cp $1/objdir/x86-win32-vs8/vpx_version.h vpx_version.h
+
+# Config files for x86-linux-gcc
+cp $1/objdir/x86-linux-gcc/vpx_config.c vpx_config_x86-linux-gcc.c
+cp $1/objdir/x86-linux-gcc/vpx_config.asm vpx_config_x86-linux-gcc.asm
+cp $1/objdir/x86-linux-gcc/vpx_config.h vpx_config_x86-linux-gcc.h
+
+# Copy config files for mac...
+cp $1/objdir/x86-darwin9-gcc/vpx_config.c vpx_config_x86-darwin9-gcc.c
+cp $1/objdir/x86-darwin9-gcc/vpx_config.asm vpx_config_x86-darwin9-gcc.asm
+cp $1/objdir/x86-darwin9-gcc/vpx_config.h vpx_config_x86-darwin9-gcc.h
+
+# Copy config files for Mac64
+cp $1/objdir/x86_64-darwin9-gcc/vpx_config.c vpx_config_x86_64-darwin9-gcc.c
+cp $1/objdir/x86_64-darwin9-gcc/vpx_config.asm vpx_config_x86_64-darwin9-gcc.asm
+cp $1/objdir/x86_64-darwin9-gcc/vpx_config.h vpx_config_x86_64-darwin9-gcc.h
+
+# Config files for generic-gnu
+cp $1/objdir/generic-gnu/vpx_config.c vpx_config_generic-gnu.c
+cp $1/objdir/generic-gnu/vpx_config.h vpx_config_generic-gnu.h
+
+# Copy common source files into mozilla tree.
+for f in ${commonFiles[@]}
+do
+  mkdir -p -v `dirname $f`
+  cp -v $1/$f $f
+done
+
+# Patch to reduce compiler warnings, so we can compile with -Werror in mozilla.
+patch -p3 < reduce-warnings-1.patch
+patch -p3 < splitmv-bounds.patch
+patch -p3 < subpixel-qword.patch
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/alloccommon.c
@@ -0,0 +1,250 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include "vpx_ports/config.h"
+#include "blockd.h"
+#include "vpx_mem/vpx_mem.h"
+#include "onyxc_int.h"
+#include "findnearmv.h"
+#include "entropymode.h"
+#include "systemdependent.h"
+#include "vpxerrors.h"
+
+
+extern  void vp8_init_scan_order_mask();
+
+void vp8_update_mode_info_border(MODE_INFO *mi, int rows, int cols)
+{
+    int i;
+    vpx_memset(mi - cols - 1, 0, sizeof(MODE_INFO) * cols + 1);
+
+    for (i = 0; i < rows; i++)
+    {
+        vpx_memset(&mi[i*cols-1], 0, sizeof(MODE_INFO));
+    }
+}
+void vp8_de_alloc_frame_buffers(VP8_COMMON *oci)
+{
+    vp8_yv12_de_alloc_frame_buffer(&oci->temp_scale_frame);
+    vp8_yv12_de_alloc_frame_buffer(&oci->new_frame);
+    vp8_yv12_de_alloc_frame_buffer(&oci->last_frame);
+    vp8_yv12_de_alloc_frame_buffer(&oci->golden_frame);
+    vp8_yv12_de_alloc_frame_buffer(&oci->alt_ref_frame);
+    vp8_yv12_de_alloc_frame_buffer(&oci->post_proc_buffer);
+
+    vpx_free(oci->above_context[Y1CONTEXT]);
+    vpx_free(oci->above_context[UCONTEXT]);
+    vpx_free(oci->above_context[VCONTEXT]);
+    vpx_free(oci->above_context[Y2CONTEXT]);
+    vpx_free(oci->mip);
+
+    oci->above_context[Y1CONTEXT] = 0;
+    oci->above_context[UCONTEXT]  = 0;
+    oci->above_context[VCONTEXT]  = 0;
+    oci->above_context[Y2CONTEXT] = 0;
+    oci->mip = 0;
+
+    // Structure used to minitor GF useage
+    if (oci->gf_active_flags != 0)
+        vpx_free(oci->gf_active_flags);
+
+    oci->gf_active_flags = 0;
+}
+
+int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height)
+{
+    vp8_de_alloc_frame_buffers(oci);
+
+    // our internal buffers are always multiples of 16
+    if ((width & 0xf) != 0)
+        width += 16 - (width & 0xf);
+
+    if ((height & 0xf) != 0)
+        height += 16 - (height & 0xf);
+
+
+    if (vp8_yv12_alloc_frame_buffer(&oci->temp_scale_frame,   width, 16, VP8BORDERINPIXELS) < 0)
+    {
+        vp8_de_alloc_frame_buffers(oci);
+        return ALLOC_FAILURE;
+    }
+
+
+    if (vp8_yv12_alloc_frame_buffer(&oci->new_frame,   width, height, VP8BORDERINPIXELS) < 0)
+    {
+        vp8_de_alloc_frame_buffers(oci);
+        return ALLOC_FAILURE;
+    }
+
+    if (vp8_yv12_alloc_frame_buffer(&oci->last_frame,  width, height, VP8BORDERINPIXELS) < 0)
+    {
+        vp8_de_alloc_frame_buffers(oci);
+        return ALLOC_FAILURE;
+    }
+
+    if (vp8_yv12_alloc_frame_buffer(&oci->golden_frame, width, height, VP8BORDERINPIXELS) < 0)
+    {
+        vp8_de_alloc_frame_buffers(oci);
+        return ALLOC_FAILURE;
+    }
+
+    if (vp8_yv12_alloc_frame_buffer(&oci->alt_ref_frame, width, height, VP8BORDERINPIXELS) < 0)
+    {
+        vp8_de_alloc_frame_buffers(oci);
+        return ALLOC_FAILURE;
+    }
+
+    if (vp8_yv12_alloc_frame_buffer(&oci->post_proc_buffer, width, height, VP8BORDERINPIXELS) < 0)
+    {
+        vp8_de_alloc_frame_buffers(oci);
+        return ALLOC_FAILURE;
+    }
+
+    oci->mb_rows = height >> 4;
+    oci->mb_cols = width >> 4;
+    oci->MBs = oci->mb_rows * oci->mb_cols;
+    oci->mode_info_stride = oci->mb_cols + 1;
+    oci->mip = vpx_calloc((oci->mb_cols + 1) * (oci->mb_rows + 1), sizeof(MODE_INFO));
+
+    if (!oci->mip)
+    {
+        vp8_de_alloc_frame_buffers(oci);
+        return ALLOC_FAILURE;
+    }
+
+    oci->mi = oci->mip + oci->mode_info_stride + 1;
+
+
+    oci->above_context[Y1CONTEXT] = vpx_calloc(sizeof(ENTROPY_CONTEXT) * oci->mb_cols * 4 , 1);
+
+    if (!oci->above_context[Y1CONTEXT])
+    {
+        vp8_de_alloc_frame_buffers(oci);
+        return ALLOC_FAILURE;
+    }
+
+    oci->above_context[UCONTEXT]  = vpx_calloc(sizeof(ENTROPY_CONTEXT) * oci->mb_cols * 2 , 1);
+
+    if (!oci->above_context[UCONTEXT])
+    {
+        vp8_de_alloc_frame_buffers(oci);
+        return ALLOC_FAILURE;
+    }
+
+    oci->above_context[VCONTEXT]  = vpx_calloc(sizeof(ENTROPY_CONTEXT) * oci->mb_cols * 2 , 1);
+
+    if (!oci->above_context[VCONTEXT])
+    {
+        vp8_de_alloc_frame_buffers(oci);
+        return ALLOC_FAILURE;
+    }
+
+    oci->above_context[Y2CONTEXT] = vpx_calloc(sizeof(ENTROPY_CONTEXT) * oci->mb_cols     , 1);
+
+    if (!oci->above_context[Y2CONTEXT])
+    {
+        vp8_de_alloc_frame_buffers(oci);
+        return ALLOC_FAILURE;
+    }
+
+    vp8_update_mode_info_border(oci->mi, oci->mb_rows, oci->mb_cols);
+
+    // Structures used to minitor GF usage
+    if (oci->gf_active_flags != 0)
+        vpx_free(oci->gf_active_flags);
+
+    oci->gf_active_flags = (unsigned char *)vpx_calloc(oci->mb_rows * oci->mb_cols, 1);
+
+    if (!oci->gf_active_flags)
+    {
+        vp8_de_alloc_frame_buffers(oci);
+        return ALLOC_FAILURE;
+    }
+
+    oci->gf_active_count = oci->mb_rows * oci->mb_cols;
+
+    return 0;
+}
+void vp8_setup_version(VP8_COMMON *cm)
+{
+    switch (cm->version)
+    {
+    case 0:
+        cm->no_lpf = 0;
+        cm->simpler_lpf = 0;
+        cm->use_bilinear_mc_filter = 0;
+        cm->full_pixel = 0;
+        break;
+    case 1:
+        cm->no_lpf = 0;
+        cm->simpler_lpf = 1;
+        cm->use_bilinear_mc_filter = 1;
+        cm->full_pixel = 0;
+        break;
+    case 2:
+        cm->no_lpf = 1;
+        cm->simpler_lpf = 0;
+        cm->use_bilinear_mc_filter = 1;
+        cm->full_pixel = 0;
+        break;
+    case 3:
+        cm->no_lpf = 1;
+        cm->simpler_lpf = 1;
+        cm->use_bilinear_mc_filter = 1;
+        cm->full_pixel = 1;
+        break;
+    default:
+        //4,5,6,7 are reserved for future use
+        cm->no_lpf = 0;
+        cm->simpler_lpf = 0;
+        cm->use_bilinear_mc_filter = 0;
+        cm->full_pixel = 0;
+        break;
+    }
+}
+void vp8_create_common(VP8_COMMON *oci)
+{
+    vp8_machine_specific_config(oci);
+    vp8_default_coef_probs(oci);
+    vp8_init_mbmode_probs(oci);
+    vp8_default_bmode_probs(oci->fc.bmode_prob);
+
+    oci->mb_no_coeff_skip = 1;
+    oci->no_lpf = 0;
+    oci->simpler_lpf = 0;
+    oci->use_bilinear_mc_filter = 0;
+    oci->full_pixel = 0;
+    oci->multi_token_partition = ONE_PARTITION;
+    oci->clr_type = REG_YUV;
+    oci->clamp_type = RECON_CLAMP_REQUIRED;
+
+    // Initialise reference frame sign bias structure to defaults
+    vpx_memset(oci->ref_frame_sign_bias, 0, sizeof(oci->ref_frame_sign_bias));
+
+    // Default disable buffer to buffer copying
+    oci->copy_buffer_to_gf = 0;
+    oci->copy_buffer_to_arf = 0;
+}
+
+void vp8_remove_common(VP8_COMMON *oci)
+{
+    vp8_de_alloc_frame_buffers(oci);
+}
+
+void vp8_initialize_common()
+{
+    vp8_coef_tree_initialize();
+
+    vp8_entropy_mode_init();
+
+    vp8_init_scan_order_mask();
+
+}
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/alloccommon.h
@@ -0,0 +1,23 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __INC_ALLOCCOMMON_H
+#define __INC_ALLOCCOMMON_H
+
+#include "onyxc_int.h"
+
+void vp8_create_common(VP8_COMMON *oci);
+void vp8_remove_common(VP8_COMMON *oci);
+void vp8_de_alloc_frame_buffers(VP8_COMMON *oci);
+int vp8_alloc_frame_buffers(VP8_COMMON *oci, int width, int height);
+void vp8_setup_version(VP8_COMMON *oci);
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/blockd.c
@@ -0,0 +1,24 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include "blockd.h"
+#include "vpx_mem/vpx_mem.h"
+
+void vp8_setup_temp_context(TEMP_CONTEXT *t, ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l, int count)
+{
+    vpx_memcpy(t->l, l, sizeof(ENTROPY_CONTEXT) * count);
+    vpx_memcpy(t->a, a, sizeof(ENTROPY_CONTEXT) * count);
+}
+
+const int vp8_block2left[25] = { 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 0, 0, 1, 1, 0, 0, 1, 1, 0};
+const int vp8_block2above[25] = { 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 2, 3, 0, 1, 0, 1, 0, 1, 0, 1, 0};
+const int vp8_block2type[25] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 1};
+const int vp8_block2context[25] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3};
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/blockd.h
@@ -0,0 +1,300 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __INC_BLOCKD_H
+#define __INC_BLOCKD_H
+
+void vpx_log(const char *format, ...);
+
+#include "vpx_ports/config.h"
+#include "vpx_scale/yv12config.h"
+#include "mv.h"
+#include "treecoder.h"
+#include "subpixel.h"
+#include "vpx_ports/mem.h"
+
+#define TRUE    1
+#define FALSE   0
+
+//#define DCPRED 1
+#define DCPREDSIMTHRESH 0
+#define DCPREDCNTTHRESH 3
+
+#define Y1CONTEXT 0
+#define UCONTEXT 1
+#define VCONTEXT 2
+#define Y2CONTEXT 3
+
+#define MB_FEATURE_TREE_PROBS   3
+#define MAX_MB_SEGMENTS         4
+
+#define MAX_REF_LF_DELTAS       4
+#define MAX_MODE_LF_DELTAS      4
+
+// Segment Feature Masks
+#define SEGMENT_DELTADATA   0
+#define SEGMENT_ABSDATA     1
+
+typedef struct
+{
+    int r, c;
+} POS;
+
+
+typedef int ENTROPY_CONTEXT;
+
+typedef struct
+{
+    ENTROPY_CONTEXT l[4];
+    ENTROPY_CONTEXT a[4];
+} TEMP_CONTEXT;
+
+extern void vp8_setup_temp_context(TEMP_CONTEXT *t, ENTROPY_CONTEXT *a, ENTROPY_CONTEXT *l, int count);
+extern const int vp8_block2left[25];
+extern const int vp8_block2above[25];
+extern const int vp8_block2type[25];
+extern const int vp8_block2context[25];
+
+#define VP8_COMBINEENTROPYCONTEXTS( Dest, A, B) \
+    Dest = ((A)!=0) + ((B)!=0);
+
+
+typedef enum
+{
+    KEY_FRAME = 0,
+    INTER_FRAME = 1
+} FRAME_TYPE;
+
+typedef enum
+{
+    DC_PRED,            // average of above and left pixels
+    V_PRED,             // vertical prediction
+    H_PRED,             // horizontal prediction
+    TM_PRED,            // Truemotion prediction
+    B_PRED,             // block based prediction, each block has its own prediction mode
+
+    NEARESTMV,
+    NEARMV,
+    ZEROMV,
+    NEWMV,
+    SPLITMV,
+
+    MB_MODE_COUNT
+} MB_PREDICTION_MODE;
+
+// Macroblock level features
+typedef enum
+{
+    MB_LVL_ALT_Q = 0,               // Use alternate Quantizer ....
+    MB_LVL_ALT_LF = 1,              // Use alternate loop filter value...
+    MB_LVL_MAX = 2                 // Number of MB level features supported
+
+} MB_LVL_FEATURES;
+
+// Segment Feature Masks
+#define SEGMENT_ALTQ    0x01
+#define SEGMENT_ALT_LF  0x02
+
+#define VP8_YMODES  (B_PRED + 1)
+#define VP8_UV_MODES (TM_PRED + 1)
+
+#define VP8_MVREFS (1 + SPLITMV - NEARESTMV)
+
+typedef enum
+{
+    B_DC_PRED,          // average of above and left pixels
+    B_TM_PRED,
+
+    B_VE_PRED,           // vertical prediction
+    B_HE_PRED,           // horizontal prediction
+
+    B_LD_PRED,
+    B_RD_PRED,
+
+    B_VR_PRED,
+    B_VL_PRED,
+    B_HD_PRED,
+    B_HU_PRED,
+
+    LEFT4X4,
+    ABOVE4X4,
+    ZERO4X4,
+    NEW4X4,
+
+    B_MODE_COUNT
+} B_PREDICTION_MODE;
+
+#define VP8_BINTRAMODES (B_HU_PRED + 1)  /* 10 */
+#define VP8_SUBMVREFS (1 + NEW4X4 - LEFT4X4)
+
+/* For keyframes, intra block modes are predicted by the (already decoded)
+   modes for the Y blocks to the left and above us; for interframes, there
+   is a single probability table. */
+
+typedef struct
+{
+    B_PREDICTION_MODE mode;
+    union
+    {
+        int as_int;
+        MV  as_mv;
+    } mv;
+} B_MODE_INFO;
+
+
+typedef enum
+{
+    INTRA_FRAME = 0,
+    LAST_FRAME = 1,
+    GOLDEN_FRAME = 2,
+    ALTREF_FRAME = 3,
+    MAX_REF_FRAMES = 4
+} MV_REFERENCE_FRAME;
+
+typedef struct
+{
+    MB_PREDICTION_MODE mode, uv_mode;
+    MV_REFERENCE_FRAME ref_frame;
+    union
+    {
+        int as_int;
+        MV  as_mv;
+    } mv;
+    int partitioning;
+    int partition_count;
+    int mb_skip_coeff;                                //does this mb has coefficients at all, 1=no coefficients, 0=need decode tokens
+    int dc_diff;
+    unsigned char   segment_id;                  // Which set of segmentation parameters should be used for this MB
+    int force_no_skip;
+
+    B_MODE_INFO partition_bmi[16];
+
+} MB_MODE_INFO;
+
+
+typedef struct
+{
+    MB_MODE_INFO mbmi;
+    B_MODE_INFO bmi[16];
+} MODE_INFO;
+
+
+typedef struct
+{
+    short *qcoeff;
+    short *dqcoeff;
+    unsigned char  *predictor;
+    short *diff;
+    short *reference;
+
+    short(*dequant)[4];
+
+    // 16 Y blocks, 4 U blocks, 4 V blocks each with 16 entries
+    unsigned char **base_pre;
+    int pre;
+    int pre_stride;
+
+    unsigned char **base_dst;
+    int dst;
+    int dst_stride;
+
+    int eob;
+
+    B_MODE_INFO bmi;
+
+} BLOCKD;
+
+typedef struct
+{
+    DECLARE_ALIGNED(16, short, diff[400]);      // from idct diff
+    DECLARE_ALIGNED(16, unsigned char,  predictor[384]);
+    DECLARE_ALIGNED(16, short, reference[384]);
+    DECLARE_ALIGNED(16, short, qcoeff[400]);
+    DECLARE_ALIGNED(16, short, dqcoeff[400]);
+
+    // 16 Y blocks, 4 U, 4 V, 1 DC 2nd order block, each with 16 entries.
+    BLOCKD block[25];
+
+    YV12_BUFFER_CONFIG pre; // Filtered copy of previous frame reconstruction
+    YV12_BUFFER_CONFIG dst;
+
+    MODE_INFO *mode_info_context;
+    MODE_INFO *mode_info;
+
+    int mode_info_stride;
+
+    FRAME_TYPE frame_type;
+
+    MB_MODE_INFO mbmi;
+
+    int up_available;
+    int left_available;
+
+    // Y,U,V,Y2
+    ENTROPY_CONTEXT *above_context[4];   // row of context for each plane
+    ENTROPY_CONTEXT(*left_context)[4];   // (up to) 4 contexts ""
+
+    // 0 indicates segmentation at MB level is not enabled. Otherwise the individual bits indicate which features are active.
+    unsigned char segmentation_enabled;
+
+    // 0 (do not update) 1 (update) the macroblock segmentation map.
+    unsigned char update_mb_segmentation_map;
+
+    // 0 (do not update) 1 (update) the macroblock segmentation feature data.
+    unsigned char update_mb_segmentation_data;
+
+    // 0 (do not update) 1 (update) the macroblock segmentation feature data.
+    unsigned char mb_segement_abs_delta;
+
+    // Per frame flags that define which MB level features (such as quantizer or loop filter level)
+    // are enabled and when enabled the proabilities used to decode the per MB flags in MB_MODE_INFO
+    vp8_prob mb_segment_tree_probs[MB_FEATURE_TREE_PROBS];         // Probability Tree used to code Segment number
+
+    signed char segment_feature_data[MB_LVL_MAX][MAX_MB_SEGMENTS];            // Segment parameters
+
+    // mode_based Loop filter adjustment
+    unsigned char mode_ref_lf_delta_enabled;
+    unsigned char mode_ref_lf_delta_update;
+
+    // Delta values have the range +/- MAX_LOOP_FILTER
+    //char ref_lf_deltas[MAX_REF_LF_DELTAS];                      // 0 = Intra, Last, GF, ARF
+    //char mode_lf_deltas[MAX_MODE_LF_DELTAS];                            // 0 = BPRED, ZERO_MV, MV, SPLIT
+    signed char ref_lf_deltas[MAX_REF_LF_DELTAS];                     // 0 = Intra, Last, GF, ARF
+    signed char mode_lf_deltas[MAX_MODE_LF_DELTAS];                           // 0 = BPRED, ZERO_MV, MV, SPLIT
+
+    // Distance of MB away from frame edges
+    int mb_to_left_edge;
+    int mb_to_right_edge;
+    int mb_to_top_edge;
+    int mb_to_bottom_edge;
+
+    //char * gf_active_ptr;
+    signed char *gf_active_ptr;
+
+    unsigned int frames_since_golden;
+    unsigned int frames_till_alt_ref_frame;
+    vp8_subpix_fn_t  subpixel_predict;
+    vp8_subpix_fn_t  subpixel_predict8x4;
+    vp8_subpix_fn_t  subpixel_predict8x8;
+    vp8_subpix_fn_t  subpixel_predict16x16;
+
+    void *current_bc;
+
+#if CONFIG_RUNTIME_CPU_DETECT
+    struct VP8_COMMON_RTCD  *rtcd;
+#endif
+} MACROBLOCKD;
+
+
+extern void vp8_build_block_doffsets(MACROBLOCKD *x);
+extern void vp8_setup_block_dptrs(MACROBLOCKD *x);
+
+#endif  /* __INC_BLOCKD_H */
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/coefupdateprobs.h
@@ -0,0 +1,185 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+/* Update probabilities for the nodes in the token entropy tree.
+   Generated file included by entropy.c */
+
+const vp8_prob vp8_coef_update_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens-1] =
+{
+    {
+        {
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {176, 246, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {223, 241, 252, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {249, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 244, 252, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {234, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 246, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {239, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {251, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {251, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {254, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 254, 253, 255, 254, 255, 255, 255, 255, 255, 255, },
+            {250, 255, 254, 255, 254, 255, 255, 255, 255, 255, 255, },
+            {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+    },
+    {
+        {
+            {217, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {225, 252, 241, 253, 255, 255, 254, 255, 255, 255, 255, },
+            {234, 250, 241, 250, 253, 255, 253, 254, 255, 255, 255, },
+        },
+        {
+            {255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {223, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {238, 253, 254, 254, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 248, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {249, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 253, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {247, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {252, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {253, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+    },
+    {
+        {
+            {186, 251, 250, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {234, 251, 244, 254, 255, 255, 255, 255, 255, 255, 255, },
+            {251, 251, 243, 253, 254, 255, 254, 255, 255, 255, 255, },
+        },
+        {
+            {255, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {236, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {251, 253, 253, 254, 254, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+    },
+    {
+        {
+            {248, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {250, 254, 252, 254, 255, 255, 255, 255, 255, 255, 255, },
+            {248, 254, 249, 253, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {246, 253, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {252, 254, 251, 254, 254, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 254, 252, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {248, 254, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {253, 255, 254, 254, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {245, 251, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {253, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 251, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {252, 253, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 252, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {249, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 254, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 255, 253, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {250, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+        {
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+            {255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, },
+        },
+    },
+};
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/common.h
@@ -0,0 +1,42 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef common_h
+#define common_h 1
+
+#include <assert.h>
+
+/* Interface header for common constant data structures and lookup tables */
+
+#include "vpx_mem/vpx_mem.h"
+
+#include "common_types.h"
+
+/* Only need this for fixed-size arrays, for structs just assign. */
+
+#define vp8_copy( Dest, Src) { \
+        assert( sizeof( Dest) == sizeof( Src)); \
+        vpx_memcpy( Dest, Src, sizeof( Src)); \
+    }
+
+/* Use this for variably-sized arrays. */
+
+#define vp8_copy_array( Dest, Src, N) { \
+        assert( sizeof( *Dest) == sizeof( *Src)); \
+        vpx_memcpy( Dest, Src, N * sizeof( *Src)); \
+    }
+
+#define vp8_zero( Dest)  vpx_memset( &Dest, 0, sizeof( Dest));
+
+#define vp8_zero_array( Dest, N)  vpx_memset( Dest, 0, N * sizeof( *Dest));
+
+
+#endif  /* common_h */
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/common_types.h
@@ -0,0 +1,18 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __INC_COMMON_TYPES
+#define __INC_COMMON_TYPES
+
+#define TRUE    1
+#define FALSE   0
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/debugmodes.c
@@ -0,0 +1,157 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include <stdio.h>
+#include "blockd.h"
+
+
+void vp8_print_modes_and_motion_vectors(MODE_INFO *mi, int rows, int cols, int frame)
+{
+
+    int mb_row;
+    int mb_col;
+    int mb_index = 0;
+    FILE *mvs = fopen("mvs.stt", "a");
+
+    // print out the macroblock Y modes
+    mb_index = 0;
+    fprintf(mvs, "Mb Modes for Frame %d\n", frame);
+
+    for (mb_row = 0; mb_row < rows; mb_row++)
+    {
+        for (mb_col = 0; mb_col < cols; mb_col++)
+        {
+
+            fprintf(mvs, "%2d ", mi[mb_index].mbmi.mode);
+
+            mb_index++;
+        }
+
+        fprintf(mvs, "\n");
+        mb_index++;
+    }
+
+    fprintf(mvs, "\n");
+
+    mb_index = 0;
+    fprintf(mvs, "Mb mv ref for Frame %d\n", frame);
+
+    for (mb_row = 0; mb_row < rows; mb_row++)
+    {
+        for (mb_col = 0; mb_col < cols; mb_col++)
+        {
+
+            fprintf(mvs, "%2d ", mi[mb_index].mbmi.ref_frame);
+
+            mb_index++;
+        }
+
+        fprintf(mvs, "\n");
+        mb_index++;
+    }
+
+    fprintf(mvs, "\n");
+
+    // print out the macroblock UV modes
+    mb_index = 0;
+    fprintf(mvs, "UV Modes for Frame %d\n", frame);
+
+    for (mb_row = 0; mb_row < rows; mb_row++)
+    {
+        for (mb_col = 0; mb_col < cols; mb_col++)
+        {
+
+            fprintf(mvs, "%2d ", mi[mb_index].mbmi.uv_mode);
+
+            mb_index++;
+        }
+
+        mb_index++;
+        fprintf(mvs, "\n");
+    }
+
+    fprintf(mvs, "\n");
+
+    // print out the block modes
+    mb_index = 0;
+    fprintf(mvs, "Mbs for Frame %d\n", frame);
+    {
+        int b_row;
+
+        for (b_row = 0; b_row < 4 * rows; b_row++)
+        {
+            int b_col;
+            int bindex;
+
+            for (b_col = 0; b_col < 4 * cols; b_col++)
+            {
+                mb_index = (b_row >> 2) * (cols + 1) + (b_col >> 2);
+                bindex = (b_row & 3) * 4 + (b_col & 3);
+
+                if (mi[mb_index].mbmi.mode == B_PRED)
+                    fprintf(mvs, "%2d ", mi[mb_index].bmi[bindex].mode);
+                else
+                    fprintf(mvs, "xx ");
+
+            }
+
+            fprintf(mvs, "\n");
+        }
+    }
+    fprintf(mvs, "\n");
+
+    // print out the macroblock mvs
+    mb_index = 0;
+    fprintf(mvs, "MVs for Frame %d\n", frame);
+
+    for (mb_row = 0; mb_row < rows; mb_row++)
+    {
+        for (mb_col = 0; mb_col < cols; mb_col++)
+        {
+            fprintf(mvs, "%5d:%-5d", mi[mb_index].mbmi.mv.as_mv.row / 2, mi[mb_index].mbmi.mv.as_mv.col / 2);
+
+            mb_index++;
+        }
+
+        mb_index++;
+        fprintf(mvs, "\n");
+    }
+
+    fprintf(mvs, "\n");
+
+
+    // print out the block modes
+    mb_index = 0;
+    fprintf(mvs, "MVs for Frame %d\n", frame);
+    {
+        int b_row;
+
+        for (b_row = 0; b_row < 4 * rows; b_row++)
+        {
+            int b_col;
+            int bindex;
+
+            for (b_col = 0; b_col < 4 * cols; b_col++)
+            {
+                mb_index = (b_row >> 2) * (cols + 1) + (b_col >> 2);
+                bindex = (b_row & 3) * 4 + (b_col & 3);
+                fprintf(mvs, "%3d:%-3d ", mi[mb_index].bmi[bindex].mv.as_mv.row, mi[mb_index].bmi[bindex].mv.as_mv.col);
+
+            }
+
+            fprintf(mvs, "\n");
+        }
+    }
+    fprintf(mvs, "\n");
+
+
+    fclose(mvs);
+}
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/defaultcoefcounts.h
@@ -0,0 +1,221 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+/* Generated file, included by entropy.c */
+
+static const unsigned int default_coef_counts [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens] =
+{
+
+    {
+        // Block Type ( 0 )
+        {
+            // Coeff Band ( 0 )
+            {   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,},
+            {   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,},
+            {   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,},
+        },
+        {
+            // Coeff Band ( 1 )
+            {30190, 26544, 225,  24,   4,   0,   0,   0,   0,   0,   0, 4171593,},
+            {26846, 25157, 1241, 130,  26,   6,   1,   0,   0,   0,   0, 149987,},
+            {10484, 9538, 1006, 160,  36,  18,   0,   0,   0,   0,   0, 15104,},
+        },
+        {
+            // Coeff Band ( 2 )
+            {25842, 40456, 1126,  83,  11,   2,   0,   0,   0,   0,   0,   0,},
+            {9338, 8010, 512,  73,   7,   3,   2,   0,   0,   0,   0, 43294,},
+            {1047, 751, 149,  31,  13,   6,   1,   0,   0,   0,   0, 879,},
+        },
+        {
+            // Coeff Band ( 3 )
+            {26136, 9826, 252,  13,   0,   0,   0,   0,   0,   0,   0,   0,},
+            {8134, 5574, 191,  14,   2,   0,   0,   0,   0,   0,   0, 35302,},
+            { 605, 677, 116,   9,   1,   0,   0,   0,   0,   0,   0, 611,},
+        },
+        {
+            // Coeff Band ( 4 )
+            {10263, 15463, 283,  17,   0,   0,   0,   0,   0,   0,   0,   0,},
+            {2773, 2191, 128,   9,   2,   2,   0,   0,   0,   0,   0, 10073,},
+            { 134, 125,  32,   4,   0,   2,   0,   0,   0,   0,   0,  50,},
+        },
+        {
+            // Coeff Band ( 5 )
+            {10483, 2663,  23,   1,   0,   0,   0,   0,   0,   0,   0,   0,},
+            {2137, 1251,  27,   1,   1,   0,   0,   0,   0,   0,   0, 14362,},
+            { 116, 156,  14,   2,   1,   0,   0,   0,   0,   0,   0, 190,},
+        },
+        {
+            // Coeff Band ( 6 )
+            {40977, 27614, 412,  28,   0,   0,   0,   0,   0,   0,   0,   0,},
+            {6113, 5213, 261,  22,   3,   0,   0,   0,   0,   0,   0, 26164,},
+            { 382, 312,  50,  14,   2,   0,   0,   0,   0,   0,   0, 345,},
+        },
+        {
+            // Coeff Band ( 7 )
+            {   0,  26,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,},
+            {   0,  13,   0,   0,   0,   0,   0,   0,   0,   0,   0, 319,},
+            {   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   8,},
+        },
+    },
+    {
+        // Block Type ( 1 )
+        {
+            // Coeff Band ( 0 )
+            {3268, 19382, 1043, 250,  93,  82,  49,  26,  17,   8,  25, 82289,},
+            {8758, 32110, 5436, 1832, 827, 668, 420, 153,  24,   0,   3, 52914,},
+            {9337, 23725, 8487, 3954, 2107, 1836, 1069, 399,  59,   0,   0, 18620,},
+        },
+        {
+            // Coeff Band ( 1 )
+            {12419, 8420, 452,  62,   9,   1,   0,   0,   0,   0,   0,   0,},
+            {11715, 8705, 693,  92,  15,   7,   2,   0,   0,   0,   0, 53988,},
+            {7603, 8585, 2306, 778, 270, 145,  39,   5,   0,   0,   0, 9136,},
+        },
+        {
+            // Coeff Band ( 2 )
+            {15938, 14335, 1207, 184,  55,  13,   4,   1,   0,   0,   0,   0,},
+            {7415, 6829, 1138, 244,  71,  26,   7,   0,   0,   0,   0, 9980,},
+            {1580, 1824, 655, 241,  89,  46,  10,   2,   0,   0,   0, 429,},
+        },
+        {
+            // Coeff Band ( 3 )
+            {19453, 5260, 201,  19,   0,   0,   0,   0,   0,   0,   0,   0,},
+            {9173, 3758, 213,  22,   1,   1,   0,   0,   0,   0,   0, 9820,},
+            {1689, 1277, 276,  51,  17,   4,   0,   0,   0,   0,   0, 679,},
+        },
+        {
+            // Coeff Band ( 4 )
+            {12076, 10667, 620,  85,  19,   9,   5,   0,   0,   0,   0,   0,},
+            {4665, 3625, 423,  55,  19,   9,   0,   0,   0,   0,   0, 5127,},
+            { 415, 440, 143,  34,  20,   7,   2,   0,   0,   0,   0, 101,},
+        },
+        {
+            // Coeff Band ( 5 )
+            {12183, 4846, 115,  11,   1,   0,   0,   0,   0,   0,   0,   0,},
+            {4226, 3149, 177,  21,   2,   0,   0,   0,   0,   0,   0, 7157,},
+            { 375, 621, 189,  51,  11,   4,   1,   0,   0,   0,   0, 198,},
+        },
+        {
+            // Coeff Band ( 6 )
+            {61658, 37743, 1203,  94,  10,   3,   0,   0,   0,   0,   0,   0,},
+            {15514, 11563, 903, 111,  14,   5,   0,   0,   0,   0,   0, 25195,},
+            { 929, 1077, 291,  78,  14,   7,   1,   0,   0,   0,   0, 507,},
+        },
+        {
+            // Coeff Band ( 7 )
+            {   0, 990,  15,   3,   0,   0,   0,   0,   0,   0,   0,   0,},
+            {   0, 412,  13,   0,   0,   0,   0,   0,   0,   0,   0, 1641,},
+            {   0,  18,   7,   1,   0,   0,   0,   0,   0,   0,   0,  30,},
+        },
+    },
+    {
+        // Block Type ( 2 )
+        {
+            // Coeff Band ( 0 )
+            { 953, 24519, 628, 120,  28,  12,   4,   0,   0,   0,   0, 2248798,},
+            {1525, 25654, 2647, 617, 239, 143,  42,   5,   0,   0,   0, 66837,},
+            {1180, 11011, 3001, 1237, 532, 448, 239,  54,   5,   0,   0, 7122,},
+        },
+        {
+            // Coeff Band ( 1 )
+            {1356, 2220,  67,  10,   4,   1,   0,   0,   0,   0,   0,   0,},
+            {1450, 2544, 102,  18,   4,   3,   0,   0,   0,   0,   0, 57063,},
+            {1182, 2110, 470, 130,  41,  21,   0,   0,   0,   0,   0, 6047,},
+        },
+        {
+            // Coeff Band ( 2 )
+            { 370, 3378, 200,  30,   5,   4,   1,   0,   0,   0,   0,   0,},
+            { 293, 1006, 131,  29,  11,   0,   0,   0,   0,   0,   0, 5404,},
+            { 114, 387,  98,  23,   4,   8,   1,   0,   0,   0,   0, 236,},
+        },
+        {
+            // Coeff Band ( 3 )
+            { 579, 194,   4,   0,   0,   0,   0,   0,   0,   0,   0,   0,},
+            { 395, 213,   5,   1,   0,   0,   0,   0,   0,   0,   0, 4157,},
+            { 119, 122,   4,   0,   0,   0,   0,   0,   0,   0,   0, 300,},
+        },
+        {
+            // Coeff Band ( 4 )
+            {  38, 557,  19,   0,   0,   0,   0,   0,   0,   0,   0,   0,},
+            {  21, 114,  12,   1,   0,   0,   0,   0,   0,   0,   0, 427,},
+            {   0,   5,   0,   0,   0,   0,   0,   0,   0,   0,   0,   7,},
+        },
+        {
+            // Coeff Band ( 5 )
+            {  52,   7,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,},
+            {  18,   6,   0,   0,   0,   0,   0,   0,   0,   0,   0, 652,},
+            {   1,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,  30,},
+        },
+        {
+            // Coeff Band ( 6 )
+            { 640, 569,  10,   0,   0,   0,   0,   0,   0,   0,   0,   0,},
+            {  25,  77,   2,   0,   0,   0,   0,   0,   0,   0,   0, 517,},
+            {   4,   7,   0,   0,   0,   0,   0,   0,   0,   0,   0,   3,},
+        },
+        {
+            // Coeff Band ( 7 )
+            {   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,},
+            {   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,},
+            {   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,},
+        },
+    },
+    {
+        // Block Type ( 3 )
+        {
+            // Coeff Band ( 0 )
+            {2506, 20161, 2707, 767, 261, 178, 107,  30,  14,   3,   0, 100694,},
+            {8806, 36478, 8817, 3268, 1280, 850, 401, 114,  42,   0,   0, 58572,},
+            {11003, 27214, 11798, 5716, 2482, 2072, 1048, 175,  32,   0,   0, 19284,},
+        },
+        {
+            // Coeff Band ( 1 )
+            {9738, 11313, 959, 205,  70,  18,  11,   1,   0,   0,   0,   0,},
+            {12628, 15085, 1507, 273,  52,  19,   9,   0,   0,   0,   0, 54280,},
+            {10701, 15846, 5561, 1926, 813, 570, 249,  36,   0,   0,   0, 6460,},
+        },
+        {
+            // Coeff Band ( 2 )
+            {6781, 22539, 2784, 634, 182, 123,  20,   4,   0,   0,   0,   0,},
+            {6263, 11544, 2649, 790, 259, 168,  27,   5,   0,   0,   0, 20539,},
+            {3109, 4075, 2031, 896, 457, 386, 158,  29,   0,   0,   0, 1138,},
+        },
+        {
+            // Coeff Band ( 3 )
+            {11515, 4079, 465,  73,   5,  14,   2,   0,   0,   0,   0,   0,},
+            {9361, 5834, 650,  96,  24,   8,   4,   0,   0,   0,   0, 22181,},
+            {4343, 3974, 1360, 415, 132,  96,  14,   1,   0,   0,   0, 1267,},
+        },
+        {
+            // Coeff Band ( 4 )
+            {4787, 9297, 823, 168,  44,  12,   4,   0,   0,   0,   0,   0,},
+            {3619, 4472, 719, 198,  60,  31,   3,   0,   0,   0,   0, 8401,},
+            {1157, 1175, 483, 182,  88,  31,   8,   0,   0,   0,   0, 268,},
+        },
+        {
+            // Coeff Band ( 5 )
+            {8299, 1226,  32,   5,   1,   0,   0,   0,   0,   0,   0,   0,},
+            {3502, 1568,  57,   4,   1,   1,   0,   0,   0,   0,   0, 9811,},
+            {1055, 1070, 166,  29,   6,   1,   0,   0,   0,   0,   0, 527,},
+        },
+        {
+            // Coeff Band ( 6 )
+            {27414, 27927, 1989, 347,  69,  26,   0,   0,   0,   0,   0,   0,},
+            {5876, 10074, 1574, 341,  91,  24,   4,   0,   0,   0,   0, 21954,},
+            {1571, 2171, 778, 324, 124,  65,  16,   0,   0,   0,   0, 979,},
+        },
+        {
+            // Coeff Band ( 7 )
+            {   0,  29,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,},
+            {   0,  23,   0,   0,   0,   0,   0,   0,   0,   0,   0, 459,},
+            {   0,   1,   0,   0,   0,   0,   0,   0,   0,   0,   0,  13,},
+        },
+    },
+};
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/entropy.c
@@ -0,0 +1,162 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include <stdio.h>
+
+#include "entropy.h"
+#include "string.h"
+#include "blockd.h"
+#include "onyxc_int.h"
+
+#define uchar unsigned char     /* typedefs can clash */
+#define uint  unsigned int
+
+typedef const uchar cuchar;
+typedef const uint cuint;
+
+typedef vp8_prob Prob;
+
+#include "coefupdateprobs.h"
+
+DECLARE_ALIGNED(16, cuchar, vp8_coef_bands[16]) = { 0, 1, 2, 3, 6, 4, 5, 6, 6, 6, 6, 6, 6, 6, 6, 7};
+DECLARE_ALIGNED(16, cuchar, vp8_prev_token_class[MAX_ENTROPY_TOKENS]) = { 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0};
+DECLARE_ALIGNED(16, const int, vp8_default_zig_zag1d[16]) =
+{
+    0,  1,  4,  8,
+    5,  2,  3,  6,
+    9, 12, 13, 10,
+    7, 11, 14, 15,
+};
+
+DECLARE_ALIGNED(16, short, vp8_default_zig_zag_mask[16]);
+
+const int vp8_mb_feature_data_bits[MB_LVL_MAX] = {7, 6};
+
+/* Array indices are identical to previously-existing CONTEXT_NODE indices */
+
+const vp8_tree_index vp8_coef_tree[ 22] =     /* corresponding _CONTEXT_NODEs */
+{
+    -DCT_EOB_TOKEN, 2,                             /* 0 = EOB */
+    -ZERO_TOKEN, 4,                               /* 1 = ZERO */
+    -ONE_TOKEN, 6,                               /* 2 = ONE */
+    8, 12,                                      /* 3 = LOW_VAL */
+    -TWO_TOKEN, 10,                            /* 4 = TWO */
+    -THREE_TOKEN, -FOUR_TOKEN,                /* 5 = THREE */
+    14, 16,                                    /* 6 = HIGH_LOW */
+    -DCT_VAL_CATEGORY1, -DCT_VAL_CATEGORY2,   /* 7 = CAT_ONE */
+    18, 20,                                   /* 8 = CAT_THREEFOUR */
+    -DCT_VAL_CATEGORY3, -DCT_VAL_CATEGORY4,  /* 9 = CAT_THREE */
+    -DCT_VAL_CATEGORY5, -DCT_VAL_CATEGORY6   /* 10 = CAT_FIVE */
+};
+
+struct vp8_token_struct vp8_coef_encodings[vp8_coef_tokens];
+
+/* Trees for extra bits.  Probabilities are constant and
+   do not depend on previously encoded bits */
+
+static const Prob Pcat1[] = { 159};
+static const Prob Pcat2[] = { 165, 145};
+static const Prob Pcat3[] = { 173, 148, 140};
+static const Prob Pcat4[] = { 176, 155, 140, 135};
+static const Prob Pcat5[] = { 180, 157, 141, 134, 130};
+static const Prob Pcat6[] =
+{ 254, 254, 243, 230, 196, 177, 153, 140, 133, 130, 129};
+
+static vp8_tree_index cat1[2], cat2[4], cat3[6], cat4[8], cat5[10], cat6[22];
+
+void vp8_init_scan_order_mask()
+{
+    int i;
+
+    for (i = 0; i < 16; i++)
+    {
+        vp8_default_zig_zag_mask[vp8_default_zig_zag1d[i]] = 1 << i;
+    }
+
+}
+
+static void init_bit_tree(vp8_tree_index *p, int n)
+{
+    int i = 0;
+
+    while (++i < n)
+    {
+        p[0] = p[1] = i << 1;
+        p += 2;
+    }
+
+    p[0] = p[1] = 0;
+}
+
+static void init_bit_trees()
+{
+    init_bit_tree(cat1, 1);
+    init_bit_tree(cat2, 2);
+    init_bit_tree(cat3, 3);
+    init_bit_tree(cat4, 4);
+    init_bit_tree(cat5, 5);
+    init_bit_tree(cat6, 11);
+}
+
+
+static vp8bc_index_t bcc1[1], bcc2[2], bcc3[3], bcc4[4], bcc5[5], bcc6[11];
+
+vp8_extra_bit_struct vp8_extra_bits[12] =
+{
+    { 0, 0, 0, 0, 0},
+    { 0, 0, 0, 0, 1},
+    { 0, 0, 0, 0, 2},
+    { 0, 0, 0, 0, 3},
+    { 0, 0, 0, 0, 4},
+    { cat1, Pcat1, bcc1, 1, 5},
+    { cat2, Pcat2, bcc2, 2, 7},
+    { cat3, Pcat3, bcc3, 3, 11},
+    { cat4, Pcat4, bcc4, 4, 19},
+    { cat5, Pcat5, bcc5, 5, 35},
+    { cat6, Pcat6, bcc6, 11, 67},
+    { 0, 0, 0, 0, 0}
+};
+#include "defaultcoefcounts.h"
+
+void vp8_default_coef_probs(VP8_COMMON *pc)
+{
+    int h = 0;
+
+    do
+    {
+        int i = 0;
+
+        do
+        {
+            int k = 0;
+
+            do
+            {
+                unsigned int branch_ct [vp8_coef_tokens-1] [2];
+                vp8_tree_probs_from_distribution(
+                    vp8_coef_tokens, vp8_coef_encodings, vp8_coef_tree,
+                    pc->fc.coef_probs [h][i][k], branch_ct, default_coef_counts [h][i][k],
+                    256, 1);
+
+            }
+            while (++k < PREV_COEF_CONTEXTS);
+        }
+        while (++i < COEF_BANDS);
+    }
+    while (++h < BLOCK_TYPES);
+}
+
+
+void vp8_coef_tree_initialize()
+{
+    init_bit_trees();
+    vp8_tokens_from_tree(vp8_coef_encodings, vp8_coef_tree);
+}
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/entropy.h
@@ -0,0 +1,102 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __INC_ENTROPY_H
+#define __INC_ENTROPY_H
+
+#include "treecoder.h"
+#include "blockd.h"
+
+/* Coefficient token alphabet */
+
+#define ZERO_TOKEN              0       //0         Extra Bits 0+0
+#define ONE_TOKEN               1       //1         Extra Bits 0+1
+#define TWO_TOKEN               2       //2         Extra Bits 0+1
+#define THREE_TOKEN             3       //3         Extra Bits 0+1
+#define FOUR_TOKEN              4       //4         Extra Bits 0+1
+#define DCT_VAL_CATEGORY1       5       //5-6       Extra Bits 1+1
+#define DCT_VAL_CATEGORY2       6       //7-10      Extra Bits 2+1
+#define DCT_VAL_CATEGORY3       7       //11-26     Extra Bits 4+1
+#define DCT_VAL_CATEGORY4       8       //11-26     Extra Bits 5+1
+#define DCT_VAL_CATEGORY5       9       //27-58     Extra Bits 5+1
+#define DCT_VAL_CATEGORY6       10      //59+       Extra Bits 11+1
+#define DCT_EOB_TOKEN           11      //EOB       Extra Bits 0+0
+
+#define vp8_coef_tokens 12
+#define MAX_ENTROPY_TOKENS vp8_coef_tokens
+#define ENTROPY_NODES 11
+
+extern const vp8_tree_index vp8_coef_tree[];
+
+extern struct vp8_token_struct vp8_coef_encodings[vp8_coef_tokens];
+
+typedef struct
+{
+    vp8_tree_p tree;
+    const vp8_prob *prob;
+    vp8bc_index_t *prob_bc;
+    int Len;
+    int base_val;
+} vp8_extra_bit_struct;
+
+extern vp8_extra_bit_struct vp8_extra_bits[12];    /* indexed by token value */
+
+#define PROB_UPDATE_BASELINE_COST   7
+
+#define MAX_PROB                255
+#define DCT_MAX_VALUE           2048
+
+
+/* Coefficients are predicted via a 3-dimensional probability table. */
+
+/* Outside dimension.  0 = Y no DC, 1 = Y2, 2 = UV, 3 = Y with DC */
+
+#define BLOCK_TYPES 4
+
+/* Middle dimension is a coarsening of the coefficient's
+   position within the 4x4 DCT. */
+
+#define COEF_BANDS 8
+extern DECLARE_ALIGNED(16, const unsigned char, vp8_coef_bands[16]);
+
+/* Inside dimension is 3-valued measure of nearby complexity, that is,
+   the extent to which nearby coefficients are nonzero.  For the first
+   coefficient (DC, unless block type is 0), we look at the (already encoded)
+   blocks above and to the left of the current block.  The context index is
+   then the number (0,1,or 2) of these blocks having nonzero coefficients.
+   After decoding a coefficient, the measure is roughly the size of the
+   most recently decoded coefficient (0 for 0, 1 for 1, 2 for >1).
+   Note that the intuitive meaning of this measure changes as coefficients
+   are decoded, e.g., prior to the first token, a zero means that my neighbors
+   are empty while, after the first token, because of the use of end-of-block,
+   a zero means we just decoded a zero and hence guarantees that a non-zero
+   coefficient will appear later in this block.  However, this shift
+   in meaning is perfectly OK because our context depends also on the
+   coefficient band (and since zigzag positions 0, 1, and 2 are in
+   distinct bands). */
+
+/*# define DC_TOKEN_CONTEXTS        3 // 00, 0!0, !0!0 */
+#   define PREV_COEF_CONTEXTS       3
+
+extern DECLARE_ALIGNED(16, const unsigned char, vp8_prev_token_class[vp8_coef_tokens]);
+
+extern const vp8_prob vp8_coef_update_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens-1];
+
+
+struct VP8Common;
+void vp8_default_coef_probs(struct VP8Common *);
+
+extern DECLARE_ALIGNED(16, const int, vp8_default_zig_zag1d[16]);
+extern short vp8_default_zig_zag_mask[16];
+extern const int vp8_mb_feature_data_bits[MB_LVL_MAX];
+
+void vp8_coef_tree_initialize(void);
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/entropymode.c
@@ -0,0 +1,271 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include "entropymode.h"
+#include "entropy.h"
+#include "vpx_mem/vpx_mem.h"
+
+static const unsigned int kf_y_mode_cts[VP8_YMODES] = { 1607, 915, 812, 811, 5455};
+static const unsigned int y_mode_cts  [VP8_YMODES] = { 8080, 1908, 1582, 1007, 5874};
+
+static const unsigned int uv_mode_cts  [VP8_UV_MODES] = { 59483, 13605, 16492, 4230};
+static const unsigned int kf_uv_mode_cts[VP8_UV_MODES] = { 5319, 1904, 1703, 674};
+
+static const unsigned int bmode_cts[VP8_BINTRAMODES] =
+{
+    43891, 17694, 10036, 3920, 3363, 2546, 5119, 3221, 2471, 1723
+};
+
+typedef enum
+{
+    SUBMVREF_NORMAL,
+    SUBMVREF_LEFT_ZED,
+    SUBMVREF_ABOVE_ZED,
+    SUBMVREF_LEFT_ABOVE_SAME,
+    SUBMVREF_LEFT_ABOVE_ZED
+} sumvfref_t;
+
+int vp8_mv_cont(const MV *l, const MV *a)
+{
+    int lez = (l->row == 0 && l->col == 0);
+    int aez = (a->row == 0 && a->col == 0);
+    int lea = (l->row == a->row && l->col == a->col);
+
+    if (lea && lez)
+        return SUBMVREF_LEFT_ABOVE_ZED;
+
+    if (lea)
+        return SUBMVREF_LEFT_ABOVE_SAME;
+
+    if (aez)
+        return SUBMVREF_ABOVE_ZED;
+
+    if (lez)
+        return SUBMVREF_LEFT_ZED;
+
+    return SUBMVREF_NORMAL;
+}
+
+static const vp8_prob sub_mv_ref_prob [VP8_SUBMVREFS-1] = { 180, 162, 25};
+
+const vp8_prob vp8_sub_mv_ref_prob2 [SUBMVREF_COUNT][VP8_SUBMVREFS-1] =
+{
+    { 147, 136, 18 },
+    { 106, 145, 1  },
+    { 179, 121, 1  },
+    { 223, 1  , 34 },
+    { 208, 1  , 1  }
+};
+
+
+
+vp8_mbsplit vp8_mbsplits [VP8_NUMMBSPLITS] =
+{
+    {
+        0,  0,  0,  0,
+        0,  0,  0,  0,
+        1,  1,  1,  1,
+        1,  1,  1,  1,
+    },
+    {
+        0,  0,  1,  1,
+        0,  0,  1,  1,
+        0,  0,  1,  1,
+        0,  0,  1,  1,
+    },
+    {
+        0,  0,  1,  1,
+        0,  0,  1,  1,
+        2,  2,  3,  3,
+        2,  2,  3,  3,
+    },
+    {
+        0,  1,  2,  3,
+        4,  5,  6,  7,
+        8,  9,  10, 11,
+        12, 13, 14, 15,
+    },
+};
+
+const int vp8_mbsplit_count [VP8_NUMMBSPLITS] = { 2, 2, 4, 16};
+
+const vp8_prob vp8_mbsplit_probs [VP8_NUMMBSPLITS-1] = { 110, 111, 150};
+
+
+/* Array indices are identical to previously-existing INTRAMODECONTEXTNODES. */
+
+const vp8_tree_index vp8_bmode_tree[18] =     /* INTRAMODECONTEXTNODE value */
+{
+    -B_DC_PRED, 2,                             /* 0 = DC_NODE */
+    -B_TM_PRED, 4,                            /* 1 = TM_NODE */
+    -B_VE_PRED, 6,                           /* 2 = VE_NODE */
+    8, 12,                                  /* 3 = COM_NODE */
+    -B_HE_PRED, 10,                        /* 4 = HE_NODE */
+    -B_RD_PRED, -B_VR_PRED,               /* 5 = RD_NODE */
+    -B_LD_PRED, 14,                        /* 6 = LD_NODE */
+    -B_VL_PRED, 16,                      /* 7 = VL_NODE */
+    -B_HD_PRED, -B_HU_PRED             /* 8 = HD_NODE */
+};
+
+/* Again, these trees use the same probability indices as their
+   explicitly-programmed predecessors. */
+
+const vp8_tree_index vp8_ymode_tree[8] =
+{
+    -DC_PRED, 2,
+    4, 6,
+    -V_PRED, -H_PRED,
+    -TM_PRED, -B_PRED
+};
+
+const vp8_tree_index vp8_kf_ymode_tree[8] =
+{
+    -B_PRED, 2,
+    4, 6,
+    -DC_PRED, -V_PRED,
+    -H_PRED, -TM_PRED
+};
+
+const vp8_tree_index vp8_uv_mode_tree[6] =
+{
+    -DC_PRED, 2,
+    -V_PRED, 4,
+    -H_PRED, -TM_PRED
+};
+
+const vp8_tree_index vp8_mbsplit_tree[6] =
+{
+    -3, 2,
+    -2, 4,
+    -0, -1
+};
+
+const vp8_tree_index vp8_mv_ref_tree[8] =
+{
+    -ZEROMV, 2,
+    -NEARESTMV, 4,
+    -NEARMV, 6,
+    -NEWMV, -SPLITMV
+};
+
+const vp8_tree_index vp8_sub_mv_ref_tree[6] =
+{
+    -LEFT4X4, 2,
+    -ABOVE4X4, 4,
+    -ZERO4X4, -NEW4X4
+};
+
+
+struct vp8_token_struct vp8_bmode_encodings   [VP8_BINTRAMODES];
+struct vp8_token_struct vp8_ymode_encodings   [VP8_YMODES];
+struct vp8_token_struct vp8_kf_ymode_encodings [VP8_YMODES];
+struct vp8_token_struct vp8_uv_mode_encodings  [VP8_UV_MODES];
+struct vp8_token_struct vp8_mbsplit_encodings [VP8_NUMMBSPLITS];
+
+struct vp8_token_struct vp8_mv_ref_encoding_array    [VP8_MVREFS];
+struct vp8_token_struct vp8_sub_mv_ref_encoding_array [VP8_SUBMVREFS];
+
+
+const vp8_tree_index vp8_small_mvtree [14] =
+{
+    2, 8,
+    4, 6,
+    -0, -1,
+    -2, -3,
+    10, 12,
+    -4, -5,
+    -6, -7
+};
+
+struct vp8_token_struct vp8_small_mvencodings [8];
+
+void vp8_init_mbmode_probs(VP8_COMMON *x)
+{
+    unsigned int bct [VP8_YMODES] [2];      /* num Ymodes > num UV modes */
+
+    vp8_tree_probs_from_distribution(
+        VP8_YMODES, vp8_ymode_encodings, vp8_ymode_tree,
+        x->fc.ymode_prob, bct, y_mode_cts,
+        256, 1
+    );
+    vp8_tree_probs_from_distribution(
+        VP8_YMODES, vp8_kf_ymode_encodings, vp8_kf_ymode_tree,
+        x->kf_ymode_prob, bct, kf_y_mode_cts,
+        256, 1
+    );
+    vp8_tree_probs_from_distribution(
+        VP8_UV_MODES, vp8_uv_mode_encodings, vp8_uv_mode_tree,
+        x->fc.uv_mode_prob, bct, uv_mode_cts,
+        256, 1
+    );
+    vp8_tree_probs_from_distribution(
+        VP8_UV_MODES, vp8_uv_mode_encodings, vp8_uv_mode_tree,
+        x->kf_uv_mode_prob, bct, kf_uv_mode_cts,
+        256, 1
+    );
+    vpx_memcpy(x->fc.sub_mv_ref_prob, sub_mv_ref_prob, sizeof(sub_mv_ref_prob));
+}
+
+
+static void intra_bmode_probs_from_distribution(
+    vp8_prob p [VP8_BINTRAMODES-1],
+    unsigned int branch_ct [VP8_BINTRAMODES-1] [2],
+    const unsigned int events [VP8_BINTRAMODES]
+)
+{
+    vp8_tree_probs_from_distribution(
+        VP8_BINTRAMODES, vp8_bmode_encodings, vp8_bmode_tree,
+        p, branch_ct, events,
+        256, 1
+    );
+}
+
+void vp8_default_bmode_probs(vp8_prob p [VP8_BINTRAMODES-1])
+{
+    unsigned int branch_ct [VP8_BINTRAMODES-1] [2];
+    intra_bmode_probs_from_distribution(p, branch_ct, bmode_cts);
+}
+
+void vp8_kf_default_bmode_probs(vp8_prob p [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES-1])
+{
+    unsigned int branch_ct [VP8_BINTRAMODES-1] [2];
+
+    int i = 0;
+
+    do
+    {
+        int j = 0;
+
+        do
+        {
+            intra_bmode_probs_from_distribution(
+                p[i][j], branch_ct, vp8_kf_default_bmode_counts[i][j]);
+
+        }
+        while (++j < VP8_BINTRAMODES);
+    }
+    while (++i < VP8_BINTRAMODES);
+}
+
+
+void vp8_entropy_mode_init()
+{
+    vp8_tokens_from_tree(vp8_bmode_encodings,   vp8_bmode_tree);
+    vp8_tokens_from_tree(vp8_ymode_encodings,   vp8_ymode_tree);
+    vp8_tokens_from_tree(vp8_kf_ymode_encodings, vp8_kf_ymode_tree);
+    vp8_tokens_from_tree(vp8_uv_mode_encodings,  vp8_uv_mode_tree);
+    vp8_tokens_from_tree(vp8_mbsplit_encodings, vp8_mbsplit_tree);
+
+    vp8_tokens_from_tree(VP8_MVREFENCODINGS,   vp8_mv_ref_tree);
+    vp8_tokens_from_tree(VP8_SUBMVREFENCODINGS, vp8_sub_mv_ref_tree);
+
+    vp8_tokens_from_tree(vp8_small_mvencodings, vp8_small_mvtree);
+}
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/entropymode.h
@@ -0,0 +1,72 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __INC_ENTROPYMODE_H
+#define __INC_ENTROPYMODE_H
+
+#include "onyxc_int.h"
+#include "treecoder.h"
+
+typedef const int vp8_mbsplit[16];
+
+#define VP8_NUMMBSPLITS 4
+
+extern vp8_mbsplit vp8_mbsplits [VP8_NUMMBSPLITS];
+
+extern const int vp8_mbsplit_count [VP8_NUMMBSPLITS];    /* # of subsets */
+
+extern const vp8_prob vp8_mbsplit_probs [VP8_NUMMBSPLITS-1];
+
+extern int vp8_mv_cont(const MV *l, const MV *a);
+#define SUBMVREF_COUNT 5
+extern const vp8_prob vp8_sub_mv_ref_prob2 [SUBMVREF_COUNT][VP8_SUBMVREFS-1];
+
+
+extern const unsigned int vp8_kf_default_bmode_counts [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES];
+
+
+extern const vp8_tree_index vp8_bmode_tree[];
+
+extern const vp8_tree_index  vp8_ymode_tree[];
+extern const vp8_tree_index  vp8_kf_ymode_tree[];
+extern const vp8_tree_index  vp8_uv_mode_tree[];
+
+extern const vp8_tree_index  vp8_mbsplit_tree[];
+extern const vp8_tree_index  vp8_mv_ref_tree[];
+extern const vp8_tree_index  vp8_sub_mv_ref_tree[];
+
+extern struct vp8_token_struct vp8_bmode_encodings   [VP8_BINTRAMODES];
+extern struct vp8_token_struct vp8_ymode_encodings   [VP8_YMODES];
+extern struct vp8_token_struct vp8_kf_ymode_encodings [VP8_YMODES];
+extern struct vp8_token_struct vp8_uv_mode_encodings  [VP8_UV_MODES];
+extern struct vp8_token_struct vp8_mbsplit_encodings  [VP8_NUMMBSPLITS];
+
+/* Inter mode values do not start at zero */
+
+extern struct vp8_token_struct vp8_mv_ref_encoding_array    [VP8_MVREFS];
+extern struct vp8_token_struct vp8_sub_mv_ref_encoding_array [VP8_SUBMVREFS];
+
+#define VP8_MVREFENCODINGS      (vp8_mv_ref_encoding_array - NEARESTMV)
+#define VP8_SUBMVREFENCODINGS   (vp8_sub_mv_ref_encoding_array - LEFT4X4)
+
+
+extern const vp8_tree_index vp8_small_mvtree[];
+
+extern struct vp8_token_struct vp8_small_mvencodings [8];
+
+void vp8_entropy_mode_init(void);
+
+void vp8_init_mbmode_probs(VP8_COMMON *x);
+
+void   vp8_default_bmode_probs(vp8_prob dest [VP8_BINTRAMODES-1]);
+void vp8_kf_default_bmode_probs(vp8_prob dest [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES-1]);
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/entropymv.c
@@ -0,0 +1,49 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include "entropymv.h"
+
+const MV_CONTEXT vp8_mv_update_probs[2] =
+{
+    {{
+        237,
+        246,
+        253, 253, 254, 254, 254, 254, 254,
+        254, 254, 254, 254, 254, 250, 250, 252, 254, 254
+    }},
+    {{
+        231,
+        243,
+        245, 253, 254, 254, 254, 254, 254,
+        254, 254, 254, 254, 254, 251, 251, 254, 254, 254
+    }}
+};
+const MV_CONTEXT vp8_default_mv_context[2] =
+{
+    {{
+        // row
+        162,                                        // is short
+        128,                                        // sign
+        225, 146, 172, 147, 214,  39, 156,          // short tree
+        128, 129, 132,  75, 145, 178, 206, 239, 254, 254 // long bits
+    }},
+
+
+
+    {{
+        // same for column
+        164,                                        // is short
+        128,
+        204, 170, 119, 235, 140, 230, 228,
+        128, 130, 130,  74, 148, 180, 203, 236, 254, 254 // long bits
+
+    }}
+};
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/entropymv.h
@@ -0,0 +1,42 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __INC_ENTROPYMV_H
+#define __INC_ENTROPYMV_H
+
+#include "treecoder.h"
+
+enum
+{
+    mv_max  = 1023,              /* max absolute value of a MV component */
+    MVvals = (2 * mv_max) + 1,   /* # possible values "" */
+
+    mvlong_width = 10,       /* Large MVs have 9 bit magnitudes */
+    mvnum_short = 8,         /* magnitudes 0 through 7 */
+
+    /* probability offsets for coding each MV component */
+
+    mvpis_short = 0,         /* short (<= 7) vs long (>= 8) */
+    MVPsign,                /* sign for non-zero */
+    MVPshort,               /* 8 short values = 7-position tree */
+
+    MVPbits = MVPshort + mvnum_short - 1, /* mvlong_width long value bits */
+    MVPcount = MVPbits + mvlong_width    /* (with independent probabilities) */
+};
+
+typedef struct mv_context
+{
+    vp8_prob prob[MVPcount];  /* often come in row, col pairs */
+} MV_CONTEXT;
+
+extern const MV_CONTEXT vp8_mv_update_probs[2], vp8_default_mv_context[2];
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/extend.c
@@ -0,0 +1,121 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include "extend.h"
+#include "vpx_mem/vpx_mem.h"
+
+
+static void extend_plane_borders
+(
+    unsigned char *s, // source
+    int sp,           // pitch
+    int h,            // height
+    int w,            // width
+    int et,           // extend top border
+    int el,           // extend left border
+    int eb,           // extend bottom border
+    int er            // extend right border
+)
+{
+
+    int i;
+    unsigned char *src_ptr1, *src_ptr2;
+    unsigned char *dest_ptr1, *dest_ptr2;
+    int linesize;
+
+    // copy the left and right most columns out
+    src_ptr1 = s;
+    src_ptr2 = s + w - 1;
+    dest_ptr1 = s - el;
+    dest_ptr2 = s + w;
+
+    for (i = 0; i < h - 0 + 1; i++)
+    {
+        vpx_memset(dest_ptr1, src_ptr1[0], el);
+        vpx_memset(dest_ptr2, src_ptr2[0], er);
+        src_ptr1  += sp;
+        src_ptr2  += sp;
+        dest_ptr1 += sp;
+        dest_ptr2 += sp;
+    }
+
+    // Now copy the top and bottom source lines into each line of the respective borders
+    src_ptr1 = s - el;
+    src_ptr2 = s + sp * (h - 1) - el;
+    dest_ptr1 = s + sp * (-et) - el;
+    dest_ptr2 = s + sp * (h) - el;
+    linesize = el + er + w + 1;
+
+    for (i = 0; i < (int)et; i++)
+    {
+        vpx_memcpy(dest_ptr1, src_ptr1, linesize);
+        dest_ptr1 += sp;
+    }
+
+    for (i = 0; i < (int)eb; i++)
+    {
+        vpx_memcpy(dest_ptr2, src_ptr2, linesize);
+        dest_ptr2 += sp;
+    }
+}
+
+
+void vp8_extend_to_multiple_of16(YV12_BUFFER_CONFIG *ybf, int width, int height)
+{
+    int er = 0xf & (16 - (width & 0xf));
+    int eb = 0xf & (16 - (height & 0xf));
+
+    // check for non multiples of 16
+    if (er != 0 || eb != 0)
+    {
+        extend_plane_borders(ybf->y_buffer, ybf->y_stride, height, width, 0, 0, eb, er);
+
+        //adjust for uv
+        height = (height + 1) >> 1;
+        width  = (width  + 1) >> 1;
+        er = 0x7 & (8 - (width  & 0x7));
+        eb = 0x7 & (8 - (height & 0x7));
+
+        if (er || eb)
+        {
+            extend_plane_borders(ybf->u_buffer, ybf->uv_stride, height, width, 0, 0, eb, er);
+            extend_plane_borders(ybf->v_buffer, ybf->uv_stride, height, width, 0, 0, eb, er);
+        }
+    }
+}
+
+// note the extension is only for the last row, for intra prediction purpose
+void vp8_extend_mb_row(YV12_BUFFER_CONFIG *ybf, unsigned char *YPtr, unsigned char *UPtr, unsigned char *VPtr)
+{
+    int i;
+
+    YPtr += ybf->y_stride * 14;
+    UPtr += ybf->uv_stride * 6;
+    VPtr += ybf->uv_stride * 6;
+
+    for (i = 0; i < 4; i++)
+    {
+        YPtr[i] = YPtr[-1];
+        UPtr[i] = UPtr[-1];
+        VPtr[i] = VPtr[-1];
+    }
+
+    YPtr += ybf->y_stride;
+    UPtr += ybf->uv_stride;
+    VPtr += ybf->uv_stride;
+
+    for (i = 0; i < 4; i++)
+    {
+        YPtr[i] = YPtr[-1];
+        UPtr[i] = UPtr[-1];
+        VPtr[i] = VPtr[-1];
+    }
+}
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/extend.h
@@ -0,0 +1,21 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __INC_EXTEND_H
+#define __INC_EXTEND_H
+
+#include "vpx_scale/yv12config.h"
+
+void Extend(YV12_BUFFER_CONFIG *ybf);
+void vp8_extend_mb_row(YV12_BUFFER_CONFIG *ybf, unsigned char *YPtr, unsigned char *UPtr, unsigned char *VPtr);
+void vp8_extend_to_multiple_of16(YV12_BUFFER_CONFIG *ybf, int width, int height);
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/filter_c.c
@@ -0,0 +1,540 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include <stdlib.h>
+
+#define BLOCK_HEIGHT_WIDTH 4
+#define VP8_FILTER_WEIGHT 128
+#define VP8_FILTER_SHIFT  7
+
+
+static const int bilinear_filters[8][2] =
+{
+    { 128,   0 },
+    { 112,  16 },
+    {  96,  32 },
+    {  80,  48 },
+    {  64,  64 },
+    {  48,  80 },
+    {  32,  96 },
+    {  16, 112 }
+};
+
+
+static const short sub_pel_filters[8][6] =
+{
+
+    { 0,  0,  128,    0,   0,  0 },         // note that 1/8 pel positions are just as per alpha -0.5 bicubic
+    { 0, -6,  123,   12,  -1,  0 },
+    { 2, -11, 108,   36,  -8,  1 },         // New 1/4 pel 6 tap filter
+    { 0, -9,   93,   50,  -6,  0 },
+    { 3, -16,  77,   77, -16,  3 },         // New 1/2 pel 6 tap filter
+    { 0, -6,   50,   93,  -9,  0 },
+    { 1, -8,   36,  108, -11,  2 },         // New 1/4 pel 6 tap filter
+    { 0, -1,   12,  123,  -6,  0 },
+
+
+
+};
+
+void vp8_filter_block2d_first_pass
+(
+    unsigned char *src_ptr,
+    int *output_ptr,
+    unsigned int src_pixels_per_line,
+    unsigned int pixel_step,
+    unsigned int output_height,
+    unsigned int output_width,
+    const short *vp8_filter
+)
+{
+    unsigned int i, j;
+    int  Temp;
+
+    for (i = 0; i < output_height; i++)
+    {
+        for (j = 0; j < output_width; j++)
+        {
+            Temp = ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[0]) +
+                   ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[1]) +
+                   ((int)src_ptr[0]                 * vp8_filter[2]) +
+                   ((int)src_ptr[pixel_step]         * vp8_filter[3]) +
+                   ((int)src_ptr[2*pixel_step]       * vp8_filter[4]) +
+                   ((int)src_ptr[3*pixel_step]       * vp8_filter[5]) +
+                   (VP8_FILTER_WEIGHT >> 1);      // Rounding
+
+            // Normalize back to 0-255
+            Temp = Temp >> VP8_FILTER_SHIFT;
+
+            if (Temp < 0)
+                Temp = 0;
+            else if (Temp > 255)
+                Temp = 255;
+
+            output_ptr[j] = Temp;
+            src_ptr++;
+        }
+
+        // Next row...
+        src_ptr    += src_pixels_per_line - output_width;
+        output_ptr += output_width;
+    }
+}
+
+void vp8_filter_block2d_second_pass
+(
+    int *src_ptr,
+    unsigned char *output_ptr,
+    int output_pitch,
+    unsigned int src_pixels_per_line,
+    unsigned int pixel_step,
+    unsigned int output_height,
+    unsigned int output_width,
+    const short *vp8_filter
+)
+{
+    unsigned int i, j;
+    int  Temp;
+
+    for (i = 0; i < output_height; i++)
+    {
+        for (j = 0; j < output_width; j++)
+        {
+            // Apply filter
+            Temp = ((int)src_ptr[-2 * (int)pixel_step] * vp8_filter[0]) +
+                   ((int)src_ptr[-1 * (int)pixel_step] * vp8_filter[1]) +
+                   ((int)src_ptr[0]                 * vp8_filter[2]) +
+                   ((int)src_ptr[pixel_step]         * vp8_filter[3]) +
+                   ((int)src_ptr[2*pixel_step]       * vp8_filter[4]) +
+                   ((int)src_ptr[3*pixel_step]       * vp8_filter[5]) +
+                   (VP8_FILTER_WEIGHT >> 1);   // Rounding
+
+            // Normalize back to 0-255
+            Temp = Temp >> VP8_FILTER_SHIFT;
+
+            if (Temp < 0)
+                Temp = 0;
+            else if (Temp > 255)
+                Temp = 255;
+
+            output_ptr[j] = (unsigned char)Temp;
+            src_ptr++;
+        }
+
+        // Start next row
+        src_ptr    += src_pixels_per_line - output_width;
+        output_ptr += output_pitch;
+    }
+}
+
+
+void vp8_filter_block2d
+(
+    unsigned char  *src_ptr,
+    unsigned char  *output_ptr,
+    unsigned int src_pixels_per_line,
+    int output_pitch,
+    const short  *HFilter,
+    const short  *VFilter
+)
+{
+    int FData[9*4]; // Temp data bufffer used in filtering
+
+    // First filter 1-D horizontally...
+    vp8_filter_block2d_first_pass(src_ptr - (2 * src_pixels_per_line), FData, src_pixels_per_line, 1, 9, 4, HFilter);
+
+    // then filter verticaly...
+    vp8_filter_block2d_second_pass(FData + 8, output_ptr, output_pitch, 4, 4, 4, 4, VFilter);
+}
+
+
+void vp8_block_variation_c
+(
+    unsigned char  *src_ptr,
+    int   src_pixels_per_line,
+    int *HVar,
+    int *VVar
+)
+{
+    int i, j;
+    unsigned char *Ptr = src_ptr;
+
+    for (i = 0; i < 4; i++)
+    {
+        for (j = 0; j < 4; j++)
+        {
+            *HVar += abs((int)Ptr[j] - (int)Ptr[j+1]);
+            *VVar += abs((int)Ptr[j] - (int)Ptr[j+src_pixels_per_line]);
+        }
+
+        Ptr += src_pixels_per_line;
+    }
+}
+
+
+
+
+void vp8_sixtap_predict_c
+(
+    unsigned char  *src_ptr,
+    int   src_pixels_per_line,
+    int  xoffset,
+    int  yoffset,
+    unsigned char *dst_ptr,
+    int dst_pitch
+)
+{
+    const short  *HFilter;
+    const short  *VFilter;
+
+    HFilter = sub_pel_filters[xoffset];   // 6 tap
+    VFilter = sub_pel_filters[yoffset];   // 6 tap
+
+    vp8_filter_block2d(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter);
+}
+void vp8_sixtap_predict8x8_c
+(
+    unsigned char  *src_ptr,
+    int  src_pixels_per_line,
+    int  xoffset,
+    int  yoffset,
+    unsigned char *dst_ptr,
+    int  dst_pitch
+)
+{
+    const short  *HFilter;
+    const short  *VFilter;
+    int FData[13*16];   // Temp data bufffer used in filtering
+
+    HFilter = sub_pel_filters[xoffset];   // 6 tap
+    VFilter = sub_pel_filters[yoffset];   // 6 tap
+
+    // First filter 1-D horizontally...
+    vp8_filter_block2d_first_pass(src_ptr - (2 * src_pixels_per_line), FData, src_pixels_per_line, 1, 13, 8, HFilter);
+
+
+    // then filter verticaly...
+    vp8_filter_block2d_second_pass(FData + 16, dst_ptr, dst_pitch, 8, 8, 8, 8, VFilter);
+
+}
+
+void vp8_sixtap_predict8x4_c
+(
+    unsigned char  *src_ptr,
+    int  src_pixels_per_line,
+    int  xoffset,
+    int  yoffset,
+    unsigned char *dst_ptr,
+    int  dst_pitch
+)
+{
+    const short  *HFilter;
+    const short  *VFilter;
+    int FData[13*16];   // Temp data bufffer used in filtering
+
+    HFilter = sub_pel_filters[xoffset];   // 6 tap
+    VFilter = sub_pel_filters[yoffset];   // 6 tap
+
+    // First filter 1-D horizontally...
+    vp8_filter_block2d_first_pass(src_ptr - (2 * src_pixels_per_line), FData, src_pixels_per_line, 1, 9, 8, HFilter);
+
+
+    // then filter verticaly...
+    vp8_filter_block2d_second_pass(FData + 16, dst_ptr, dst_pitch, 8, 8, 4, 8, VFilter);
+
+}
+
+void vp8_sixtap_predict16x16_c
+(
+    unsigned char  *src_ptr,
+    int  src_pixels_per_line,
+    int  xoffset,
+    int  yoffset,
+    unsigned char *dst_ptr,
+    int  dst_pitch
+)
+{
+    const short  *HFilter;
+    const short  *VFilter;
+    int FData[21*24];   // Temp data bufffer used in filtering
+
+
+    HFilter = sub_pel_filters[xoffset];   // 6 tap
+    VFilter = sub_pel_filters[yoffset];   // 6 tap
+
+    // First filter 1-D horizontally...
+    vp8_filter_block2d_first_pass(src_ptr - (2 * src_pixels_per_line), FData, src_pixels_per_line, 1, 21, 16, HFilter);
+
+    // then filter verticaly...
+    vp8_filter_block2d_second_pass(FData + 32, dst_ptr, dst_pitch, 16, 16, 16, 16, VFilter);
+
+}
+
+
+/****************************************************************************
+ *
+ *  ROUTINE       : filter_block2d_bil_first_pass
+ *
+ *  INPUTS        : UINT8  *src_ptr          : Pointer to source block.
+ *                  UINT32 src_pixels_per_line : Stride of input block.
+ *                  UINT32 pixel_step        : Offset between filter input samples (see notes).
+ *                  UINT32 output_height     : Input block height.
+ *                  UINT32 output_width      : Input block width.
+ *                  INT32  *vp8_filter          : Array of 2 bi-linear filter taps.
+ *
+ *  OUTPUTS       : INT32 *output_ptr        : Pointer to filtered block.
+ *
+ *  RETURNS       : void
+ *
+ *  FUNCTION      : Applies a 1-D 2-tap bi-linear filter to the source block in
+ *                  either horizontal or vertical direction to produce the
+ *                  filtered output block. Used to implement first-pass
+ *                  of 2-D separable filter.
+ *
+ *  SPECIAL NOTES : Produces INT32 output to retain precision for next pass.
+ *                  Two filter taps should sum to VP8_FILTER_WEIGHT.
+ *                  pixel_step defines whether the filter is applied
+ *                  horizontally (pixel_step=1) or vertically (pixel_step=stride).
+ *                  It defines the offset required to move from one input
+ *                  to the next.
+ *
+ ****************************************************************************/
+void vp8_filter_block2d_bil_first_pass
+(
+    unsigned char *src_ptr,
+    unsigned short *output_ptr,
+    unsigned int src_pixels_per_line,
+    int pixel_step,
+    unsigned int output_height,
+    unsigned int output_width,
+    const int *vp8_filter
+)
+{
+    unsigned int i, j;
+
+    for (i = 0; i < output_height; i++)
+    {
+        for (j = 0; j < output_width; j++)
+        {
+            // Apply bilinear filter
+            output_ptr[j] = (((int)src_ptr[0]          * vp8_filter[0]) +
+                             ((int)src_ptr[pixel_step] * vp8_filter[1]) +
+                             (VP8_FILTER_WEIGHT / 2)) >> VP8_FILTER_SHIFT;
+            src_ptr++;
+        }
+
+        // Next row...
+        src_ptr    += src_pixels_per_line - output_width;
+        output_ptr += output_width;
+    }
+}
+
+/****************************************************************************
+ *
+ *  ROUTINE       : filter_block2d_bil_second_pass
+ *
+ *  INPUTS        : INT32  *src_ptr          : Pointer to source block.
+ *                  UINT32 src_pixels_per_line : Stride of input block.
+ *                  UINT32 pixel_step        : Offset between filter input samples (see notes).
+ *                  UINT32 output_height     : Input block height.
+ *                  UINT32 output_width      : Input block width.
+ *                  INT32  *vp8_filter          : Array of 2 bi-linear filter taps.
+ *
+ *  OUTPUTS       : UINT16 *output_ptr       : Pointer to filtered block.
+ *
+ *  RETURNS       : void
+ *
+ *  FUNCTION      : Applies a 1-D 2-tap bi-linear filter to the source block in
+ *                  either horizontal or vertical direction to produce the
+ *                  filtered output block. Used to implement second-pass
+ *                  of 2-D separable filter.
+ *
+ *  SPECIAL NOTES : Requires 32-bit input as produced by filter_block2d_bil_first_pass.
+ *                  Two filter taps should sum to VP8_FILTER_WEIGHT.
+ *                  pixel_step defines whether the filter is applied
+ *                  horizontally (pixel_step=1) or vertically (pixel_step=stride).
+ *                  It defines the offset required to move from one input
+ *                  to the next.
+ *
+ ****************************************************************************/
+void vp8_filter_block2d_bil_second_pass
+(
+    unsigned short *src_ptr,
+    unsigned char  *output_ptr,
+    int output_pitch,
+    unsigned int  src_pixels_per_line,
+    unsigned int  pixel_step,
+    unsigned int  output_height,
+    unsigned int  output_width,
+    const int *vp8_filter
+)
+{
+    unsigned int  i, j;
+    int  Temp;
+
+    for (i = 0; i < output_height; i++)
+    {
+        for (j = 0; j < output_width; j++)
+        {
+            // Apply filter
+            Temp = ((int)src_ptr[0]         * vp8_filter[0]) +
+                   ((int)src_ptr[pixel_step] * vp8_filter[1]) +
+                   (VP8_FILTER_WEIGHT / 2);
+            output_ptr[j] = (unsigned int)(Temp >> VP8_FILTER_SHIFT);
+            src_ptr++;
+        }
+
+        // Next row...
+        src_ptr    += src_pixels_per_line - output_width;
+        output_ptr += output_pitch;
+    }
+}
+
+
+/****************************************************************************
+ *
+ *  ROUTINE       : filter_block2d_bil
+ *
+ *  INPUTS        : UINT8  *src_ptr          : Pointer to source block.
+ *                  UINT32 src_pixels_per_line : Stride of input block.
+ *                  INT32  *HFilter         : Array of 2 horizontal filter taps.
+ *                  INT32  *VFilter         : Array of 2 vertical filter taps.
+ *
+ *  OUTPUTS       : UINT16 *output_ptr       : Pointer to filtered block.
+ *
+ *  RETURNS       : void
+ *
+ *  FUNCTION      : 2-D filters an input block by applying a 2-tap
+ *                  bi-linear filter horizontally followed by a 2-tap
+ *                  bi-linear filter vertically on the result.
+ *
+ *  SPECIAL NOTES : The largest block size can be handled here is 16x16
+ *
+ ****************************************************************************/
+void vp8_filter_block2d_bil
+(
+    unsigned char *src_ptr,
+    unsigned char *output_ptr,
+    unsigned int   src_pixels_per_line,
+    unsigned int   dst_pitch,
+    const int      *HFilter,
+    const int      *VFilter,
+    int            Width,
+    int            Height
+)
+{
+
+    unsigned short FData[17*16];    // Temp data bufffer used in filtering
+
+    // First filter 1-D horizontally...
+    vp8_filter_block2d_bil_first_pass(src_ptr, FData, src_pixels_per_line, 1, Height + 1, Width, HFilter);
+
+    // then 1-D vertically...
+    vp8_filter_block2d_bil_second_pass(FData, output_ptr, dst_pitch, Width, Width, Height, Width, VFilter);
+}
+
+
+void vp8_bilinear_predict4x4_c
+(
+    unsigned char  *src_ptr,
+    int   src_pixels_per_line,
+    int  xoffset,
+    int  yoffset,
+    unsigned char *dst_ptr,
+    int dst_pitch
+)
+{
+    const int  *HFilter;
+    const int  *VFilter;
+
+    HFilter = bilinear_filters[xoffset];
+    VFilter = bilinear_filters[yoffset];
+#if 0
+    {
+        int i;
+        unsigned char temp1[16];
+        unsigned char temp2[16];
+
+        bilinear_predict4x4_mmx(src_ptr, src_pixels_per_line, xoffset, yoffset, temp1, 4);
+        vp8_filter_block2d_bil(src_ptr, temp2, src_pixels_per_line, 4, HFilter, VFilter, 4, 4);
+
+        for (i = 0; i < 16; i++)
+        {
+            if (temp1[i] != temp2[i])
+            {
+                bilinear_predict4x4_mmx(src_ptr, src_pixels_per_line, xoffset, yoffset, temp1, 4);
+                vp8_filter_block2d_bil(src_ptr, temp2, src_pixels_per_line, 4, HFilter, VFilter, 4, 4);
+            }
+        }
+    }
+#endif
+    vp8_filter_block2d_bil(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 4, 4);
+
+}
+
+void vp8_bilinear_predict8x8_c
+(
+    unsigned char  *src_ptr,
+    int  src_pixels_per_line,
+    int  xoffset,
+    int  yoffset,
+    unsigned char *dst_ptr,
+    int  dst_pitch
+)
+{
+    const int  *HFilter;
+    const int  *VFilter;
+
+    HFilter = bilinear_filters[xoffset];
+    VFilter = bilinear_filters[yoffset];
+
+    vp8_filter_block2d_bil(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 8, 8);
+
+}
+
+void vp8_bilinear_predict8x4_c
+(
+    unsigned char  *src_ptr,
+    int  src_pixels_per_line,
+    int  xoffset,
+    int  yoffset,
+    unsigned char *dst_ptr,
+    int  dst_pitch
+)
+{
+    const int  *HFilter;
+    const int  *VFilter;
+
+    HFilter = bilinear_filters[xoffset];
+    VFilter = bilinear_filters[yoffset];
+
+    vp8_filter_block2d_bil(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 8, 4);
+
+}
+
+void vp8_bilinear_predict16x16_c
+(
+    unsigned char  *src_ptr,
+    int  src_pixels_per_line,
+    int  xoffset,
+    int  yoffset,
+    unsigned char *dst_ptr,
+    int  dst_pitch
+)
+{
+    const int  *HFilter;
+    const int  *VFilter;
+
+    HFilter = bilinear_filters[xoffset];
+    VFilter = bilinear_filters[yoffset];
+
+    vp8_filter_block2d_bil(src_ptr, dst_ptr, src_pixels_per_line, dst_pitch, HFilter, VFilter, 16, 16);
+}
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/findnearmv.c
@@ -0,0 +1,208 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include "findnearmv.h"
+
+#define FINDNEAR_SEARCH_SITES   3
+
+/* Predict motion vectors using those from already-decoded nearby blocks.
+   Note that we only consider one 4x4 subblock from each candidate 16x16
+   macroblock.   */
+
+typedef union
+{
+    unsigned int as_int;
+    MV           as_mv;
+} int_mv;        /* facilitates rapid equality tests */
+
+static void mv_bias(const MODE_INFO *x, int refframe, int_mv *mvp, const int *ref_frame_sign_bias)
+{
+    MV xmv;
+    xmv = x->mbmi.mv.as_mv;
+
+    if (ref_frame_sign_bias[x->mbmi.ref_frame] != ref_frame_sign_bias[refframe])
+    {
+        xmv.row *= -1;
+        xmv.col *= -1;
+    }
+
+    mvp->as_mv = xmv;
+}
+
+
+void vp8_clamp_mv(MV *mv, const MACROBLOCKD *xd)
+{
+    if (mv->col < (xd->mb_to_left_edge - LEFT_TOP_MARGIN))
+        mv->col = xd->mb_to_left_edge - LEFT_TOP_MARGIN;
+    else if (mv->col > xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN)
+        mv->col = xd->mb_to_right_edge + RIGHT_BOTTOM_MARGIN;
+
+    if (mv->row < (xd->mb_to_top_edge - LEFT_TOP_MARGIN))
+        mv->row = xd->mb_to_top_edge - LEFT_TOP_MARGIN;
+    else if (mv->row > xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN)
+        mv->row = xd->mb_to_bottom_edge + RIGHT_BOTTOM_MARGIN;
+}
+
+
+void vp8_find_near_mvs
+(
+    MACROBLOCKD *xd,
+    const MODE_INFO *here,
+    MV *nearest,
+    MV *nearby,
+    MV *best_mv,
+    int cnt[4],
+    int refframe,
+    int *ref_frame_sign_bias
+)
+{
+    const MODE_INFO *above = here - xd->mode_info_stride;
+    const MODE_INFO *left = here - 1;
+    const MODE_INFO *aboveleft = above - 1;
+    int_mv            near_mvs[4];
+    int_mv           *mv = near_mvs;
+    int             *cntx = cnt;
+    enum {CNT_INTRA, CNT_NEAREST, CNT_NEAR, CNT_SPLITMV};
+
+    /* Zero accumulators */
+    mv[0].as_int = mv[1].as_int = mv[2].as_int = 0;
+    cnt[0] = cnt[1] = cnt[2] = cnt[3] = 0;
+
+    /* Process above */
+    if (above->mbmi.ref_frame != INTRA_FRAME)
+    {
+        if (above->mbmi.mv.as_int)
+        {
+            (++mv)->as_int = above->mbmi.mv.as_int;
+            mv_bias(above, refframe, mv, ref_frame_sign_bias);
+            ++cntx;
+        }
+
+        *cntx += 2;
+    }
+
+    /* Process left */
+    if (left->mbmi.ref_frame != INTRA_FRAME)
+    {
+        if (left->mbmi.mv.as_int)
+        {
+            int_mv this_mv;
+
+            this_mv.as_int = left->mbmi.mv.as_int;
+            mv_bias(left, refframe, &this_mv, ref_frame_sign_bias);
+
+            if (this_mv.as_int != mv->as_int)
+            {
+                (++mv)->as_int = this_mv.as_int;
+                ++cntx;
+            }
+
+            *cntx += 2;
+        }
+        else
+            cnt[CNT_INTRA] += 2;
+    }
+
+    /* Process above left */
+    if (aboveleft->mbmi.ref_frame != INTRA_FRAME)
+    {
+        if (aboveleft->mbmi.mv.as_int)
+        {
+            int_mv this_mv;
+
+            this_mv.as_int = aboveleft->mbmi.mv.as_int;
+            mv_bias(aboveleft, refframe, &this_mv, ref_frame_sign_bias);
+
+            if (this_mv.as_int != mv->as_int)
+            {
+                (++mv)->as_int = this_mv.as_int;
+                ++cntx;
+            }
+
+            *cntx += 1;
+        }
+        else
+            cnt[CNT_INTRA] += 1;
+    }
+
+    /* If we have three distinct MV's ... */
+    if (cnt[CNT_SPLITMV])
+    {
+        /* See if above-left MV can be merged with NEAREST */
+        if (mv->as_int == near_mvs[CNT_NEAREST].as_int)
+            cnt[CNT_NEAREST] += 1;
+    }
+
+    cnt[CNT_SPLITMV] = ((above->mbmi.mode == SPLITMV)
+                        + (left->mbmi.mode == SPLITMV)) * 2
+                       + (aboveleft->mbmi.mode == SPLITMV);
+
+    /* Swap near and nearest if necessary */
+    if (cnt[CNT_NEAR] > cnt[CNT_NEAREST])
+    {
+        int tmp;
+        tmp = cnt[CNT_NEAREST];
+        cnt[CNT_NEAREST] = cnt[CNT_NEAR];
+        cnt[CNT_NEAR] = tmp;
+        tmp = near_mvs[CNT_NEAREST].as_int;
+        near_mvs[CNT_NEAREST].as_int = near_mvs[CNT_NEAR].as_int;
+        near_mvs[CNT_NEAR].as_int = tmp;
+    }
+
+    /* Use near_mvs[0] to store the "best" MV */
+    if (cnt[CNT_NEAREST] >= cnt[CNT_INTRA])
+        near_mvs[CNT_INTRA] = near_mvs[CNT_NEAREST];
+
+    /* Set up return values */
+    *best_mv = near_mvs[0].as_mv;
+    *nearest = near_mvs[CNT_NEAREST].as_mv;
+    *nearby = near_mvs[CNT_NEAR].as_mv;
+
+    vp8_clamp_mv(nearest, xd);
+    vp8_clamp_mv(nearby, xd);
+    vp8_clamp_mv(best_mv, xd); //TODO: move this up before the copy
+}
+
+vp8_prob *vp8_mv_ref_probs(
+    vp8_prob p[VP8_MVREFS-1], const int near_mv_ref_ct[4]
+)
+{
+    p[0] = vp8_mode_contexts [near_mv_ref_ct[0]] [0];
+    p[1] = vp8_mode_contexts [near_mv_ref_ct[1]] [1];
+    p[2] = vp8_mode_contexts [near_mv_ref_ct[2]] [2];
+    p[3] = vp8_mode_contexts [near_mv_ref_ct[3]] [3];
+    //p[3] = vp8_mode_contexts [near_mv_ref_ct[1] + near_mv_ref_ct[2] + near_mv_ref_ct[3]] [3];
+    return p;
+}
+
+const B_MODE_INFO *vp8_left_bmi(const MODE_INFO *cur_mb, int b)
+{
+    if (!(b & 3))
+    {
+        /* On L edge, get from MB to left of us */
+        --cur_mb;
+        b += 4;
+    }
+
+    return cur_mb->bmi + b - 1;
+}
+
+const B_MODE_INFO *vp8_above_bmi(const MODE_INFO *cur_mb, int b, int mi_stride)
+{
+    if (!(b >> 2))
+    {
+        /* On top edge, get from MB above us */
+        cur_mb -= mi_stride;
+        b += 16;
+    }
+
+    return cur_mb->bmi + b - 4;
+}
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/findnearmv.h
@@ -0,0 +1,42 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __INC_FINDNEARMV_H
+#define __INC_FINDNEARMV_H
+
+#include "mv.h"
+#include "blockd.h"
+#include "modecont.h"
+#include "treecoder.h"
+
+void vp8_find_near_mvs
+(
+    MACROBLOCKD *xd,
+    const MODE_INFO *here,
+    MV *nearest, MV *nearby, MV *best,
+    int near_mv_ref_cts[4],
+    int refframe,
+    int *ref_frame_sign_bias
+);
+
+vp8_prob *vp8_mv_ref_probs(
+    vp8_prob p[VP8_MVREFS-1], const int near_mv_ref_ct[4]
+);
+
+const B_MODE_INFO *vp8_left_bmi(const MODE_INFO *cur_mb, int b);
+
+const B_MODE_INFO *vp8_above_bmi(const MODE_INFO *cur_mb, int b, int mi_stride);
+
+#define LEFT_TOP_MARGIN (16 << 3)
+#define RIGHT_BOTTOM_MARGIN (16 << 3)
+
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/g_common.h
@@ -0,0 +1,21 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+extern void (*vp8_clear_system_state)(void);
+extern void (*vp8_plane_add_noise)(unsigned char *Start, unsigned int Width, unsigned int Height, int Pitch, int DPitch, int q);
+extern void (*de_interlace)
+(
+    unsigned char *src_ptr,
+    unsigned char *dst_ptr,
+    int Width,
+    int Height,
+    int Stride
+);
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/generic/systemdependent.c
@@ -0,0 +1,80 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include "vpx_ports/config.h"
+#include "g_common.h"
+#include "subpixel.h"
+#include "loopfilter.h"
+#include "recon.h"
+#include "idct.h"
+#include "onyxc_int.h"
+
+extern void vp8_arch_x86_common_init(VP8_COMMON *ctx);
+
+void (*vp8_build_intra_predictors_mby_ptr)(MACROBLOCKD *x);
+extern void vp8_build_intra_predictors_mby(MACROBLOCKD *x);
+
+void (*vp8_build_intra_predictors_mby_s_ptr)(MACROBLOCKD *x);
+extern void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x);
+
+void vp8_machine_specific_config(VP8_COMMON *ctx)
+{
+#if CONFIG_RUNTIME_CPU_DETECT
+    VP8_COMMON_RTCD *rtcd = &ctx->rtcd;
+
+    rtcd->idct.idct1        = vp8_short_idct4x4llm_1_c;
+    rtcd->idct.idct16       = vp8_short_idct4x4llm_c;
+    rtcd->idct.idct1_scalar = vp8_dc_only_idct_c;
+    rtcd->idct.iwalsh1      = vp8_short_inv_walsh4x4_1_c;
+    rtcd->idct.iwalsh16     = vp8_short_inv_walsh4x4_c;
+
+    rtcd->recon.copy16x16   = vp8_copy_mem16x16_c;
+    rtcd->recon.copy8x8     = vp8_copy_mem8x8_c;
+    rtcd->recon.copy8x4     = vp8_copy_mem8x4_c;
+    rtcd->recon.recon      = vp8_recon_b_c;
+    rtcd->recon.recon2      = vp8_recon2b_c;
+    rtcd->recon.recon4     = vp8_recon4b_c;
+
+    rtcd->subpix.sixtap16x16   = vp8_sixtap_predict16x16_c;
+    rtcd->subpix.sixtap8x8     = vp8_sixtap_predict8x8_c;
+    rtcd->subpix.sixtap8x4     = vp8_sixtap_predict8x4_c;
+    rtcd->subpix.sixtap4x4     = vp8_sixtap_predict_c;
+    rtcd->subpix.bilinear16x16 = vp8_bilinear_predict16x16_c;
+    rtcd->subpix.bilinear8x8   = vp8_bilinear_predict8x8_c;
+    rtcd->subpix.bilinear8x4   = vp8_bilinear_predict8x4_c;
+    rtcd->subpix.bilinear4x4   = vp8_bilinear_predict4x4_c;
+
+    rtcd->loopfilter.normal_mb_v = vp8_loop_filter_mbv_c;
+    rtcd->loopfilter.normal_b_v  = vp8_loop_filter_bv_c;
+    rtcd->loopfilter.normal_mb_h = vp8_loop_filter_mbh_c;
+    rtcd->loopfilter.normal_b_h  = vp8_loop_filter_bh_c;
+    rtcd->loopfilter.simple_mb_v = vp8_loop_filter_mbvs_c;
+    rtcd->loopfilter.simple_b_v  = vp8_loop_filter_bvs_c;
+    rtcd->loopfilter.simple_mb_h = vp8_loop_filter_mbhs_c;
+    rtcd->loopfilter.simple_b_h  = vp8_loop_filter_bhs_c;
+
+#if CONFIG_POSTPROC || CONFIG_VP8_ENCODER
+    rtcd->postproc.down        = vp8_mbpost_proc_down_c;
+    rtcd->postproc.across      = vp8_mbpost_proc_across_ip_c;
+    rtcd->postproc.downacross  = vp8_post_proc_down_and_across_c;
+    rtcd->postproc.addnoise    = vp8_plane_add_noise_c;
+#endif
+
+#endif
+    // Pure C:
+    vp8_build_intra_predictors_mby_ptr = vp8_build_intra_predictors_mby;
+    vp8_build_intra_predictors_mby_s_ptr = vp8_build_intra_predictors_mby_s;
+
+#if ARCH_X86 || ARCH_X86_64
+    vp8_arch_x86_common_init(ctx);
+#endif
+
+}
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/header.h
@@ -0,0 +1,43 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __INC_HEADER_H
+#define __INC_HEADER_H
+
+/* 24 bits total */
+typedef struct
+{
+    unsigned int type: 1;
+    unsigned int version: 3;
+    unsigned int show_frame: 1;
+
+    /* Allow 2^20 bytes = 8 megabits for first partition */
+
+    unsigned int first_partition_length_in_bytes: 19;
+
+#ifdef PACKET_TESTING
+    unsigned int frame_number;
+    unsigned int update_gold: 1;
+    unsigned int uses_gold: 1;
+    unsigned int update_last: 1;
+    unsigned int uses_last: 1;
+#endif
+
+} VP8_HEADER;
+
+#ifdef PACKET_TESTING
+#define VP8_HEADER_SIZE 8
+#else
+#define VP8_HEADER_SIZE 3
+#endif
+
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/idct.h
@@ -0,0 +1,78 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __INC_IDCT_H
+#define __INC_IDCT_H
+
+#define prototype_second_order(sym) \
+    void sym(short *input, short *output)
+
+#define prototype_idct(sym) \
+    void sym(short *input, short *output, int pitch)
+
+#define prototype_idct_scalar(sym) \
+    void sym(short input, short *output, int pitch)
+
+#if ARCH_X86 || ARCH_X86_64
+#include "x86/idct_x86.h"
+#endif
+
+#if ARCH_ARM
+#include "arm/idct_arm.h"
+#endif
+
+#ifndef vp8_idct_idct1
+#define vp8_idct_idct1 vp8_short_idct4x4llm_1_c
+#endif
+extern prototype_idct(vp8_idct_idct1);
+
+#ifndef vp8_idct_idct16
+#define vp8_idct_idct16 vp8_short_idct4x4llm_c
+#endif
+extern prototype_idct(vp8_idct_idct16);
+
+#ifndef vp8_idct_idct1_scalar
+#define vp8_idct_idct1_scalar vp8_dc_only_idct_c
+#endif
+extern prototype_idct_scalar(vp8_idct_idct1_scalar);
+
+
+#ifndef vp8_idct_iwalsh1
+#define vp8_idct_iwalsh1 vp8_short_inv_walsh4x4_1_c
+#endif
+extern prototype_second_order(vp8_idct_iwalsh1);
+
+#ifndef vp8_idct_iwalsh16
+#define vp8_idct_iwalsh16 vp8_short_inv_walsh4x4_c
+#endif
+extern prototype_second_order(vp8_idct_iwalsh16);
+
+typedef prototype_idct((*vp8_idct_fn_t));
+typedef prototype_idct_scalar((*vp8_idct_scalar_fn_t));
+typedef prototype_second_order((*vp8_second_order_fn_t));
+
+typedef struct
+{
+    vp8_idct_fn_t         idct1;
+    vp8_idct_fn_t         idct16;
+    vp8_idct_scalar_fn_t  idct1_scalar;
+
+    vp8_second_order_fn_t iwalsh1;
+    vp8_second_order_fn_t iwalsh16;
+} vp8_idct_rtcd_vtable_t;
+
+#if CONFIG_RUNTIME_CPU_DETECT
+#define IDCT_INVOKE(ctx,fn) (ctx)->fn
+#else
+#define IDCT_INVOKE(ctx,fn) vp8_idct_##fn
+#endif
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/idctllm.c
@@ -0,0 +1,190 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+/****************************************************************************
+ * Notes:
+ *
+ * This implementation makes use of 16 bit fixed point verio of two multiply
+ * constants:
+ *         1.   sqrt(2) * cos (pi/8)
+ *         2.   sqrt(2) * sin (pi/8)
+ * Becuase the first constant is bigger than 1, to maintain the same 16 bit
+ * fixed point precision as the second one, we use a trick of
+ *         x * a = x + x*(a-1)
+ * so
+ *         x * sqrt(2) * cos (pi/8) = x + x * (sqrt(2) *cos(pi/8)-1).
+ **************************************************************************/
+static const int cospi8sqrt2minus1 = 20091;
+static const int sinpi8sqrt2      = 35468;
+static const int rounding = 0;
+void vp8_short_idct4x4llm_c(short *input, short *output, int pitch)
+{
+    int i;
+    int a1, b1, c1, d1;
+
+    short *ip = input;
+    short *op = output;
+    int temp1, temp2;
+    int shortpitch = pitch >> 1;
+
+    for (i = 0; i < 4; i++)
+    {
+        a1 = ip[0] + ip[8];
+        b1 = ip[0] - ip[8];
+
+        temp1 = (ip[4] * sinpi8sqrt2 + rounding) >> 16;
+        temp2 = ip[12] + ((ip[12] * cospi8sqrt2minus1 + rounding) >> 16);
+        c1 = temp1 - temp2;
+
+        temp1 = ip[4] + ((ip[4] * cospi8sqrt2minus1 + rounding) >> 16);
+        temp2 = (ip[12] * sinpi8sqrt2 + rounding) >> 16;
+        d1 = temp1 + temp2;
+
+        op[shortpitch*0] = a1 + d1;
+        op[shortpitch*3] = a1 - d1;
+
+        op[shortpitch*1] = b1 + c1;
+        op[shortpitch*2] = b1 - c1;
+
+        ip++;
+        op++;
+    }
+
+    ip = output;
+    op = output;
+
+    for (i = 0; i < 4; i++)
+    {
+        a1 = ip[0] + ip[2];
+        b1 = ip[0] - ip[2];
+
+        temp1 = (ip[1] * sinpi8sqrt2 + rounding) >> 16;
+        temp2 = ip[3] + ((ip[3] * cospi8sqrt2minus1 + rounding) >> 16);
+        c1 = temp1 - temp2;
+
+        temp1 = ip[1] + ((ip[1] * cospi8sqrt2minus1 + rounding) >> 16);
+        temp2 = (ip[3] * sinpi8sqrt2 + rounding) >> 16;
+        d1 = temp1 + temp2;
+
+
+        op[0] = (a1 + d1 + 4) >> 3;
+        op[3] = (a1 - d1 + 4) >> 3;
+
+        op[1] = (b1 + c1 + 4) >> 3;
+        op[2] = (b1 - c1 + 4) >> 3;
+
+        ip += shortpitch;
+        op += shortpitch;
+    }
+}
+
+void vp8_short_idct4x4llm_1_c(short *input, short *output, int pitch)
+{
+    int i;
+    int a1;
+    short *op = output;
+    int shortpitch = pitch >> 1;
+    a1 = ((input[0] + 4) >> 3);
+
+    for (i = 0; i < 4; i++)
+    {
+        op[0] = a1;
+        op[1] = a1;
+        op[2] = a1;
+        op[3] = a1;
+        op += shortpitch;
+    }
+}
+
+
+void vp8_dc_only_idct_c(short input_dc, short *output, int pitch)
+{
+    int i;
+    int a1;
+    short *op = output;
+    int shortpitch = pitch >> 1;
+    a1 = ((input_dc + 4) >> 3);
+
+    for (i = 0; i < 4; i++)
+    {
+        op[0] = a1;
+        op[1] = a1;
+        op[2] = a1;
+        op[3] = a1;
+        op += shortpitch;
+    }
+}
+
+void vp8_short_inv_walsh4x4_c(short *input, short *output)
+{
+    int i;
+    int a1, b1, c1, d1;
+    int a2, b2, c2, d2;
+    short *ip = input;
+    short *op = output;
+
+    for (i = 0; i < 4; i++)
+    {
+        a1 = ip[0] + ip[12];
+        b1 = ip[4] + ip[8];
+        c1 = ip[4] - ip[8];
+        d1 = ip[0] - ip[12];
+
+        op[0] = a1 + b1;
+        op[4] = c1 + d1;
+        op[8] = a1 - b1;
+        op[12] = d1 - c1;
+        ip++;
+        op++;
+    }
+
+    ip = output;
+    op = output;
+
+    for (i = 0; i < 4; i++)
+    {
+        a1 = ip[0] + ip[3];
+        b1 = ip[1] + ip[2];
+        c1 = ip[1] - ip[2];
+        d1 = ip[0] - ip[3];
+
+        a2 = a1 + b1;
+        b2 = c1 + d1;
+        c2 = a1 - b1;
+        d2 = d1 - c1;
+
+        op[0] = (a2 + 3) >> 3;
+        op[1] = (b2 + 3) >> 3;
+        op[2] = (c2 + 3) >> 3;
+        op[3] = (d2 + 3) >> 3;
+
+        ip += 4;
+        op += 4;
+    }
+}
+
+void vp8_short_inv_walsh4x4_1_c(short *input, short *output)
+{
+    int i;
+    int a1;
+    short *op = output;
+
+    a1 = ((input[0] + 3) >> 3);
+
+    for (i = 0; i < 4; i++)
+    {
+        op[0] = a1;
+        op[1] = a1;
+        op[2] = a1;
+        op[3] = a1;
+        op += 4;
+    }
+}
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/invtrans.c
@@ -0,0 +1,87 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include "invtrans.h"
+
+
+
+static void recon_dcblock(MACROBLOCKD *x)
+{
+    BLOCKD *b = &x->block[24];
+    int i;
+
+    for (i = 0; i < 16; i++)
+    {
+        x->block[i].dqcoeff[0] = b->diff[i];
+    }
+
+}
+
+void vp8_inverse_transform_b(const vp8_idct_rtcd_vtable_t *rtcd, BLOCKD *b, int pitch)
+{
+    if (b->eob > 1)
+        IDCT_INVOKE(rtcd, idct16)(b->dqcoeff, b->diff, pitch);
+    else
+        IDCT_INVOKE(rtcd, idct1)(b->dqcoeff, b->diff, pitch);
+}
+
+
+void vp8_inverse_transform_mby(const vp8_idct_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
+{
+    int i;
+
+    // do 2nd order transform on the dc block
+    IDCT_INVOKE(rtcd, iwalsh16)(x->block[24].dqcoeff, x->block[24].diff);
+
+    recon_dcblock(x);
+
+    for (i = 0; i < 16; i++)
+    {
+        vp8_inverse_transform_b(rtcd, &x->block[i], 32);
+    }
+
+}
+void vp8_inverse_transform_mbuv(const vp8_idct_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
+{
+    int i;
+
+    for (i = 16; i < 24; i++)
+    {
+        vp8_inverse_transform_b(rtcd, &x->block[i], 16);
+    }
+
+}
+
+
+void vp8_inverse_transform_mb(const vp8_idct_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
+{
+    int i;
+
+    if (x->mbmi.mode != B_PRED && x->mbmi.mode != SPLITMV)
+    {
+        // do 2nd order transform on the dc block
+
+        IDCT_INVOKE(rtcd, iwalsh16)(&x->block[24].dqcoeff[0], x->block[24].diff);
+        recon_dcblock(x);
+    }
+
+    for (i = 0; i < 16; i++)
+    {
+        vp8_inverse_transform_b(rtcd, &x->block[i], 32);
+    }
+
+
+    for (i = 16; i < 24; i++)
+    {
+        vp8_inverse_transform_b(rtcd, &x->block[i], 16);
+    }
+
+}
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/invtrans.h
@@ -0,0 +1,23 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __INC_INVTRANS_H
+#define __INC_INVTRANS_H
+
+#include "vpx_ports/config.h"
+#include "idct.h"
+#include "blockd.h"
+extern void vp8_inverse_transform_b(const vp8_idct_rtcd_vtable_t *rtcd, BLOCKD *b, int pitch);
+extern void vp8_inverse_transform_mb(const vp8_idct_rtcd_vtable_t *rtcd, MACROBLOCKD *x);
+extern void vp8_inverse_transform_mby(const vp8_idct_rtcd_vtable_t *rtcd, MACROBLOCKD *x);
+extern void vp8_inverse_transform_mbuv(const vp8_idct_rtcd_vtable_t *rtcd, MACROBLOCKD *x);
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/loopfilter.c
@@ -0,0 +1,602 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include "vpx_ports/config.h"
+#include "loopfilter.h"
+#include "onyxc_int.h"
+
+typedef unsigned char uc;
+
+
+prototype_loopfilter(vp8_loop_filter_horizontal_edge_c);
+prototype_loopfilter(vp8_loop_filter_vertical_edge_c);
+prototype_loopfilter(vp8_mbloop_filter_horizontal_edge_c);
+prototype_loopfilter(vp8_mbloop_filter_vertical_edge_c);
+prototype_loopfilter(vp8_loop_filter_simple_horizontal_edge_c);
+prototype_loopfilter(vp8_loop_filter_simple_vertical_edge_c);
+
+// Horizontal MB filtering
+void vp8_loop_filter_mbh_c(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
+                           int y_stride, int uv_stride, loop_filter_info *lfi, int simpler_lpf)
+{
+    (void) simpler_lpf;
+    vp8_mbloop_filter_horizontal_edge_c(y_ptr, y_stride, lfi->mbflim, lfi->lim, lfi->mbthr, 2);
+
+    if (u_ptr)
+        vp8_mbloop_filter_horizontal_edge_c(u_ptr, uv_stride, lfi->uvmbflim, lfi->uvlim, lfi->uvmbthr, 1);
+
+    if (v_ptr)
+        vp8_mbloop_filter_horizontal_edge_c(v_ptr, uv_stride, lfi->uvmbflim, lfi->uvlim, lfi->uvmbthr, 1);
+}
+
+void vp8_loop_filter_mbhs_c(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
+                            int y_stride, int uv_stride, loop_filter_info *lfi, int simpler_lpf)
+{
+    (void) u_ptr;
+    (void) v_ptr;
+    (void) uv_stride;
+    (void) simpler_lpf;
+    vp8_loop_filter_simple_horizontal_edge_c(y_ptr, y_stride, lfi->mbflim, lfi->lim, lfi->mbthr, 2);
+}
+
+// Vertical MB Filtering
+void vp8_loop_filter_mbv_c(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
+                           int y_stride, int uv_stride, loop_filter_info *lfi, int simpler_lpf)
+{
+    (void) simpler_lpf;
+    vp8_mbloop_filter_vertical_edge_c(y_ptr, y_stride, lfi->mbflim, lfi->lim, lfi->mbthr, 2);
+
+    if (u_ptr)
+        vp8_mbloop_filter_vertical_edge_c(u_ptr, uv_stride, lfi->uvmbflim, lfi->uvlim, lfi->uvmbthr, 1);
+
+    if (v_ptr)
+        vp8_mbloop_filter_vertical_edge_c(v_ptr, uv_stride, lfi->uvmbflim, lfi->uvlim, lfi->uvmbthr, 1);
+}
+
+void vp8_loop_filter_mbvs_c(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
+                            int y_stride, int uv_stride, loop_filter_info *lfi, int simpler_lpf)
+{
+    (void) u_ptr;
+    (void) v_ptr;
+    (void) uv_stride;
+    (void) simpler_lpf;
+    vp8_loop_filter_simple_vertical_edge_c(y_ptr, y_stride, lfi->mbflim, lfi->lim, lfi->mbthr, 2);
+}
+
+// Horizontal B Filtering
+void vp8_loop_filter_bh_c(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
+                          int y_stride, int uv_stride, loop_filter_info *lfi, int simpler_lpf)
+{
+    (void) simpler_lpf;
+    vp8_loop_filter_horizontal_edge_c(y_ptr + 4 * y_stride, y_stride, lfi->flim, lfi->lim, lfi->thr, 2);
+    vp8_loop_filter_horizontal_edge_c(y_ptr + 8 * y_stride, y_stride, lfi->flim, lfi->lim, lfi->thr, 2);
+    vp8_loop_filter_horizontal_edge_c(y_ptr + 12 * y_stride, y_stride, lfi->flim, lfi->lim, lfi->thr, 2);
+
+    if (u_ptr)
+        vp8_loop_filter_horizontal_edge_c(u_ptr + 4 * uv_stride, uv_stride, lfi->uvflim, lfi->uvlim, lfi->uvthr, 1);
+
+    if (v_ptr)
+        vp8_loop_filter_horizontal_edge_c(v_ptr + 4 * uv_stride, uv_stride, lfi->uvflim, lfi->uvlim, lfi->uvthr, 1);
+}
+
+void vp8_loop_filter_bhs_c(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
+                           int y_stride, int uv_stride, loop_filter_info *lfi, int simpler_lpf)
+{
+    (void) u_ptr;
+    (void) v_ptr;
+    (void) uv_stride;
+    (void) simpler_lpf;
+    vp8_loop_filter_simple_horizontal_edge_c(y_ptr + 4 * y_stride, y_stride, lfi->flim, lfi->lim, lfi->thr, 2);
+    vp8_loop_filter_simple_horizontal_edge_c(y_ptr + 8 * y_stride, y_stride, lfi->flim, lfi->lim, lfi->thr, 2);
+    vp8_loop_filter_simple_horizontal_edge_c(y_ptr + 12 * y_stride, y_stride, lfi->flim, lfi->lim, lfi->thr, 2);
+}
+
+// Vertical B Filtering
+void vp8_loop_filter_bv_c(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
+                          int y_stride, int uv_stride, loop_filter_info *lfi, int simpler_lpf)
+{
+    (void) simpler_lpf;
+    vp8_loop_filter_vertical_edge_c(y_ptr + 4, y_stride, lfi->flim, lfi->lim, lfi->thr, 2);
+    vp8_loop_filter_vertical_edge_c(y_ptr + 8, y_stride, lfi->flim, lfi->lim, lfi->thr, 2);
+    vp8_loop_filter_vertical_edge_c(y_ptr + 12, y_stride, lfi->flim, lfi->lim, lfi->thr, 2);
+
+    if (u_ptr)
+        vp8_loop_filter_vertical_edge_c(u_ptr + 4, uv_stride, lfi->uvflim, lfi->uvlim, lfi->uvthr, 1);
+
+    if (v_ptr)
+        vp8_loop_filter_vertical_edge_c(v_ptr + 4, uv_stride, lfi->uvflim, lfi->uvlim, lfi->uvthr, 1);
+}
+
+void vp8_loop_filter_bvs_c(unsigned char *y_ptr, unsigned char *u_ptr, unsigned char *v_ptr,
+                           int y_stride, int uv_stride, loop_filter_info *lfi, int simpler_lpf)
+{
+    (void) u_ptr;
+    (void) v_ptr;
+    (void) uv_stride;
+    (void) simpler_lpf;
+    vp8_loop_filter_simple_vertical_edge_c(y_ptr + 4, y_stride, lfi->flim, lfi->lim, lfi->thr, 2);
+    vp8_loop_filter_simple_vertical_edge_c(y_ptr + 8, y_stride, lfi->flim, lfi->lim, lfi->thr, 2);
+    vp8_loop_filter_simple_vertical_edge_c(y_ptr + 12, y_stride, lfi->flim, lfi->lim, lfi->thr, 2);
+}
+
+void vp8_init_loop_filter(VP8_COMMON *cm)
+{
+    loop_filter_info *lfi = cm->lf_info;
+    LOOPFILTERTYPE lft = cm->filter_type;
+    int sharpness_lvl = cm->sharpness_level;
+    int frame_type = cm->frame_type;
+    int i, j;
+
+    int block_inside_limit = 0;
+    int HEVThresh;
+    const int yhedge_boost  = 2;
+    const int uvhedge_boost = 2;
+
+    // For each possible value for the loop filter fill out a "loop_filter_info" entry.
+    for (i = 0; i <= MAX_LOOP_FILTER; i++)
+    {
+        int filt_lvl = i;
+
+        if (frame_type == KEY_FRAME)
+        {
+            if (filt_lvl >= 40)
+                HEVThresh = 2;
+            else if (filt_lvl >= 15)
+                HEVThresh = 1;
+            else
+                HEVThresh = 0;
+        }
+        else
+        {
+            if (filt_lvl >= 40)
+                HEVThresh = 3;
+            else if (filt_lvl >= 20)
+                HEVThresh = 2;
+            else if (filt_lvl >= 15)
+                HEVThresh = 1;
+            else
+                HEVThresh = 0;
+        }
+
+        // Set loop filter paramaeters that control sharpness.
+        block_inside_limit = filt_lvl >> (sharpness_lvl > 0);
+        block_inside_limit = block_inside_limit >> (sharpness_lvl > 4);
+
+        if (sharpness_lvl > 0)
+        {
+            if (block_inside_limit > (9 - sharpness_lvl))
+                block_inside_limit = (9 - sharpness_lvl);
+        }
+
+        if (block_inside_limit < 1)
+            block_inside_limit = 1;
+
+        for (j = 0; j < 16; j++)
+        {
+            lfi[i].lim[j] = block_inside_limit;
+            lfi[i].mbflim[j] = filt_lvl + yhedge_boost;
+            lfi[i].mbthr[j] = HEVThresh;
+            lfi[i].flim[j] = filt_lvl;
+            lfi[i].thr[j] = HEVThresh;
+            lfi[i].uvlim[j] = block_inside_limit;
+            lfi[i].uvmbflim[j] = filt_lvl + uvhedge_boost;
+            lfi[i].uvmbthr[j] = HEVThresh;
+            lfi[i].uvflim[j] = filt_lvl;
+            lfi[i].uvthr[j] = HEVThresh;
+        }
+
+    }
+
+    // Set up the function pointers depending on the type of loop filtering selected
+    if (lft == NORMAL_LOOPFILTER)
+    {
+        cm->lf_mbv = LF_INVOKE(&cm->rtcd.loopfilter, normal_mb_v);
+        cm->lf_bv  = LF_INVOKE(&cm->rtcd.loopfilter, normal_b_v);
+        cm->lf_mbh = LF_INVOKE(&cm->rtcd.loopfilter, normal_mb_h);
+        cm->lf_bh  = LF_INVOKE(&cm->rtcd.loopfilter, normal_b_h);
+    }
+    else
+    {
+        cm->lf_mbv = LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_v);
+        cm->lf_bv  = LF_INVOKE(&cm->rtcd.loopfilter, simple_b_v);
+        cm->lf_mbh = LF_INVOKE(&cm->rtcd.loopfilter, simple_mb_h);
+        cm->lf_bh  = LF_INVOKE(&cm->rtcd.loopfilter, simple_b_h);
+    }
+}
+
+// Put vp8_init_loop_filter() in vp8dx_create_decompressor(). Only call vp8_frame_init_loop_filter() while decoding
+// each frame. Check last_frame_type to skip the function most of times.
+void vp8_frame_init_loop_filter(loop_filter_info *lfi, int frame_type)
+{
+    int HEVThresh;
+    int i, j;
+
+    // For each possible value for the loop filter fill out a "loop_filter_info" entry.
+    for (i = 0; i <= MAX_LOOP_FILTER; i++)
+    {
+        int filt_lvl = i;
+
+        if (frame_type == KEY_FRAME)
+        {
+            if (filt_lvl >= 40)
+                HEVThresh = 2;
+            else if (filt_lvl >= 15)
+                HEVThresh = 1;
+            else
+                HEVThresh = 0;
+        }
+        else
+        {
+            if (filt_lvl >= 40)
+                HEVThresh = 3;
+            else if (filt_lvl >= 20)
+                HEVThresh = 2;
+            else if (filt_lvl >= 15)
+                HEVThresh = 1;
+            else
+                HEVThresh = 0;
+        }
+
+        for (j = 0; j < 16; j++)
+        {
+            //lfi[i].lim[j] = block_inside_limit;
+            //lfi[i].mbflim[j] = filt_lvl+yhedge_boost;
+            lfi[i].mbthr[j] = HEVThresh;
+            //lfi[i].flim[j] = filt_lvl;
+            lfi[i].thr[j] = HEVThresh;
+            //lfi[i].uvlim[j] = block_inside_limit;
+            //lfi[i].uvmbflim[j] = filt_lvl+uvhedge_boost;
+            lfi[i].uvmbthr[j] = HEVThresh;
+            //lfi[i].uvflim[j] = filt_lvl;
+            lfi[i].uvthr[j] = HEVThresh;
+        }
+    }
+}
+
+
+void vp8_adjust_mb_lf_value(MACROBLOCKD *mbd, int *filter_level)
+{
+    MB_MODE_INFO *mbmi = &mbd->mode_info_context->mbmi;
+
+    if (mbd->mode_ref_lf_delta_enabled)
+    {
+        // Aplly delta for reference frame
+        *filter_level += mbd->ref_lf_deltas[mbmi->ref_frame];
+
+        // Apply delta for mode
+        if (mbmi->ref_frame == INTRA_FRAME)
+        {
+            // Only the split mode BPRED has a further special case
+            if (mbmi->mode == B_PRED)
+                *filter_level +=  mbd->mode_lf_deltas[0];
+        }
+        else
+        {
+            // Zero motion mode
+            if (mbmi->mode == ZEROMV)
+                *filter_level +=  mbd->mode_lf_deltas[1];
+
+            // Split MB motion mode
+            else if (mbmi->mode == SPLITMV)
+                *filter_level +=  mbd->mode_lf_deltas[3];
+
+            // All other inter motion modes (Nearest, Near, New)
+            else
+                *filter_level +=  mbd->mode_lf_deltas[2];
+        }
+
+        // Range check
+        if (*filter_level > MAX_LOOP_FILTER)
+            *filter_level = MAX_LOOP_FILTER;
+        else if (*filter_level < 0)
+            *filter_level = 0;
+    }
+}
+
+
+void vp8_loop_filter_frame
+(
+    VP8_COMMON *cm,
+    MACROBLOCKD *mbd,
+    int default_filt_lvl
+)
+{
+    YV12_BUFFER_CONFIG *post = cm->frame_to_show;
+    loop_filter_info *lfi = cm->lf_info;
+    int frame_type = cm->frame_type;
+
+    int mb_row;
+    int mb_col;
+
+
+    int baseline_filter_level[MAX_MB_SEGMENTS];
+    int filter_level;
+    int alt_flt_enabled = mbd->segmentation_enabled;
+
+    int i;
+    unsigned char *y_ptr, *u_ptr, *v_ptr;
+
+    mbd->mode_info_context = cm->mi;          // Point at base of Mb MODE_INFO list
+
+    // Note the baseline filter values for each segment
+    if (alt_flt_enabled)
+    {
+        for (i = 0; i < MAX_MB_SEGMENTS; i++)
+        {
+            // Abs value
+            if (mbd->mb_segement_abs_delta == SEGMENT_ABSDATA)
+                baseline_filter_level[i] = mbd->segment_feature_data[MB_LVL_ALT_LF][i];
+            // Delta Value
+            else
+            {
+                baseline_filter_level[i] = default_filt_lvl + mbd->segment_feature_data[MB_LVL_ALT_LF][i];
+                baseline_filter_level[i] = (baseline_filter_level[i] >= 0) ? ((baseline_filter_level[i] <= MAX_LOOP_FILTER) ? baseline_filter_level[i] : MAX_LOOP_FILTER) : 0;  // Clamp to valid range
+            }
+        }
+    }
+    else
+    {
+        for (i = 0; i < MAX_MB_SEGMENTS; i++)
+            baseline_filter_level[i] = default_filt_lvl;
+    }
+
+    // Initialize the loop filter for this frame.
+    if ((cm->last_filter_type != cm->filter_type) || (cm->last_sharpness_level != cm->sharpness_level))
+        vp8_init_loop_filter(cm);
+    else if (frame_type != cm->last_frame_type)
+        vp8_frame_init_loop_filter(lfi, frame_type);
+
+    // Set up the buffer pointers
+    y_ptr = post->y_buffer;
+    u_ptr = post->u_buffer;
+    v_ptr = post->v_buffer;
+
+    // vp8_filter each macro block
+    for (mb_row = 0; mb_row < cm->mb_rows; mb_row++)
+    {
+        for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
+        {
+            int Segment = (alt_flt_enabled) ? mbd->mode_info_context->mbmi.segment_id : 0;
+
+            filter_level = baseline_filter_level[Segment];
+
+            // Distance of Mb to the various image edges.
+            // These specified to 8th pel as they are always compared to values that are in 1/8th pel units
+            // Apply any context driven MB level adjustment
+            vp8_adjust_mb_lf_value(mbd, &filter_level);
+
+            if (filter_level)
+            {
+                if (mb_col > 0)
+                    cm->lf_mbv(y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &lfi[filter_level], cm->simpler_lpf);
+
+                if (mbd->mode_info_context->mbmi.dc_diff > 0)
+                    cm->lf_bv(y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &lfi[filter_level], cm->simpler_lpf);
+
+                // don't apply across umv border
+                if (mb_row > 0)
+                    cm->lf_mbh(y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &lfi[filter_level], cm->simpler_lpf);
+
+                if (mbd->mode_info_context->mbmi.dc_diff > 0)
+                    cm->lf_bh(y_ptr, u_ptr, v_ptr, post->y_stride, post->uv_stride, &lfi[filter_level], cm->simpler_lpf);
+            }
+
+            y_ptr += 16;
+            u_ptr += 8;
+            v_ptr += 8;
+
+            mbd->mode_info_context++;     // step to next MB
+        }
+
+        y_ptr += post->y_stride  * 16 - post->y_width;
+        u_ptr += post->uv_stride *  8 - post->uv_width;
+        v_ptr += post->uv_stride *  8 - post->uv_width;
+
+        mbd->mode_info_context++;         // Skip border mb
+    }
+}
+
+
+void vp8_loop_filter_frame_yonly
+(
+    VP8_COMMON *cm,
+    MACROBLOCKD *mbd,
+    int default_filt_lvl,
+    int sharpness_lvl
+)
+{
+    YV12_BUFFER_CONFIG *post = cm->frame_to_show;
+
+    int i;
+    unsigned char *y_ptr;
+    int mb_row;
+    int mb_col;
+
+    loop_filter_info *lfi = cm->lf_info;
+    int baseline_filter_level[MAX_MB_SEGMENTS];
+    int filter_level;
+    int alt_flt_enabled = mbd->segmentation_enabled;
+    int frame_type = cm->frame_type;
+
+    (void) sharpness_lvl;
+
+    //MODE_INFO * this_mb_mode_info = cm->mi;  // Point at base of Mb MODE_INFO list
+    mbd->mode_info_context = cm->mi;          // Point at base of Mb MODE_INFO list
+
+    // Note the baseline filter values for each segment
+    if (alt_flt_enabled)
+    {
+        for (i = 0; i < MAX_MB_SEGMENTS; i++)
+        {
+            // Abs value
+            if (mbd->mb_segement_abs_delta == SEGMENT_ABSDATA)
+                baseline_filter_level[i] = mbd->segment_feature_data[MB_LVL_ALT_LF][i];
+            // Delta Value
+            else
+            {
+                baseline_filter_level[i] = default_filt_lvl + mbd->segment_feature_data[MB_LVL_ALT_LF][i];
+                baseline_filter_level[i] = (baseline_filter_level[i] >= 0) ? ((baseline_filter_level[i] <= MAX_LOOP_FILTER) ? baseline_filter_level[i] : MAX_LOOP_FILTER) : 0;  // Clamp to valid range
+            }
+        }
+    }
+    else
+    {
+        for (i = 0; i < MAX_MB_SEGMENTS; i++)
+            baseline_filter_level[i] = default_filt_lvl;
+    }
+
+    // Initialize the loop filter for this frame.
+    if ((cm->last_filter_type != cm->filter_type) || (cm->last_sharpness_level != cm->sharpness_level))
+        vp8_init_loop_filter(cm);
+    else if (frame_type != cm->last_frame_type)
+        vp8_frame_init_loop_filter(lfi, frame_type);
+
+    // Set up the buffer pointers
+    y_ptr = post->y_buffer;
+
+    // vp8_filter each macro block
+    for (mb_row = 0; mb_row < cm->mb_rows; mb_row++)
+    {
+        for (mb_col = 0; mb_col < cm->mb_cols; mb_col++)
+        {
+            int Segment = (alt_flt_enabled) ? mbd->mode_info_context->mbmi.segment_id : 0;
+            filter_level = baseline_filter_level[Segment];
+
+            // Apply any context driven MB level adjustment
+            vp8_adjust_mb_lf_value(mbd, &filter_level);
+
+            if (filter_level)
+            {
+                if (mb_col > 0)
+                    cm->lf_mbv(y_ptr, 0, 0, post->y_stride, 0, &lfi[filter_level], 0);
+
+                if (mbd->mode_info_context->mbmi.dc_diff > 0)
+                    cm->lf_bv(y_ptr, 0, 0, post->y_stride, 0, &lfi[filter_level], 0);
+
+                // don't apply across umv border
+                if (mb_row > 0)
+                    cm->lf_mbh(y_ptr, 0, 0, post->y_stride, 0, &lfi[filter_level], 0);
+
+                if (mbd->mode_info_context->mbmi.dc_diff > 0)
+                    cm->lf_bh(y_ptr, 0, 0, post->y_stride, 0, &lfi[filter_level], 0);
+            }
+
+            y_ptr += 16;
+            mbd->mode_info_context ++;        // step to next MB
+
+        }
+
+        y_ptr += post->y_stride  * 16 - post->y_width;
+        mbd->mode_info_context ++;            // Skip border mb
+    }
+
+}
+
+
+void vp8_loop_filter_partial_frame
+(
+    VP8_COMMON *cm,
+    MACROBLOCKD *mbd,
+    int default_filt_lvl,
+    int sharpness_lvl,
+    int Fraction
+)
+{
+    YV12_BUFFER_CONFIG *post = cm->frame_to_show;
+
+    int i;
+    unsigned char *y_ptr;
+    int mb_row;
+    int mb_col;
+    //int mb_rows = post->y_height >> 4;
+    int mb_cols = post->y_width  >> 4;
+
+    int linestocopy;
+
+    loop_filter_info *lfi = cm->lf_info;
+    int baseline_filter_level[MAX_MB_SEGMENTS];
+    int filter_level;
+    int alt_flt_enabled = mbd->segmentation_enabled;
+    int frame_type = cm->frame_type;
+
+    (void) sharpness_lvl;
+
+    //MODE_INFO * this_mb_mode_info = cm->mi + (post->y_height>>5) * (mb_cols + 1);  // Point at base of Mb MODE_INFO list
+    mbd->mode_info_context = cm->mi + (post->y_height >> 5) * (mb_cols + 1);        // Point at base of Mb MODE_INFO list
+
+    linestocopy = (post->y_height >> (4 + Fraction));
+
+    if (linestocopy < 1)
+        linestocopy = 1;
+
+    linestocopy <<= 4;
+
+    // Note the baseline filter values for each segment
+    if (alt_flt_enabled)
+    {
+        for (i = 0; i < MAX_MB_SEGMENTS; i++)
+        {
+            // Abs value
+            if (mbd->mb_segement_abs_delta == SEGMENT_ABSDATA)
+                baseline_filter_level[i] = mbd->segment_feature_data[MB_LVL_ALT_LF][i];
+            // Delta Value
+            else
+            {
+                baseline_filter_level[i] = default_filt_lvl + mbd->segment_feature_data[MB_LVL_ALT_LF][i];
+                baseline_filter_level[i] = (baseline_filter_level[i] >= 0) ? ((baseline_filter_level[i] <= MAX_LOOP_FILTER) ? baseline_filter_level[i] : MAX_LOOP_FILTER) : 0;  // Clamp to valid range
+            }
+        }
+    }
+    else
+    {
+        for (i = 0; i < MAX_MB_SEGMENTS; i++)
+            baseline_filter_level[i] = default_filt_lvl;
+    }
+
+    // Initialize the loop filter for this frame.
+    if ((cm->last_filter_type != cm->filter_type) || (cm->last_sharpness_level != cm->sharpness_level))
+        vp8_init_loop_filter(cm);
+    else if (frame_type != cm->last_frame_type)
+        vp8_frame_init_loop_filter(lfi, frame_type);
+
+    // Set up the buffer pointers
+    y_ptr = post->y_buffer + (post->y_height >> 5) * 16 * post->y_stride;
+
+    // vp8_filter each macro block
+    for (mb_row = 0; mb_row<(linestocopy >> 4); mb_row++)
+    {
+        for (mb_col = 0; mb_col < mb_cols; mb_col++)
+        {
+            int Segment = (alt_flt_enabled) ? mbd->mode_info_context->mbmi.segment_id : 0;
+            filter_level = baseline_filter_level[Segment];
+
+            if (filter_level)
+            {
+                if (mb_col > 0)
+                    cm->lf_mbv(y_ptr, 0, 0, post->y_stride, 0, &lfi[filter_level], 0);
+
+                if (mbd->mode_info_context->mbmi.dc_diff > 0)
+                    cm->lf_bv(y_ptr, 0, 0, post->y_stride, 0, &lfi[filter_level], 0);
+
+                cm->lf_mbh(y_ptr, 0, 0, post->y_stride, 0, &lfi[filter_level], 0);
+
+                if (mbd->mode_info_context->mbmi.dc_diff > 0)
+                    cm->lf_bh(y_ptr, 0, 0, post->y_stride, 0, &lfi[filter_level], 0);
+            }
+
+            y_ptr += 16;
+            mbd->mode_info_context += 1;      // step to next MB
+        }
+
+        y_ptr += post->y_stride  * 16 - post->y_width;
+        mbd->mode_info_context += 1;          // Skip border mb
+    }
+}
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/loopfilter.h
@@ -0,0 +1,121 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef loopfilter_h
+#define loopfilter_h
+
+#include "vpx_ports/mem.h"
+
+#define MAX_LOOP_FILTER 63
+
+typedef enum
+{
+    NORMAL_LOOPFILTER = 0,
+    SIMPLE_LOOPFILTER = 1
+} LOOPFILTERTYPE;
+
+// FRK
+// Need to align this structure so when it is declared and
+// passed it can be loaded into vector registers.
+// FRK
+typedef struct
+{
+    DECLARE_ALIGNED(16, signed char, lim[16]);
+    DECLARE_ALIGNED(16, signed char, flim[16]);
+    DECLARE_ALIGNED(16, signed char, thr[16]);
+    DECLARE_ALIGNED(16, signed char, mbflim[16]);
+    DECLARE_ALIGNED(16, signed char, mbthr[16]);
+    DECLARE_ALIGNED(16, signed char, uvlim[16]);
+    DECLARE_ALIGNED(16, signed char, uvflim[16]);
+    DECLARE_ALIGNED(16, signed char, uvthr[16]);
+    DECLARE_ALIGNED(16, signed char, uvmbflim[16]);
+    DECLARE_ALIGNED(16, signed char, uvmbthr[16]);
+} loop_filter_info;
+
+
+#define prototype_loopfilter(sym) \
+    void sym(unsigned char *src, int pitch, const signed char *flimit,\
+             const signed char *limit, const signed char *thresh, int count)
+
+#define prototype_loopfilter_block(sym) \
+    void sym(unsigned char *y, unsigned char *u, unsigned char *v,\
+             int ystride, int uv_stride, loop_filter_info *lfi, int simpler)
+
+#if ARCH_X86 || ARCH_X86_64
+#include "x86/loopfilter_x86.h"
+#endif
+
+#if ARCH_ARM
+#include "arm/loopfilter_arm.h"
+#endif
+
+#ifndef vp8_lf_normal_mb_v
+#define vp8_lf_normal_mb_v vp8_loop_filter_mbv_c
+#endif
+extern prototype_loopfilter_block(vp8_lf_normal_mb_v);
+
+#ifndef vp8_lf_normal_b_v
+#define vp8_lf_normal_b_v vp8_loop_filter_bv_c
+#endif
+extern prototype_loopfilter_block(vp8_lf_normal_b_v);
+
+#ifndef vp8_lf_normal_mb_h
+#define vp8_lf_normal_mb_h vp8_loop_filter_mbh_c
+#endif
+extern prototype_loopfilter_block(vp8_lf_normal_mb_h);
+
+#ifndef vp8_lf_normal_b_h
+#define vp8_lf_normal_b_h vp8_loop_filter_bh_c
+#endif
+extern prototype_loopfilter_block(vp8_lf_normal_b_h);
+
+
+#ifndef vp8_lf_simple_mb_v
+#define vp8_lf_simple_mb_v vp8_loop_filter_mbvs_c
+#endif
+extern prototype_loopfilter_block(vp8_lf_simple_mb_v);
+
+#ifndef vp8_lf_simple_b_v
+#define vp8_lf_simple_b_v vp8_loop_filter_bvs_c
+#endif
+extern prototype_loopfilter_block(vp8_lf_simple_b_v);
+
+#ifndef vp8_lf_simple_mb_h
+#define vp8_lf_simple_mb_h vp8_loop_filter_mbhs_c
+#endif
+extern prototype_loopfilter_block(vp8_lf_simple_mb_h);
+
+#ifndef vp8_lf_simple_b_h
+#define vp8_lf_simple_b_h vp8_loop_filter_bhs_c
+#endif
+extern prototype_loopfilter_block(vp8_lf_simple_b_h);
+
+typedef prototype_loopfilter_block((*vp8_lf_block_fn_t));
+typedef struct
+{
+    vp8_lf_block_fn_t  normal_mb_v;
+    vp8_lf_block_fn_t  normal_b_v;
+    vp8_lf_block_fn_t  normal_mb_h;
+    vp8_lf_block_fn_t  normal_b_h;
+    vp8_lf_block_fn_t  simple_mb_v;
+    vp8_lf_block_fn_t  simple_b_v;
+    vp8_lf_block_fn_t  simple_mb_h;
+    vp8_lf_block_fn_t  simple_b_h;
+} vp8_loopfilter_rtcd_vtable_t;
+
+#if CONFIG_RUNTIME_CPU_DETECT
+#define LF_INVOKE(ctx,fn) (ctx)->fn
+#else
+#define LF_INVOKE(ctx,fn) vp8_lf_##fn
+#endif
+
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/loopfilter_filters.c
@@ -0,0 +1,369 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include <stdlib.h>
+#include "loopfilter.h"
+#include "onyxc_int.h"
+
+
+#define NEW_LOOPFILTER_MASK
+
+typedef unsigned char uc;
+
+__inline signed char vp8_signed_char_clamp(int t)
+{
+    t = (t < -128 ? -128 : t);
+    t = (t > 127 ? 127 : t);
+    return (signed char) t;
+}
+
+
+// should we apply any filter at all ( 11111111 yes, 00000000 no)
+__inline signed char vp8_filter_mask(signed char limit, signed char flimit,
+                                     uc p3, uc p2, uc p1, uc p0, uc q0, uc q1, uc q2, uc q3)
+{
+    signed char mask = 0;
+    mask |= (abs(p3 - p2) > limit) * -1;
+    mask |= (abs(p2 - p1) > limit) * -1;
+    mask |= (abs(p1 - p0) > limit) * -1;
+    mask |= (abs(q1 - q0) > limit) * -1;
+    mask |= (abs(q2 - q1) > limit) * -1;
+    mask |= (abs(q3 - q2) > limit) * -1;
+#ifndef NEW_LOOPFILTER_MASK
+    mask |= (abs(p0 - q0) > flimit) * -1;
+#else
+    mask |= (abs(p0 - q0) * 2 + abs(p1 - q1) / 2  > flimit * 2 + limit) * -1;
+#endif
+    mask = ~mask;
+    return mask;
+}
+
+// is there high variance internal edge ( 11111111 yes, 00000000 no)
+__inline signed char vp8_hevmask(signed char thresh, uc p1, uc p0, uc q0, uc q1)
+{
+    signed char hev = 0;
+    hev  |= (abs(p1 - p0) > thresh) * -1;
+    hev  |= (abs(q1 - q0) > thresh) * -1;
+    return hev;
+}
+
+__inline void vp8_filter(signed char mask, signed char hev, uc *op1, uc *op0, uc *oq0, uc *oq1)
+
+{
+    signed char ps0, qs0;
+    signed char ps1, qs1;
+    signed char vp8_filter, Filter1, Filter2;
+    signed char u;
+
+    ps1 = (signed char) * op1 ^ 0x80;
+    ps0 = (signed char) * op0 ^ 0x80;
+    qs0 = (signed char) * oq0 ^ 0x80;
+    qs1 = (signed char) * oq1 ^ 0x80;
+
+    // add outer taps if we have high edge variance
+    vp8_filter = vp8_signed_char_clamp(ps1 - qs1);
+    vp8_filter &= hev;
+
+    // inner taps
+    vp8_filter = vp8_signed_char_clamp(vp8_filter + 3 * (qs0 - ps0));
+    vp8_filter &= mask;
+
+    // save bottom 3 bits so that we round one side +4 and the other +3
+    // if it equals 4 we'll set to adjust by -1 to account for the fact
+    // we'd round 3 the other way
+    Filter1 = vp8_signed_char_clamp(vp8_filter + 4);
+    Filter2 = vp8_signed_char_clamp(vp8_filter + 3);
+    Filter1 >>= 3;
+    Filter2 >>= 3;
+    u = vp8_signed_char_clamp(qs0 - Filter1);
+    *oq0 = u ^ 0x80;
+    u = vp8_signed_char_clamp(ps0 + Filter2);
+    *op0 = u ^ 0x80;
+    vp8_filter = Filter1;
+
+    // outer tap adjustments
+    vp8_filter += 1;
+    vp8_filter >>= 1;
+    vp8_filter &= ~hev;
+
+    u = vp8_signed_char_clamp(qs1 - vp8_filter);
+    *oq1 = u ^ 0x80;
+    u = vp8_signed_char_clamp(ps1 + vp8_filter);
+    *op1 = u ^ 0x80;
+
+}
+void vp8_loop_filter_horizontal_edge_c
+(
+    unsigned char *s,
+    int p, //pitch
+    const signed char *flimit,
+    const signed char *limit,
+    const signed char *thresh,
+    int count
+)
+{
+    int  hev = 0; // high edge variance
+    signed char mask = 0;
+    int i = 0;
+
+    // loop filter designed to work using chars so that we can make maximum use
+    // of 8 bit simd instructions.
+    do
+    {
+        mask = vp8_filter_mask(limit[i], flimit[i],
+                               s[-4*p], s[-3*p], s[-2*p], s[-1*p],
+                               s[0*p], s[1*p], s[2*p], s[3*p]);
+
+        hev = vp8_hevmask(thresh[i], s[-2*p], s[-1*p], s[0*p], s[1*p]);
+
+        vp8_filter(mask, hev, s - 2 * p, s - 1 * p, s, s + 1 * p);
+
+        ++s;
+    }
+    while (++i < count * 8);
+}
+
+void vp8_loop_filter_vertical_edge_c
+(
+    unsigned char *s,
+    int p,
+    const signed char *flimit,
+    const signed char *limit,
+    const signed char *thresh,
+    int count
+)
+{
+    int  hev = 0; // high edge variance
+    signed char mask = 0;
+    int i = 0;
+
+    // loop filter designed to work using chars so that we can make maximum use
+    // of 8 bit simd instructions.
+    do
+    {
+        mask = vp8_filter_mask(limit[i], flimit[i],
+                               s[-4], s[-3], s[-2], s[-1], s[0], s[1], s[2], s[3]);
+
+        hev = vp8_hevmask(thresh[i], s[-2], s[-1], s[0], s[1]);
+
+        vp8_filter(mask, hev, s - 2, s - 1, s, s + 1);
+
+        s += p;
+    }
+    while (++i < count * 8);
+}
+
+__inline void vp8_mbfilter(signed char mask, signed char hev,
+                           uc *op2, uc *op1, uc *op0, uc *oq0, uc *oq1, uc *oq2)
+{
+    signed char s, u;
+    signed char vp8_filter, Filter1, Filter2;
+    signed char ps2 = (signed char) * op2 ^ 0x80;
+    signed char ps1 = (signed char) * op1 ^ 0x80;
+    signed char ps0 = (signed char) * op0 ^ 0x80;
+    signed char qs0 = (signed char) * oq0 ^ 0x80;
+    signed char qs1 = (signed char) * oq1 ^ 0x80;
+    signed char qs2 = (signed char) * oq2 ^ 0x80;
+
+    // add outer taps if we have high edge variance
+    vp8_filter = vp8_signed_char_clamp(ps1 - qs1);
+    vp8_filter = vp8_signed_char_clamp(vp8_filter + 3 * (qs0 - ps0));
+    vp8_filter &= mask;
+
+    Filter2 = vp8_filter;
+    Filter2 &= hev;
+
+    // save bottom 3 bits so that we round one side +4 and the other +3
+    Filter1 = vp8_signed_char_clamp(Filter2 + 4);
+    Filter2 = vp8_signed_char_clamp(Filter2 + 3);
+    Filter1 >>= 3;
+    Filter2 >>= 3;
+    qs0 = vp8_signed_char_clamp(qs0 - Filter1);
+    ps0 = vp8_signed_char_clamp(ps0 + Filter2);
+
+
+    // only apply wider filter if not high edge variance
+    vp8_filter &= ~hev;
+    Filter2 = vp8_filter;
+
+    // roughly 3/7th difference across boundary
+    u = vp8_signed_char_clamp((63 + Filter2 * 27) >> 7);
+    s = vp8_signed_char_clamp(qs0 - u);
+    *oq0 = s ^ 0x80;
+    s = vp8_signed_char_clamp(ps0 + u);
+    *op0 = s ^ 0x80;
+
+    // roughly 2/7th difference across boundary
+    u = vp8_signed_char_clamp((63 + Filter2 * 18) >> 7);
+    s = vp8_signed_char_clamp(qs1 - u);
+    *oq1 = s ^ 0x80;
+    s = vp8_signed_char_clamp(ps1 + u);
+    *op1 = s ^ 0x80;
+
+    // roughly 1/7th difference across boundary
+    u = vp8_signed_char_clamp((63 + Filter2 * 9) >> 7);
+    s = vp8_signed_char_clamp(qs2 - u);
+    *oq2 = s ^ 0x80;
+    s = vp8_signed_char_clamp(ps2 + u);
+    *op2 = s ^ 0x80;
+}
+
+void vp8_mbloop_filter_horizontal_edge_c
+(
+    unsigned char *s,
+    int p,
+    const signed char *flimit,
+    const signed char *limit,
+    const signed char *thresh,
+    int count
+)
+{
+    signed char hev = 0; // high edge variance
+    signed char mask = 0;
+    int i = 0;
+
+    // loop filter designed to work using chars so that we can make maximum use
+    // of 8 bit simd instructions.
+    do
+    {
+
+        mask = vp8_filter_mask(limit[i], flimit[i],
+                               s[-4*p], s[-3*p], s[-2*p], s[-1*p],
+                               s[0*p], s[1*p], s[2*p], s[3*p]);
+
+        hev = vp8_hevmask(thresh[i], s[-2*p], s[-1*p], s[0*p], s[1*p]);
+
+        vp8_mbfilter(mask, hev, s - 3 * p, s - 2 * p, s - 1 * p, s, s + 1 * p, s + 2 * p);
+
+        ++s;
+    }
+    while (++i < count * 8);
+
+}
+
+
+void vp8_mbloop_filter_vertical_edge_c
+(
+    unsigned char *s,
+    int p,
+    const signed char *flimit,
+    const signed char *limit,
+    const signed char *thresh,
+    int count
+)
+{
+    signed char hev = 0; // high edge variance
+    signed char mask = 0;
+    int i = 0;
+
+    do
+    {
+
+        mask = vp8_filter_mask(limit[i], flimit[i],
+                               s[-4], s[-3], s[-2], s[-1], s[0], s[1], s[2], s[3]);
+
+        hev = vp8_hevmask(thresh[i], s[-2], s[-1], s[0], s[1]);
+
+        vp8_mbfilter(mask, hev, s - 3, s - 2, s - 1, s, s + 1, s + 2);
+
+        s += p;
+    }
+    while (++i < count * 8);
+
+}
+
+// should we apply any filter at all ( 11111111 yes, 00000000 no)
+__inline signed char vp8_simple_filter_mask(signed char limit, signed char flimit, uc p1, uc p0, uc q0, uc q1)
+{
+// Why does this cause problems for win32?
+// error C2143: syntax error : missing ';' before 'type'
+//  (void) limit;
+#ifndef NEW_LOOPFILTER_MASK
+    signed char mask = (abs(p0 - q0) <= flimit) * -1;
+#else
+    signed char mask = (abs(p0 - q0) * 2 + abs(p1 - q1) / 2  <= flimit * 2 + limit) * -1;
+#endif
+    return mask;
+}
+
+__inline void vp8_simple_filter(signed char mask, uc *op1, uc *op0, uc *oq0, uc *oq1)
+{
+    signed char vp8_filter, Filter1, Filter2;
+    signed char p1 = (signed char) * op1 ^ 0x80;
+    signed char p0 = (signed char) * op0 ^ 0x80;
+    signed char q0 = (signed char) * oq0 ^ 0x80;
+    signed char q1 = (signed char) * oq1 ^ 0x80;
+    signed char u;
+
+    vp8_filter = vp8_signed_char_clamp(p1 - q1);
+    vp8_filter = vp8_signed_char_clamp(vp8_filter + 3 * (q0 - p0));
+    vp8_filter &= mask;
+
+    // save bottom 3 bits so that we round one side +4 and the other +3
+    Filter1 = vp8_signed_char_clamp(vp8_filter + 4);
+    Filter1 >>= 3;
+    u = vp8_signed_char_clamp(q0 - Filter1);
+    *oq0  = u ^ 0x80;
+
+    Filter2 = vp8_signed_char_clamp(vp8_filter + 3);
+    Filter2 >>= 3;
+    u = vp8_signed_char_clamp(p0 + Filter2);
+    *op0 = u ^ 0x80;
+}
+
+void vp8_loop_filter_simple_horizontal_edge_c
+(
+    unsigned char *s,
+    int p,
+    const signed char *flimit,
+    const signed char *limit,
+    const signed char *thresh,
+    int count
+)
+{
+    signed char mask = 0;
+    int i = 0;
+    (void) thresh;
+
+    do
+    {
+        //mask = vp8_simple_filter_mask( limit[i], flimit[i],s[-1*p],s[0*p]);
+        mask = vp8_simple_filter_mask(limit[i], flimit[i], s[-2*p], s[-1*p], s[0*p], s[1*p]);
+        vp8_simple_filter(mask, s - 2 * p, s - 1 * p, s, s + 1 * p);
+        ++s;
+    }
+    while (++i < count * 8);
+}
+
+void vp8_loop_filter_simple_vertical_edge_c
+(
+    unsigned char *s,
+    int p,
+    const signed char *flimit,
+    const signed char *limit,
+    const signed char *thresh,
+    int count
+)
+{
+    signed char mask = 0;
+    int i = 0;
+    (void) thresh;
+
+    do
+    {
+        //mask = vp8_simple_filter_mask( limit[i], flimit[i],s[-1],s[0]);
+        mask = vp8_simple_filter_mask(limit[i], flimit[i], s[-2], s[-1], s[0], s[1]);
+        vp8_simple_filter(mask, s - 2, s - 1, s, s + 1);
+        s += p;
+    }
+    while (++i < count * 8);
+
+}
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/mbpitch.c
@@ -0,0 +1,129 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include "blockd.h"
+
+typedef enum
+{
+    PRED = 0,
+    DEST = 1,
+} BLOCKSET;
+
+void vp8_setup_block
+(
+    BLOCKD *b,
+    int mv_stride,
+    unsigned char **base,
+    int Stride,
+    int offset,
+    BLOCKSET bs
+)
+{
+
+    if (bs == DEST)
+    {
+        b->dst_stride = Stride;
+        b->dst = offset;
+        b->base_dst = base;
+    }
+    else
+    {
+        b->pre_stride = Stride;
+        b->pre = offset;
+        b->base_pre = base;
+    }
+
+}
+
+void vp8_setup_macroblock(MACROBLOCKD *x, BLOCKSET bs)
+{
+    int block;
+
+    unsigned char **y, **u, **v;
+
+    if (bs == DEST)
+    {
+        y = &x->dst.y_buffer;
+        u = &x->dst.u_buffer;
+        v = &x->dst.v_buffer;
+    }
+    else
+    {
+        y = &x->pre.y_buffer;
+        u = &x->pre.u_buffer;
+        v = &x->pre.v_buffer;
+    }
+
+    for (block = 0; block < 16; block++) // y blocks
+    {
+        vp8_setup_block(&x->block[block], x->dst.y_stride, y, x->dst.y_stride,
+                        (block >> 2) * 4 * x->dst.y_stride + (block & 3) * 4, bs);
+    }
+
+    for (block = 16; block < 20; block++) // U and V blocks
+    {
+        vp8_setup_block(&x->block[block], x->dst.uv_stride, u, x->dst.uv_stride,
+                        ((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs);
+
+        vp8_setup_block(&x->block[block+4], x->dst.uv_stride, v, x->dst.uv_stride,
+                        ((block - 16) >> 1) * 4 * x->dst.uv_stride + (block & 1) * 4, bs);
+    }
+}
+
+void vp8_setup_block_dptrs(MACROBLOCKD *x)
+{
+    int r, c;
+
+    for (r = 0; r < 4; r++)
+    {
+        for (c = 0; c < 4; c++)
+        {
+            x->block[r*4+c].diff      = &x->diff[r * 4 * 16 + c * 4];
+            x->block[r*4+c].predictor = x->predictor + r * 4 * 16 + c * 4;
+        }
+    }
+
+    for (r = 0; r < 2; r++)
+    {
+        for (c = 0; c < 2; c++)
+        {
+            x->block[16+r*2+c].diff      = &x->diff[256 + r * 4 * 8 + c * 4];
+            x->block[16+r*2+c].predictor = x->predictor + 256 + r * 4 * 8 + c * 4;
+
+        }
+    }
+
+    for (r = 0; r < 2; r++)
+    {
+        for (c = 0; c < 2; c++)
+        {
+            x->block[20+r*2+c].diff      = &x->diff[320+ r * 4 * 8 + c * 4];
+            x->block[20+r*2+c].predictor = x->predictor + 320 + r * 4 * 8 + c * 4;
+
+        }
+    }
+
+    x->block[24].diff = &x->diff[384];
+
+    for (r = 0; r < 25; r++)
+    {
+        x->block[r].qcoeff  = x->qcoeff  + r * 16;
+        x->block[r].dqcoeff = x->dqcoeff + r * 16;
+    }
+}
+
+void vp8_build_block_doffsets(MACROBLOCKD *x)
+{
+
+    // handle the destination pitch features
+    vp8_setup_macroblock(x, DEST);
+    vp8_setup_macroblock(x, PRED);
+}
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/modecont.c
@@ -0,0 +1,40 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include "entropy.h"
+
+const int vp8_mode_contexts[6][4] =
+{
+    {
+        // 0
+        7,     1,     1,   143,
+    },
+    {
+        // 1
+        14,    18,    14,   107,
+    },
+    {
+        // 2
+        135,    64,    57,    68,
+    },
+    {
+        // 3
+        60,    56,   128,    65,
+    },
+    {
+        // 4
+        159,   134,   128,    34,
+    },
+    {
+        // 5
+        234,   188,   128,    28,
+    },
+};
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/modecont.h
@@ -0,0 +1,17 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __INC_MODECONT_H
+#define __INC_MODECONT_H
+
+extern const int vp8_mode_contexts[6][4];
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/modecontext.c
@@ -0,0 +1,146 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include "entropymode.h"
+
+const unsigned int vp8_kf_default_bmode_counts [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES] =
+{
+    {
+        //Above Mode :  0
+        { 43438,   2195,    470,    316,    615,    171,    217,    412,    124,    160, }, // left_mode 0
+        {  5722,   2751,    296,    291,     81,     68,     80,    101,    100,    170, }, // left_mode 1
+        {  1629,    201,    307,     25,     47,     16,     34,     72,     19,     28, }, // left_mode 2
+        {   332,    266,     36,    500,     20,     65,     23,     14,    154,    106, }, // left_mode 3
+        {   450,     97,     10,     24,    117,     10,      2,     12,      8,     71, }, // left_mode 4
+        {   384,     49,     29,     44,     12,    162,     51,      5,     87,     42, }, // left_mode 5
+        {   495,     53,    157,     27,     14,     57,    180,     17,     17,     34, }, // left_mode 6
+        {   695,     64,     62,      9,     27,      5,      3,    147,     10,     26, }, // left_mode 7
+        {   230,     54,     20,    124,     16,    125,     29,     12,    283,     37, }, // left_mode 8
+        {   260,     87,     21,    120,     32,     16,     33,     16,     33,    203, }, // left_mode 9
+    },
+    {
+        //Above Mode :  1
+        {  3934,   2573,    355,    137,    128,     87,    133,    117,     37,     27, }, // left_mode 0
+        {  1036,   1929,    278,    135,     27,     37,     48,     55,     41,     91, }, // left_mode 1
+        {   223,    256,    253,     15,     13,      9,     28,     64,      3,      3, }, // left_mode 2
+        {   120,    129,     17,    316,     15,     11,      9,      4,     53,     74, }, // left_mode 3
+        {   129,     58,      6,     11,     38,      2,      0,      5,      2,     67, }, // left_mode 4
+        {    53,     22,     11,     16,      8,     26,     14,      3,     19,     12, }, // left_mode 5
+        {    59,     26,     61,     11,      4,      9,     35,     13,      8,      8, }, // left_mode 6
+        {   101,     52,     40,      8,      5,      2,      8,     59,      2,     20, }, // left_mode 7
+        {    48,     34,     10,     52,      8,     15,      6,      6,     63,     20, }, // left_mode 8
+        {    96,     48,     22,     63,     11,     14,      5,      8,      9,     96, }, // left_mode 9
+    },
+    {
+        //Above Mode :  2
+        {   709,    461,    506,     36,     27,     33,    151,     98,     24,      6, }, // left_mode 0
+        {   201,    375,    442,     27,     13,      8,     46,     58,      6,     19, }, // left_mode 1
+        {   122,    140,    417,      4,     13,      3,     33,     59,      4,      2, }, // left_mode 2
+        {    36,     17,     22,     16,      6,      8,     12,     17,      9,     21, }, // left_mode 3
+        {    51,     15,      7,      1,     14,      0,      4,      5,      3,     22, }, // left_mode 4
+        {    18,     11,     30,      9,      7,     20,     11,      5,      2,      6, }, // left_mode 5
+        {    38,     21,    103,      9,      4,     12,     79,     13,      2,      5, }, // left_mode 6
+        {    64,     17,     66,      2,     12,      4,      2,     65,      4,      5, }, // left_mode 7
+        {    14,      7,      7,     16,      3,     11,      4,     13,     15,     16, }, // left_mode 8
+        {    36,      8,     32,      9,      9,      4,     14,      7,      6,     24, }, // left_mode 9
+    },
+    {
+        //Above Mode :  3
+        {  1340,    173,     36,    119,     30,     10,     13,     10,     20,     26, }, // left_mode 0
+        {   156,    293,     26,    108,      5,     16,      2,      4,     23,     30, }, // left_mode 1
+        {    60,     34,     13,      7,      3,      3,      0,      8,      4,      5, }, // left_mode 2
+        {    72,     64,      1,    235,      3,      9,      2,      7,     28,     38, }, // left_mode 3
+        {    29,     14,      1,      3,      5,      0,      2,      2,      5,     13, }, // left_mode 4
+        {    22,      7,      4,     11,      2,      5,      1,      2,      6,      4, }, // left_mode 5
+        {    18,     14,      5,      6,      4,      3,     14,      0,      9,      2, }, // left_mode 6
+        {    41,     10,      7,      1,      2,      0,      0,     10,      2,      1, }, // left_mode 7
+        {    23,     19,      2,     33,      1,      5,      2,      0,     51,      8, }, // left_mode 8
+        {    33,     26,      7,     53,      3,      9,      3,      3,      9,     19, }, // left_mode 9
+    },
+    {
+        //Above Mode :  4
+        {   410,    165,     43,     31,     66,     15,     30,     54,      8,     17, }, // left_mode 0
+        {   115,     64,     27,     18,     30,      7,     11,     15,      4,     19, }, // left_mode 1
+        {    31,     23,     25,      1,      7,      2,      2,     10,      0,      5, }, // left_mode 2
+        {    17,      4,      1,      6,      8,      2,      7,      5,      5,     21, }, // left_mode 3
+        {   120,     12,      1,      2,     83,      3,      0,      4,      1,     40, }, // left_mode 4
+        {     4,      3,      1,      2,      1,      2,      5,      0,      3,      6, }, // left_mode 5
+        {    10,      2,     13,      6,      6,      6,      8,      2,      4,      5, }, // left_mode 6
+        {    58,     10,      5,      1,     28,      1,      1,     33,      1,      9, }, // left_mode 7
+        {     8,      2,      1,      4,      2,      5,      1,      1,      2,     10, }, // left_mode 8
+        {    76,      7,      5,      7,     18,      2,      2,      0,      5,     45, }, // left_mode 9
+    },
+    {
+        //Above Mode :  5
+        {   444,     46,     47,     20,     14,    110,     60,     14,     60,      7, }, // left_mode 0
+        {    59,     57,     25,     18,      3,     17,     21,      6,     14,      6, }, // left_mode 1
+        {    24,     17,     20,      6,      4,     13,      7,      2,      3,      2, }, // left_mode 2
+        {    13,     11,      5,     14,      4,      9,      2,      4,     15,      7, }, // left_mode 3
+        {     8,      5,      2,      1,      4,      0,      1,      1,      2,     12, }, // left_mode 4
+        {    19,      5,      5,      7,      4,     40,      6,      3,     10,      4, }, // left_mode 5
+        {    16,      5,      9,      1,      1,     16,     26,      2,     10,      4, }, // left_mode 6
+        {    11,      4,      8,      1,      1,      4,      4,      5,      4,      1, }, // left_mode 7
+        {    15,      1,      3,      7,      3,     21,      7,      1,     34,      5, }, // left_mode 8
+        {    18,      5,      1,      3,      4,      3,      7,      1,      2,      9, }, // left_mode 9
+    },
+    {
+        //Above Mode :  6
+        {   476,    149,     94,     13,     14,     77,    291,     27,     23,      3, }, // left_mode 0
+        {    79,     83,     42,     14,      2,     12,     63,      2,      4,     14, }, // left_mode 1
+        {    43,     36,     55,      1,      3,      8,     42,     11,      5,      1, }, // left_mode 2
+        {     9,      9,      6,     16,      1,      5,      6,      3,     11,     10, }, // left_mode 3
+        {    10,      3,      1,      3,     10,      1,      0,      1,      1,      4, }, // left_mode 4
+        {    14,      6,     15,      5,      1,     20,     25,      2,      5,      0, }, // left_mode 5
+        {    28,      7,     51,      1,      0,      8,    127,      6,      2,      5, }, // left_mode 6
+        {    13,      3,      3,      2,      3,      1,      2,      8,      1,      2, }, // left_mode 7
+        {    10,      3,      3,      3,      3,      8,      2,      2,      9,      3, }, // left_mode 8
+        {    13,      7,     11,      4,      0,      4,      6,      2,      5,      8, }, // left_mode 9
+    },
+    {
+        //Above Mode :  7
+        {   376,    135,    119,      6,     32,      8,     31,    224,      9,      3, }, // left_mode 0
+        {    93,     60,     54,      6,     13,      7,      8,     92,      2,     12, }, // left_mode 1
+        {    74,     36,     84,      0,      3,      2,      9,     67,      2,      1, }, // left_mode 2
+        {    19,      4,      4,      8,      8,      2,      4,      7,      6,     16, }, // left_mode 3
+        {    51,      7,      4,      1,     77,      3,      0,     14,      1,     15, }, // left_mode 4
+        {     7,      7,      5,      7,      4,      7,      4,      5,      0,      3, }, // left_mode 5
+        {    18,      2,     19,      2,      2,      4,     12,     11,      1,      2, }, // left_mode 6
+        {   129,      6,     27,      1,     21,      3,      0,    189,      0,      6, }, // left_mode 7
+        {     9,      1,      2,      8,      3,      7,      0,      5,      3,      3, }, // left_mode 8
+        {    20,      4,      5,     10,      4,      2,      7,     17,      3,     16, }, // left_mode 9
+    },
+    {
+        //Above Mode :  8
+        {   617,     68,     34,     79,     11,     27,     25,     14,     75,     13, }, // left_mode 0
+        {    51,     82,     21,     26,      6,     12,     13,      1,     26,     16, }, // left_mode 1
+        {    29,      9,     12,     11,      3,      7,      1,     10,      2,      2, }, // left_mode 2
+        {    17,     19,     11,     74,      4,      3,      2,      0,     58,     13, }, // left_mode 3
+        {    10,      1,      1,      3,      4,      1,      0,      2,      1,      8, }, // left_mode 4
+        {    14,      4,      5,      5,      1,     13,      2,      0,     27,      8, }, // left_mode 5
+        {    10,      3,      5,      4,      1,      7,      6,      4,      5,      1, }, // left_mode 6
+        {    10,      2,      6,      2,      1,      1,      1,      4,      2,      1, }, // left_mode 7
+        {    14,      8,      5,     23,      2,     12,      6,      2,    117,      5, }, // left_mode 8
+        {     9,      6,      2,     19,      1,      6,      3,      2,      9,      9, }, // left_mode 9
+    },
+    {
+        //Above Mode :  9
+        {   680,     73,     22,     38,     42,      5,     11,      9,      6,     28, }, // left_mode 0
+        {   113,    112,     21,     22,     10,      2,      8,      4,      6,     42, }, // left_mode 1
+        {    44,     20,     24,      6,      5,      4,      3,      3,      1,      2, }, // left_mode 2
+        {    40,     23,      7,     71,      5,      2,      4,      1,      7,     22, }, // left_mode 3
+        {    85,      9,      4,      4,     17,      2,      0,      3,      2,     23, }, // left_mode 4
+        {    13,      4,      2,      6,      1,      7,      0,      1,      7,      6, }, // left_mode 5
+        {    26,      6,      8,      3,      2,      3,      8,      1,      5,      4, }, // left_mode 6
+        {    54,      8,      9,      6,      7,      0,      1,     11,      1,      3, }, // left_mode 7
+        {     9,     10,      4,     13,      2,      5,      4,      2,     14,      8, }, // left_mode 8
+        {    92,      9,      5,     19,     15,      3,      3,      1,      6,     58, }, // left_mode 9
+    },
+};
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/mv.h
@@ -0,0 +1,21 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __INC_MV_H
+#define __INC_MV_H
+
+typedef struct
+{
+    short row;
+    short col;
+} MV;
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/onyx.h
@@ -0,0 +1,223 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __INC_VP8_H
+#define __INC_VP8_H
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+#include "vpx/internal/vpx_codec_internal.h"
+#include "vpx_scale/yv12config.h"
+#include "type_aliases.h"
+#include "ppflags.h"
+    typedef int *VP8_PTR;
+
+    /* Create/destroy static data structures. */
+
+    typedef enum
+    {
+        NORMAL      = 0,
+        FOURFIVE    = 1,
+        THREEFIVE   = 2,
+        ONETWO      = 3
+
+    } VPX_SCALING;
+
+    typedef enum
+    {
+        VP8_LAST_FLAG = 1,
+        VP8_GOLD_FLAG = 2,
+        VP8_ALT_FLAG = 4
+    } VP8_REFFRAME;
+
+
+    typedef enum
+    {
+        USAGE_STREAM_FROM_SERVER    = 0x0,
+        USAGE_LOCAL_FILE_PLAYBACK   = 0x1
+    } END_USAGE;
+
+
+    typedef enum
+    {
+        MODE_REALTIME       = 0x0,
+        MODE_GOODQUALITY    = 0x1,
+        MODE_BESTQUALITY    = 0x2,
+        MODE_FIRSTPASS      = 0x3,
+        MODE_SECONDPASS     = 0x4,
+        MODE_SECONDPASS_BEST = 0x5,
+    } MODE;
+
+    typedef enum
+    {
+        FRAMEFLAGS_KEY    = 1,
+        FRAMEFLAGS_GOLDEN = 2,
+        FRAMEFLAGS_ALTREF = 4,
+    } FRAMETYPE_FLAGS;
+
+
+#include <assert.h>
+    static __inline void Scale2Ratio(int mode, int *hr, int *hs)
+    {
+        switch (mode)
+        {
+        case    NORMAL:
+            *hr = 1;
+            *hs = 1;
+            break;
+        case    FOURFIVE:
+            *hr = 4;
+            *hs = 5;
+            break;
+        case    THREEFIVE:
+            *hr = 3;
+            *hs = 5;
+            break;
+        case    ONETWO:
+            *hr = 1;
+            *hs = 2;
+            break;
+        default:
+            *hr = 1;
+            *hs = 1;
+            assert(0);
+            break;
+        }
+    }
+
+    typedef struct
+    {
+        int Version;            // 4 versions of bitstream defined 0 best quality/slowest decode, 3 lowest quality/fastest decode
+        int Width;              // width of data passed to the compressor
+        int Height;             // height of data passed to the compressor
+        double frame_rate;       // set to passed in framerate
+        int target_bandwidth;    // bandwidth to be used in kilobits per second
+
+        int noise_sensitivity;   // parameter used for applying pre processing blur: recommendation 0
+        int Sharpness;          // parameter used for sharpening output: recommendation 0:
+        int cpu_used;
+
+        // mode ->
+        //(0)=Realtime/Live Encoding. This mode is optimized for realtim encoding (for example, capturing
+        //    a television signal or feed from a live camera). ( speed setting controls how fast )
+        //(1)=Good Quality Fast Encoding. The encoder balances quality with the amount of time it takes to
+        //    encode the output. ( speed setting controls how fast )
+        //(2)=One Pass - Best Quality. The encoder places priority on the quality of the output over encoding
+        //    speed. The output is compressed at the highest possible quality. This option takes the longest
+        //    amount of time to encode. ( speed setting ignored )
+        //(3)=Two Pass - First Pass. The encoder generates a file of statistics for use in the second encoding
+        //    pass. ( speed setting controls how fast )
+        //(4)=Two Pass - Second Pass. The encoder uses the statistics that were generated in the first encoding
+        //    pass to create the compressed output. ( speed setting controls how fast )
+        //(5)=Two Pass - Second Pass Best.  The encoder uses the statistics that were generated in the first
+        //    encoding pass to create the compressed output using the highest possible quality, and taking a
+        //    longer amount of time to encode.. ( speed setting ignored )
+        int Mode;               //
+
+        // Key Framing Operations
+        int auto_key;            // automatically detect cut scenes and set the keyframes
+        int key_freq;            // maximum distance to key frame.
+
+        int allow_lag;           // allow lagged compression (if 0 lagin frames is ignored)
+        int lag_in_frames;        // how many frames lag before we start encoding
+
+        //----------------------------------------------------------------
+        // DATARATE CONTROL OPTIONS
+
+        int end_usage; // vbr or cbr
+
+        // shoot to keep buffer full at all times by undershooting a bit 95 recommended
+        int under_shoot_pct;
+
+        // buffering parameters
+        int starting_buffer_level;  // in seconds
+        int optimal_buffer_level;
+        int maximum_buffer_size;
+
+        // controlling quality
+        int fixed_q;
+        int worst_allowed_q;
+        int best_allowed_q;
+
+        // allow internal resizing ( currently disabled in the build !!!!!)
+        int allow_spatial_resampling;
+        int resample_down_water_mark;
+        int resample_up_water_mark;
+
+        // allow internal frame rate alterations
+        int allow_df;
+        int drop_frames_water_mark;
+
+        // two pass datarate control
+        int two_pass_vbrbias;        // two pass datarate control tweaks
+        int two_pass_vbrmin_section;
+        int two_pass_vbrmax_section;
+        // END DATARATE CONTROL OPTIONS
+        //----------------------------------------------------------------
+
+
+        // these parameters aren't to be used in final build don't use!!!
+        int play_alternate;
+        int alt_freq;
+        int alt_q;
+        int key_q;
+        int gold_q;
+
+
+        int multi_threaded;   // how many threads to run the encoder on
+        int token_partitions; // how many token partitions to create for multi core decoding
+        int encode_breakout;  // early breakout encode threshold : for video conf recommend 800
+
+        int error_resilient_mode;  // if running over udp networks provides decodable frames after a
+        // dropped packet
+
+        int arnr_max_frames;
+        int arnr_strength ;
+        int arnr_type     ;
+
+
+        struct vpx_fixed_buf         two_pass_stats_in;
+        struct vpx_codec_pkt_list  *output_pkt_list;
+    } VP8_CONFIG;
+
+
+    void vp8_initialize();
+
+    VP8_PTR vp8_create_compressor(VP8_CONFIG *oxcf);
+    void vp8_remove_compressor(VP8_PTR *comp);
+
+    void vp8_init_config(VP8_PTR onyx, VP8_CONFIG *oxcf);
+    void vp8_change_config(VP8_PTR onyx, VP8_CONFIG *oxcf);
+
+// receive a frames worth of data caller can assume that a copy of this frame is made
+// and not just a copy of the pointer..
+    int vp8_receive_raw_frame(VP8_PTR comp, unsigned int frame_flags, YV12_BUFFER_CONFIG *sd, INT64 time_stamp, INT64 end_time_stamp);
+    int vp8_get_compressed_data(VP8_PTR comp, unsigned int *frame_flags, unsigned long *size, unsigned char *dest, INT64 *time_stamp, INT64 *time_end, int flush);
+    int vp8_get_preview_raw_frame(VP8_PTR comp, YV12_BUFFER_CONFIG *dest, int deblock_level, int noise_level, int flags);
+
+    int vp8_use_as_reference(VP8_PTR comp, int ref_frame_flags);
+    int vp8_update_reference(VP8_PTR comp, int ref_frame_flags);
+    int vp8_get_reference(VP8_PTR comp, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd);
+    int vp8_set_reference(VP8_PTR comp, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd);
+    int vp8_update_entropy(VP8_PTR comp, int update);
+    int vp8_set_roimap(VP8_PTR comp, unsigned char *map, unsigned int rows, unsigned int cols, int delta_q[4], int delta_lf[4], unsigned int threshold[4]);
+    int vp8_set_active_map(VP8_PTR comp, unsigned char *map, unsigned int rows, unsigned int cols);
+    int vp8_set_internal_size(VP8_PTR comp, VPX_SCALING horiz_mode, VPX_SCALING vert_mode);
+    int vp8_get_quantizer(VP8_PTR c);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/onyxc_int.h
@@ -0,0 +1,206 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __INC_VP8C_INT_H
+#define __INC_VP8C_INT_H
+
+#include "vpx_config.h"
+#include "vpx/internal/vpx_codec_internal.h"
+#include "loopfilter.h"
+#include "entropymv.h"
+#include "entropy.h"
+#include "idct.h"
+#include "recon.h"
+#include "postproc.h"
+
+//#ifdef PACKET_TESTING
+#include "header.h"
+//#endif
+
+/* Create/destroy static data structures. */
+
+void vp8_initialize_common(void);
+
+#define MINQ 0
+#define MAXQ 127
+#define QINDEX_RANGE (MAXQ + 1)
+
+
+typedef struct frame_contexts
+{
+    vp8_prob bmode_prob [VP8_BINTRAMODES-1];
+    vp8_prob ymode_prob [VP8_YMODES-1];   /* interframe intra mode probs */
+    vp8_prob uv_mode_prob [VP8_UV_MODES-1];
+    vp8_prob sub_mv_ref_prob [VP8_SUBMVREFS-1];
+    vp8_prob coef_probs [BLOCK_TYPES] [COEF_BANDS] [PREV_COEF_CONTEXTS] [vp8_coef_tokens-1];
+    MV_CONTEXT mvc[2];
+    MV_CONTEXT pre_mvc[2];  //not to caculate the mvcost for the frame if mvc doesn't change.
+} FRAME_CONTEXT;
+
+typedef enum
+{
+    ONE_PARTITION  = 0,
+    TWO_PARTITION  = 1,
+    FOUR_PARTITION = 2,
+    EIGHT_PARTITION = 3
+} TOKEN_PARTITION;
+
+typedef enum
+{
+    RECON_CLAMP_REQUIRED        = 0,
+    RECON_CLAMP_NOTREQUIRED     = 1
+} CLAMP_TYPE;
+
+typedef enum
+{
+    SIXTAP   = 0,
+    BILINEAR = 1
+} INTERPOLATIONFILTERTYPE;
+
+typedef struct VP8_COMMON_RTCD
+{
+#if CONFIG_RUNTIME_CPU_DETECT
+    vp8_idct_rtcd_vtable_t        idct;
+    vp8_recon_rtcd_vtable_t       recon;
+    vp8_subpix_rtcd_vtable_t      subpix;
+    vp8_loopfilter_rtcd_vtable_t  loopfilter;
+    vp8_postproc_rtcd_vtable_t    postproc;
+#else
+    int unused;
+#endif
+} VP8_COMMON_RTCD;
+
+typedef struct VP8Common
+{
+    struct vpx_internal_error_info  error;
+
+    DECLARE_ALIGNED(16, short, Y1dequant[QINDEX_RANGE][4][4]);
+    DECLARE_ALIGNED(16, short, Y2dequant[QINDEX_RANGE][4][4]);
+    DECLARE_ALIGNED(16, short, UVdequant[QINDEX_RANGE][4][4]);
+
+    int Width;
+    int Height;
+    int horiz_scale;
+    int vert_scale;
+
+    YUV_TYPE clr_type;
+    CLAMP_TYPE  clamp_type;
+
+    YV12_BUFFER_CONFIG last_frame;
+    YV12_BUFFER_CONFIG golden_frame;
+    YV12_BUFFER_CONFIG alt_ref_frame;
+    YV12_BUFFER_CONFIG new_frame;
+    YV12_BUFFER_CONFIG *frame_to_show;
+    YV12_BUFFER_CONFIG post_proc_buffer;
+    YV12_BUFFER_CONFIG temp_scale_frame;
+
+    FRAME_TYPE last_frame_type;  //Add to check if vp8_frame_init_loop_filter() can be skiped.
+    FRAME_TYPE frame_type;
+
+    int show_frame;
+
+    int frame_flags;
+    int MBs;
+    int mb_rows;
+    int mb_cols;
+    int mode_info_stride;
+
+    // prfile settings
+    int mb_no_coeff_skip;
+    int no_lpf;
+    int simpler_lpf;
+    int use_bilinear_mc_filter;
+    int full_pixel;
+
+    int base_qindex;
+    int last_kf_gf_q;  // Q used on the last GF or KF
+
+    int y1dc_delta_q;
+    int y2dc_delta_q;
+    int y2ac_delta_q;
+    int uvdc_delta_q;
+    int uvac_delta_q;
+
+    unsigned int frames_since_golden;
+    unsigned int frames_till_alt_ref_frame;
+    unsigned char *gf_active_flags;   // Record of which MBs still refer to last golden frame either directly or through 0,0
+    int gf_active_count;
+
+    /* We allocate a MODE_INFO struct for each macroblock, together with
+       an extra row on top and column on the left to simplify prediction. */
+
+    MODE_INFO *mip; /* Base of allocated array */
+    MODE_INFO *mi;  /* Corresponds to upper left visible macroblock */
+
+
+    INTERPOLATIONFILTERTYPE mcomp_filter_type;
+    LOOPFILTERTYPE last_filter_type;
+    LOOPFILTERTYPE filter_type;
+    loop_filter_info lf_info[MAX_LOOP_FILTER+1];
+    prototype_loopfilter_block((*lf_mbv));
+    prototype_loopfilter_block((*lf_mbh));
+    prototype_loopfilter_block((*lf_bv));
+    prototype_loopfilter_block((*lf_bh));
+    int filter_level;
+    int last_sharpness_level;
+    int sharpness_level;
+
+    int refresh_last_frame;       // Two state 0 = NO, 1 = YES
+    int refresh_golden_frame;     // Two state 0 = NO, 1 = YES
+    int refresh_alt_ref_frame;     // Two state 0 = NO, 1 = YES
+
+    int copy_buffer_to_gf;         // 0 none, 1 Last to GF, 2 ARF to GF
+    int copy_buffer_to_arf;        // 0 none, 1 Last to ARF, 2 GF to ARF
+
+    int refresh_entropy_probs;    // Two state 0 = NO, 1 = YES
+
+    int ref_frame_sign_bias[MAX_REF_FRAMES];    // Two state 0, 1
+
+    // Y,U,V,Y2
+    ENTROPY_CONTEXT *above_context[4];   // row of context for each plane
+    ENTROPY_CONTEXT left_context[4][4];  // (up to) 4 contexts ""
+
+
+    // keyframe block modes are predicted by their above, left neighbors
+
+    vp8_prob kf_bmode_prob [VP8_BINTRAMODES] [VP8_BINTRAMODES] [VP8_BINTRAMODES-1];
+    vp8_prob kf_ymode_prob [VP8_YMODES-1];  /* keyframe "" */
+    vp8_prob kf_uv_mode_prob [VP8_UV_MODES-1];
+
+
+    FRAME_CONTEXT lfc; // last frame entropy
+    FRAME_CONTEXT fc;  // this frame entropy
+
+    unsigned int current_video_frame;
+
+    int near_boffset[3];
+    int version;
+
+    TOKEN_PARTITION multi_token_partition;
+
+#ifdef PACKET_TESTING
+    VP8_HEADER oh;
+#endif
+    double bitrate;
+    double framerate;
+
+#if CONFIG_RUNTIME_CPU_DETECT
+    VP8_COMMON_RTCD rtcd;
+#endif
+    struct postproc_state  postproc_state;
+} VP8_COMMON;
+
+
+void vp8_adjust_mb_lf_value(MACROBLOCKD *mbd, int *filter_level);
+void vp8_init_loop_filter(VP8_COMMON *cm);
+extern void vp8_loop_filter_frame(VP8_COMMON *cm,    MACROBLOCKD *mbd,  int filt_val);
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/onyxd.h
@@ -0,0 +1,68 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __INC_VP8D_H
+#define __INC_VP8D_H
+
+
+/* Create/destroy static data structures. */
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+#include "type_aliases.h"
+#include "vpx_scale/yv12config.h"
+#include "ppflags.h"
+#include "vpx_ports/mem.h"
+
+    typedef void   *VP8D_PTR;
+    typedef struct
+    {
+        int     Width;
+        int     Height;
+        int     Version;
+        int     postprocess;
+        int     max_threads;
+    } VP8D_CONFIG;
+    typedef enum
+    {
+        VP8_LAST_FLAG = 1,
+        VP8_GOLD_FLAG = 2,
+        VP8_ALT_FLAG = 4
+    } VP8_REFFRAME;
+
+    typedef enum
+    {
+        VP8D_OK = 0
+    } VP8D_SETTING;
+
+    void vp8dx_initialize(void);
+
+    void vp8dx_set_setting(VP8D_PTR comp, VP8D_SETTING oxst, int x);
+
+    int vp8dx_get_setting(VP8D_PTR comp, VP8D_SETTING oxst);
+
+    int vp8dx_receive_compressed_data(VP8D_PTR comp, unsigned long size, const unsigned char *dest, INT64 time_stamp);
+    int vp8dx_get_raw_frame(VP8D_PTR comp, YV12_BUFFER_CONFIG *sd, INT64 *time_stamp, INT64 *time_end_stamp, int deblock_level,  int noise_level, int flags);
+
+    int vp8dx_get_reference(VP8D_PTR comp, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd);
+    int vp8dx_set_reference(VP8D_PTR comp, VP8_REFFRAME ref_frame_flag, YV12_BUFFER_CONFIG *sd);
+
+    VP8D_PTR vp8dx_create_decompressor(VP8D_CONFIG *oxcf);
+
+    void vp8dx_remove_decompressor(VP8D_PTR comp);
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/postproc.c
@@ -0,0 +1,642 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include "vpx_ports/config.h"
+#include "vpx_scale/yv12config.h"
+#include "postproc.h"
+#include "vpx_scale/yv12extend.h"
+#include "vpx_scale/vpxscale.h"
+#include "systemdependent.h"
+
+#include <math.h>
+#include <stdlib.h>
+#include <stdio.h>
+// global constants
+
+static const short kernel5[] =
+{
+    1, 1, 4, 1, 1
+};
+
+const short vp8_rv[] =
+{
+    8, 5, 2, 2, 8, 12, 4, 9, 8, 3,
+    0, 3, 9, 0, 0, 0, 8, 3, 14, 4,
+    10, 1, 11, 14, 1, 14, 9, 6, 12, 11,
+    8, 6, 10, 0, 0, 8, 9, 0, 3, 14,
+    8, 11, 13, 4, 2, 9, 0, 3, 9, 6,
+    1, 2, 3, 14, 13, 1, 8, 2, 9, 7,
+    3, 3, 1, 13, 13, 6, 6, 5, 2, 7,
+    11, 9, 11, 8, 7, 3, 2, 0, 13, 13,
+    14, 4, 12, 5, 12, 10, 8, 10, 13, 10,
+    4, 14, 4, 10, 0, 8, 11, 1, 13, 7,
+    7, 14, 6, 14, 13, 2, 13, 5, 4, 4,
+    0, 10, 0, 5, 13, 2, 12, 7, 11, 13,
+    8, 0, 4, 10, 7, 2, 7, 2, 2, 5,
+    3, 4, 7, 3, 3, 14, 14, 5, 9, 13,
+    3, 14, 3, 6, 3, 0, 11, 8, 13, 1,
+    13, 1, 12, 0, 10, 9, 7, 6, 2, 8,
+    5, 2, 13, 7, 1, 13, 14, 7, 6, 7,
+    9, 6, 10, 11, 7, 8, 7, 5, 14, 8,
+    4, 4, 0, 8, 7, 10, 0, 8, 14, 11,
+    3, 12, 5, 7, 14, 3, 14, 5, 2, 6,
+    11, 12, 12, 8, 0, 11, 13, 1, 2, 0,
+    5, 10, 14, 7, 8, 0, 4, 11, 0, 8,
+    0, 3, 10, 5, 8, 0, 11, 6, 7, 8,
+    10, 7, 13, 9, 2, 5, 1, 5, 10, 2,
+    4, 3, 5, 6, 10, 8, 9, 4, 11, 14,
+    0, 10, 0, 5, 13, 2, 12, 7, 11, 13,
+    8, 0, 4, 10, 7, 2, 7, 2, 2, 5,
+    3, 4, 7, 3, 3, 14, 14, 5, 9, 13,
+    3, 14, 3, 6, 3, 0, 11, 8, 13, 1,
+    13, 1, 12, 0, 10, 9, 7, 6, 2, 8,
+    5, 2, 13, 7, 1, 13, 14, 7, 6, 7,
+    9, 6, 10, 11, 7, 8, 7, 5, 14, 8,
+    4, 4, 0, 8, 7, 10, 0, 8, 14, 11,
+    3, 12, 5, 7, 14, 3, 14, 5, 2, 6,
+    11, 12, 12, 8, 0, 11, 13, 1, 2, 0,
+    5, 10, 14, 7, 8, 0, 4, 11, 0, 8,
+    0, 3, 10, 5, 8, 0, 11, 6, 7, 8,
+    10, 7, 13, 9, 2, 5, 1, 5, 10, 2,
+    4, 3, 5, 6, 10, 8, 9, 4, 11, 14,
+    3, 8, 3, 7, 8, 5, 11, 4, 12, 3,
+    11, 9, 14, 8, 14, 13, 4, 3, 1, 2,
+    14, 6, 5, 4, 4, 11, 4, 6, 2, 1,
+    5, 8, 8, 12, 13, 5, 14, 10, 12, 13,
+    0, 9, 5, 5, 11, 10, 13, 9, 10, 13,
+};
+
+
+extern void vp8_blit_text(const char *msg, unsigned char *address, const int pitch);
+
+/***********************************************************************************************************
+ */
+void vp8_post_proc_down_and_across_c
+(
+    unsigned char *src_ptr,
+    unsigned char *dst_ptr,
+    int src_pixels_per_line,
+    int dst_pixels_per_line,
+    int rows,
+    int cols,
+    int flimit
+)
+{
+    unsigned char *p_src, *p_dst;
+    int row;
+    int col;
+    int i;
+    int v;
+    int pitch = src_pixels_per_line;
+    unsigned char d[8];
+    (void)dst_pixels_per_line;
+
+    for (row = 0; row < rows; row++)
+    {
+        // post_proc_down for one row
+        p_src = src_ptr;
+        p_dst = dst_ptr;
+
+        for (col = 0; col < cols; col++)
+        {
+
+            int kernel = 4;
+            int v = p_src[col];
+
+            for (i = -2; i <= 2; i++)
+            {
+                if (abs(v - p_src[col+i*pitch]) > flimit)
+                    goto down_skip_convolve;
+
+                kernel += kernel5[2+i] * p_src[col+i*pitch];
+            }
+
+            v = (kernel >> 3);
+        down_skip_convolve:
+            p_dst[col] = v;
+        }
+
+        // now post_proc_across
+        p_src = dst_ptr;
+        p_dst = dst_ptr;
+
+        for (i = 0; i < 8; i++)
+            d[i] = p_src[i];
+
+        for (col = 0; col < cols; col++)
+        {
+            int kernel = 4;
+            v = p_src[col];
+
+            d[col&7] = v;
+
+            for (i = -2; i <= 2; i++)
+            {
+                if (abs(v - p_src[col+i]) > flimit)
+                    goto across_skip_convolve;
+
+                kernel += kernel5[2+i] * p_src[col+i];
+            }
+
+            d[col&7] = (kernel >> 3);
+        across_skip_convolve:
+
+            if (col >= 2)
+                p_dst[col-2] = d[(col-2)&7];
+        }
+
+        //handle the last two pixels
+        p_dst[col-2] = d[(col-2)&7];
+        p_dst[col-1] = d[(col-1)&7];
+
+
+        //next row
+        src_ptr += pitch;
+        dst_ptr += pitch;
+    }
+}
+
+int vp8_q2mbl(int x)
+{
+    if (x < 20) x = 20;
+
+    x = 50 + (x - 50) * 10 / 8;
+    return x * x / 3;
+}
+void vp8_mbpost_proc_across_ip_c(unsigned char *src, int pitch, int rows, int cols, int flimit)
+{
+    int r, c, i;
+
+    unsigned char *s = src;
+    unsigned char d[16];
+
+
+    for (r = 0; r < rows; r++)
+    {
+        int sumsq = 0;
+        int sum   = 0;
+
+        for (i = -8; i <= 6; i++)
+        {
+            sumsq += s[i] * s[i];
+            sum   += s[i];
+            d[i+8] = 0;
+        }
+
+        for (c = 0; c < cols + 8; c++)
+        {
+            int x = s[c+7] - s[c-8];
+            int y = s[c+7] + s[c-8];
+
+            sum  += x;
+            sumsq += x * y;
+
+            d[c&15] = s[c];
+
+            if (sumsq * 15 - sum * sum < flimit)
+            {
+                d[c&15] = (8 + sum + s[c]) >> 4;
+            }
+
+            s[c-8] = d[(c-8)&15];
+        }
+
+        s += pitch;
+    }
+}
+
+
+
+
+
+void vp8_mbpost_proc_down_c(unsigned char *dst, int pitch, int rows, int cols, int flimit)
+{
+    int r, c, i;
+    const short *rv3 = &vp8_rv[63&rand()];
+
+    for (c = 0; c < cols; c++)
+    {
+        unsigned char *s = &dst[c];
+        int sumsq = 0;
+        int sum   = 0;
+        unsigned char d[16];
+        const short *rv2 = rv3 + ((c * 17) & 127);
+
+        for (i = -8; i <= 6; i++)
+        {
+            sumsq += s[i*pitch] * s[i*pitch];
+            sum   += s[i*pitch];
+        }
+
+        for (r = 0; r < rows + 8; r++)
+        {
+            sumsq += s[7*pitch] * s[ 7*pitch] - s[-8*pitch] * s[-8*pitch];
+            sum  += s[7*pitch] - s[-8*pitch];
+            d[r&15] = s[0];
+
+            if (sumsq * 15 - sum * sum < flimit)
+            {
+                d[r&15] = (rv2[r&127] + sum + s[0]) >> 4;
+            }
+
+            s[-8*pitch] = d[(r-8)&15];
+            s += pitch;
+        }
+    }
+}
+
+
+static void vp8_deblock_and_de_macro_block(YV12_BUFFER_CONFIG         *source,
+        YV12_BUFFER_CONFIG         *post,
+        int                         q,
+        int                         low_var_thresh,
+        int                         flag,
+        vp8_postproc_rtcd_vtable_t *rtcd)
+{
+    double level = 6.0e-05 * q * q * q - .0067 * q * q + .306 * q + .0065;
+    int ppl = (int)(level + .5);
+    (void) low_var_thresh;
+    (void) flag;
+
+    POSTPROC_INVOKE(rtcd, downacross)(source->y_buffer, post->y_buffer, source->y_stride,  post->y_stride, source->y_height, source->y_width,  ppl);
+    POSTPROC_INVOKE(rtcd, across)(post->y_buffer, post->y_stride, post->y_height, post->y_width, vp8_q2mbl(q));
+    POSTPROC_INVOKE(rtcd, down)(post->y_buffer, post->y_stride, post->y_height, post->y_width, vp8_q2mbl(q));
+
+    POSTPROC_INVOKE(rtcd, downacross)(source->u_buffer, post->u_buffer, source->uv_stride, post->uv_stride, source->uv_height, source->uv_width, ppl);
+    POSTPROC_INVOKE(rtcd, downacross)(source->v_buffer, post->v_buffer, source->uv_stride, post->uv_stride, source->uv_height, source->uv_width, ppl);
+
+}
+
+void vp8_deblock(YV12_BUFFER_CONFIG         *source,
+                        YV12_BUFFER_CONFIG         *post,
+                        int                         q,
+                        int                         low_var_thresh,
+                        int                         flag,
+                        vp8_postproc_rtcd_vtable_t *rtcd)
+{
+    double level = 6.0e-05 * q * q * q - .0067 * q * q + .306 * q + .0065;
+    int ppl = (int)(level + .5);
+    (void) low_var_thresh;
+    (void) flag;
+
+    POSTPROC_INVOKE(rtcd, downacross)(source->y_buffer, post->y_buffer, source->y_stride,  post->y_stride, source->y_height, source->y_width,   ppl);
+    POSTPROC_INVOKE(rtcd, downacross)(source->u_buffer, post->u_buffer, source->uv_stride, post->uv_stride,  source->uv_height, source->uv_width, ppl);
+    POSTPROC_INVOKE(rtcd, downacross)(source->v_buffer, post->v_buffer, source->uv_stride, post->uv_stride, source->uv_height, source->uv_width, ppl);
+}
+
+void vp8_de_noise(YV12_BUFFER_CONFIG         *source,
+                  YV12_BUFFER_CONFIG         *post,
+                  int                         q,
+                  int                         low_var_thresh,
+                  int                         flag,
+                  vp8_postproc_rtcd_vtable_t *rtcd)
+{
+    double level = 6.0e-05 * q * q * q - .0067 * q * q + .306 * q + .0065;
+    int ppl = (int)(level + .5);
+    (void) post;
+    (void) low_var_thresh;
+    (void) flag;
+
+    POSTPROC_INVOKE(rtcd, downacross)(
+        source->y_buffer + 2 * source->y_stride + 2,
+        source->y_buffer + 2 * source->y_stride + 2,
+        source->y_stride,
+        source->y_stride,
+        source->y_height - 4,
+        source->y_width - 4,
+        ppl);
+    POSTPROC_INVOKE(rtcd, downacross)(
+        source->u_buffer + 2 * source->uv_stride + 2,
+        source->u_buffer + 2 * source->uv_stride + 2,
+        source->uv_stride,
+        source->uv_stride,
+        source->uv_height - 4,
+        source->uv_width - 4, ppl);
+    POSTPROC_INVOKE(rtcd, downacross)(
+        source->v_buffer + 2 * source->uv_stride + 2,
+        source->v_buffer + 2 * source->uv_stride + 2,
+        source->uv_stride,
+        source->uv_stride,
+        source->uv_height - 4,
+        source->uv_width - 4, ppl);
+
+}
+
+
+//Notes: It is better to change CHAR to unsigned or signed to
+//avoid error on ARM platform.
+char vp8_an[8][64][3072];
+int vp8_cd[8][64];
+
+
+double vp8_gaussian(double sigma, double mu, double x)
+{
+    return 1 / (sigma * sqrt(2.0 * 3.14159265)) *
+           (exp(-(x - mu) * (x - mu) / (2 * sigma * sigma)));
+}
+
+extern void (*vp8_clear_system_state)(void);
+
+
+static void fillrd(struct postproc_state *state, int q, int a)
+{
+    char char_dist[300];
+
+    double sigma;
+    int ai = a, qi = q, i;
+
+    vp8_clear_system_state();
+
+
+    sigma = ai + .5 + .6 * (63 - qi) / 63.0;
+
+    // set up a lookup table of 256 entries that matches
+    // a gaussian distribution with sigma determined by q.
+    //
+    {
+        double i;
+        int next, j;
+
+        next = 0;
+
+        for (i = -32; i < 32; i++)
+        {
+            int a = (int)(.5 + 256 * vp8_gaussian(sigma, 0, i));
+
+            if (a)
+            {
+                for (j = 0; j < a; j++)
+                {
+                    char_dist[next+j] = (char) i;
+                }
+
+                next = next + j;
+            }
+
+        }
+
+        for (next = next; next < 256; next++)
+            char_dist[next] = 0;
+
+    }
+
+    for (i = 0; i < 3072; i++)
+    {
+        state->noise[i] = char_dist[rand() & 0xff];
+    }
+
+    for (i = 0; i < 16; i++)
+    {
+        state->blackclamp[i] = -char_dist[0];
+        state->whiteclamp[i] = -char_dist[0];
+        state->bothclamp[i] = -2 * char_dist[0];
+    }
+
+    state->last_q = q;
+    state->last_noise = a;
+}
+
+/****************************************************************************
+ *
+ *  ROUTINE       : plane_add_noise_c
+ *
+ *  INPUTS        : unsigned char *Start    starting address of buffer to add gaussian
+ *                                  noise to
+ *                  unsigned int Width    width of plane
+ *                  unsigned int Height   height of plane
+ *                  int  Pitch    distance between subsequent lines of frame
+ *                  int  q        quantizer used to determine amount of noise
+ *                                  to add
+ *
+ *  OUTPUTS       : None.
+ *
+ *  RETURNS       : void.
+ *
+ *  FUNCTION      : adds gaussian noise to a plane of pixels
+ *
+ *  SPECIAL NOTES : None.
+ *
+ ****************************************************************************/
+void vp8_plane_add_noise_c(unsigned char *Start, char *noise,
+                           char blackclamp[16],
+                           char whiteclamp[16],
+                           char bothclamp[16],
+                           unsigned int Width, unsigned int Height, int Pitch)
+{
+    unsigned int i, j;
+
+    for (i = 0; i < Height; i++)
+    {
+        unsigned char *Pos = Start + i * Pitch;
+        char  *Ref = (char *)(noise + (rand() & 0xff));
+
+        for (j = 0; j < Width; j++)
+        {
+            if (Pos[j] < blackclamp[0])
+                Pos[j] = blackclamp[0];
+
+            if (Pos[j] > 255 + whiteclamp[0])
+                Pos[j] = 255 + whiteclamp[0];
+
+            Pos[j] += Ref[j];
+        }
+    }
+}
+
+#if CONFIG_RUNTIME_CPU_DETECT
+#define RTCD_VTABLE(oci) (&(oci)->rtcd.postproc)
+#else
+#define RTCD_VTABLE(oci) NULL
+#endif
+
+int vp8_post_proc_frame(VP8_COMMON *oci, YV12_BUFFER_CONFIG *dest, int deblock_level, int noise_level, int flags)
+{
+    char message[512];
+    int q = oci->filter_level * 10 / 6;
+
+    if (!oci->frame_to_show)
+        return -1;
+
+    if (q > 63)
+        q = 63;
+
+    if (!flags)
+    {
+        *dest = *oci->frame_to_show;
+
+        // handle problem with extending borders
+        dest->y_width = oci->Width;
+        dest->y_height = oci->Height;
+        dest->uv_height = dest->y_height / 2;
+        return 0;
+
+    }
+
+#if ARCH_X86||ARCH_X86_64
+    vpx_reset_mmx_state();
+#endif
+
+    if (flags & VP8D_DEMACROBLOCK)
+    {
+        vp8_deblock_and_de_macro_block(oci->frame_to_show, &oci->post_proc_buffer,
+                                       q + (deblock_level - 5) * 10, 1, 0, RTCD_VTABLE(oci));
+    }
+    else if (flags & VP8D_DEBLOCK)
+    {
+        vp8_deblock(oci->frame_to_show, &oci->post_proc_buffer,
+                    q, 1, 0, RTCD_VTABLE(oci));
+    }
+    else
+    {
+        vp8_yv12_copy_frame_ptr(oci->frame_to_show, &oci->post_proc_buffer);
+    }
+
+    if (flags & VP8D_ADDNOISE)
+    {
+        if (oci->postproc_state.last_q != q
+            || oci->postproc_state.last_noise != noise_level)
+        {
+            fillrd(&oci->postproc_state, 63 - q, noise_level);
+        }
+
+        POSTPROC_INVOKE(RTCD_VTABLE(oci), addnoise)
+        (oci->post_proc_buffer.y_buffer,
+         oci->postproc_state.noise,
+         oci->postproc_state.blackclamp,
+         oci->postproc_state.whiteclamp,
+         oci->postproc_state.bothclamp,
+         oci->post_proc_buffer.y_width, oci->post_proc_buffer.y_height,
+         oci->post_proc_buffer.y_stride);
+    }
+
+    if (flags & VP8D_DEBUG_LEVEL1)
+    {
+        sprintf(message, "F%1dG%1dQ%3dF%3dP%d_s%dx%d",
+                (oci->frame_type == KEY_FRAME),
+                oci->refresh_golden_frame,
+                oci->base_qindex,
+                oci->filter_level,
+                flags,
+                oci->mb_cols, oci->mb_rows);
+        vp8_blit_text(message, oci->post_proc_buffer.y_buffer, oci->post_proc_buffer.y_stride);
+    }
+    else if (flags & VP8D_DEBUG_LEVEL2)
+    {
+        int i, j;
+        unsigned char *y_ptr;
+        YV12_BUFFER_CONFIG *post = &oci->post_proc_buffer;
+        int mb_rows = post->y_height >> 4;
+        int mb_cols = post->y_width  >> 4;
+        int mb_index = 0;
+        MODE_INFO *mi = oci->mi;
+
+        y_ptr = post->y_buffer + 4 * post->y_stride + 4;
+
+        // vp8_filter each macro block
+        for (i = 0; i < mb_rows; i++)
+        {
+            for (j = 0; j < mb_cols; j++)
+            {
+                char zz[4];
+
+                sprintf(zz, "%c", mi[mb_index].mbmi.mode + 'a');
+
+                vp8_blit_text(zz, y_ptr, post->y_stride);
+                mb_index ++;
+                y_ptr += 16;
+            }
+
+            mb_index ++; //border
+            y_ptr += post->y_stride  * 16 - post->y_width;
+
+        }
+    }
+    else if (flags & VP8D_DEBUG_LEVEL3)
+    {
+        int i, j;
+        unsigned char *y_ptr;
+        YV12_BUFFER_CONFIG *post = &oci->post_proc_buffer;
+        int mb_rows = post->y_height >> 4;
+        int mb_cols = post->y_width  >> 4;
+        int mb_index = 0;
+        MODE_INFO *mi = oci->mi;
+
+        y_ptr = post->y_buffer + 4 * post->y_stride + 4;
+
+        // vp8_filter each macro block
+        for (i = 0; i < mb_rows; i++)
+        {
+            for (j = 0; j < mb_cols; j++)
+            {
+                char zz[4];
+
+                if (oci->frame_type == KEY_FRAME)
+                    sprintf(zz, "a");
+                else
+                    sprintf(zz, "%c", mi[mb_index].mbmi.dc_diff + '0');
+
+                vp8_blit_text(zz, y_ptr, post->y_stride);
+                mb_index ++;
+                y_ptr += 16;
+            }
+
+            mb_index ++; //border
+            y_ptr += post->y_stride  * 16 - post->y_width;
+
+        }
+    }
+    else if (flags & VP8D_DEBUG_LEVEL4)
+    {
+        sprintf(message, "Bitrate: %10.2f frame_rate: %10.2f ", oci->bitrate, oci->framerate);
+        vp8_blit_text(message, oci->post_proc_buffer.y_buffer, oci->post_proc_buffer.y_stride);
+#if 0
+        int i, j;
+        unsigned char *y_ptr;
+        YV12_BUFFER_CONFIG *post = &oci->post_proc_buffer;
+        int mb_rows = post->y_height >> 4;
+        int mb_cols = post->y_width  >> 4;
+        int mb_index = 0;
+        MODE_INFO *mi = oci->mi;
+
+        y_ptr = post->y_buffer + 4 * post->y_stride + 4;
+
+        // vp8_filter each macro block
+        for (i = 0; i < mb_rows; i++)
+        {
+            for (j = 0; j < mb_cols; j++)
+            {
+                char zz[4];
+
+                sprintf(zz, "%c", mi[mb_index].mbmi.dc_diff + '0');
+                vp8_blit_text(zz, y_ptr, post->y_stride);
+                mb_index ++;
+                y_ptr += 16;
+            }
+
+            mb_index ++; //border
+            y_ptr += post->y_stride  * 16 - post->y_width;
+
+        }
+
+#endif
+
+    }
+
+
+
+    *dest = oci->post_proc_buffer;
+
+    // handle problem with extending borders
+    dest->y_width = oci->Width;
+    dest->y_height = oci->Height;
+    dest->uv_height = dest->y_height / 2;
+    return 0;
+}
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/postproc.h
@@ -0,0 +1,98 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef POSTPROC_H
+#define POSTPROC_H
+
+#define prototype_postproc_inplace(sym)\
+    void sym (unsigned char *dst, int pitch, int rows, int cols,int flimit)
+
+#define prototype_postproc(sym)\
+    void sym (unsigned char *src, unsigned char *dst, int src_pitch,\
+              int dst_pitch, int rows, int cols, int flimit)
+
+#define prototype_postproc_addnoise(sym) \
+    void sym (unsigned char *s, char *noise, char blackclamp[16],\
+              char whiteclamp[16], char bothclamp[16],\
+              unsigned int w, unsigned int h, int pitch)
+
+#if ARCH_X86 || ARCH_X86_64
+#include "x86/postproc_x86.h"
+#endif
+
+#ifndef vp8_postproc_down
+#define vp8_postproc_down vp8_mbpost_proc_down_c
+#endif
+extern prototype_postproc_inplace(vp8_postproc_down);
+
+#ifndef vp8_postproc_across
+#define vp8_postproc_across vp8_mbpost_proc_across_ip_c
+#endif
+extern prototype_postproc_inplace(vp8_postproc_across);
+
+#ifndef vp8_postproc_downacross
+#define vp8_postproc_downacross vp8_post_proc_down_and_across_c
+#endif
+extern prototype_postproc(vp8_postproc_downacross);
+
+#ifndef vp8_postproc_addnoise
+#define vp8_postproc_addnoise vp8_plane_add_noise_c
+#endif
+extern prototype_postproc_addnoise(vp8_postproc_addnoise);
+
+
+typedef prototype_postproc((*vp8_postproc_fn_t));
+typedef prototype_postproc_inplace((*vp8_postproc_inplace_fn_t));
+typedef prototype_postproc_addnoise((*vp8_postproc_addnoise_fn_t));
+typedef struct
+{
+    vp8_postproc_inplace_fn_t   down;
+    vp8_postproc_inplace_fn_t   across;
+    vp8_postproc_fn_t           downacross;
+    vp8_postproc_addnoise_fn_t  addnoise;
+} vp8_postproc_rtcd_vtable_t;
+
+#if CONFIG_RUNTIME_CPU_DETECT
+#define POSTPROC_INVOKE(ctx,fn) (ctx)->fn
+#else
+#define POSTPROC_INVOKE(ctx,fn) vp8_postproc_##fn
+#endif
+
+#include "vpx_ports/mem.h"
+struct postproc_state
+{
+    int           last_q;
+    int           last_noise;
+    char          noise[3072];
+    DECLARE_ALIGNED(16, char, blackclamp[16]);
+    DECLARE_ALIGNED(16, char, whiteclamp[16]);
+    DECLARE_ALIGNED(16, char, bothclamp[16]);
+};
+#include "onyxc_int.h"
+#include "ppflags.h"
+int vp8_post_proc_frame(struct VP8Common *oci, YV12_BUFFER_CONFIG *dest,
+                        int deblock_level, int noise_level, int flags);
+
+
+void vp8_de_noise(YV12_BUFFER_CONFIG         *source,
+                  YV12_BUFFER_CONFIG         *post,
+                  int                         q,
+                  int                         low_var_thresh,
+                  int                         flag,
+                  vp8_postproc_rtcd_vtable_t *rtcd);
+
+void vp8_deblock(YV12_BUFFER_CONFIG         *source,
+                 YV12_BUFFER_CONFIG         *post,
+                 int                         q,
+                 int                         low_var_thresh,
+                 int                         flag,
+                 vp8_postproc_rtcd_vtable_t *rtcd);
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/ppflags.h
@@ -0,0 +1,26 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __INC_PPFLAGS_H
+#define __INC_PPFLAGS_H
+enum
+{
+    VP8D_NOFILTERING    = 0,
+    VP8D_DEBLOCK        = 1,
+    VP8D_DEMACROBLOCK   = 2,
+    VP8D_ADDNOISE       = 4,
+    VP8D_DEBUG_LEVEL1   = 8,
+    VP8D_DEBUG_LEVEL2   = 16,
+    VP8D_DEBUG_LEVEL3   = 32,
+    VP8D_DEBUG_LEVEL4   = 64
+};
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/pragmas.h
@@ -0,0 +1,19 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+
+
+#ifdef __INTEL_COMPILER
+#pragma warning(disable:997 1011 170)
+#endif
+#ifdef _MSC_VER
+#pragma warning(disable:4799)
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/predictdc.c
@@ -0,0 +1,44 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include <stdlib.h>
+#include "blockd.h"
+
+
+void vp8_predict_dc(short *lastdc, short *thisdc, short quant, short *cons)
+{
+    int diff;
+    int sign;
+    int last_dc = *lastdc;
+    int this_dc = *thisdc;
+
+    if (*cons  > DCPREDCNTTHRESH)
+    {
+        this_dc += last_dc;
+    }
+
+    diff = abs(last_dc - this_dc);
+    sign  = (last_dc >> 31) ^(this_dc >> 31);
+    sign |= (!last_dc | !this_dc);
+
+    if (sign)
+    {
+        *cons = 0;
+    }
+    else
+    {
+        if (diff <= DCPREDSIMTHRESH * quant)
+            (*cons)++ ;
+    }
+
+    *thisdc = this_dc;
+    *lastdc = this_dc;
+}
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/predictdc.h
@@ -0,0 +1,18 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __PREDICTDC_H
+#define __PREDICTDC_H
+
+void uvvp8_predict_dc(short *lastdc, short *thisdc, short quant, short *cons);
+void vp8_predict_dc(short *lastdc, short *thisdc, short quant, short *cons);
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/preproc.h
@@ -0,0 +1,46 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+/****************************************************************************
+*
+*   Module Title :     preproc.h
+*
+*   Description  :     simple preprocessor
+*
+****************************************************************************/
+
+#ifndef __INC_PREPROC_H
+#define __INC_PREPROC_H
+
+/****************************************************************************
+*  Types
+****************************************************************************/
+
+typedef struct
+{
+    unsigned char *frame_buffer;
+    int frame;
+    unsigned int *fixed_divide;
+
+    unsigned char *frame_buffer_alloc;
+    unsigned int *fixed_divide_alloc;
+} pre_proc_instance;
+
+/****************************************************************************
+*  Functions.
+****************************************************************************/
+void pre_proc_machine_specific_config(void);
+void delete_pre_proc(pre_proc_instance *ppi);
+int init_pre_proc(pre_proc_instance *ppi, int frame_size);
+extern void spatial_filter_c(pre_proc_instance *ppi, unsigned char *s, unsigned char *d, int width, int height, int pitch, int strength);
+extern void (*temp_filter)(pre_proc_instance *ppi, unsigned char *s, unsigned char *d, int bytes, int strength);
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/quant_common.c
@@ -0,0 +1,132 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include "quant_common.h"
+
+static const int dc_qlookup[QINDEX_RANGE] =
+{
+    4,    5,    6,    7,    8,    9,   10,   10,   11,   12,   13,   14,   15,   16,   17,   17,
+    18,   19,   20,   20,   21,   21,   22,   22,   23,   23,   24,   25,   25,   26,   27,   28,
+    29,   30,   31,   32,   33,   34,   35,   36,   37,   37,   38,   39,   40,   41,   42,   43,
+    44,   45,   46,   46,   47,   48,   49,   50,   51,   52,   53,   54,   55,   56,   57,   58,
+    59,   60,   61,   62,   63,   64,   65,   66,   67,   68,   69,   70,   71,   72,   73,   74,
+    75,   76,   76,   77,   78,   79,   80,   81,   82,   83,   84,   85,   86,   87,   88,   89,
+    91,   93,   95,   96,   98,  100,  101,  102,  104,  106,  108,  110,  112,  114,  116,  118,
+    122,  124,  126,  128,  130,  132,  134,  136,  138,  140,  143,  145,  148,  151,  154,  157,
+};
+
+static const int ac_qlookup[QINDEX_RANGE] =
+{
+    4,    5,    6,    7,    8,    9,   10,   11,   12,   13,   14,   15,   16,   17,   18,   19,
+    20,   21,   22,   23,   24,   25,   26,   27,   28,   29,   30,   31,   32,   33,   34,   35,
+    36,   37,   38,   39,   40,   41,   42,   43,   44,   45,   46,   47,   48,   49,   50,   51,
+    52,   53,   54,   55,   56,   57,   58,   60,   62,   64,   66,   68,   70,   72,   74,   76,
+    78,   80,   82,   84,   86,   88,   90,   92,   94,   96,   98,  100,  102,  104,  106,  108,
+    110,  112,  114,  116,  119,  122,  125,  128,  131,  134,  137,  140,  143,  146,  149,  152,
+    155,  158,  161,  164,  167,  170,  173,  177,  181,  185,  189,  193,  197,  201,  205,  209,
+    213,  217,  221,  225,  229,  234,  239,  245,  249,  254,  259,  264,  269,  274,  279,  284,
+};
+
+
+int vp8_dc_quant(int QIndex, int Delta)
+{
+    int retval;
+
+    QIndex = QIndex + Delta;
+
+    if (QIndex > 127)
+        QIndex = 127;
+    else if (QIndex < 0)
+        QIndex = 0;
+
+    retval = dc_qlookup[ QIndex ];
+    return retval;
+}
+
+int vp8_dc2quant(int QIndex, int Delta)
+{
+    int retval;
+
+    QIndex = QIndex + Delta;
+
+    if (QIndex > 127)
+        QIndex = 127;
+    else if (QIndex < 0)
+        QIndex = 0;
+
+    retval = dc_qlookup[ QIndex ] * 2;
+    return retval;
+
+}
+int vp8_dc_uv_quant(int QIndex, int Delta)
+{
+    int retval;
+
+    QIndex = QIndex + Delta;
+
+    if (QIndex > 127)
+        QIndex = 127;
+    else if (QIndex < 0)
+        QIndex = 0;
+
+    retval = dc_qlookup[ QIndex ];
+
+    if (retval > 132)
+        retval = 132;
+
+    return retval;
+}
+
+int vp8_ac_yquant(int QIndex)
+{
+    int retval;
+
+    if (QIndex > 127)
+        QIndex = 127;
+    else if (QIndex < 0)
+        QIndex = 0;
+
+    retval = ac_qlookup[ QIndex ];
+    return retval;
+}
+
+int vp8_ac2quant(int QIndex, int Delta)
+{
+    int retval;
+
+    QIndex = QIndex + Delta;
+
+    if (QIndex > 127)
+        QIndex = 127;
+    else if (QIndex < 0)
+        QIndex = 0;
+
+    retval = (ac_qlookup[ QIndex ] * 155) / 100;
+
+    if (retval < 8)
+        retval = 8;
+
+    return retval;
+}
+int vp8_ac_uv_quant(int QIndex, int Delta)
+{
+    int retval;
+
+    QIndex = QIndex + Delta;
+
+    if (QIndex > 127)
+        QIndex = 127;
+    else if (QIndex < 0)
+        QIndex = 0;
+
+    retval = ac_qlookup[ QIndex ];
+    return retval;
+}
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/quant_common.h
@@ -0,0 +1,21 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include "string.h"
+#include "blockd.h"
+#include "onyxc_int.h"
+
+extern int vp8_ac_yquant(int QIndex);
+extern int vp8_dc_quant(int QIndex, int Delta);
+extern int vp8_dc2quant(int QIndex, int Delta);
+extern int vp8_ac2quant(int QIndex, int Delta);
+extern int vp8_dc_uv_quant(int QIndex, int Delta);
+extern int vp8_ac_uv_quant(int QIndex, int Delta);
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/recon.c
@@ -0,0 +1,138 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include "vpx_ports/config.h"
+#include "recon.h"
+#include "blockd.h"
+
+void vp8_recon_b_c
+(
+    unsigned char *pred_ptr,
+    short *diff_ptr,
+    unsigned char *dst_ptr,
+    int stride
+)
+{
+    int r, c;
+
+    for (r = 0; r < 4; r++)
+    {
+        for (c = 0; c < 4; c++)
+        {
+            int a = diff_ptr[c] + pred_ptr[c] ;
+
+            if (a < 0)
+                a = 0;
+
+            if (a > 255)
+                a = 255;
+
+            dst_ptr[c] = (unsigned char) a ;
+        }
+
+        dst_ptr += stride;
+        diff_ptr += 16;
+        pred_ptr += 16;
+    }
+}
+
+void vp8_recon4b_c
+(
+    unsigned char *pred_ptr,
+    short *diff_ptr,
+    unsigned char *dst_ptr,
+    int stride
+)
+{
+    int r, c;
+
+    for (r = 0; r < 4; r++)
+    {
+        for (c = 0; c < 16; c++)
+        {
+            int a = diff_ptr[c] + pred_ptr[c] ;
+
+            if (a < 0)
+                a = 0;
+
+            if (a > 255)
+                a = 255;
+
+            dst_ptr[c] = (unsigned char) a ;
+        }
+
+        dst_ptr += stride;
+        diff_ptr += 16;
+        pred_ptr += 16;
+    }
+}
+
+void vp8_recon2b_c
+(
+    unsigned char *pred_ptr,
+    short *diff_ptr,
+    unsigned char *dst_ptr,
+    int stride
+)
+{
+    int r, c;
+
+    for (r = 0; r < 4; r++)
+    {
+        for (c = 0; c < 8; c++)
+        {
+            int a = diff_ptr[c] + pred_ptr[c] ;
+
+            if (a < 0)
+                a = 0;
+
+            if (a > 255)
+                a = 255;
+
+            dst_ptr[c] = (unsigned char) a ;
+        }
+
+        dst_ptr += stride;
+        diff_ptr += 8;
+        pred_ptr += 8;
+    }
+}
+
+void vp8_recon16x16mby(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
+{
+    int i;
+
+    for (i = 0; i < 16; i += 4)
+    {
+        BLOCKD *b = &x->block[i];
+
+        RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+    }
+}
+
+void vp8_recon16x16mb(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
+{
+    int i;
+
+    for (i = 0; i < 16; i += 4)
+    {
+        BLOCKD *b = &x->block[i];
+
+        RECON_INVOKE(rtcd, recon4)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+    }
+
+    for (i = 16; i < 24; i += 2)
+    {
+        BLOCKD *b = &x->block[i];
+
+        RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+    }
+}
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/recon.h
@@ -0,0 +1,82 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __INC_RECON_H
+#define __INC_RECON_H
+
+#define prototype_copy_block(sym) \
+    void sym(unsigned char *src, int src_pitch, unsigned char *dst, int dst_pitch)
+
+#define prototype_recon_block(sym) \
+    void sym(unsigned char *pred, short *diff, unsigned char *dst, int pitch);
+
+#if ARCH_X86 || ARCH_X86_64
+#include "x86/recon_x86.h"
+#endif
+
+#if ARCH_ARM
+#include "arm/recon_arm.h"
+#endif
+
+#ifndef vp8_recon_copy16x16
+#define vp8_recon_copy16x16 vp8_copy_mem16x16_c
+#endif
+extern prototype_copy_block(vp8_recon_copy16x16);
+
+#ifndef vp8_recon_copy8x8
+#define vp8_recon_copy8x8 vp8_copy_mem8x8_c
+#endif
+extern prototype_copy_block(vp8_recon_copy8x8);
+
+#ifndef vp8_recon_copy8x4
+#define vp8_recon_copy8x4 vp8_copy_mem8x4_c
+#endif
+extern prototype_copy_block(vp8_recon_copy8x4);
+
+#ifndef vp8_recon_recon
+#define vp8_recon_recon vp8_recon_b_c
+#endif
+extern prototype_recon_block(vp8_recon_recon);
+
+#ifndef vp8_recon_recon2
+#define vp8_recon_recon2 vp8_recon2b_c
+#endif
+extern prototype_recon_block(vp8_recon_recon2);
+
+#ifndef vp8_recon_recon4
+#define vp8_recon_recon4 vp8_recon4b_c
+#endif
+extern prototype_recon_block(vp8_recon_recon4);
+
+typedef prototype_copy_block((*vp8_copy_block_fn_t));
+typedef prototype_recon_block((*vp8_recon_fn_t));
+typedef struct
+{
+    vp8_copy_block_fn_t  copy16x16;
+    vp8_copy_block_fn_t  copy8x8;
+    vp8_copy_block_fn_t  copy8x4;
+    vp8_recon_fn_t       recon;
+    vp8_recon_fn_t       recon2;
+    vp8_recon_fn_t       recon4;
+} vp8_recon_rtcd_vtable_t;
+
+#if CONFIG_RUNTIME_CPU_DETECT
+#define RECON_INVOKE(ctx,fn) (ctx)->fn
+#else
+#define RECON_INVOKE(ctx,fn) vp8_recon_##fn
+#endif
+
+#include "blockd.h"
+void vp8_recon16x16mby(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x);
+void vp8_recon16x16mb(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x);
+void vp8_recon_intra4x4mb(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x);
+void vp8_recon_intra_mbuv(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x);
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/reconinter.c
@@ -0,0 +1,681 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include "vpx_ports/config.h"
+#include "recon.h"
+#include "subpixel.h"
+#include "blockd.h"
+#include "reconinter.h"
+#if CONFIG_RUNTIME_CPU_DETECT
+#include "onyxc_int.h"
+#endif
+
+// use this define on systems where unaligned int reads and writes are
+// not allowed, i.e. ARM architectures
+//#define MUST_BE_ALIGNED
+
+
+static const int bbb[4] = {0, 2, 8, 10};
+
+
+
+void vp8_copy_mem16x16_c(
+    unsigned char *src,
+    int src_stride,
+    unsigned char *dst,
+    int dst_stride)
+{
+
+    int r;
+
+    for (r = 0; r < 16; r++)
+    {
+#ifdef MUST_BE_ALIGNED
+        dst[0] = src[0];
+        dst[1] = src[1];
+        dst[2] = src[2];
+        dst[3] = src[3];
+        dst[4] = src[4];
+        dst[5] = src[5];
+        dst[6] = src[6];
+        dst[7] = src[7];
+        dst[8] = src[8];
+        dst[9] = src[9];
+        dst[10] = src[10];
+        dst[11] = src[11];
+        dst[12] = src[12];
+        dst[13] = src[13];
+        dst[14] = src[14];
+        dst[15] = src[15];
+
+#else
+        ((int *)dst)[0] = ((int *)src)[0] ;
+        ((int *)dst)[1] = ((int *)src)[1] ;
+        ((int *)dst)[2] = ((int *)src)[2] ;
+        ((int *)dst)[3] = ((int *)src)[3] ;
+
+#endif
+        src += src_stride;
+        dst += dst_stride;
+
+    }
+
+}
+
+void vp8_copy_mem8x8_c(
+    unsigned char *src,
+    int src_stride,
+    unsigned char *dst,
+    int dst_stride)
+{
+    int r;
+
+    for (r = 0; r < 8; r++)
+    {
+#ifdef MUST_BE_ALIGNED
+        dst[0] = src[0];
+        dst[1] = src[1];
+        dst[2] = src[2];
+        dst[3] = src[3];
+        dst[4] = src[4];
+        dst[5] = src[5];
+        dst[6] = src[6];
+        dst[7] = src[7];
+#else
+        ((int *)dst)[0] = ((int *)src)[0] ;
+        ((int *)dst)[1] = ((int *)src)[1] ;
+#endif
+        src += src_stride;
+        dst += dst_stride;
+
+    }
+
+}
+
+void vp8_copy_mem8x4_c(
+    unsigned char *src,
+    int src_stride,
+    unsigned char *dst,
+    int dst_stride)
+{
+    int r;
+
+    for (r = 0; r < 4; r++)
+    {
+#ifdef MUST_BE_ALIGNED
+        dst[0] = src[0];
+        dst[1] = src[1];
+        dst[2] = src[2];
+        dst[3] = src[3];
+        dst[4] = src[4];
+        dst[5] = src[5];
+        dst[6] = src[6];
+        dst[7] = src[7];
+#else
+        ((int *)dst)[0] = ((int *)src)[0] ;
+        ((int *)dst)[1] = ((int *)src)[1] ;
+#endif
+        src += src_stride;
+        dst += dst_stride;
+
+    }
+
+}
+
+
+
+void vp8_build_inter_predictors_b(BLOCKD *d, int pitch, vp8_subpix_fn_t sppf)
+{
+    int r;
+    unsigned char *ptr_base;
+    unsigned char *ptr;
+    unsigned char *pred_ptr = d->predictor;
+
+    ptr_base = *(d->base_pre);
+
+    if (d->bmi.mv.as_mv.row & 7 || d->bmi.mv.as_mv.col & 7)
+    {
+        ptr = ptr_base + d->pre + (d->bmi.mv.as_mv.row >> 3) * d->pre_stride + (d->bmi.mv.as_mv.col >> 3);
+        sppf(ptr, d->pre_stride, d->bmi.mv.as_mv.col & 7, d->bmi.mv.as_mv.row & 7, pred_ptr, pitch);
+    }
+    else
+    {
+        ptr_base += d->pre + (d->bmi.mv.as_mv.row >> 3) * d->pre_stride + (d->bmi.mv.as_mv.col >> 3);
+        ptr = ptr_base;
+
+        for (r = 0; r < 4; r++)
+        {
+#ifdef MUST_BE_ALIGNED
+            pred_ptr[0]  = ptr[0];
+            pred_ptr[1]  = ptr[1];
+            pred_ptr[2]  = ptr[2];
+            pred_ptr[3]  = ptr[3];
+#else
+            *(int *)pred_ptr = *(int *)ptr ;
+#endif
+            pred_ptr     += pitch;
+            ptr         += d->pre_stride;
+        }
+    }
+}
+
+void vp8_build_inter_predictors4b(MACROBLOCKD *x, BLOCKD *d, int pitch)
+{
+    unsigned char *ptr_base;
+    unsigned char *ptr;
+    unsigned char *pred_ptr = d->predictor;
+
+    ptr_base = *(d->base_pre);
+    ptr = ptr_base + d->pre + (d->bmi.mv.as_mv.row >> 3) * d->pre_stride + (d->bmi.mv.as_mv.col >> 3);
+
+    if (d->bmi.mv.as_mv.row & 7 || d->bmi.mv.as_mv.col & 7)
+    {
+        x->subpixel_predict8x8(ptr, d->pre_stride, d->bmi.mv.as_mv.col & 7, d->bmi.mv.as_mv.row & 7, pred_ptr, pitch);
+    }
+    else
+    {
+        RECON_INVOKE(&x->rtcd->recon, copy8x8)(ptr, d->pre_stride, pred_ptr, pitch);
+    }
+}
+
+void vp8_build_inter_predictors2b(MACROBLOCKD *x, BLOCKD *d, int pitch)
+{
+    unsigned char *ptr_base;
+    unsigned char *ptr;
+    unsigned char *pred_ptr = d->predictor;
+
+    ptr_base = *(d->base_pre);
+    ptr = ptr_base + d->pre + (d->bmi.mv.as_mv.row >> 3) * d->pre_stride + (d->bmi.mv.as_mv.col >> 3);
+
+    if (d->bmi.mv.as_mv.row & 7 || d->bmi.mv.as_mv.col & 7)
+    {
+        x->subpixel_predict8x4(ptr, d->pre_stride, d->bmi.mv.as_mv.col & 7, d->bmi.mv.as_mv.row & 7, pred_ptr, pitch);
+    }
+    else
+    {
+        RECON_INVOKE(&x->rtcd->recon, copy8x4)(ptr, d->pre_stride, pred_ptr, pitch);
+    }
+}
+
+
+void vp8_build_inter_predictors_mbuv(MACROBLOCKD *x)
+{
+    int i;
+
+    if (x->mbmi.ref_frame != INTRA_FRAME && x->mbmi.mode != SPLITMV)
+    {
+        unsigned char *uptr, *vptr;
+        unsigned char *upred_ptr = &x->predictor[256];
+        unsigned char *vpred_ptr = &x->predictor[320];
+
+        int mv_row = x->block[16].bmi.mv.as_mv.row;
+        int mv_col = x->block[16].bmi.mv.as_mv.col;
+        int offset;
+        int pre_stride = x->block[16].pre_stride;
+
+        offset = (mv_row >> 3) * pre_stride + (mv_col >> 3);
+        uptr = x->pre.u_buffer + offset;
+        vptr = x->pre.v_buffer + offset;
+
+        if ((mv_row | mv_col) & 7)
+        {
+            x->subpixel_predict8x8(uptr, pre_stride, mv_col & 7, mv_row & 7, upred_ptr, 8);
+            x->subpixel_predict8x8(vptr, pre_stride, mv_col & 7, mv_row & 7, vpred_ptr, 8);
+        }
+        else
+        {
+            RECON_INVOKE(&x->rtcd->recon, copy8x8)(uptr, pre_stride, upred_ptr, 8);
+            RECON_INVOKE(&x->rtcd->recon, copy8x8)(vptr, pre_stride, vpred_ptr, 8);
+        }
+    }
+    else
+    {
+        for (i = 16; i < 24; i += 2)
+        {
+            BLOCKD *d0 = &x->block[i];
+            BLOCKD *d1 = &x->block[i+1];
+
+            if (d0->bmi.mv.as_int == d1->bmi.mv.as_int)
+                vp8_build_inter_predictors2b(x, d0, 8);
+            else
+            {
+                vp8_build_inter_predictors_b(d0, 8, x->subpixel_predict);
+                vp8_build_inter_predictors_b(d1, 8, x->subpixel_predict);
+            }
+        }
+    }
+}
+
+
+void vp8_build_inter_predictors_mby(MACROBLOCKD *x)
+{
+    if (x->mbmi.ref_frame != INTRA_FRAME && x->mbmi.mode != SPLITMV)
+    {
+        unsigned char *ptr_base;
+        unsigned char *ptr;
+        unsigned char *pred_ptr = x->predictor;
+        int mv_row = x->mbmi.mv.as_mv.row;
+        int mv_col = x->mbmi.mv.as_mv.col;
+        int pre_stride = x->block[0].pre_stride;
+
+        ptr_base = x->pre.y_buffer;
+        ptr = ptr_base + (mv_row >> 3) * pre_stride + (mv_col >> 3);
+
+        if ((mv_row | mv_col) & 7)
+        {
+            x->subpixel_predict16x16(ptr, pre_stride, mv_col & 7, mv_row & 7, pred_ptr, 16);
+        }
+        else
+        {
+            RECON_INVOKE(&x->rtcd->recon, copy16x16)(ptr, pre_stride, pred_ptr, 16);
+        }
+    }
+    else
+    {
+        int i;
+
+        if (x->mbmi.partitioning < 3)
+        {
+            for (i = 0; i < 4; i++)
+            {
+                BLOCKD *d = &x->block[bbb[i]];
+                vp8_build_inter_predictors4b(x, d, 16);
+            }
+
+        }
+        else
+        {
+            for (i = 0; i < 16; i += 2)
+            {
+                BLOCKD *d0 = &x->block[i];
+                BLOCKD *d1 = &x->block[i+1];
+
+                if (d0->bmi.mv.as_int == d1->bmi.mv.as_int)
+                    vp8_build_inter_predictors2b(x, d0, 16);
+                else
+                {
+                    vp8_build_inter_predictors_b(d0, 16, x->subpixel_predict);
+                    vp8_build_inter_predictors_b(d1, 16, x->subpixel_predict);
+                }
+
+            }
+        }
+    }
+}
+
+void vp8_build_inter_predictors_mb(MACROBLOCKD *x)
+{
+    if (x->mbmi.ref_frame != INTRA_FRAME && x->mbmi.mode != SPLITMV)
+    {
+        int offset;
+        unsigned char *ptr_base;
+        unsigned char *ptr;
+        unsigned char *uptr, *vptr;
+        unsigned char *pred_ptr = x->predictor;
+        unsigned char *upred_ptr = &x->predictor[256];
+        unsigned char *vpred_ptr = &x->predictor[320];
+
+        int mv_row = x->mbmi.mv.as_mv.row;
+        int mv_col = x->mbmi.mv.as_mv.col;
+        int pre_stride = x->block[0].pre_stride;
+
+        ptr_base = x->pre.y_buffer;
+        ptr = ptr_base + (mv_row >> 3) * pre_stride + (mv_col >> 3);
+
+        if ((mv_row | mv_col) & 7)
+        {
+            x->subpixel_predict16x16(ptr, pre_stride, mv_col & 7, mv_row & 7, pred_ptr, 16);
+        }
+        else
+        {
+            RECON_INVOKE(&x->rtcd->recon, copy16x16)(ptr, pre_stride, pred_ptr, 16);
+        }
+
+        mv_row = x->block[16].bmi.mv.as_mv.row;
+        mv_col = x->block[16].bmi.mv.as_mv.col;
+        pre_stride >>= 1;
+        offset = (mv_row >> 3) * pre_stride + (mv_col >> 3);
+        uptr = x->pre.u_buffer + offset;
+        vptr = x->pre.v_buffer + offset;
+
+        if ((mv_row | mv_col) & 7)
+        {
+            x->subpixel_predict8x8(uptr, pre_stride, mv_col & 7, mv_row & 7, upred_ptr, 8);
+            x->subpixel_predict8x8(vptr, pre_stride, mv_col & 7, mv_row & 7, vpred_ptr, 8);
+        }
+        else
+        {
+            RECON_INVOKE(&x->rtcd->recon, copy8x8)(uptr, pre_stride, upred_ptr, 8);
+            RECON_INVOKE(&x->rtcd->recon, copy8x8)(vptr, pre_stride, vpred_ptr, 8);
+        }
+    }
+    else
+    {
+        int i;
+
+        if (x->mbmi.partitioning < 3)
+        {
+            for (i = 0; i < 4; i++)
+            {
+                BLOCKD *d = &x->block[bbb[i]];
+                vp8_build_inter_predictors4b(x, d, 16);
+            }
+        }
+        else
+        {
+            for (i = 0; i < 16; i += 2)
+            {
+                BLOCKD *d0 = &x->block[i];
+                BLOCKD *d1 = &x->block[i+1];
+
+                if (d0->bmi.mv.as_int == d1->bmi.mv.as_int)
+                    vp8_build_inter_predictors2b(x, d0, 16);
+                else
+                {
+                    vp8_build_inter_predictors_b(d0, 16, x->subpixel_predict);
+                    vp8_build_inter_predictors_b(d1, 16, x->subpixel_predict);
+                }
+
+            }
+
+        }
+
+        for (i = 16; i < 24; i += 2)
+        {
+            BLOCKD *d0 = &x->block[i];
+            BLOCKD *d1 = &x->block[i+1];
+
+            if (d0->bmi.mv.as_int == d1->bmi.mv.as_int)
+                vp8_build_inter_predictors2b(x, d0, 8);
+            else
+            {
+                vp8_build_inter_predictors_b(d0, 8, x->subpixel_predict);
+                vp8_build_inter_predictors_b(d1, 8, x->subpixel_predict);
+            }
+
+        }
+
+    }
+}
+
+void vp8_build_uvmvs(MACROBLOCKD *x, int fullpixel)
+{
+    int i, j;
+
+    if (x->mbmi.mode == SPLITMV)
+    {
+        for (i = 0; i < 2; i++)
+        {
+            for (j = 0; j < 2; j++)
+            {
+                int yoffset = i * 8 + j * 2;
+                int uoffset = 16 + i * 2 + j;
+                int voffset = 20 + i * 2 + j;
+
+                int temp;
+
+                temp = x->block[yoffset  ].bmi.mv.as_mv.row
+                       + x->block[yoffset+1].bmi.mv.as_mv.row
+                       + x->block[yoffset+4].bmi.mv.as_mv.row
+                       + x->block[yoffset+5].bmi.mv.as_mv.row;
+
+                if (temp < 0) temp -= 4;
+                else temp += 4;
+
+                x->block[uoffset].bmi.mv.as_mv.row = temp / 8;
+
+                if (fullpixel)
+                    x->block[uoffset].bmi.mv.as_mv.row = (temp / 8) & 0xfffffff8;
+
+                temp = x->block[yoffset  ].bmi.mv.as_mv.col
+                       + x->block[yoffset+1].bmi.mv.as_mv.col
+                       + x->block[yoffset+4].bmi.mv.as_mv.col
+                       + x->block[yoffset+5].bmi.mv.as_mv.col;
+
+                if (temp < 0) temp -= 4;
+                else temp += 4;
+
+                x->block[uoffset].bmi.mv.as_mv.col = temp / 8;
+
+                if (fullpixel)
+                    x->block[uoffset].bmi.mv.as_mv.col = (temp / 8) & 0xfffffff8;
+
+                x->block[voffset].bmi.mv.as_mv.row = x->block[uoffset].bmi.mv.as_mv.row ;
+                x->block[voffset].bmi.mv.as_mv.col = x->block[uoffset].bmi.mv.as_mv.col ;
+            }
+        }
+    }
+    else
+    {
+        int mvrow = x->mbmi.mv.as_mv.row;
+        int mvcol = x->mbmi.mv.as_mv.col;
+
+        if (mvrow < 0)
+            mvrow -= 1;
+        else
+            mvrow += 1;
+
+        if (mvcol < 0)
+            mvcol -= 1;
+        else
+            mvcol += 1;
+
+        mvrow /= 2;
+        mvcol /= 2;
+
+        for (i = 0; i < 8; i++)
+        {
+            x->block[ 16 + i].bmi.mv.as_mv.row = mvrow;
+            x->block[ 16 + i].bmi.mv.as_mv.col = mvcol;
+
+            if (fullpixel)
+            {
+                x->block[ 16 + i].bmi.mv.as_mv.row = mvrow & 0xfffffff8;
+                x->block[ 16 + i].bmi.mv.as_mv.col = mvcol & 0xfffffff8;
+            }
+        }
+    }
+}
+
+
+// The following functions are wriiten for skip_recon_mb() to call. Since there is no recon in this
+// situation, we can write the result directly to dst buffer instead of writing it to predictor
+// buffer and then copying it to dst buffer.
+static void vp8_build_inter_predictors_b_s(BLOCKD *d, unsigned char *dst_ptr, vp8_subpix_fn_t sppf)
+{
+    int r;
+    unsigned char *ptr_base;
+    unsigned char *ptr;
+    //unsigned char *pred_ptr = d->predictor;
+    int dst_stride = d->dst_stride;
+    int pre_stride = d->pre_stride;
+
+    ptr_base = *(d->base_pre);
+
+    if (d->bmi.mv.as_mv.row & 7 || d->bmi.mv.as_mv.col & 7)
+    {
+        ptr = ptr_base + d->pre + (d->bmi.mv.as_mv.row >> 3) * d->pre_stride + (d->bmi.mv.as_mv.col >> 3);
+        sppf(ptr, pre_stride, d->bmi.mv.as_mv.col & 7, d->bmi.mv.as_mv.row & 7, dst_ptr, dst_stride);
+    }
+    else
+    {
+        ptr_base += d->pre + (d->bmi.mv.as_mv.row >> 3) * d->pre_stride + (d->bmi.mv.as_mv.col >> 3);
+        ptr = ptr_base;
+
+        for (r = 0; r < 4; r++)
+        {
+#ifdef MUST_BE_ALIGNED
+            dst_ptr[0]   = ptr[0];
+            dst_ptr[1]   = ptr[1];
+            dst_ptr[2]   = ptr[2];
+            dst_ptr[3]   = ptr[3];
+#else
+            *(int *)dst_ptr = *(int *)ptr ;
+#endif
+            dst_ptr      += dst_stride;
+            ptr         += pre_stride;
+        }
+    }
+}
+
+
+
+void vp8_build_inter_predictors_mb_s(MACROBLOCKD *x)
+{
+    //unsigned char *pred_ptr = x->block[0].predictor;
+    //unsigned char *dst_ptr = *(x->block[0].base_dst) + x->block[0].dst;
+    unsigned char *pred_ptr = x->predictor;
+    unsigned char *dst_ptr = x->dst.y_buffer;
+
+    if (x->mbmi.mode != SPLITMV)
+    {
+        int offset;
+        unsigned char *ptr_base;
+        unsigned char *ptr;
+        unsigned char *uptr, *vptr;
+        //unsigned char *pred_ptr = x->predictor;
+        //unsigned char *upred_ptr = &x->predictor[256];
+        //unsigned char *vpred_ptr = &x->predictor[320];
+        unsigned char *udst_ptr = x->dst.u_buffer;
+        unsigned char *vdst_ptr = x->dst.v_buffer;
+
+        int mv_row = x->mbmi.mv.as_mv.row;
+        int mv_col = x->mbmi.mv.as_mv.col;
+        int pre_stride = x->dst.y_stride; //x->block[0].pre_stride;
+
+        ptr_base = x->pre.y_buffer;
+        ptr = ptr_base + (mv_row >> 3) * pre_stride + (mv_col >> 3);
+
+        if ((mv_row | mv_col) & 7)
+        {
+            x->subpixel_predict16x16(ptr, pre_stride, mv_col & 7, mv_row & 7, dst_ptr, x->dst.y_stride); //x->block[0].dst_stride);
+        }
+        else
+        {
+            RECON_INVOKE(&x->rtcd->recon, copy16x16)(ptr, pre_stride, dst_ptr, x->dst.y_stride); //x->block[0].dst_stride);
+        }
+
+        mv_row = x->block[16].bmi.mv.as_mv.row;
+        mv_col = x->block[16].bmi.mv.as_mv.col;
+        pre_stride >>= 1;
+        offset = (mv_row >> 3) * pre_stride + (mv_col >> 3);
+        uptr = x->pre.u_buffer + offset;
+        vptr = x->pre.v_buffer + offset;
+
+        if ((mv_row | mv_col) & 7)
+        {
+            x->subpixel_predict8x8(uptr, pre_stride, mv_col & 7, mv_row & 7, udst_ptr, x->dst.uv_stride);
+            x->subpixel_predict8x8(vptr, pre_stride, mv_col & 7, mv_row & 7, vdst_ptr, x->dst.uv_stride);
+        }
+        else
+        {
+            RECON_INVOKE(&x->rtcd->recon, copy8x8)(uptr, pre_stride, udst_ptr, x->dst.uv_stride);
+            RECON_INVOKE(&x->rtcd->recon, copy8x8)(vptr, pre_stride, vdst_ptr, x->dst.uv_stride);
+        }
+    }
+    else
+    {
+        //note: this whole ELSE part is not executed at all. So, no way to test the correctness of my modification. Later,
+        //if sth is wrong, go back to what it is in build_inter_predictors_mb.
+        int i;
+
+        if (x->mbmi.partitioning < 3)
+        {
+            for (i = 0; i < 4; i++)
+            {
+                BLOCKD *d = &x->block[bbb[i]];
+                //vp8_build_inter_predictors4b(x, d, 16);
+
+                {
+                    unsigned char *ptr_base;
+                    unsigned char *ptr;
+                    unsigned char *pred_ptr = d->predictor;
+
+                    ptr_base = *(d->base_pre);
+                    ptr = ptr_base + d->pre + (d->bmi.mv.as_mv.row >> 3) * d->pre_stride + (d->bmi.mv.as_mv.col >> 3);
+
+                    if (d->bmi.mv.as_mv.row & 7 || d->bmi.mv.as_mv.col & 7)
+                    {
+                        x->subpixel_predict8x8(ptr, d->pre_stride, d->bmi.mv.as_mv.col & 7, d->bmi.mv.as_mv.row & 7, dst_ptr, x->dst.y_stride); //x->block[0].dst_stride);
+                    }
+                    else
+                    {
+                        RECON_INVOKE(&x->rtcd->recon, copy8x8)(ptr, d->pre_stride, dst_ptr, x->dst.y_stride); //x->block[0].dst_stride);
+                    }
+                }
+            }
+        }
+        else
+        {
+            for (i = 0; i < 16; i += 2)
+            {
+                BLOCKD *d0 = &x->block[i];
+                BLOCKD *d1 = &x->block[i+1];
+
+                if (d0->bmi.mv.as_int == d1->bmi.mv.as_int)
+                {
+                    //vp8_build_inter_predictors2b(x, d0, 16);
+                    unsigned char *ptr_base;
+                    unsigned char *ptr;
+                    unsigned char *pred_ptr = d0->predictor;
+
+                    ptr_base = *(d0->base_pre);
+                    ptr = ptr_base + d0->pre + (d0->bmi.mv.as_mv.row >> 3) * d0->pre_stride + (d0->bmi.mv.as_mv.col >> 3);
+
+                    if (d0->bmi.mv.as_mv.row & 7 || d0->bmi.mv.as_mv.col & 7)
+                    {
+                        x->subpixel_predict8x4(ptr, d0->pre_stride, d0->bmi.mv.as_mv.col & 7, d0->bmi.mv.as_mv.row & 7, dst_ptr, x->dst.y_stride);
+                    }
+                    else
+                    {
+                        RECON_INVOKE(&x->rtcd->recon, copy8x4)(ptr, d0->pre_stride, dst_ptr, x->dst.y_stride);
+                    }
+                }
+                else
+                {
+                    vp8_build_inter_predictors_b_s(d0, dst_ptr, x->subpixel_predict);
+                    vp8_build_inter_predictors_b_s(d1, dst_ptr, x->subpixel_predict);
+                }
+            }
+        }
+
+        for (i = 16; i < 24; i += 2)
+        {
+            BLOCKD *d0 = &x->block[i];
+            BLOCKD *d1 = &x->block[i+1];
+
+            if (d0->bmi.mv.as_int == d1->bmi.mv.as_int)
+            {
+                //vp8_build_inter_predictors2b(x, d0, 8);
+                unsigned char *ptr_base;
+                unsigned char *ptr;
+                unsigned char *pred_ptr = d0->predictor;
+
+                ptr_base = *(d0->base_pre);
+                ptr = ptr_base + d0->pre + (d0->bmi.mv.as_mv.row >> 3) * d0->pre_stride + (d0->bmi.mv.as_mv.col >> 3);
+
+                if (d0->bmi.mv.as_mv.row & 7 || d0->bmi.mv.as_mv.col & 7)
+                {
+                    x->subpixel_predict8x4(ptr, d0->pre_stride, d0->bmi.mv.as_mv.col & 7, d0->bmi.mv.as_mv.row & 7, dst_ptr, x->dst.y_stride);
+                }
+                else
+                {
+                    RECON_INVOKE(&x->rtcd->recon, copy8x4)(ptr, d0->pre_stride, dst_ptr, x->dst.y_stride);
+                }
+            }
+            else
+            {
+                vp8_build_inter_predictors_b_s(d0, dst_ptr, x->subpixel_predict);
+                vp8_build_inter_predictors_b_s(d1, dst_ptr, x->subpixel_predict);
+            }
+        }
+    }
+}
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/reconinter.h
@@ -0,0 +1,23 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#ifndef __INC_RECONINTER_H
+#define __INC_RECONINTER_H
+
+extern void vp8_build_inter_predictors_mb(MACROBLOCKD *x);
+extern void vp8_build_inter_predictors_mb_s(MACROBLOCKD *x);
+
+extern void vp8_build_inter_predictors_mby(MACROBLOCKD *x);
+extern void vp8_build_uvmvs(MACROBLOCKD *x, int fullpixel);
+extern void vp8_build_inter_predictors_b(BLOCKD *d, int pitch, vp8_subpix_fn_t sppf);
+extern void vp8_build_inter_predictors_mbuv(MACROBLOCKD *x);
+
+#endif
new file mode 100644
--- /dev/null
+++ b/media/libvpx/vp8/common/reconintra.c
@@ -0,0 +1,556 @@
+/*
+ *  Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
+ *
+ *  Use of this source code is governed by a BSD-style license 
+ *  that can be found in the LICENSE file in the root of the source
+ *  tree. An additional intellectual property rights grant can be found
+ *  in the file PATENTS.  All contributing project authors may 
+ *  be found in the AUTHORS file in the root of the source tree.
+ */
+
+
+#include "vpx_ports/config.h"
+#include "recon.h"
+#include "reconintra.h"
+#include "vpx_mem/vpx_mem.h"
+
+// For skip_recon_mb(), add vp8_build_intra_predictors_mby_s(MACROBLOCKD *x) and
+// vp8_build_intra_predictors_mbuv_s(MACROBLOCKD *x).
+
+void vp8_recon_intra_mbuv(const vp8_recon_rtcd_vtable_t *rtcd, MACROBLOCKD *x)
+{
+    int i;
+
+    for (i = 16; i < 24; i += 2)
+    {
+        BLOCKD *b = &x->block[i];
+        RECON_INVOKE(rtcd, recon2)(b->predictor, b->diff, *(b->base_dst) + b->dst, b->dst_stride);
+    }
+}
+
+void vp8_build_intra_predictors_mby(MACROBLOCKD *x)
+{
+
+    unsigned char *yabove_row = x->dst.y_buffer - x->dst.y_stride;
+    unsigned char yleft_col[16];
+    unsigned char ytop_left = yabove_row[-1];
+    unsigned char *ypred_ptr = x->predictor;
+    int r, c, i;
+
+    for (i = 0; i < 16; i++)
+    {
+        yleft_col[i] = x->dst.y_buffer [i* x->dst.y_stride -1];
+    }
+
+    // for Y
+    switch (x->mbmi.mode)
+    {
+    case DC_PRED:
+    {
+        int expected_dc;
+        int i;
+        int shift;
+        int average = 0;
+
+
+        if (x->up_available || x->left_available)
+        {
+            if (x->up_available)
+            {
+                for (i = 0; i < 16; i++)
+                {
+                    average += yabove_row[i];
+                }
+            }
+
+            if (x->left_available)
+            {
+
+                for (i = 0; i < 16; i++)
+                {
+                    average += yleft_col[i];
+                }
+
+            }
+
+
+
+            shift = 3 + x->up_available + x->left_available;
+            expected_dc = (average + (1 << (shift - 1))) >> shift;
+        }
+        else
+        {
+            expected_dc = 128;
+        }
+
+        vpx_memset(ypred_ptr, expected_dc, 256);
+    }
+    break;
+    case V_PRED:
+    {
+
+        for (r = 0; r < 16; r++)
+        {
+
+            ((int *)ypred_ptr)[0] = ((int *)yabove_row)[0];
+            ((int *)ypred_ptr)[1] = ((int *)yabove_row)[1];
+            ((int *)ypred_ptr)[2] = ((int *)yabove_row)[2];
+            ((int *)ypred_ptr)[3] = ((int *)yabove_row)[3];
+            ypred_ptr += 16;
+        }
+    }
+    break;
+    case H_PRED:
+    {
+
+        for (r = 0; r < 16; r++)
+        {
+
+            vpx_memset(ypred_ptr, yleft_col[r], 16);
+            ypred_ptr += 16;
+        }
+
+    }
+    break;
+    case TM_PRED:
+    {
+
+        for (r = 0; r < 16; r++)
+        {
+            for (c = 0; c < 16; c++)
+            {
+                int pred =  yleft_col[r] + yabove_row[ c] - ytop_left;
+
+                if (pred < 0)
+                    pred = 0;
+
+                if (pred > 255)
+                    pred = 255;
+
+                ypred_ptr[c] = pred;
+            }
+
+            ypred_ptr += 16;
+        }
+
+    }
+    break;
+    case B_PRED:
+    case NEARESTMV:
+    case NEARMV:
+    case ZEROMV:
+    case NEWMV:
+    case SPLITMV:
+    case MB_MODE_COUNT:
+        break;
+    }
+}
+
+void vp8_build_intra_predictors_mby_s(MACROBLOCKD *x)
+{
+
+    unsigned char *yabove_row = x->dst.y_buffer - x->dst.y_stride;
+    unsigned char yleft_col[16];
+    unsigned char ytop_left = yabove_row[-1];
+    unsigned char *ypred_ptr = x->predictor;
+    int r, c, i;
+
+    int y_stride = x->dst.y_stride;
+    ypred_ptr = x->dst.y_buffer; //x->predictor;
+
+    for (i = 0; i < 16; i++)
+    {
+        yleft_col[i] = x->dst.y_buffer [i* x->dst.y_stride -1];
+    }
+
+    // for Y
+    switch (x->mbmi.mode)
+    {
+    case DC_PRED:
+    {
+        int expected_dc;
+        int i;
+        int shift;
+        int average = 0;
+
+
+        if (x->up_available || x->left_available)
+        {
+            if (x->up_available)