From 3ebbdaa94863ae892d63a6677e5c79f943fefbd3 Mon Sep 17 00:00:00 2001
From: Michael Wild <themiwi@users.sourceforge.net>
Date: Fri, 17 Jul 2009 10:45:51 +0200
Subject: [PATCH 1/3] ENH: Added vtkoggtheora library (Ogg/Theora) to VTK

Signed-off-by: Michael Wild <themiwi@users.sourceforge.net>
---
 VTK/CMake/FindOGGTHEORA.cmake                      |   48 +
 VTK/CMakeLists.txt                                 |    1 +
 VTK/IO/CMakeLists.txt                              |    2 +-
 VTK/Utilities/CMakeLists.txt                       |    2 +
 VTK/Utilities/vtk_oggtheora.h                      |   29 +
 VTK/Utilities/vtkoggtheora/.NoDartCoverage         |    1 +
 VTK/Utilities/vtkoggtheora/CMakeLists.txt          |  273 ++
 VTK/Utilities/vtkoggtheora/README.Kitware.txt      |   36 +
 VTK/Utilities/vtkoggtheora/libogg-1.1.4/AUTHORS    |    4 +
 VTK/Utilities/vtkoggtheora/libogg-1.1.4/CHANGES    |   42 +
 VTK/Utilities/vtkoggtheora/libogg-1.1.4/COPYING    |   28 +
 VTK/Utilities/vtkoggtheora/libogg-1.1.4/README     |  133 +
 .../libogg-1.1.4/include/ogg/config_types.h.in     |   20 +
 .../vtkoggtheora/libogg-1.1.4/include/ogg/ogg.h    |  209 +
 .../libogg-1.1.4/include/ogg/os_types.h            |  143 +
 .../vtkoggtheora/libogg-1.1.4/src/bitwise.c        |  823 ++++
 .../vtkoggtheora/libogg-1.1.4/src/framing.c        | 1881 +++++++++
 .../vtkoggtheora/libtheora-1.1alpha2/AUTHORS       |   47 +
 .../vtkoggtheora/libtheora-1.1alpha2/CHANGES       |  189 +
 .../vtkoggtheora/libtheora-1.1alpha2/COPYING       |   28 +
 .../vtkoggtheora/libtheora-1.1alpha2/LICENSE       |   18 +
 .../vtkoggtheora/libtheora-1.1alpha2/README        |  150 +
 .../vtkoggtheora/libtheora-1.1alpha2/config.h.in   |   43 +
 .../libtheora-1.1alpha2/examples/encoder_example.c | 1544 ++++++++
 .../libtheora-1.1alpha2/include/theora/codec.h     |  595 +++
 .../libtheora-1.1alpha2/include/theora/theora.h    |  823 ++++
 .../libtheora-1.1alpha2/include/theora/theoradec.h |  311 ++
 .../libtheora-1.1alpha2/include/theora/theoraenc.h |  293 ++
 .../vtkoggtheora/libtheora-1.1alpha2/lib/cpu.c     |  226 ++
 .../vtkoggtheora/libtheora-1.1alpha2/lib/cpu.h     |   34 +
 .../libtheora-1.1alpha2/lib/dec/apiwrapper.c       |  166 +
 .../libtheora-1.1alpha2/lib/dec/apiwrapper.h       |   56 +
 .../libtheora-1.1alpha2/lib/dec/bitpack.h          |   39 +
 .../vtkoggtheora/libtheora-1.1alpha2/lib/dec/dct.h |   31 +
 .../libtheora-1.1alpha2/lib/dec/decint.h           |  100 +
 .../libtheora-1.1alpha2/lib/dec/dequant.h          |   26 +
 .../libtheora-1.1alpha2/lib/dec/fragment.c         |  205 +
 .../libtheora-1.1alpha2/lib/dec/huffdec.h          |   91 +
 .../libtheora-1.1alpha2/lib/dec/huffman.h          |   71 +
 .../libtheora-1.1alpha2/lib/dec/idct.c             |  370 ++
 .../libtheora-1.1alpha2/lib/dec/info.c             |  123 +
 .../libtheora-1.1alpha2/lib/dec/internal.c         |  379 ++
 .../libtheora-1.1alpha2/lib/dec/ocintrin.h         |  117 +
 .../libtheora-1.1alpha2/lib/dec/quant.h            |   35 +
 .../libtheora-1.1alpha2/lib/dec/x86/mmxfrag.c      |  293 ++
 .../libtheora-1.1alpha2/lib/dec/x86/mmxfrag.h      |   64 +
 .../libtheora-1.1alpha2/lib/dec/x86/mmxidct.c      |  651 ++++
 .../libtheora-1.1alpha2/lib/dec/x86/mmxloop.h      |  215 ++
 .../libtheora-1.1alpha2/lib/dec/x86/x86int.h       |   45 +
 .../libtheora-1.1alpha2/lib/dec/x86_vc/mmxfrag.c   |  214 ++
 .../libtheora-1.1alpha2/lib/dec/x86_vc/mmxidct.c   | 1007 +++++
 .../lib/dec/x86_vc/mmxloopfilter.c                 |  377 ++
 .../libtheora-1.1alpha2/lib/dec/x86_vc/mmxstate.c  |  189 +
 .../libtheora-1.1alpha2/lib/dec/x86_vc/x86int.h    |   49 +
 .../libtheora-1.1alpha2/lib/dec/x86_vc/x86state.c  |   41 +
 .../libtheora-1.1alpha2/lib/enc/codec_internal.h   |  531 +++
 .../vtkoggtheora/libtheora-1.1alpha2/lib/enc/dct.c |  158 +
 .../libtheora-1.1alpha2/lib/enc/dct_decode.c       |  232 ++
 .../libtheora-1.1alpha2/lib/enc/dct_encode.c       |  783 ++++
 .../libtheora-1.1alpha2/lib/enc/encapiwrapper.c    |  330 ++
 .../libtheora-1.1alpha2/lib/enc/encfrag.c          |  397 ++
 .../libtheora-1.1alpha2/lib/enc/encode.c           |  460 +++
 .../libtheora-1.1alpha2/lib/enc/encoder_disabled.c |   51 +
 .../libtheora-1.1alpha2/lib/enc/encoder_huffman.h  |   76 +
 .../libtheora-1.1alpha2/lib/enc/encoder_lookup.h   |  161 +
 .../libtheora-1.1alpha2/lib/enc/encoder_quant.c    |  293 ++
 .../libtheora-1.1alpha2/lib/enc/encoder_toplevel.c |  835 ++++
 .../libtheora-1.1alpha2/lib/enc/enquant.h          |   26 +
 .../libtheora-1.1alpha2/lib/enc/frarray.c          |  418 ++
 .../libtheora-1.1alpha2/lib/enc/frinit.c           |  417 ++
 .../libtheora-1.1alpha2/lib/enc/huffenc.c          |  911 +++++
 .../libtheora-1.1alpha2/lib/enc/huffenc.h          |   19 +
 .../libtheora-1.1alpha2/lib/enc/hufftables.h       | 1034 +++++
 .../libtheora-1.1alpha2/lib/enc/mathops.c          |  296 ++
 .../libtheora-1.1alpha2/lib/enc/mathops.h          |  142 +
 .../libtheora-1.1alpha2/lib/enc/mcenc.c            |  757 ++++
 .../libtheora-1.1alpha2/lib/enc/mode.c             | 1497 ++++++++
 .../libtheora-1.1alpha2/lib/enc/modedec.h          | 4027 ++++++++++++++++++++
 .../libtheora-1.1alpha2/lib/enc/quant_lookup.h     |   54 +
 .../libtheora-1.1alpha2/lib/enc/toplevel_lookup.h  |  134 +
 .../libtheora-1.1alpha2/lib/enc/x86/dsp_sse2.c     |   92 +
 .../libtheora-1.1alpha2/lib/enc/x86/mmxenc.c       |   64 +
 .../libtheora-1.1alpha2/lib/enc/x86/mmxencfrag.c   |  901 +++++
 .../libtheora-1.1alpha2/lib/enc/x86/mmxfdct.c      |  660 ++++
 .../libtheora-1.1alpha2/lib/enc/x86/sse2fdct.c     |  518 +++
 .../libtheora-1.1alpha2/lib/enc/x86/x86enc.c       |   53 +
 .../libtheora-1.1alpha2/lib/enc/x86/x86enc.h       |   48 +
 .../lib/enc/x86_32_vs/dsp_mmx.c                    | 1603 ++++++++
 .../lib/enc/x86_32_vs/fdct_mmx.c                   |  334 ++
 .../lib/enc/x86_32_vs/recon_mmx.c                  |  103 +
 .../libtheora-1.1alpha2/lib/internal.h             |  529 +++
 VTK/Utilities/vtkoggtheora/vtk_oggtheora_mangle.h  |  405 ++
 VTK/Utilities/vtkoggtheora/vtkoggtheora.def        |   16 +
 VTK/Utilities/vtkoggtheora/vtkoggtheora.exp        |   14 +
 VTK/Utilities/vtkoggtheora/vtkoggtheora.rc         |   32 +
 VTK/Utilities/vtkoggtheora/vtkoggtheora.vscript    |   19 +
 VTK/vtkIncludeDirectories.cmake                    |    1 +
 VTK/vtkToolkits.h.in                               |    1 +
 98 files changed, 32361 insertions(+), 1 deletions(-)
 create mode 100644 VTK/CMake/FindOGGTHEORA.cmake
 create mode 100644 VTK/Utilities/vtk_oggtheora.h
 create mode 100644 VTK/Utilities/vtkoggtheora/.NoDartCoverage
 create mode 100644 VTK/Utilities/vtkoggtheora/CMakeLists.txt
 create mode 100644 VTK/Utilities/vtkoggtheora/README.Kitware.txt
 create mode 100644 VTK/Utilities/vtkoggtheora/libogg-1.1.4/AUTHORS
 create mode 100644 VTK/Utilities/vtkoggtheora/libogg-1.1.4/CHANGES
 create mode 100644 VTK/Utilities/vtkoggtheora/libogg-1.1.4/COPYING
 create mode 100644 VTK/Utilities/vtkoggtheora/libogg-1.1.4/README
 create mode 100644 VTK/Utilities/vtkoggtheora/libogg-1.1.4/include/ogg/config_types.h.in
 create mode 100644 VTK/Utilities/vtkoggtheora/libogg-1.1.4/include/ogg/ogg.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libogg-1.1.4/include/ogg/os_types.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libogg-1.1.4/src/bitwise.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libogg-1.1.4/src/framing.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/AUTHORS
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/CHANGES
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/COPYING
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/LICENSE
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/README
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/config.h.in
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/examples/encoder_example.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/include/theora/codec.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/include/theora/theora.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/include/theora/theoradec.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/include/theora/theoraenc.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/cpu.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/cpu.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/apiwrapper.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/apiwrapper.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/bitpack.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/dct.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/decint.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/dequant.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/fragment.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/huffdec.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/huffman.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/idct.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/info.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/internal.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/ocintrin.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/quant.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/mmxfrag.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/mmxfrag.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/mmxidct.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/mmxloop.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/x86int.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/mmxfrag.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/mmxidct.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/mmxloopfilter.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/mmxstate.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/x86int.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/x86state.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/codec_internal.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/dct.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/dct_decode.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/dct_encode.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encapiwrapper.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encfrag.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encode.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_disabled.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_huffman.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_lookup.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_quant.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_toplevel.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/enquant.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/frarray.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/frinit.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/huffenc.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/huffenc.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/hufftables.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/mathops.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/mathops.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/mcenc.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/mode.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/modedec.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/quant_lookup.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/toplevel_lookup.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/dsp_sse2.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/mmxenc.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/mmxencfrag.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/mmxfdct.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/sse2fdct.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/x86enc.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/x86enc.h
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86_32_vs/dsp_mmx.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86_32_vs/fdct_mmx.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86_32_vs/recon_mmx.c
 create mode 100644 VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/internal.h
 create mode 100644 VTK/Utilities/vtkoggtheora/vtk_oggtheora_mangle.h
 create mode 100644 VTK/Utilities/vtkoggtheora/vtkoggtheora.def
 create mode 100644 VTK/Utilities/vtkoggtheora/vtkoggtheora.exp
 create mode 100644 VTK/Utilities/vtkoggtheora/vtkoggtheora.rc
 create mode 100644 VTK/Utilities/vtkoggtheora/vtkoggtheora.vscript

diff --git a/VTK/CMake/FindOGGTHEORA.cmake b/VTK/CMake/FindOGGTHEORA.cmake
new file mode 100644
index 0000000..4446db4
--- /dev/null
+++ b/VTK/CMake/FindOGGTHEORA.cmake
@@ -0,0 +1,48 @@
+#
+# Find the native Ogg/Theora includes and libraries
+#
+# This module defines
+# OGGTHEORA_INCLUDE_DIR, where to find ogg/ogg.h and theora/theora.h
+# OGGTHEORA_LIBRARIES, the libraries to link against to use Ogg/Theora.
+# OGGTHEORA_FOUND, If false, do not try to use Ogg/Theora.
+
+FIND_PATH(OGGTHEORA_ogg_INCLUDE_DIR ogg/ogg.h)
+
+FIND_PATH(OGGTHEORA_theora_INCLUDE_DIR theora/theora.h)
+
+FIND_LIBRARY(OGGTHEORA_ogg_LIBRARY ogg)
+
+FIND_LIBRARY(OGGTHEORA_theoraenc_LIBRARY theoraenc)
+
+FIND_LIBRARY(OGGTHEORA_theoradec_LIBRARY theoradec)
+
+SET(OGGTHEORA_INCLUDE_DIRS
+  ${OGGTHEORA_ogg_INCLUDE_DIR}
+  ${OGGTHEORA_theora_INCLUDE_DIR}
+  )
+#HACK multiple directories
+SET(OGGTHEORA_INCLUDE_DIR ${OGGTHEORA_INCLUDE_DIRS})
+
+SET(OGGTHEORA_LIBRARIES
+  ${OGGTHEORA_ogg_LIBRARY}
+  ${OGGTHEORA_theoraenc_LIBRARY}
+  ${OGGTHEORA_theoradec_LIBRARY}
+  )
+#HACK multiple libraries
+SET(OGGTHEORA_LIBRARY ${OGGTHEORA_LIBRARIES})
+
+GET_FILENAME_COMPONENT(_CURRENT_DIR  "${CMAKE_CURRENT_LIST_FILE}" PATH)
+INCLUDE(${_CURRENT_DIR}/FindPackageHandleStandardArgs.cmake)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(OGGTHEORA
+  "Could NOT find the ogg and theora libraries"
+  OGGTHEORA_ogg_LIBRARY
+  OGGTHEORA_theoraenc_LIBRARY
+  OGGTHEORA_theoradec_LIBRARY
+  OGGTHEORA_ogg_INCLUDE_DIR
+  OGGTHEORA_theora_INCLUDE_DIR
+  )
+
+MARK_AS_ADVANCED(OGGTHEORA_ogg_INCLUDE_DIR OGGTHEORA_theora_INCLUDE_DIR
+  OGGTHEORA_ogg_LIBRARY OGGTHEORA_theoraenc_LIBRARY
+  OGGTHEORA_theoradec_LIBRARY
+  )
diff --git a/VTK/CMakeLists.txt b/VTK/CMakeLists.txt
index 1545b80..bf89b7b 100644
--- a/VTK/CMakeLists.txt
+++ b/VTK/CMakeLists.txt
@@ -664,6 +664,7 @@ VTK_THIRD_PARTY_OPTION(EXPAT expat)
 VTK_THIRD_PARTY_OPTION(FREETYPE freetype)
 VTK_THIRD_PARTY_OPTION(LIBXML2 libxml2)
 VTK_THIRD_PARTY_OPTION(LIBPROJ4 proj4)
+VTK_THIRD_PARTY_OPTION(OGGTHEORA oggtheora)
 
 #-----------------------------------------------------------------------------
 # Configure OpenGL support.
diff --git a/VTK/IO/CMakeLists.txt b/VTK/IO/CMakeLists.txt
index 9930ce3..84d78ac 100644
--- a/VTK/IO/CMakeLists.txt
+++ b/VTK/IO/CMakeLists.txt
@@ -13,7 +13,7 @@ SET(KIT_PYTHON_LIBS vtkFilteringPythonD)
 SET(KIT_JAVA_LIBS vtkFilteringJava)
 SET(KIT_LIBS vtkFiltering vtkDICOMParser vtkNetCDF ${_VTK_METAIO_LIB} vtksqlite
   ${VTK_PNG_LIBRARIES} ${VTK_ZLIB_LIBRARIES} ${VTK_JPEG_LIBRARIES}
-  ${VTK_TIFF_LIBRARIES} ${VTK_EXPAT_LIBRARIES}
+  ${VTK_TIFF_LIBRARIES} ${VTK_EXPAT_LIBRARIES} ${VTK_OGGTHEORA_LIBRARIES}
   ${KWSYS_NAMESPACE})
 
 SET( Kit_SRCS
diff --git a/VTK/Utilities/CMakeLists.txt b/VTK/Utilities/CMakeLists.txt
index 4f8534c..dfa1b2a 100644
--- a/VTK/Utilities/CMakeLists.txt
+++ b/VTK/Utilities/CMakeLists.txt
@@ -14,6 +14,7 @@ VTK_THIRD_PARTY_SUBDIR(DICOMParser DICOMParser)
 VTK_THIRD_PARTY_SUBDIR(MATERIALLIBRARY MaterialLibrary)
 VTK_THIRD_PARTY_SUBDIR(LIBPROJ4 vtklibproj4)
 VTK_THIRD_PARTY_SUBDIR(MRMPI mrmpi)
+VTK_THIRD_PARTY_SUBDIR(OGGTHEORA vtkoggtheora)
 
 # Force build options for verdict
 SET( VERDICT_USE_FLOAT OFF CACHE BOOL "VTK requires doubles" FORCE )
@@ -67,6 +68,7 @@ IF(NOT VTK_INSTALL_NO_DEVELOPMENT)
     vtk_tiff.h
     vtk_freetype.h
     vtk_libxml2.h
+    vtk_oggtheora.h
     DESTINATION ${VTK_INSTALL_INCLUDE_DIR_CM24}
     COMPONENT Development
     )
diff --git a/VTK/Utilities/vtk_oggtheora.h b/VTK/Utilities/vtk_oggtheora.h
new file mode 100644
index 0000000..7ad4b3b
--- /dev/null
+++ b/VTK/Utilities/vtk_oggtheora.h
@@ -0,0 +1,29 @@
+/*=========================================================================
+
+  Program:   Visualization Toolkit
+  Module:    $RCSfile: vtk_oggtheora.h,v $
+
+  Copyright (c) Michael Wild, Ken Martin, Will Schroeder, Bill Lorensen
+  All rights reserved.
+  See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
+
+     This software is distributed WITHOUT ANY WARRANTY; without even
+     the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+     PURPOSE.  See the above copyright notice for more information.
+
+=========================================================================*/
+#ifndef __vtk_oggtheora_h
+#define __vtk_oggtheora_h
+
+/* Use the ogg/theora library configured for VTK.  */
+#include "vtkToolkits.h"
+
+#ifdef VTK_USE_SYSTEM_OGGTHEORA
+# include <ogg/ogg.h>
+# include <theora/theoraenc.h>
+#else
+# include <vtkoggtheora/include/ogg/ogg.h>
+# include <vtkoggtheora/include/theora/theoraenc.h>
+#endif
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/.NoDartCoverage b/VTK/Utilities/vtkoggtheora/.NoDartCoverage
new file mode 100644
index 0000000..3c99729
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/.NoDartCoverage
@@ -0,0 +1 @@
+# do not do coverage in this directory
diff --git a/VTK/Utilities/vtkoggtheora/CMakeLists.txt b/VTK/Utilities/vtkoggtheora/CMakeLists.txt
new file mode 100644
index 0000000..4b4a12d
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/CMakeLists.txt
@@ -0,0 +1,273 @@
+PROJECT(VTKOGGTHEORA)
+
+SET(THEORA_VERSION 1.1alpha2)
+
+# do some type checks
+INCLUDE(CheckTypeSize)
+CHECK_TYPE_SIZE(int16_t     VTKOGGTHEORA_INT16_T)
+CHECK_TYPE_SIZE(int32_t     VTKOGGTHEORA_INT32_T)
+CHECK_TYPE_SIZE(uint32_t    VTKOGGTHEORA_UINT32_T)
+CHECK_TYPE_SIZE(uint16_t    VTKOGGTHEORA_UINT16_T)
+CHECK_TYPE_SIZE(u_int32_t   VTKOGGTHEORA_U_INT32_T)
+CHECK_TYPE_SIZE(u_int16_t   VTKOGGTHEORA_U_INT16_T)
+CHECK_TYPE_SIZE(int64_t     VTKOGGTHEORA_INT64_T)
+CHECK_TYPE_SIZE(short       VTKOGGTHEORA_SHORT)
+CHECK_TYPE_SIZE(int         VTKOGGTHEORA_INT)
+CHECK_TYPE_SIZE(long        VTKOGGTHEORA_LONG)
+CHECK_TYPE_SIZE("long long" VTKOGGTHEORA_LONG_LONG)
+
+IF(HAVE_VTKOGGTHEORA_INT16_T)
+  SET(SIZE16 int16_t)
+ELSEIF(VTKOGGTHEORA_SHORT EQUAL 2)
+  SET(SIZE16 short)
+ELSEIF(VTKOGGTHEORA_INT EQUAL 2)
+  SET(SIZE16 int)
+ELSE(HAVE_VTKOGGTHEORA_INT16_T)
+  MESSAGE(SEND_ERROR "No 16 bit type found")
+ENDIF(HAVE_VTKOGGTHEORA_INT16_T)
+
+IF(HAVE_VTKOGGTHEORA_INT32_T)
+  SET(SIZE32 int32_t)
+ELSEIF(VTKOGGTHEORA_SHORT EQUAL 4)
+  SET(SIZE32 short)
+ELSEIF(VTKOGGTHEORA_INT EQUAL 4)
+  SET(SIZE32 int)
+ELSEIF(VTKOGGTHEORA_LONG EQUAL 4)
+  SET(SIZE32 long)
+ELSE(HAVE_VTKOGGTHEORA_INT32_T)
+  MESSAGE(SEND_ERROR "No 32 bit type found")
+ENDIF(HAVE_VTKOGGTHEORA_INT32_T)
+
+IF(HAVE_VTKOGGTHEORA_UINT32_T)
+  SET(USIZE32 uint32_t)
+ELSEIF(VTKOGGTHEORA_SHORT EQUAL 4)
+  SET(USIZE32 "unsigned short")
+ELSEIF(VTKOGGTHEORA_INT EQUAL 4)
+  SET(USIZE32 "unsigned int")
+ELSEIF(VTKOGGTHEORA_LONG EQUAL 4)
+  SET(USIZE32 "unsigned long")
+ELSE(HAVE_VTKOGGTHEORA_UINT32_T)
+  MESSAGE(SEND_ERROR "No unsigned 32 bit type found")
+ENDIF(HAVE_VTKOGGTHEORA_UINT32_T)
+
+IF(HAVE_VTKOGGTHEORA_UINT16_T)
+  SET(VTKOGGTHEORA_USIZE16 uint16_t)
+ELSEIF(VTKOGGTHEORA_SHORT EQUAL 2)
+  SET(USIZE16 "unsigned short")
+ELSEIF(VTKOGGTHEORA_INT EQUAL 2)
+  SET(VTKOGGTHEORA_USIZE16 "unsigned int")
+ELSEIF(LONG EQUAL 2)
+  SET(VTKOGGTHEORA_USIZE16 "unsigned long")
+ELSE(HAVE_VTKOGGTHEORA_UINT16_T)
+  MESSAGE(SEND_ERROR "No unsigned 16 bit type found")
+ENDIF(HAVE_VTKOGGTHEORA_UINT16_T)
+
+IF(HAVE_VTKOGGTHEORA_INT64_T)
+  SET(SIZE64 int64_t)
+ELSEIF(VTKOGGTHEORA_INT EQUAL 8)
+  SET(SIZE64 int)
+ELSEIF(VTKOGGTHEORA_LONG EQUAL 8)
+  SET(SIZE64 long)
+ELSEIF(VTKOGGTHEORA_LONG_LONG EQUAL 8)
+  SET(SIZE64 "long long")
+ELSE(HAVE_VTKOGGTHEORA_INT64_T)
+  MESSAGE(SEND_ERROR "No 64 bit type found")
+ENDIF(HAVE_VTKOGGTHEORA_INT64_T)
+
+# check whether compiler supports named ASM params
+SET(VTKOGGTHEORA_COMPILER_SUPPORTS_NAMED_ASM_PARAMS TRUE)
+# for gcc anything below 3.1 does not, so don't even ask user
+IF(CMAKE_COMPILER_IS_GNU_C)
+  MESSAGE(STATUS "Checking whether GCC ${CMAKE_C_COMPILER} is older than 3.1")
+  IF(NOT VTKOGGTHEORA_GCC_VERSION)
+    EXECUTE_PROCESS(
+      COMMAND ${CMAKE_C_COMPILER} -dumpversion
+      OUTPUT_VARIABLE VTKOGGTHEORA_GCC_VERSION
+      OUTPUT_STRIP_TRAILING_WHITESPACE
+      )
+    SET(VTKOGGTHEORA_GCC_VERSION ${VTKOGGTHEORA_GCC_VERSION} CACHE INTERNAL "The gcc version")
+    IF(${VTKOGGTHEORA_GCC_VERSION} VERSION_LESS 3.1.0)
+      SET(VTKOGGTHEORA_COMPILER_SUPPORTS_NAMED_ASM_PARAMS FALSE)
+    ENDIF(${VTKOGGTHEORA_GCC_VERSION} VERSION_LESS 3.1.0)
+  ENDIF(NOT VTKOGGTHEORA_GCC_VERSION)
+ENDIF(CMAKE_COMPILER_IS_GNU_C)
+
+# options
+IF(VTKOGGTHEORA_COMPILER_SUPPORTS_NAMED_ASM_PARAMS)
+  OPTION(VTKOGGTHEORA_DISABLE_ASM "Disable assemby optimizations" OFF)
+ENDIF(VTKOGGTHEORA_COMPILER_SUPPORTS_NAMED_ASM_PARAMS)
+OPTION(VTKOGGTHEORA_DISABLE_FLOAT "Disable the use of floating point code in theora" OFF)
+MARK_AS_ADVANCED(VTKOGGTHEORA_DISABLE_ASM VTKOGGTHEORA_DISABLE_FLOAT)
+
+# we have special code for x86 and x86_64
+SET(OC_X86_ASM FALSE)
+SET(OC_X86_64_ASM FALSE)
+IF(CMAKE_SYSTEM_PROCESSOR MATCHES "i[3-6]|x86_64")
+  IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
+    SET(OC_X86_ASM TRUE)
+  ELSE(CMAKE_SIZEOF_VOID_P EQUAL 4)
+    SET(OC_X86_64_ASM TRUE)
+  ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ENDIF(CMAKE_SYSTEM_PROCESSOR MATCHES "i[3-6]|x86_64")
+
+# set up compiler flags (only for gcc)
+IF(CMAKE_COMPILER_IS_GNU_C)
+  SET(VTKOGGTHEORA_C_FLAGS_RELEASE
+    "-fast -fforce-addr -fomit-frame-pointer -finline-functions -funroll-loops"
+    CACHE STRING "Additional compiler flags for the vtkoggtheora library (release build)")
+  MARK_AS_ADVANCED(VTKOGGTHEORA_C_FLAGS_RELEASE)
+  SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${VTKOGGTHEORA_C_FLAGS_RELEASE}")
+ENDIF(CMAKE_COMPILER_IS_GNU_C)
+
+# set up linker flags
+IF(APPLE)
+  SET( VTKOGGTHEORA_SHARED_LINKER_FLAGS
+    "-read_only_relocs suppress -Wl,-exported_symbols_list,${VTKOGGTHEORA_SOURCE_DIR}/vtkoggtheora.exp"
+    )
+ENDIF(APPLE)
+# assume that -Wl,--version-script works on UNIX systems (excluding Mac and Cygwin).
+# otherwise the user can always set to an empty string
+IF(UNIX AND NOT APPLE AND NOT CYGWIN)
+  SET( VTKOGGTHEORA_SHARED_LINKER_FLAGS
+    "-Wl,--version-script=${VTKOGGTHEORA_SOURCE_DIR}/vtkoggtheora.vscript"
+    )
+ENDIF(UNIX AND NOT APPLE AND NOT CYGWIN)
+SET(VTKOGGTHEORA_SHARED_LINKER_FLAGS "${VTKOGGTHEORA_SHARED_LINKER_FLAGS}"
+  CACHE STRING "Additional linker flags for vtkoggtheora when building as a shared library"
+  )
+MARK_AS_ADVANCED(VTKOGGTHEORA_SHARED_LINKER_FLAGS)
+SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${VTKOGGTHEORA_SHARED_LINKER_FLAGS}")
+
+SET(USE_ASM FALSE)
+IF(NOT VTKOGGTHEORA_DISABLE_ASM)
+  IF(OC_X86_ASM OR OC_X86_64_ASM OR APPLE)
+    SET(USE_ASM TRUE)
+  ENDIF(OC_X86_ASM OR OC_X86_64_ASM OR APPLE)
+ENDIF(NOT VTKOGGTHEORA_DISABLE_ASM)
+
+CONFIGURE_FILE(libogg-1.1.4/include/ogg/config_types.h.in
+  ${VTKOGGTHEORA_BINARY_DIR}/include/ogg/config_types.h @ONLY)
+
+CONFIGURE_FILE(libtheora-1.1alpha2/config.h.in
+  ${VTKOGGTHEORA_BINARY_DIR}/include/config.h @ONLY)
+
+CONFIGURE_FILE(libogg-1.1.4/include/ogg/ogg.h
+  ${VTKOGGTHEORA_BINARY_DIR}/include/ogg/ogg.h COPYONLY)
+CONFIGURE_FILE(libogg-1.1.4/include/ogg/os_types.h
+  ${VTKOGGTHEORA_BINARY_DIR}/include/ogg/os_types.h COPYONLY)
+CONFIGURE_FILE(libtheora-1.1alpha2/include/theora/codec.h
+  ${VTKOGGTHEORA_BINARY_DIR}/include/theora/codec.h COPYONLY)
+CONFIGURE_FILE(libtheora-1.1alpha2/include/theora/theora.h
+  ${VTKOGGTHEORA_BINARY_DIR}/include/theora/theora.h COPYONLY)
+CONFIGURE_FILE(libtheora-1.1alpha2/include/theora/theoradec.h
+  ${VTKOGGTHEORA_BINARY_DIR}/include/theora/theoradec.h COPYONLY)
+CONFIGURE_FILE(libtheora-1.1alpha2/include/theora/theoraenc.h
+  ${VTKOGGTHEORA_BINARY_DIR}/include/theora/theoraenc.h COPYONLY)
+
+CONFIGURE_FILE(vtk_oggtheora_mangle.h
+  ${VTKOGGTHEORA_BINARY_DIR}/include/vtk_oggtheora_mangle.h COPYONLY)
+
+CONFIGURE_FILE(${VTKOGGTHEORA_SOURCE_DIR}/.NoDartCoverage
+  ${VTKOGGTHEORA_BINARY_DIR}/.NoDartCoverage COPYONLY)
+
+INCLUDE_DIRECTORIES(BEFORE
+  ${VTKOGGTHEORA_BINARY_DIR}/..
+  )
+
+SET(VTKOGGTHEORA_SRCS
+  # ogg sources
+  libogg-1.1.4/src/framing.c libogg-1.1.4/src/bitwise.c
+  # theora encoder sources (general)
+  libtheora-1.1alpha2/lib/enc/dct.c libtheora-1.1alpha2/lib/enc/dct_decode.c
+  libtheora-1.1alpha2/lib/enc/dct_encode.c
+  libtheora-1.1alpha2/lib/enc/encfrag.c
+  libtheora-1.1alpha2/lib/enc/encapiwrapper.c
+  libtheora-1.1alpha2/lib/enc/encode.c
+  libtheora-1.1alpha2/lib/enc/encoder_toplevel.c
+  libtheora-1.1alpha2/lib/enc/encoder_quant.c
+  libtheora-1.1alpha2/lib/enc/frarray.c libtheora-1.1alpha2/lib/enc/frinit.c
+  libtheora-1.1alpha2/lib/enc/huffenc.c libtheora-1.1alpha2/lib/enc/mathops.c
+  libtheora-1.1alpha2/lib/enc/mcenc.c libtheora-1.1alpha2/lib/enc/mode.c
+  # theora decoder sources (general)
+  libtheora-1.1alpha2/lib/dec/apiwrapper.c
+  libtheora-1.1alpha2/lib/dec/fragment.c
+  libtheora-1.1alpha2/lib/dec/idct.c
+  libtheora-1.1alpha2/lib/dec/info.c
+  libtheora-1.1alpha2/lib/dec/internal.c
+  )
+IF(OC_X86_ASM OR OC_X86_64_ASM)
+  SET(VTKOGGTHEORA_SRCS
+    ${VTKOGGTHEORA_SRCS}
+    # x86/x86_64 encoder sources
+    libtheora-1.1alpha2/lib/enc/x86/mmxenc.c
+    libtheora-1.1alpha2/lib/enc/x86/mmxencfrag.c
+    libtheora-1.1alpha2/lib/enc/x86/mmxfdct.c
+    libtheora-1.1alpha2/lib/enc/x86/x86enc.c
+    # x86/x86_64 decoder sources
+    libtheora-1.1alpha2/lib/dec/x86/mmxfrag.c
+    libtheora-1.1alpha2/lib/dec/x86/mmxidct.c
+    )
+  IF(MSVC)
+    SET(VTKOGGTHEORA_SRCS
+      ${VTKOGGTHEORA_SRCS}
+      # MSVC specific x86 encoder sources
+      libtheora-1.1alpha2/lib/enc/x86_32_vs/dsp_mmx.c
+      libtheora-1.1alpha2/lib/enc/x86_32_vs/fdct_mmx.c
+      libtheora-1.1alpha2/lib/enc/x86_32_vs/recon_mmx.c
+      # MSVC specific x86 decoder sources
+      libtheora-1.1alpha2/lib/dec/x86_vc/mmxfrag.c
+      libtheora-1.1alpha2/lib/dec/x86_vc/mmxidct.c
+      libtheora-1.1alpha2/lib/dec/x86_vc/mmxloopfilter.c
+      libtheora-1.1alpha2/lib/dec/x86_vc/mmxstate.c
+      libtheora-1.1alpha2/lib/dec/x86_vc/x86state.c
+      )
+  ENDIF(MSVC)
+ENDIF(OC_X86_ASM OR OC_X86_64_ASM)
+IF(OC_X86_ASM)
+  SET(VTKOGGTHEORA_SRCS
+    ${VTKOGGTHEORA_SRCS}
+    # x86_64 encoder sources
+    libtheora-1.1alpha2/lib/enc/x86/sse2fdct.c
+    )
+ENDIF(OC_X86_ASM)
+IF(MSVC)
+  LIST(APPEND VTKOGGTHEORA_SRCS vtkoggtheora.def vtkoggtheora.rc)
+ENDIF(MSVC)
+
+ADD_DEFINITIONS(-DHAVE_CONFIG_H)
+
+ADD_LIBRARY(vtkoggtheora ${VTKOGGTHEORA_SRCS})
+
+# Apply user-defined properties to the library target.
+IF(VTK_LIBRARY_PROPERTIES)
+  SET_TARGET_PROPERTIES(vtkoggtheora PROPERTIES ${VTK_LIBRARY_PROPERTIES}
+    )
+ENDIF(VTK_LIBRARY_PROPERTIES)
+
+IF(NOT VTK_INSTALL_NO_LIBRARIES)
+  INSTALL(TARGETS vtkoggtheora
+    RUNTIME DESTINATION ${VTK_INSTALL_BIN_DIR_CM24} COMPONENT RuntimeLibraries
+    LIBRARY DESTINATION ${VTK_INSTALL_LIB_DIR_CM24} COMPONENT RuntimeLibraries
+    ARCHIVE DESTINATION ${VTK_INSTALL_LIB_DIR_CM24} COMPONENT Development)
+ENDIF(NOT VTK_INSTALL_NO_LIBRARIES)
+
+IF(NOT VTK_INSTALL_NO_DEVELOPMENT)
+  INSTALL(FILES
+    ${VTKOGGTHEORA_SOURCE_DIR}/vtk_oggtheora_mangle.h
+    DESTINATION ${VTK_INSTALL_INCLUDE_DIR_CM24}/vtkoggtheora/include
+    COMPONENT Development)
+  INSTALL(FILES
+    ${VTKOGGTHEORA_SOURCE_DIR}/libogg-1.1.4/include/ogg/ogg.h
+    ${VTKOGGTHEORA_SOURCE_DIR}/libogg-1.1.4/include/ogg/os_types.h
+    ${VTKOGGTHEORA_BINARY_DIR}/include/ogg/config_types.h
+    DESTINATION ${VTK_INSTALL_INCLUDE_DIR_CM24}/vtkoggtheora/include/ogg
+    COMPONENT Development)
+  INSTALL(FILES
+    ${VTKOGGTHEORA_SOURCE_DIR}/libtheora-1.1alpha2/include/theora/codec.h
+    ${VTKOGGTHEORA_SOURCE_DIR}/libtheora-1.1alpha2/include/theora/theora.h
+    ${VTKOGGTHEORA_SOURCE_DIR}/libtheora-1.1alpha2/include/theora/theoradec.h
+    ${VTKOGGTHEORA_SOURCE_DIR}/libtheora-1.1alpha2/include/theora/theoraenc.h
+    ${VTKOGGTHEORA_SOURCE_DIR}/libtheora-1.1alpha2/include/theora/theoraenc.h
+    DESTINATION ${VTK_INSTALL_INCLUDE_DIR_CM24}/vtkoggtheora/include/theora
+    COMPONENT Development)
+ENDIF(NOT VTK_INSTALL_NO_DEVELOPMENT)
diff --git a/VTK/Utilities/vtkoggtheora/README.Kitware.txt b/VTK/Utilities/vtkoggtheora/README.Kitware.txt
new file mode 100644
index 0000000..15321c7
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/README.Kitware.txt
@@ -0,0 +1,36 @@
+This directory contains a subset of the libogg-1.1.4 and libtheora-1.1alpha2
+libraries and some custom changes. The reason to choose the alpha version of
+the latter is that it features much better assembly code for x86 architectures,
+encoding is faster and shows no instabilities for our purposes.
+
+We only include enough of the distribution to provide the functionalities
+required. Both libraries are compiled into the single vtkoggtheora library.
+
+We would like to thank Xiph.org for distributing these libraries.
+http://www.xiph.org
+
+Added Files
+-----------
+
+CMakeLists.txt
+  -Support building with CMake.
+
+vtkoggtheora.rc
+  -For MS Windows only: provide a version resource in a dll build so that
+   when you look at the dll file in Windows explorer, it will show you the
+   version in the "Version" tab of the file's properties view.
+
+vtkoggtheora.def
+vtkoggtheora.exp
+vtkoggtheora.vscript
+  -For MS Windows, Mac OS X and Linux respectively: used to explicitly list the
+   exports from dll builds. Only the functions actually used in
+   vtkOggTheoraWriter are exported.
+
+vtk_oggtheora_mangle.h
+  -Mangles symbols exported from the ogg/theora libraries for use by VTK.
+
+Changed Files
+-------------
+You can search the code for "KITWARE_OGGTHEORA_CHANGE" to find modifications
+vs the original ogg/theora code.
diff --git a/VTK/Utilities/vtkoggtheora/libogg-1.1.4/AUTHORS b/VTK/Utilities/vtkoggtheora/libogg-1.1.4/AUTHORS
new file mode 100644
index 0000000..80c787c
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libogg-1.1.4/AUTHORS
@@ -0,0 +1,4 @@
+Monty <monty@xiph.org>
+
+and the rest of the Xiph.Org Foundation.
+
diff --git a/VTK/Utilities/vtkoggtheora/libogg-1.1.4/CHANGES b/VTK/Utilities/vtkoggtheora/libogg-1.1.4/CHANGES
new file mode 100644
index 0000000..35de4b6
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libogg-1.1.4/CHANGES
@@ -0,0 +1,42 @@
+Version 1.1.4 (2009 June 24)
+
+* New async error reporting mechanism. Calls made after a fatal error are 
+  now safely handled in the event an error code is ignored
+* Added allocation checks useful to some embedded applications
+* fix possible read past end of buffer when reading 0 bits
+* Updates to API documentation
+* Build fixes
+
+Version 1.1.3 (2005 November 27)
+
+ * Correct a bug in the granulepos field of pages where no packet ends
+ * New VS2003 and XCode builds, minor fixes to other builds
+ * documentation fixes and cleanup
+ 
+Version 1.1.2 (2004 September 23)
+
+ * fix a bug with multipage packet assembly after seek
+
+Version 1.1.1 (2004 September 12)
+
+ * various bugfixes
+ * important bugfix for 64-bit platforms
+ * various portability fixes
+ * autotools cleanup from Thomas Vander Stichele
+ * Symbian OS build support from Colin Ward at CSIRO
+ * new multiplexed Ogg stream documentation
+
+Version 1.1 (2003 November 17)
+
+ * big-endian bitpacker routines for Theora
+ * various portability fixes
+ * improved API documenation
+ * RFC 3533 documentation of the format by Silvia Pfeiffer at CSIRO
+ * RFC 3534 documentation of the application/ogg mime-type by Linus Walleij
+ 
+Version 1.0 (2002 July 19)
+
+ * First stable release
+ * little-endian bitpacker routines for Vorbis
+ * basic Ogg bitstream sync and coding support
+
diff --git a/VTK/Utilities/vtkoggtheora/libogg-1.1.4/COPYING b/VTK/Utilities/vtkoggtheora/libogg-1.1.4/COPYING
new file mode 100644
index 0000000..6111c6c
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libogg-1.1.4/COPYING
@@ -0,0 +1,28 @@
+Copyright (c) 2002, Xiph.org Foundation
+
+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 the Xiph.org Foundation 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 FOUNDATION
+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.
diff --git a/VTK/Utilities/vtkoggtheora/libogg-1.1.4/README b/VTK/Utilities/vtkoggtheora/libogg-1.1.4/README
new file mode 100644
index 0000000..e31d40a
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libogg-1.1.4/README
@@ -0,0 +1,133 @@
+********************************************************************
+*                                                                  *
+* THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
+* USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+* GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+* IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+*                                                                  *
+* THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002             *
+* by the Xiph.Org Foundation http://www.xiph.org/                  *
+*                                                                  *
+********************************************************************
+
+WHAT'S HERE:
+
+This source distribution includes libogg and nothing else.  Other modules 
+(eg, the modules vorbis, vorbis-tools and vorbis-plugins for the Vorbis 
+codec) contain the codec libraries for use with Ogg bitstreams.
+
+Directory:
+
+./src  		The source for libogg, a BSD-license inplementation of 
+		the public domain Ogg bitstream format
+
+./include       Library API headers and codebooks
+
+./doc           Ogg specification documents
+
+./win32		Win32 projects and build automation
+
+./macosx	MacOS X project and build files
+
+./macos		Classic MacOS 9 projects and build automation
+
+./debian        Rules/spec files for building Debian .deb packages
+		(may not be present, depending on your distribution)
+
+WHAT IS OGG?:
+
+Ogg project codecs use the Ogg bitstream format to arrange the raw,
+compressed bitstream into a more robust, useful form.  For example,
+the Ogg bitstream makes seeking, time stamping and error recovery
+possible, as well as mixing several sepearate, concurrent media
+streams into a single physical bitstream.
+
+CONTACT:
+
+The Ogg homepage is located at 'http://www.xiph.org/ogg/'.
+Up to date technical documents, contact information, source code and
+pre-built utilities may be found there.
+
+BUILDING FROM REPOSITORY SOURCE:
+
+A standard svn build should consist of nothing more than:
+
+./autogen.sh
+make 
+
+and as root if desired :
+
+make install
+
+This will install the Ogg libraries (static and shared) into
+/usr/local/lib, includes into /usr/local/include and API manpages
+(once we write some) into /usr/local/man.
+
+BUILDING FROM TARBALL DISTRIBUTIONS:
+
+./configure
+make
+
+and optionally (as root):
+make install
+
+BUILDING RPMS:
+
+RPMs may be built by:
+
+make dist
+rpm -ta libogg-<version>.tar.gz
+
+BUILDING ON WIN32:
+
+Use the project file in the win32 directory.  It should compile out of the box.
+You can also run one of the batch files from the commandline.
+
+E.g.: build_ogg_dynamic
+
+CROSS COMPILING FROM LINUX TO WIN32:
+
+It is also possible to cross compile from Linux to windows using the MinGW
+cross tools and even to run the test suite under Wine, the Linux/*nix
+windows emulator.
+
+On Debian and Ubuntu systems, these cross compiler tools can be installed
+by doing:
+
+    sudo apt-get mingw32 mingw32-binutils mingw32-runtime wine
+
+Once these tools are installed its possible to compile and test by
+executing the following commands:
+
+    ./configure --host=i586-mingw32msvc --target=i586-mingw32msvc \
+         --build=i586-linux
+    make
+    make check
+
+The above has been tested with the following versions of the tools on
+Ubuntu's Hardy Heron release:
+
+    mingw32             4.2.1.dfsg-1ubuntu1
+    mingw32-binutils    2.17.50-20070129.1-1
+    mingw32-runtime     3.13-1
+    wine                0.9.59-0ubuntu4
+
+BUILDING ON MACOS 9:
+
+Ogg on MacOS 9 is built using CodeWarrior 5.3.  To build it, first
+open ogg/mac/libogg.mcp, switch to the "Targets" pane, select
+everything, and make the project.  In ogg/mac/Output you will now have
+both debug and final versions of Ogg shared libraries to link your
+projects against.
+
+To build a project using Ogg, add access paths to your CodeWarrior
+project for the ogg/include and ogg/mac/Output folders.  Be sure that
+"interpret DOS and Unix paths" is turned on in your project; it can be
+found in the "access paths" pane in your project settings.  Now simply
+add the shared libraries you need to your project (OggLib at least)
+and #include "ogg/ogg.h" wherever you need to acces Ogg functionality.
+
+(Build instructions for Ogg codecs such as vorbis are similar and may
+be found in those source modules' README files)
+
+$Id: README 14726 2008-04-14 08:40:46Z erikd $
diff --git a/VTK/Utilities/vtkoggtheora/libogg-1.1.4/include/ogg/config_types.h.in b/VTK/Utilities/vtkoggtheora/libogg-1.1.4/include/ogg/config_types.h.in
new file mode 100644
index 0000000..beb0311
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libogg-1.1.4/include/ogg/config_types.h.in
@@ -0,0 +1,20 @@
+#ifndef __CONFIG_TYPES_H__
+#define __CONFIG_TYPES_H__
+
+/* KITWARE_OGGTHEORA_CHANGE quite a few systems require
+ * the inclusing of stdint.h for the exact-width integers
+ */
+#cmakedefine HAVE_STDINT_H
+
+#ifdef HAVE_STDINT_H
+#include <stdint.h>
+#endif
+
+/* these are filled in by configure */
+typedef @SIZE16@ ogg_int16_t;
+typedef @USIZE16@ ogg_uint16_t;
+typedef @SIZE32@ ogg_int32_t;
+typedef @USIZE32@ ogg_uint32_t;
+typedef @SIZE64@ ogg_int64_t;
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libogg-1.1.4/include/ogg/ogg.h b/VTK/Utilities/vtkoggtheora/libogg-1.1.4/include/ogg/ogg.h
new file mode 100644
index 0000000..2270b9e
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libogg-1.1.4/include/ogg/ogg.h
@@ -0,0 +1,209 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2007             *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+ function: toplevel libogg include
+ last mod: $Id: ogg.h 16051 2009-05-27 05:00:06Z xiphmont $
+
+ ********************************************************************/
+#ifndef _OGG_H
+#define _OGG_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <stddef.h>
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+#include <vtkoggtheora/include/ogg/os_types.h>
+
+typedef struct {
+  void *iov_base;
+  size_t iov_len;
+} ogg_iovec_t;
+
+typedef struct {
+  long endbyte;
+  int  endbit;
+
+  unsigned char *buffer;
+  unsigned char *ptr;
+  long storage;
+} oggpack_buffer;
+
+/* ogg_page is used to encapsulate the data in one Ogg bitstream page *****/
+
+typedef struct {
+  unsigned char *header;
+  long header_len;
+  unsigned char *body;
+  long body_len;
+} ogg_page;
+
+/* ogg_stream_state contains the current encode/decode state of a logical
+   Ogg bitstream **********************************************************/
+
+typedef struct {
+  unsigned char   *body_data;    /* bytes from packet bodies */
+  long    body_storage;          /* storage elements allocated */
+  long    body_fill;             /* elements stored; fill mark */
+  long    body_returned;         /* elements of fill returned */
+
+
+  int     *lacing_vals;      /* The values that will go to the segment table */
+  ogg_int64_t *granule_vals; /* granulepos values for headers. Not compact
+                                this way, but it is simple coupled to the
+                                lacing fifo */
+  long    lacing_storage;
+  long    lacing_fill;
+  long    lacing_packet;
+  long    lacing_returned;
+
+  unsigned char    header[282];      /* working space for header encode */
+  int              header_fill;
+
+  int     e_o_s;          /* set when we have buffered the last packet in the
+                             logical bitstream */
+  int     b_o_s;          /* set after we've written the initial page
+                             of a logical bitstream */
+  long    serialno;
+  long    pageno;
+  ogg_int64_t  packetno;  /* sequence number for decode; the framing
+                             knows where there's a hole in the data,
+                             but we need coupling so that the codec
+                             (which is in a seperate abstraction
+                             layer) also knows about the gap */
+  ogg_int64_t   granulepos;
+
+} ogg_stream_state;
+
+/* ogg_packet is used to encapsulate the data and metadata belonging
+   to a single raw Ogg/Vorbis packet *************************************/
+
+typedef struct {
+  unsigned char *packet;
+  long  bytes;
+  long  b_o_s;
+  long  e_o_s;
+
+  ogg_int64_t  granulepos;
+
+  ogg_int64_t  packetno;     /* sequence number for decode; the framing
+                                knows where there's a hole in the data,
+                                but we need coupling so that the codec
+                                (which is in a seperate abstraction
+                                layer) also knows about the gap */
+} ogg_packet;
+
+typedef struct {
+  unsigned char *data;
+  int storage;
+  int fill;
+  int returned;
+
+  int unsynced;
+  int headerbytes;
+  int bodybytes;
+} ogg_sync_state;
+
+/* Ogg BITSTREAM PRIMITIVES: bitstream ************************/
+
+extern void  oggpack_writeinit(oggpack_buffer *b);
+extern int   oggpack_writecheck(oggpack_buffer *b);
+extern void  oggpack_writetrunc(oggpack_buffer *b,long bits);
+extern void  oggpack_writealign(oggpack_buffer *b);
+extern void  oggpack_writecopy(oggpack_buffer *b,void *source,long bits);
+extern void  oggpack_reset(oggpack_buffer *b);
+extern void  oggpack_writeclear(oggpack_buffer *b);
+extern void  oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
+extern void  oggpack_write(oggpack_buffer *b,unsigned long value,int bits);
+extern long  oggpack_look(oggpack_buffer *b,int bits);
+extern long  oggpack_look1(oggpack_buffer *b);
+extern void  oggpack_adv(oggpack_buffer *b,int bits);
+extern void  oggpack_adv1(oggpack_buffer *b);
+extern long  oggpack_read(oggpack_buffer *b,int bits);
+extern long  oggpack_read1(oggpack_buffer *b);
+extern long  oggpack_bytes(oggpack_buffer *b);
+extern long  oggpack_bits(oggpack_buffer *b);
+extern unsigned char *oggpack_get_buffer(oggpack_buffer *b);
+
+extern void  oggpackB_writeinit(oggpack_buffer *b);
+extern int   oggpackB_writecheck(oggpack_buffer *b);
+extern void  oggpackB_writetrunc(oggpack_buffer *b,long bits);
+extern void  oggpackB_writealign(oggpack_buffer *b);
+extern void  oggpackB_writecopy(oggpack_buffer *b,void *source,long bits);
+extern void  oggpackB_reset(oggpack_buffer *b);
+extern void  oggpackB_writeclear(oggpack_buffer *b);
+extern void  oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes);
+extern void  oggpackB_write(oggpack_buffer *b,unsigned long value,int bits);
+extern long  oggpackB_look(oggpack_buffer *b,int bits);
+extern long  oggpackB_look1(oggpack_buffer *b);
+extern void  oggpackB_adv(oggpack_buffer *b,int bits);
+extern void  oggpackB_adv1(oggpack_buffer *b);
+extern long  oggpackB_read(oggpack_buffer *b,int bits);
+extern long  oggpackB_read1(oggpack_buffer *b);
+extern long  oggpackB_bytes(oggpack_buffer *b);
+extern long  oggpackB_bits(oggpack_buffer *b);
+extern unsigned char *oggpackB_get_buffer(oggpack_buffer *b);
+
+/* Ogg BITSTREAM PRIMITIVES: encoding **************************/
+
+extern int      ogg_stream_packetin(ogg_stream_state *os, ogg_packet *op);
+extern int      ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov,
+                                   int count, long e_o_s, ogg_int64_t granulepos);
+extern int      ogg_stream_pageout(ogg_stream_state *os, ogg_page *og);
+extern int      ogg_stream_flush(ogg_stream_state *os, ogg_page *og);
+
+/* Ogg BITSTREAM PRIMITIVES: decoding **************************/
+
+extern int      ogg_sync_init(ogg_sync_state *oy);
+extern int      ogg_sync_clear(ogg_sync_state *oy);
+extern int      ogg_sync_reset(ogg_sync_state *oy);
+extern int      ogg_sync_destroy(ogg_sync_state *oy);
+extern int      ogg_sync_check(ogg_sync_state *oy);
+
+extern char    *ogg_sync_buffer(ogg_sync_state *oy, long size);
+extern int      ogg_sync_wrote(ogg_sync_state *oy, long bytes);
+extern long     ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og);
+extern int      ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og);
+extern int      ogg_stream_pagein(ogg_stream_state *os, ogg_page *og);
+extern int      ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op);
+extern int      ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op);
+
+/* Ogg BITSTREAM PRIMITIVES: general ***************************/
+
+extern int      ogg_stream_init(ogg_stream_state *os,int serialno);
+extern int      ogg_stream_clear(ogg_stream_state *os);
+extern int      ogg_stream_reset(ogg_stream_state *os);
+extern int      ogg_stream_reset_serialno(ogg_stream_state *os,int serialno);
+extern int      ogg_stream_destroy(ogg_stream_state *os);
+extern int      ogg_stream_check(ogg_stream_state *os);
+extern int      ogg_stream_eos(ogg_stream_state *os);
+
+extern void     ogg_page_checksum_set(ogg_page *og);
+
+extern int      ogg_page_version(const ogg_page *og);
+extern int      ogg_page_continued(const ogg_page *og);
+extern int      ogg_page_bos(const ogg_page *og);
+extern int      ogg_page_eos(const ogg_page *og);
+extern ogg_int64_t  ogg_page_granulepos(const ogg_page *og);
+extern int      ogg_page_serialno(const ogg_page *og);
+extern long     ogg_page_pageno(const ogg_page *og);
+extern int      ogg_page_packets(const ogg_page *og);
+
+extern void     ogg_packet_clear(ogg_packet *op);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif  /* _OGG_H */
diff --git a/VTK/Utilities/vtkoggtheora/libogg-1.1.4/include/ogg/os_types.h b/VTK/Utilities/vtkoggtheora/libogg-1.1.4/include/ogg/os_types.h
new file mode 100644
index 0000000..1345a3b
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libogg-1.1.4/include/ogg/os_types.h
@@ -0,0 +1,143 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002             *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+ function: #ifdef jail to whip a few platforms into the UNIX ideal.
+ last mod: $Id: os_types.h 14997 2008-06-04 03:27:18Z ivo $
+
+ ********************************************************************/
+#ifndef _OS_TYPES_H
+#define _OS_TYPES_H
+
+/* KITWARE_OGGTHEORA_CHANGE - Added to mangle function names */
+#include "vtk_oggtheora_mangle.h"
+
+/* make it easy on the folks that want to compile the libs with a
+   different malloc than stdlib */
+#define _ogg_malloc  malloc
+#define _ogg_calloc  calloc
+#define _ogg_realloc realloc
+#define _ogg_free    free
+
+#if defined(_WIN32) 
+
+#  if defined(__CYGWIN__)
+#    include <stdint.h>
+     typedef int16_t ogg_int16_t;
+     typedef uint16_t ogg_uint16_t;
+     typedef int32_t ogg_int32_t;
+     typedef uint32_t ogg_uint32_t;
+     typedef int64_t ogg_int64_t;
+     typedef uint64_t ogg_uint64_t;
+#  elif defined(__MINGW32__)
+#    include <sys/types.h>
+     typedef short ogg_int16_t;
+     typedef unsigned short ogg_uint16_t;
+     typedef int ogg_int32_t;
+     typedef unsigned int ogg_uint32_t;
+     typedef long long ogg_int64_t;
+     typedef unsigned long long ogg_uint64_t;
+#  elif defined(__MWERKS__)
+     typedef long long ogg_int64_t;
+     typedef int ogg_int32_t;
+     typedef unsigned int ogg_uint32_t;
+     typedef short ogg_int16_t;
+     typedef unsigned short ogg_uint16_t;
+#  else
+     /* MSVC/Borland */
+     typedef __int64 ogg_int64_t;
+     typedef __int32 ogg_int32_t;
+     typedef unsigned __int32 ogg_uint32_t;
+     typedef __int16 ogg_int16_t;
+     typedef unsigned __int16 ogg_uint16_t;
+#  endif
+
+#elif defined(__MACOS__)
+
+#  include <sys/types.h>
+   typedef SInt16 ogg_int16_t;
+   typedef UInt16 ogg_uint16_t;
+   typedef SInt32 ogg_int32_t;
+   typedef UInt32 ogg_uint32_t;
+   typedef SInt64 ogg_int64_t;
+
+#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */
+
+#  include <sys/types.h>
+   typedef int16_t ogg_int16_t;
+   typedef u_int16_t ogg_uint16_t;
+   typedef int32_t ogg_int32_t;
+   typedef u_int32_t ogg_uint32_t;
+   typedef int64_t ogg_int64_t;
+
+#elif defined(__HAIKU__)
+
+  /* Haiku */
+#  include <sys/types.h>
+   typedef short ogg_int16_t;
+   typedef unsigned short ogg_uint16_t;
+   typedef int ogg_int32_t;
+   typedef unsigned int ogg_uint32_t;
+   typedef long long ogg_int64_t;
+
+#elif defined(__BEOS__)
+
+   /* Be */
+#  include <inttypes.h>
+   typedef int16_t ogg_int16_t;
+   typedef u_int16_t ogg_uint16_t;
+   typedef int32_t ogg_int32_t;
+   typedef u_int32_t ogg_uint32_t;
+   typedef int64_t ogg_int64_t;
+
+#elif defined (__EMX__)
+
+   /* OS/2 GCC */
+   typedef short ogg_int16_t;
+   typedef unsigned short ogg_uint16_t;
+   typedef int ogg_int32_t;
+   typedef unsigned int ogg_uint32_t;
+   typedef long long ogg_int64_t;
+
+#elif defined (DJGPP)
+
+   /* DJGPP */
+   typedef short ogg_int16_t;
+   typedef int ogg_int32_t;
+   typedef unsigned int ogg_uint32_t;
+   typedef long long ogg_int64_t;
+
+#elif defined(R5900)
+
+   /* PS2 EE */
+   typedef long ogg_int64_t;
+   typedef int ogg_int32_t;
+   typedef unsigned ogg_uint32_t;
+   typedef short ogg_int16_t;
+
+#elif defined(__SYMBIAN32__)
+
+   /* Symbian GCC */
+   typedef signed short ogg_int16_t;
+   typedef unsigned short ogg_uint16_t;
+   typedef signed int ogg_int32_t;
+   typedef unsigned int ogg_uint32_t;
+   typedef long long int ogg_int64_t;
+
+#else
+
+#  include <sys/types.h>
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+#  include <vtkoggtheora/include/ogg/config_types.h>
+
+#endif
+
+#endif  /* _OS_TYPES_H */
diff --git a/VTK/Utilities/vtkoggtheora/libogg-1.1.4/src/bitwise.c b/VTK/Utilities/vtkoggtheora/libogg-1.1.4/src/bitwise.c
new file mode 100644
index 0000000..807d7cb
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libogg-1.1.4/src/bitwise.c
@@ -0,0 +1,823 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009             *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function: packing variable sized words into an octet stream
+  last mod: $Id: bitwise.c 16051 2009-05-27 05:00:06Z xiphmont $
+
+ ********************************************************************/
+
+/* We're 'LSb' endian; if we write a word but read individual bits,
+   then we'll read the lsb first */
+
+#include <string.h>
+#include <stdlib.h>
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+#include <vtkoggtheora/include/ogg/ogg.h>
+
+#define BUFFER_INCREMENT 256
+
+static const unsigned long mask[]=
+{0x00000000,0x00000001,0x00000003,0x00000007,0x0000000f,
+ 0x0000001f,0x0000003f,0x0000007f,0x000000ff,0x000001ff,
+ 0x000003ff,0x000007ff,0x00000fff,0x00001fff,0x00003fff,
+ 0x00007fff,0x0000ffff,0x0001ffff,0x0003ffff,0x0007ffff,
+ 0x000fffff,0x001fffff,0x003fffff,0x007fffff,0x00ffffff,
+ 0x01ffffff,0x03ffffff,0x07ffffff,0x0fffffff,0x1fffffff,
+ 0x3fffffff,0x7fffffff,0xffffffff };
+
+static const unsigned int mask8B[]=
+{0x00,0x80,0xc0,0xe0,0xf0,0xf8,0xfc,0xfe,0xff};
+
+void oggpack_writeinit(oggpack_buffer *b){
+  memset(b,0,sizeof(*b));
+  b->ptr=b->buffer=_ogg_malloc(BUFFER_INCREMENT);
+  b->buffer[0]='\0';
+  b->storage=BUFFER_INCREMENT;
+}
+
+void oggpackB_writeinit(oggpack_buffer *b){
+  oggpack_writeinit(b);
+}
+
+int oggpack_writecheck(oggpack_buffer *b){
+  if(!b->ptr || !b->storage)return -1;
+  return 0;
+}
+
+int oggpackB_writecheck(oggpack_buffer *b){
+  return oggpack_writecheck(b);
+}
+
+void oggpack_writetrunc(oggpack_buffer *b,long bits){
+  long bytes=bits>>3;
+  if(b->ptr){
+    bits-=bytes*8;
+    b->ptr=b->buffer+bytes;
+    b->endbit=bits;
+    b->endbyte=bytes;
+    *b->ptr&=mask[bits];
+  }
+}
+
+void oggpackB_writetrunc(oggpack_buffer *b,long bits){
+  long bytes=bits>>3;
+  if(b->ptr){
+    bits-=bytes*8;
+    b->ptr=b->buffer+bytes;
+    b->endbit=bits;
+    b->endbyte=bytes;
+    *b->ptr&=mask8B[bits];
+  }
+}
+
+/* Takes only up to 32 bits. */
+void oggpack_write(oggpack_buffer *b,unsigned long value,int bits){
+  if(b->endbyte+4>=b->storage){
+    void *ret;
+    if(!b->ptr)return;
+    ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT);
+    if(!ret){
+      oggpack_writeclear(b);
+      return;
+    }
+    b->buffer=ret;
+    b->storage+=BUFFER_INCREMENT;
+    b->ptr=b->buffer+b->endbyte;
+  }
+
+  value&=mask[bits]; 
+  bits+=b->endbit;
+
+  b->ptr[0]|=value<<b->endbit;  
+  
+  if(bits>=8){
+    b->ptr[1]=(unsigned char)(value>>(8-b->endbit));
+    if(bits>=16){
+      b->ptr[2]=(unsigned char)(value>>(16-b->endbit));
+      if(bits>=24){
+        b->ptr[3]=(unsigned char)(value>>(24-b->endbit));
+        if(bits>=32){
+          if(b->endbit)
+            b->ptr[4]=(unsigned char)(value>>(32-b->endbit));
+          else
+            b->ptr[4]=0;
+        }
+      }
+    }
+  }
+
+  b->endbyte+=bits/8;
+  b->ptr+=bits/8;
+  b->endbit=bits&7;
+}
+
+/* Takes only up to 32 bits. */
+void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits){
+  if(b->endbyte+4>=b->storage){
+    void *ret;
+    if(!b->ptr)return;
+    ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT);
+    if(!ret){
+      oggpack_writeclear(b);
+      return;
+    }
+    b->buffer=ret;
+    b->storage+=BUFFER_INCREMENT;
+    b->ptr=b->buffer+b->endbyte;
+  }
+
+  value=(value&mask[bits])<<(32-bits); 
+  bits+=b->endbit;
+
+  b->ptr[0]|=value>>(24+b->endbit);  
+  
+  if(bits>=8){
+    b->ptr[1]=(unsigned char)(value>>(16+b->endbit));
+    if(bits>=16){
+      b->ptr[2]=(unsigned char)(value>>(8+b->endbit));
+      if(bits>=24){
+        b->ptr[3]=(unsigned char)(value>>(b->endbit));
+        if(bits>=32){
+          if(b->endbit)
+            b->ptr[4]=(unsigned char)(value<<(8-b->endbit));
+          else
+            b->ptr[4]=0;
+        }
+      }
+    }
+  }
+
+  b->endbyte+=bits/8;
+  b->ptr+=bits/8;
+  b->endbit=bits&7;
+}
+
+void oggpack_writealign(oggpack_buffer *b){
+  int bits=8-b->endbit;
+  if(bits<8)
+    oggpack_write(b,0,bits);
+}
+
+void oggpackB_writealign(oggpack_buffer *b){
+  int bits=8-b->endbit;
+  if(bits<8)
+    oggpackB_write(b,0,bits);
+}
+
+static void oggpack_writecopy_helper(oggpack_buffer *b,
+                                     void *source,
+                                     long bits,
+                                     void (*w)(oggpack_buffer *,
+                                               unsigned long,
+                                               int),
+                                     int msb){
+  unsigned char *ptr=(unsigned char *)source;
+
+  long bytes=bits/8;
+  bits-=bytes*8;
+
+  if(b->endbit){
+    int i;
+    /* unaligned copy.  Do it the hard way. */
+    for(i=0;i<bytes;i++)
+      w(b,(unsigned long)(ptr[i]),8);    
+  }else{
+    /* aligned block copy */
+    if(b->endbyte+bytes+1>=b->storage){
+      void *ret;
+      if(!b->ptr)return;
+      b->storage=b->endbyte+bytes+BUFFER_INCREMENT;
+      ret=_ogg_realloc(b->buffer,b->storage);
+      if(!ret){
+        oggpack_writeclear(b);
+        return;
+      }
+      b->buffer=ret;
+      b->ptr=b->buffer+b->endbyte;
+    }
+
+    memmove(b->ptr,source,bytes);
+    b->ptr+=bytes;
+    b->endbyte+=bytes;
+    *b->ptr=0;
+
+  }
+  if(bits){
+    if(msb)
+      w(b,(unsigned long)(ptr[bytes]>>(8-bits)),bits);    
+    else
+      w(b,(unsigned long)(ptr[bytes]),bits);    
+  }
+}
+
+void oggpack_writecopy(oggpack_buffer *b,void *source,long bits){
+  oggpack_writecopy_helper(b,source,bits,oggpack_write,0);
+}
+
+void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits){
+  oggpack_writecopy_helper(b,source,bits,oggpackB_write,1);
+}
+
+void oggpack_reset(oggpack_buffer *b){
+  if(!b->ptr)return;
+  b->ptr=b->buffer;
+  b->buffer[0]=0;
+  b->endbit=b->endbyte=0;
+}
+
+void oggpackB_reset(oggpack_buffer *b){
+  oggpack_reset(b);
+}
+
+void oggpack_writeclear(oggpack_buffer *b){
+  if(b->buffer)_ogg_free(b->buffer);
+  memset(b,0,sizeof(*b));
+}
+
+void oggpackB_writeclear(oggpack_buffer *b){
+  oggpack_writeclear(b);
+}
+
+void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes){
+  memset(b,0,sizeof(*b));
+  b->buffer=b->ptr=buf;
+  b->storage=bytes;
+}
+
+void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes){
+  oggpack_readinit(b,buf,bytes);
+}
+
+/* Read in bits without advancing the bitptr; bits <= 32 */
+long oggpack_look(oggpack_buffer *b,int bits){
+  unsigned long ret;
+  unsigned long m=mask[bits];
+
+  bits+=b->endbit;
+
+  if(b->endbyte+4>=b->storage){
+    /* not the main path */
+    if(b->endbyte*8+bits>b->storage*8)return(-1);
+  }
+  
+  ret=b->ptr[0]>>b->endbit;
+  if(bits>8){
+    ret|=b->ptr[1]<<(8-b->endbit);  
+    if(bits>16){
+      ret|=b->ptr[2]<<(16-b->endbit);  
+      if(bits>24){
+        ret|=b->ptr[3]<<(24-b->endbit);  
+        if(bits>32 && b->endbit)
+          ret|=b->ptr[4]<<(32-b->endbit);
+      }
+    }
+  }
+  return(m&ret);
+}
+
+/* Read in bits without advancing the bitptr; bits <= 32 */
+long oggpackB_look(oggpack_buffer *b,int bits){
+  unsigned long ret;
+  int m=32-bits;
+
+  bits+=b->endbit;
+
+  if(b->endbyte+4>=b->storage){
+    /* not the main path */
+    if(b->endbyte*8+bits>b->storage*8)return(-1);
+  }
+  
+  ret=b->ptr[0]<<(24+b->endbit);
+  if(bits>8){
+    ret|=b->ptr[1]<<(16+b->endbit);  
+    if(bits>16){
+      ret|=b->ptr[2]<<(8+b->endbit);  
+      if(bits>24){
+        ret|=b->ptr[3]<<(b->endbit);  
+        if(bits>32 && b->endbit)
+          ret|=b->ptr[4]>>(8-b->endbit);
+      }
+    }
+  }
+  return ((ret&0xffffffff)>>(m>>1))>>((m+1)>>1);
+}
+
+long oggpack_look1(oggpack_buffer *b){
+  if(b->endbyte>=b->storage)return(-1);
+  return((b->ptr[0]>>b->endbit)&1);
+}
+
+long oggpackB_look1(oggpack_buffer *b){
+  if(b->endbyte>=b->storage)return(-1);
+  return((b->ptr[0]>>(7-b->endbit))&1);
+}
+
+void oggpack_adv(oggpack_buffer *b,int bits){
+  bits+=b->endbit;
+  b->ptr+=bits/8;
+  b->endbyte+=bits/8;
+  b->endbit=bits&7;
+}
+
+void oggpackB_adv(oggpack_buffer *b,int bits){
+  oggpack_adv(b,bits);
+}
+
+void oggpack_adv1(oggpack_buffer *b){
+  if(++(b->endbit)>7){
+    b->endbit=0;
+    b->ptr++;
+    b->endbyte++;
+  }
+}
+
+void oggpackB_adv1(oggpack_buffer *b){
+  oggpack_adv1(b);
+}
+
+/* bits <= 32 */
+long oggpack_read(oggpack_buffer *b,int bits){
+  long ret;
+  unsigned long m=mask[bits];
+
+  bits+=b->endbit;
+
+  if(b->endbyte+4>=b->storage){
+    /* not the main path */
+    ret=-1L;
+    if(b->endbyte*8+bits>b->storage*8)goto overflow;
+  }
+  
+  ret=b->ptr[0]>>b->endbit;
+  if(bits>8){
+    ret|=b->ptr[1]<<(8-b->endbit);  
+    if(bits>16){
+      ret|=b->ptr[2]<<(16-b->endbit);  
+      if(bits>24){
+        ret|=b->ptr[3]<<(24-b->endbit);  
+        if(bits>32 && b->endbit){
+          ret|=b->ptr[4]<<(32-b->endbit);
+        }
+      }
+    }
+  }
+  ret&=m;
+  
+ overflow:
+
+  b->ptr+=bits/8;
+  b->endbyte+=bits/8;
+  b->endbit=bits&7;
+  return(ret);
+}
+
+/* bits <= 32 */
+long oggpackB_read(oggpack_buffer *b,int bits){
+  long ret;
+  long m=32-bits;
+  
+  bits+=b->endbit;
+
+  if(b->endbyte+4>=b->storage){
+    /* not the main path */
+    ret=-1L;
+    if(b->endbyte*8+bits>b->storage*8)goto overflow;
+    /* special case to avoid reading b->ptr[0], which might be past the end of
+        the buffer; also skips some useless accounting */
+    else if(!bits)return(0L);
+  }
+  
+  ret=b->ptr[0]<<(24+b->endbit);
+  if(bits>8){
+    ret|=b->ptr[1]<<(16+b->endbit);  
+    if(bits>16){
+      ret|=b->ptr[2]<<(8+b->endbit);  
+      if(bits>24){
+        ret|=b->ptr[3]<<(b->endbit);  
+        if(bits>32 && b->endbit)
+          ret|=b->ptr[4]>>(8-b->endbit);
+      }
+    }
+  }
+  ret=((ret&0xffffffffUL)>>(m>>1))>>((m+1)>>1);
+  
+ overflow:
+
+  b->ptr+=bits/8;
+  b->endbyte+=bits/8;
+  b->endbit=bits&7;
+  return(ret);
+}
+
+long oggpack_read1(oggpack_buffer *b){
+  long ret;
+  
+  if(b->endbyte>=b->storage){
+    /* not the main path */
+    ret=-1L;
+    goto overflow;
+  }
+
+  ret=(b->ptr[0]>>b->endbit)&1;
+  
+ overflow:
+
+  b->endbit++;
+  if(b->endbit>7){
+    b->endbit=0;
+    b->ptr++;
+    b->endbyte++;
+  }
+  return(ret);
+}
+
+long oggpackB_read1(oggpack_buffer *b){
+  long ret;
+  
+  if(b->endbyte>=b->storage){
+    /* not the main path */
+    ret=-1L;
+    goto overflow;
+  }
+
+  ret=(b->ptr[0]>>(7-b->endbit))&1;
+  
+ overflow:
+
+  b->endbit++;
+  if(b->endbit>7){
+    b->endbit=0;
+    b->ptr++;
+    b->endbyte++;
+  }
+  return(ret);
+}
+
+long oggpack_bytes(oggpack_buffer *b){
+  return(b->endbyte+(b->endbit+7)/8);
+}
+
+long oggpack_bits(oggpack_buffer *b){
+  return(b->endbyte*8+b->endbit);
+}
+
+long oggpackB_bytes(oggpack_buffer *b){
+  return oggpack_bytes(b);
+}
+
+long oggpackB_bits(oggpack_buffer *b){
+  return oggpack_bits(b);
+}
+  
+unsigned char *oggpack_get_buffer(oggpack_buffer *b){
+  return(b->buffer);
+}
+
+unsigned char *oggpackB_get_buffer(oggpack_buffer *b){
+  return oggpack_get_buffer(b);
+}
+
+/* Self test of the bitwise routines; everything else is based on
+   them, so they damned well better be solid. */
+
+#ifdef _V_SELFTEST
+#include <stdio.h>
+
+static int ilog(unsigned int v){
+  int ret=0;
+  while(v){
+    ret++;
+    v>>=1;
+  }
+  return(ret);
+}
+      
+oggpack_buffer o;
+oggpack_buffer r;
+
+void report(char *in){
+  fprintf(stderr,"%s",in);
+  exit(1);
+}
+
+void cliptest(unsigned long *b,int vals,int bits,int *comp,int compsize){
+  long bytes,i;
+  unsigned char *buffer;
+
+  oggpack_reset(&o);
+  for(i=0;i<vals;i++)
+    oggpack_write(&o,b[i],bits?bits:ilog(b[i]));
+  buffer=oggpack_get_buffer(&o);
+  bytes=oggpack_bytes(&o);
+  if(bytes!=compsize)report("wrong number of bytes!\n");
+  for(i=0;i<bytes;i++)if(buffer[i]!=comp[i]){
+    for(i=0;i<bytes;i++)fprintf(stderr,"%x %x\n",(int)buffer[i],(int)comp[i]);
+    report("wrote incorrect value!\n");
+  }
+  oggpack_readinit(&r,buffer,bytes);
+  for(i=0;i<vals;i++){
+    int tbit=bits?bits:ilog(b[i]);
+    if(oggpack_look(&r,tbit)==-1)
+      report("out of data!\n");
+    if(oggpack_look(&r,tbit)!=(b[i]&mask[tbit]))
+      report("looked at incorrect value!\n");
+    if(tbit==1)
+      if(oggpack_look1(&r)!=(b[i]&mask[tbit]))
+        report("looked at single bit incorrect value!\n");
+    if(tbit==1){
+      if(oggpack_read1(&r)!=(b[i]&mask[tbit]))
+        report("read incorrect single bit value!\n");
+    }else{
+    if(oggpack_read(&r,tbit)!=(b[i]&mask[tbit]))
+      report("read incorrect value!\n");
+    }
+  }
+  if(oggpack_bytes(&r)!=bytes)report("leftover bytes after read!\n");
+}
+
+void cliptestB(unsigned long *b,int vals,int bits,int *comp,int compsize){
+  long bytes,i;
+  unsigned char *buffer;
+  
+  oggpackB_reset(&o);
+  for(i=0;i<vals;i++)
+    oggpackB_write(&o,b[i],bits?bits:ilog(b[i]));
+  buffer=oggpackB_get_buffer(&o);
+  bytes=oggpackB_bytes(&o);
+  if(bytes!=compsize)report("wrong number of bytes!\n");
+  for(i=0;i<bytes;i++)if(buffer[i]!=comp[i]){
+    for(i=0;i<bytes;i++)fprintf(stderr,"%x %x\n",(int)buffer[i],(int)comp[i]);
+    report("wrote incorrect value!\n");
+  }
+  oggpackB_readinit(&r,buffer,bytes);
+  for(i=0;i<vals;i++){
+    int tbit=bits?bits:ilog(b[i]);
+    if(oggpackB_look(&r,tbit)==-1)
+      report("out of data!\n");
+    if(oggpackB_look(&r,tbit)!=(b[i]&mask[tbit]))
+      report("looked at incorrect value!\n");
+    if(tbit==1)
+      if(oggpackB_look1(&r)!=(b[i]&mask[tbit]))
+        report("looked at single bit incorrect value!\n");
+    if(tbit==1){
+      if(oggpackB_read1(&r)!=(b[i]&mask[tbit]))
+        report("read incorrect single bit value!\n");
+    }else{
+    if(oggpackB_read(&r,tbit)!=(b[i]&mask[tbit]))
+      report("read incorrect value!\n");
+    }
+  }
+  if(oggpackB_bytes(&r)!=bytes)report("leftover bytes after read!\n");
+}
+
+int main(void){
+  unsigned char *buffer;
+  long bytes,i;
+  static unsigned long testbuffer1[]=
+    {18,12,103948,4325,543,76,432,52,3,65,4,56,32,42,34,21,1,23,32,546,456,7,
+       567,56,8,8,55,3,52,342,341,4,265,7,67,86,2199,21,7,1,5,1,4};
+  int test1size=43;
+
+  static unsigned long testbuffer2[]=
+    {216531625L,1237861823,56732452,131,3212421,12325343,34547562,12313212,
+       1233432,534,5,346435231,14436467,7869299,76326614,167548585,
+       85525151,0,12321,1,349528352};
+  int test2size=21;
+
+  static unsigned long testbuffer3[]=
+    {1,0,14,0,1,0,12,0,1,0,0,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,1,1,1,1,1,0,0,1,
+       0,1,30,1,1,1,0,0,1,0,0,0,12,0,11,0,1,0,0,1};
+  int test3size=56;
+
+  static unsigned long large[]=
+    {2136531625L,2137861823,56732452,131,3212421,12325343,34547562,12313212,
+       1233432,534,5,2146435231,14436467,7869299,76326614,167548585,
+       85525151,0,12321,1,2146528352};
+
+  int onesize=33;
+  static int one[33]={146,25,44,151,195,15,153,176,233,131,196,65,85,172,47,40,
+                    34,242,223,136,35,222,211,86,171,50,225,135,214,75,172,
+                    223,4};
+  static int oneB[33]={150,101,131,33,203,15,204,216,105,193,156,65,84,85,222,
+                       8,139,145,227,126,34,55,244,171,85,100,39,195,173,18,
+                       245,251,128};
+
+  int twosize=6;
+  static int two[6]={61,255,255,251,231,29};
+  static int twoB[6]={247,63,255,253,249,120};
+
+  int threesize=54;
+  static int three[54]={169,2,232,252,91,132,156,36,89,13,123,176,144,32,254,
+                      142,224,85,59,121,144,79,124,23,67,90,90,216,79,23,83,
+                      58,135,196,61,55,129,183,54,101,100,170,37,127,126,10,
+                      100,52,4,14,18,86,77,1};
+  static int threeB[54]={206,128,42,153,57,8,183,251,13,89,36,30,32,144,183,
+                         130,59,240,121,59,85,223,19,228,180,134,33,107,74,98,
+                         233,253,196,135,63,2,110,114,50,155,90,127,37,170,104,
+                         200,20,254,4,58,106,176,144,0};
+
+  int foursize=38;
+  static int four[38]={18,6,163,252,97,194,104,131,32,1,7,82,137,42,129,11,72,
+                     132,60,220,112,8,196,109,64,179,86,9,137,195,208,122,169,
+                     28,2,133,0,1};
+  static int fourB[38]={36,48,102,83,243,24,52,7,4,35,132,10,145,21,2,93,2,41,
+                        1,219,184,16,33,184,54,149,170,132,18,30,29,98,229,67,
+                        129,10,4,32};
+
+  int fivesize=45;
+  static int five[45]={169,2,126,139,144,172,30,4,80,72,240,59,130,218,73,62,
+                     241,24,210,44,4,20,0,248,116,49,135,100,110,130,181,169,
+                     84,75,159,2,1,0,132,192,8,0,0,18,22};
+  static int fiveB[45]={1,84,145,111,245,100,128,8,56,36,40,71,126,78,213,226,
+                        124,105,12,0,133,128,0,162,233,242,67,152,77,205,77,
+                        172,150,169,129,79,128,0,6,4,32,0,27,9,0};
+
+  int sixsize=7;
+  static int six[7]={17,177,170,242,169,19,148};
+  static int sixB[7]={136,141,85,79,149,200,41};
+
+  /* Test read/write together */
+  /* Later we test against pregenerated bitstreams */
+  oggpack_writeinit(&o);
+
+  fprintf(stderr,"\nSmall preclipped packing (LSb): ");
+  cliptest(testbuffer1,test1size,0,one,onesize);
+  fprintf(stderr,"ok.");
+
+  fprintf(stderr,"\nNull bit call (LSb): ");
+  cliptest(testbuffer3,test3size,0,two,twosize);
+  fprintf(stderr,"ok.");
+
+  fprintf(stderr,"\nLarge preclipped packing (LSb): ");
+  cliptest(testbuffer2,test2size,0,three,threesize);
+  fprintf(stderr,"ok.");
+
+  fprintf(stderr,"\n32 bit preclipped packing (LSb): ");
+  oggpack_reset(&o);
+  for(i=0;i<test2size;i++)
+    oggpack_write(&o,large[i],32);
+  buffer=oggpack_get_buffer(&o);
+  bytes=oggpack_bytes(&o);
+  oggpack_readinit(&r,buffer,bytes);
+  for(i=0;i<test2size;i++){
+    if(oggpack_look(&r,32)==-1)report("out of data. failed!");
+    if(oggpack_look(&r,32)!=large[i]){
+      fprintf(stderr,"%ld != %ld (%lx!=%lx):",oggpack_look(&r,32),large[i],
+              oggpack_look(&r,32),large[i]);
+      report("read incorrect value!\n");
+    }
+    oggpack_adv(&r,32);
+  }
+  if(oggpack_bytes(&r)!=bytes)report("leftover bytes after read!\n");
+  fprintf(stderr,"ok.");
+
+  fprintf(stderr,"\nSmall unclipped packing (LSb): ");
+  cliptest(testbuffer1,test1size,7,four,foursize);
+  fprintf(stderr,"ok.");
+
+  fprintf(stderr,"\nLarge unclipped packing (LSb): ");
+  cliptest(testbuffer2,test2size,17,five,fivesize);
+  fprintf(stderr,"ok.");
+
+  fprintf(stderr,"\nSingle bit unclipped packing (LSb): ");
+  cliptest(testbuffer3,test3size,1,six,sixsize);
+  fprintf(stderr,"ok.");
+
+  fprintf(stderr,"\nTesting read past end (LSb): ");
+  oggpack_readinit(&r,"\0\0\0\0\0\0\0\0",8);
+  for(i=0;i<64;i++){
+    if(oggpack_read(&r,1)!=0){
+      fprintf(stderr,"failed; got -1 prematurely.\n");
+      exit(1);
+    }
+  }
+  if(oggpack_look(&r,1)!=-1 ||
+     oggpack_read(&r,1)!=-1){
+      fprintf(stderr,"failed; read past end without -1.\n");
+      exit(1);
+  }
+  oggpack_readinit(&r,"\0\0\0\0\0\0\0\0",8);
+  if(oggpack_read(&r,30)!=0 || oggpack_read(&r,16)!=0){
+      fprintf(stderr,"failed 2; got -1 prematurely.\n");
+      exit(1);
+  }
+
+  if(oggpack_look(&r,18)!=0 ||
+     oggpack_look(&r,18)!=0){
+    fprintf(stderr,"failed 3; got -1 prematurely.\n");
+      exit(1);
+  }
+  if(oggpack_look(&r,19)!=-1 ||
+     oggpack_look(&r,19)!=-1){
+    fprintf(stderr,"failed; read past end without -1.\n");
+      exit(1);
+  }
+  if(oggpack_look(&r,32)!=-1 ||
+     oggpack_look(&r,32)!=-1){
+    fprintf(stderr,"failed; read past end without -1.\n");
+      exit(1);
+  }
+  oggpack_writeclear(&o);
+  fprintf(stderr,"ok.\n");
+
+  /********** lazy, cut-n-paste retest with MSb packing ***********/
+
+  /* Test read/write together */
+  /* Later we test against pregenerated bitstreams */
+  oggpackB_writeinit(&o);
+
+  fprintf(stderr,"\nSmall preclipped packing (MSb): ");
+  cliptestB(testbuffer1,test1size,0,oneB,onesize);
+  fprintf(stderr,"ok.");
+
+  fprintf(stderr,"\nNull bit call (MSb): ");
+  cliptestB(testbuffer3,test3size,0,twoB,twosize);
+  fprintf(stderr,"ok.");
+
+  fprintf(stderr,"\nLarge preclipped packing (MSb): ");
+  cliptestB(testbuffer2,test2size,0,threeB,threesize);
+  fprintf(stderr,"ok.");
+
+  fprintf(stderr,"\n32 bit preclipped packing (MSb): ");
+  oggpackB_reset(&o);
+  for(i=0;i<test2size;i++)
+    oggpackB_write(&o,large[i],32);
+  buffer=oggpackB_get_buffer(&o);
+  bytes=oggpackB_bytes(&o);
+  oggpackB_readinit(&r,buffer,bytes);
+  for(i=0;i<test2size;i++){
+    if(oggpackB_look(&r,32)==-1)report("out of data. failed!");
+    if(oggpackB_look(&r,32)!=large[i]){
+      fprintf(stderr,"%ld != %ld (%lx!=%lx):",oggpackB_look(&r,32),large[i],
+              oggpackB_look(&r,32),large[i]);
+      report("read incorrect value!\n");
+    }
+    oggpackB_adv(&r,32);
+  }
+  if(oggpackB_bytes(&r)!=bytes)report("leftover bytes after read!\n");
+  fprintf(stderr,"ok.");
+
+  fprintf(stderr,"\nSmall unclipped packing (MSb): ");
+  cliptestB(testbuffer1,test1size,7,fourB,foursize);
+  fprintf(stderr,"ok.");
+
+  fprintf(stderr,"\nLarge unclipped packing (MSb): ");
+  cliptestB(testbuffer2,test2size,17,fiveB,fivesize);
+  fprintf(stderr,"ok.");
+
+  fprintf(stderr,"\nSingle bit unclipped packing (MSb): ");
+  cliptestB(testbuffer3,test3size,1,sixB,sixsize);
+  fprintf(stderr,"ok.");
+
+  fprintf(stderr,"\nTesting read past end (MSb): ");
+  oggpackB_readinit(&r,"\0\0\0\0\0\0\0\0",8);
+  for(i=0;i<64;i++){
+    if(oggpackB_read(&r,1)!=0){
+      fprintf(stderr,"failed; got -1 prematurely.\n");
+      exit(1);
+    }
+  }
+  if(oggpackB_look(&r,1)!=-1 ||
+     oggpackB_read(&r,1)!=-1){
+      fprintf(stderr,"failed; read past end without -1.\n");
+      exit(1);
+  }
+  oggpackB_readinit(&r,"\0\0\0\0\0\0\0\0",8);
+  if(oggpackB_read(&r,30)!=0 || oggpackB_read(&r,16)!=0){
+      fprintf(stderr,"failed 2; got -1 prematurely.\n");
+      exit(1);
+  }
+
+  if(oggpackB_look(&r,18)!=0 ||
+     oggpackB_look(&r,18)!=0){
+    fprintf(stderr,"failed 3; got -1 prematurely.\n");
+      exit(1);
+  }
+  if(oggpackB_look(&r,19)!=-1 ||
+     oggpackB_look(&r,19)!=-1){
+    fprintf(stderr,"failed; read past end without -1.\n");
+      exit(1);
+  }
+  if(oggpackB_look(&r,32)!=-1 ||
+     oggpackB_look(&r,32)!=-1){
+    fprintf(stderr,"failed; read past end without -1.\n");
+      exit(1);
+  }
+  oggpackB_writeclear(&o);
+  fprintf(stderr,"ok.\n\n");
+
+
+  return(0);
+}  
+#endif  /* _V_SELFTEST */
+
+#undef BUFFER_INCREMENT
diff --git a/VTK/Utilities/vtkoggtheora/libogg-1.1.4/src/framing.c b/VTK/Utilities/vtkoggtheora/libogg-1.1.4/src/framing.c
new file mode 100644
index 0000000..2fa702a
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libogg-1.1.4/src/framing.c
@@ -0,0 +1,1881 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2009             *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+ function: code raw packets into framed OggSquish stream and
+           decode Ogg streams back into raw packets
+ last mod: $Id: framing.c 16051 2009-05-27 05:00:06Z xiphmont $
+
+ note: The CRC code is directly derived from public domain code by
+ Ross Williams (ross@guest.adelaide.edu.au).  See docs/framing.html
+ for details.
+
+ ********************************************************************/
+
+#include <stdlib.h>
+#include <string.h>
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+#include <vtkoggtheora/include/ogg/ogg.h>
+
+/* A complete description of Ogg framing exists in docs/framing.html */
+
+int ogg_page_version(const ogg_page *og){
+  return((int)(og->header[4]));
+}
+
+int ogg_page_continued(const ogg_page *og){
+  return((int)(og->header[5]&0x01));
+}
+
+int ogg_page_bos(const ogg_page *og){
+  return((int)(og->header[5]&0x02));
+}
+
+int ogg_page_eos(const ogg_page *og){
+  return((int)(og->header[5]&0x04));
+}
+
+ogg_int64_t ogg_page_granulepos(const ogg_page *og){
+  unsigned char *page=og->header;
+  ogg_int64_t granulepos=page[13]&(0xff);
+  granulepos= (granulepos<<8)|(page[12]&0xff);
+  granulepos= (granulepos<<8)|(page[11]&0xff);
+  granulepos= (granulepos<<8)|(page[10]&0xff);
+  granulepos= (granulepos<<8)|(page[9]&0xff);
+  granulepos= (granulepos<<8)|(page[8]&0xff);
+  granulepos= (granulepos<<8)|(page[7]&0xff);
+  granulepos= (granulepos<<8)|(page[6]&0xff);
+  return(granulepos);
+}
+
+int ogg_page_serialno(const ogg_page *og){
+  return(og->header[14] |
+         (og->header[15]<<8) |
+         (og->header[16]<<16) |
+         (og->header[17]<<24));
+}
+ 
+long ogg_page_pageno(const ogg_page *og){
+  return(og->header[18] |
+         (og->header[19]<<8) |
+         (og->header[20]<<16) |
+         (og->header[21]<<24));
+}
+
+
+
+/* returns the number of packets that are completed on this page (if
+   the leading packet is begun on a previous page, but ends on this
+   page, it's counted */
+
+/* NOTE:
+If a page consists of a packet begun on a previous page, and a new
+packet begun (but not completed) on this page, the return will be:
+  ogg_page_packets(page)   ==1, 
+  ogg_page_continued(page) !=0
+
+If a page happens to be a single packet that was begun on a
+previous page, and spans to the next page (in the case of a three or
+more page packet), the return will be: 
+  ogg_page_packets(page)   ==0, 
+  ogg_page_continued(page) !=0
+*/
+
+int ogg_page_packets(const ogg_page *og){
+  int i,n=og->header[26],count=0;
+  for(i=0;i<n;i++)
+    if(og->header[27+i]<255)count++;
+  return(count);
+}
+
+
+#if 0
+/* helper to initialize lookup for direct-table CRC (illustrative; we
+   use the static init below) */
+
+static ogg_uint32_t _ogg_crc_entry(unsigned long index){
+  int           i;
+  unsigned long r;
+
+  r = index << 24;
+  for (i=0; i<8; i++)
+    if (r & 0x80000000UL)
+      r = (r << 1) ^ 0x04c11db7; /* The same as the ethernet generator
+                                    polynomial, although we use an
+                                    unreflected alg and an init/final
+                                    of 0, not 0xffffffff */
+    else
+       r<<=1;
+ return (r & 0xffffffffUL);
+}
+#endif
+
+static const ogg_uint32_t crc_lookup[256]={
+  0x00000000,0x04c11db7,0x09823b6e,0x0d4326d9,
+  0x130476dc,0x17c56b6b,0x1a864db2,0x1e475005,
+  0x2608edb8,0x22c9f00f,0x2f8ad6d6,0x2b4bcb61,
+  0x350c9b64,0x31cd86d3,0x3c8ea00a,0x384fbdbd,
+  0x4c11db70,0x48d0c6c7,0x4593e01e,0x4152fda9,
+  0x5f15adac,0x5bd4b01b,0x569796c2,0x52568b75,
+  0x6a1936c8,0x6ed82b7f,0x639b0da6,0x675a1011,
+  0x791d4014,0x7ddc5da3,0x709f7b7a,0x745e66cd,
+  0x9823b6e0,0x9ce2ab57,0x91a18d8e,0x95609039,
+  0x8b27c03c,0x8fe6dd8b,0x82a5fb52,0x8664e6e5,
+  0xbe2b5b58,0xbaea46ef,0xb7a96036,0xb3687d81,
+  0xad2f2d84,0xa9ee3033,0xa4ad16ea,0xa06c0b5d,
+  0xd4326d90,0xd0f37027,0xddb056fe,0xd9714b49,
+  0xc7361b4c,0xc3f706fb,0xceb42022,0xca753d95,
+  0xf23a8028,0xf6fb9d9f,0xfbb8bb46,0xff79a6f1,
+  0xe13ef6f4,0xe5ffeb43,0xe8bccd9a,0xec7dd02d,
+  0x34867077,0x30476dc0,0x3d044b19,0x39c556ae,
+  0x278206ab,0x23431b1c,0x2e003dc5,0x2ac12072,
+  0x128e9dcf,0x164f8078,0x1b0ca6a1,0x1fcdbb16,
+  0x018aeb13,0x054bf6a4,0x0808d07d,0x0cc9cdca,
+  0x7897ab07,0x7c56b6b0,0x71159069,0x75d48dde,
+  0x6b93dddb,0x6f52c06c,0x6211e6b5,0x66d0fb02,
+  0x5e9f46bf,0x5a5e5b08,0x571d7dd1,0x53dc6066,
+  0x4d9b3063,0x495a2dd4,0x44190b0d,0x40d816ba,
+  0xaca5c697,0xa864db20,0xa527fdf9,0xa1e6e04e,
+  0xbfa1b04b,0xbb60adfc,0xb6238b25,0xb2e29692,
+  0x8aad2b2f,0x8e6c3698,0x832f1041,0x87ee0df6,
+  0x99a95df3,0x9d684044,0x902b669d,0x94ea7b2a,
+  0xe0b41de7,0xe4750050,0xe9362689,0xedf73b3e,
+  0xf3b06b3b,0xf771768c,0xfa325055,0xfef34de2,
+  0xc6bcf05f,0xc27dede8,0xcf3ecb31,0xcbffd686,
+  0xd5b88683,0xd1799b34,0xdc3abded,0xd8fba05a,
+  0x690ce0ee,0x6dcdfd59,0x608edb80,0x644fc637,
+  0x7a089632,0x7ec98b85,0x738aad5c,0x774bb0eb,
+  0x4f040d56,0x4bc510e1,0x46863638,0x42472b8f,
+  0x5c007b8a,0x58c1663d,0x558240e4,0x51435d53,
+  0x251d3b9e,0x21dc2629,0x2c9f00f0,0x285e1d47,
+  0x36194d42,0x32d850f5,0x3f9b762c,0x3b5a6b9b,
+  0x0315d626,0x07d4cb91,0x0a97ed48,0x0e56f0ff,
+  0x1011a0fa,0x14d0bd4d,0x19939b94,0x1d528623,
+  0xf12f560e,0xf5ee4bb9,0xf8ad6d60,0xfc6c70d7,
+  0xe22b20d2,0xe6ea3d65,0xeba91bbc,0xef68060b,
+  0xd727bbb6,0xd3e6a601,0xdea580d8,0xda649d6f,
+  0xc423cd6a,0xc0e2d0dd,0xcda1f604,0xc960ebb3,
+  0xbd3e8d7e,0xb9ff90c9,0xb4bcb610,0xb07daba7,
+  0xae3afba2,0xaafbe615,0xa7b8c0cc,0xa379dd7b,
+  0x9b3660c6,0x9ff77d71,0x92b45ba8,0x9675461f,
+  0x8832161a,0x8cf30bad,0x81b02d74,0x857130c3,
+  0x5d8a9099,0x594b8d2e,0x5408abf7,0x50c9b640,
+  0x4e8ee645,0x4a4ffbf2,0x470cdd2b,0x43cdc09c,
+  0x7b827d21,0x7f436096,0x7200464f,0x76c15bf8,
+  0x68860bfd,0x6c47164a,0x61043093,0x65c52d24,
+  0x119b4be9,0x155a565e,0x18197087,0x1cd86d30,
+  0x029f3d35,0x065e2082,0x0b1d065b,0x0fdc1bec,
+  0x3793a651,0x3352bbe6,0x3e119d3f,0x3ad08088,
+  0x2497d08d,0x2056cd3a,0x2d15ebe3,0x29d4f654,
+  0xc5a92679,0xc1683bce,0xcc2b1d17,0xc8ea00a0,
+  0xd6ad50a5,0xd26c4d12,0xdf2f6bcb,0xdbee767c,
+  0xe3a1cbc1,0xe760d676,0xea23f0af,0xeee2ed18,
+  0xf0a5bd1d,0xf464a0aa,0xf9278673,0xfde69bc4,
+  0x89b8fd09,0x8d79e0be,0x803ac667,0x84fbdbd0,
+  0x9abc8bd5,0x9e7d9662,0x933eb0bb,0x97ffad0c,
+  0xafb010b1,0xab710d06,0xa6322bdf,0xa2f33668,
+  0xbcb4666d,0xb8757bda,0xb5365d03,0xb1f740b4};
+
+/* init the encode/decode logical stream state */
+
+int ogg_stream_init(ogg_stream_state *os,int serialno){
+  if(os){
+    memset(os,0,sizeof(*os));
+    os->body_storage=16*1024;
+    os->lacing_storage=1024;
+
+    os->body_data=_ogg_malloc(os->body_storage*sizeof(*os->body_data));
+    os->lacing_vals=_ogg_malloc(os->lacing_storage*sizeof(*os->lacing_vals));
+    os->granule_vals=_ogg_malloc(os->lacing_storage*sizeof(*os->granule_vals));
+
+    if(!os->body_data || !os->lacing_vals || !os->granule_vals){
+      ogg_stream_clear(os);
+      return -1;
+    }
+
+    os->serialno=serialno;
+
+    return(0);
+  }
+  return(-1);
+} 
+
+/* async/delayed error detection for the ogg_stream_state */
+int ogg_stream_check(ogg_stream_state *os){
+  if(!os || !os->body_data) return -1;
+  return 0;
+}
+
+/* _clear does not free os, only the non-flat storage within */
+int ogg_stream_clear(ogg_stream_state *os){
+  if(os){
+    if(os->body_data)_ogg_free(os->body_data);
+    if(os->lacing_vals)_ogg_free(os->lacing_vals);
+    if(os->granule_vals)_ogg_free(os->granule_vals);
+
+    memset(os,0,sizeof(*os));    
+  }
+  return(0);
+} 
+
+int ogg_stream_destroy(ogg_stream_state *os){
+  if(os){
+    ogg_stream_clear(os);
+    _ogg_free(os);
+  }
+  return(0);
+} 
+
+/* Helpers for ogg_stream_encode; this keeps the structure and
+   what's happening fairly clear */
+
+static int _os_body_expand(ogg_stream_state *os,int needed){
+  if(os->body_storage<=os->body_fill+needed){
+    void *ret;
+    ret=_ogg_realloc(os->body_data,(os->body_storage+needed+1024)*
+                     sizeof(*os->body_data));
+    if(!ret){
+      ogg_stream_clear(os);
+      return -1;
+    }
+    os->body_storage+=(needed+1024);
+    os->body_data=ret;
+  }
+  return 0;
+}
+
+static int _os_lacing_expand(ogg_stream_state *os,int needed){
+  if(os->lacing_storage<=os->lacing_fill+needed){
+    void *ret;
+    ret=_ogg_realloc(os->lacing_vals,(os->lacing_storage+needed+32)*
+                     sizeof(*os->lacing_vals));
+    if(!ret){
+      ogg_stream_clear(os);
+      return -1;
+    }
+    os->lacing_vals=ret;
+    ret=_ogg_realloc(os->granule_vals,(os->lacing_storage+needed+32)*
+                     sizeof(*os->granule_vals));
+    if(!ret){
+      ogg_stream_clear(os);
+      return -1;
+    }
+    os->granule_vals=ret;
+    os->lacing_storage+=(needed+32);
+  }
+  return 0;
+}
+
+/* checksum the page */
+/* Direct table CRC; note that this will be faster in the future if we
+   perform the checksum silmultaneously with other copies */
+
+void ogg_page_checksum_set(ogg_page *og){
+  if(og){
+    ogg_uint32_t crc_reg=0;
+    int i;
+
+    /* safety; needed for API behavior, but not framing code */
+    og->header[22]=0;
+    og->header[23]=0;
+    og->header[24]=0;
+    og->header[25]=0;
+    
+    for(i=0;i<og->header_len;i++)
+      crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->header[i]];
+    for(i=0;i<og->body_len;i++)
+      crc_reg=(crc_reg<<8)^crc_lookup[((crc_reg >> 24)&0xff)^og->body[i]];
+    
+    og->header[22]=(unsigned char)(crc_reg&0xff);
+    og->header[23]=(unsigned char)((crc_reg>>8)&0xff);
+    og->header[24]=(unsigned char)((crc_reg>>16)&0xff);
+    og->header[25]=(unsigned char)((crc_reg>>24)&0xff);
+  }
+}
+
+/* submit data to the internal buffer of the framing engine */
+int ogg_stream_iovecin(ogg_stream_state *os, ogg_iovec_t *iov, int count,
+                       long e_o_s, ogg_int64_t granulepos){
+
+  int bytes = 0, lacing_vals, i;
+
+  if(ogg_stream_check(os)) return -1;
+  if(!iov) return 0;
+ 
+  for (i = 0; i < count; ++i) bytes += (int)iov[i].iov_len;
+  lacing_vals=bytes/255+1;
+
+  if(os->body_returned){
+    /* advance packet data according to the body_returned pointer. We
+       had to keep it around to return a pointer into the buffer last
+       call */
+    
+    os->body_fill-=os->body_returned;
+    if(os->body_fill)
+      memmove(os->body_data,os->body_data+os->body_returned,
+              os->body_fill);
+    os->body_returned=0;
+  }
+ 
+  /* make sure we have the buffer storage */
+  if(_os_body_expand(os,bytes) || _os_lacing_expand(os,lacing_vals))
+    return -1;
+
+  /* Copy in the submitted packet.  Yes, the copy is a waste; this is
+     the liability of overly clean abstraction for the time being.  It
+     will actually be fairly easy to eliminate the extra copy in the
+     future */
+
+  for (i = 0; i < count; ++i) {
+    memcpy(os->body_data+os->body_fill, iov[i].iov_base, iov[i].iov_len);
+    os->body_fill += (int)iov[i].iov_len;
+  }
+
+  /* Store lacing vals for this packet */
+  for(i=0;i<lacing_vals-1;i++){
+    os->lacing_vals[os->lacing_fill+i]=255;
+    os->granule_vals[os->lacing_fill+i]=os->granulepos;
+  }
+  os->lacing_vals[os->lacing_fill+i]=bytes%255;
+  os->granulepos=os->granule_vals[os->lacing_fill+i]=granulepos;
+
+  /* flag the first segment as the beginning of the packet */
+  os->lacing_vals[os->lacing_fill]|= 0x100;
+
+  os->lacing_fill+=lacing_vals;
+
+  /* for the sake of completeness */
+  os->packetno++;
+
+  if(e_o_s)os->e_o_s=1;
+
+  return(0);
+}
+
+int ogg_stream_packetin(ogg_stream_state *os,ogg_packet *op){
+  ogg_iovec_t iov;
+  iov.iov_base = op->packet;
+  iov.iov_len = op->bytes;
+  return ogg_stream_iovecin(os, &iov, 1, op->e_o_s, op->granulepos);
+}
+
+/* This will flush remaining packets into a page (returning nonzero),
+   even if there is not enough data to trigger a flush normally
+   (undersized page). If there are no packets or partial packets to
+   flush, ogg_stream_flush returns 0.  Note that ogg_stream_flush will
+   try to flush a normal sized page like ogg_stream_pageout; a call to
+   ogg_stream_flush does not guarantee that all packets have flushed.
+   Only a return value of 0 from ogg_stream_flush indicates all packet
+   data is flushed into pages.
+
+   since ogg_stream_flush will flush the last page in a stream even if
+   it's undersized, you almost certainly want to use ogg_stream_pageout
+   (and *not* ogg_stream_flush) unless you specifically need to flush 
+   an page regardless of size in the middle of a stream. */
+
+int ogg_stream_flush(ogg_stream_state *os,ogg_page *og){
+  int i;
+  int vals=0;
+  int maxvals=(os->lacing_fill>255?255:os->lacing_fill);
+  int bytes=0;
+  long acc=0;
+  ogg_int64_t granule_pos=-1;
+
+  if(ogg_stream_check(os)) return 0;
+  if(maxvals==0)return 0;
+  
+  /* construct a page */
+  /* decide how many segments to include */
+  
+  /* If this is the initial header case, the first page must only include
+     the initial header packet */
+  if(os->b_o_s==0){  /* 'initial header page' case */
+    granule_pos=0;
+    for(vals=0;vals<maxvals;vals++){
+      if((os->lacing_vals[vals]&0x0ff)<255){
+        vals++;
+        break;
+      }
+    }
+  }else{
+    for(vals=0;vals<maxvals;vals++){
+      if(acc>4096)break;
+      acc+=os->lacing_vals[vals]&0x0ff;
+      if((os->lacing_vals[vals]&0xff)<255)
+        granule_pos=os->granule_vals[vals];
+    }
+  }
+  
+  /* construct the header in temp storage */
+  memcpy(os->header,"OggS",4);
+  
+  /* stream structure version */
+  os->header[4]=0x00;
+  
+  /* continued packet flag? */
+  os->header[5]=0x00;
+  if((os->lacing_vals[0]&0x100)==0)os->header[5]|=0x01;
+  /* first page flag? */
+  if(os->b_o_s==0)os->header[5]|=0x02;
+  /* last page flag? */
+  if(os->e_o_s && os->lacing_fill==vals)os->header[5]|=0x04;
+  os->b_o_s=1;
+
+  /* 64 bits of PCM position */
+  for(i=6;i<14;i++){
+    os->header[i]=(unsigned char)(granule_pos&0xff);
+    granule_pos>>=8;
+  }
+
+  /* 32 bits of stream serial number */
+  {
+    long serialno=os->serialno;
+    for(i=14;i<18;i++){
+      os->header[i]=(unsigned char)(serialno&0xff);
+      serialno>>=8;
+    }
+  }
+
+  /* 32 bits of page counter (we have both counter and page header
+     because this val can roll over) */
+  if(os->pageno==-1)os->pageno=0; /* because someone called
+                                     stream_reset; this would be a
+                                     strange thing to do in an
+                                     encode stream, but it has
+                                     plausible uses */
+  {
+    long pageno=os->pageno++;
+    for(i=18;i<22;i++){
+      os->header[i]=(unsigned char)(pageno&0xff);
+      pageno>>=8;
+    }
+  }
+  
+  /* zero for computation; filled in later */
+  os->header[22]=0;
+  os->header[23]=0;
+  os->header[24]=0;
+  os->header[25]=0;
+  
+  /* segment table */
+  os->header[26]=(unsigned char)(vals&0xff);
+  for(i=0;i<vals;i++)
+    bytes+=os->header[i+27]=(unsigned char)(os->lacing_vals[i]&0xff);
+  
+  /* set pointers in the ogg_page struct */
+  og->header=os->header;
+  og->header_len=os->header_fill=vals+27;
+  og->body=os->body_data+os->body_returned;
+  og->body_len=bytes;
+  
+  /* advance the lacing data and set the body_returned pointer */
+  
+  os->lacing_fill-=vals;
+  memmove(os->lacing_vals,os->lacing_vals+vals,os->lacing_fill*sizeof(*os->lacing_vals));
+  memmove(os->granule_vals,os->granule_vals+vals,os->lacing_fill*sizeof(*os->granule_vals));
+  os->body_returned+=bytes;
+  
+  /* calculate the checksum */
+  
+  ogg_page_checksum_set(og);
+
+  /* done */
+  return(1);
+}
+
+
+/* This constructs pages from buffered packet segments.  The pointers
+returned are to static buffers; do not free. The returned buffers are
+good only until the next call (using the same ogg_stream_state) */
+
+int ogg_stream_pageout(ogg_stream_state *os, ogg_page *og){
+  if(ogg_stream_check(os)) return 0;
+
+  if((os->e_o_s&&os->lacing_fill) ||          /* 'were done, now flush' case */
+     os->body_fill-os->body_returned > 4096 ||/* 'page nominal size' case */
+     os->lacing_fill>=255 ||                  /* 'segment table full' case */
+     (os->lacing_fill&&!os->b_o_s)){          /* 'initial header page' case */
+        
+    return(ogg_stream_flush(os,og));
+  }
+  
+  /* not enough data to construct a page and not end of stream */
+  return 0;
+}
+
+int ogg_stream_eos(ogg_stream_state *os){
+  if(ogg_stream_check(os)) return 1;
+  return os->e_o_s;
+}
+
+/* DECODING PRIMITIVES: packet streaming layer **********************/
+
+/* This has two layers to place more of the multi-serialno and paging
+   control in the application's hands.  First, we expose a data buffer
+   using ogg_sync_buffer().  The app either copies into the
+   buffer, or passes it directly to read(), etc.  We then call
+   ogg_sync_wrote() to tell how many bytes we just added.
+
+   Pages are returned (pointers into the buffer in ogg_sync_state)
+   by ogg_sync_pageout().  The page is then submitted to
+   ogg_stream_pagein() along with the appropriate
+   ogg_stream_state* (ie, matching serialno).  We then get raw
+   packets out calling ogg_stream_packetout() with a
+   ogg_stream_state. */
+
+/* initialize the struct to a known state */
+int ogg_sync_init(ogg_sync_state *oy){
+  if(oy){
+    oy->storage = -1; /* used as a readiness flag */
+    memset(oy,0,sizeof(*oy));
+  }
+  return(0);
+}
+
+/* clear non-flat storage within */
+int ogg_sync_clear(ogg_sync_state *oy){
+  if(oy){
+    if(oy->data)_ogg_free(oy->data);
+    memset(oy,0,sizeof(*oy));
+  }
+  return(0);
+}
+
+int ogg_sync_destroy(ogg_sync_state *oy){
+  if(oy){
+    ogg_sync_clear(oy);
+    _ogg_free(oy);
+  }
+  return(0);
+}
+
+int ogg_sync_check(ogg_sync_state *oy){
+  if(oy->storage<0) return -1;
+  return 0;
+}
+
+char *ogg_sync_buffer(ogg_sync_state *oy, long size){
+  if(ogg_sync_check(oy)) return NULL;
+
+  /* first, clear out any space that has been previously returned */
+  if(oy->returned){
+    oy->fill-=oy->returned;
+    if(oy->fill>0)
+      memmove(oy->data,oy->data+oy->returned,oy->fill);
+    oy->returned=0;
+  }
+
+  if(size>oy->storage-oy->fill){
+    /* We need to extend the internal buffer */
+    long newsize=size+oy->fill+4096; /* an extra page to be nice */
+    void *ret;
+
+    if(oy->data)
+      ret=_ogg_realloc(oy->data,newsize);
+    else
+      ret=_ogg_malloc(newsize);
+    if(!ret){
+      ogg_sync_clear(oy);
+      return NULL;
+    }
+    oy->data=ret;
+    oy->storage=newsize;
+  }
+
+  /* expose a segment at least as large as requested at the fill mark */
+  return((char *)oy->data+oy->fill);
+}
+
+int ogg_sync_wrote(ogg_sync_state *oy, long bytes){
+  if(ogg_sync_check(oy))return -1;
+  if(oy->fill+bytes>oy->storage)return -1;
+  oy->fill+=bytes;
+  return(0);
+}
+
+/* sync the stream.  This is meant to be useful for finding page
+   boundaries.
+
+   return values for this:
+  -n) skipped n bytes
+   0) page not ready; more data (no bytes skipped)
+   n) page synced at current location; page length n bytes
+   
+*/
+
+long ogg_sync_pageseek(ogg_sync_state *oy,ogg_page *og){
+  unsigned char *page=oy->data+oy->returned;
+  unsigned char *next;
+  long bytes=oy->fill-oy->returned;
+
+  if(ogg_sync_check(oy))return 0;
+  
+  if(oy->headerbytes==0){
+    int headerbytes,i;
+    if(bytes<27)return(0); /* not enough for a header */
+    
+    /* verify capture pattern */
+    if(memcmp(page,"OggS",4))goto sync_fail;
+    
+    headerbytes=page[26]+27;
+    if(bytes<headerbytes)return(0); /* not enough for header + seg table */
+    
+    /* count up body length in the segment table */
+    
+    for(i=0;i<page[26];i++)
+      oy->bodybytes+=page[27+i];
+    oy->headerbytes=headerbytes;
+  }
+  
+  if(oy->bodybytes+oy->headerbytes>bytes)return(0);
+  
+  /* The whole test page is buffered.  Verify the checksum */
+  {
+    /* Grab the checksum bytes, set the header field to zero */
+    char chksum[4];
+    ogg_page log;
+    
+    memcpy(chksum,page+22,4);
+    memset(page+22,0,4);
+    
+    /* set up a temp page struct and recompute the checksum */
+    log.header=page;
+    log.header_len=oy->headerbytes;
+    log.body=page+oy->headerbytes;
+    log.body_len=oy->bodybytes;
+    ogg_page_checksum_set(&log);
+    
+    /* Compare */
+    if(memcmp(chksum,page+22,4)){
+      /* D'oh.  Mismatch! Corrupt page (or miscapture and not a page
+         at all) */
+      /* replace the computed checksum with the one actually read in */
+      memcpy(page+22,chksum,4);
+      
+      /* Bad checksum. Lose sync */
+      goto sync_fail;
+    }
+  }
+  
+  /* yes, have a whole page all ready to go */
+  {
+    unsigned char *page=oy->data+oy->returned;
+    long bytes;
+
+    if(og){
+      og->header=page;
+      og->header_len=oy->headerbytes;
+      og->body=page+oy->headerbytes;
+      og->body_len=oy->bodybytes;
+    }
+
+    oy->unsynced=0;
+    oy->returned+=(bytes=oy->headerbytes+oy->bodybytes);
+    oy->headerbytes=0;
+    oy->bodybytes=0;
+    return(bytes);
+  }
+  
+ sync_fail:
+  
+  oy->headerbytes=0;
+  oy->bodybytes=0;
+  
+  /* search for possible capture */
+  next=memchr(page+1,'O',bytes-1);
+  if(!next)
+    next=oy->data+oy->fill;
+
+  oy->returned=(int)(next-oy->data);
+  return((long)-(next-page));
+}
+
+/* sync the stream and get a page.  Keep trying until we find a page.
+   Supress 'sync errors' after reporting the first.
+
+   return values:
+   -1) recapture (hole in data)
+    0) need more data
+    1) page returned
+
+   Returns pointers into buffered data; invalidated by next call to
+   _stream, _clear, _init, or _buffer */
+
+int ogg_sync_pageout(ogg_sync_state *oy, ogg_page *og){
+
+  if(ogg_sync_check(oy))return 0;
+
+  /* all we need to do is verify a page at the head of the stream
+     buffer.  If it doesn't verify, we look for the next potential
+     frame */
+
+  for(;;){
+    long ret=ogg_sync_pageseek(oy,og);
+    if(ret>0){
+      /* have a page */
+      return(1);
+    }
+    if(ret==0){
+      /* need more data */
+      return(0);
+    }
+    
+    /* head did not start a synced page... skipped some bytes */
+    if(!oy->unsynced){
+      oy->unsynced=1;
+      return(-1);
+    }
+
+    /* loop. keep looking */
+
+  }
+}
+
+/* add the incoming page to the stream state; we decompose the page
+   into packet segments here as well. */
+
+int ogg_stream_pagein(ogg_stream_state *os, ogg_page *og){
+  unsigned char *header=og->header;
+  unsigned char *body=og->body;
+  long           bodysize=og->body_len;
+  int            segptr=0;
+
+  int version=ogg_page_version(og);
+  int continued=ogg_page_continued(og);
+  int bos=ogg_page_bos(og);
+  int eos=ogg_page_eos(og);
+  ogg_int64_t granulepos=ogg_page_granulepos(og);
+  int serialno=ogg_page_serialno(og);
+  long pageno=ogg_page_pageno(og);
+  int segments=header[26];
+  
+  if(ogg_stream_check(os)) return -1;
+
+  /* clean up 'returned data' */
+  {
+    long lr=os->lacing_returned;
+    long br=os->body_returned;
+
+    /* body data */
+    if(br){
+      os->body_fill-=br;
+      if(os->body_fill)
+        memmove(os->body_data,os->body_data+br,os->body_fill);
+      os->body_returned=0;
+    }
+
+    if(lr){
+      /* segment table */
+      if(os->lacing_fill-lr){
+        memmove(os->lacing_vals,os->lacing_vals+lr,
+                (os->lacing_fill-lr)*sizeof(*os->lacing_vals));
+        memmove(os->granule_vals,os->granule_vals+lr,
+                (os->lacing_fill-lr)*sizeof(*os->granule_vals));
+      }
+      os->lacing_fill-=lr;
+      os->lacing_packet-=lr;
+      os->lacing_returned=0;
+    }
+  }
+
+  /* check the serial number */
+  if(serialno!=os->serialno)return(-1);
+  if(version>0)return(-1);
+
+  if(_os_lacing_expand(os,segments+1)) return -1;
+
+  /* are we in sequence? */
+  if(pageno!=os->pageno){
+    int i;
+
+    /* unroll previous partial packet (if any) */
+    for(i=os->lacing_packet;i<os->lacing_fill;i++)
+      os->body_fill-=os->lacing_vals[i]&0xff;
+    os->lacing_fill=os->lacing_packet;
+
+    /* make a note of dropped data in segment table */
+    if(os->pageno!=-1){
+      os->lacing_vals[os->lacing_fill++]=0x400;
+      os->lacing_packet++;
+    }
+  }
+
+  /* are we a 'continued packet' page?  If so, we may need to skip
+     some segments */
+  if(continued){
+    if(os->lacing_fill<1 || 
+       os->lacing_vals[os->lacing_fill-1]==0x400){
+      bos=0;
+      for(;segptr<segments;segptr++){
+        int val=header[27+segptr];
+        body+=val;
+        bodysize-=val;
+        if(val<255){
+          segptr++;
+          break;
+        }
+      }
+    }
+  }
+  
+  if(bodysize){
+    if(_os_body_expand(os,bodysize)) return -1;
+    memcpy(os->body_data+os->body_fill,body,bodysize);
+    os->body_fill+=bodysize;
+  }
+
+  {
+    int saved=-1;
+    while(segptr<segments){
+      int val=header[27+segptr];
+      os->lacing_vals[os->lacing_fill]=val;
+      os->granule_vals[os->lacing_fill]=-1;
+      
+      if(bos){
+        os->lacing_vals[os->lacing_fill]|=0x100;
+        bos=0;
+      }
+      
+      if(val<255)saved=os->lacing_fill;
+      
+      os->lacing_fill++;
+      segptr++;
+      
+      if(val<255)os->lacing_packet=os->lacing_fill;
+    }
+  
+    /* set the granulepos on the last granuleval of the last full packet */
+    if(saved!=-1){
+      os->granule_vals[saved]=granulepos;
+    }
+
+  }
+
+  if(eos){
+    os->e_o_s=1;
+    if(os->lacing_fill>0)
+      os->lacing_vals[os->lacing_fill-1]|=0x200;
+  }
+
+  os->pageno=pageno+1;
+
+  return(0);
+}
+
+/* clear things to an initial state.  Good to call, eg, before seeking */
+int ogg_sync_reset(ogg_sync_state *oy){
+  if(ogg_sync_check(oy))return -1;
+
+  oy->fill=0;
+  oy->returned=0;
+  oy->unsynced=0;
+  oy->headerbytes=0;
+  oy->bodybytes=0;
+  return(0);
+}
+
+int ogg_stream_reset(ogg_stream_state *os){
+  if(ogg_stream_check(os)) return -1;
+
+  os->body_fill=0;
+  os->body_returned=0;
+
+  os->lacing_fill=0;
+  os->lacing_packet=0;
+  os->lacing_returned=0;
+
+  os->header_fill=0;
+
+  os->e_o_s=0;
+  os->b_o_s=0;
+  os->pageno=-1;
+  os->packetno=0;
+  os->granulepos=0;
+
+  return(0);
+}
+
+int ogg_stream_reset_serialno(ogg_stream_state *os,int serialno){
+  if(ogg_stream_check(os)) return -1;
+  ogg_stream_reset(os);
+  os->serialno=serialno;
+  return(0);
+}
+
+static int _packetout(ogg_stream_state *os,ogg_packet *op,int adv){
+
+  /* The last part of decode. We have the stream broken into packet
+     segments.  Now we need to group them into packets (or return the
+     out of sync markers) */
+
+  int ptr=os->lacing_returned;
+
+  if(os->lacing_packet<=ptr)return(0);
+
+  if(os->lacing_vals[ptr]&0x400){
+    /* we need to tell the codec there's a gap; it might need to
+       handle previous packet dependencies. */
+    os->lacing_returned++;
+    os->packetno++;
+    return(-1);
+  }
+
+  if(!op && !adv)return(1); /* just using peek as an inexpensive way
+                               to ask if there's a whole packet
+                               waiting */
+
+  /* Gather the whole packet. We'll have no holes or a partial packet */
+  {
+    int size=os->lacing_vals[ptr]&0xff;
+    int bytes=size;
+    int eos=os->lacing_vals[ptr]&0x200; /* last packet of the stream? */
+    int bos=os->lacing_vals[ptr]&0x100; /* first packet of the stream? */
+
+    while(size==255){
+      int val=os->lacing_vals[++ptr];
+      size=val&0xff;
+      if(val&0x200)eos=0x200;
+      bytes+=size;
+    }
+
+    if(op){
+      op->e_o_s=eos;
+      op->b_o_s=bos;
+      op->packet=os->body_data+os->body_returned;
+      op->packetno=os->packetno;
+      op->granulepos=os->granule_vals[ptr];
+      op->bytes=bytes;
+    }
+
+    if(adv){
+      os->body_returned+=bytes;
+      os->lacing_returned=ptr+1;
+      os->packetno++;
+    }
+  }
+  return(1);
+}
+
+int ogg_stream_packetout(ogg_stream_state *os,ogg_packet *op){
+  if(ogg_stream_check(os)) return 0;
+  return _packetout(os,op,1);
+}
+
+int ogg_stream_packetpeek(ogg_stream_state *os,ogg_packet *op){
+  if(ogg_stream_check(os)) return 0;
+  return _packetout(os,op,0);
+}
+
+void ogg_packet_clear(ogg_packet *op) {
+  _ogg_free(op->packet);
+  memset(op, 0, sizeof(*op));
+}
+
+#ifdef _V_SELFTEST
+#include <stdio.h>
+
+ogg_stream_state os_en, os_de;
+ogg_sync_state oy;
+
+void checkpacket(ogg_packet *op,int len, int no, int pos){
+  long j;
+  static int sequence=0;
+  static int lastno=0;
+
+  if(op->bytes!=len){
+    fprintf(stderr,"incorrect packet length!\n");
+    exit(1);
+  }
+  if(op->granulepos!=pos){
+    fprintf(stderr,"incorrect packet position!\n");
+    exit(1);
+  }
+
+  /* packet number just follows sequence/gap; adjust the input number
+     for that */
+  if(no==0){
+    sequence=0;
+  }else{
+    sequence++;
+    if(no>lastno+1)
+      sequence++;
+  }
+  lastno=no;
+  if(op->packetno!=sequence){
+    fprintf(stderr,"incorrect packet sequence %ld != %d\n",
+            (long)(op->packetno),sequence);
+    exit(1);
+  }
+
+  /* Test data */
+  for(j=0;j<op->bytes;j++)
+    if(op->packet[j]!=((j+no)&0xff)){
+      fprintf(stderr,"body data mismatch (1) at pos %ld: %x!=%lx!\n\n",
+              j,op->packet[j],(j+no)&0xff);
+      exit(1);
+    }
+}
+
+void check_page(unsigned char *data,const int *header,ogg_page *og){
+  long j;
+  /* Test data */
+  for(j=0;j<og->body_len;j++)
+    if(og->body[j]!=data[j]){
+      fprintf(stderr,"body data mismatch (2) at pos %ld: %x!=%x!\n\n",
+              j,data[j],og->body[j]);
+      exit(1);
+    }
+
+  /* Test header */
+  for(j=0;j<og->header_len;j++){
+    if(og->header[j]!=header[j]){
+      fprintf(stderr,"header content mismatch at pos %ld:\n",j);
+      for(j=0;j<header[26]+27;j++)
+        fprintf(stderr," (%ld)%02x:%02x",j,header[j],og->header[j]);
+      fprintf(stderr,"\n");
+      exit(1);
+    }
+  }
+  if(og->header_len!=header[26]+27){
+    fprintf(stderr,"header length incorrect! (%ld!=%d)\n",
+            og->header_len,header[26]+27);
+    exit(1);
+  }
+}
+
+void print_header(ogg_page *og){
+  int j;
+  fprintf(stderr,"\nHEADER:\n");
+  fprintf(stderr,"  capture: %c %c %c %c  version: %d  flags: %x\n",
+          og->header[0],og->header[1],og->header[2],og->header[3],
+          (int)og->header[4],(int)og->header[5]);
+
+  fprintf(stderr,"  granulepos: %d  serialno: %d  pageno: %ld\n",
+          (og->header[9]<<24)|(og->header[8]<<16)|
+          (og->header[7]<<8)|og->header[6],
+          (og->header[17]<<24)|(og->header[16]<<16)|
+          (og->header[15]<<8)|og->header[14],
+          ((long)(og->header[21])<<24)|(og->header[20]<<16)|
+          (og->header[19]<<8)|og->header[18]);
+
+  fprintf(stderr,"  checksum: %02x:%02x:%02x:%02x\n  segments: %d (",
+          (int)og->header[22],(int)og->header[23],
+          (int)og->header[24],(int)og->header[25],
+          (int)og->header[26]);
+
+  for(j=27;j<og->header_len;j++)
+    fprintf(stderr,"%d ",(int)og->header[j]);
+  fprintf(stderr,")\n\n");
+}
+
+void copy_page(ogg_page *og){
+  unsigned char *temp=_ogg_malloc(og->header_len);
+  memcpy(temp,og->header,og->header_len);
+  og->header=temp;
+
+  temp=_ogg_malloc(og->body_len);
+  memcpy(temp,og->body,og->body_len);
+  og->body=temp;
+}
+
+void free_page(ogg_page *og){
+  _ogg_free (og->header);
+  _ogg_free (og->body);
+}
+
+void error(void){
+  fprintf(stderr,"error!\n");
+  exit(1);
+}
+
+/* 17 only */
+const int head1_0[] = {0x4f,0x67,0x67,0x53,0,0x06,
+                       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+                       0x01,0x02,0x03,0x04,0,0,0,0,
+                       0x15,0xed,0xec,0x91,
+                       1,
+                       17};
+
+/* 17, 254, 255, 256, 500, 510, 600 byte, pad */
+const int head1_1[] = {0x4f,0x67,0x67,0x53,0,0x02,
+                       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+                       0x01,0x02,0x03,0x04,0,0,0,0,
+                       0x59,0x10,0x6c,0x2c,
+                       1,
+                       17};
+const int head2_1[] = {0x4f,0x67,0x67,0x53,0,0x04,
+                       0x07,0x18,0x00,0x00,0x00,0x00,0x00,0x00,
+                       0x01,0x02,0x03,0x04,1,0,0,0,
+                       0x89,0x33,0x85,0xce,
+                       13,
+                       254,255,0,255,1,255,245,255,255,0,
+                       255,255,90};
+
+/* nil packets; beginning,middle,end */
+const int head1_2[] = {0x4f,0x67,0x67,0x53,0,0x02,
+                       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+                       0x01,0x02,0x03,0x04,0,0,0,0,
+                       0xff,0x7b,0x23,0x17,
+                       1,
+                       0};
+const int head2_2[] = {0x4f,0x67,0x67,0x53,0,0x04,
+                       0x07,0x28,0x00,0x00,0x00,0x00,0x00,0x00,
+                       0x01,0x02,0x03,0x04,1,0,0,0,
+                       0x5c,0x3f,0x66,0xcb,
+                       17,
+                       17,254,255,0,0,255,1,0,255,245,255,255,0,
+                       255,255,90,0};
+
+/* large initial packet */
+const int head1_3[] = {0x4f,0x67,0x67,0x53,0,0x02,
+                       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+                       0x01,0x02,0x03,0x04,0,0,0,0,
+                       0x01,0x27,0x31,0xaa,
+                       18,
+                       255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255,10};
+
+const int head2_3[] = {0x4f,0x67,0x67,0x53,0,0x04,
+                       0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
+                       0x01,0x02,0x03,0x04,1,0,0,0,
+                       0x7f,0x4e,0x8a,0xd2,
+                       4,
+                       255,4,255,0};
+
+
+/* continuing packet test */
+const int head1_4[] = {0x4f,0x67,0x67,0x53,0,0x02,
+                       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+                       0x01,0x02,0x03,0x04,0,0,0,0,
+                       0xff,0x7b,0x23,0x17,
+                       1,
+                       0};
+
+const int head2_4[] = {0x4f,0x67,0x67,0x53,0,0x00,
+                       0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+                       0x01,0x02,0x03,0x04,1,0,0,0,
+                       0x54,0x05,0x51,0xc8,
+                       17,
+                       255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255};
+
+const int head3_4[] = {0x4f,0x67,0x67,0x53,0,0x05,
+                       0x07,0x0c,0x00,0x00,0x00,0x00,0x00,0x00,
+                       0x01,0x02,0x03,0x04,2,0,0,0,
+                       0xc8,0xc3,0xcb,0xed,
+                       5,
+                       10,255,4,255,0};
+
+
+/* page with the 255 segment limit */
+const int head1_5[] = {0x4f,0x67,0x67,0x53,0,0x02,
+                       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+                       0x01,0x02,0x03,0x04,0,0,0,0,
+                       0xff,0x7b,0x23,0x17,
+                       1,
+                       0};
+
+const int head2_5[] = {0x4f,0x67,0x67,0x53,0,0x00,
+                       0x07,0xfc,0x03,0x00,0x00,0x00,0x00,0x00,
+                       0x01,0x02,0x03,0x04,1,0,0,0,
+                       0xed,0x2a,0x2e,0xa7,
+                       255,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10,10,
+                       10,10,10,10,10,10,10};
+
+const int head3_5[] = {0x4f,0x67,0x67,0x53,0,0x04,
+                       0x07,0x00,0x04,0x00,0x00,0x00,0x00,0x00,
+                       0x01,0x02,0x03,0x04,2,0,0,0,
+                       0x6c,0x3b,0x82,0x3d,
+                       1,
+                       50};
+
+
+/* packet that overspans over an entire page */
+const int head1_6[] = {0x4f,0x67,0x67,0x53,0,0x02,
+                       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+                       0x01,0x02,0x03,0x04,0,0,0,0,
+                       0xff,0x7b,0x23,0x17,
+                       1,
+                       0};
+
+const int head2_6[] = {0x4f,0x67,0x67,0x53,0,0x00,
+                       0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
+                       0x01,0x02,0x03,0x04,1,0,0,0,
+                       0x3c,0xd9,0x4d,0x3f,
+                       17,
+                       100,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255};
+
+const int head3_6[] = {0x4f,0x67,0x67,0x53,0,0x01,
+                       0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
+                       0x01,0x02,0x03,0x04,2,0,0,0,
+                       0x01,0xd2,0xe5,0xe5,
+                       17,
+                       255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255,255};
+
+const int head4_6[] = {0x4f,0x67,0x67,0x53,0,0x05,
+                       0x07,0x10,0x00,0x00,0x00,0x00,0x00,0x00,
+                       0x01,0x02,0x03,0x04,3,0,0,0,
+                       0xef,0xdd,0x88,0xde,
+                       7,
+                       255,255,75,255,4,255,0};
+
+/* packet that overspans over an entire page */
+const int head1_7[] = {0x4f,0x67,0x67,0x53,0,0x02,
+                       0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
+                       0x01,0x02,0x03,0x04,0,0,0,0,
+                       0xff,0x7b,0x23,0x17,
+                       1,
+                       0};
+
+const int head2_7[] = {0x4f,0x67,0x67,0x53,0,0x00,
+                       0x07,0x04,0x00,0x00,0x00,0x00,0x00,0x00,
+                       0x01,0x02,0x03,0x04,1,0,0,0,
+                       0x3c,0xd9,0x4d,0x3f,
+                       17,
+                       100,255,255,255,255,255,255,255,255,
+                       255,255,255,255,255,255,255,255};
+
+const int head3_7[] = {0x4f,0x67,0x67,0x53,0,0x05,
+                       0x07,0x08,0x00,0x00,0x00,0x00,0x00,0x00,
+                       0x01,0x02,0x03,0x04,2,0,0,0,
+                       0xd4,0xe0,0x60,0xe5,
+                       1,0};
+
+void test_pack(const int *pl, const int **headers, int byteskip, 
+               int pageskip, int packetskip){
+  unsigned char *data=_ogg_malloc(1024*1024); /* for scripted test cases only */
+  long inptr=0;
+  long outptr=0;
+  long deptr=0;
+  long depacket=0;
+  long granule_pos=7,pageno=0;
+  int i,j,packets,pageout=pageskip;
+  int eosflag=0;
+  int bosflag=0;
+
+  int byteskipcount=0;
+
+  ogg_stream_reset(&os_en);
+  ogg_stream_reset(&os_de);
+  ogg_sync_reset(&oy);
+
+  for(packets=0;packets<packetskip;packets++)
+    depacket+=pl[packets];
+
+  for(packets=0;;packets++)if(pl[packets]==-1)break;
+
+  for(i=0;i<packets;i++){
+    /* construct a test packet */
+    ogg_packet op;
+    int len=pl[i];
+    
+    op.packet=data+inptr;
+    op.bytes=len;
+    op.e_o_s=(pl[i+1]<0?1:0);
+    op.granulepos=granule_pos;
+
+    granule_pos+=1024;
+
+    for(j=0;j<len;j++)data[inptr++]=i+j;
+
+    /* submit the test packet */
+    ogg_stream_packetin(&os_en,&op);
+
+    /* retrieve any finished pages */
+    {
+      ogg_page og;
+      
+      while(ogg_stream_pageout(&os_en,&og)){
+        /* We have a page.  Check it carefully */
+
+        fprintf(stderr,"%ld, ",pageno);
+
+        if(headers[pageno]==NULL){
+          fprintf(stderr,"coded too many pages!\n");
+          exit(1);
+        }
+
+        check_page(data+outptr,headers[pageno],&og);
+
+        outptr+=og.body_len;
+        pageno++;
+        if(pageskip){
+          bosflag=1;
+          pageskip--;
+          deptr+=og.body_len;
+        }
+
+        /* have a complete page; submit it to sync/decode */
+
+        {
+          ogg_page og_de;
+          ogg_packet op_de,op_de2;
+          char *buf=ogg_sync_buffer(&oy,og.header_len+og.body_len);
+          char *next=buf;
+          byteskipcount+=og.header_len;
+          if(byteskipcount>byteskip){
+            memcpy(next,og.header,byteskipcount-byteskip);
+            next+=byteskipcount-byteskip;
+            byteskipcount=byteskip;
+          }
+
+          byteskipcount+=og.body_len;
+          if(byteskipcount>byteskip){
+            memcpy(next,og.body,byteskipcount-byteskip);
+            next+=byteskipcount-byteskip;
+            byteskipcount=byteskip;
+          }
+
+          ogg_sync_wrote(&oy,next-buf);
+
+          while(1){
+            int ret=ogg_sync_pageout(&oy,&og_de);
+            if(ret==0)break;
+            if(ret<0)continue;
+            /* got a page.  Happy happy.  Verify that it's good. */
+            
+            fprintf(stderr,"(%ld), ",pageout);
+
+            check_page(data+deptr,headers[pageout],&og_de);
+            deptr+=og_de.body_len;
+            pageout++;
+
+            /* submit it to deconstitution */
+            ogg_stream_pagein(&os_de,&og_de);
+
+            /* packets out? */
+            while(ogg_stream_packetpeek(&os_de,&op_de2)>0){
+              ogg_stream_packetpeek(&os_de,NULL);
+              ogg_stream_packetout(&os_de,&op_de); /* just catching them all */
+              
+              /* verify peek and out match */
+              if(memcmp(&op_de,&op_de2,sizeof(op_de))){
+                fprintf(stderr,"packetout != packetpeek! pos=%ld\n",
+                        depacket);
+                exit(1);
+              }
+
+              /* verify the packet! */
+              /* check data */
+              if(memcmp(data+depacket,op_de.packet,op_de.bytes)){
+                fprintf(stderr,"packet data mismatch in decode! pos=%ld\n",
+                        depacket);
+                exit(1);
+              }
+              /* check bos flag */
+              if(bosflag==0 && op_de.b_o_s==0){
+                fprintf(stderr,"b_o_s flag not set on packet!\n");
+                exit(1);
+              }
+              if(bosflag && op_de.b_o_s){
+                fprintf(stderr,"b_o_s flag incorrectly set on packet!\n");
+                exit(1);
+              }
+              bosflag=1;
+              depacket+=op_de.bytes;
+              
+              /* check eos flag */
+              if(eosflag){
+                fprintf(stderr,"Multiple decoded packets with eos flag!\n");
+                exit(1);
+              }
+
+              if(op_de.e_o_s)eosflag=1;
+
+              /* check granulepos flag */
+              if(op_de.granulepos!=-1){
+                fprintf(stderr," granule:%ld ",(long)op_de.granulepos);
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+  _ogg_free(data);
+  if(headers[pageno]!=NULL){
+    fprintf(stderr,"did not write last page!\n");
+    exit(1);
+  }
+  if(headers[pageout]!=NULL){
+    fprintf(stderr,"did not decode last page!\n");
+    exit(1);
+  }
+  if(inptr!=outptr){
+    fprintf(stderr,"encoded page data incomplete!\n");
+    exit(1);
+  }
+  if(inptr!=deptr){
+    fprintf(stderr,"decoded page data incomplete!\n");
+    exit(1);
+  }
+  if(inptr!=depacket){
+    fprintf(stderr,"decoded packet data incomplete!\n");
+    exit(1);
+  }
+  if(!eosflag){
+    fprintf(stderr,"Never got a packet with EOS set!\n");
+    exit(1);
+  }
+  fprintf(stderr,"ok.\n");
+}
+
+int main(void){
+
+  ogg_stream_init(&os_en,0x04030201);
+  ogg_stream_init(&os_de,0x04030201);
+  ogg_sync_init(&oy);
+
+  /* Exercise each code path in the framing code.  Also verify that
+     the checksums are working.  */
+
+  {
+    /* 17 only */
+    const int packets[]={17, -1};
+    const int *headret[]={head1_0,NULL};
+    
+    fprintf(stderr,"testing single page encoding... ");
+    test_pack(packets,headret,0,0,0);
+  }
+
+  {
+    /* 17, 254, 255, 256, 500, 510, 600 byte, pad */
+    const int packets[]={17, 254, 255, 256, 500, 510, 600, -1};
+    const int *headret[]={head1_1,head2_1,NULL};
+    
+    fprintf(stderr,"testing basic page encoding... ");
+    test_pack(packets,headret,0,0,0);
+  }
+
+  {
+    /* nil packets; beginning,middle,end */
+    const int packets[]={0,17, 254, 255, 0, 256, 0, 500, 510, 600, 0, -1};
+    const int *headret[]={head1_2,head2_2,NULL};
+    
+    fprintf(stderr,"testing basic nil packets... ");
+    test_pack(packets,headret,0,0,0);
+  }
+
+  {
+    /* large initial packet */
+    const int packets[]={4345,259,255,-1};
+    const int *headret[]={head1_3,head2_3,NULL};
+    
+    fprintf(stderr,"testing initial-packet lacing > 4k... ");
+    test_pack(packets,headret,0,0,0);
+  }
+
+  {
+    /* continuing packet test */
+    const int packets[]={0,4345,259,255,-1};
+    const int *headret[]={head1_4,head2_4,head3_4,NULL};
+    
+    fprintf(stderr,"testing single packet page span... ");
+    test_pack(packets,headret,0,0,0);
+  }
+
+  /* page with the 255 segment limit */
+  {
+
+    const int packets[]={0,10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,10,
+                   10,10,10,10,10,10,10,50,-1};
+    const int *headret[]={head1_5,head2_5,head3_5,NULL};
+    
+    fprintf(stderr,"testing max packet segments... ");
+    test_pack(packets,headret,0,0,0);
+  }
+
+  {
+    /* packet that overspans over an entire page */
+    const int packets[]={0,100,9000,259,255,-1};
+    const int *headret[]={head1_6,head2_6,head3_6,head4_6,NULL};
+    
+    fprintf(stderr,"testing very large packets... ");
+    test_pack(packets,headret,0,0,0);
+  }
+
+  {
+    /* test for the libogg 1.1.1 resync in large continuation bug
+       found by Josh Coalson)  */
+    const int packets[]={0,100,9000,259,255,-1};
+    const int *headret[]={head1_6,head2_6,head3_6,head4_6,NULL};
+    
+    fprintf(stderr,"testing continuation resync in very large packets... ");
+    test_pack(packets,headret,100,2,3);
+  }
+
+  {
+    /* term only page.  why not? */
+    const int packets[]={0,100,4080,-1};
+    const int *headret[]={head1_7,head2_7,head3_7,NULL};
+    
+    fprintf(stderr,"testing zero data page (1 nil packet)... ");
+    test_pack(packets,headret,0,0,0);
+  }
+
+
+
+  {
+    /* build a bunch of pages for testing */
+    unsigned char *data=_ogg_malloc(1024*1024);
+    int pl[]={0,100,4079,2956,2057,76,34,912,0,234,1000,1000,1000,300,-1};
+    int inptr=0,i,j;
+    ogg_page og[5];
+    
+    ogg_stream_reset(&os_en);
+
+    for(i=0;pl[i]!=-1;i++){
+      ogg_packet op;
+      int len=pl[i];
+      
+      op.packet=data+inptr;
+      op.bytes=len;
+      op.e_o_s=(pl[i+1]<0?1:0);
+      op.granulepos=(i+1)*1000;
+
+      for(j=0;j<len;j++)data[inptr++]=i+j;
+      ogg_stream_packetin(&os_en,&op);
+    }
+
+    _ogg_free(data);
+
+    /* retrieve finished pages */
+    for(i=0;i<5;i++){
+      if(ogg_stream_pageout(&os_en,&og[i])==0){
+        fprintf(stderr,"Too few pages output building sync tests!\n");
+        exit(1);
+      }
+      copy_page(&og[i]);
+    }
+
+    /* Test lost pages on pagein/packetout: no rollback */
+    {
+      ogg_page temp;
+      ogg_packet test;
+
+      fprintf(stderr,"Testing loss of pages... ");
+
+      ogg_sync_reset(&oy);
+      ogg_stream_reset(&os_de);
+      for(i=0;i<5;i++){
+        memcpy(ogg_sync_buffer(&oy,og[i].header_len),og[i].header,
+               og[i].header_len);
+        ogg_sync_wrote(&oy,og[i].header_len);
+        memcpy(ogg_sync_buffer(&oy,og[i].body_len),og[i].body,og[i].body_len);
+        ogg_sync_wrote(&oy,og[i].body_len);
+      }
+
+      ogg_sync_pageout(&oy,&temp);
+      ogg_stream_pagein(&os_de,&temp);
+      ogg_sync_pageout(&oy,&temp);
+      ogg_stream_pagein(&os_de,&temp);
+      ogg_sync_pageout(&oy,&temp);
+      /* skip */
+      ogg_sync_pageout(&oy,&temp);
+      ogg_stream_pagein(&os_de,&temp);
+
+      /* do we get the expected results/packets? */
+      
+      if(ogg_stream_packetout(&os_de,&test)!=1)error();
+      checkpacket(&test,0,0,0);
+      if(ogg_stream_packetout(&os_de,&test)!=1)error();
+      checkpacket(&test,100,1,-1);
+      if(ogg_stream_packetout(&os_de,&test)!=1)error();
+      checkpacket(&test,4079,2,3000);
+      if(ogg_stream_packetout(&os_de,&test)!=-1){
+        fprintf(stderr,"Error: loss of page did not return error\n");
+        exit(1);
+      }
+      if(ogg_stream_packetout(&os_de,&test)!=1)error();
+      checkpacket(&test,76,5,-1);
+      if(ogg_stream_packetout(&os_de,&test)!=1)error();
+      checkpacket(&test,34,6,-1);
+      fprintf(stderr,"ok.\n");
+    }
+
+    /* Test lost pages on pagein/packetout: rollback with continuation */
+    {
+      ogg_page temp;
+      ogg_packet test;
+
+      fprintf(stderr,"Testing loss of pages (rollback required)... ");
+
+      ogg_sync_reset(&oy);
+      ogg_stream_reset(&os_de);
+      for(i=0;i<5;i++){
+        memcpy(ogg_sync_buffer(&oy,og[i].header_len),og[i].header,
+               og[i].header_len);
+        ogg_sync_wrote(&oy,og[i].header_len);
+        memcpy(ogg_sync_buffer(&oy,og[i].body_len),og[i].body,og[i].body_len);
+        ogg_sync_wrote(&oy,og[i].body_len);
+      }
+
+      ogg_sync_pageout(&oy,&temp);
+      ogg_stream_pagein(&os_de,&temp);
+      ogg_sync_pageout(&oy,&temp);
+      ogg_stream_pagein(&os_de,&temp);
+      ogg_sync_pageout(&oy,&temp);
+      ogg_stream_pagein(&os_de,&temp);
+      ogg_sync_pageout(&oy,&temp);
+      /* skip */
+      ogg_sync_pageout(&oy,&temp);
+      ogg_stream_pagein(&os_de,&temp);
+
+      /* do we get the expected results/packets? */
+      
+      if(ogg_stream_packetout(&os_de,&test)!=1)error();
+      checkpacket(&test,0,0,0);
+      if(ogg_stream_packetout(&os_de,&test)!=1)error();
+      checkpacket(&test,100,1,-1);
+      if(ogg_stream_packetout(&os_de,&test)!=1)error();
+      checkpacket(&test,4079,2,3000);
+      if(ogg_stream_packetout(&os_de,&test)!=1)error();
+      checkpacket(&test,2956,3,4000);
+      if(ogg_stream_packetout(&os_de,&test)!=-1){
+        fprintf(stderr,"Error: loss of page did not return error\n");
+        exit(1);
+      }
+      if(ogg_stream_packetout(&os_de,&test)!=1)error();
+      checkpacket(&test,300,13,14000);
+      fprintf(stderr,"ok.\n");
+    }
+    
+    /* the rest only test sync */
+    {
+      ogg_page og_de;
+      /* Test fractional page inputs: incomplete capture */
+      fprintf(stderr,"Testing sync on partial inputs... ");
+      ogg_sync_reset(&oy);
+      memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header,
+             3);
+      ogg_sync_wrote(&oy,3);
+      if(ogg_sync_pageout(&oy,&og_de)>0)error();
+      
+      /* Test fractional page inputs: incomplete fixed header */
+      memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+3,
+             20);
+      ogg_sync_wrote(&oy,20);
+      if(ogg_sync_pageout(&oy,&og_de)>0)error();
+      
+      /* Test fractional page inputs: incomplete header */
+      memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+23,
+             5);
+      ogg_sync_wrote(&oy,5);
+      if(ogg_sync_pageout(&oy,&og_de)>0)error();
+      
+      /* Test fractional page inputs: incomplete body */
+      
+      memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+28,
+             og[1].header_len-28);
+      ogg_sync_wrote(&oy,og[1].header_len-28);
+      if(ogg_sync_pageout(&oy,&og_de)>0)error();
+      
+      memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,1000);
+      ogg_sync_wrote(&oy,1000);
+      if(ogg_sync_pageout(&oy,&og_de)>0)error();
+      
+      memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body+1000,
+             og[1].body_len-1000);
+      ogg_sync_wrote(&oy,og[1].body_len-1000);
+      if(ogg_sync_pageout(&oy,&og_de)<=0)error();
+      
+      fprintf(stderr,"ok.\n");
+    }
+
+    /* Test fractional page inputs: page + incomplete capture */
+    {
+      ogg_page og_de;
+      fprintf(stderr,"Testing sync on 1+partial inputs... ");
+      ogg_sync_reset(&oy); 
+
+      memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header,
+             og[1].header_len);
+      ogg_sync_wrote(&oy,og[1].header_len);
+
+      memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,
+             og[1].body_len);
+      ogg_sync_wrote(&oy,og[1].body_len);
+
+      memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header,
+             20);
+      ogg_sync_wrote(&oy,20);
+      if(ogg_sync_pageout(&oy,&og_de)<=0)error();
+      if(ogg_sync_pageout(&oy,&og_de)>0)error();
+
+      memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header+20,
+             og[1].header_len-20);
+      ogg_sync_wrote(&oy,og[1].header_len-20);
+      memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,
+             og[1].body_len);
+      ogg_sync_wrote(&oy,og[1].body_len);
+      if(ogg_sync_pageout(&oy,&og_de)<=0)error();
+
+      fprintf(stderr,"ok.\n");
+    }
+    
+    /* Test recapture: garbage + page */
+    {
+      ogg_page og_de;
+      fprintf(stderr,"Testing search for capture... ");
+      ogg_sync_reset(&oy); 
+      
+      /* 'garbage' */
+      memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,
+             og[1].body_len);
+      ogg_sync_wrote(&oy,og[1].body_len);
+
+      memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header,
+             og[1].header_len);
+      ogg_sync_wrote(&oy,og[1].header_len);
+
+      memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,
+             og[1].body_len);
+      ogg_sync_wrote(&oy,og[1].body_len);
+
+      memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header,
+             20);
+      ogg_sync_wrote(&oy,20);
+      if(ogg_sync_pageout(&oy,&og_de)>0)error();
+      if(ogg_sync_pageout(&oy,&og_de)<=0)error();
+      if(ogg_sync_pageout(&oy,&og_de)>0)error();
+
+      memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header+20,
+             og[2].header_len-20);
+      ogg_sync_wrote(&oy,og[2].header_len-20);
+      memcpy(ogg_sync_buffer(&oy,og[2].body_len),og[2].body,
+             og[2].body_len);
+      ogg_sync_wrote(&oy,og[2].body_len);
+      if(ogg_sync_pageout(&oy,&og_de)<=0)error();
+
+      fprintf(stderr,"ok.\n");
+    }
+
+    /* Test recapture: page + garbage + page */
+    {
+      ogg_page og_de;
+      fprintf(stderr,"Testing recapture... ");
+      ogg_sync_reset(&oy); 
+
+      memcpy(ogg_sync_buffer(&oy,og[1].header_len),og[1].header,
+             og[1].header_len);
+      ogg_sync_wrote(&oy,og[1].header_len);
+
+      memcpy(ogg_sync_buffer(&oy,og[1].body_len),og[1].body,
+             og[1].body_len);
+      ogg_sync_wrote(&oy,og[1].body_len);
+
+      memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header,
+             og[2].header_len);
+      ogg_sync_wrote(&oy,og[2].header_len);
+
+      memcpy(ogg_sync_buffer(&oy,og[2].header_len),og[2].header,
+             og[2].header_len);
+      ogg_sync_wrote(&oy,og[2].header_len);
+
+      if(ogg_sync_pageout(&oy,&og_de)<=0)error();
+
+      memcpy(ogg_sync_buffer(&oy,og[2].body_len),og[2].body,
+             og[2].body_len-5);
+      ogg_sync_wrote(&oy,og[2].body_len-5);
+
+      memcpy(ogg_sync_buffer(&oy,og[3].header_len),og[3].header,
+             og[3].header_len);
+      ogg_sync_wrote(&oy,og[3].header_len);
+
+      memcpy(ogg_sync_buffer(&oy,og[3].body_len),og[3].body,
+             og[3].body_len);
+      ogg_sync_wrote(&oy,og[3].body_len);
+
+      if(ogg_sync_pageout(&oy,&og_de)>0)error();
+      if(ogg_sync_pageout(&oy,&og_de)<=0)error();
+
+      fprintf(stderr,"ok.\n");
+    }
+
+    /* Free page data that was previously copied */
+    {
+      for(i=0;i<5;i++){
+        free_page(&og[i]);
+      }
+    }
+  }    
+
+  return(0);
+}
+
+#endif
+
+
+
+
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/AUTHORS b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/AUTHORS
new file mode 100644
index 0000000..17e85d4
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/AUTHORS
@@ -0,0 +1,47 @@
+Monty <monty@xiph.org>
+	- Original VP3 port
+
+Ralph Giles
+Timothy B. Terriberry
+Monty
+	- Ongoing development
+	
+Dan B. Miller
+	- Pre alpha3 development
+	
+Wim Tayman
+Dan Lenski
+Nils Pipenbrinck
+Monty
+	- MMX optimized functions
+	
+Aaron Colwell
+Thomas Vander Stichele
+Jan Gerber
+Conrad Parker
+Cristian Adam
+Sebastian Pippin
+	- Bug fixes, enhancements, build systems.
+	
+Mauricio Piacentini
+	- Original win32 projects and example ports
+	- VP3->Theora transcoder
+
+Silvia Pfeiffer
+	- Figures for the spec
+
+Michael Smith
+Andre Pang
+calc
+ccheney
+brendan
+Edward Hervey
+Adam Moss
+Colin Ward
+Jeremy C. Reed
+Arc Riley
+Rodolphe Ortalo
+	- Bug fixes
+
+
+and other Xiph.org contributors
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/CHANGES b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/CHANGES
new file mode 100644
index 0000000..60bd052
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/CHANGES
@@ -0,0 +1,189 @@
+libtheora 1.1alpha2 (2009 May 26)
+
+ - Reduce lambda for small quantizers.
+ - New encoder fDCT does better on smooth gradients
+ - Use SATD for mode decisions (1-2% bitrate reduction)
+ - Assembly rewrite for new features and general speed up
+ - Share code between the encoder and decoder for performance
+ - Fix 4:2:2 decoding and telemetry
+ - MSVC project files updated, but assembly is disabled.
+ - New configure option --disable-spec to work around toolchain
+   detection failures.
+ - Limit symbol exports on MacOS X.
+ - Port remaining unit tests from the 1.0 release.
+
+libtheora 1.1alpha1 (2009 March 27)
+
+ - Encoder rewrite with much improved vbr quality/bitrate and
+   better tracking of the target rate in cbr mode.
+ - MSVC project files do not work in this release.
+
+libtheora 1.0 (2008 November 3)
+
+ - Merge x86 assembly for forward DCT from Thusnelda branch.
+ - Update 32 bit MMX with loop filter fix.
+ - Check for an uninitialized state before dereferencing in propagating
+   decode calls.
+ - Remove all TH_DEBUG statements.
+ - Rename the bitpacker source files copied from libogg to avoid
+   confusing simple build systems using both libraries.
+ - Declare bitfield entries to be explicitly signed for Solaris cc.
+ - Set quantization parameters to default values when an empty buffer is
+   passed with TH_ENCCTL_SET_QUANT_PARAMS.
+ - Split encoder and decoder tests depending on configure settings.
+ - Return lstylex.sty to the distribution.
+ - Disable inline assembly on gcc versions prior to 3.1.
+ - Remove extern references for OC_*_QUANT_MIN.
+ - Make various data tables static const so they can be read-only.
+ - Remove ENCCTL codes from the old encoder API.
+ - Implement TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE ctl.
+ - Fix segfault when exactly one of the width or height is not a multiple
+   of 16, but the other is.
+ - Compute the correct vertical offset for chroma.
+ - cpuid assembly fix for MSVC.
+ - Add VS2008 project files.
+ - Build updates for 64-bit platforms, Mingw32, VS and XCode.
+ - Do not clobber the cropping rectangle.
+ - Declare ourselves 1.0final to pkg-config to sort after beta releases.
+ - Fix the scons build to include asm in libtheoradec/enc.
+
+libtheora 1.0beta3 (2008 April 16)
+
+ - Build new libtheoradec and libtheoraenc libraries
+   supporting the new API from theora-exp. This API should
+   not be considered stable yet.
+ - Change granule_frame() to return an index as documented.
+   This is a change of behaviour from 1.0beta1.
+ - Document that granule_time() returns the end of the
+   presentation interval.
+ - Use a custom copy of the libogg bitpacker in the decoder
+   to avoid function call overhead.
+ - MMX code improved and ported to MSVC.
+ - Fix a problem with the MMX code on SELinux.
+ - Fix a problem with decoder quantizer initialization.
+ - Fix a page queue problem with png2theora.
+ - Improved robustness.
+ - Updated VS2005 project files.
+ - Dropped build support for Microsoft VS2003.
+ - Dropped build support for the unreleased libogg2.
+ - Added the specification to the autotools build.
+ - Specification corrections.
+
+libtheora 1.0beta2 (2007 October 12)
+
+ - Fix a crash bug on char-is-unsigned architectures (PowerPC)
+ - Fix a buffer sizing issue that caused rare encoder crashes
+ - Fix a buffer alignment issue
+ - Build fixes for MingW32, MSVC
+ - Improved format documentation.
+
+libtheora 1.0beta1 (2007 September 22)
+
+ - Granulepos scheme modified to match other codecs. This bumps
+   the bitstream revision to 3.2.1. Bitstreams marked 3.2.0 are
+   handled correctly by this decoder. Older decoders will show
+   a one frame sync error in the less noticable direction.
+
+libtheora 1.0alpha8 (2007 September 18)
+
+ - Switch to new spec compliant decoder from theora-exp branch.
+   Written by Dr. Timothy Terriberry.
+ - Add support to the encoder for using quantization settings
+   provided by the application.
+ - more assembly optimizations
+
+libtheora 1.0alpha7 (2006 June 20)
+
+ - Enable mmx assembly by default
+ - Avoid some relocations that caused problems on SELinux
+ - Other build fixes
+ - time testing mode (-f) for the dump_video example
+
+libtheora 1.0alpha6 (2006 May 30)
+
+ * Merge theora-mmx simd acceleration (x86_32 and x86_64)
+ * Major RTP payload specification update
+ * Minor format specification updates
+ * Fix some spurious calls to free() instead of _ogg_free()
+ * Fix invalid array indexing in PixelLineSearch()
+ * Improve robustness against invalid input
+ * General warning cleanup
+ * The offset_y member now means what every application thought it meant
+   (offset from the top). This will mean some old files (those with a 
+   non-centered image created with a buggy encoder) will display differently.
+
+libtheora 1.0alpha5 (2005 August 20)
+
+ * Fixed bitrate management bugs that caused popping and encode
+   errors
+ * Fixed a crash problem with the theora_state internals not
+   being intialized properly.
+ * new utility function:
+   - theora_granule_shift()
+ * dump_video example now makes YUV4MPEG files by default, so
+   the results can be fed back to encoder_example and similar
+   tools. The old behavior is restored through the '-r' switch.
+ * ./configure now prints a summary
+ * simple unit test of the comment api under 'make check'
+ * misc code cleanup, warning and leak fixes
+
+libtheora 1.0alpha4 (2004 December 15)
+
+ * first draft of the Theora I Format Specification
+ * API documentation generated from theora.h with Doxygen
+ * fix a double-update bug in the motion analysis
+ * apply the loop filter before filling motion vector border 
+   in the reference frame
+ * new utility functions:
+   - theora_packet_isheader(),
+   - theora_packet_iskeyframe()
+   - theora_granule_frame()
+ * optional support for building without floating point
+ * optional support for building without encode support 
+ * various build and packaging fixes
+ * pkg-config support
+ * SymbianOS build support
+
+libtheora 1.0alpha3 (2004 March 20)
+
+ UPDATE: on 2004 July 1 the Theora I bitstream format was frozen. Files
+ produced by the libtheora 1.0alpha3 reference encoder will always be
+ decodable by the Theora I spec.
+
+ * Bitstream info header FORMAT CHANGES:
+   - move the granulepos shift field to maintain byte alignment longer.
+   - reserve 5 additional bits for subsampling and interlace flags.
+ * Bitstream setup header FORMAT CHANGES:
+   - support for a range of interpolated quant matricies.
+   - include the in-loop block filter coeff.
+ * Bitsteam data packet FORMAT CHANGES:
+   - Reserve a bit for per-block Q index selection.
+   - Flip the coded image orientation for compatibility with VP3.
+     This allows lossless transcoding of VP3 content, but files
+     encoded with earlier theora releases would play upside down.
+ * example VP3 lossless transcoder
+ * optional support for libogg2
+ * timing improvements in the example player
+ * packaging and build system updates and fixes
+
+libtheora 1.0alpha2 (2003 June 9)
+
+ * bitstream FORMAT CHANGES:
+   - store the quant tables in a third setup header for
+     future encoder flexibility
+   - store the huffman tables in the third setup header
+   - add a field for marking the colorspace to the info header
+   - add crop parameters for non-multiple-of-16 frame sizes
+   - add a second vorbiscomment-style metadata header
+ * API changes to handle multiple headers with a single 
+   theora_decode_header() call, like libvorbis
+ * code cleanup and minor fixes
+ * new dump_video code example/utility
+ * experimental win32 code examples
+
+libtheora 1.0alpha1 (2002 September 25)
+
+ * First release of the theora reference implementation
+ * Port of the newly opened VP3 code to the Ogg container
+ * Rewrite of the code for portability and to use the libogg bitpacker
+
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/COPYING b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/COPYING
new file mode 100644
index 0000000..c35e188
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/COPYING
@@ -0,0 +1,28 @@
+Copyright (C) 2002-2007 Xiph.org Foundation
+
+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 the Xiph.org Foundation 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 FOUNDATION
+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.
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/LICENSE b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/LICENSE
new file mode 100644
index 0000000..5e5ec08
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/LICENSE
@@ -0,0 +1,18 @@
+Please see the file COPYING for the copyright license for this software.
+
+In addition to and irrespective of the copyright license associated
+with this software, On2 Technologies, Inc. makes the following statement
+regarding technology used in this software:
+
+  On2 represents and warrants that it shall not assert any rights 
+  relating to infringement of On2's registered patents, nor initiate
+  any litigation asserting such rights, against any person who, or
+  entity which utilizes the On2 VP3 Codec Software, including any 
+  use, distribution, and sale of said Software; which make changes, 
+  modifications, and improvements in said Software; and to use,
+  distribute, and sell said changes as well as applications for other 
+  fields of use.
+
+This reference implementation is originally derived from the On2 VP3
+Codec Software, and the Theora video format is essentially compatible
+with the VP3 video format, consisting of a backward-compatible superset.
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/README b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/README
new file mode 100644
index 0000000..b6aa9cd
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/README
@@ -0,0 +1,150 @@
+-------------------------------------------------------------------------
+             The Xiph.org Foundation's libtheora 1.1 alpha release
+-------------------------------------------------------------------------
+
+*** What is Theora?
+
+Theora is Xiph.Org's first publicly released video codec, intended
+for use within the Foundation's Ogg multimedia streaming system.
+Theora is derived directly from On2's VP3 codec; Currently the 
+encoders are nearly identical, but Theora will make use of new
+features supported by the decoder to improve on what is possible
+with VP3.
+
+The 1.1 release features a completely rewritten encoder, offering
+better performance and compression, and making more complete use
+of the format's feature set.
+
+*** Where is Theora?
+
+Theora's main site is www.theora.org.  Theora and related libraries
+can be gotten from www.theora.org or the main Xiph.Org site at
+www.xiph.org.  Development source is kept in an open subversion 
+repository, see http://theora.org/svn/ for instructions.
+
+-------------------------------------------------------------------------
+Getting started with the code
+-------------------------------------------------------------------------
+
+*** What do I need to build the source?
+
+Requirements summary:
+
+  For libtheora:
+
+      libogg 1.1 or newer.
+
+  For example encoder:
+
+      as above,
+
+      libvorbis and libvorbisenc 1.0.1 or newer.
+
+  For creating a source distribution package:
+
+      as above,
+
+      Doxygen to build the API documentation,
+      pdflatex and fig2dev to build the format specification
+        (transfig package in Ubuntu).
+
+  For the player only:
+
+      as above,
+
+      SDL (Simple Direct media Layer) libraries and headers,
+      OSS audio driver and development headers.
+
+The provided build system is the GNU automake/autoconf system, and
+the main library, libtheora, should already build smoothly on any
+system.  Failure of libtheora to build on a GNU-enabled system is
+considered a bug; please report problems to theora-dev@xiph.org.
+
+Windows build support is included in the win32 directory.
+
+Project files for Apple XCode are included in the macosx directory.
+
+There is also an experimental scons build.
+
+*** How do I use the sample encoder?
+
+The sample encoder takes raw video in YUV4MPEG2 format, as used by
+lavtools, mjpeg-tools and other packages. The encoder expects audio,
+if any, in a separate wave WAV file. Try 'encoder_example -h' for a 
+complete list of options.
+
+An easy way to get raw video and audio files is to use MPlayer as an
+export utility.  The options " -ao pcm -vo yuv4mpeg " will export a
+wav file named audiodump.wav and a YUV video file in the correct
+format for encoder_example as stream.yuv.  Be careful when exporting
+video alone; MPlayer may drop frames to 'keep up' with the audio
+timer.  The example encoder can't properly synchronize input audio and
+video file that aren't in sync to begin with.  
+
+The encoder will also take video or audio on stdin if '-' is specified
+as the input file name.
+
+There is also a 'png2theora' example which accepts a set of image
+files in that format.
+
+*** How do I use the sample player?
+
+The sample player takes an Ogg file on standard in; the file may be
+audio alone, video alone or video with audio.
+
+*** What other tools are available?
+
+The programs in the examples directory are intended as tutorial source 
+for developers using the library. As such they sacrifice features and 
+robustness in the interests of comprehension and should not be 
+considered serious applications.
+
+If you're wanting to just use theora, consider the programs linked
+from http://www.theora.org/. There is playback support in a number
+of common free players, and plugins for major media frameworks.
+Jan Gerber's ffmpeg2theora is an excellent encoding front end.
+
+-------------------------------------------------------------------------
+Troubleshooting the build process
+-------------------------------------------------------------------------
+
+*** Compile error, such as:
+
+encoder_internal.h:664: parse error before `ogg_uint16_t'
+
+This means you have version of libogg prior to 1.1. A *complete* new Ogg 
+install, libs and headers is needed.
+
+Also be sure that there aren't multiple copies of Ogg installed in
+/usr and /usr/local; an older one might be first on the search path
+for libs and headers.
+
+*** Link error, such as:
+
+undefined reference to `oggpackB_stream'
+
+See above; you need libogg 1.1 or later.
+
+*** Link error, such as:
+
+undefined reference to `vorbis_granule_time'
+
+You need libvorbis and libvorbisenc from the 1.0.1 release or later.
+
+*** Link error, such as:
+
+/usr/lib/libSDL.a(SDL_esdaudio.lo): In function `ESD_OpenAudio':
+SDL_esdaudio.lo(.text+0x25d): undefined reference to `esd_play_stream'
+
+Be sure to use an SDL that's built to work with OSS.  If you use an
+SDL that is also built with ESD and/or ALSA support, it will try to
+suck in all those extra libraries at link time too.  That will only
+work if the extra libraries are also installed.
+
+*** Link warning, such as:
+
+libtool: link: warning: library `/usr/lib/libogg.la' was moved.
+libtool: link: warning: library `/usr/lib/libogg.la' was moved.
+
+Re-run theora/autogen.sh after an Ogg or Vorbis rebuild/reinstall
+
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/config.h.in b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/config.h.in
new file mode 100644
index 0000000..6b0e20d
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/config.h.in
@@ -0,0 +1,43 @@
+/* KITWARE_OGGTHEORA_CHANGE - Stripped out unused defines (autoheader pain)
+ * and made it work for universal builds on Mac OS X */
+
+#ifndef THEORA_CONFIG_H
+#define THEORA_CONFIG_H
+
+/* KITWARE_OGGTHEORA_CHANGE - Added to mangle function names */
+#include "vtk_oggtheora_mangle.h"
+
+/* Define to exclude floating point code from the build */
+#cmakedefine THEORA_DISABLE_FLOAT
+
+/* make use of asm optimization */
+#if !defined(__APPLE__)
+#cmakedefine USE_ASM
+#elif !defined(THEORA_DISABLE_ASM)
+#  undef USE_ASM
+#  if defined(__i386__) || defined(__x86_64__)
+#    define USE_ASM 1
+#  endif
+#endif
+
+/* determine whether we should use x86_32 or x86_64 asm (if at all) */
+#if defined(USE_ASM)
+#  if !defined(__APPLE__)
+#cmakedefine OC_X86_ASM
+#cmakedefine OC_X86_64_ASM
+#  else
+#    if defined(__i386__)
+#      define OC_X86_ASM 1
+#    elif defined(__x86_64__)
+#      define OC_X86_64_ASM 1
+#    endif
+#  endif
+#endif
+
+/* never use Cairo */
+#undef HAVE_CAIRO
+
+/* Version number of package */
+#define VERSION "@THEORA_VERSION@"
+
+#endif /* THEORA_CONFIG_H */
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/examples/encoder_example.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/examples/encoder_example.c
new file mode 100644
index 0000000..ebccaed
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/examples/encoder_example.c
@@ -0,0 +1,1544 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function: example encoder application; makes an Ogg Theora/Vorbis
+            file from YUV4MPEG2 and WAV input
+  last mod: $Id: encoder_example.c 15955 2009-04-26 18:05:29Z gmaxwell $
+
+ ********************************************************************/
+
+#if !defined(_REENTRANT)
+#define _REENTRANT
+#endif
+#if !defined(_GNU_SOURCE)
+#define _GNU_SOURCE
+#endif
+#if !defined(_LARGEFILE_SOURCE)
+#define _LARGEFILE_SOURCE
+#endif
+#if !defined(_LARGEFILE64_SOURCE)
+#define _LARGEFILE64_SOURCE
+#endif
+#if !defined(_FILE_OFFSET_BITS)
+#define _FILE_OFFSET_BITS 64
+#endif
+
+#include <stdio.h>
+#if !defined(_WIN32)
+#include <getopt.h>
+#include <unistd.h>
+#else
+#include "getopt.h"
+#endif
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+#include <math.h>
+#include "theora/theoraenc.h"
+#include "vorbis/codec.h"
+#include "vorbis/vorbisenc.h"
+
+#ifdef _WIN32
+/*supply missing headers and functions to Win32. going to hell, I know*/
+#include <fcntl.h>
+#include <io.h>
+
+static double rint(double x)
+{
+  if (x < 0.0)
+    return (double)(int)(x - 0.5);
+  else
+    return (double)(int)(x + 0.5);
+}
+#endif
+
+const char *optstring = "b:e:o:a:A:v:V:s:S:f:F:ck:";
+struct option options [] = {
+  {"begin-time",required_argument,NULL,'b'},
+  {"end-time",required_argument,NULL,'e'},
+  {"output",required_argument,NULL,'o'},
+  {"audio-rate-target",required_argument,NULL,'A'},
+  {"video-rate-target",required_argument,NULL,'V'},
+  {"audio-quality",required_argument,NULL,'a'},
+  {"video-quality",required_argument,NULL,'v'},
+  {"aspect-numerator",required_argument,NULL,'s'},
+  {"aspect-denominator",required_argument,NULL,'S'},
+  {"framerate-numerator",required_argument,NULL,'f'},
+  {"framerate-denominator",required_argument,NULL,'F'},
+  {"vp3-compatible",no_argument,NULL,'c'},
+  {"keyframe-freq",required_argument,NULL,'k'},
+  {NULL,0,NULL,0}
+};
+
+/* You'll go to Hell for using globals. */
+
+FILE *audio=NULL;
+FILE *video=NULL;
+
+int audio_ch=0;
+int audio_hz=0;
+
+float audio_q=.1f;
+int audio_r=-1;
+int vp3_compatible=0;
+
+int frame_w=0;
+int frame_h=0;
+int pic_w=0;
+int pic_h=0;
+int pic_x=0;
+int pic_y=0;
+int video_fps_n=-1;
+int video_fps_d=-1;
+int video_par_n=-1;
+int video_par_d=-1;
+char interlace;
+int src_c_dec_h=2;
+int src_c_dec_v=2;
+int dst_c_dec_h=2;
+int dst_c_dec_v=2;
+char chroma_type[16];
+
+/*The size of each converted frame buffer.*/
+size_t y4m_dst_buf_sz;
+/*The amount to read directly into the converted frame buffer.*/
+size_t y4m_dst_buf_read_sz;
+/*The size of the auxilliary buffer.*/
+size_t y4m_aux_buf_sz;
+/*The amount to read into the auxilliary buffer.*/
+size_t y4m_aux_buf_read_sz;
+
+/*The function used to perform chroma conversion.*/
+typedef void (*y4m_convert_func)(unsigned char *_dst,unsigned char *_aux);
+
+y4m_convert_func y4m_convert=NULL;
+
+int video_r=-1;
+int video_q=48;
+ogg_uint32_t keyframe_frequency=64;
+
+long begin_sec=-1;
+long begin_usec=0;
+long end_sec=-1;
+long end_usec=0;
+
+static void usage(void){
+  fprintf(stderr,
+          "Usage: encoder_example [options] [audio_file] video_file\n\n"
+          "Options: \n\n"
+          "  -o --output <filename.ogv>      file name for encoded output;\n"
+          "                                  If this option is not given, the\n"
+          "                                  compressed data is sent to stdout.\n\n"
+          "  -A --audio-rate-target <n>      bitrate target for Vorbis audio;\n"
+          "                                  use -a and not -A if at all possible,\n"
+          "                                  as -a gives higher quality for a given\n"
+          "                                  bitrate.\n\n"
+          "  -V --video-rate-target <n>      bitrate target for Theora video\n\n"
+          "  -a --audio-quality <n>          Vorbis quality selector from -1 to 10\n"
+          "                                  (-1 yields smallest files but lowest\n"
+          "                                  fidelity; 10 yields highest fidelity\n"
+          "                                  but large files. '2' is a reasonable\n"
+          "                                  default).\n\n"
+          "   -v --video-quality <n>         Theora quality selector from 0 to 10\n"
+          "                                  (0 yields smallest files but lowest\n"
+          "                                  video quality. 10 yields highest\n"
+          "                                  fidelity but large files).\n\n"
+          "   -s --aspect-numerator <n>      Aspect ratio numerator, default is 0\n"
+          "                                  or extracted from YUV input file\n"
+          "   -S --aspect-denominator <n>    Aspect ratio denominator, default is 0\n"
+          "                                  or extracted from YUV input file\n"
+          "   -f --framerate-numerator <n>   Frame rate numerator, can be extracted\n"
+          "                                  from YUV input file. ex: 30000000\n"
+          "   -F --framerate-denominator <n> Frame rate denominator, can be extracted\n"
+          "                                  from YUV input file. ex: 1000000\n"
+          "                                  The frame rate nominator divided by this\n"
+          "                                  determinates the frame rate in units per tick\n"
+          "   -k --keyframe-freq <n>         Keyframe frequency\n"
+          "   -b --begin-time <h:m:s.f>     Begin encoding at offset into input\n"
+          "   -e --end-time <h:m:s.f>       End encoding at offset into input\n"
+          "encoder_example accepts only uncompressed RIFF WAV format audio and\n"
+          "YUV4MPEG2 uncompressed video.\n\n");
+  exit(1);
+}
+
+static int y4m_parse_tags(char *_tags){
+  int   got_w;
+  int   got_h;
+  int   got_fps;
+  int   got_interlace;
+  int   got_par;
+  int   got_chroma;
+  int   tmp_video_fps_n;
+  int   tmp_video_fps_d;
+  int   tmp_video_par_n;
+  int   tmp_video_par_d;
+  char *p;
+  char *q;
+  got_w=got_h=got_fps=got_interlace=got_par=got_chroma=0;
+  for(p=_tags;;p=q){
+    /*Skip any leading spaces.*/
+    while(*p==' ')p++;
+    /*If that's all we have, stop.*/
+    if(p[0]=='\0')break;
+    /*Find the end of this tag.*/
+    for(q=p+1;*q!='\0'&&*q!=' ';q++);
+    /*Process the tag.*/
+    switch(p[0]){
+      case 'W':{
+        if(sscanf(p+1,"%d",&pic_w)!=1)return -1;
+        got_w=1;
+      }break;
+      case 'H':{
+        if(sscanf(p+1,"%d",&pic_h)!=1)return -1;
+        got_h=1;
+      }break;
+      case 'F':{
+        if(sscanf(p+1,"%d:%d",&tmp_video_fps_n,&tmp_video_fps_d)!=2)return -1;
+        got_fps=1;
+      }break;
+      case 'I':{
+        interlace=p[1];
+        got_interlace=1;
+      }break;
+      case 'A':{
+        if(sscanf(p+1,"%d:%d",&tmp_video_par_n,&tmp_video_par_d)!=2)return -1;
+        got_par=1;
+      }break;
+      case 'C':{
+        if(q-p>16)return -1;
+        memcpy(chroma_type,p+1,q-p-1);
+        chroma_type[q-p-1]='\0';
+        got_chroma=1;
+      }break;
+      /*Ignore unknown tags.*/
+    }
+  }
+  if(!got_w||!got_h||!got_fps||!got_interlace||!got_par)return -1;
+  /*Chroma-type is not specified in older files, e.g., those generated by
+     mplayer.*/
+  if(!got_chroma)strcpy(chroma_type,"420");
+  /*Update fps and aspect ratio globals if not specified in the command line.*/
+  if(video_fps_n==-1)video_fps_n=tmp_video_fps_n;
+  if(video_fps_d==-1)video_fps_d=tmp_video_fps_d;
+  if(video_par_n==-1)video_par_n=tmp_video_par_n;
+  if(video_par_d==-1)video_par_d=tmp_video_par_d;
+  return 0;
+}
+
+/*All anti-aliasing filters in the following conversion functions are based on
+   one of two window functions:
+  The 6-tap Lanczos window (for down-sampling and shifts):
+   sinc(\pi*t)*sinc(\pi*t/3), |t|<3  (sinc(t)==sin(t)/t)
+   0,                         |t|>=3
+  The 4-tap Mitchell window (for up-sampling):
+   7|t|^3-12|t|^2+16/3,             |t|<1
+   -(7/3)|x|^3+12|x|^2-20|x|+32/3,  |t|<2
+   0,                               |t|>=2
+  The number of taps is intentionally kept small to reduce computational
+   overhead and limit ringing.
+
+  The taps from these filters are scaled so that their sum is 1, and the result
+   is scaled by 128 and rounded to integers to create a filter whose
+   intermediate values fit inside 16 bits.
+  Coefficients are rounded in such a way as to ensure their sum is still 128,
+   which is usually equivalent to normal rounding.*/
+
+#define OC_MINI(_a,_b)      ((_a)>(_b)?(_b):(_a))
+#define OC_MAXI(_a,_b)      ((_a)<(_b)?(_b):(_a))
+#define OC_CLAMPI(_a,_b,_c) (OC_MAXI(_a,OC_MINI(_b,_c)))
+
+/*420jpeg chroma samples are sited like:
+  Y-------Y-------Y-------Y-------
+  |       |       |       |
+  |   BR  |       |   BR  |
+  |       |       |       |
+  Y-------Y-------Y-------Y-------
+  |       |       |       |
+  |       |       |       |
+  |       |       |       |
+  Y-------Y-------Y-------Y-------
+  |       |       |       |
+  |   BR  |       |   BR  |
+  |       |       |       |
+  Y-------Y-------Y-------Y-------
+  |       |       |       |
+  |       |       |       |
+  |       |       |       |
+
+  420mpeg2 chroma samples are sited like:
+  Y-------Y-------Y-------Y-------
+  |       |       |       |
+  BR      |       BR      |
+  |       |       |       |
+  Y-------Y-------Y-------Y-------
+  |       |       |       |
+  |       |       |       |
+  |       |       |       |
+  Y-------Y-------Y-------Y-------
+  |       |       |       |
+  BR      |       BR      |
+  |       |       |       |
+  Y-------Y-------Y-------Y-------
+  |       |       |       |
+  |       |       |       |
+  |       |       |       |
+
+  We use a resampling filter to shift the site locations one quarter pixel (at
+   the chroma plane's resolution) to the right.
+  The 4:2:2 modes look exactly the same, except there are twice as many chroma
+   lines, and they are vertically co-sited with the luma samples in both the
+   mpeg2 and jpeg cases (thus requiring no vertical resampling).*/
+static void y4m_convert_42xmpeg2_42xjpeg(unsigned char *_dst,
+ unsigned char *_aux){
+  int c_w;
+  int c_h;
+  int pli;
+  int y;
+  int x;
+  /*Skip past the luma data.*/
+  _dst+=pic_w*pic_h;
+  /*Compute the size of each chroma plane.*/
+  c_w=(pic_w+dst_c_dec_h-1)/dst_c_dec_h;
+  c_h=(pic_h+dst_c_dec_v-1)/dst_c_dec_v;
+  for(pli=1;pli<3;pli++){
+    for(y=0;y<c_h;y++){
+      /*Filter: [4 -17 114 35 -9 1]/128, derived from a 6-tap Lanczos
+         window.*/
+      for(x=0;x<OC_MINI(c_w,2);x++){
+        _dst[x]=(unsigned char)OC_CLAMPI(0,4*_aux[0]-17*_aux[OC_MAXI(x-1,0)]+
+         114*_aux[x]+35*_aux[OC_MINI(x+1,c_w-1)]-9*_aux[OC_MINI(x+2,c_w-1)]+
+         _aux[OC_MINI(x+3,c_w-1)]+64>>7,255);
+      }
+      for(;x<c_w-3;x++){
+        _dst[x]=(unsigned char)OC_CLAMPI(0,4*_aux[x-2]-17*_aux[x-1]+
+         114*_aux[x]+35*_aux[x+1]-9*_aux[x+2]+_aux[x+3]+64>>7,255);
+      }
+      for(;x<c_w;x++){
+        _dst[x]=(unsigned char)OC_CLAMPI(0,4*_aux[x-2]-17*_aux[x-1]+
+         114*_aux[x]+35*_aux[OC_MINI(x+1,c_w-1)]-9*_aux[OC_MINI(x+2,c_w-1)]+
+         _aux[c_w-1]+64>>7,255);
+      }
+      _dst+=c_w;
+      _aux+=c_w;
+    }
+  }
+}
+
+/*This format is only used for interlaced content, but is included for
+   completeness.
+
+  420jpeg chroma samples are sited like:
+  Y-------Y-------Y-------Y-------
+  |       |       |       |
+  |   BR  |       |   BR  |
+  |       |       |       |
+  Y-------Y-------Y-------Y-------
+  |       |       |       |
+  |       |       |       |
+  |       |       |       |
+  Y-------Y-------Y-------Y-------
+  |       |       |       |
+  |   BR  |       |   BR  |
+  |       |       |       |
+  Y-------Y-------Y-------Y-------
+  |       |       |       |
+  |       |       |       |
+  |       |       |       |
+
+  420paldv chroma samples are sited like:
+  YR------Y-------YR------Y-------
+  |       |       |       |
+  |       |       |       |
+  |       |       |       |
+  YB------Y-------YB------Y-------
+  |       |       |       |
+  |       |       |       |
+  |       |       |       |
+  YR------Y-------YR------Y-------
+  |       |       |       |
+  |       |       |       |
+  |       |       |       |
+  YB------Y-------YB------Y-------
+  |       |       |       |
+  |       |       |       |
+  |       |       |       |
+
+  We use a resampling filter to shift the site locations one quarter pixel (at
+   the chroma plane's resolution) to the right.
+  Then we use another filter to move the C_r location down one quarter pixel,
+   and the C_b location up one quarter pixel.*/
+static void y4m_convert_42xpaldv_42xjpeg(unsigned char *_dst,
+ unsigned char *_aux){
+  unsigned char *tmp;
+  int            c_w;
+  int            c_h;
+  int            c_sz;
+  int            pli;
+  int            y;
+  int            x;
+  /*Skip past the luma data.*/
+  _dst+=pic_w*pic_h;
+  /*Compute the size of each chroma plane.*/
+  c_w=(pic_w+1)/2;
+  c_h=(pic_h+dst_c_dec_h-1)/dst_c_dec_h;
+  c_sz=c_w*c_h;
+  /*First do the horizontal re-sampling.
+    This is the same as the mpeg2 case, except that after the horizontal case,
+     we need to apply a second vertical filter.*/
+  tmp=_aux+2*c_sz;
+  for(pli=1;pli<3;pli++){
+    for(y=0;y<c_h;y++){
+      /*Filter: [4 -17 114 35 -9 1]/128, derived from a 6-tap Lanczos
+         window.*/
+      for(x=0;x<OC_MINI(c_w,2);x++){
+        tmp[x]=(unsigned char)OC_CLAMPI(0,4*_aux[0]-17*_aux[OC_MAXI(x-1,0)]+
+         114*_aux[x]+35*_aux[OC_MINI(x+1,c_w-1)]-9*_aux[OC_MINI(x+2,c_w-1)]+
+         _aux[OC_MINI(x+3,c_w-1)]+64>>7,255);
+      }
+      for(;x<c_w-3;x++){
+        tmp[x]=(unsigned char)OC_CLAMPI(0,4*_aux[x-2]-17*_aux[x-1]+
+         114*_aux[x]+35*_aux[x+1]-9*_aux[x+2]+_aux[x+3]+64>>7,255);
+      }
+      for(;x<c_w;x++){
+        tmp[x]=(unsigned char)OC_CLAMPI(0,4*_aux[x-2]-17*_aux[x-1]+
+         114*_aux[x]+35*_aux[OC_MINI(x+1,c_w-1)]-9*_aux[OC_MINI(x+2,c_w-1)]+
+         _aux[c_w-1]+64>>7,255);
+      }
+      tmp+=c_w;
+      _aux+=c_w;
+    }
+    switch(pli){
+      case 1:{
+        tmp-=c_sz;
+        /*Slide C_b up a quarter-pel.
+          This is the same filter used above, but in the other order.*/
+        for(x=0;x<c_w;x++){
+          for(y=0;y<OC_MINI(c_h,3);y++){
+            _dst[y*c_w]=(unsigned char)OC_CLAMPI(0,tmp[0]-
+             9*tmp[OC_MAXI(y-2,0)*c_w]+35*tmp[OC_MAXI(y-1,0)*c_w]+
+             114*tmp[y*c_w]-17*tmp[OC_MINI(y+1,c_h-1)*c_w]+
+             4*tmp[OC_MINI(y+2,c_h-1)*c_w]+64>>7,255);
+          }
+          for(;y<c_h-2;y++){
+            _dst[y*c_w]=(unsigned char)OC_CLAMPI(0,tmp[(y-3)*c_w]-
+             9*tmp[(y-2)*c_w]+35*tmp[(y-1)*c_w]+114*tmp[y*c_w]-
+             17*tmp[(y+1)*c_w]+4*tmp[(y+2)*c_w]+64>>7,255);
+          }
+          for(;y<c_h;y++){
+            _dst[y*c_w]=(unsigned char)OC_CLAMPI(0,tmp[(y-3)*c_w]-
+             9*tmp[(y-2)*c_w]+35*tmp[(y-1)*c_w]+114*tmp[y*c_w]-
+             17*tmp[OC_MINI(y+1,c_h-1)*c_w]+4*tmp[(c_h-1)*c_w]+64>>7,255);
+          }
+          _dst++;
+          tmp++;
+        }
+        _dst+=c_sz-c_w;
+        tmp-=c_w;
+      }break;
+      case 2:{
+        tmp-=c_sz;
+        /*Slide C_r down a quarter-pel.
+          This is the same as the horizontal filter.*/
+        for(x=0;x<c_w;x++){
+          for(y=0;y<OC_MINI(c_h,2);y++){
+            _dst[y*c_w]=(unsigned char)OC_CLAMPI(0,4*tmp[0]-
+             17*tmp[OC_MAXI(y-1,0)*c_w]+114*tmp[y*c_w]+
+             35*tmp[OC_MINI(y+1,c_h-1)*c_w]-9*tmp[OC_MINI(y+2,c_h-1)*c_w]+
+             tmp[OC_MINI(y+3,c_h-1)*c_w]+64>>7,255);
+          }
+          for(;y<c_h-3;y++){
+            _dst[y*c_w]=(unsigned char)OC_CLAMPI(0,4*tmp[(y-2)*c_w]-
+             17*tmp[(y-1)*c_w]+114*tmp[y*c_w]+35*tmp[(y+1)*c_w]-
+             9*tmp[(y+2)*c_w]+tmp[(y+3)*c_w]+64>>7,255);
+          }
+          for(;y<c_h;y++){
+            _dst[y*c_w]=(unsigned char)OC_CLAMPI(0,4*tmp[(y-2)*c_w]-
+             17*tmp[(y-1)*c_w]+114*tmp[y*c_w]+35*tmp[OC_MINI(y+1,c_h-1)*c_w]-
+             9*tmp[OC_MINI(y+2,c_h-1)*c_w]+tmp[(c_h-1)*c_w]+64>>7,255);
+          }
+          _dst++;
+          tmp++;
+        }
+      }break;
+    }
+    /*For actual interlaced material, this would have to be done separately on
+       each field, and the shift amounts would be different.
+      C_r moves down 1/8, C_b up 3/8 in the top field, and C_r moves down 3/8,
+       C_b up 1/8 in the bottom field.
+      The corresponding filters would be:
+       Down 1/8 (reverse order for up): [3 -11 125 15 -4 0]/128
+       Down 3/8 (reverse order for up): [4 -19 98 56 -13 2]/128*/
+  }
+}
+
+/*422jpeg chroma samples are sited like:
+  Y---BR--Y-------Y---BR--Y-------
+  |       |       |       |
+  |       |       |       |
+  |       |       |       |
+  Y---BR--Y-------Y---BR--Y-------
+  |       |       |       |
+  |       |       |       |
+  |       |       |       |
+  Y---BR--Y-------Y---BR--Y-------
+  |       |       |       |
+  |       |       |       |
+  |       |       |       |
+  Y---BR--Y-------Y---BR--Y-------
+  |       |       |       |
+  |       |       |       |
+  |       |       |       |
+
+  411 chroma samples are sited like:
+  YBR-----Y-------Y-------Y-------
+  |       |       |       |
+  |       |       |       |
+  |       |       |       |
+  YBR-----Y-------Y-------Y-------
+  |       |       |       |
+  |       |       |       |
+  |       |       |       |
+  YBR-----Y-------Y-------Y-------
+  |       |       |       |
+  |       |       |       |
+  |       |       |       |
+  YBR-----Y-------Y-------Y-------
+  |       |       |       |
+  |       |       |       |
+  |       |       |       |
+
+  We use a filter to resample at site locations one eighth pixel (at the source
+   chroma plane's horizontal resolution) and five eighths of a pixel to the
+   right.*/
+static void y4m_convert_411_422jpeg(unsigned char *_dst,
+ unsigned char *_aux){
+  int c_w;
+  int dst_c_w;
+  int c_h;
+  int pli;
+  int y;
+  int x;
+  /*Skip past the luma data.*/
+  _dst+=pic_w*pic_h;
+  /*Compute the size of each chroma plane.*/
+  c_w=(pic_w+src_c_dec_h-1)/src_c_dec_h;
+  dst_c_w=(pic_w+dst_c_dec_h-1)/dst_c_dec_h;
+  c_h=(pic_h+dst_c_dec_v-1)/dst_c_dec_v;
+  for(pli=1;pli<3;pli++){
+    for(y=0;y<c_h;y++){
+      /*Filters: [1 110 18 -1]/128 and [-3 50 86 -5]/128, both derived from a
+         4-tap Mitchell window.*/
+      for(x=0;x<OC_MINI(c_w,1);x++){
+        _dst[x<<1]=(unsigned char)OC_CLAMPI(0,111*_aux[0]+
+         18*_aux[OC_MINI(1,c_w-1)]-_aux[OC_MINI(2,c_w-1)]+64>>7,255);
+        _dst[x<<1|1]=(unsigned char)OC_CLAMPI(0,47*_aux[0]+
+         86*_aux[OC_MINI(1,c_w-1)]-5*_aux[OC_MINI(2,c_w-1)]+64>>7,255);
+      }
+      for(;x<c_w-2;x++){
+        _dst[x<<1]=(unsigned char)OC_CLAMPI(0,_aux[x-1]+110*_aux[x]+
+         18*_aux[x+1]-_aux[x+2]+64>>7,255);
+        _dst[x<<1|1]=(unsigned char)OC_CLAMPI(0,-3*_aux[x-1]+50*_aux[x]+
+         86*_aux[x+1]-5*_aux[x+2]+64>>7,255);
+      }
+      for(;x<c_w;x++){
+        _dst[x<<1]=(unsigned char)OC_CLAMPI(0,_aux[x-1]+110*_aux[x]+
+         18*_aux[OC_MINI(x+1,c_w-1)]-_aux[c_w-1]+64>>7,255);
+        if((x<<1|1)<dst_c_w){
+          _dst[x<<1|1]=(unsigned char)OC_CLAMPI(0,-3*_aux[x-1]+50*_aux[x]+
+           86*_aux[OC_MINI(x+1,c_w-1)]-5*_aux[c_w-1]+64>>7,255);
+        }
+      }
+      _dst+=dst_c_w;
+      _aux+=c_w;
+    }
+  }
+}
+
+/*The image is padded with empty chroma components at 4:2:0.
+  This costs about 17 bits a frame to code.*/
+static void y4m_convert_mono_420jpeg(unsigned char *_dst,
+ unsigned char *_aux){
+  int c_sz;
+  _dst+=pic_w*pic_h;
+  c_sz=((pic_w+dst_c_dec_h-1)/dst_c_dec_h)*((pic_h+dst_c_dec_v-1)/dst_c_dec_v);
+  memset(_dst,128,c_sz*2);
+}
+
+#if 0
+/*Right now just 444 to 420.
+  Not too hard to generalize.*/
+static void y4m_convert_4xxjpeg_42xjpeg(unsigned char *_dst,
+ unsigned char *_aux){
+  unsigned char *tmp;
+  int            c_w;
+  int            c_h;
+  int            pic_sz;
+  int            tmp_sz;
+  int            c_sz;
+  int            pli;
+  int            y;
+  int            x;
+  /*Compute the size of each chroma plane.*/
+  c_w=(pic_w+dst_c_dec_h-1)/dst_c_dec_h;
+  c_h=(pic_h+dst_c_dec_v-1)/dst_c_dec_v;
+  pic_sz=pic_w*pic_h;
+  tmp_sz=c_w*pic_h;
+  c_sz=c_w*c_h;
+  _dst+=pic_sz;
+  for(pli=1;pli<3;pli++){
+    tmp=_aux+pic_sz;
+    /*In reality, the horizontal and vertical steps could be pipelined, for
+       less memory consumption and better cache performance, but we do them
+       separately for simplicity.*/
+    /*First do horizontal filtering (convert to 4:2:2)*/
+    /*Filter: [3 -17 78 78 -17 3]/128, derived from a 6-tap Lanczos window.*/
+    for(y=0;y<pic_h;y++){
+      for(x=0;x<OC_MINI(pic_w,2);x+=2){
+        tmp[x>>1]=OC_CLAMPI(0,64*_aux[0]+78*_aux[OC_MINI(1,pic_w-1)]-
+         17*_aux[OC_MINI(2,pic_w-1)]+3*_aux[OC_MINI(3,pic_w-1)]+64>>7,255);
+      }
+      for(;x<pic_w-3;x+=2){
+        tmp[x>>1]=OC_CLAMPI(0,3*(_aux[x-2]+_aux[x+3])-17*(_aux[x-1]+_aux[x+2])+
+         78*(_aux[x]+_aux[x+1])+64>>7,255);
+      }
+      for(;x<pic_w;x+=2){
+        tmp[x>>1]=OC_CLAMPI(0,3*(_aux[x-2]+_aux[pic_w-1])-
+         17*(_aux[x-1]+_aux[OC_MINI(x+2,pic_w-1)])+
+         78*(_aux[x]+_aux[OC_MINI(x+1,pic_w-1)])+64>>7,255);
+      }
+      tmp+=c_w;
+      _aux+=pic_w;
+    }
+    _aux-=pic_sz;
+    tmp-=tmp_sz;
+    /*Now do the vertical filtering.*/
+    for(x=0;x<c_w;x++){
+      for(y=0;y<OC_MINI(pic_h,2);y+=2){
+        _dst[(y>>1)*c_w]=OC_CLAMPI(0,64*tmp[0]+78*tmp[OC_MINI(1,pic_h-1)*c_w]-
+         17*tmp[OC_MINI(2,pic_h-1)*c_w]+3*tmp[OC_MINI(3,pic_h-1)*c_w]+
+         64>>7,255);
+      }
+      for(;y<pic_h-3;y+=2){
+        _dst[(y>>1)*c_w]=OC_CLAMPI(0,3*(tmp[(y-2)*c_w]+tmp[(y+3)*c_w])-
+         17*(tmp[(y-1)*c_w]+tmp[(y+2)*c_w])+78*(tmp[y*c_w]+tmp[(y+1)*c_w])+
+         64>>7,255);
+      }
+      for(;y<pic_h;y+=2){
+        _dst[(y>>1)*c_w]=OC_CLAMPI(0,3*(tmp[(y-2)*c_w]+tmp[(pic_h-1)*c_w])-
+         17*(tmp[(y-1)*c_w]+tmp[OC_MINI(y+2,pic_h-1)*c_w])+
+         78*(tmp[y*c_w]+tmp[OC_MINI(y+1,pic_h-1)*c_w])+64>>7,255);
+      }
+      tmp++;
+      _dst++;
+    }
+    _dst-=c_w;
+  }
+}
+#endif
+
+
+/*No conversion function needed.*/
+static void y4m_convert_null(unsigned char *_dst,
+ unsigned char *_aux){
+}
+
+static void id_file(char *f){
+  FILE *test;
+  unsigned char buffer[80];
+  int ret;
+
+  /* open it, look for magic */
+
+  if(!strcmp(f,"-")){
+    /* stdin */
+    test=stdin;
+  }else{
+    test=fopen(f,"rb");
+    if(!test){
+      fprintf(stderr,"Unable to open file %s.\n",f);
+      exit(1);
+    }
+  }
+
+  ret=fread(buffer,1,4,test);
+  if(ret<4){
+    fprintf(stderr,"EOF determining file type of file %s.\n",f);
+    exit(1);
+  }
+
+  if(!memcmp(buffer,"RIFF",4)){
+    /* possible WAV file */
+
+    if(audio){
+      /* umm, we already have one */
+      fprintf(stderr,"Multiple RIFF WAVE files specified on command line.\n");
+      exit(1);
+    }
+
+    /* Parse the rest of the header */
+
+    ret=fread(buffer,1,4,test);
+    ret=fread(buffer,1,4,test);
+    if(ret<4)goto riff_err;
+    if(!memcmp(buffer,"WAVE",4)){
+
+      while(!feof(test)){
+        ret=fread(buffer,1,4,test);
+        if(ret<4)goto riff_err;
+        if(!memcmp("fmt",buffer,3)){
+
+          /* OK, this is our audio specs chunk.  Slurp it up. */
+
+          ret=fread(buffer,1,20,test);
+          if(ret<20)goto riff_err;
+
+          if(memcmp(buffer+4,"\001\000",2)){
+            fprintf(stderr,"The WAV file %s is in a compressed format; "
+                    "can't read it.\n",f);
+            exit(1);
+          }
+
+          audio=test;
+          audio_ch=buffer[6]+(buffer[7]<<8);
+          audio_hz=buffer[8]+(buffer[9]<<8)+
+            (buffer[10]<<16)+(buffer[11]<<24);
+
+          if(buffer[18]+(buffer[19]<<8)!=16){
+            fprintf(stderr,"Can only read 16 bit WAV files for now.\n");
+            exit(1);
+          }
+
+          /* Now, align things to the beginning of the data */
+          /* Look for 'dataxxxx' */
+          while(!feof(test)){
+            ret=fread(buffer,1,4,test);
+            if(ret<4)goto riff_err;
+            if(!memcmp("data",buffer,4)){
+              /* We're there.  Ignore the declared size for now. */
+              ret=fread(buffer,1,4,test);
+              if(ret<4)goto riff_err;
+
+              fprintf(stderr,"File %s is 16 bit %d channel %d Hz RIFF WAV audio.\n",
+                      f,audio_ch,audio_hz);
+
+              return;
+            }
+          }
+        }
+      }
+    }
+
+    fprintf(stderr,"Couldn't find WAVE data in RIFF file %s.\n",f);
+    exit(1);
+
+  }
+  if(!memcmp(buffer,"YUV4",4)){
+    /* possible YUV2MPEG2 format file */
+    /* read until newline, or 80 cols, whichever happens first */
+    int i;
+    for(i=0;i<79;i++){
+      ret=fread(buffer+i,1,1,test);
+      if(ret<1)goto yuv_err;
+      if(buffer[i]=='\n')break;
+    }
+    if(i==79){
+      fprintf(stderr,"Error parsing %s header; not a YUV2MPEG2 file?\n",f);
+    }
+    buffer[i]='\0';
+
+    if(!memcmp(buffer,"MPEG",4)){
+
+      if(video){
+        /* umm, we already have one */
+        fprintf(stderr,"Multiple video files specified on command line.\n");
+        exit(1);
+      }
+
+      if(buffer[4]!='2'){
+        fprintf(stderr,"Incorrect YUV input file version; YUV4MPEG2 required.\n");
+      }
+
+      ret=y4m_parse_tags((char *)buffer+5);
+      if(ret<0){
+        fprintf(stderr,"Error parsing YUV4MPEG2 header in file %s.\n",f);
+        exit(1);
+      }
+
+      if(interlace!='p'){
+        fprintf(stderr,"Input video is interlaced; Theora handles only progressive scan\n");
+        exit(1);
+      }
+
+      if(strcmp(chroma_type,"420")==0||strcmp(chroma_type,"420jpeg")==0){
+        src_c_dec_h=dst_c_dec_h=src_c_dec_v=dst_c_dec_v=2;
+        y4m_dst_buf_read_sz=pic_w*pic_h+2*((pic_w+1)/2)*((pic_h+1)/2);
+        y4m_aux_buf_sz=y4m_aux_buf_read_sz=0;
+        y4m_convert=y4m_convert_null;
+      }
+      else if(strcmp(chroma_type,"420mpeg2")==0){
+        src_c_dec_h=dst_c_dec_h=src_c_dec_v=dst_c_dec_v=2;
+        y4m_dst_buf_read_sz=pic_w*pic_h;
+        /*Chroma filter required: read into the aux buf first.*/
+        y4m_aux_buf_sz=y4m_aux_buf_read_sz=2*((pic_w+1)/2)*((pic_h+1)/2);
+        y4m_convert=y4m_convert_42xmpeg2_42xjpeg;
+      }
+      else if(strcmp(chroma_type,"420paldv")==0){
+        src_c_dec_h=dst_c_dec_h=src_c_dec_v=dst_c_dec_v=2;
+        y4m_dst_buf_read_sz=pic_w*pic_h;
+        /*Chroma filter required: read into the aux buf first.
+          We need to make two filter passes, so we need some extra space in the
+           aux buffer.*/
+        y4m_aux_buf_sz=3*((pic_w+1)/2)*((pic_h+1)/2);
+        y4m_aux_buf_read_sz=2*((pic_w+1)/2)*((pic_h+1)/2);
+        y4m_convert=y4m_convert_42xpaldv_42xjpeg;
+      }
+      else if(strcmp(chroma_type,"422")==0){
+        src_c_dec_h=dst_c_dec_h=2;
+        src_c_dec_v=dst_c_dec_v=1;
+        y4m_dst_buf_read_sz=pic_w*pic_h;
+        /*Chroma filter required: read into the aux buf first.*/
+        y4m_aux_buf_sz=y4m_aux_buf_read_sz=2*((pic_w+1)/2)*pic_h;
+        y4m_convert=y4m_convert_42xmpeg2_42xjpeg;
+      }
+      else if(strcmp(chroma_type,"411")==0){
+        src_c_dec_h=4;
+        /*We don't want to introduce any additional sub-sampling, so we
+           promote 4:1:1 material to 4:2:2, as the closest format Theora can
+           handle.*/
+        dst_c_dec_h=2;
+        src_c_dec_v=dst_c_dec_v=1;
+        y4m_dst_buf_read_sz=pic_w*pic_h;
+        /*Chroma filter required: read into the aux buf first.*/
+        y4m_aux_buf_sz=y4m_aux_buf_read_sz=2*((pic_w+3)/4)*pic_h;
+        y4m_convert=y4m_convert_411_422jpeg;
+      }
+      else if(strcmp(chroma_type,"444")==0){
+        src_c_dec_h=dst_c_dec_h=src_c_dec_v=dst_c_dec_v=1;
+        y4m_dst_buf_read_sz=pic_w*pic_h*3;
+        y4m_aux_buf_sz=y4m_aux_buf_read_sz=0;
+        y4m_convert=y4m_convert_null;
+      }
+      else if(strcmp(chroma_type,"444alpha")==0){
+        src_c_dec_h=dst_c_dec_h=src_c_dec_v=dst_c_dec_v=1;
+        y4m_dst_buf_read_sz=pic_w*pic_h*3;
+        /*Read the extra alpha plane into the aux buf.
+          It will be discarded.*/
+        y4m_aux_buf_sz=y4m_aux_buf_read_sz=pic_w*pic_h;
+        y4m_convert=y4m_convert_null;
+      }
+      else if(strcmp(chroma_type,"mono")==0){
+        src_c_dec_h=src_c_dec_v=0;
+        dst_c_dec_h=dst_c_dec_v=2;
+        y4m_dst_buf_read_sz=pic_w*pic_h;
+        y4m_aux_buf_sz=y4m_aux_buf_read_sz=0;
+        y4m_convert=y4m_convert_mono_420jpeg;
+      }
+      else{
+        fprintf(stderr,"Unknown chroma sampling type: %s\n",chroma_type);
+        exit(1);
+      }
+      /*The size of the final frame buffers is always computed from the
+         destination chroma decimation type.*/
+      y4m_dst_buf_sz=pic_w*pic_h+2*((pic_w+dst_c_dec_h-1)/dst_c_dec_h)*
+       ((pic_h+dst_c_dec_v-1)/dst_c_dec_v);
+
+      video=test;
+
+      fprintf(stderr,"File %s is %dx%d %.02f fps %s video.\n",
+              f,pic_w,pic_h,(double)video_fps_n/video_fps_d,chroma_type);
+
+      return;
+    }
+  }
+  fprintf(stderr,"Input file %s is neither a WAV nor YUV4MPEG2 file.\n",f);
+  exit(1);
+
+ riff_err:
+  fprintf(stderr,"EOF parsing RIFF file %s.\n",f);
+  exit(1);
+ yuv_err:
+  fprintf(stderr,"EOF parsing YUV4MPEG2 file %s.\n",f);
+  exit(1);
+
+}
+
+int spinner=0;
+char *spinascii="|/-\\";
+void spinnit(void){
+  spinner++;
+  if(spinner==4)spinner=0;
+  fprintf(stderr,"\r%c",spinascii[spinner]);
+}
+
+int fetch_and_process_audio(FILE *audio,ogg_page *audiopage,
+                            ogg_stream_state *vo,
+                            vorbis_dsp_state *vd,
+                            vorbis_block *vb,
+                            int audioflag){
+  static ogg_int64_t samples_sofar=0;
+  ogg_packet op;
+  int i,j;
+  ogg_int64_t beginsample = audio_hz*begin_sec + audio_hz*begin_usec/1000000;
+  ogg_int64_t endsample = audio_hz*end_sec + audio_hz*end_usec/1000000;
+
+  while(audio && !audioflag){
+    /* process any audio already buffered */
+    spinnit();
+    if(ogg_stream_pageout(vo,audiopage)>0) return 1;
+    if(ogg_stream_eos(vo))return 0;
+
+    {
+      /* read and process more audio */
+      signed char readbuffer[4096];
+      signed char *readptr=readbuffer;
+      int toread=4096/2/audio_ch;
+      int bytesread=fread(readbuffer,1,toread*2*audio_ch,audio);
+      int sampread=bytesread/2/audio_ch;
+      float **vorbis_buffer;
+      int count=0;
+
+      if(bytesread<=0 ||
+         (samples_sofar>=endsample && endsample>0)){
+        /* end of file.  this can be done implicitly, but it's
+           easier to see here in non-clever fashion.  Tell the
+           library we're at end of stream so that it can handle the
+           last frame and mark end of stream in the output properly */
+        vorbis_analysis_wrote(vd,0);
+      }else{
+        if(samples_sofar < beginsample){
+          if(samples_sofar+sampread > beginsample){
+            readptr += (beginsample-samples_sofar)*2*audio_ch;
+            sampread += samples_sofar-beginsample;
+            samples_sofar = sampread+beginsample;
+          }else{
+            samples_sofar += sampread;
+            sampread = 0;
+          }
+        }else{
+          samples_sofar += sampread;
+        }
+
+        if(samples_sofar > endsample && endsample > 0)
+          sampread-= (samples_sofar - endsample);
+
+        if(sampread>0){
+
+          vorbis_buffer=vorbis_analysis_buffer(vd,sampread);
+          /* uninterleave samples */
+          for(i=0;i<sampread;i++){
+            for(j=0;j<audio_ch;j++){
+              vorbis_buffer[j][i]=((readptr[count+1]<<8)|
+                                   (0x00ff&(int)readptr[count]))/32768.f;
+              count+=2;
+            }
+          }
+
+          vorbis_analysis_wrote(vd,sampread);
+        }
+      }
+
+      while(vorbis_analysis_blockout(vd,vb)==1){
+
+        /* analysis, assume we want to use bitrate management */
+        vorbis_analysis(vb,NULL);
+        vorbis_bitrate_addblock(vb);
+
+        /* weld packets into the bitstream */
+        while(vorbis_bitrate_flushpacket(vd,&op))
+          ogg_stream_packetin(vo,&op);
+
+      }
+    }
+  }
+
+  return audioflag;
+}
+
+int fetch_and_process_video(FILE *video,ogg_page *videopage,
+                            ogg_stream_state *to,
+                            th_enc_ctx *td,
+                            int videoflag){
+  /* You'll go to Hell for using static variables */
+  static ogg_int64_t         frames=0;
+  static int                 state=-1;
+  static unsigned char      *yuvframe[3];
+  static th_ycbcr_buffer     ycbcr;
+  ogg_packet                 op;
+  int                        pic_sz;
+  int                        frame_c_w;
+  int                        frame_c_h;
+  int                        c_w;
+  int                        c_h;
+  int                        c_sz;
+  ogg_int64_t                beginframe = (video_fps_n*begin_sec +
+                                           video_fps_n*begin_usec/1000000)/video_fps_d;
+  ogg_int64_t                endframe = (video_fps_n*end_sec +
+                                         video_fps_n*end_usec/1000000)/video_fps_d;
+
+  pic_sz=pic_w*pic_h;
+  frame_c_w=frame_w/dst_c_dec_h;
+  frame_c_h=frame_h/dst_c_dec_v;
+  c_w=(pic_w+dst_c_dec_h-1)/dst_c_dec_h;
+  c_h=(pic_h+dst_c_dec_v-1)/dst_c_dec_v;
+  c_sz=c_w*c_h;
+
+  if(state==-1){
+        /* initialize the double frame buffer */
+    yuvframe[0]=(unsigned char *)malloc(y4m_dst_buf_sz);
+    yuvframe[1]=(unsigned char *)malloc(y4m_dst_buf_sz);
+    yuvframe[2]=(unsigned char *)malloc(y4m_aux_buf_sz);
+
+    state=0;
+  }
+
+  /* is there a video page flushed?  If not, work until there is. */
+  while(!videoflag){
+    spinnit();
+
+    if(ogg_stream_pageout(to,videopage)>0) return 1;
+    if(ogg_stream_eos(to)) return 0;
+
+    {
+      /* read and process more video */
+      /* video strategy reads one frame ahead so we know when we're
+         at end of stream and can mark last video frame as such
+         (vorbis audio has to flush one frame past last video frame
+         due to overlap and thus doesn't need this extra work */
+
+      /* have two frame buffers full (if possible) before
+         proceeding.  after first pass and until eos, one will
+         always be full when we get here */
+
+      for(;state<2 && (frames<endframe || endframe<0);){
+        char c,frame[6];
+        int ret=fread(frame,1,6,video);
+
+        /* match and skip the frame header */
+        if(ret<6)break;
+        if(memcmp(frame,"FRAME",5)){
+          fprintf(stderr,"Loss of framing in YUV input data\n");
+          exit(1);
+        }
+        if(frame[5]!='\n'){
+          int j;
+          for(j=0;j<79;j++)
+            if(fread(&c,1,1,video)&&c=='\n')break;
+          if(j==79){
+            fprintf(stderr,"Error parsing YUV frame header\n");
+            exit(1);
+          }
+        }
+        /*Read the frame data that needs no conversion.*/
+        if(fread(yuvframe[state],1,y4m_dst_buf_read_sz,video)!=
+           y4m_dst_buf_read_sz){
+          fprintf(stderr,"Error reading YUV frame data.\n");
+          exit(1);
+        }
+        /*Read the frame data that does need conversion.*/
+        if(fread(yuvframe[2],1,y4m_aux_buf_read_sz,video)!=
+           y4m_aux_buf_read_sz){
+          fprintf(stderr,"Error reading YUV frame data.\n");
+          exit(1);
+        }
+        /*Now convert the just read frame.*/
+        (*y4m_convert)(yuvframe[state],yuvframe[2]);
+
+        frames++;
+        if(frames>=beginframe)
+          state++;
+
+      }
+
+      if(state<1){
+        /* can't get here unless YUV4MPEG stream has no video */
+        fprintf(stderr,"Video input contains no frames.\n");
+        exit(1);
+      }
+
+      /* Theora is a one-frame-in,one-frame-out system; submit a frame
+         for compression and pull out the packet */
+
+      /*We submit the buffer to the library as if it were padded, but we do not
+         actually allocate space for the padding.
+        This is okay, because the library will never read data from the padded
+         region.
+        This is only currently true of the experimental encoder; do NOT do this
+         with the reference encoder.*/
+      ycbcr[0].width=frame_w;
+      ycbcr[0].height=frame_h;
+      ycbcr[0].stride=pic_w;
+      ycbcr[0].data=yuvframe[0]-pic_x-pic_y*pic_w;
+      ycbcr[1].width=frame_c_w;
+      ycbcr[1].height=frame_c_h;
+      ycbcr[1].stride=c_w;
+      ycbcr[1].data=yuvframe[0]+pic_sz-(pic_x/dst_c_dec_h)-
+       (pic_y/dst_c_dec_v)*c_w;
+      ycbcr[2].width=frame_c_w;
+      ycbcr[2].height=frame_c_h;
+      ycbcr[2].stride=c_w;
+      ycbcr[2].data=ycbcr[1].data+c_sz;
+
+      th_encode_ycbcr_in(td,ycbcr);
+
+      /* if there's only one frame, it's the last in the stream */
+      while(th_encode_packetout(td,state<2,&op)){
+        ogg_stream_packetin(to,&op);
+      }
+
+      {
+        unsigned char *temp=yuvframe[0];
+        yuvframe[0]=yuvframe[1];
+        yuvframe[1]=temp;
+        state--;
+      }
+
+    }
+  }
+  return videoflag;
+}
+
+static int ilog(unsigned _v){
+  int ret;
+  for(ret=0;_v;ret++)_v>>=1;
+  return ret;
+}
+
+int main(int argc,char *argv[]){
+  int c,long_option_index,ret;
+
+  ogg_stream_state to; /* take physical pages, weld into a logical
+                           stream of packets */
+  ogg_stream_state vo; /* take physical pages, weld into a logical
+                           stream of packets */
+  ogg_page         og; /* one Ogg bitstream page.  Vorbis packets are inside */
+  ogg_packet       op; /* one raw packet of data for decode */
+
+  th_enc_ctx      *td;
+  th_info          ti;
+  th_comment       tc;
+
+  vorbis_info      vi; /* struct that stores all the static vorbis bitstream
+                          settings */
+  vorbis_comment   vc; /* struct that stores all the user comments */
+
+  vorbis_dsp_state vd; /* central working state for the packet->PCM decoder */
+  vorbis_block     vb; /* local working space for packet->PCM decode */
+
+  int audioflag=0;
+  int videoflag=0;
+  int akbps=0;
+  int vkbps=0;
+
+  ogg_int64_t audio_bytesout=0;
+  ogg_int64_t video_bytesout=0;
+  double timebase;
+
+  FILE *outfile = stdout;
+
+#ifdef _WIN32 /* We need to set stdin/stdout to binary mode. Damn windows. */
+  /* if we were reading/writing a file, it would also need to in
+     binary mode, eg, fopen("file.wav","wb"); */
+  /* Beware the evil ifdef. We avoid these where we can, but this one we
+     cannot. Don't add any more, you'll probably go to hell if you do. */
+  _setmode( _fileno( stdin ), _O_BINARY );
+  _setmode( _fileno( stdout ), _O_BINARY );
+#endif
+
+  while((c=getopt_long(argc,argv,optstring,options,&long_option_index))!=EOF){
+    switch(c){
+    case 'o':
+      outfile=fopen(optarg,"wb");
+      if(outfile==NULL){
+        fprintf(stderr,"Unable to open output file '%s'\n", optarg);
+        exit(1);
+      }
+      break;;
+
+    case 'a':
+      audio_q=(float)(atof(optarg)*.099);
+      if(audio_q<-.1 || audio_q>1){
+        fprintf(stderr,"Illegal audio quality (choose -1 through 10)\n");
+        exit(1);
+      }
+      audio_r=-1;
+      break;
+
+    case 'v':
+      video_q=(int)rint(6.3*atof(optarg));
+      if(video_q<0 || video_q>63){
+        fprintf(stderr,"Illegal video quality (choose 0 through 10)\n");
+        exit(1);
+      }
+      video_r=0;
+      break;
+
+    case 'A':
+      audio_r=(int)(atof(optarg)*1000);
+      if(audio_q<0){
+        fprintf(stderr,"Illegal audio quality (choose > 0 please)\n");
+        exit(1);
+      }
+      audio_q=-99;
+      break;
+
+    case 'V':
+      video_r=(int)rint(atof(optarg)*1000);
+      if(video_r<1){
+        fprintf(stderr,"Illegal video bitrate (choose > 0 please)\n");
+        exit(1);
+      }
+      video_q=0;
+     break;
+
+    case 's':
+      video_par_n=(int)rint(atof(optarg));
+      break;
+
+    case 'S':
+      video_par_d=(int)rint(atof(optarg));
+      break;
+
+    case 'f':
+      video_fps_n=(int)rint(atof(optarg));
+      break;
+
+    case 'F':
+      video_fps_d=(int)rint(atof(optarg));
+      break;
+
+    case 'c':
+      vp3_compatible=1;
+      break;
+
+    case 'k':
+      keyframe_frequency=rint(atof(optarg));
+      if(keyframe_frequency<1 || keyframe_frequency>2147483647){
+        fprintf(stderr,"Illegal keyframe frequency\n");
+        exit(1);
+      }
+      break;
+
+    case 'b':
+      {
+        char *pos=strchr(optarg,':');
+        begin_sec=atol(optarg);
+        if(pos){
+          char *pos2=strchr(++pos,':');
+          begin_sec*=60;
+          begin_sec+=atol(pos);
+          if(pos2){
+            pos2++;
+            begin_sec*=60;
+            begin_sec+=atol(pos2);
+          }else{
+            pos2=pos;
+          }
+          pos2=strchr(pos2,'.');
+          if(pos2){
+            pos2++;
+            begin_usec=atol(pos2);
+          }
+        }
+      }
+      break;
+    case 'e':
+      {
+        char *pos=strchr(optarg,':');
+        end_sec=atol(optarg);
+        if(pos){
+          char *pos2=strchr(++pos,':');
+          end_sec*=60;
+          end_sec+=atol(pos);
+          if(pos2){
+            pos2++;
+            end_sec*=60;
+            end_sec+=atol(pos2);
+          }else{
+            pos2=pos;
+          }
+          pos2=strchr(pos2,'.');
+          if(pos2){
+            pos2++;
+            end_usec=atol(pos2);
+          }
+        }
+      }
+      break;
+
+    default:
+      usage();
+    }
+  }
+
+  while(optind<argc){
+    /* assume that anything following the options must be a filename */
+    id_file(argv[optind]);
+    optind++;
+  }
+
+  /* yayness.  Set up Ogg output stream */
+  srand(time(NULL));
+  if(audio)ogg_stream_init(&vo,rand());
+  ogg_stream_init(&to,rand()); /* oops, add one ot the above */
+
+  /* Set up Theora encoder */
+  if(!video){
+    fprintf(stderr,"No video files submitted for compression?\n");
+    exit(1);
+  }
+  /* Theora has a divisible-by-sixteen restriction for the encoded frame size */
+  /* scale the picture size up to the nearest /16 and calculate offsets */
+  frame_w=pic_w+15&~0xF;
+  frame_h=pic_h+15&~0xF;
+  /*Force the offsets to be even so that chroma samples line up like we
+     expect.*/
+  pic_x=frame_w-pic_w>>1&~1;
+  pic_y=frame_h-pic_h>>1&~1;
+
+  th_info_init(&ti);
+  ti.frame_width=frame_w;
+  ti.frame_height=frame_h;
+  ti.pic_width=pic_w;
+  ti.pic_height=pic_h;
+  ti.pic_x=pic_x;
+  ti.pic_y=pic_y;
+  ti.fps_numerator=video_fps_n;
+  ti.fps_denominator=video_fps_d;
+  ti.aspect_numerator=video_par_n;
+  ti.aspect_denominator=video_par_d;
+  ti.colorspace=TH_CS_UNSPECIFIED;
+  /*Account for the Ogg page overhead.
+    This is 1 byte per 255 for lacing values, plus 26 bytes per 4096 bytes for
+     the page header, plus approximately 1/2 byte per packet (not accounted for
+     here).*/
+  ti.target_bitrate=(int)(64870*(ogg_int64_t)video_r>>16);
+  ti.quality=video_q;
+  ti.keyframe_granule_shift=ilog(keyframe_frequency-1);
+
+  if(dst_c_dec_h==2){
+    if(dst_c_dec_v==2)ti.pixel_fmt=TH_PF_420;
+    else ti.pixel_fmt=TH_PF_422;
+  }
+  else ti.pixel_fmt=TH_PF_444;
+
+  td=th_encode_alloc(&ti);
+  th_info_clear(&ti);
+
+  /* setting just the granule shift only allows power-of-two keyframe
+     spacing.  Set the actual requested spacing. */
+  ret=th_encode_ctl(td,TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE,&keyframe_frequency,
+                    sizeof(keyframe_frequency-1));
+  if(ret<0){
+    fprintf(stderr,"Could not set keyframe interval to %d.\n",(int)keyframe_frequency);
+  }
+
+  if(vp3_compatible){
+    ret=th_encode_ctl(td,TH_ENCCTL_SET_VP3_COMPATIBLE,&vp3_compatible,
+     sizeof(vp3_compatible));
+    if(ret<0||!vp3_compatible){
+      fprintf(stderr,"Could not enable strict VP3 compatibility.\n");
+      if(ret>=0){
+        fprintf(stderr,"Ensure your source format is supported by VP3.\n");
+        fprintf(stderr,
+         "(4:2:0 pixel format, width and height multiples of 16).\n");
+      }
+    }
+  }
+
+  /* initialize Vorbis too, assuming we have audio to compress. */
+  if(audio){
+    vorbis_info_init(&vi);
+    if(audio_q>-99)
+      ret = vorbis_encode_init_vbr(&vi,audio_ch,audio_hz,audio_q);
+    else
+      ret = vorbis_encode_init(&vi,audio_ch,audio_hz,-1,
+       (int)(64870*(ogg_int64_t)audio_r>>16),-1);
+    if(ret){
+      fprintf(stderr,"The Vorbis encoder could not set up a mode according to\n"
+              "the requested quality or bitrate.\n\n");
+      exit(1);
+    }
+
+    vorbis_comment_init(&vc);
+    vorbis_analysis_init(&vd,&vi);
+    vorbis_block_init(&vd,&vb);
+  }
+
+  /* write the bitstream header packets with proper page interleave */
+
+  th_comment_init(&tc);
+
+  /* first packet will get its own page automatically */
+  if(th_encode_flushheader(td,&tc,&op)<=0){
+    fprintf(stderr,"Internal Theora library error.\n");
+    exit(1);
+  }
+  ogg_stream_packetin(&to,&op);
+  if(ogg_stream_pageout(&to,&og)!=1){
+    fprintf(stderr,"Internal Ogg library error.\n");
+    exit(1);
+  }
+  fwrite(og.header,1,og.header_len,outfile);
+  fwrite(og.body,1,og.body_len,outfile);
+
+  /* create the remaining theora headers */
+  for(;;){
+    ret=th_encode_flushheader(td,&tc,&op);
+    if(ret<0){
+      fprintf(stderr,"Internal Theora library error.\n");
+      exit(1);
+    }
+    else if(!ret)break;
+    ogg_stream_packetin(&to,&op);
+  }
+
+  if(audio){
+    ogg_packet header;
+    ogg_packet header_comm;
+    ogg_packet header_code;
+
+    vorbis_analysis_headerout(&vd,&vc,&header,&header_comm,&header_code);
+    ogg_stream_packetin(&vo,&header); /* automatically placed in its own
+                                         page */
+    if(ogg_stream_pageout(&vo,&og)!=1){
+      fprintf(stderr,"Internal Ogg library error.\n");
+      exit(1);
+    }
+    fwrite(og.header,1,og.header_len,outfile);
+    fwrite(og.body,1,og.body_len,outfile);
+
+    /* remaining vorbis header packets */
+    ogg_stream_packetin(&vo,&header_comm);
+    ogg_stream_packetin(&vo,&header_code);
+  }
+
+  /* Flush the rest of our headers. This ensures
+     the actual data in each stream will start
+     on a new page, as per spec. */
+  for(;;){
+    int result = ogg_stream_flush(&to,&og);
+      if(result<0){
+        /* can't get here */
+        fprintf(stderr,"Internal Ogg library error.\n");
+        exit(1);
+      }
+    if(result==0)break;
+    fwrite(og.header,1,og.header_len,outfile);
+    fwrite(og.body,1,og.body_len,outfile);
+  }
+  if(audio){
+    for(;;){
+      int result=ogg_stream_flush(&vo,&og);
+      if(result<0){
+        /* can't get here */
+        fprintf(stderr,"Internal Ogg library error.\n");
+        exit(1);
+      }
+      if(result==0)break;
+      fwrite(og.header,1,og.header_len,outfile);
+      fwrite(og.body,1,og.body_len,outfile);
+    }
+  }
+
+  /* setup complete.  Raw processing loop */
+  fprintf(stderr,"Compressing....\n");
+  for(;;){
+    ogg_page audiopage;
+    ogg_page videopage;
+
+    /* is there an audio page flushed?  If not, fetch one if possible */
+    audioflag=fetch_and_process_audio(audio,&audiopage,&vo,&vd,&vb,audioflag);
+
+    /* is there a video page flushed?  If not, fetch one if possible */
+    videoflag=fetch_and_process_video(video,&videopage,&to,td,videoflag);
+
+    /* no pages of either?  Must be end of stream. */
+    if(!audioflag && !videoflag)break;
+
+    /* which is earlier; the end of the audio page or the end of the
+       video page? Flush the earlier to stream */
+    {
+      int audio_or_video=-1;
+      double audiotime=
+        audioflag?vorbis_granule_time(&vd,ogg_page_granulepos(&audiopage)):-1;
+      double videotime=
+        videoflag?th_granule_time(td,ogg_page_granulepos(&videopage)):-1;
+
+      if(!audioflag){
+        audio_or_video=1;
+      } else if(!videoflag) {
+        audio_or_video=0;
+      } else {
+        if(audiotime<videotime)
+          audio_or_video=0;
+        else
+          audio_or_video=1;
+      }
+
+      if(audio_or_video==1){
+        /* flush a video page */
+        video_bytesout+=fwrite(videopage.header,1,videopage.header_len,outfile);
+        video_bytesout+=fwrite(videopage.body,1,videopage.body_len,outfile);
+        videoflag=0;
+        timebase=videotime;
+
+      }else{
+        /* flush an audio page */
+        audio_bytesout+=fwrite(audiopage.header,1,audiopage.header_len,outfile);
+        audio_bytesout+=fwrite(audiopage.body,1,audiopage.body_len,outfile);
+        audioflag=0;
+        timebase=audiotime;
+      }
+      if(timebase > 0)
+      {
+        int hundredths=(int)(timebase*100-(long)timebase*100);
+        int seconds=(long)timebase%60;
+        int minutes=((long)timebase/60)%60;
+        int hours=(long)timebase/3600;
+
+        if(audio_or_video)
+          vkbps=(int)rint(video_bytesout*8./timebase*.001);
+        else
+          akbps=(int)rint(audio_bytesout*8./timebase*.001);
+
+        fprintf(stderr,
+                "\r      %d:%02d:%02d.%02d audio: %dkbps video: %dkbps                 ",
+                hours,minutes,seconds,hundredths,akbps,vkbps);
+      }
+    }
+
+  }
+
+  /* clear out state */
+
+  if(audio){
+    ogg_stream_clear(&vo);
+    vorbis_block_clear(&vb);
+    vorbis_dsp_clear(&vd);
+    vorbis_comment_clear(&vc);
+    vorbis_info_clear(&vi);
+    if(audio!=stdin)fclose(audio);
+  }
+  if(video){
+    ogg_stream_clear(&to);
+    th_encode_free(td);
+    th_comment_clear(&tc);
+    if(video!=stdin)fclose(video);
+  }
+
+  if(outfile && outfile!=stdout)fclose(outfile);
+
+  fprintf(stderr,"\r   \ndone.\n\n");
+
+  return(0);
+
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/include/theora/codec.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/include/theora/codec.h
new file mode 100644
index 0000000..11fde87
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/include/theora/codec.h
@@ -0,0 +1,595 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: theora.h,v 1.8 2004/03/15 22:17:32 derf Exp $
+
+ ********************************************************************/
+
+/**\mainpage
+ * 
+ * \section intro Introduction
+ *
+ * This is the documentation for <tt>libtheora</tt> C API.
+ * The current reference
+ * implementation for <a href="http://www.theora.org/">Theora</a>, a free,
+ * patent-unencumbered video codec.
+ * Theora is derived from On2's VP3 codec with additional features and
+ *  integration for Ogg multimedia formats by
+ *  <a href="http://www.xiph.org/">the Xiph.Org Foundation</a>.
+ * Complete documentation of the format itself is available in
+ * <a href="http://www.theora.org/doc/Theora_I_spec.pdf">the Theora
+ *  specification</a>.
+ *
+ * \subsection Organization
+ *
+ * The functions documented here are actually subdivided into three 
+ * separate libraries:
+ * - <tt>libtheoraenc</tt> contains the encoder interface,
+ *   described in \ref encfuncs.
+ * - <tt>libtheoradec</tt> contains the decoder interface and
+ *   routines shared with the encoder.
+ *   You must also link to this if you link to <tt>libtheoraenc</tt>.
+ *   The routines in this library are described in \ref decfuncs and 
+ *   \ref basefuncs.
+ * - <tt>libtheora</tt> contains the \ref oldfuncs.
+ *
+ * New code should link to <tt>libtheoradec</tt> and, if using encoder
+ * features, <tt>libtheoraenc</tt>. Together these two export both
+ * the standard and the legacy API, so this is all that is needed by
+ * any code. The older <tt>libtheora</tt> library is provided just for
+ * compatibility with older build configurations.
+ *
+ * In general the recommended 1.x API symbols can be distinguished
+ * by their <tt>th_</tt> or <tt>TH_</tt> namespace prefix.
+ * The older, legacy API uses <tt>theora_</tt> or <tt>OC_</tt>
+ * prefixes instead.
+ */
+
+/**\file
+ * The shared <tt>libtheoradec</tt> and <tt>libtheoraenc</tt> C API.
+ * You don't need to include this directly.*/
+
+#if !defined(_O_THEORA_CODEC_H_)
+# define _O_THEORA_CODEC_H_ (1)
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+# include <vtkoggtheora/include/ogg/ogg.h>
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+
+
+/**\name Return codes*/
+/*@{*/
+/**An invalid pointer was provided.*/
+#define TH_EFAULT     (-1)
+/**An invalid argument was provided.*/
+#define TH_EINVAL     (-10)
+/**The contents of the header were incomplete, invalid, or unexpected.*/
+#define TH_EBADHEADER (-20)
+/**The header does not belong to a Theora stream.*/
+#define TH_ENOTFORMAT (-21)
+/**The bitstream version is too high.*/
+#define TH_EVERSION   (-22)
+/**The specified function is not implemented.*/
+#define TH_EIMPL      (-23)
+/**There were errors in the video data packet.*/
+#define TH_EBADPACKET (-24)
+/**The decoded packet represented a dropped frame.
+   The player can continue to display the current frame, as the contents of the
+    decoded frame buffer have not changed.*/
+#define TH_DUPFRAME   (1)
+/*@}*/
+
+/**The currently defined color space tags.
+ * See <a href="http://www.theora.org/doc/Theora_I_spec.pdf">the Theora
+ *  specification</a>, Chapter 4, for exact details on the meaning of each of
+ *  these color spaces.*/
+typedef enum{
+  /**The color space was not specified at the encoder.
+      It may be conveyed by an external means.*/
+  TH_CS_UNSPECIFIED,
+  /**A color space designed for NTSC content.*/
+  TH_CS_ITU_REC_470M,
+  /**A color space designed for PAL/SECAM content.*/
+  TH_CS_ITU_REC_470BG,
+  /**The total number of currently defined color spaces.*/
+  TH_CS_NSPACES
+}th_colorspace;
+
+/**The currently defined pixel format tags.
+ * See <a href="http://www.theora.org/doc/Theora_I_spec.pdf">the Theora
+ *  specification</a>, Section 4.4, for details on the precise sample
+ *  locations.*/
+typedef enum{
+  /**Chroma decimation by 2 in both the X and Y directions (4:2:0).
+     The Cb and Cr chroma planes are half the width and half the height of the
+      luma plane.*/
+  TH_PF_420,
+  /**Currently reserved.*/
+  TH_PF_RSVD,
+  /**Chroma decimation by 2 in the X direction (4:2:2).
+     The Cb and Cr chroma planes are half the width of the luma plane, but full
+      height.*/
+  TH_PF_422,
+  /**No chroma decimation (4:4:4).
+     The Cb and Cr chroma planes are full width and full height.*/
+  TH_PF_444,
+  /**The total number of currently defined pixel formats.*/
+  TH_PF_NFORMATS
+}th_pixel_fmt;
+
+
+
+/**A buffer for a single color plane in an uncompressed image.
+ * This contains the image data in a left-to-right, top-down format.
+ * Each row of pixels is stored contiguously in memory, but successive rows
+ *  need not be.
+ * Use \a stride to compute the offset of the next row.
+ * The encoder accepts both positive \a stride values (top-down in memory) and
+ *  negative (bottom-up in memory).
+ * The decoder currently always generates images with positive strides.*/
+typedef struct{
+  /**The width of this plane.*/
+  int            width;
+  /**The height of this plane.*/
+  int            height;
+  /**The offset in bytes between successive rows.*/
+  int            stride;
+  /**A pointer to the beginning of the first row.*/
+  unsigned char *data;
+}th_img_plane;
+
+/**A complete image buffer for an uncompressed frame.
+ * The chroma planes may be decimated by a factor of two in either direction,
+ *  as indicated by th_info#pixel_fmt.
+ * The width and height of the Y' plane must be multiples of 16.
+ * They may need to be cropped for display, using the rectangle specified by
+ *  th_info#pic_x, th_info#pic_y, th_info#pic_width, and
+ *  th_info#pic_height.
+ * All samples are 8 bits.
+ * \note The term YUV often used to describe a colorspace is ambiguous.
+ * The exact parameters of the RGB to YUV conversion process aside, in many
+ *  contexts the U and V channels actually have opposite meanings.
+ * To avoid this confusion, we are explicit: the name of the color channels are
+ *  Y'CbCr, and they appear in that order, always.
+ * The prime symbol denotes that the Y channel is non-linear.
+ * Cb and Cr stand for "Chroma blue" and "Chroma red", respectively.*/
+typedef th_img_plane th_ycbcr_buffer[3];
+
+/**Theora bitstream information.
+ * This contains the basic playback parameters for a stream, and corresponds to 
+ *  the initial 'info' header packet.
+ * To initialize an encoder, the application fills in this structure and
+ *  passes it to th_encode_alloc().
+ * A default encoding mode is chosen based on the values of the #quality and
+ *  #target_bitrate fields.
+ * On decode, it is filled in by th_decode_headerin(), and then passed to
+ *  th_decode_alloc().
+ *
+ * Encoded Theora frames must be a multiple of 16 in size;
+ *  this is what the #frame_width and #frame_height members represent.
+ * To handle arbitrary picture sizes, a crop rectangle is specified in the
+ *  #pic_x, #pic_y, #pic_width and #pic_height members.
+ *
+ * All frame buffers contain pointers to the full, padded frame.
+ * However, the current encoder <em>will not</em> reference pixels outside of
+ *  the cropped picture region, and the application does not need to fill them
+ *  in.
+ * The decoder <em>will</em> allocate storage for a full frame, but the
+ *  application <em>should not</em> rely on the padding containing sensible
+ *  data.
+ *
+ * It is also generally recommended that the offsets and sizes should still be
+ *  multiples of 2 to avoid chroma sampling shifts when chroma is sub-sampled.
+ * See <a href="http://www.theora.org/doc/Theora_I_spec.pdf">the Theora
+ *  specification</a>, Section 4.4, for more details.
+ *
+ * Frame rate, in frames per second, is stored as a rational fraction, as is
+ *  the pixel aspect ratio.
+ * Note that this refers to the aspect ratio of the individual pixels, not of
+ *  the overall frame itself.
+ * The frame aspect ratio can be computed from pixel aspect ratio using the
+ *  image dimensions.*/
+typedef struct{
+  /**\name Theora version
+   * Bitstream version information.*/
+  /*@{*/
+  unsigned char version_major;
+  unsigned char version_minor;
+  unsigned char version_subminor;
+  /*@}*/
+  /**The encoded frame width.
+   * This must be a multiple of 16, and less than 1048576.*/
+  ogg_uint32_t  frame_width;
+  /**The encoded frame height.
+   * This must be a multiple of 16, and less than 1048576.*/
+  ogg_uint32_t  frame_height;
+  /**The displayed picture width.
+   * This must be no larger than width.*/
+  ogg_uint32_t  pic_width;
+  /**The displayed picture height.
+   * This must be no larger than height.*/
+  ogg_uint32_t  pic_height;
+  /**The X offset of the displayed picture.
+   * This must be no larger than #frame_width-#pic_width or 255, whichever is
+   *  smaller.*/
+  ogg_uint32_t  pic_x;
+  /**The Y offset of the displayed picture.
+   * This must be no larger than #frame_height-#pic_height, and
+   *  #frame_height-#pic_height-#pic_y must be no larger than 255.
+   * This slightly funny restriction is due to the fact that the offset is
+   *  specified from the top of the image for consistency with the standard
+   *  graphics left-handed coordinate system used throughout this API, while it
+   *  is stored in the encoded stream as an offset from the bottom.*/
+  ogg_uint32_t  pic_y;
+  /**\name Frame rate
+   * The frame rate, as a fraction.
+   * If either is 0, the frame rate is undefined.*/
+  /*@{*/
+  ogg_uint32_t  fps_numerator;
+  ogg_uint32_t  fps_denominator;
+  /*@}*/
+  /**\name Aspect ratio
+   * The aspect ratio of the pixels.
+   * If either value is zero, the aspect ratio is undefined.
+   * If not specified by any external means, 1:1 should be assumed.
+   * The aspect ratio of the full picture can be computed as
+   * \code
+   *  aspect_numerator*pic_width/(aspect_denominator*pic_height).
+   * \endcode */
+  /*@{*/
+  ogg_uint32_t  aspect_numerator;
+  ogg_uint32_t  aspect_denominator;
+  /*@}*/
+  /**The color space.*/
+  th_colorspace colorspace;
+  /**The pixel format.*/
+  th_pixel_fmt  pixel_fmt;
+  /**The target bit-rate in bits per second.
+     If initializing an encoder with this struct, set this field to a non-zero
+      value to activate CBR encoding by default.*/
+  /*TODO: Current encoder does not support CBR mode, or anything like it.
+    We also don't really know what nominal rate each quality level
+     corresponds to yet.*/
+  int           target_bitrate;
+  /**The target quality level.
+     Valid values range from 0 to 63, inclusive, with higher values giving
+      higher quality.
+     If initializing an encoder with this struct, and #target_bitrate is set
+      to zero, VBR encoding at this quality will be activated by default.*/
+  /*Currently this is set so that a qi of 0 corresponds to distortions of 24
+     times the JND, and each increase by 16 halves that value.
+    This gives us fine discrimination at low qualities, yet effective rate
+     control at high qualities.
+    The qi value 63 is special, however.
+    For this, the highest quality, we use one half of a JND for our threshold.
+    Due to the lower bounds placed on allowable quantizers in Theora, we will
+     not actually be able to achieve quality this good, but this should
+     provide as close to visually lossless quality as Theora is capable of.
+    We could lift the quantizer restrictions without breaking VP3.1
+     compatibility, but this would result in quantized coefficients that are
+     too large for the current bitstream to be able to store.
+    We'd have to redesign the token syntax to store these large coefficients,
+     which would make transcoding complex.*/
+  int           quality;
+  /**The amount to shift to extract the last keyframe number from the granule
+   *  position.
+   * This can be at most 31.
+   * th_info_init() will set this to a default value (currently <tt>6</tt>,
+   *  which is good for streaming applications), but you can set it to 0 to
+   *  make every frame a keyframe.
+   * The maximum distance between key frames is
+   *  <tt>1<<#keyframe_granule_shift</tt>.
+   * The keyframe frequency can be more finely controlled with
+   *  #TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE, which can also be adjusted
+   *  during encoding (for example, to force the next frame to be a keyframe),
+   *  but it cannot be set larger than the amount permitted by this field after
+   *  the headers have been output.*/
+  int           keyframe_granule_shift;
+}th_info;
+
+/**The comment information.
+ *
+ * This structure holds the in-stream metadata corresponding to
+ *  the 'comment' header packet.
+ * The comment header is meant to be used much like someone jotting a quick
+ *  note on the label of a video.
+ * It should be a short, to the point text note that can be more than a couple
+ *  words, but not more than a short paragraph.
+ *
+ * The metadata is stored as a series of (tag, value) pairs, in
+ *  length-encoded string vectors.
+ * The first occurrence of the '=' character delimits the tag and value.
+ * A particular tag may occur more than once, and order is significant.
+ * The character set encoding for the strings is always UTF-8, but the tag
+ *  names are limited to ASCII, and treated as case-insensitive.
+ * See <a href="http://www.theora.org/doc/Theora_I_spec.pdf">the Theora
+ *  specification</a>, Section 6.3.3 for details.
+ *
+ * In filling in this structure, th_decode_headerin() will null-terminate
+ *  the user_comment strings for safety.
+ * However, the bitstream format itself treats them as 8-bit clean vectors,
+ *  possibly containing null characters, and so the length array should be
+ *  treated as their authoritative length.
+ */
+typedef struct th_comment{
+  /**The array of comment string vectors.*/
+  char **user_comments;
+  /**An array of the corresponding length of each vector, in bytes.*/
+  int   *comment_lengths;
+  /**The total number of comment strings.*/
+  int    comments;
+  /**The null-terminated vendor string.
+     This identifies the software used to encode the stream.*/
+  char  *vendor;
+}th_comment;
+
+
+
+/**A single base matrix.*/
+typedef unsigned char th_quant_base[64];
+
+/**A set of \a qi ranges.*/
+typedef struct{
+  /**The number of ranges in the set.*/
+  int                  nranges;
+  /**The size of each of the #nranges ranges.
+     These must sum to 63.*/
+  const int           *sizes;
+  /**#nranges <tt>+1</tt> base matrices.
+     Matrices \a i and <tt>i+1</tt> form the endpoints of range \a i.*/
+  const th_quant_base *base_matrices;
+}th_quant_ranges;
+
+/**A complete set of quantization parameters.
+   The quantizer for each coefficient is calculated as:
+   \code
+    Q=MAX(MIN(qmin[qti][ci!=0],scale[ci!=0][qi]*base[qti][pli][qi][ci]/100),
+     1024).
+   \endcode
+
+   \a qti is the quantization type index: 0 for intra, 1 for inter.
+   <tt>ci!=0</tt> is 0 for the DC coefficient and 1 for AC coefficients.
+   \a qi is the quality index, ranging between 0 (low quality) and 63 (high
+    quality).
+   \a pli is the color plane index: 0 for Y', 1 for Cb, 2 for Cr.
+   \a ci is the DCT coefficient index.
+   Coefficient indices correspond to the normal 2D DCT block
+    ordering--row-major with low frequencies first--\em not zig-zag order.
+
+   Minimum quantizers are constant, and are given by:
+   \code
+   qmin[2][2]={{4,2},{8,4}}.
+   \endcode
+
+   Parameters that can be stored in the bitstream are as follows:
+    - The two scale matrices ac_scale and dc_scale.
+      \code
+      scale[2][64]={dc_scale,ac_scale}.
+      \endcode
+    - The base matrices for each \a qi, \a qti and \a pli (up to 384 in all).
+      In order to avoid storing a full 384 base matrices, only a sparse set of
+       matrices are stored, and the rest are linearly interpolated.
+      This is done as follows.
+      For each \a qti and \a pli, a series of \a n \a qi ranges is defined.
+      The size of each \a qi range can vary arbitrarily, but they must sum to
+       63.
+      Then, <tt>n+1</tt> matrices are specified, one for each endpoint of the
+       ranges.
+      For interpolation purposes, each range's endpoints are the first \a qi
+       value it contains and one past the last \a qi value it contains.
+      Fractional values are rounded to the nearest integer, with ties rounded
+       away from zero.
+
+      Base matrices are stored by reference, so if the same matrices are used
+       multiple times, they will only appear once in the bitstream.
+      The bitstream is also capable of omitting an entire set of ranges and
+       its associated matrices if they are the same as either the previous
+       set (indexed in row-major order) or if the inter set is the same as the
+       intra set.
+
+    - Loop filter limit values.
+      The same limits are used for the loop filter in all color planes, despite
+       potentially differing levels of quantization in each.
+
+   For the current encoder, <tt>scale[ci!=0][qi]</tt> must be no greater
+    than <tt>scale[ci!=0][qi-1]</tt> and <tt>base[qti][pli][qi][ci]</tt> must
+    be no greater than <tt>base[qti][pli][qi-1][ci]</tt>.
+   These two conditions ensure that the actual quantizer for a given \a qti,
+    \a pli, and \a ci does not increase as \a qi increases.
+   This is not required by the decoder.*/
+typedef struct{
+  /**The DC scaling factors.*/
+  ogg_uint16_t    dc_scale[64];
+  /**The AC scaling factors.*/
+  ogg_uint16_t    ac_scale[64];
+  /**The loop filter limit values.*/
+  unsigned char   loop_filter_limits[64];
+  /**The \a qi ranges for each \a ci and \a pli.*/
+  th_quant_ranges qi_ranges[2][3];
+}th_quant_info;
+
+
+
+/**The number of Huffman tables used by Theora.*/
+#define TH_NHUFFMAN_TABLES (80)
+/**The number of DCT token values in each table.*/
+#define TH_NDCT_TOKENS     (32)
+
+/**A Huffman code for a Theora DCT token.
+ * Each set of Huffman codes in a given table must form a complete, prefix-free
+ *  code.
+ * There is no requirement that all the tokens in a table have a valid code,
+ *  but the current encoder is not optimized to take advantage of this.
+ * If each of the five grouops of 16 tables does not contain at least one table
+ *  with a code for every token, then the encoder may fail to encode certain
+ *  frames.
+ * The complete table in the first group of 16 does not have to be in the same
+ *  place as the complete table in the other groups, but the complete tables in
+ *  the remaining four groups must all be in the same place.*/
+typedef struct{
+  /**The bit pattern for the code, with the LSbit of the pattern aligned in
+   *   the LSbit of the word.*/
+  ogg_uint32_t pattern;
+  /**The number of bits in the code.
+   * This must be between 0 and 32, inclusive.*/
+  int          nbits;
+}th_huff_code;
+
+
+
+/**\defgroup basefuncs Functions Shared by Encode and Decode*/
+/*@{*/
+/**\name Basic shared functions*/
+/*@{*/
+/**Retrieves a human-readable string to identify the library vendor and
+ *  version.
+ * \return the version string.*/
+extern const char *th_version_string(void);
+/**Retrieves the library version number.
+ * This is the highest bitstream version that the encoder library will produce,
+ *  or that the decoder library can decode.
+ * This number is composed of a 16-bit major version, 8-bit minor version
+ * and 8 bit sub-version, composed as follows:
+ * \code
+ * (VERSION_MAJOR<<16)+(VERSION_MINOR<<8)+(VERSION_SUBMINOR)
+ * \endcode
+ * \return the version number.*/
+extern ogg_uint32_t th_version_number(void);
+/**Converts a granule position to an absolute frame index, starting at
+ *  <tt>0</tt>.
+ * The granule position is interpreted in the context of a given
+ *  #th_enc_ctx or #th_dec_ctx handle (either will suffice).
+ * \param _encdec  A previously allocated #th_enc_ctx or #th_dec_ctx
+ *                  handle.
+ * \param _granpos The granule position to convert.
+ * \returns The absolute frame index corresponding to \a _granpos.
+ * \retval -1 The given granule position was invalid (i.e. negative).*/
+extern ogg_int64_t th_granule_frame(void *_encdec,ogg_int64_t _granpos);
+/**Converts a granule position to an absolute time in seconds.
+ * The granule position is interpreted in the context of a given
+ *  #th_enc_ctx or #th_dec_ctx handle (either will suffice).
+ * \param _encdec  A previously allocated #th_enc_ctx or #th_dec_ctx
+ *                  handle.
+ * \param _granpos The granule position to convert.
+ * \return The absolute time in seconds corresponding to \a _granpos.
+ *         This is the "end time" for the frame, or the latest time it should
+ *          be displayed.
+ *         It is not the presentation time.
+ * \retval -1 The given granule position was invalid (i.e. negative).*/
+extern double th_granule_time(void *_encdec,ogg_int64_t _granpos);
+/**Determines whether a Theora packet is a header or not.
+ * This function does no verification beyond checking the packet type bit, so
+ *  it should not be used for bitstream identification; use
+ *  th_decode_headerin() for that.
+ * As per the Theora specification, an empty (0-byte) packet is treated as a
+ *  data packet (a delta frame with no coded blocks).
+ * \param _op An <tt>ogg_packet</tt> containing encoded Theora data.
+ * \retval 1 The packet is a header packet
+ * \retval 0 The packet is a video data packet.*/
+extern int th_packet_isheader(ogg_packet *_op);
+/**Determines whether a theora packet is a key frame or not.
+ * This function does no verification beyond checking the packet type and
+ *  key frame bits, so it should not be used for bitstream identification; use
+ *  th_decode_headerin() for that.
+ * As per the Theora specification, an empty (0-byte) packet is treated as a
+ *  delta frame (with no coded blocks).
+ * \param _op An <tt>ogg_packet</tt> containing encoded Theora data.
+ * \retval 1  The packet contains a key frame.
+ * \retval 0  The packet contains a delta frame.
+ * \retval -1 The packet is not a video data packet.*/
+extern int th_packet_iskeyframe(ogg_packet *_op);
+/*@}*/
+
+
+/**\name Functions for manipulating header data*/
+/*@{*/
+/**Initializes a th_info structure.
+ * This should be called on a freshly allocated #th_info structure before
+ *  attempting to use it.
+ * \param _info The #th_info struct to initialize.*/
+extern void th_info_init(th_info *_info);
+/**Clears a #th_info structure.
+ * This should be called on a #th_info structure after it is no longer
+ *  needed.
+ * \param _info The #th_info struct to clear.*/
+extern void th_info_clear(th_info *_info);
+
+/**Initialize a #th_comment structure.
+ * This should be called on a freshly allocated #th_comment structure
+ *  before attempting to use it.
+ * \param _tc The #th_comment struct to initialize.*/
+extern void th_comment_init(th_comment *_tc);
+/**Add a comment to an initialized #th_comment structure.
+ * \note Neither th_comment_add() nor th_comment_add_tag() support
+ *  comments containing null values, although the bitstream format does
+ *  support them.
+ * To add such comments you will need to manipulate the #th_comment
+ *  structure directly.
+ * \param _tc      The #th_comment struct to add the comment to.
+ * \param _comment Must be a null-terminated UTF-8 string containing the
+ *                  comment in "TAG=the value" form.*/
+extern void th_comment_add(th_comment *_tc, char *_comment);
+/**Add a comment to an initialized #th_comment structure.
+ * \note Neither th_comment_add() nor th_comment_add_tag() support
+ *  comments containing null values, although the bitstream format does
+ *  support them.
+ * To add such comments you will need to manipulate the #th_comment
+ *  structure directly.
+ * \param _tc  The #th_comment struct to add the comment to.
+ * \param _tag A null-terminated string containing the tag  associated with
+ *              the comment.
+ * \param _val The corresponding value as a null-terminated string.*/
+extern void th_comment_add_tag(th_comment *_tc,char *_tag,char *_val);
+/**Look up a comment value by its tag.
+ * \param _tc    An initialized #th_comment structure.
+ * \param _tag   The tag to look up.
+ * \param _count The instance of the tag.
+ *               The same tag can appear multiple times, each with a distinct
+ *                value, so an index is required to retrieve them all.
+ *               The order in which these values appear is significant and
+ *                should be preserved.
+ *               Use th_comment_query_count() to get the legal range for
+ *                the \a _count parameter.
+ * \return A pointer to the queried tag's value.
+ *         This points directly to data in the #th_comment structure.
+ *         It should not be modified or freed by the application, and
+ *          modifications to the structure may invalidate the pointer.
+ * \retval NULL If no matching tag is found.*/
+extern char *th_comment_query(th_comment *_tc,char *_tag,int _count);
+/**Look up the number of instances of a tag.
+ * Call this first when querying for a specific tag and then iterate over the
+ *  number of instances with separate calls to th_comment_query() to
+ *  retrieve all the values for that tag in order.
+ * \param _tc    An initialized #th_comment structure.
+ * \param _tag   The tag to look up.
+ * \return The number on instances of this particular tag.*/
+extern int th_comment_query_count(th_comment *_tc,char *_tag);
+/**Clears a #th_comment structure.
+ * This should be called on a #th_comment structure after it is no longer
+ *  needed.
+ * It will free all memory used by the structure members.
+ * \param _tc The #th_comment struct to clear.*/
+extern void th_comment_clear(th_comment *_tc);
+/*@}*/
+/*@}*/
+
+
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/include/theora/theora.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/include/theora/theora.h
new file mode 100644
index 0000000..0316891
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/include/theora/theora.h
@@ -0,0 +1,823 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: theora.h,v 1.17 2003/12/06 18:06:19 arc Exp $
+
+ ********************************************************************/
+
+#ifndef _O_THEORA_H_
+#define _O_THEORA_H_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+#include <stddef.h>	/* for size_t */
+
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+#include <vtkoggtheora/include/ogg/ogg.h>
+
+/** \defgroup oldfuncs Legacy pre-1.0 C API */
+/*  @{ */
+
+/** \mainpage
+ * 
+ * \section intro Introduction
+ *
+ * This is the documentation for the libtheora legacy C API, declared in 
+ * the theora.h header, which describes the old interface used before
+ * the 1.0 release. This API was widely deployed for several years and
+ * remains supported, but for new code we recommend the cleaner API 
+ * declared in theoradec.h and theoraenc.h.
+ *
+ * libtheora is the reference implementation for
+ * <a href="http://www.theora.org/">Theora</a>, a free video codec.
+ * Theora is derived from On2's VP3 codec with improved integration for
+ * Ogg multimedia formats by <a href="http://www.xiph.org/">Xiph.Org</a>.
+ * 
+ * \section overview Overview
+ *
+ * This library will both decode and encode theora packets to/from raw YUV 
+ * frames.  In either case, the packets will most likely either come from or
+ * need to be embedded in an Ogg stream.  Use 
+ * <a href="http://xiph.org/ogg/">libogg</a> or 
+ * <a href="http://www.annodex.net/software/liboggz/index.html">liboggz</a>
+ * to extract/package these packets.
+ *
+ * \section decoding Decoding Process
+ *
+ * Decoding can be separated into the following steps:
+ * -# initialise theora_info and theora_comment structures using 
+ *    theora_info_init() and theora_comment_init():
+ \verbatim
+ theora_info     info;
+ theora_comment  comment;
+   
+ theora_info_init(&info);
+ theora_comment_init(&comment);
+ \endverbatim
+ * -# retrieve header packets from Ogg stream (there should be 3) and decode 
+ *    into theora_info and theora_comment structures using 
+ *    theora_decode_header().  See \ref identification for more information on 
+ *    identifying which packets are theora packets.
+ \verbatim
+ int i;
+ for (i = 0; i < 3; i++)
+ {
+   (get a theora packet "op" from the Ogg stream)
+   theora_decode_header(&info, &comment, op);
+ }
+ \endverbatim
+ * -# initialise the decoder based on the information retrieved into the
+ *    theora_info struct by theora_decode_header().  You will need a 
+ *    theora_state struct.
+ \verbatim
+ theora_state state;
+ 
+ theora_decode_init(&state, &info);
+ \endverbatim
+ * -# pass in packets and retrieve decoded frames!  See the yuv_buffer 
+ *    documentation for information on how to retrieve raw YUV data.
+ \verbatim
+ yuf_buffer buffer;
+ while (last packet was not e_o_s) {
+   (get a theora packet "op" from the Ogg stream)
+   theora_decode_packetin(&state, op);
+   theora_decode_YUVout(&state, &buffer);
+ }
+ \endverbatim
+ *  
+ *
+ * \subsection identification Identifying Theora Packets
+ *
+ * All streams inside an Ogg file have a unique serial_no attached to the 
+ * stream.  Typically, you will want to 
+ *  - retrieve the serial_no for each b_o_s (beginning of stream) page 
+ *    encountered within the Ogg file; 
+ *  - test the first (only) packet on that page to determine if it is a theora 
+ *    packet;
+ *  - once you have found a theora b_o_s page then use the retrieved serial_no 
+ *    to identify future packets belonging to the same theora stream.
+ * 
+ * Note that you \e cannot use theora_packet_isheader() to determine if a 
+ * packet is a theora packet or not, as this function does not perform any
+ * checking beyond whether a header bit is present.  Instead, use the
+ * theora_decode_header() function and check the return value; or examine the
+ * header bytes at the beginning of the Ogg page.
+ *
+ * \subsection example Example Decoder 
+ *
+ * See <a href="http://svn.xiph.org/trunk/theora/examples/dump_video.c">
+ * examples/dump_video.c</a> for a simple decoder implementation.
+ *
+ * \section encoding Encoding Process
+ *
+ * See <a href="http://svn.xiph.org/trunk/theora/examples/encoder_example.c">
+ * examples/encoder_example.c</a> for a simple encoder implementation.
+ */
+
+/** \file
+ * The libtheora pre-1.0 legacy C API.
+ */
+
+/**
+ * A YUV buffer for passing uncompressed frames to and from the codec.
+ * This holds a Y'CbCr frame in planar format. The CbCr planes can be
+ * subsampled and have their own separate dimensions and row stride
+ * offsets. Note that the strides may be negative in some 
+ * configurations. For theora the width and height of the largest plane
+ * must be a multiple of 16. The actual meaningful picture size and 
+ * offset are stored in the theora_info structure; frames returned by
+ * the decoder may need to be cropped for display.
+ *
+ * All samples are 8 bits. Within each plane samples are ordered by
+ * row from the top of the frame to the bottom. Within each row samples
+ * are ordered from left to right.
+ *
+ * During decode, the yuv_buffer struct is allocated by the user, but all
+ * fields (including luma and chroma pointers) are filled by the library.  
+ * These pointers address library-internal memory and their contents should 
+ * not be modified.
+ *
+ * Conversely, during encode the user allocates the struct and fills out all
+ * fields.  The user also manages the data addressed by the luma and chroma
+ * pointers.  See the encoder_example.c and dump_video.c example files in
+ * theora/examples/ for more information.
+ */
+typedef struct {
+    int   y_width;      /**< Width of the Y' luminance plane */
+    int   y_height;     /**< Height of the luminance plane */
+    int   y_stride;     /**< Offset in bytes between successive rows */
+
+    int   uv_width;     /**< Width of the Cb and Cr chroma planes */
+    int   uv_height;    /**< Height of the chroma planes */
+    int   uv_stride;    /**< Offset between successive chroma rows */
+    unsigned char *y;   /**< Pointer to start of luminance data */
+    unsigned char *u;   /**< Pointer to start of Cb data */
+    unsigned char *v;   /**< Pointer to start of Cr data */
+
+} yuv_buffer;
+
+/**
+ * A Colorspace.
+ */
+typedef enum {
+  OC_CS_UNSPECIFIED,    /**< The colorspace is unknown or unspecified */
+  OC_CS_ITU_REC_470M,   /**< This is the best option for 'NTSC' content */
+  OC_CS_ITU_REC_470BG,  /**< This is the best option for 'PAL' content */
+  OC_CS_NSPACES         /**< This marks the end of the defined colorspaces */
+} theora_colorspace;
+
+/**
+ * A Chroma subsampling
+ *
+ * These enumerate the available chroma subsampling options supported
+ * by the theora format. See Section 4.4 of the specification for
+ * exact definitions.
+ */
+typedef enum {
+  OC_PF_420,    /**< Chroma subsampling by 2 in each direction (4:2:0) */
+  OC_PF_RSVD,   /**< Reserved value */
+  OC_PF_422,    /**< Horizonatal chroma subsampling by 2 (4:2:2) */
+  OC_PF_444,    /**< No chroma subsampling at all (4:4:4) */
+} theora_pixelformat;
+
+/**
+ * Theora bitstream info.
+ * Contains the basic playback parameters for a stream,
+ * corresponding to the initial 'info' header packet.
+ * 
+ * Encoded theora frames must be a multiple of 16 in width and height.
+ * To handle other frame sizes, a crop rectangle is specified in
+ * frame_height and frame_width, offset_x and * offset_y. The offset
+ * and size should still be a multiple of 2 to avoid chroma sampling
+ * shifts. Offset values in this structure are measured from the
+ * upper left of the image.
+ *
+ * Frame rate, in frames per second, is stored as a rational
+ * fraction. Aspect ratio is also stored as a rational fraction, and
+ * refers to the aspect ratio of the frame pixels, not of the
+ * overall frame itself.
+ * 
+ * See <a href="http://svn.xiph.org/trunk/theora/examples/encoder_example.c">
+ * examples/encoder_example.c</a> for usage examples of the
+ * other paramters and good default settings for the encoder parameters.
+ */
+typedef struct {
+  ogg_uint32_t  width;		/**< encoded frame width  */
+  ogg_uint32_t  height;		/**< encoded frame height */
+  ogg_uint32_t  frame_width;	/**< display frame width  */
+  ogg_uint32_t  frame_height;	/**< display frame height */
+  ogg_uint32_t  offset_x;	/**< horizontal offset of the displayed frame */
+  ogg_uint32_t  offset_y;	/**< vertical offset of the displayed frame */
+  ogg_uint32_t  fps_numerator;	    /**< frame rate numerator **/
+  ogg_uint32_t  fps_denominator;    /**< frame rate denominator **/
+  ogg_uint32_t  aspect_numerator;   /**< pixel aspect ratio numerator */
+  ogg_uint32_t  aspect_denominator; /**< pixel aspect ratio denominator */
+  theora_colorspace colorspace;	    /**< colorspace */
+  int           target_bitrate;	    /**< nominal bitrate in bits per second */
+  int           quality;  /**< Nominal quality setting, 0-63 */
+  int           quick_p;  /**< Quick encode/decode */
+
+  /* decode only */
+  unsigned char version_major;
+  unsigned char version_minor;
+  unsigned char version_subminor;
+
+  void *codec_setup;
+
+  /* encode only */
+  int           dropframes_p;
+  int           keyframe_auto_p;
+  ogg_uint32_t  keyframe_frequency;
+  ogg_uint32_t  keyframe_frequency_force;  /* also used for decode init to
+                                              get granpos shift correct */
+  ogg_uint32_t  keyframe_data_target_bitrate;
+  ogg_int32_t   keyframe_auto_threshold;
+  ogg_uint32_t  keyframe_mindistance;
+  ogg_int32_t   noise_sensitivity;
+  ogg_int32_t   sharpness;
+
+  theora_pixelformat pixelformat;	/**< chroma subsampling mode to expect */
+
+} theora_info;
+
+/** Codec internal state and context.
+ */
+typedef struct{
+  theora_info *i;
+  ogg_int64_t granulepos;
+
+  void *internal_encode;
+  void *internal_decode;
+
+} theora_state;
+
+/** 
+ * Comment header metadata.
+ *
+ * This structure holds the in-stream metadata corresponding to
+ * the 'comment' header packet.
+ *
+ * Meta data is stored as a series of (tag, value) pairs, in
+ * length-encoded string vectors. The first occurence of the 
+ * '=' character delimits the tag and value. A particular tag
+ * may occur more than once. The character set encoding for
+ * the strings is always UTF-8, but the tag names are limited
+ * to case-insensitive ASCII. See the spec for details.
+ *
+ * In filling in this structure, theora_decode_header() will
+ * null-terminate the user_comment strings for safety. However,
+ * the bitstream format itself treats them as 8-bit clean,
+ * and so the length array should be treated as authoritative
+ * for their length.
+ */
+typedef struct theora_comment{
+  char **user_comments;         /**< An array of comment string vectors */
+  int   *comment_lengths;       /**< An array of corresponding string vector lengths in bytes */
+  int    comments;              /**< The total number of comment string vectors */
+  char  *vendor;                /**< The vendor string identifying the encoder, null terminated */
+
+} theora_comment;
+
+
+/**\name theora_control() codes */
+
+/**\anchor decctlcodes
+ * These are the available request codes for theora_control()
+ * when called with a decoder instance.
+ * By convention, these are odd, to distinguish them from the
+ *  \ref encctlcodes "encoder control codes".
+ * Keep any experimental or vendor-specific values above \c 0x8000.*/
+
+/**Get the maximum post-processing level.
+ * The decoder supports a post-processing filter that can improve
+ * the appearance of the decoded images. This returns the highest
+ * level setting for this post-processor, corresponding to maximum
+ * improvement and computational expense.
+ */
+#define TH_DECCTL_GET_PPLEVEL_MAX (1)
+
+/**Set the post-processing level.
+ * Sets the level of post-processing to use when decoding the 
+ * compressed stream. This must be a value between zero (off)
+ * and the maximum returned by TH_DECCTL_GET_PPLEVEL_MAX.
+ */
+#define TH_DECCTL_SET_PPLEVEL (3)
+
+/**Sets the maximum distance between key frames.
+ * This can be changed during an encode, but will be bounded by
+ *  <tt>1<<th_info#keyframe_granule_shift</tt>.
+ * If it is set before encoding begins, th_info#keyframe_granule_shift will
+ *  be enlarged appropriately.
+ *
+ * \param[in]  buf <tt>ogg_uint32_t</tt>: The maximum distance between key
+ *                   frames.
+ * \param[out] buf <tt>ogg_uint32_t</tt>: The actual maximum distance set.
+ * \retval TH_FAULT  \a theora_state or \a buf is <tt>NULL</tt>.
+ * \retval TH_EINVAL \a buf_sz is not <tt>sizeof(ogg_uint32_t)</tt>.
+ * \retval TH_IMPL   Not supported by this implementation.*/
+#define TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE (4)
+
+/**Set the granule position.
+ * Call this after a seek, to update the internal granulepos
+ * in the decoder, to insure that subsequent frames are marked
+ * properly. If you track timestamps yourself and do not use
+ * the granule postion returned by the decoder, then you do
+ * not need to use this control.
+ */
+#define TH_DECCTL_SET_GRANPOS (5)
+
+#define TH_DECCTL_SET_TELEMETRY_MBMODE (9)
+#define TH_DECCTL_SET_TELEMETRY_MV (11)
+
+/**\anchor encctlcodes
+ * These are the available request codes for theora_control()
+ * when called with an encoder instance.
+ * By convention, these are even, to distinguish them from the
+ *  \ref decctlcodes "decoder control codes".
+ * Keep any experimental or vendor-specific values above \c 0x8000.*/
+/*@{*/
+/**Sets the quantization parameters to use.
+ * The parameters are copied, not stored by reference, so they can be freed
+ *  after this call.
+ * <tt>NULL</tt> may be specified to revert to the default parameters.
+ * For the current encoder, <tt>scale[ci!=0][qi]</tt> must be no greater than
+ *  <tt>scale[ci!=0][qi-1]</tt> and <tt>base[qti][pli][qi][ci]</tt> must be no
+ *  greater than <tt>base[qti][pli][qi-1][ci]</tt>.
+ * These two conditions ensure that the actual quantizer for a given \a qti,
+ *  \a pli, and \a ci does not increase as \a qi increases.
+ *
+ * \param[in] buf #th_quant_info
+ * \retval TH_FAULT  \a theora_state is <tt>NULL</tt>.
+ * \retval TH_EINVAL Encoding has already begun, the quantization parameters
+ *                    do not meet one of the above stated conditions, \a buf
+ *                    is <tt>NULL</tt> and \a buf_sz is not zero, or \a buf
+ *                    is non-<tt>NULL</tt> and \a buf_sz is not
+ *                    <tt>sizeof(#th_quant_info)</tt>.
+ * \retval TH_IMPL   Not supported by this implementation.*/
+#define TH_ENCCTL_SET_QUANT_PARAMS (2)
+/**Disables any encoder features that would prevent lossless transcoding back
+ *  to VP3.
+ * This primarily means disabling block-level QI values and not using 4MV mode
+ *  when any of the luma blocks in a macro block are not coded.
+ * It also includes using the VP3 quantization tables and Huffman codes; if you
+ *  set them explicitly after calling this function, the resulting stream will
+ *  not be VP3-compatible.
+ * If you enable VP3-compatibility when encoding 4:2:2 or 4:4:4 source
+ *  material, or when using a picture region smaller than the full frame (e.g.
+ *  a non-multiple-of-16 width or height), then non-VP3 bitstream features will
+ *  still be disabled, but the stream will still not be VP3-compatible, as VP3
+ *  was not capable of encoding such formats.
+ * If you call this after encoding has already begun, then the quantization
+ *  tables and codebooks cannot be changed, but the frame-level features will
+ *  be enabled or disabled as requested.
+ *
+ * \param[in]  buf <tt>int</tt>: a non-zero value to enable VP3 compatibility,
+ *                   or 0 to disable it (the default).
+ * \param[out] buf <tt>int</tt>: 1 if all bitstream features required for
+ *                   VP3-compatibility could be set, and 0 otherwise.
+ *                  The latter will be returned if the pixel format is not
+ *                   4:2:0, the picture region is smaller than the full frame,
+ *                   or if encoding has begun, preventing the quantization
+ *                   tables and codebooks from being set.
+ * \retval TH_FAULT  \a theora_state or \a buf is <tt>NULL</tt>.
+ * \retval TH_EINVAL \a buf_sz is not <tt>sizeof(int)</tt>.
+ * \retval TH_IMPL   Not supported by this implementation.*/
+#define TH_ENCCTL_SET_VP3_COMPATIBLE (10)
+/**Gets the maximum speed level.
+ * Higher speed levels favor quicker encoding over better quality per bit.
+ * Depending on the encoding mode, and the internal algorithms used, quality
+ *  may actually improve, but in this case bitrate will also likely increase.
+ * In any case, overall rate/distortion performance will probably decrease.
+ * The maximum value, and the meaning of each value, may change depending on
+ *  the current encoding mode (VBR vs. CQI, etc.).
+ *
+ * \param[out] buf int: The maximum encoding speed level.
+ * \retval TH_FAULT  \a theora_state or \a buf is <tt>NULL</tt>.
+ * \retval TH_EINVAL \a buf_sz is not <tt>sizeof(int)</tt>.
+ * \retval TH_IMPL   Not supported by this implementation in the current
+ *                    encoding mode.*/
+#define TH_ENCCTL_GET_SPLEVEL_MAX (12)
+/**Sets the speed level.
+ * By default a speed value of 1 is used.
+ *
+ * \param[in] buf int: The new encoding speed level.
+ *                      0 is slowest, larger values use less CPU.
+ * \retval TH_FAULT  \a theora_state or \a buf is <tt>NULL</tt>.
+ * \retval TH_EINVAL \a buf_sz is not <tt>sizeof(int)</tt>, or the
+ *                    encoding speed level is out of bounds.
+ *                   The maximum encoding speed level may be
+ *                    implementation- and encoding mode-specific, and can be
+ *                    obtained via #TH_ENCCTL_GET_SPLEVEL_MAX.
+ * \retval TH_IMPL   Not supported by this implementation in the current
+ *                    encoding mode.*/
+#define TH_ENCCTL_SET_SPLEVEL (14)
+/**Sets the number of duplicates of the next frame to produce.
+ * Although libtheora can encode duplicate frames very cheaply, it costs some
+ *  amount of CPU to detect them, and a run of duplicates cannot span a
+ *  keyframe boundary.
+ * This control code tells the encoder to produce the specified number of extra
+ *  duplicates of the next frame.
+ * This allows the encoder to make smarter keyframe placement decisions and
+ *  rate control decisions, as well as reduces CPU usage, when compared to just
+ *  submitting the same frame for encoding multiple times.
+ * This setting only applies to the next frame submitted for encoding.
+ * You MUST call th_encode_packetout() repeatedly until it returns 0, or the
+ *  extra duplicate frames will be lost.
+ *
+ * \param[in] _buf int: The number of duplicates to produce.
+ *                      Unless this is positive, no duplicates will be produced.
+ * \retval TH_EFAULT \a _enc_ctx or \a _buf is <tt>NULL</tt>.
+ * \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>, or the
+ *                    number of duplicates is greater than or equal to the
+ *                    maximum keyframe interval.
+ *                   In the latter case, NO duplicate frames will be produced.
+ *                   You must ensure that the maximum keyframe interval is set
+ *                    larger than the maximum number of duplicates you will
+ *                    ever wish to insert prior to encoding.
+ * \retval TH_IMPL   Not supported by this implementation in the current
+ *                    encoding mode.*/
+#define TH_ENCCTL_SET_DUP_COUNT (18)
+/*@}*/
+
+#define OC_FAULT       -1       /**< General failure */
+#define OC_EINVAL      -10      /**< Library encountered invalid internal data */
+#define OC_DISABLED    -11      /**< Requested action is disabled */
+#define OC_BADHEADER   -20      /**< Header packet was corrupt/invalid */
+#define OC_NOTFORMAT   -21      /**< Packet is not a theora packet */
+#define OC_VERSION     -22      /**< Bitstream version is not handled */
+#define OC_IMPL        -23      /**< Feature or action not implemented */
+#define OC_BADPACKET   -24      /**< Packet is corrupt */
+#define OC_NEWPACKET   -25      /**< Packet is an (ignorable) unhandled extension */
+#define OC_DUPFRAME    1        /**< Packet is a dropped frame */
+
+/** 
+ * Retrieve a human-readable string to identify the encoder vendor and version.
+ * \returns A version string.
+ */
+extern const char *theora_version_string(void);
+
+/**
+ * Retrieve a 32-bit version number.
+ * This number is composed of a 16-bit major version, 8-bit minor version
+ * and 8 bit sub-version, composed as follows:
+<pre>
+   (VERSION_MAJOR<<16) + (VERSION_MINOR<<8) + (VERSION_SUB)
+</pre>
+* \returns The version number.
+*/
+extern ogg_uint32_t theora_version_number(void);
+
+/**
+ * Initialize the theora encoder.
+ * \param th The theora_state handle to initialize for encoding.
+ * \param ti A theora_info struct filled with the desired encoding parameters.
+ * \retval 0 Success
+ */
+extern int theora_encode_init(theora_state *th, theora_info *ti);
+
+/**
+ * Submit a YUV buffer to the theora encoder.
+ * \param t A theora_state handle previously initialized for encoding.
+ * \param yuv A buffer of YUV data to encode.  Note that both the yuv_buffer
+ *            struct and the luma/chroma buffers within should be allocated by
+ *            the user.
+ * \retval OC_EINVAL Encoder is not ready, or is finished.
+ * \retval -1 The size of the given frame differs from those previously input
+ * \retval 0 Success
+ */
+extern int theora_encode_YUVin(theora_state *t, yuv_buffer *yuv);
+
+/**
+ * Request the next packet of encoded video. 
+ * The encoded data is placed in a user-provided ogg_packet structure.
+ * \param t A theora_state handle previously initialized for encoding.
+ * \param last_p whether this is the last packet the encoder should produce.
+ * \param op An ogg_packet structure to fill. libtheora will set all
+ *           elements of this structure, including a pointer to encoded
+ *           data. The memory for the encoded data is owned by libtheora.
+ * \retval 0 No internal storage exists OR no packet is ready
+ * \retval -1 The encoding process has completed
+ * \retval 1 Success
+ */
+extern int theora_encode_packetout( theora_state *t, int last_p,
+                                    ogg_packet *op);
+
+/**
+ * Request a packet containing the initial header.
+ * A pointer to the header data is placed in a user-provided ogg_packet
+ * structure.
+ * \param t A theora_state handle previously initialized for encoding.
+ * \param op An ogg_packet structure to fill. libtheora will set all
+ *           elements of this structure, including a pointer to the header
+ *           data. The memory for the header data is owned by libtheora.
+ * \retval 0 Success
+ */
+extern int theora_encode_header(theora_state *t, ogg_packet *op);
+
+/**
+ * Request a comment header packet from provided metadata.
+ * A pointer to the comment data is placed in a user-provided ogg_packet
+ * structure.
+ * \param tc A theora_comment structure filled with the desired metadata
+ * \param op An ogg_packet structure to fill. libtheora will set all
+ *           elements of this structure, including a pointer to the encoded
+ *           comment data. The memory for the comment data is owned by
+ *           libtheora.
+ * \retval 0 Success
+ */
+extern int theora_encode_comment(theora_comment *tc, ogg_packet *op);
+
+/**
+ * Request a packet containing the codebook tables for the stream.
+ * A pointer to the codebook data is placed in a user-provided ogg_packet
+ * structure.
+ * \param t A theora_state handle previously initialized for encoding.
+ * \param op An ogg_packet structure to fill. libtheora will set all
+ *           elements of this structure, including a pointer to the codebook
+ *           data. The memory for the header data is owned by libtheora.
+ * \retval 0 Success
+ */
+extern int theora_encode_tables(theora_state *t, ogg_packet *op);
+
+/**
+ * Decode an Ogg packet, with the expectation that the packet contains
+ * an initial header, comment data or codebook tables.
+ *
+ * \param ci A theora_info structure to fill. This must have been previously
+ *           initialized with theora_info_init(). If \a op contains an initial
+ *           header, theora_decode_header() will fill \a ci with the
+ *           parsed header values. If \a op contains codebook tables,
+ *           theora_decode_header() will parse these and attach an internal
+ *           representation to \a ci->codec_setup.
+ * \param cc A theora_comment structure to fill. If \a op contains comment
+ *           data, theora_decode_header() will fill \a cc with the parsed
+ *           comments.
+ * \param op An ogg_packet structure which you expect contains an initial
+ *           header, comment data or codebook tables.
+ *
+ * \retval OC_BADHEADER \a op is NULL; OR the first byte of \a op->packet
+ *                      has the signature of an initial packet, but op is
+ *                      not a b_o_s packet; OR this packet has the signature
+ *                      of an initial header packet, but an initial header
+ *                      packet has already been seen; OR this packet has the
+ *                      signature of a comment packet, but the initial header
+ *                      has not yet been seen; OR this packet has the signature
+ *                      of a comment packet, but contains invalid data; OR
+ *                      this packet has the signature of codebook tables,
+ *                      but the initial header or comments have not yet
+ *                      been seen; OR this packet has the signature of codebook
+ *                      tables, but contains invalid data;
+ *                      OR the stream being decoded has a compatible version
+ *                      but this packet does not have the signature of a
+ *                      theora initial header, comments, or codebook packet
+ * \retval OC_VERSION   The packet data of \a op is an initial header with
+ *                      a version which is incompatible with this version of
+ *                      libtheora.
+ * \retval OC_NEWPACKET the stream being decoded has an incompatible (future)
+ *                      version and contains an unknown signature.
+ * \retval 0            Success
+ *
+ * \note The normal usage is that theora_decode_header() be called on the
+ *       first three packets of a theora logical bitstream in succession.
+ */
+extern int theora_decode_header(theora_info *ci, theora_comment *cc,
+                                ogg_packet *op);
+
+/**
+ * Initialize a theora_state handle for decoding.
+ * \param th The theora_state handle to initialize.
+ * \param c  A theora_info struct filled with the desired decoding parameters.
+ *           This is of course usually obtained from a previous call to
+ *           theora_decode_header().
+ * \retval 0 Success
+ */
+extern int theora_decode_init(theora_state *th, theora_info *c);
+
+/**
+ * Input a packet containing encoded data into the theora decoder.
+ * \param th A theora_state handle previously initialized for decoding.
+ * \param op An ogg_packet containing encoded theora data.
+ * \retval 0 Success
+ * \retval OC_BADPACKET \a op does not contain encoded video data
+ */
+extern int theora_decode_packetin(theora_state *th,ogg_packet *op);
+
+/**
+ * Output the next available frame of decoded YUV data.
+ * \param th A theora_state handle previously initialized for decoding.
+ * \param yuv A yuv_buffer in which libtheora should place the decoded data.
+ *            Note that the buffer struct itself is allocated by the user, but
+ *            that the luma and chroma pointers will be filled in by the 
+ *            library.  Also note that these luma and chroma regions should be 
+ *            considered read-only by the user.
+ * \retval 0 Success
+ */
+extern int theora_decode_YUVout(theora_state *th,yuv_buffer *yuv);
+
+/**
+ * Report whether a theora packet is a header or not
+ * This function does no verification beyond checking the header
+ * flag bit so it should not be used for bitstream identification;
+ * use theora_decode_header() for that.
+ *
+ * \param op An ogg_packet containing encoded theora data.
+ * \retval 1 The packet is a header packet
+ * \retval 0 The packet is not a header packet (and so contains frame data)
+ *
+ * Thus function was added in the 1.0alpha4 release.
+ */
+extern int theora_packet_isheader(ogg_packet *op);
+
+/**
+ * Report whether a theora packet is a keyframe or not
+ *
+ * \param op An ogg_packet containing encoded theora data.
+ * \retval 1 The packet contains a keyframe image
+ * \retval 0 The packet is contains an interframe delta
+ * \retval -1 The packet is not an image data packet at all
+ *
+ * Thus function was added in the 1.0alpha4 release.
+ */
+extern int theora_packet_iskeyframe(ogg_packet *op);
+
+/**
+ * Report the granulepos shift radix
+ *
+ * When embedded in Ogg, Theora uses a two-part granulepos, 
+ * splitting the 64-bit field into two pieces. The more-significant
+ * section represents the frame count at the last keyframe,
+ * and the less-significant section represents the count of
+ * frames since the last keyframe. In this way the overall
+ * field is still non-decreasing with time, but usefully encodes
+ * a pointer to the last keyframe, which is necessary for
+ * correctly restarting decode after a seek. 
+ *
+ * This function reports the number of bits used to represent
+ * the distance to the last keyframe, and thus how the granulepos
+ * field must be shifted or masked to obtain the two parts.
+ * 
+ * Since libtheora returns compressed data in an ogg_packet
+ * structure, this may be generally useful even if the Theora
+ * packets are not being used in an Ogg container. 
+ *
+ * \param ti A previously initialized theora_info struct
+ * \returns The bit shift dividing the two granulepos fields
+ *
+ * This function was added in the 1.0alpha5 release.
+ */
+int theora_granule_shift(theora_info *ti);
+
+/**
+ * Convert a granulepos to an absolute frame index, starting at 0.
+ * The granulepos is interpreted in the context of a given theora_state handle.
+ * 
+ * Note that while the granulepos encodes the frame count (i.e. starting
+ * from 1) this call returns the frame index, starting from zero. Thus
+ * One can calculate the presentation time by multiplying the index by
+ * the rate.
+ *
+ * \param th A previously initialized theora_state handle (encode or decode)
+ * \param granulepos The granulepos to convert.
+ * \returns The frame index corresponding to \a granulepos.
+ * \retval -1 The given granulepos is undefined (i.e. negative)
+ *
+ * Thus function was added in the 1.0alpha4 release.
+ */
+extern ogg_int64_t theora_granule_frame(theora_state *th,ogg_int64_t granulepos);
+
+/**
+ * Convert a granulepos to absolute time in seconds. The granulepos is
+ * interpreted in the context of a given theora_state handle, and gives
+ * the end time of a frame's presentation as used in Ogg mux ordering.
+ *
+ * \param th A previously initialized theora_state handle (encode or decode)
+ * \param granulepos The granulepos to convert.
+ * \returns The absolute time in seconds corresponding to \a granulepos.
+ *          This is the "end time" for the frame, or the latest time it should
+ *           be displayed.
+ *          It is not the presentation time.
+ * \retval -1. The given granulepos is undefined (i.e. negative), or
+ * \retval -1. The function has been disabled because floating 
+ *              point support is not available.
+ */
+extern double theora_granule_time(theora_state *th,ogg_int64_t granulepos);
+
+/**
+ * Initialize a theora_info structure. All values within the given theora_info
+ * structure are initialized, and space is allocated within libtheora for
+ * internal codec setup data.
+ * \param c A theora_info struct to initialize.
+ */
+extern void theora_info_init(theora_info *c);
+
+/**
+ * Clear a theora_info structure. All values within the given theora_info
+ * structure are cleared, and associated internal codec setup data is freed.
+ * \param c A theora_info struct to initialize.
+ */
+extern void theora_info_clear(theora_info *c);
+
+/**
+ * Free all internal data associated with a theora_state handle.
+ * \param t A theora_state handle.
+ */
+extern void theora_clear(theora_state *t);
+
+/**
+ * Initialize an allocated theora_comment structure
+ * \param tc An allocated theora_comment structure 
+ **/
+extern void theora_comment_init(theora_comment *tc);
+
+/**
+ * Add a comment to an initialized theora_comment structure
+ * \param tc A previously initialized theora comment structure
+ * \param comment A null-terminated string encoding the comment in the form
+ *                "TAG=the value"
+ *
+ * Neither theora_comment_add() nor theora_comment_add_tag() support
+ * comments containing null values, although the bitstream format
+ * supports this. To add such comments you will need to manipulate
+ * the theora_comment structure directly.
+ **/
+
+extern void theora_comment_add(theora_comment *tc, char *comment);
+
+/**
+ * Add a comment to an initialized theora_comment structure.
+ * \param tc A previously initialized theora comment structure
+ * \param tag A null-terminated string containing the tag 
+ *            associated with the comment.
+ * \param value The corresponding value as a null-terminated string
+ *
+ * Neither theora_comment_add() nor theora_comment_add_tag() support
+ * comments containing null values, although the bitstream format
+ * supports this. To add such comments you will need to manipulate
+ * the theora_comment structure directly.
+ **/
+extern void theora_comment_add_tag(theora_comment *tc,
+                                       char *tag, char *value);
+
+/**
+ * Look up a comment value by tag.
+ * \param tc Tn initialized theora_comment structure
+ * \param tag The tag to look up
+ * \param count The instance of the tag. The same tag can appear multiple
+ *              times, each with a distinct and ordered value, so an index
+ *              is required to retrieve them all.
+ * \returns A pointer to the queried tag's value
+ * \retval NULL No matching tag is found
+ *
+ * \note Use theora_comment_query_count() to get the legal range for the
+ * count parameter.
+ **/
+
+extern char *theora_comment_query(theora_comment *tc, char *tag, int count);
+
+/** Look up the number of instances of a tag.
+ *  \param tc An initialized theora_comment structure
+ *  \param tag The tag to look up
+ *  \returns The number on instances of a particular tag.
+ * 
+ *  Call this first when querying for a specific tag and then interate
+ *  over the number of instances with separate calls to 
+ *  theora_comment_query() to retrieve all instances in order.
+ **/
+extern int   theora_comment_query_count(theora_comment *tc, char *tag);
+
+/**
+ * Clear an allocated theora_comment struct so that it can be freed.
+ * \param tc An allocated theora_comment structure.
+ **/
+extern void  theora_comment_clear(theora_comment *tc);
+
+/**Encoder control function.
+ * This is used to provide advanced control the encoding process.
+ * \param th     A #theora_state handle.
+ * \param req    The control code to process.
+ *                See \ref encctlcodes "the list of available control codes"
+ *                 for details.
+ * \param buf    The parameters for this control code.
+ * \param buf_sz The size of the parameter buffer.*/
+extern int theora_control(theora_state *th,int req,void *buf,size_t buf_sz);
+
+/* @} */ /* end oldfuncs doxygen group */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _O_THEORA_H_ */
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/include/theora/theoradec.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/include/theora/theoradec.h
new file mode 100644
index 0000000..dd72825
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/include/theora/theoradec.h
@@ -0,0 +1,311 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: theora.h,v 1.8 2004/03/15 22:17:32 derf Exp $
+
+ ********************************************************************/
+
+/**\file
+ * The <tt>libtheoradec</tt> C decoding API.*/
+
+#if !defined(_O_THEORA_THEORADEC_H_)
+# define _O_THEORA_THEORADEC_H_ (1)
+# include <stddef.h>
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+# include <vtkoggtheora/include/ogg/ogg.h>
+# include "codec.h"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+
+
+/**\name th_decode_ctl() codes
+ * \anchor decctlcodes
+ * These are the available request codes for th_decode_ctl().
+ * By convention, these are odd, to distinguish them from the
+ *  \ref encctlcodes "encoder control codes".
+ * Keep any experimental or vendor-specific values above \c 0x8000.*/
+/*@{*/
+/**Gets the maximum post-processing level.
+ *
+ * \param[out] _buf int: The maximum post-processing level.
+ * \retval TH_EFAULT  \a _dec_ctx or \a _buf is <tt>NULL</tt>.
+ * \retval TH_EINVAL  \a _buf_sz is not <tt>sizeof(int)</tt>.
+ * \retval TH_EIMPL   Not supported by this implementation.*/
+#define TH_DECCTL_GET_PPLEVEL_MAX (1)
+/**Sets the post-processing level.
+ * By default, post-processing is disabled.
+ *
+ * \param[in] _buf int: The new post-processing level.
+ *                      0 to disable; larger values use more CPU.
+ * \retval TH_EFAULT  \a _dec_ctx or \a _buf is <tt>NULL</tt>.
+ * \retval TH_EINVAL  \a _buf_sz is not <tt>sizeof(int)</tt>, or the
+ *                     post-processing level is out of bounds.
+ *                    The maximum post-processing level may be
+ *                     implementation-specific, and can be obtained via
+ *                     #TH_DECCTL_GET_PPLEVEL_MAX.
+ * \retval TH_EIMPL   Not supported by this implementation.*/
+#define TH_DECCTL_SET_PPLEVEL (3)
+/**Sets the granule position.
+ * Call this after a seek, before decoding the first frame, to ensure that the
+ *  proper granule position is returned for all subsequent frames.
+ * If you track timestamps yourself and do not use the granule position
+ *  returned by the decoder, then you need not call this function.
+ *
+ * \param[in] _buf <tt>ogg_int64_t</tt>: The granule position of the next
+ *                  frame.
+ * \retval TH_EFAULT  \a _dec_ctx or \a _buf is <tt>NULL</tt>.
+ * \retval TH_EINVAL  \a _buf_sz is not <tt>sizeof(ogg_int64_t)</tt>, or the
+ *                     granule position is negative.*/
+#define TH_DECCTL_SET_GRANPOS (5)
+/**Sets the striped decode callback function.
+ * If set, this function will be called as each piece of a frame is fully
+ *  decoded in th_decode_packetin().
+ * You can pass in a #th_stripe_callback with
+ *  th_stripe_callback#stripe_decoded set to <tt>NULL</tt> to disable the
+ *  callbacks at any point.
+ * Enabling striped decode does not prevent you from calling
+ *  th_decode_ycbcr_out() after the frame is fully decoded.
+ *
+ * \param[in]  _buf #th_stripe_callback: The callback parameters.
+ * \retval TH_EFAULT  \a _dec_ctx or \a _buf is <tt>NULL</tt>.
+ * \retval TH_EINVAL  \a _buf_sz is not
+ *                     <tt>sizeof(th_stripe_callback)</tt>.*/
+#define TH_DECCTL_SET_STRIPE_CB (7)
+/*@}*/
+
+#define TH_DECCTL_SET_TELEMETRY_MBMODE (9)
+#define TH_DECCTL_SET_TELEMETRY_MV (11)
+
+
+
+/**A callback function for striped decode.
+ * This is a function pointer to an application-provided function that will be
+ *  called each time a section of the image is fully decoded in
+ *  th_decode_packetin().
+ * This allows the application to process the section immediately, while it is
+ *  still in cache.
+ * Note that the frame is decoded bottom to top, so \a _yfrag0 will steadily
+ *  decrease with each call until it reaches 0, at which point the full frame
+ *  is decoded.
+ * The number of fragment rows made available in each call depends on the pixel
+ *  format and the number of post-processing filters enabled, and may not even
+ *  be constant for the entire frame.
+ * If a non-<tt>NULL</tt> \a _granpos pointer is passed to
+ *  th_decode_packetin(), the granule position for the frame will be stored
+ *  in it before the first callback is made.
+ * If an entire frame is dropped (a 0-byte packet), then no callbacks will be
+ *  made at all for that frame.
+ * \param _ctx       An application-provided context pointer.
+ * \param _buf       The image buffer for the decoded frame.
+ * \param _yfrag0    The Y coordinate of the first row of 8x8 fragments
+ *                    decoded.
+ *                   Multiply this by 8 to obtain the pixel row number in the
+ *                    luma plane.
+ *                   If the chroma planes are subsampled in the Y direction,
+ *                    this will always be divisible by two.
+ * \param _yfrag_end The Y coordinate of the first row of 8x8 fragments past
+ *                    the newly decoded section.
+ *                   If the chroma planes are subsampled in the Y direction,
+ *                    this will always be divisible by two.
+ *                   I.e., this section contains fragment rows
+ *                    <tt>\a _yfrag0 ...\a _yfrag_end -1</tt>.*/
+typedef void (*th_stripe_decoded_func)(void *_ctx,th_ycbcr_buffer _buf,
+ int _yfrag0,int _yfrag_end);
+
+/**The striped decode callback data to pass to #TH_DECCTL_SET_STRIPE_CB.*/
+typedef struct{
+  /**An application-provided context pointer.
+   * This will be passed back verbatim to the application.*/
+  void                   *ctx;
+  /**The callback function pointer.*/
+  th_stripe_decoded_func  stripe_decoded;
+}th_stripe_callback;
+
+
+
+/**\name Decoder state
+   The following data structures are opaque, and their contents are not
+    publicly defined by this API.
+   Referring to their internals directly is unsupported, and may break without
+    warning.*/
+/*@{*/
+/**The decoder context.*/
+typedef struct th_dec_ctx    th_dec_ctx;
+/**Setup information.
+   This contains auxiliary information (Huffman tables and quantization
+    parameters) decoded from the setup header by th_decode_headerin() to be
+    passed to th_decode_alloc().
+   It can be re-used to initialize any number of decoders, and can be freed
+    via th_setup_free() at any time.*/
+typedef struct th_setup_info th_setup_info;
+/*@}*/
+
+
+
+/**\defgroup decfuncs Functions for Decoding*/
+/*@{*/
+/**\name Functions for decoding
+ * You must link to <tt>libtheoradec</tt> if you use any of the 
+ * functions in this section.
+ *
+ * The functions are listed in the order they are used in a typical decode.
+ * The basic steps are:
+ * - Parse the header packets by repeatedly calling th_decode_headerin().
+ * - Allocate a #th_dec_ctx handle with th_decode_alloc().
+ * - Call th_setup_free() to free any memory used for codec setup
+ *    information.
+ * - Perform any additional decoder configuration with th_decode_ctl().
+ * - For each video data packet:
+ *   - Submit the packet to the decoder via th_decode_packetin().
+ *   - Retrieve the uncompressed video data via th_decode_ycbcr_out().
+ * - Call th_decode_free() to release all decoder memory.*/
+/*@{*/
+/**Decodes the header packets of a Theora stream.
+ * This should be called on the initial packets of the stream, in succession,
+ *  until it returns <tt>0</tt>, indicating that all headers have been
+ *  processed, or an error is encountered.
+ * At least three header packets are required, and additional optional header
+ *  packets may follow.
+ * This can be used on the first packet of any logical stream to determine if
+ *  that stream is a Theora stream.
+ * \param _info  A #th_info structure to fill in.
+ *               This must have been previously initialized with
+ *                th_info_init().
+ *               The application may immediately begin using the contents of
+ *                this structure after the first header is decoded, though it
+ *                must continue to be passed in on all subsequent calls.
+ * \param _tc    A #th_comment structure to fill in.
+ *               The application may immediately begin using the contents of
+ *                this structure after the second header is decoded, though it
+ *                must continue to be passed in on all subsequent calls.
+ * \param _setup Returns a pointer to additional, private setup information
+ *                needed by the decoder.
+ *               The contents of this pointer must be initialized to
+ *                <tt>NULL</tt> on the first call, and the returned value must
+ *                continue to be passed in on all subsequent calls.
+ * \param _op    An <tt>ogg_packet</tt> structure which contains one of the
+ *                initial packets of an Ogg logical stream.
+ * \return A positive value indicates that a Theora header was successfully
+ *          processed.
+ * \retval 0             The first video data packet was encountered after all
+ *                        required header packets were parsed.
+ *                       The packet just passed in on this call should be saved
+ *                        and fed to th_decode_packetin() to begin decoding
+ *                        video data.
+ * \retval TH_EFAULT     One of \a _info, \a _tc, or \a _setup was
+ *                        <tt>NULL</tt>.
+ * \retval TH_EBADHEADER \a _op was <tt>NULL</tt>, the packet was not the next
+ *                        header packet in the expected sequence, or the format
+ *                        of the header data was invalid.
+ * \retval TH_EVERSION   The packet data was a Theora info header, but for a
+ *                        bitstream version not decodable with this version of
+ *                        <tt>libtheoradec</tt>.
+ * \retval TH_ENOTFORMAT The packet was not a Theora header.
+ */
+extern int th_decode_headerin(th_info *_info,th_comment *_tc,
+ th_setup_info **_setup,ogg_packet *_op);
+/**Allocates a decoder instance.
+ *
+ * <b>Security Warning:</b> The Theora format supports very large frame sizes,
+ *  potentially even larger than the address space of a 32-bit machine, and
+ *  creating a decoder context allocates the space for several frames of data.
+ * If the allocation fails here, your program will crash, possibly at some
+ *  future point because the OS kernel returned a valid memory range and will
+ *  only fail when it tries to map the pages in it the first time they are
+ *  used.
+ * Even if it succeeds, you may experience a denial of service if the frame
+ *  size is large enough to cause excessive paging.
+ * If you are integrating libtheora in a larger application where such things
+ *  are undesirable, it is highly recommended that you check the frame size in
+ *  \a _info before calling this function and refuse to decode streams where it
+ *  is larger than some reasonable maximum.
+ * libtheora will not check this for you, because there may be machines that
+ *  can handle such streams and applications that wish to.
+ * \param _info  A #th_info struct filled via th_decode_headerin().
+ * \param _setup A #th_setup_info handle returned via
+ *                th_decode_headerin().
+ * \return The initialized #th_dec_ctx handle.
+ * \retval NULL If the decoding parameters were invalid.*/
+extern th_dec_ctx *th_decode_alloc(const th_info *_info,
+ const th_setup_info *_setup);
+/**Releases all storage used for the decoder setup information.
+ * This should be called after you no longer want to create any decoders for
+ *  a stream whose headers you have parsed with th_decode_headerin().
+ * \param _setup The setup information to free.
+ *               This can safely be <tt>NULL</tt>.*/
+extern void th_setup_free(th_setup_info *_setup);
+/**Decoder control function.
+ * This is used to provide advanced control of the decoding process.
+ * \param _dec    A #th_dec_ctx handle.
+ * \param _req    The control code to process.
+ *                See \ref decctlcodes "the list of available control codes"
+ *                 for details.
+ * \param _buf    The parameters for this control code.
+ * \param _buf_sz The size of the parameter buffer.*/
+extern int th_decode_ctl(th_dec_ctx *_dec,int _req,void *_buf,
+ size_t _buf_sz);
+/**Submits a packet containing encoded video data to the decoder.
+ * \param _dec     A #th_dec_ctx handle.
+ * \param _op      An <tt>ogg_packet</tt> containing encoded video data.
+ * \param _granpos Returns the granule position of the decoded packet.
+ *                 If non-<tt>NULL</tt>, the granule position for this specific
+ *                  packet is stored in this location.
+ *                 This is computed incrementally from previously decoded
+ *                  packets.
+ *                 After a seek, the correct granule position must be set via
+ *                  #TH_DECCTL_SET_GRANPOS for this to work properly.
+ * \retval 0             Success.
+ *                       A new decoded frame can be retrieved by calling
+ *                        th_decode_ycbcr_out().
+ * \retval TH_DUPFRAME   The packet represented a dropped (0-byte) frame.
+ *                       The player can skip the call to th_decode_ycbcr_out(),
+ *                        as the contents of the decoded frame buffer have not
+ *                        changed.
+ * \retval TH_EFAULT     \a _dec or \a _op was <tt>NULL</tt>.
+ * \retval TH_EBADPACKET \a _op does not contain encoded video data.
+ * \retval TH_EIMPL      The video data uses bitstream features which this
+ *                        library does not support.*/
+extern int th_decode_packetin(th_dec_ctx *_dec,const ogg_packet *_op,
+ ogg_int64_t *_granpos);
+/**Outputs the next available frame of decoded Y'CbCr data.
+ * If a striped decode callback has been set with #TH_DECCTL_SET_STRIPE_CB,
+ *  then the application does not need to call this function.
+ * \param _dec   A #th_dec_ctx handle.
+ * \param _ycbcr A video buffer structure to fill in.
+ *               <tt>libtheoradec</tt> will fill in all the members of this
+ *                structure, including the pointers to the uncompressed video
+ *                data.
+ *               The memory for this video data is owned by
+ *                <tt>libtheoradec</tt>.
+ *               It may be freed or overwritten without notification when
+ *                subsequent frames are decoded.
+ * \retval 0 Success
+ */
+extern int th_decode_ycbcr_out(th_dec_ctx *_dec,
+ th_ycbcr_buffer _ycbcr);
+/**Frees an allocated decoder instance.
+ * \param _dec A #th_dec_ctx handle.*/
+extern void th_decode_free(th_dec_ctx *_dec);
+/*@}*/
+/*@}*/
+
+
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/include/theora/theoraenc.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/include/theora/theoraenc.h
new file mode 100644
index 0000000..7518749
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/include/theora/theoraenc.h
@@ -0,0 +1,293 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2003                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: theora.h,v 1.8 2004/03/15 22:17:32 derf Exp $
+
+ ********************************************************************/
+
+/**\file
+ * The <tt>libtheoraenc</tt> C encoding API.*/
+
+#if !defined(_O_THEORA_THEORAENC_H_)
+# define _O_THEORA_THEORAENC_H_ (1)
+# include <stddef.h>
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+# include <vtkoggtheora/include/ogg/ogg.h>
+# include "codec.h"
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+
+
+
+/**\name th_encode_ctl() codes
+ * \anchor encctlcodes
+ * These are the available request codes for th_encode_ctl().
+ * By convention, these are even, to distinguish them from the
+ *  \ref decctlcodes "decoder control codes".
+ * Keep any experimental or vendor-specific values above \c 0x8000.*/
+/*@{*/
+/**Sets the Huffman tables to use.
+ * The tables are copied, not stored by reference, so they can be freed after
+ *  this call.
+ * <tt>NULL</tt> may be specified to revert to the default tables.
+ *
+ * \param[in] _buf <tt>#th_huff_code[#TH_NHUFFMAN_TABLES][#TH_NDCT_TOKENS]</tt>
+ * \retval TH_EFAULT \a _enc_ctx is <tt>NULL</tt>.
+ * \retval TH_EINVAL Encoding has already begun or one or more of the given
+ *                     tables is not full or prefix-free, \a _buf is
+ *                     <tt>NULL</tt> and \a _buf_sz is not zero, or \a _buf is
+ *                     non-<tt>NULL</tt> and \a _buf_sz is not
+ *                     <tt>sizeof(#th_huff_code)*#TH_NHUFFMAN_TABLES*#TH_NDCT_TOKENS</tt>.
+ * \retval TH_IMPL   Not supported by this implementation.*/
+#define TH_ENCCTL_SET_HUFFMAN_CODES (0)
+/**Sets the quantization parameters to use.
+ * The parameters are copied, not stored by reference, so they can be freed
+ *  after this call.
+ * <tt>NULL</tt> may be specified to revert to the default parameters.
+ * For the current encoder, <tt>scale[ci!=0][qi]</tt> must be no greater than
+ *  <tt>scale[ci!=0][qi-1]</tt> and <tt>base[qti][pli][qi][ci]</tt> must be no
+ *  greater than <tt>base[qti][pli][qi-1][ci]</tt>.
+ * These two conditions ensure that the actual quantizer for a given \a qti,
+ *  \a pli, and \a ci does not increase as \a qi increases.
+ *
+ * \param[in] _buf #th_quant_info
+ * \retval TH_EFAULT \a _enc_ctx is <tt>NULL</tt>.
+ * \retval TH_EINVAL Encoding has already begun, the quantization parameters
+ *                    do not meet one of the above stated conditions, \a _buf
+ *                    is <tt>NULL</tt> and \a _buf_sz is not zero, or \a _buf
+ *                    is non-<tt>NULL</tt> and \a _buf_sz is not
+ *                    <tt>sizeof(#th_quant_info)</tt>.
+ * \retval TH_IMPL   Not supported by this implementation.*/
+#define TH_ENCCTL_SET_QUANT_PARAMS (2)
+/**Sets the maximum distance between key frames.
+ * This can be changed during an encode, but will be bounded by
+ *  <tt>1<<th_info#keyframe_granule_shift</tt>.
+ * If it is set before encoding begins, th_info#keyframe_granule_shift will
+ *  be enlarged appropriately.
+ *
+ * \param[in]  _buf <tt>ogg_uint32_t</tt>: The maximum distance between key
+ *                   frames.
+ * \param[out] _buf <tt>ogg_uint32_t</tt>: The actual maximum distance set.
+ * \retval TH_EFAULT \a _enc_ctx or \a _buf is <tt>NULL</tt>.
+ * \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(ogg_uint32_t)</tt>.
+ * \retval TH_IMPL   Not supported by this implementation.*/
+#define TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE (4)
+/**Disables any encoder features that would prevent lossless transcoding back
+ *  to VP3.
+ * This primarily means disabling block-level QI values and not using 4MV mode
+ *  when any of the luma blocks in a macro block are not coded.
+ * It also includes using the VP3 quantization tables and Huffman codes; if you
+ *  set them explicitly after calling this function, the resulting stream will
+ *  not be VP3-compatible.
+ * If you enable VP3-compatibility when encoding 4:2:2 or 4:4:4 source
+ *  material, or when using a picture region smaller than the full frame (e.g.
+ *  a non-multiple-of-16 width or height), then non-VP3 bitstream features will
+ *  still be disabled, but the stream will still not be VP3-compatible, as VP3
+ *  was not capable of encoding such formats.
+ * If you call this after encoding has already begun, then the quantization
+ *  tables and codebooks cannot be changed, but the frame-level features will
+ *  be enabled or disabled as requested.
+ *
+ * \param[in]  _buf <tt>int</tt>: a non-zero value to enable VP3 compatibility,
+ *                   or 0 to disable it (the default).
+ * \param[out] _buf <tt>int</tt>: 1 if all bitstream features required for
+ *                   VP3-compatibility could be set, and 0 otherwise.
+ *                  The latter will be returned if the pixel format is not
+ *                   4:2:0, the picture region is smaller than the full frame,
+ *                   or if encoding has begun, preventing the quantization
+ *                   tables and codebooks from being set.
+ * \retval TH_EFAULT \a _enc_ctx or \a _buf is <tt>NULL</tt>.
+ * \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>.
+ * \retval TH_IMPL   Not supported by this implementation.*/
+#define TH_ENCCTL_SET_VP3_COMPATIBLE (10)
+/**Gets the maximum speed level.
+ * Higher speed levels favor quicker encoding over better quality per bit.
+ * Depending on the encoding mode, and the internal algorithms used, quality
+ *  may actually improve, but in this case bitrate will also likely increase.
+ * In any case, overall rate/distortion performance will probably decrease.
+ * The maximum value, and the meaning of each value, may change depending on
+ *  the current encoding mode (VBR vs. CQI, etc.).
+ *
+ * \param[out] _buf int: The maximum encoding speed level.
+ * \retval TH_EFAULT \a _enc_ctx or \a _buf is <tt>NULL</tt>.
+ * \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>.
+ * \retval TH_IMPL   Not supported by this implementation in the current
+ *                    encoding mode.*/
+#define TH_ENCCTL_GET_SPLEVEL_MAX (12)
+/**Sets the speed level.
+ * By default, the slowest speed (0) is used.
+ *
+ * \param[in] _buf int: The new encoding speed level.
+ *                      0 is slowest, larger values use less CPU.
+ * \retval TH_EFAULT \a _enc_ctx or \a _buf is <tt>NULL</tt>.
+ * \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>, or the
+ *                    encoding speed level is out of bounds.
+ *                   The maximum encoding speed level may be
+ *                    implementation- and encoding mode-specific, and can be
+ *                    obtained via #TH_ENCCTL_GET_SPLEVEL_MAX.
+ * \retval TH_IMPL   Not supported by this implementation in the current
+ *                    encoding mode.*/
+#define TH_ENCCTL_SET_SPLEVEL (14)
+/**Sets the number of duplicates of the next frame to produce.
+ * Although libtheora can encode duplicate frames very cheaply, it costs some
+ *  amount of CPU to detect them, and a run of duplicates cannot span a
+ *  keyframe boundary.
+ * This control code tells the encoder to produce the specified number of extra
+ *  duplicates of the next frame.
+ * This allows the encoder to make smarter keyframe placement decisions and
+ *  rate control decisions, as well as reduces CPU usage, when compared to just
+ *  submitting the same frame for encoding multiple times.
+ * This setting only applies to the next frame submitted for encoding.
+ * You MUST call th_encode_packetout() repeatedly until it returns 0, or the
+ *  extra duplicate frames will be lost.
+ *
+ * \param[in] _buf int: The number of duplicates to produce.
+ *                      Unless this is positive, no duplicates will be produced.
+ * \retval TH_EFAULT \a _enc_ctx or \a _buf is <tt>NULL</tt>.
+ * \retval TH_EINVAL \a _buf_sz is not <tt>sizeof(int)</tt>, or the
+ *                    number of duplicates is greater than or equal to the
+ *                    maximum keyframe interval.
+ *                   In the latter case, NO duplicate frames will be produced.
+ *                   You must ensure that the maximum keyframe interval is set
+ *                    larger than the maximum number of duplicates you will
+ *                    ever wish to insert prior to encoding.
+ * \retval TH_IMPL   Not supported by this implementation in the current
+ *                    encoding mode.*/
+#define TH_ENCCTL_SET_DUP_COUNT (18)
+/*@}*/
+
+
+
+/**The quantization parameters used by VP3.*/
+extern const th_quant_info TH_VP31_QUANT_INFO;
+
+/**The Huffman tables used by VP3.*/
+extern const th_huff_code
+ TH_VP31_HUFF_CODES[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS];
+
+
+
+/**\name Encoder state
+   The following data structure is opaque, and its contents are not publicly
+    defined by this API.
+   Referring to its internals directly is unsupported, and may break without
+    warning.*/
+/*@{*/
+/**The encoder context.*/
+typedef struct th_enc_ctx    th_enc_ctx;
+/*@}*/
+
+
+
+/**\defgroup encfuncs Functions for Encoding*/
+/*@{*/
+/**\name Functions for encoding
+ * You must link to <tt>libtheoraenc</tt> and <tt>libtheoradec</tt>
+ *  if you use any of the functions in this section.
+ *
+ * The functions are listed in the order they are used in a typical encode.
+ * The basic steps are:
+ * - Fill in a #th_info structure with details on the format of the video you
+ *    wish to encode.
+ * - Allocate a #th_enc_ctx handle with th_encode_alloc().
+ * - Perform any additional encoder configuration required with
+ *    th_encode_ctl().
+ * - Repeatedly call th_encode_flushheader() to retrieve all the header
+ *    packets.
+ * - For each uncompressed frame:
+ *   - Submit the uncompressed frame via th_encode_ycbcr_in()
+ *   - Repeatedly call th_encode_packetout() to retrieve any video data packets
+ *      that are ready.
+ * - Call th_encode_free() to release all encoder memory.*/
+/*@{*/
+/**Allocates an encoder instance.
+ * \param _info A #th_info struct filled with the desired encoding parameters.
+ * \return The initialized #th_enc_ctx handle.
+ * \retval NULL If the encoding parameters were invalid.*/
+extern th_enc_ctx *th_encode_alloc(const th_info *_info);
+/**Encoder control function.
+ * This is used to provide advanced control the encoding process.
+ * \param _enc    A #th_enc_ctx handle.
+ * \param _req    The control code to process.
+ *                See \ref encctlcodes "the list of available control codes"
+ *                 for details.
+ * \param _buf    The parameters for this control code.
+ * \param _buf_sz The size of the parameter buffer.*/
+extern int th_encode_ctl(th_enc_ctx *_enc,int _req,void *_buf,size_t _buf_sz);
+/**Outputs the next header packet.
+ * This should be called repeatedly after encoder initialization until it
+ *  returns 0 in order to get all of the header packets, in order, before
+ *  encoding actual video data.
+ * \param _enc      A #th_enc_ctx handle.
+ * \param _comments The metadata to place in the comment header, when it is
+ *                   encoded.
+ * \param _op       An <tt>ogg_packet</tt> structure to fill.
+ *                  All of the elements of this structure will be set,
+ *                   including a pointer to the header data.
+ *                  The memory for the header data is owned by
+ *                   <tt>libtheoraenc</tt>, and may be invalidated when the
+ *                   next encoder function is called.
+ * \return A positive value indicates that a header packet was successfully
+ *          produced.
+ * \retval 0         No packet was produced, and no more header packets remain.
+ * \retval TH_EFAULT \a _enc, \a _comments, or \a _op was <tt>NULL</tt>.*/
+extern int th_encode_flushheader(th_enc_ctx *_enc,
+ th_comment *_comments,ogg_packet *_op);
+/**Submits an uncompressed frame to the encoder.
+ * \param _enc   A #th_enc_ctx handle.
+ * \param _ycbcr A buffer of Y'CbCr data to encode.
+ * \retval 0         Success.
+ * \retval TH_EFAULT \a _enc or \a _ycbcr is <tt>NULL</tt>.
+ * \retval TH_EINVAL The buffer size does not match the frame size the encoder
+ *                    was initialized with, or encoding has already
+ *                    completed.*/
+extern int th_encode_ycbcr_in(th_enc_ctx *_enc,th_ycbcr_buffer _ycbcr);
+/**Retrieves encoded video data packets.
+ * This should be called repeatedly after each frame is submitted to flush any
+ *  encoded packets, until it returns 0.
+ * The encoder will not buffer these packets as subsequent frames are
+ *  compressed, so a failure to do so will result in lost video data.
+ * \note Currently the encoder operates in a one-frame-in, one-packet-out
+ *        manner.
+ *       However, this may be changed in the future.
+ * \param _enc  A #th_enc_ctx handle.
+ * \param _last Set this flag to a non-zero value if no more uncompressed
+ *               frames will be submitted.
+ *              This ensures that a proper EOS flag is set on the last packet.
+ * \param _op   An <tt>ogg_packet</tt> structure to fill.
+ *              All of the elements of this structure will be set, including a
+ *               pointer to the video data.
+ *              The memory for the video data is owned by
+ *               <tt>libtheoraenc</tt>, and may be invalidated when the next
+ *               encoder function is called.
+ * \return A positive value indicates that a video data packet was successfully
+ *          produced.
+ * \retval 0         No packet was produced, and no more encoded video data
+ *                    remains.
+ * \retval TH_EFAULT \a _enc or \a _op was <tt>NULL</tt>.*/
+extern int th_encode_packetout(th_enc_ctx *_enc,int _last,ogg_packet *_op);
+/**Frees an allocated encoder instance.
+ * \param _enc A #th_enc_ctx handle.*/
+extern void th_encode_free(th_enc_ctx *_enc);
+/*@}*/
+/*@}*/
+
+
+
+#if defined(__cplusplus)
+}
+#endif
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/cpu.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/cpu.c
new file mode 100644
index 0000000..55b6073
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/cpu.c
@@ -0,0 +1,226 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2008                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+ CPU capability detection for x86 processors.
+  Originally written by Rudolf Marek.
+
+ function:
+  last mod: $Id: cpu.c 15953 2009-04-26 14:30:15Z tterribe $
+
+ ********************************************************************/
+
+#include "cpu.h"
+
+#if !defined(OC_X86_ASM)
+static ogg_uint32_t oc_cpu_flags_get(void){
+  return 0;
+}
+#else
+# if !defined(_MSC_VER)
+#  if defined(__amd64__)||defined(__x86_64__)
+/*On x86-64, gcc seems to be able to figure out how to save %rbx for us when
+   compiling with -fPIC.*/
+#   define cpuid(_op,_eax,_ebx,_ecx,_edx) \
+  __asm__ __volatile__( \
+   "cpuid\n\t" \
+   :[eax]"=a"(_eax),[ebx]"=b"(_ebx),[ecx]"=c"(_ecx),[edx]"=d"(_edx) \
+   :"a"(_op) \
+   :"cc" \
+  )
+#  else
+/*On x86-32, not so much.*/
+#   define cpuid(_op,_eax,_ebx,_ecx,_edx) \
+  __asm__ __volatile__( \
+   "xchgl %%ebx,%[ebx]\n\t" \
+   "cpuid\n\t" \
+   "xchgl %%ebx,%[ebx]\n\t" \
+   :[eax]"=a"(_eax),[ebx]"=r"(_ebx),[ecx]"=c"(_ecx),[edx]"=d"(_edx) \
+   :"a"(_op) \
+   :"cc" \
+  )
+#  endif
+# else
+/*Why does MSVC need this complicated rigamarole?
+  At this point I honestly do not care.*/
+
+/*Visual C cpuid helper function.
+  For VS2005 we could as well use the _cpuid builtin, but that wouldn't work
+   for VS2003 users, so we do it in inline assembler.*/
+static void oc_cpuid_helper(ogg_uint32_t _cpu_info[4],ogg_uint32_t _op){
+  _asm{
+    mov eax,[_op]
+    mov esi,_cpu_info
+    cpuid
+    mov [esi+0],eax
+    mov [esi+4],ebx
+    mov [esi+8],ecx
+    mov [esi+12],edx
+  }
+}
+
+#  define cpuid(_op,_eax,_ebx,_ecx,_edx) \
+  do{ \
+    ogg_uint32_t cpu_info[4]; \
+    oc_cpuid_helper(cpu_info,_op); \
+    (_eax)=cpu_info[0]; \
+    (_ebx)=cpu_info[1]; \
+    (_ecx)=cpu_info[2]; \
+    (_edx)=cpu_info[3]; \
+  }while(0)
+
+static void oc_detect_cpuid_helper(ogg_uint32_t *_eax,ogg_uint32_t *_ebx){
+  _asm{
+    pushfd
+    pushfd
+    pop eax
+    mov ebx,eax
+    xor eax,200000h
+    push eax
+    popfd
+    pushfd
+    pop eax
+    popfd
+    mov ecx,_eax
+    mov [ecx],eax
+    mov ecx,_ebx
+    mov [ecx],ebx
+  }
+}
+# endif
+
+static ogg_uint32_t oc_parse_intel_flags(ogg_uint32_t _edx,ogg_uint32_t _ecx){
+  ogg_uint32_t flags;
+  /*If there isn't even MMX, give up.*/
+  if(!(_edx&0x00800000))return 0;
+  flags=OC_CPU_X86_MMX;
+  if(_edx&0x02000000)flags|=OC_CPU_X86_MMXEXT|OC_CPU_X86_SSE;
+  if(_edx&0x04000000)flags|=OC_CPU_X86_SSE2;
+  if(_ecx&0x00000001)flags|=OC_CPU_X86_PNI;
+  if(_ecx&0x00000100)flags|=OC_CPU_X86_SSSE3;
+  if(_ecx&0x00080000)flags|=OC_CPU_X86_SSE4_1;
+  if(_ecx&0x00100000)flags|=OC_CPU_X86_SSE4_2;
+  return flags;
+}
+
+static ogg_uint32_t oc_parse_amd_flags(ogg_uint32_t _edx,ogg_uint32_t _ecx){
+  ogg_uint32_t flags;
+  /*If there isn't even MMX, give up.*/
+  if(!(_edx&0x00800000))return 0;
+  flags=OC_CPU_X86_MMX;
+  if(_edx&0x00400000)flags|=OC_CPU_X86_MMXEXT;
+  if(_edx&0x80000000)flags|=OC_CPU_X86_3DNOW;
+  if(_edx&0x40000000)flags|=OC_CPU_X86_3DNOWEXT;
+  if(_ecx&0x00000040)flags|=OC_CPU_X86_SSE4A;
+  if(_ecx&0x00000800)flags|=OC_CPU_X86_SSE5;
+  return flags;
+}
+
+static ogg_uint32_t oc_cpu_flags_get(void){
+  ogg_uint32_t flags;
+  ogg_uint32_t eax;
+  ogg_uint32_t ebx;
+  ogg_uint32_t ecx;
+  ogg_uint32_t edx;
+# if !defined(__amd64__)&&!defined(__x86_64__)
+  /*Not all x86-32 chips support cpuid, so we have to check.*/
+#  if !defined(_MSC_VER)
+  __asm__ __volatile__(
+   "pushfl\n\t"
+   "pushfl\n\t"
+   "popl %[a]\n\t"
+   "movl %[a],%[b]\n\t"
+   "xorl $0x200000,%[a]\n\t"
+   "pushl %[a]\n\t"
+   "popfl\n\t"
+   "pushfl\n\t"
+   "popl %[a]\n\t"
+   "popfl\n\t"
+   :[a]"=r"(eax),[b]"=r"(ebx)
+   :
+   :"cc"
+  );
+#  else
+  oc_detect_cpuid_helper(&eax,&ebx);
+#  endif
+  /*No cpuid.*/
+  if(eax==ebx)return 0;
+# endif
+  cpuid(0,eax,ebx,ecx,edx);
+  /*         l e t n          I e n i          u n e G*/
+  if(ecx==0x6C65746E&&edx==0x49656E69&&ebx==0x756E6547||
+   /*      6 8 x M          T e n i          u n e G*/
+   ecx==0x3638784D&&edx==0x54656E69&&ebx==0x756E6547){
+    /*Intel, Transmeta (tested with Crusoe TM5800):*/
+    cpuid(1,eax,ebx,ecx,edx);
+    flags=oc_parse_intel_flags(edx,ecx);
+  }
+  /*              D M A c          i t n e          h t u A*/
+  else if(ecx==0x444D4163&&edx==0x69746E65&&ebx==0x68747541||
+   /*      C S N            y b   e          d o e G*/
+   ecx==0x43534e20&&edx==0x79622065&&ebx==0x646f6547){
+    /*AMD, Geode:*/
+    cpuid(0x80000000,eax,ebx,ecx,edx);
+    if(eax<0x80000001)flags=0;
+    else{
+      cpuid(0x80000001,eax,ebx,ecx,edx);
+      flags=oc_parse_amd_flags(edx,ecx);
+    }
+    /*Also check for SSE.*/
+    cpuid(1,eax,ebx,ecx,edx);
+    flags|=oc_parse_intel_flags(edx,ecx);
+  }
+  /*Technically some VIA chips can be configured in the BIOS to return any
+     string here the user wants.
+    There is a special detection method that can be used to identify such
+     processors, but in my opinion, if the user really wants to change it, they
+     deserve what they get.*/
+  /*              s l u a          H r u a          t n e C*/
+  else if(ecx==0x736C7561&&edx==0x48727561&&ebx==0x746E6543){
+    /*VIA:*/
+    /*I only have documentation for the C7 (Esther) and Isaiah (forthcoming)
+       chips (thanks to the engineers from Centaur Technology who provided it).
+      These chips support Intel-like cpuid info.
+      The C3-2 (Nehemiah) cores appear to, as well.*/
+    cpuid(1,eax,ebx,ecx,edx);
+    flags=oc_parse_intel_flags(edx,ecx);
+    if(eax>=0x80000001){
+      /*The (non-Nehemiah) C3 processors support AMD-like cpuid info.
+        We need to check this even if the Intel test succeeds to pick up 3DNow!
+         support on these processors.
+        Unlike actual AMD processors, we cannot _rely_ on this info, since
+         some cores (e.g., the 693 stepping of the Nehemiah) claim to support
+         this function, yet return edx=0, despite the Intel test indicating
+         MMX support.
+        Therefore the features detected here are strictly added to those
+         detected by the Intel test.*/
+      /*TODO: How about earlier chips?*/
+      cpuid(0x80000001,eax,ebx,ecx,edx);
+      /*Note: As of the C7, this function returns Intel-style extended feature
+         flags, not AMD-style.
+        Currently, this only defines bits 11, 20, and 29 (0x20100800), which
+         do not conflict with any of the AMD flags we inspect.
+        For the remaining bits, Intel tells us, "Do not count on their value",
+         but VIA assures us that they will all be zero (at least on the C7 and
+         Isaiah chips).
+        In the (unlikely) event a future processor uses bits 18, 19, 30, or 31
+         (0xC0C00000) for something else, we will have to add code to detect
+         the model to decide when it is appropriate to inspect them.*/
+      flags|=oc_parse_amd_flags(edx,ecx);
+    }
+  }
+  else{
+    /*Implement me.*/
+    flags=0;
+  }
+  return flags;
+}
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/cpu.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/cpu.h
new file mode 100644
index 0000000..1d2b22e
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/cpu.h
@@ -0,0 +1,34 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+ function:
+    last mod: $Id: cpu.h 15675 2009-02-06 09:43:27Z tterribe $
+
+ ********************************************************************/
+
+#if !defined(_x86_cpu_H)
+# define _x86_cpu_H (1)
+#include "internal.h"
+
+#define OC_CPU_X86_MMX      (1<<0)
+#define OC_CPU_X86_3DNOW    (1<<1)
+#define OC_CPU_X86_3DNOWEXT (1<<2)
+#define OC_CPU_X86_MMXEXT   (1<<3)
+#define OC_CPU_X86_SSE      (1<<4)
+#define OC_CPU_X86_SSE2     (1<<5)
+#define OC_CPU_X86_PNI      (1<<6)
+#define OC_CPU_X86_SSSE3    (1<<7)
+#define OC_CPU_X86_SSE4_1   (1<<8)
+#define OC_CPU_X86_SSE4_2   (1<<9)
+#define OC_CPU_X86_SSE4A    (1<<10)
+#define OC_CPU_X86_SSE5     (1<<11)
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/apiwrapper.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/apiwrapper.c
new file mode 100644
index 0000000..a9c3a82
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/apiwrapper.c
@@ -0,0 +1,166 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: apiwrapper.c 15953 2009-04-26 14:30:15Z tterribe $
+
+ ********************************************************************/
+
+#include <stdlib.h>
+#include <string.h>
+#include <limits.h>
+#include "apiwrapper.h"
+
+
+
+const char *theora_version_string(void){
+  return th_version_string();
+}
+
+ogg_uint32_t theora_version_number(void){
+  return th_version_number();
+}
+
+void theora_info_init(theora_info *_ci){
+  memset(_ci,0,sizeof(*_ci));
+}
+
+void theora_info_clear(theora_info *_ci){
+  th_api_wrapper *api;
+  api=(th_api_wrapper *)_ci->codec_setup;
+  memset(_ci,0,sizeof(*_ci));
+  if(api!=NULL){
+    if(api->clear!=NULL)(*api->clear)(api);
+    _ogg_free(api);
+  }
+}
+
+void theora_clear(theora_state *_th){
+  /*Provide compatibility with mixed encoder and decoder shared lib versions.*/
+  if(_th->internal_decode!=NULL){
+    (*((oc_state_dispatch_vtable *)_th->internal_decode)->clear)(_th);
+  }
+  if(_th->internal_encode!=NULL){
+    (*((oc_state_dispatch_vtable *)_th->internal_encode)->clear)(_th);
+  }
+  if(_th->i!=NULL)theora_info_clear(_th->i);
+  memset(_th,0,sizeof(*_th));
+}
+
+int theora_control(theora_state *_th,int _req,void *_buf,size_t _buf_sz){
+  /*Provide compatibility with mixed encoder and decoder shared lib versions.*/
+  if(_th->internal_decode!=NULL){
+    return (*((oc_state_dispatch_vtable *)_th->internal_decode)->control)(_th,
+     _req,_buf,_buf_sz);
+  }
+  else if(_th->internal_encode!=NULL){
+    return (*((oc_state_dispatch_vtable *)_th->internal_encode)->control)(_th,
+     _req,_buf,_buf_sz);
+  }
+  else return TH_EINVAL;
+}
+
+ogg_int64_t theora_granule_frame(theora_state *_th,ogg_int64_t _gp){
+  /*Provide compatibility with mixed encoder and decoder shared lib versions.*/
+  if(_th->internal_decode!=NULL){
+    return (*((oc_state_dispatch_vtable *)_th->internal_decode)->granule_frame)(
+     _th,_gp);
+  }
+  else if(_th->internal_encode!=NULL){
+    return (*((oc_state_dispatch_vtable *)_th->internal_encode)->granule_frame)(
+     _th,_gp);
+  }
+  else return -1;
+}
+
+double theora_granule_time(theora_state *_th, ogg_int64_t _gp){
+  /*Provide compatibility with mixed encoder and decoder shared lib versions.*/
+  if(_th->internal_decode!=NULL){
+    return (*((oc_state_dispatch_vtable *)_th->internal_decode)->granule_time)(
+     _th,_gp);
+  }
+  else if(_th->internal_encode!=NULL){
+    return (*((oc_state_dispatch_vtable *)_th->internal_encode)->granule_time)(
+     _th,_gp);
+  }
+  else return -1;
+}
+
+void oc_theora_info2th_info(th_info *_info,const theora_info *_ci){
+  _info->version_major=_ci->version_major;
+  _info->version_minor=_ci->version_minor;
+  _info->version_subminor=_ci->version_subminor;
+  _info->frame_width=_ci->width;
+  _info->frame_height=_ci->height;
+  _info->pic_width=_ci->frame_width;
+  _info->pic_height=_ci->frame_height;
+  _info->pic_x=_ci->offset_x;
+  _info->pic_y=_ci->offset_y;
+  _info->fps_numerator=_ci->fps_numerator;
+  _info->fps_denominator=_ci->fps_denominator;
+  _info->aspect_numerator=_ci->aspect_numerator;
+  _info->aspect_denominator=_ci->aspect_denominator;
+  switch(_ci->colorspace){
+    case OC_CS_ITU_REC_470M:_info->colorspace=TH_CS_ITU_REC_470M;break;
+    case OC_CS_ITU_REC_470BG:_info->colorspace=TH_CS_ITU_REC_470BG;break;
+    default:_info->colorspace=TH_CS_UNSPECIFIED;break;
+  }
+  switch(_ci->pixelformat){
+    case OC_PF_420:_info->pixel_fmt=TH_PF_420;break;
+    case OC_PF_422:_info->pixel_fmt=TH_PF_422;break;
+    case OC_PF_444:_info->pixel_fmt=TH_PF_444;break;
+    default:_info->pixel_fmt=TH_PF_RSVD;
+  }
+  _info->target_bitrate=_ci->target_bitrate;
+  _info->quality=_ci->quality;
+  _info->keyframe_granule_shift=_ci->keyframe_frequency_force>0?
+   OC_MINI(31,oc_ilog(_ci->keyframe_frequency_force-1)):0;
+}
+
+int theora_packet_isheader(ogg_packet *_op){
+  return th_packet_isheader(_op);
+}
+
+int theora_packet_iskeyframe(ogg_packet *_op){
+  return th_packet_iskeyframe(_op);
+}
+
+int theora_granule_shift(theora_info *_ci){
+  /*This breaks when keyframe_frequency_force is not positive or is larger than
+     2**31 (if your int is more than 32 bits), but that's what the original
+     function does.*/
+  return oc_ilog(_ci->keyframe_frequency_force-1);
+}
+
+void theora_comment_init(theora_comment *_tc){
+  th_comment_init((th_comment *)_tc);
+}
+
+char *theora_comment_query(theora_comment *_tc,char *_tag,int _count){
+  return th_comment_query((th_comment *)_tc,_tag,_count);
+}
+
+int theora_comment_query_count(theora_comment *_tc,char *_tag){
+  return th_comment_query_count((th_comment *)_tc,_tag);
+}
+
+void theora_comment_clear(theora_comment *_tc){
+  th_comment_clear((th_comment *)_tc);
+}
+
+void theora_comment_add(theora_comment *_tc,char *_comment){
+  th_comment_add((th_comment *)_tc,_comment);
+}
+
+void theora_comment_add_tag(theora_comment *_tc, char *_tag, char *_value){
+  th_comment_add_tag((th_comment *)_tc,_tag,_value);
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/apiwrapper.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/apiwrapper.h
new file mode 100644
index 0000000..54ccfde
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/apiwrapper.h
@@ -0,0 +1,56 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: apiwrapper.h 13596 2007-08-23 20:05:38Z tterribe $
+
+ ********************************************************************/
+
+#if !defined(_apiwrapper_H)
+# define _apiwrapper_H (1)
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+# include <vtkoggtheora/include/ogg/ogg.h>
+# include <vtkoggtheora/include/theora/theora.h>
+# include "vtkoggtheora/include/theora/theoradec.h"
+/*# include "theora/theoraenc.h"*/
+typedef struct th_enc_ctx th_enc_ctx;
+# include "../internal.h"
+
+typedef struct th_api_wrapper th_api_wrapper;
+typedef struct th_api_info    th_api_info;
+
+/*Provide an entry point for the codec setup to clear itself in case we ever
+   want to break pieces off into a common base library shared by encoder and
+   decoder.
+  In addition, this makes several other pieces of the API wrapper cleaner.*/
+typedef void (*oc_setup_clear_func)(void *_ts);
+
+/*Generally only one of these pointers will be non-NULL in any given instance.
+  Technically we do not even really need this struct, since we should be able
+   to figure out which one from "context", but doing it this way makes sure we
+   don't flub it up.*/
+struct th_api_wrapper{
+  oc_setup_clear_func  clear;
+  th_setup_info       *setup;
+  th_dec_ctx          *decode;
+  th_enc_ctx          *encode;
+};
+
+struct th_api_info{
+  th_api_wrapper api;
+  theora_info    info;
+};
+
+
+void oc_theora_info2th_info(th_info *_info,const theora_info *_ci);
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/bitpack.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/bitpack.h
new file mode 100644
index 0000000..7ec5f13
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/bitpack.h
@@ -0,0 +1,39 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE OggTheora SOURCE CODE IS (C) COPYRIGHT 1994-2008             *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function: packing variable sized words into an octet stream
+  last mod: $Id: bitwise.c 7675 2004-09-01 00:34:39Z xiphmont $
+
+ ********************************************************************/
+#if !defined(_bitpack_H)
+# define _bitpack_H (1)
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+# include <vtkoggtheora/include/ogg/ogg.h>
+
+void theorapackB_readinit(oggpack_buffer *_b,unsigned char *_buf,int _bytes);
+int theorapackB_look1(oggpack_buffer *_b,long *_ret);
+void theorapackB_adv1(oggpack_buffer *_b);
+/*Here we assume 0<=_bits&&_bits<=32.*/
+int theorapackB_read(oggpack_buffer *_b,int _bits,long *_ret);
+int theorapackB_read1(oggpack_buffer *_b,long *_ret);
+long theorapackB_bytes(oggpack_buffer *_b);
+long theorapackB_bits(oggpack_buffer *_b);
+unsigned char *theorapackB_get_buffer(oggpack_buffer *_b);
+
+/*These two functions are implemented locally in huffdec.c*/
+/*Read in bits without advancing the bitptr.
+  Here we assume 0<=_bits&&_bits<=32.*/
+/*static int theorapackB_look(oggpack_buffer *_b,int _bits,long *_ret);*/
+/*static void theorapackB_adv(oggpack_buffer *_b,int _bits);*/
+
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/dct.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/dct.h
new file mode 100644
index 0000000..cf4abfa
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/dct.h
@@ -0,0 +1,31 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: dct.h 15675 2009-02-06 09:43:27Z tterribe $
+
+ ********************************************************************/
+
+/*Definitions shared by the forward and inverse DCT transforms.*/
+#if !defined(_dct_H)
+# define _dct_H (1)
+
+/*cos(n*pi/16) (resp. sin(m*pi/16)) scaled by 65536.*/
+#define OC_C1S7 ((ogg_int32_t)64277)
+#define OC_C2S6 ((ogg_int32_t)60547)
+#define OC_C3S5 ((ogg_int32_t)54491)
+#define OC_C4S4 ((ogg_int32_t)46341)
+#define OC_C5S3 ((ogg_int32_t)36410)
+#define OC_C6S2 ((ogg_int32_t)25080)
+#define OC_C7S1 ((ogg_int32_t)12785)
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/decint.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/decint.h
new file mode 100644
index 0000000..6cdf545
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/decint.h
@@ -0,0 +1,100 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: decint.h 15977 2009-05-02 17:49:35Z tterribe $
+
+ ********************************************************************/
+
+#include <limits.h>
+#if !defined(_decint_H)
+# define _decint_H (1)
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+# include "vtkoggtheora/include/theora/theoradec.h"
+# include "../internal.h"
+# include "bitpack.h"
+
+typedef struct th_setup_info oc_setup_info;
+typedef struct th_dec_ctx    oc_dec_ctx;
+
+# include "huffdec.h"
+# include "dequant.h"
+
+/*Constants for the packet-in state machine specific to the decoder.*/
+
+/*Next packet to read: Data packet.*/
+#define OC_PACKET_DATA (0)
+
+
+
+struct th_setup_info{
+  /*The Huffman codes.*/
+  oc_huff_node      *huff_tables[TH_NHUFFMAN_TABLES];
+  /*The quantization parameters.*/
+  th_quant_info  qinfo;
+};
+
+
+
+struct th_dec_ctx{
+  /*Shared encoder/decoder state.*/
+  oc_theora_state      state;
+  /*Whether or not packets are ready to be emitted.
+    This takes on negative values while there are remaining header packets to
+     be emitted, reaches 0 when the codec is ready for input, and goes to 1
+     when a frame has been processed and a data packet is ready.*/
+  int                  packet_state;
+  /*Buffer in which to assemble packets.*/
+  oggpack_buffer       opb;
+  /*Huffman decode trees.*/
+  oc_huff_node        *huff_tables[TH_NHUFFMAN_TABLES];
+  /*The index of one past the last token in each plane for each coefficient.
+    The final entries are the total number of tokens for each coefficient.*/
+  ptrdiff_t            ti0[3][64];
+  /*The index of one past the last extra bits entry in each plane for each
+     coefficient.
+    The final entries are the total number of extra bits entries for each
+     coefficient.*/
+  ptrdiff_t            ebi0[3][64];
+  /*The number of outstanding EOB runs at the start of each coefficient in each
+     plane.*/
+  ptrdiff_t            eob_runs[3][64];
+  /*The DCT token lists.*/
+  unsigned char      **dct_tokens;
+  /*The extra bits associated with DCT tokens.*/
+  ogg_uint16_t       **extra_bits;
+  /*The out-of-loop post-processing level.*/
+  int                  pp_level;
+  /*The DC scale used for out-of-loop deblocking.*/
+  int                  pp_dc_scale[64];
+  /*The sharpen modifier used for out-of-loop deringing.*/
+  int                  pp_sharp_mod[64];
+  /*The DC quantization index of each block.*/
+  unsigned char       *dc_qis;
+  /*The variance of each block.*/
+  int                 *variances;
+  /*The storage for the post-processed frame buffer.*/
+  unsigned char       *pp_frame_data;
+  /*Whether or not the post-processsed frame buffer has space for chroma.*/
+  int                  pp_frame_has_chroma;
+  /*The buffer used for the post-processed frame.*/
+  th_ycbcr_buffer      pp_frame_buf;
+  /*The striped decode callback function.*/
+  th_stripe_callback   stripe_cb;
+  /*Output metrics for debugging.*/
+  int                  telemetry;
+  int                  telemetry_mbmode;
+  int                  telemetry_mv;
+  unsigned char       *telemetry_frame_data;
+};
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/dequant.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/dequant.h
new file mode 100644
index 0000000..7ac3ef7
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/dequant.h
@@ -0,0 +1,26 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: dequant.h 15675 2009-02-06 09:43:27Z tterribe $
+
+ ********************************************************************/
+
+#if !defined(_dequant_H)
+# define _dequant_H (1)
+# include "quant.h"
+
+int oc_quant_params_unpack(oggpack_buffer *_opb,
+ th_quant_info *_qinfo);
+void oc_quant_params_clear(th_quant_info *_qinfo);
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/fragment.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/fragment.c
new file mode 100644
index 0000000..b2b18bf
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/fragment.c
@@ -0,0 +1,205 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: fragment.c 15977 2009-05-02 17:49:35Z tterribe $
+
+ ********************************************************************/
+#include <string.h>
+#include "../internal.h"
+
+void oc_frag_copy(const oc_theora_state *_state,unsigned char *_dst,
+ const unsigned char *_src,int _ystride){
+  (*_state->opt_vtable.frag_copy)(_dst,_src,_ystride);
+}
+
+void oc_frag_copy_c(unsigned char *_dst,const unsigned char *_src,int _ystride){
+  int i;
+  for(i=8;i-->0;){
+    memcpy(_dst,_src,8*sizeof(*_dst));
+    _dst+=_ystride;
+    _src+=_ystride;
+  }
+}
+
+void oc_frag_recon_intra(const oc_theora_state *_state,unsigned char *_dst,
+ int _ystride,const ogg_int16_t _residue[64]){
+  _state->opt_vtable.frag_recon_intra(_dst,_ystride,_residue);
+}
+
+void oc_frag_recon_intra_c(unsigned char *_dst,int _ystride,
+ const ogg_int16_t _residue[64]){
+  int i;
+  for(i=0;i<8;i++){
+    int j;
+    for(j=0;j<8;j++)_dst[j]=OC_CLAMP255(_residue[i*8+j]+128);
+    _dst+=_ystride;
+  }
+}
+
+void oc_frag_recon_inter(const oc_theora_state *_state,unsigned char *_dst,
+ const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]){
+  _state->opt_vtable.frag_recon_inter(_dst,_src,_ystride,_residue);
+}
+
+void oc_frag_recon_inter_c(unsigned char *_dst,
+ const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]){
+  int i;
+  for(i=0;i<8;i++){
+    int j;
+    for(j=0;j<8;j++)_dst[j]=OC_CLAMP255(_residue[i*8+j]+_src[j]);
+    _dst+=_ystride;
+    _src+=_ystride;
+  }
+}
+
+void oc_frag_recon_inter2(const oc_theora_state *_state,unsigned char *_dst,
+ const unsigned char *_src1,const unsigned char *_src2,int _ystride,
+ const ogg_int16_t _residue[64]){
+  _state->opt_vtable.frag_recon_inter2(_dst,_src1,_src2,_ystride,_residue);
+}
+
+void oc_frag_recon_inter2_c(unsigned char *_dst,const unsigned char *_src1,
+ const unsigned char *_src2,int _ystride,const ogg_int16_t _residue[64]){
+  int i;
+  for(i=0;i<8;i++){
+    int j;
+    for(j=0;j<8;j++)_dst[j]=OC_CLAMP255(_residue[i*8+j]+(_src1[j]+_src2[j]>>1));
+    _dst+=_ystride;
+    _src1+=_ystride;
+    _src2+=_ystride;
+  }
+}
+
+void oc_restore_fpu(const oc_theora_state *_state){
+  _state->opt_vtable.restore_fpu();
+}
+
+void oc_restore_fpu_c(void){}
+
+
+/*Computes the predicted DC value for the given fragment.
+  This requires that the fully decoded DC values be available for the left,
+   upper-left, upper, and upper-right fragments (if they exist).
+  _frag:      The fragment to predict the DC value for.
+  _fplane:    The fragment plane the fragment belongs to.
+  _x:         The x-coordinate of the fragment.
+  _y:         The y-coordinate of the fragment.
+  _pred_last: The last fully-decoded DC value for each predictor frame
+               (OC_FRAME_GOLD, OC_FRAME_PREV and OC_FRAME_SELF).
+              This should be initialized to 0's for the first fragment in each
+               color plane.
+  Return: The predicted DC value for this fragment.*/
+int oc_frag_pred_dc(const oc_fragment *_frag,
+ const oc_fragment_plane *_fplane,int _x,int _y,int _pred_last[3]){
+  static const signed char   PRED_SCALE[16][4]={
+    /*0*/
+    {0,0,0,0},
+    /*OC_PL*/
+    {1,0,0,0},
+    /*OC_PUL*/
+    {1,0,0,0},
+    /*OC_PL|OC_PUL*/
+    {1,0,0,0},
+    /*OC_PU*/
+    {1,0,0,0},
+    /*OC_PL|OC_PU*/
+    {1,1,0,0},
+    /*OC_PUL|OC_PU*/
+    {0,1,0,0},
+    /*OC_PL|OC_PUL|PC_PU*/
+    {29,-26,29,0},
+    /*OC_PUR*/
+    {1,0,0,0},
+    /*OC_PL|OC_PUR*/
+    {75,53,0,0},
+    /*OC_PUL|OC_PUR*/
+    {1,1,0,0},
+    /*OC_PL|OC_PUL|OC_PUR*/
+    {75,0,53,0},
+    /*OC_PU|OC_PUR*/
+    {1,0,0,0},
+    /*OC_PL|OC_PU|OC_PUR*/
+    {75,0,53,0},
+    /*OC_PUL|OC_PU|OC_PUR*/
+    {3,10,3,0},
+    /*OC_PL|OC_PUL|OC_PU|OC_PUR*/
+    {29,-26,29,0}
+  };
+  static const unsigned char PRED_SHIFT[16]={0,0,0,0,0,1,0,5,0,7,1,7,0,7,4,5};
+  static const unsigned char PRED_RMASK[16]={
+    0,0,0,0,0,1,0,31,0,127,1,127,0,127,15,31
+  };
+  static const unsigned char BC_MASK[8]={
+    /*No boundary condition.*/
+    OC_PL|OC_PUL|OC_PU|OC_PUR,
+    /*Left column.*/
+    OC_PU|OC_PUR,
+    /*Top row.*/
+    OC_PL,
+    /*Top row, left column.*/
+    0,
+    /*Right column.*/
+    OC_PL|OC_PUL|OC_PU,
+    /*Right and left column.*/
+    OC_PU,
+    /*Top row, right column.*/
+    OC_PL,
+    /*Top row, right and left column.*/
+    0
+  };
+  /*Predictor fragments, left, up-left, up, up-right.*/
+  const oc_fragment *predfr[4];
+  /*The frame used for prediction for this fragment.*/
+  int                pred_frame;
+  /*The boundary condition flags.*/
+  int                bc;
+  /*DC predictor values: left, up-left, up, up-right, missing values skipped.*/
+  int                p[4];
+  /*Predictor count.*/
+  int                np;
+  /*Which predictor constants to use.*/
+  int                pflags;
+  /*The predicted DC value.*/
+  int                ret;
+  int                i;
+  pred_frame=OC_FRAME_FOR_MODE[_frag->mb_mode];
+  bc=(_x==0)+((_y==0)<<1)+((_x+1==_fplane->nhfrags)<<2);
+  predfr[0]=_frag-1;
+  predfr[1]=_frag-_fplane->nhfrags-1;
+  predfr[2]=predfr[1]+1;
+  predfr[3]=predfr[2]+1;
+  np=0;
+  pflags=0;
+  for(i=0;i<4;i++){
+    int pflag;
+    pflag=1<<i;
+    if((BC_MASK[bc]&pflag)&&predfr[i]->coded&&
+     OC_FRAME_FOR_MODE[predfr[i]->mb_mode]==pred_frame){
+      p[np++]=predfr[i]->dc;
+      pflags|=pflag;
+    }
+  }
+  if(pflags==0)return _pred_last[pred_frame];
+  else{
+    ret=PRED_SCALE[pflags][0]*p[0];
+    /*LOOP VECTORIZES.*/
+    for(i=1;i<np;i++)ret+=PRED_SCALE[pflags][i]*p[i];
+    ret=OC_DIV_POW2(ret,PRED_SHIFT[pflags],PRED_RMASK[pflags]);
+  }
+  if((pflags&(OC_PL|OC_PUL|OC_PU))==(OC_PL|OC_PUL|OC_PU)){
+    if(abs(ret-p[2])>128)ret=p[2];
+    else if(abs(ret-p[0])>128)ret=p[0];
+    else if(abs(ret-p[1])>128)ret=p[1];
+  }
+  return ret;
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/huffdec.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/huffdec.h
new file mode 100644
index 0000000..c00002d
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/huffdec.h
@@ -0,0 +1,91 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: huffdec.h 15953 2009-04-26 14:30:15Z tterribe $
+
+ ********************************************************************/
+
+#if !defined(_huffdec_H)
+# define _huffdec_H (1)
+# include "huffman.h"
+
+
+
+typedef struct oc_huff_node oc_huff_node;
+
+/*A node in the Huffman tree.
+  Instead of storing every branching in the tree, subtrees can be collapsed
+   into one node, with a table of size 1<<nbits pointing directly to its
+   descedents nbits levels down.
+  This allows more than one bit to be read at a time, and avoids following all
+   the intermediate branches with next to no increased code complexity once
+   the collapsed tree has been built.
+  We do _not_ require that a subtree be complete to be collapsed, but instead
+   store duplicate pointers in the table, and record the actual depth of the
+   node below its parent.
+  This tells us the number of bits to advance the stream after reaching it.
+
+  This turns out to be equivalent to the method described in \cite{Hash95},
+   without the requirement that codewords be sorted by length.
+  If the codewords were sorted by length (so-called ``canonical-codes''), they
+   could be decoded much faster via either Lindell and Moffat's approach or
+   Hashemian's Condensed Huffman Code approach, the latter of which has an
+   extremely small memory footprint.
+  We can't use Choueka et al.'s finite state machine approach, which is
+   extremely fast, because we can't allow multiple symbols to be output at a
+   time; the codebook can and does change between symbols.
+  It also has very large memory requirements, which impairs cache coherency.
+
+  @ARTICLE{Hash95,
+    author="Reza Hashemian",
+    title="Memory Efficient and High-Speed Search {Huffman} Coding",
+    journal="{IEEE} Transactions on Communications",
+    volume=43,
+    number=10,
+    pages="2576--2581",
+    month=Oct,
+    year=1995
+  }*/
+struct oc_huff_node{
+  /*The number of bits of the code needed to descend through this node.
+    0 indicates a leaf node.
+    Otherwise there are 1<<nbits nodes in the nodes table, which can be
+     indexed by reading nbits bits from the stream.*/
+  unsigned char  nbits;
+  /*The value of a token stored in a leaf node.
+    The value in non-leaf nodes is undefined.*/
+  unsigned char  token;
+  /*The depth of the current node, relative to its parent in the collapsed
+     tree.
+    This can be less than its parent's nbits value, in which case there are
+     1<<nbits-depth copies of this node in the table, and the bitstream should
+     only be advanced depth bits after reaching this node.*/
+  unsigned char  depth;
+  /*The table of child nodes.
+    The ACTUAL size of this array is 1<<nbits, despite what the declaration
+     below claims.
+    The exception is that for leaf nodes the size is 0.*/
+  oc_huff_node  *nodes[2];
+};
+
+
+
+int oc_huff_trees_unpack(oggpack_buffer *_opb,
+ oc_huff_node *_nodes[TH_NHUFFMAN_TABLES]);
+void oc_huff_trees_copy(oc_huff_node *_dst[TH_NHUFFMAN_TABLES],
+ const oc_huff_node *const _src[TH_NHUFFMAN_TABLES]);
+void oc_huff_trees_clear(oc_huff_node *_nodes[TH_NHUFFMAN_TABLES]);
+int oc_huff_token_decode(oggpack_buffer *_opb,const oc_huff_node *_node);
+
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/huffman.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/huffman.h
new file mode 100644
index 0000000..da31c27
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/huffman.h
@@ -0,0 +1,71 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: huffman.h 15953 2009-04-26 14:30:15Z tterribe $
+
+ ********************************************************************/
+
+#if !defined(_huffman_H)
+# define _hufffman_H (1)
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+# include "vtkoggtheora/include/theora/codec.h"
+# include "ocintrin.h"
+
+/*The range of valid quantized DCT coefficient values.
+  VP3 used 511 in the encoder, but the bitstream is capable of 580.*/
+#define OC_DCT_VAL_RANGE         (580)
+
+#define OC_NDCT_TOKEN_BITS       (5)
+
+#define OC_DCT_EOB1_TOKEN        (0)
+#define OC_DCT_EOB2_TOKEN        (1)
+#define OC_DCT_EOB3_TOKEN        (2)
+#define OC_DCT_REPEAT_RUN0_TOKEN (3)
+#define OC_DCT_REPEAT_RUN1_TOKEN (4)
+#define OC_DCT_REPEAT_RUN2_TOKEN (5)
+#define OC_DCT_REPEAT_RUN3_TOKEN (6)
+
+#define OC_DCT_SHORT_ZRL_TOKEN   (7)
+#define OC_DCT_ZRL_TOKEN         (8)
+
+#define OC_ONE_TOKEN             (9)
+#define OC_MINUS_ONE_TOKEN       (10)
+#define OC_TWO_TOKEN             (11)
+#define OC_MINUS_TWO_TOKEN       (12)
+
+#define OC_DCT_VAL_CAT2          (13)
+#define OC_DCT_VAL_CAT3          (17)
+#define OC_DCT_VAL_CAT4          (18)
+#define OC_DCT_VAL_CAT5          (19)
+#define OC_DCT_VAL_CAT6          (20)
+#define OC_DCT_VAL_CAT7          (21)
+#define OC_DCT_VAL_CAT8          (22)
+
+#define OC_DCT_RUN_CAT1A         (23)
+#define OC_DCT_RUN_CAT1B         (28)
+#define OC_DCT_RUN_CAT1C         (29)
+#define OC_DCT_RUN_CAT2A         (30)
+#define OC_DCT_RUN_CAT2B         (31)
+
+#define OC_NDCT_EOB_TOKEN_MAX    (7)
+#define OC_NDCT_ZRL_TOKEN_MAX    (9)
+#define OC_NDCT_VAL_MAX          (23)
+#define OC_NDCT_VAL_CAT1_MAX     (13)
+#define OC_NDCT_VAL_CAT2_MAX     (17)
+#define OC_NDCT_VAL_CAT2_SIZE    (OC_NDCT_VAL_CAT2_MAX-OC_DCT_VAL_CAT2)
+#define OC_NDCT_RUN_MAX          (32)
+#define OC_NDCT_RUN_CAT1A_MAX    (28)
+
+extern const unsigned char OC_DCT_TOKEN_EXTRA_BITS[TH_NDCT_TOKENS];
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/idct.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/idct.c
new file mode 100644
index 0000000..3f15550
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/idct.c
@@ -0,0 +1,370 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: idct.c 15953 2009-04-26 14:30:15Z tterribe $
+
+ ********************************************************************/
+
+#include <string.h>
+#include "../internal.h"
+#include "dct.h"
+
+/*Performs an inverse 8 point Type-II DCT transform.
+  The output is scaled by a factor of 2 relative to the orthonormal version of
+   the transform.
+  _y: The buffer to store the result in.
+      Data will be placed in every 8th entry (e.g., in a column of an 8x8
+       block).
+  _x: The input coefficients.
+      The first 8 entries are used (e.g., from a row of an 8x8 block).*/
+static void idct8(ogg_int16_t *_y,const ogg_int16_t _x[8]){
+  ogg_int32_t t[8];
+  ogg_int32_t r;
+  /*Stage 1:*/
+  /*0-1 butterfly.*/
+  t[0]=OC_C4S4*(ogg_int16_t)(_x[0]+_x[4])>>16;
+  t[1]=OC_C4S4*(ogg_int16_t)(_x[0]-_x[4])>>16;
+  /*2-3 rotation by 6pi/16.*/
+  t[2]=(OC_C6S2*_x[2]>>16)-(OC_C2S6*_x[6]>>16);
+  t[3]=(OC_C2S6*_x[2]>>16)+(OC_C6S2*_x[6]>>16);
+  /*4-7 rotation by 7pi/16.*/
+  t[4]=(OC_C7S1*_x[1]>>16)-(OC_C1S7*_x[7]>>16);
+  /*5-6 rotation by 3pi/16.*/
+  t[5]=(OC_C3S5*_x[5]>>16)-(OC_C5S3*_x[3]>>16);
+  t[6]=(OC_C5S3*_x[5]>>16)+(OC_C3S5*_x[3]>>16);
+  t[7]=(OC_C1S7*_x[1]>>16)+(OC_C7S1*_x[7]>>16);
+  /*Stage 2:*/
+  /*4-5 butterfly.*/
+  r=t[4]+t[5];
+  t[5]=OC_C4S4*(ogg_int16_t)(t[4]-t[5])>>16;
+  t[4]=r;
+  /*7-6 butterfly.*/
+  r=t[7]+t[6];
+  t[6]=OC_C4S4*(ogg_int16_t)(t[7]-t[6])>>16;
+  t[7]=r;
+  /*Stage 3:*/
+  /*0-3 butterfly.*/
+  r=t[0]+t[3];
+  t[3]=t[0]-t[3];
+  t[0]=r;
+  /*1-2 butterfly.*/
+  r=t[1]+t[2];
+  t[2]=t[1]-t[2];
+  t[1]=r;
+  /*6-5 butterfly.*/
+  r=t[6]+t[5];
+  t[5]=t[6]-t[5];
+  t[6]=r;
+  /*Stage 4:*/
+  /*0-7 butterfly.*/
+  _y[0<<3]=(ogg_int16_t)(t[0]+t[7]);
+  /*1-6 butterfly.*/
+  _y[1<<3]=(ogg_int16_t)(t[1]+t[6]);
+  /*2-5 butterfly.*/
+  _y[2<<3]=(ogg_int16_t)(t[2]+t[5]);
+  /*3-4 butterfly.*/
+  _y[3<<3]=(ogg_int16_t)(t[3]+t[4]);
+  _y[4<<3]=(ogg_int16_t)(t[3]-t[4]);
+  _y[5<<3]=(ogg_int16_t)(t[2]-t[5]);
+  _y[6<<3]=(ogg_int16_t)(t[1]-t[6]);
+  _y[7<<3]=(ogg_int16_t)(t[0]-t[7]);
+}
+
+/*Performs an inverse 8 point Type-II DCT transform.
+  The output is scaled by a factor of 2 relative to the orthonormal version of
+   the transform.
+  _y: The buffer to store the result in.
+      Data will be placed in every 8th entry (e.g., in a column of an 8x8
+       block).
+  _x: The input coefficients.
+      Only the first 4 entries are used.
+      The other 4 are assumed to be 0.*/
+static void idct8_4(ogg_int16_t *_y,const ogg_int16_t _x[8]){
+  ogg_int32_t t[8];
+  ogg_int32_t r;
+  /*Stage 1:*/
+  t[0]=OC_C4S4*_x[0]>>16;
+  t[2]=OC_C6S2*_x[2]>>16;
+  t[3]=OC_C2S6*_x[2]>>16;
+  t[4]=OC_C7S1*_x[1]>>16;
+  t[5]=-(OC_C5S3*_x[3]>>16);
+  t[6]=OC_C3S5*_x[3]>>16;
+  t[7]=OC_C1S7*_x[1]>>16;
+  /*Stage 2:*/
+  r=t[4]+t[5];
+  t[5]=OC_C4S4*(ogg_int16_t)(t[4]-t[5])>>16;
+  t[4]=r;
+  r=t[7]+t[6];
+  t[6]=OC_C4S4*(ogg_int16_t)(t[7]-t[6])>>16;
+  t[7]=r;
+  /*Stage 3:*/
+  t[1]=t[0]+t[2];
+  t[2]=t[0]-t[2];
+  r=t[0]+t[3];
+  t[3]=t[0]-t[3];
+  t[0]=r;
+  r=t[6]+t[5];
+  t[5]=t[6]-t[5];
+  t[6]=r;
+  /*Stage 4:*/
+  _y[0<<3]=(ogg_int16_t)(t[0]+t[7]);
+  _y[1<<3]=(ogg_int16_t)(t[1]+t[6]);
+  _y[2<<3]=(ogg_int16_t)(t[2]+t[5]);
+  _y[3<<3]=(ogg_int16_t)(t[3]+t[4]);
+  _y[4<<3]=(ogg_int16_t)(t[3]-t[4]);
+  _y[5<<3]=(ogg_int16_t)(t[2]-t[5]);
+  _y[6<<3]=(ogg_int16_t)(t[1]-t[6]);
+  _y[7<<3]=(ogg_int16_t)(t[0]-t[7]);
+}
+
+/*Performs an inverse 8 point Type-II DCT transform.
+  The output is scaled by a factor of 2 relative to the orthonormal version of
+   the transform.
+  _y: The buffer to store the result in.
+      Data will be placed in every 8th entry (e.g., in a column of an 8x8
+       block).
+  _x: The input coefficients.
+      Only the first 3 entries are used.
+      The other 5 are assumed to be 0.*/
+static void idct8_3(ogg_int16_t *_y,const ogg_int16_t _x[8]){
+  ogg_int32_t t[8];
+  ogg_int32_t r;
+  /*Stage 1:*/
+  t[0]=OC_C4S4*_x[0]>>16;
+  t[2]=OC_C6S2*_x[2]>>16;
+  t[3]=OC_C2S6*_x[2]>>16;
+  t[4]=OC_C7S1*_x[1]>>16;
+  t[7]=OC_C1S7*_x[1]>>16;
+  /*Stage 2:*/
+  t[5]=OC_C4S4*t[4]>>16;
+  t[6]=OC_C4S4*t[7]>>16;
+  /*Stage 3:*/
+  t[1]=t[0]+t[2];
+  t[2]=t[0]-t[2];
+  r=t[0]+t[3];
+  t[3]=t[0]-t[3];
+  t[0]=r;
+  r=t[6]+t[5];
+  t[5]=t[6]-t[5];
+  t[6]=r;
+  /*Stage 4:*/
+  _y[0<<3]=(ogg_int16_t)(t[0]+t[7]);
+  _y[1<<3]=(ogg_int16_t)(t[1]+t[6]);
+  _y[2<<3]=(ogg_int16_t)(t[2]+t[5]);
+  _y[3<<3]=(ogg_int16_t)(t[3]+t[4]);
+  _y[4<<3]=(ogg_int16_t)(t[3]-t[4]);
+  _y[5<<3]=(ogg_int16_t)(t[2]-t[5]);
+  _y[6<<3]=(ogg_int16_t)(t[1]-t[6]);
+  _y[7<<3]=(ogg_int16_t)(t[0]-t[7]);
+}
+
+/*Performs an inverse 8 point Type-II DCT transform.
+  The output is scaled by a factor of 2 relative to the orthonormal version of
+   the transform.
+  _y: The buffer to store the result in.
+      Data will be placed in every 8th entry (e.g., in a column of an 8x8
+       block).
+  _x: The input coefficients.
+      Only the first 2 entries are used.
+      The other 6 are assumed to be 0.*/
+static void idct8_2(ogg_int16_t *_y,const ogg_int16_t _x[8]){
+  ogg_int32_t t[8];
+  ogg_int32_t r;
+  /*Stage 1:*/
+  t[0]=OC_C4S4*_x[0]>>16;
+  t[4]=OC_C7S1*_x[1]>>16;
+  t[7]=OC_C1S7*_x[1]>>16;
+  /*Stage 2:*/
+  t[5]=OC_C4S4*t[4]>>16;
+  t[6]=OC_C4S4*t[7]>>16;
+  /*Stage 3:*/
+  r=t[6]+t[5];
+  t[5]=t[6]-t[5];
+  t[6]=r;
+  /*Stage 4:*/
+  _y[0<<3]=(ogg_int16_t)(t[0]+t[7]);
+  _y[1<<3]=(ogg_int16_t)(t[0]+t[6]);
+  _y[2<<3]=(ogg_int16_t)(t[0]+t[5]);
+  _y[3<<3]=(ogg_int16_t)(t[0]+t[4]);
+  _y[4<<3]=(ogg_int16_t)(t[0]-t[4]);
+  _y[5<<3]=(ogg_int16_t)(t[0]-t[5]);
+  _y[6<<3]=(ogg_int16_t)(t[0]-t[6]);
+  _y[7<<3]=(ogg_int16_t)(t[0]-t[7]);
+}
+
+/*Performs an inverse 8 point Type-II DCT transform.
+  The output is scaled by a factor of 2 relative to the orthonormal version of
+   the transform.
+  _y: The buffer to store the result in.
+      Data will be placed in every 8th entry (e.g., in a column of an 8x8
+       block).
+  _x: The input coefficients.
+      Only the first entry is used.
+      The other 7 are assumed to be 0.*/
+static void idct8_1(ogg_int16_t *_y,const ogg_int16_t _x[1]){
+  _y[0<<3]=_y[1<<3]=_y[2<<3]=_y[3<<3]=
+   _y[4<<3]=_y[5<<3]=_y[6<<3]=_y[7<<3]=(ogg_int16_t)(OC_C4S4*_x[0]>>16);
+}
+
+/*Performs an inverse 8x8 Type-II DCT transform.
+  The input is assumed to be scaled by a factor of 4 relative to orthonormal
+   version of the transform.
+  All coefficients but the first 3 in zig-zag scan order are assumed to be 0:
+   x  x  0  0  0  0  0  0
+   x  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  0  0
+   0  0  0  0  0  0  0  0
+   0  0  0  0  0  0  0  0
+  _y: The buffer to store the result in.
+      This may be the same as _x.
+  _x: The input coefficients.*/
+static void oc_idct8x8_3(ogg_int16_t _y[64],const ogg_int16_t _x[64]){
+  const ogg_int16_t *in;
+  ogg_int16_t       *end;
+  ogg_int16_t       *out;
+  ogg_int16_t        w[64];
+  /*Transform rows of x into columns of w.*/
+  idct8_2(w,_x);
+  idct8_1(w+1,_x+8);
+  /*Transform rows of w into columns of y.*/
+  for(in=w,out=_y,end=out+8;out<end;in+=8,out++)idct8_2(out,in);
+  /*Adjust for the scale factor.*/
+  for(out=_y,end=out+64;out<end;out++)*out=(ogg_int16_t)(*out+8>>4);
+}
+
+/*Performs an inverse 8x8 Type-II DCT transform.
+  The input is assumed to be scaled by a factor of 4 relative to orthonormal
+   version of the transform.
+  All coefficients but the first 10 in zig-zag scan order are assumed to be 0:
+   x  x  x  x  0  0  0  0
+   x  x  x  0  0  0  0  0
+   x  x  0  0  0  0  0  0
+   x  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  0  0
+  _y: The buffer to store the result in.
+      This may be the same as _x.
+  _x: The input coefficients.*/
+static void oc_idct8x8_10(ogg_int16_t _y[64],const ogg_int16_t _x[64]){
+  const ogg_int16_t *in;
+  ogg_int16_t       *end;
+  ogg_int16_t       *out;
+  ogg_int16_t        w[64];
+  /*Transform rows of x into columns of w.*/
+  idct8_4(w,_x);
+  idct8_3(w+1,_x+8);
+  idct8_2(w+2,_x+16);
+  idct8_1(w+3,_x+24);
+  /*Transform rows of w into columns of y.*/
+  for(in=w,out=_y,end=out+8;out<end;in+=8,out++)idct8_4(out,in);
+  /*Adjust for the scale factor.*/
+  for(out=_y,end=out+64;out<end;out++)*out=(ogg_int16_t)(*out+8>>4);
+}
+
+/*Performs an inverse 8x8 Type-II DCT transform.
+  The input is assumed to be scaled by a factor of 4 relative to orthonormal
+   version of the transform.
+  _y: The buffer to store the result in.
+      This may be the same as _x.
+  _x: The input coefficients.*/
+static void oc_idct8x8_slow(ogg_int16_t _y[64],const ogg_int16_t _x[64]){
+  const ogg_int16_t *in;
+  ogg_int16_t       *end;
+  ogg_int16_t       *out;
+  ogg_int16_t        w[64];
+  /*Transform rows of x into columns of w.*/
+  for(in=_x,out=w,end=out+8;out<end;in+=8,out++)idct8(out,in);
+  /*Transform rows of w into columns of y.*/
+  for(in=w,out=_y,end=out+8;out<end;in+=8,out++)idct8(out,in);
+  /*Adjust for the scale factor.*/
+  for(out=_y,end=out+64;out<end;out++)*out=(ogg_int16_t)(*out+8>>4);
+}
+
+void oc_dequant_idct8x8(const oc_theora_state *_state,ogg_int16_t _y[64],
+ const ogg_int16_t _x[64],int _last_zzi,int _ncoefs,ogg_uint16_t _dc_quant,
+ const ogg_uint16_t _ac_quant[64]){
+  (*_state->opt_vtable.dequant_idct8x8)(_y,_x,_last_zzi,_ncoefs,
+   _dc_quant,_ac_quant);
+}
+
+/*Performs an inverse 8x8 Type-II DCT transform.
+  The input is assumed to be scaled by a factor of 4 relative to orthonormal
+   version of the transform.
+  _y: The buffer to store the result in.
+      This must not be the same as _x.
+  _x: The input coefficients.*/
+void oc_dequant_idct8x8_c(ogg_int16_t _y[64],const ogg_int16_t _x[64],
+ int _last_zzi,int _ncoefs,ogg_uint16_t _dc_quant,
+ const ogg_uint16_t _ac_quant[64]){
+  int ci;
+  /*_last_zzi is subtly different from an actual count of the number of
+     coefficients we decoded for this block.
+    It contains the value of zzi BEFORE the final token in the block was
+     decoded.
+    In most cases this is an EOB token (the continuation of an EOB run from a
+     previous block counts), and so this is the same as the coefficient count.
+    However, in the case that the last token was NOT an EOB token, but filled
+     the block up with exactly 64 coefficients, _last_zzi will be less than 64.
+    Provided the last token was not a pure zero run, the minimum value it can
+     be is 46, and so that doesn't affect any of the cases in this routine.
+    However, if the last token WAS a pure zero run of length 63, then _last_zzi
+     will be 1 while the number of coefficients decoded is 64.
+    Thus, we will trigger the following special case, where the real
+     coefficient count would not.
+    Note also that a zero run of length 64 will give _last_zzi a value of 0,
+     but we still process the DC coefficient, which might have a non-zero value
+     due to DC prediction.
+    Although convoluted, this is arguably the correct behavior: it allows us to
+     dequantize fewer coefficients and use a smaller transform when the block
+     ends with a long zero run instead of a normal EOB token.
+    It could be smarter... multiple separate zero runs at the end of a block
+     will fool it, but an encoder that generates these really deserves what it
+     gets.
+    Needless to say we inherited this approach from VP3.*/
+  /*Special case only having a DC component.*/
+  if(_last_zzi<2){
+    ogg_int16_t p;
+    /*We round this dequant product (and not any of the others) because there's
+       no iDCT rounding.*/
+    p=(ogg_int16_t)(_x[0]*(ogg_int32_t)_dc_quant+15>>5);
+    /*LOOP VECTORIZES.*/
+    for(ci=0;ci<64;ci++)_y[ci]=p;
+  }
+  else{
+    int zzi;
+    /*First, dequantize the coefficients.*/
+    _y[0]=(ogg_int16_t)(_x[0]*(int)_dc_quant);
+    for(zzi=1;zzi<_ncoefs;zzi++){
+      _y[OC_FZIG_ZAG[zzi]]=(ogg_int16_t)(_x[zzi]*(int)_ac_quant[zzi]);
+    }
+    /*Then, fill in the remainder of the coefficients with 0's, and perform
+       the iDCT.*/
+    if(_last_zzi<3){
+      for(;zzi<3;zzi++)_y[OC_FZIG_ZAG[zzi]]=0;
+      oc_idct8x8_3(_y,_y);
+    }
+    else if(_last_zzi<10){
+      for(;zzi<10;zzi++)_y[OC_FZIG_ZAG[zzi]]=0;
+      oc_idct8x8_10(_y,_y);
+    }
+    else{
+      for(;zzi<64;zzi++)_y[OC_FZIG_ZAG[zzi]]=0;
+      oc_idct8x8_slow(_y,_y);
+    }
+  }
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/info.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/info.c
new file mode 100644
index 0000000..35ec437
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/info.c
@@ -0,0 +1,123 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: info.c 15675 2009-02-06 09:43:27Z tterribe $
+
+ ********************************************************************/
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <string.h>
+#include "../internal.h"
+
+
+
+/*This is more or less the same as strncasecmp, but that doesn't exist
+   everywhere, and this is a fairly trivial function, so we include it.
+  Note: We take advantage of the fact that we know _n is less than or equal to
+   the length of at least one of the strings.*/
+static int oc_tagcompare(const char *_s1,const char *_s2,int _n){
+  int c;
+  for(c=0;c<_n;c++){
+    if(toupper(_s1[c])!=toupper(_s2[c]))return !0;
+  }
+  return _s1[c]!='=';
+}
+
+
+
+void th_info_init(th_info *_info){
+  memset(_info,0,sizeof(*_info));
+  _info->version_major=TH_VERSION_MAJOR;
+  _info->version_minor=TH_VERSION_MINOR;
+  _info->version_subminor=TH_VERSION_SUB;
+  _info->keyframe_granule_shift=6;
+}
+
+void th_info_clear(th_info *_info){
+  memset(_info,0,sizeof(*_info));
+}
+
+
+
+void th_comment_init(th_comment *_tc){
+  memset(_tc,0,sizeof(*_tc));
+}
+
+void th_comment_add(th_comment *_tc,char *_comment){
+  int comment_len;
+  _tc->user_comments=_ogg_realloc(_tc->user_comments,
+   (_tc->comments+2)*sizeof(*_tc->user_comments));
+  _tc->comment_lengths=_ogg_realloc(_tc->comment_lengths,
+   (_tc->comments+2)*sizeof(*_tc->comment_lengths));
+  comment_len=strlen(_comment);
+  _tc->comment_lengths[_tc->comments]=comment_len;
+  _tc->user_comments[_tc->comments]=_ogg_malloc(comment_len+1);
+  memcpy(_tc->user_comments[_tc->comments],_comment,comment_len+1);
+  _tc->comments++;
+  _tc->user_comments[_tc->comments]=NULL;
+}
+
+void th_comment_add_tag(th_comment *_tc,char *_tag,char *_val){
+  char *comment;
+  int   tag_len;
+  int   val_len;
+  tag_len=strlen(_tag);
+  val_len=strlen(_val);
+  /*+2 for '=' and '\0'.*/
+  comment=_ogg_malloc(tag_len+val_len+2);
+  memcpy(comment,_tag,tag_len);
+  comment[tag_len]='=';
+  memcpy(comment+tag_len+1,_val,val_len+1);
+  th_comment_add(_tc,comment);
+  _ogg_free(comment);
+}
+
+char *th_comment_query(th_comment *_tc,char *_tag,int _count){
+  long i;
+  int  found;
+  int  tag_len;
+  tag_len=strlen(_tag);
+  found=0;
+  for(i=0;i<_tc->comments;i++){
+    if(!oc_tagcompare(_tc->user_comments[i],_tag,tag_len)){
+      /*We return a pointer to the data, not a copy.*/
+      if(_count==found++)return _tc->user_comments[i]+tag_len+1;
+    }
+  }
+  /*Didn't find anything.*/
+  return NULL;
+}
+
+int th_comment_query_count(th_comment *_tc,char *_tag){
+  long i;
+  int  tag_len;
+  int  count;
+  tag_len=strlen(_tag);
+  count=0;
+  for(i=0;i<_tc->comments;i++){
+    if(!oc_tagcompare(_tc->user_comments[i],_tag,tag_len))count++;
+  }
+  return count;
+}
+
+void th_comment_clear(th_comment *_tc){
+  if(_tc!=NULL){
+    long i;
+    for(i=0;i<_tc->comments;i++)_ogg_free(_tc->user_comments[i]);
+    _ogg_free(_tc->user_comments);
+    _ogg_free(_tc->comment_lengths);
+    _ogg_free(_tc->vendor);
+    memset(_tc,0,sizeof(*_tc));
+  }
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/internal.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/internal.c
new file mode 100644
index 0000000..189e4e9
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/internal.c
@@ -0,0 +1,379 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: internal.c 15977 2009-05-02 17:49:35Z tterribe $
+
+ ********************************************************************/
+
+#include <stdlib.h>
+#include <limits.h>
+#include <string.h>
+#include "../internal.h"
+
+
+
+/*A map from the index in the zig zag scan to the coefficient number in a
+   block.
+  All zig zag indices beyond 63 are sent to coefficient 64, so that zero runs
+   past the end of a block in bogus streams get mapped to a known location.*/
+const unsigned char OC_FZIG_ZAG[64]={
+   0, 1, 8,16, 9, 2, 3,10,
+  17,24,32,25,18,11, 4, 5,
+  12,19,26,33,40,48,41,34,
+  27,20,13, 6, 7,14,21,28,
+  35,42,49,56,57,50,43,36,
+  29,22,15,23,30,37,44,51,
+  58,59,52,45,38,31,39,46,
+  53,60,61,54,47,55,62,63
+};
+
+/*A map from the coefficient number in a block to its index in the zig zag
+   scan.*/
+const unsigned char OC_IZIG_ZAG[64]={
+   0, 1, 5, 6,14,15,27,28,
+   2, 4, 7,13,16,26,29,42,
+   3, 8,12,17,25,30,41,43,
+   9,11,18,24,31,40,44,53,
+  10,19,23,32,39,45,52,54,
+  20,22,33,38,46,51,55,60,
+  21,34,37,47,50,56,59,61,
+  35,36,48,49,57,58,62,63
+};
+
+/*The predictor frame to use for each macro block mode.*/
+const unsigned char OC_FRAME_FOR_MODE[8]={
+  /*OC_MODE_INTER_NOMV*/
+  OC_FRAME_PREV,
+  /*OC_MODE_INTRA*/
+  OC_FRAME_SELF,
+  /*OC_MODE_INTER_MV*/
+  OC_FRAME_PREV,
+  /*OC_MODE_INTER_MV_LAST*/
+  OC_FRAME_PREV,
+  /*OC_MODE_INTER_MV_LAST2*/
+  OC_FRAME_PREV,
+  /*OC_MODE_GOLDEN*/
+  OC_FRAME_GOLD,
+  /*OC_MODE_GOLDEN_MV*/
+  OC_FRAME_GOLD,
+  /*OC_MODE_INTER_MV_FOUR*/
+  OC_FRAME_PREV,
+};
+
+/*A map from physical macro block ordering to bitstream macro block
+   ordering within a super block.*/
+const unsigned char OC_MB_MAP[2][2]={{0,3},{1,2}};
+
+/*A list of the indices in the oc_mb.map array that can be valid for each of
+   the various chroma decimation types.*/
+const unsigned char OC_MB_MAP_IDXS[TH_PF_NFORMATS][12]={
+  {0,1,2,3,4,8},
+  {0,1,2,3,4,5,8,9},
+  {0,1,2,3,4,6,8,10},
+  {0,1,2,3,4,5,6,7,8,9,10,11}
+};
+
+/*The number of indices in the oc_mb.map array that can be valid for each of
+   the various chroma decimation types.*/
+const unsigned char OC_MB_MAP_NIDXS[TH_PF_NFORMATS]={6,8,8,12};
+
+/*The number of extra bits that are coded with each of the DCT tokens.
+  Each DCT token has some fixed number of additional bits (possibly 0) stored
+   after the token itself, containing, for example, coefficient magnitude,
+   sign bits, etc.*/
+const unsigned char OC_DCT_TOKEN_EXTRA_BITS[TH_NDCT_TOKENS]={
+  0,0,0,2,3,4,12,3,6,
+  0,0,0,0,
+  1,1,1,1,2,3,4,5,6,10,
+  1,1,1,1,1,3,4,
+  2,3
+};
+
+
+
+int oc_ilog(unsigned _v){
+  int ret;
+  for(ret=0;_v;ret++)_v>>=1;
+  return ret;
+}
+
+
+
+/*Determines the number of blocks or coefficients to be skipped for a given
+   token value.
+  _token:      The token value to skip.
+  _extra_bits: The extra bits attached to this token.
+  Return: A positive value indicates that number of coefficients are to be
+           skipped in the current block.
+          Otherwise, the negative of the return value indicates that number of
+           blocks are to be ended.*/
+typedef ptrdiff_t (*oc_token_skip_func)(int _token,int _extra_bits);
+
+/*Handles the simple end of block tokens.*/
+static ptrdiff_t oc_token_skip_eob(int _token,int _extra_bits){
+  static const unsigned char NBLOCKS_ADJUST[OC_NDCT_EOB_TOKEN_MAX]=
+   {1,2,3,4,8,16,0};
+  return -_extra_bits-NBLOCKS_ADJUST[_token];
+}
+
+/*The last EOB token has a special case, where an EOB run of size zero ends all
+   the remaining blocks in the frame.*/
+static ptrdiff_t oc_token_skip_eob6(int _token,int _extra_bits){
+  /*Note: We want to return -PTRDIFF_MAX, but that requires C99, which is not
+     yet available everywhere; this should be equivalent.*/
+  if(!_extra_bits)return -(~(size_t)0>>1);
+  return -_extra_bits;
+}
+
+/*Handles the pure zero run tokens.*/
+static ptrdiff_t oc_token_skip_zrl(int _token,int _extra_bits){
+  return _extra_bits+1;
+}
+
+/*Handles a normal coefficient value token.*/
+static ptrdiff_t oc_token_skip_val(void){
+  return 1;
+}
+
+/*Handles a category 1A zero run/coefficient value combo token.*/
+static ptrdiff_t oc_token_skip_run_cat1a(int _token){
+  return _token-OC_DCT_RUN_CAT1A+2;
+}
+
+/*Handles category 1b and 2 zero run/coefficient value combo tokens.*/
+static ptrdiff_t oc_token_skip_run(int _token,int _extra_bits){
+  static const unsigned char NCOEFFS_ADJUST[OC_NDCT_RUN_MAX-OC_DCT_RUN_CAT1B]={
+    7,11,2,3
+  };
+  static const unsigned char NCOEFFS_MASK[OC_NDCT_RUN_MAX-OC_DCT_RUN_CAT1B]={
+    3,7,0,1
+  };
+  _token-=OC_DCT_RUN_CAT1B;
+  return (_extra_bits&NCOEFFS_MASK[_token])+NCOEFFS_ADJUST[_token];
+}
+
+/*A jump table for computing the number of coefficients or blocks to skip for
+   a given token value.
+  This reduces all the conditional branches, etc., needed to parse these token
+   values down to one indirect jump.*/
+static const oc_token_skip_func OC_TOKEN_SKIP_TABLE[TH_NDCT_TOKENS]={
+  oc_token_skip_eob,
+  oc_token_skip_eob,
+  oc_token_skip_eob,
+  oc_token_skip_eob,
+  oc_token_skip_eob,
+  oc_token_skip_eob,
+  oc_token_skip_eob6,
+  oc_token_skip_zrl,
+  oc_token_skip_zrl,
+  (oc_token_skip_func)oc_token_skip_val,
+  (oc_token_skip_func)oc_token_skip_val,
+  (oc_token_skip_func)oc_token_skip_val,
+  (oc_token_skip_func)oc_token_skip_val,
+  (oc_token_skip_func)oc_token_skip_val,
+  (oc_token_skip_func)oc_token_skip_val,
+  (oc_token_skip_func)oc_token_skip_val,
+  (oc_token_skip_func)oc_token_skip_val,
+  (oc_token_skip_func)oc_token_skip_val,
+  (oc_token_skip_func)oc_token_skip_val,
+  (oc_token_skip_func)oc_token_skip_val,
+  (oc_token_skip_func)oc_token_skip_val,
+  (oc_token_skip_func)oc_token_skip_val,
+  (oc_token_skip_func)oc_token_skip_val,
+  (oc_token_skip_func)oc_token_skip_run_cat1a,
+  (oc_token_skip_func)oc_token_skip_run_cat1a,
+  (oc_token_skip_func)oc_token_skip_run_cat1a,
+  (oc_token_skip_func)oc_token_skip_run_cat1a,
+  (oc_token_skip_func)oc_token_skip_run_cat1a,
+  oc_token_skip_run,
+  oc_token_skip_run,
+  oc_token_skip_run,
+  oc_token_skip_run
+};
+
+/*Determines the number of blocks or coefficients to be skipped for a given
+   token value.
+  _token:      The token value to skip.
+  _extra_bits: The extra bits attached to this token.
+  Return: A positive value indicates that number of coefficients are to be
+           skipped in the current block.
+          Otherwise, the negative of the return value indicates that number of
+           blocks are to be ended.
+          0 will never be returned, so that at least one coefficient in one
+           block will always be decoded for every token.*/
+ptrdiff_t oc_dct_token_skip(int _token,int _extra_bits){
+  return (*OC_TOKEN_SKIP_TABLE[_token])(_token,_extra_bits);
+}
+
+
+/*The function used to fill in the chroma plane motion vectors for a macro
+   block when 4 different motion vectors are specified in the luma plane.
+  This version is for use with chroma decimated in the X and Y directions
+   (4:2:0).
+  _cbmvs: The chroma block-level motion vectors to fill in.
+  _lbmvs: The luma block-level motion vectors.*/
+static void oc_set_chroma_mvs00(oc_mv _cbmvs[4],const oc_mv _lbmvs[4]){
+  int dx;
+  int dy;
+  dx=_lbmvs[0][0]+_lbmvs[1][0]+_lbmvs[2][0]+_lbmvs[3][0];
+  dy=_lbmvs[0][1]+_lbmvs[1][1]+_lbmvs[2][1]+_lbmvs[3][1];
+  _cbmvs[0][0]=(signed char)OC_DIV_ROUND_POW2(dx,2,2);
+  _cbmvs[0][1]=(signed char)OC_DIV_ROUND_POW2(dy,2,2);
+}
+
+/*The function used to fill in the chroma plane motion vectors for a macro
+   block when 4 different motion vectors are specified in the luma plane.
+  This version is for use with chroma decimated in the Y direction.
+  _cbmvs: The chroma block-level motion vectors to fill in.
+  _lbmvs: The luma block-level motion vectors.*/
+static void oc_set_chroma_mvs01(oc_mv _cbmvs[4],const oc_mv _lbmvs[4]){
+  int dx;
+  int dy;
+  dx=_lbmvs[0][0]+_lbmvs[2][0];
+  dy=_lbmvs[0][1]+_lbmvs[2][1];
+  _cbmvs[0][0]=(signed char)OC_DIV_ROUND_POW2(dx,1,1);
+  _cbmvs[0][1]=(signed char)OC_DIV_ROUND_POW2(dy,1,1);
+  dx=_lbmvs[1][0]+_lbmvs[3][0];
+  dy=_lbmvs[1][1]+_lbmvs[3][1];
+  _cbmvs[1][0]=(signed char)OC_DIV_ROUND_POW2(dx,1,1);
+  _cbmvs[1][1]=(signed char)OC_DIV_ROUND_POW2(dy,1,1);
+}
+
+/*The function used to fill in the chroma plane motion vectors for a macro
+   block when 4 different motion vectors are specified in the luma plane.
+  This version is for use with chroma decimated in the X direction (4:2:2).
+  _cbmvs: The chroma block-level motion vectors to fill in.
+  _lbmvs: The luma block-level motion vectors.*/
+static void oc_set_chroma_mvs10(oc_mv _cbmvs[4],const oc_mv _lbmvs[4]){
+  int dx;
+  int dy;
+  dx=_lbmvs[0][0]+_lbmvs[1][0];
+  dy=_lbmvs[0][1]+_lbmvs[1][1];
+  _cbmvs[0][0]=(signed char)OC_DIV_ROUND_POW2(dx,1,1);
+  _cbmvs[0][1]=(signed char)OC_DIV_ROUND_POW2(dy,1,1);
+  dx=_lbmvs[2][0]+_lbmvs[3][0];
+  dy=_lbmvs[2][1]+_lbmvs[3][1];
+  _cbmvs[2][0]=(signed char)OC_DIV_ROUND_POW2(dx,1,1);
+  _cbmvs[2][1]=(signed char)OC_DIV_ROUND_POW2(dy,1,1);
+}
+
+/*The function used to fill in the chroma plane motion vectors for a macro
+   block when 4 different motion vectors are specified in the luma plane.
+  This version is for use with no chroma decimation (4:4:4).
+  _cbmvs: The chroma block-level motion vectors to fill in.
+  _lmbmv: The luma macro-block level motion vector to fill in for use in
+           prediction.
+  _lbmvs: The luma block-level motion vectors.*/
+static void oc_set_chroma_mvs11(oc_mv _cbmvs[4],const oc_mv _lbmvs[4]){
+  memcpy(_cbmvs,_lbmvs,4*sizeof(_lbmvs[0]));
+}
+
+/*A table of functions used to fill in the chroma plane motion vectors for a
+   macro block when 4 different motion vectors are specified in the luma
+   plane.*/
+const oc_set_chroma_mvs_func OC_SET_CHROMA_MVS_TABLE[TH_PF_NFORMATS]={
+  (oc_set_chroma_mvs_func)oc_set_chroma_mvs00,
+  (oc_set_chroma_mvs_func)oc_set_chroma_mvs01,
+  (oc_set_chroma_mvs_func)oc_set_chroma_mvs10,
+  (oc_set_chroma_mvs_func)oc_set_chroma_mvs11
+};
+
+
+
+void **oc_malloc_2d(size_t _height,size_t _width,size_t _sz){
+  size_t  rowsz;
+  size_t  colsz;
+  size_t  datsz;
+  char   *ret;
+  colsz=_height*sizeof(void *);
+  rowsz=_sz*_width;
+  datsz=rowsz*_height;
+  /*Alloc array and row pointers.*/
+  ret=(char *)_ogg_malloc(datsz+colsz);
+  /*Initialize the array.*/
+  if(ret!=NULL){
+    size_t   i;
+    void   **p;
+    char    *datptr;
+    p=(void **)ret;
+    i=_height;
+    for(datptr=ret+colsz;i-->0;p++,datptr+=rowsz)*p=(void *)datptr;
+  }
+  return (void **)ret;
+}
+
+void **oc_calloc_2d(size_t _height,size_t _width,size_t _sz){
+  size_t  colsz;
+  size_t  rowsz;
+  size_t  datsz;
+  char   *ret;
+  colsz=_height*sizeof(void *);
+  rowsz=_sz*_width;
+  datsz=rowsz*_height;
+  /*Alloc array and row pointers.*/
+  ret=(char *)_ogg_calloc(datsz+colsz,1);
+  /*Initialize the array.*/
+  if(ret!=NULL){
+    size_t   i;
+    void   **p;
+    char    *datptr;
+    p=(void **)ret;
+    i=_height;
+    for(datptr=ret+colsz;i-->0;p++,datptr+=rowsz)*p=(void *)datptr;
+  }
+  return (void **)ret;
+}
+
+void oc_free_2d(void *_ptr){
+  _ogg_free(_ptr);
+}
+
+/*Fills in a Y'CbCr buffer with a pointer to the image data in the first
+   buffer, but with the opposite vertical orientation.
+  _dst: The destination buffer.
+        This can be the same as _src.
+  _src: The source buffer.*/
+void oc_ycbcr_buffer_flip(th_ycbcr_buffer _dst,
+ const th_ycbcr_buffer _src){
+  int pli;
+  for(pli=0;pli<3;pli++){
+    _dst[pli].width=_src[pli].width;
+    _dst[pli].height=_src[pli].height;
+    _dst[pli].stride=-_src[pli].stride;
+    _dst[pli].data=_src[pli].data
+     +(1-_dst[pli].height)*(ptrdiff_t)_dst[pli].stride;
+  }
+}
+
+const char *th_version_string(void){
+  return OC_VENDOR_STRING;
+}
+
+ogg_uint32_t th_version_number(void){
+  return (TH_VERSION_MAJOR<<16)+(TH_VERSION_MINOR<<8)+TH_VERSION_SUB;
+}
+
+/*Determines the packet type.
+  Note that this correctly interprets a 0-byte packet as a video data packet.
+  Return: 1 for a header packet, 0 for a data packet.*/
+int th_packet_isheader(ogg_packet *_op){
+  return _op->bytes>0?_op->packet[0]>>7:0;
+}
+
+/*Determines the frame type of a video data packet.
+  Note that this correctly interprets a 0-byte packet as a delta frame.
+  Return: 1 for a key frame, 0 for a delta frame, and -1 for a header
+           packet.*/
+int th_packet_iskeyframe(ogg_packet *_op){
+  return _op->bytes<=0?0:_op->packet[0]&0x80?-1:!(_op->packet[0]&0x40);
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/ocintrin.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/ocintrin.h
new file mode 100644
index 0000000..ad7756f
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/ocintrin.h
@@ -0,0 +1,117 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: ocintrin.h 15989 2009-05-08 03:02:38Z tterribe $
+
+ ********************************************************************/
+
+/*Some common macros for potential platform-specific optimization.*/
+#include <math.h>
+#if !defined(_ocintrin_H)
+# define _ocintrin_H (1)
+
+/*Some specific platforms may have optimized intrinsic or inline assembly
+   versions of these functions which can substantially improve performance.
+  We define macros for them to allow easy incorporation of these non-ANSI
+   features.*/
+
+/*Note that we do not provide a macro for abs(), because it is provided as a
+   library function, which we assume is translated into an intrinsic to avoid
+   the function call overhead and then implemented in the smartest way for the
+   target platform.
+  With modern gcc (4.x), this is true: it uses cmov instructions if the
+   architecture supports it and branchless bit-twiddling if it does not (the
+   speed difference between the two approaches is not measurable).
+  Interestingly, the bit-twiddling method was patented in 2000 (US 6,073,150)
+   by Sun Microsystems, despite prior art dating back to at least 1996:
+   http://web.archive.org/web/19961201174141/www.x86.org/ftp/articles/pentopt/PENTOPT.TXT
+  On gcc 3.x, however, our assumption is not true, as abs() is translated to a
+   conditional jump, which is horrible on deeply piplined architectures (e.g.,
+   all consumer architectures for the past decade or more).
+  Also be warned that -C*abs(x) where C is a constant is mis-optimized as
+   abs(C*x) on every gcc release before 4.2.3.
+  See bug http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34130 */
+
+/*Modern gcc (4.x) can compile the naive versions of min and max with cmov if
+   given an appropriate architecture, but the branchless bit-twiddling versions
+   are just as fast, and do not require any special target architecture.
+  Earlier gcc versions (3.x) compiled both code to the same assembly
+   instructions, because of the way they represented ((_b)>(_a)) internally.*/
+#define OC_MAXI(_a,_b)      ((_a)-((_a)-(_b)&-((_b)>(_a))))
+#define OC_MINI(_a,_b)      ((_a)+((_b)-(_a)&-((_b)<(_a))))
+/*Clamps an integer into the given range.
+  If _a>_c, then the lower bound _a is respected over the upper bound _c (this
+   behavior is required to meet our documented API behavior).
+  _a: The lower bound.
+  _b: The value to clamp.
+  _c: The upper boud.*/
+#define OC_CLAMPI(_a,_b,_c) (OC_MAXI(_a,OC_MINI(_b,_c)))
+#define OC_CLAMP255(_x)     ((unsigned char)((((_x)<0)-1)&((_x)|-((_x)>255))))
+/*This has a chance of compiling branchless, and is just as fast as the
+   bit-twiddling method, which is slightly less portable, since it relies on a
+   sign-extended rightshift, which is not guaranteed by ANSI (but present on
+   every relevant platform).*/
+#define OC_SIGNI(_a)        (((_a)>0)-((_a)<0))
+/*Slightly more portable than relying on a sign-extended right-shift (which is
+   not guaranteed by ANSI), and just as fast, since gcc (3.x and 4.x both)
+   compile it into the right-shift anyway.*/
+#define OC_SIGNMASK(_a)     (-((_a)<0))
+/*Divides an integer by a power of two, truncating towards 0.
+  _dividend: The integer to divide.
+  _shift:    The non-negative power of two to divide by.
+  _rmask:    (1<<_shift)-1*/
+#define OC_DIV_POW2(_dividend,_shift,_rmask)\
+  ((_dividend)+(OC_SIGNMASK(_dividend)&(_rmask))>>(_shift))
+/*Divides _x by 65536, truncating towards 0.*/
+#define OC_DIV2_16(_x) OC_DIV_POW2(_x,16,0xFFFF)
+/*Divides _x by 2, truncating towards 0.*/
+#define OC_DIV2(_x) OC_DIV_POW2(_x,1,0x1)
+/*Divides _x by 8, truncating towards 0.*/
+#define OC_DIV8(_x) OC_DIV_POW2(_x,3,0x7)
+/*Divides _x by 16, truncating towards 0.*/
+#define OC_DIV16(_x) OC_DIV_POW2(_x,4,0xF)
+/*Right shifts _dividend by _shift, adding _rval, and subtracting one for
+   negative dividends first.
+  When _rval is (1<<_shift-1), this is equivalent to division with rounding
+   ties away from zero.*/
+#define OC_DIV_ROUND_POW2(_dividend,_shift,_rval)\
+ ((_dividend)+OC_SIGNMASK(_dividend)+(_rval)>>(_shift))
+/*Divides a _x by 2, rounding towards even numbers.*/
+#define OC_DIV2_RE(_x) ((_x)+((_x)>>1&1)>>1)
+/*Divides a _x by (1<<(_shift)), rounding towards even numbers.*/
+#define OC_DIV_POW2_RE(_x,_shift) \
+ ((_x)+((_x)>>(_shift)&1)+((1<<(_shift))-1>>1)>>(_shift))
+/*Swaps two integers _a and _b if _a>_b.*/
+#define OC_SORT2I(_a,_b)\
+  do{\
+    int t__;\
+    t__=((_a)^(_b))&-((_b)<(_a));\
+    (_a)^=t__;\
+    (_b)^=t__;\
+  }\
+  while(0)\
+
+
+
+/*All of these macros should expect floats as arguments.*/
+#define OC_MAXF(_a,_b)      ((_a)<(_b)?(_b):(_a))
+#define OC_MINF(_a,_b)      ((_a)>(_b)?(_b):(_a))
+#define OC_CLAMPF(_a,_b,_c) (OC_MINF(_a,OC_MAXF(_b,_c)))
+#define OC_FABSF(_f)        ((float)fabs(_f))
+#define OC_SQRTF(_f)        ((float)sqrt(_f))
+#define OC_POWF(_b,_e)      ((float)pow(_b,_e))
+#define OC_LOGF(_f)         ((float)log(_f))
+#define OC_IFLOORF(_f)      ((int)floor(_f))
+#define OC_ICEILF(_f)       ((int)ceil(_f))
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/quant.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/quant.h
new file mode 100644
index 0000000..2870557
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/quant.h
@@ -0,0 +1,35 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: quant.h 15675 2009-02-06 09:43:27Z tterribe $
+
+ ********************************************************************/
+
+#if !defined(_quant_H)
+# define _quant_H (1)
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+# include "vtkoggtheora/include/theora/codec.h"
+# include "ocintrin.h"
+
+typedef ogg_uint16_t   oc_quant_table[64];
+typedef oc_quant_table oc_quant_tables[64];
+
+
+/*Maximum scaled quantizer value.*/
+#define OC_QUANT_MAX          (1024<<2)
+
+
+void oc_dequant_tables_init(oc_quant_table *_dequant[2][3],
+ int _pp_dc_scale[64],const th_quant_info *_qinfo);
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/mmxfrag.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/mmxfrag.c
new file mode 100644
index 0000000..e4e26ef
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/mmxfrag.c
@@ -0,0 +1,293 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2003                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: mmxfrag.c 15953 2009-04-26 14:30:15Z tterribe $
+
+ ********************************************************************/
+
+/*MMX acceleration of fragment reconstruction for motion compensation.
+  Originally written by Rudolf Marek.
+  Additional optimization by Nils Pipenbrinck.
+  Note: Loops are unrolled for best performance.
+  The iteration each instruction belongs to is marked in the comments as #i.*/
+#include <stddef.h>
+#include "x86int.h"
+#include "mmxfrag.h"
+
+#if defined(OC_X86_ASM)
+
+/*Copies an 8x8 block of pixels from _src to _dst, assuming _ystride bytes
+   between rows.*/
+void oc_frag_copy_mmx(unsigned char *_dst,
+ const unsigned char *_src,int _ystride){
+  OC_FRAG_COPY_MMX(_dst,_src,_ystride);
+}
+
+void oc_frag_recon_intra_mmx(unsigned char *_dst,int _ystride,
+ const ogg_int16_t *_residue){
+  __asm__ __volatile__(
+    /*Set mm0 to 0xFFFFFFFFFFFFFFFF.*/
+    "pcmpeqw %%mm0,%%mm0\n\t"
+    /*#0 Load low residue.*/
+    "movq 0*8(%[residue]),%%mm1\n\t"
+    /*#0 Load high residue.*/
+    "movq 1*8(%[residue]),%%mm2\n\t"
+    /*Set mm0 to 0x8000800080008000.*/
+    "psllw $15,%%mm0\n\t"
+    /*#1 Load low residue.*/
+    "movq 2*8(%[residue]),%%mm3\n\t"
+    /*#1 Load high residue.*/
+    "movq 3*8(%[residue]),%%mm4\n\t"
+    /*Set mm0 to 0x0080008000800080.*/
+    "psrlw $8,%%mm0\n\t"
+    /*#2 Load low residue.*/
+    "movq 4*8(%[residue]),%%mm5\n\t"
+    /*#2 Load high residue.*/
+    "movq 5*8(%[residue]),%%mm6\n\t"
+    /*#0 Bias low  residue.*/
+    "paddsw %%mm0,%%mm1\n\t"
+    /*#0 Bias high residue.*/
+    "paddsw %%mm0,%%mm2\n\t"
+    /*#0 Pack to byte.*/
+    "packuswb %%mm2,%%mm1\n\t"
+    /*#1 Bias low  residue.*/
+    "paddsw %%mm0,%%mm3\n\t"
+    /*#1 Bias high residue.*/
+    "paddsw %%mm0,%%mm4\n\t"
+    /*#1 Pack to byte.*/
+    "packuswb %%mm4,%%mm3\n\t"
+    /*#2 Bias low  residue.*/
+    "paddsw %%mm0,%%mm5\n\t"
+    /*#2 Bias high residue.*/
+    "paddsw %%mm0,%%mm6\n\t"
+    /*#2 Pack to byte.*/
+    "packuswb %%mm6,%%mm5\n\t"
+    /*#0 Write row.*/
+    "movq %%mm1,(%[dst])\n\t"
+    /*#1 Write row.*/
+    "movq %%mm3,(%[dst],%[ystride])\n\t"
+    /*#2 Write row.*/
+    "movq %%mm5,(%[dst],%[ystride],2)\n\t"
+    /*#3 Load low residue.*/
+    "movq 6*8(%[residue]),%%mm1\n\t"
+    /*#3 Load high residue.*/
+    "movq 7*8(%[residue]),%%mm2\n\t"
+    /*#4 Load high residue.*/
+    "movq 8*8(%[residue]),%%mm3\n\t"
+    /*#4 Load high residue.*/
+    "movq 9*8(%[residue]),%%mm4\n\t"
+    /*#5 Load high residue.*/
+    "movq 10*8(%[residue]),%%mm5\n\t"
+    /*#5 Load high residue.*/
+    "movq 11*8(%[residue]),%%mm6\n\t"
+    /*#3 Bias low  residue.*/
+    "paddsw %%mm0,%%mm1\n\t"
+    /*#3 Bias high residue.*/
+    "paddsw %%mm0,%%mm2\n\t"
+    /*#3 Pack to byte.*/
+    "packuswb %%mm2,%%mm1\n\t"
+    /*#4 Bias low  residue.*/
+    "paddsw %%mm0,%%mm3\n\t"
+    /*#4 Bias high residue.*/
+    "paddsw %%mm0,%%mm4\n\t"
+    /*#4 Pack to byte.*/
+    "packuswb %%mm4,%%mm3\n\t"
+    /*#5 Bias low  residue.*/
+    "paddsw %%mm0,%%mm5\n\t"
+    /*#5 Bias high residue.*/
+    "paddsw %%mm0,%%mm6\n\t"
+    /*#5 Pack to byte.*/
+    "packuswb %%mm6,%%mm5\n\t"
+    /*#3 Write row.*/
+    "movq %%mm1,(%[dst],%[ystride3])\n\t"
+    /*#4 Write row.*/
+    "movq %%mm3,(%[dst4])\n\t"
+    /*#5 Write row.*/
+    "movq %%mm5,(%[dst4],%[ystride])\n\t"
+    /*#6 Load low residue.*/
+    "movq 12*8(%[residue]),%%mm1\n\t"
+    /*#6 Load high residue.*/
+    "movq 13*8(%[residue]),%%mm2\n\t"
+    /*#7 Load low residue.*/
+    "movq 14*8(%[residue]),%%mm3\n\t"
+    /*#7 Load high residue.*/
+    "movq 15*8(%[residue]),%%mm4\n\t"
+    /*#6 Bias low  residue.*/
+    "paddsw %%mm0,%%mm1\n\t"
+    /*#6 Bias high residue.*/
+    "paddsw %%mm0,%%mm2\n\t"
+    /*#6 Pack to byte.*/
+    "packuswb %%mm2,%%mm1\n\t"
+    /*#7 Bias low  residue.*/
+    "paddsw %%mm0,%%mm3\n\t"
+    /*#7 Bias high residue.*/
+    "paddsw %%mm0,%%mm4\n\t"
+    /*#7 Pack to byte.*/
+    "packuswb %%mm4,%%mm3\n\t"
+    /*#6 Write row.*/
+    "movq %%mm1,(%[dst4],%[ystride],2)\n\t"
+    /*#7 Write row.*/
+    "movq %%mm3,(%[dst4],%[ystride3])\n\t"
+    :
+    :[residue]"r"(_residue),
+     [dst]"r"(_dst),
+     [dst4]"r"(_dst+(_ystride<<2)),
+     [ystride]"r"((ptrdiff_t)_ystride),
+     [ystride3]"r"((ptrdiff_t)_ystride*3)
+    :"memory"
+  );
+}
+
+void oc_frag_recon_inter_mmx(unsigned char *_dst,const unsigned char *_src,
+ int _ystride,const ogg_int16_t *_residue){
+  int i;
+  /*Zero mm0.*/
+  __asm__ __volatile__("pxor %%mm0,%%mm0\n\t"::);
+  for(i=4;i-->0;){
+    __asm__ __volatile__(
+      /*#0 Load source.*/
+      "movq (%[src]),%%mm3\n\t"
+      /*#1 Load source.*/
+      "movq (%[src],%[ystride]),%%mm7\n\t"
+      /*#0 Get copy of src.*/
+      "movq %%mm3,%%mm4\n\t"
+      /*#0 Expand high source.*/
+      "punpckhbw %%mm0,%%mm4\n\t"
+      /*#0 Expand low  source.*/
+      "punpcklbw %%mm0,%%mm3\n\t"
+      /*#0 Add residue high.*/
+      "paddsw 8(%[residue]),%%mm4\n\t"
+      /*#1 Get copy of src.*/
+      "movq %%mm7,%%mm2\n\t"
+      /*#0 Add residue low.*/
+      "paddsw (%[residue]), %%mm3\n\t"
+      /*#1 Expand high source.*/
+      "punpckhbw %%mm0,%%mm2\n\t"
+      /*#0 Pack final row pixels.*/
+      "packuswb %%mm4,%%mm3\n\t"
+      /*#1 Expand low  source.*/
+      "punpcklbw %%mm0,%%mm7\n\t"
+      /*#1 Add residue low.*/
+      "paddsw 16(%[residue]),%%mm7\n\t"
+      /*#1 Add residue high.*/
+      "paddsw 24(%[residue]),%%mm2\n\t"
+      /*Advance residue.*/
+      "lea 32(%[residue]),%[residue]\n\t"
+      /*#1 Pack final row pixels.*/
+      "packuswb %%mm2,%%mm7\n\t"
+      /*Advance src.*/
+      "lea (%[src],%[ystride],2),%[src]\n\t"
+      /*#0 Write row.*/
+      "movq %%mm3,(%[dst])\n\t"
+      /*#1 Write row.*/
+      "movq %%mm7,(%[dst],%[ystride])\n\t"
+      /*Advance dst.*/
+      "lea (%[dst],%[ystride],2),%[dst]\n\t"
+      :[residue]"+r"(_residue),[dst]"+r"(_dst),[src]"+r"(_src)
+      :[ystride]"r"((ptrdiff_t)_ystride)
+      :"memory"
+    );
+  }
+}
+
+void oc_frag_recon_inter2_mmx(unsigned char *_dst,const unsigned char *_src1,
+ const unsigned char *_src2,int _ystride,const ogg_int16_t *_residue){
+  int i;
+  /*Zero mm7.*/
+  __asm__ __volatile__("pxor %%mm7,%%mm7\n\t"::);
+  for(i=4;i-->0;){
+    __asm__ __volatile__(
+      /*#0 Load src1.*/
+      "movq (%[src1]),%%mm0\n\t"
+      /*#0 Load src2.*/
+      "movq (%[src2]),%%mm2\n\t"
+      /*#0 Copy src1.*/
+      "movq %%mm0,%%mm1\n\t"
+      /*#0 Copy src2.*/
+      "movq %%mm2,%%mm3\n\t"
+      /*#1 Load src1.*/
+      "movq (%[src1],%[ystride]),%%mm4\n\t"
+      /*#0 Unpack lower src1.*/
+      "punpcklbw %%mm7,%%mm0\n\t"
+      /*#1 Load src2.*/
+      "movq (%[src2],%[ystride]),%%mm5\n\t"
+      /*#0 Unpack higher src1.*/
+      "punpckhbw %%mm7,%%mm1\n\t"
+      /*#0 Unpack lower src2.*/
+      "punpcklbw %%mm7,%%mm2\n\t"
+      /*#0 Unpack higher src2.*/
+      "punpckhbw %%mm7,%%mm3\n\t"
+      /*Advance src1 ptr.*/
+      "lea (%[src1],%[ystride],2),%[src1]\n\t"
+      /*Advance src2 ptr.*/
+      "lea (%[src2],%[ystride],2),%[src2]\n\t"
+      /*#0 Lower src1+src2.*/
+      "paddsw %%mm2,%%mm0\n\t"
+      /*#0 Higher src1+src2.*/
+      "paddsw %%mm3,%%mm1\n\t"
+      /*#1 Copy src1.*/
+      "movq %%mm4,%%mm2\n\t"
+      /*#0 Build lo average.*/
+      "psraw $1,%%mm0\n\t"
+      /*#1 Copy src2.*/
+      "movq %%mm5,%%mm3\n\t"
+      /*#1 Unpack lower src1.*/
+      "punpcklbw %%mm7,%%mm4\n\t"
+      /*#0 Build hi average.*/
+      "psraw $1,%%mm1\n\t"
+      /*#1 Unpack higher src1.*/
+      "punpckhbw %%mm7,%%mm2\n\t"
+      /*#0 low+=residue.*/
+      "paddsw (%[residue]),%%mm0\n\t"
+      /*#1 Unpack lower src2.*/
+      "punpcklbw %%mm7,%%mm5\n\t"
+      /*#0 high+=residue.*/
+      "paddsw 8(%[residue]),%%mm1\n\t"
+      /*#1 Unpack higher src2.*/
+      "punpckhbw %%mm7,%%mm3\n\t"
+      /*#1 Lower src1+src2.*/
+      "paddsw %%mm4,%%mm5\n\t"
+      /*#0 Pack and saturate.*/
+      "packuswb %%mm1,%%mm0\n\t"
+      /*#1 Higher src1+src2.*/
+      "paddsw %%mm2,%%mm3\n\t"
+      /*#0 Write row.*/
+      "movq %%mm0,(%[dst])\n\t"
+      /*#1 Build lo average.*/
+      "psraw $1,%%mm5\n\t"
+      /*#1 Build hi average.*/
+      "psraw $1,%%mm3\n\t"
+      /*#1 low+=residue.*/
+      "paddsw 16(%[residue]),%%mm5\n\t"
+      /*#1 high+=residue.*/
+      "paddsw 24(%[residue]),%%mm3\n\t"
+      /*#1 Pack and saturate.*/
+      "packuswb  %%mm3,%%mm5\n\t"
+      /*#1 Write row ptr.*/
+      "movq %%mm5,(%[dst],%[ystride])\n\t"
+      /*Advance residue ptr.*/
+      "add $32,%[residue]\n\t"
+      /*Advance dest ptr.*/
+      "lea (%[dst],%[ystride],2),%[dst]\n\t"
+     :[dst]"+r"(_dst),[residue]"+r"(_residue),
+      [src1]"+%r"(_src1),[src2]"+r"(_src2)
+     :[ystride]"r"((ptrdiff_t)_ystride)
+     :"memory"
+    );
+  }
+}
+
+void oc_restore_fpu_mmx(void){
+  __asm__ __volatile__("emms\n\t");
+}
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/mmxfrag.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/mmxfrag.h
new file mode 100644
index 0000000..a398427
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/mmxfrag.h
@@ -0,0 +1,64 @@
+#if !defined(_x86_mmxfrag_H)
+# define _x86_mmxfrag_H (1)
+# include <stddef.h>
+# include "x86int.h"
+
+#if defined(OC_X86_ASM)
+
+/*Copies an 8x8 block of pixels from _src to _dst, assuming _ystride bytes
+   between rows.*/
+#define OC_FRAG_COPY_MMX(_dst,_src,_ystride) \
+  do{ \
+    const unsigned char *src; \
+    unsigned char       *dst; \
+    ptrdiff_t            ystride3; \
+    src=(_src); \
+    dst=(_dst); \
+    __asm__ __volatile__( \
+      /*src+0*ystride*/ \
+      "movq (%[src]),%%mm0\n\t" \
+      /*src+1*ystride*/ \
+      "movq (%[src],%[ystride]),%%mm1\n\t" \
+      /*ystride3=ystride*3*/ \
+      "lea (%[ystride],%[ystride],2),%[ystride3]\n\t" \
+      /*src+2*ystride*/ \
+      "movq (%[src],%[ystride],2),%%mm2\n\t" \
+      /*src+3*ystride*/ \
+      "movq (%[src],%[ystride3]),%%mm3\n\t" \
+      /*dst+0*ystride*/ \
+      "movq %%mm0,(%[dst])\n\t" \
+      /*dst+1*ystride*/ \
+      "movq %%mm1,(%[dst],%[ystride])\n\t" \
+      /*Pointer to next 4.*/ \
+      "lea (%[src],%[ystride],4),%[src]\n\t" \
+      /*dst+2*ystride*/ \
+      "movq %%mm2,(%[dst],%[ystride],2)\n\t" \
+      /*dst+3*ystride*/ \
+      "movq %%mm3,(%[dst],%[ystride3])\n\t" \
+      /*Pointer to next 4.*/ \
+      "lea (%[dst],%[ystride],4),%[dst]\n\t" \
+      /*src+0*ystride*/ \
+      "movq (%[src]),%%mm0\n\t" \
+      /*src+1*ystride*/ \
+      "movq (%[src],%[ystride]),%%mm1\n\t" \
+      /*src+2*ystride*/ \
+      "movq (%[src],%[ystride],2),%%mm2\n\t" \
+      /*src+3*ystride*/ \
+      "movq (%[src],%[ystride3]),%%mm3\n\t" \
+      /*dst+0*ystride*/ \
+      "movq %%mm0,(%[dst])\n\t" \
+      /*dst+1*ystride*/ \
+      "movq %%mm1,(%[dst],%[ystride])\n\t" \
+      /*dst+2*ystride*/ \
+      "movq %%mm2,(%[dst],%[ystride],2)\n\t" \
+      /*dst+3*ystride*/ \
+      "movq %%mm3,(%[dst],%[ystride3])\n\t" \
+      :[dst]"+r"(dst),[src]"+r"(src),[ystride3]"=&r"(ystride3) \
+      :[ystride]"r"((ptrdiff_t)(_ystride)) \
+      :"memory" \
+    ); \
+  } \
+  while(0)
+
+# endif
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/mmxidct.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/mmxidct.c
new file mode 100644
index 0000000..b9c8944
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/mmxidct.c
@@ -0,0 +1,651 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: mmxidct.c 16019 2009-05-20 01:36:41Z tterribe $
+
+ ********************************************************************/
+
+/*MMX acceleration of Theora's iDCT.
+  Originally written by Rudolf Marek, based on code from On2's VP3.*/
+#include "x86int.h"
+#include "../dct.h"
+
+#if defined(OC_X86_ASM)
+
+/*These are offsets into the table of constants below.*/
+/*7 rows of cosines, in order: pi/16 * (1 ... 7).*/
+#define OC_COSINE_OFFSET (0)
+/*A row of 8's.*/
+#define OC_EIGHT_OFFSET  (56)
+
+
+
+/*A table of constants used by the MMX routines.*/
+static const ogg_uint16_t __attribute__((aligned(8),used))
+ OC_IDCT_CONSTS[(7+1)*4]={
+  (ogg_uint16_t)OC_C1S7,(ogg_uint16_t)OC_C1S7,
+  (ogg_uint16_t)OC_C1S7,(ogg_uint16_t)OC_C1S7,
+  (ogg_uint16_t)OC_C2S6,(ogg_uint16_t)OC_C2S6,
+  (ogg_uint16_t)OC_C2S6,(ogg_uint16_t)OC_C2S6,
+  (ogg_uint16_t)OC_C3S5,(ogg_uint16_t)OC_C3S5,
+  (ogg_uint16_t)OC_C3S5,(ogg_uint16_t)OC_C3S5,
+  (ogg_uint16_t)OC_C4S4,(ogg_uint16_t)OC_C4S4,
+  (ogg_uint16_t)OC_C4S4,(ogg_uint16_t)OC_C4S4,
+  (ogg_uint16_t)OC_C5S3,(ogg_uint16_t)OC_C5S3,
+  (ogg_uint16_t)OC_C5S3,(ogg_uint16_t)OC_C5S3,
+  (ogg_uint16_t)OC_C6S2,(ogg_uint16_t)OC_C6S2,
+  (ogg_uint16_t)OC_C6S2,(ogg_uint16_t)OC_C6S2,
+  (ogg_uint16_t)OC_C7S1,(ogg_uint16_t)OC_C7S1,
+  (ogg_uint16_t)OC_C7S1,(ogg_uint16_t)OC_C7S1,
+      8,    8,    8,    8
+};
+
+/*Converts the expression in the argument to a string.*/
+#define OC_M2STR(_s) #_s
+
+/*38 cycles*/
+#define OC_IDCT_BEGIN \
+  "#OC_IDCT_BEGIN\n\t" \
+  "movq "OC_I(3)",%%mm2\n\t" \
+  "movq "OC_C(3)",%%mm6\n\t" \
+  "movq %%mm2,%%mm4\n\t" \
+  "movq "OC_J(5)",%%mm7\n\t" \
+  "pmulhw %%mm6,%%mm4\n\t" \
+  "movq "OC_C(5)",%%mm1\n\t" \
+  "pmulhw %%mm7,%%mm6\n\t" \
+  "movq %%mm1,%%mm5\n\t" \
+  "pmulhw %%mm2,%%mm1\n\t" \
+  "movq "OC_I(1)",%%mm3\n\t" \
+  "pmulhw %%mm7,%%mm5\n\t" \
+  "movq "OC_C(1)",%%mm0\n\t" \
+  "paddw %%mm2,%%mm4\n\t" \
+  "paddw %%mm7,%%mm6\n\t" \
+  "paddw %%mm1,%%mm2\n\t" \
+  "movq "OC_J(7)",%%mm1\n\t" \
+  "paddw %%mm5,%%mm7\n\t" \
+  "movq %%mm0,%%mm5\n\t" \
+  "pmulhw %%mm3,%%mm0\n\t" \
+  "paddw %%mm7,%%mm4\n\t" \
+  "pmulhw %%mm1,%%mm5\n\t" \
+  "movq "OC_C(7)",%%mm7\n\t" \
+  "psubw %%mm2,%%mm6\n\t" \
+  "paddw %%mm3,%%mm0\n\t" \
+  "pmulhw %%mm7,%%mm3\n\t" \
+  "movq "OC_I(2)",%%mm2\n\t" \
+  "pmulhw %%mm1,%%mm7\n\t" \
+  "paddw %%mm1,%%mm5\n\t" \
+  "movq %%mm2,%%mm1\n\t" \
+  "pmulhw "OC_C(2)",%%mm2\n\t" \
+  "psubw %%mm5,%%mm3\n\t" \
+  "movq "OC_J(6)",%%mm5\n\t" \
+  "paddw %%mm7,%%mm0\n\t" \
+  "movq %%mm5,%%mm7\n\t" \
+  "psubw %%mm4,%%mm0\n\t" \
+  "pmulhw "OC_C(2)",%%mm5\n\t" \
+  "paddw %%mm1,%%mm2\n\t" \
+  "pmulhw "OC_C(6)",%%mm1\n\t" \
+  "paddw %%mm4,%%mm4\n\t" \
+  "paddw %%mm0,%%mm4\n\t" \
+  "psubw %%mm6,%%mm3\n\t" \
+  "paddw %%mm7,%%mm5\n\t" \
+  "paddw %%mm6,%%mm6\n\t" \
+  "pmulhw "OC_C(6)",%%mm7\n\t" \
+  "paddw %%mm3,%%mm6\n\t" \
+  "movq %%mm4,"OC_I(1)"\n\t" \
+  "psubw %%mm5,%%mm1\n\t" \
+  "movq "OC_C(4)",%%mm4\n\t" \
+  "movq %%mm3,%%mm5\n\t" \
+  "pmulhw %%mm4,%%mm3\n\t" \
+  "paddw %%mm2,%%mm7\n\t" \
+  "movq %%mm6,"OC_I(2)"\n\t" \
+  "movq %%mm0,%%mm2\n\t" \
+  "movq "OC_I(0)",%%mm6\n\t" \
+  "pmulhw %%mm4,%%mm0\n\t" \
+  "paddw %%mm3,%%mm5\n\t" \
+  "movq "OC_J(4)",%%mm3\n\t" \
+  "psubw %%mm1,%%mm5\n\t" \
+  "paddw %%mm0,%%mm2\n\t" \
+  "psubw %%mm3,%%mm6\n\t" \
+  "movq %%mm6,%%mm0\n\t" \
+  "pmulhw %%mm4,%%mm6\n\t" \
+  "paddw %%mm3,%%mm3\n\t" \
+  "paddw %%mm1,%%mm1\n\t" \
+  "paddw %%mm0,%%mm3\n\t" \
+  "paddw %%mm5,%%mm1\n\t" \
+  "pmulhw %%mm3,%%mm4\n\t" \
+  "paddw %%mm0,%%mm6\n\t" \
+  "psubw %%mm2,%%mm6\n\t" \
+  "paddw %%mm2,%%mm2\n\t" \
+  "movq "OC_I(1)",%%mm0\n\t" \
+  "paddw %%mm6,%%mm2\n\t" \
+  "paddw %%mm3,%%mm4\n\t" \
+  "psubw %%mm1,%%mm2\n\t" \
+  "#end OC_IDCT_BEGIN\n\t" \
+
+/*38+8=46 cycles.*/
+#define OC_ROW_IDCT \
+  "#OC_ROW_IDCT\n" \
+  OC_IDCT_BEGIN \
+  /*r3=D'*/ \
+  "movq "OC_I(2)",%%mm3\n\t" \
+  /*r4=E'=E-G*/ \
+  "psubw %%mm7,%%mm4\n\t" \
+  /*r1=H'+H'*/ \
+  "paddw %%mm1,%%mm1\n\t" \
+  /*r7=G+G*/ \
+  "paddw %%mm7,%%mm7\n\t" \
+  /*r1=R1=A''+H'*/ \
+  "paddw %%mm2,%%mm1\n\t" \
+  /*r7=G'=E+G*/ \
+  "paddw %%mm4,%%mm7\n\t" \
+  /*r4=R4=E'-D'*/ \
+  "psubw %%mm3,%%mm4\n\t" \
+  "paddw %%mm3,%%mm3\n\t" \
+  /*r6=R6=F'-B''*/ \
+  "psubw %%mm5,%%mm6\n\t" \
+  "paddw %%mm5,%%mm5\n\t" \
+  /*r3=R3=E'+D'*/ \
+  "paddw %%mm4,%%mm3\n\t" \
+  /*r5=R5=F'+B''*/ \
+  "paddw %%mm6,%%mm5\n\t" \
+  /*r7=R7=G'-C'*/ \
+  "psubw %%mm0,%%mm7\n\t" \
+  "paddw %%mm0,%%mm0\n\t" \
+  /*Save R1.*/ \
+  "movq %%mm1,"OC_I(1)"\n\t" \
+  /*r0=R0=G.+C.*/ \
+  "paddw %%mm7,%%mm0\n\t" \
+  "#end OC_ROW_IDCT\n\t" \
+
+/*The following macro does two 4x4 transposes in place.
+  At entry, we assume:
+    r0 = a3 a2 a1 a0
+  I(1) = b3 b2 b1 b0
+    r2 = c3 c2 c1 c0
+    r3 = d3 d2 d1 d0
+
+    r4 = e3 e2 e1 e0
+    r5 = f3 f2 f1 f0
+    r6 = g3 g2 g1 g0
+    r7 = h3 h2 h1 h0
+
+  At exit, we have:
+  I(0) = d0 c0 b0 a0
+  I(1) = d1 c1 b1 a1
+  I(2) = d2 c2 b2 a2
+  I(3) = d3 c3 b3 a3
+
+  J(4) = h0 g0 f0 e0
+  J(5) = h1 g1 f1 e1
+  J(6) = h2 g2 f2 e2
+  J(7) = h3 g3 f3 e3
+
+  I(0) I(1) I(2) I(3) is the transpose of r0 I(1) r2 r3.
+  J(4) J(5) J(6) J(7) is the transpose of r4  r5  r6 r7.
+
+  Since r1 is free at entry, we calculate the Js first.*/
+/*19 cycles.*/
+#define OC_TRANSPOSE \
+  "#OC_TRANSPOSE\n\t" \
+  "movq %%mm4,%%mm1\n\t" \
+  "punpcklwd %%mm5,%%mm4\n\t" \
+  "movq %%mm0,"OC_I(0)"\n\t" \
+  "punpckhwd %%mm5,%%mm1\n\t" \
+  "movq %%mm6,%%mm0\n\t" \
+  "punpcklwd %%mm7,%%mm6\n\t" \
+  "movq %%mm4,%%mm5\n\t" \
+  "punpckldq %%mm6,%%mm4\n\t" \
+  "punpckhdq %%mm6,%%mm5\n\t" \
+  "movq %%mm1,%%mm6\n\t" \
+  "movq %%mm4,"OC_J(4)"\n\t" \
+  "punpckhwd %%mm7,%%mm0\n\t" \
+  "movq %%mm5,"OC_J(5)"\n\t" \
+  "punpckhdq %%mm0,%%mm6\n\t" \
+  "movq "OC_I(0)",%%mm4\n\t" \
+  "punpckldq %%mm0,%%mm1\n\t" \
+  "movq "OC_I(1)",%%mm5\n\t" \
+  "movq %%mm4,%%mm0\n\t" \
+  "movq %%mm6,"OC_J(7)"\n\t" \
+  "punpcklwd %%mm5,%%mm0\n\t" \
+  "movq %%mm1,"OC_J(6)"\n\t" \
+  "punpckhwd %%mm5,%%mm4\n\t" \
+  "movq %%mm2,%%mm5\n\t" \
+  "punpcklwd %%mm3,%%mm2\n\t" \
+  "movq %%mm0,%%mm1\n\t" \
+  "punpckldq %%mm2,%%mm0\n\t" \
+  "punpckhdq %%mm2,%%mm1\n\t" \
+  "movq %%mm4,%%mm2\n\t" \
+  "movq %%mm0,"OC_I(0)"\n\t" \
+  "punpckhwd %%mm3,%%mm5\n\t" \
+  "movq %%mm1,"OC_I(1)"\n\t" \
+  "punpckhdq %%mm5,%%mm4\n\t" \
+  "punpckldq %%mm5,%%mm2\n\t" \
+  "movq %%mm4,"OC_I(3)"\n\t" \
+  "movq %%mm2,"OC_I(2)"\n\t" \
+  "#end OC_TRANSPOSE\n\t" \
+
+/*38+19=57 cycles.*/
+#define OC_COLUMN_IDCT \
+  "#OC_COLUMN_IDCT\n" \
+  OC_IDCT_BEGIN \
+  "paddw "OC_8",%%mm2\n\t" \
+  /*r1=H'+H'*/ \
+  "paddw %%mm1,%%mm1\n\t" \
+  /*r1=R1=A''+H'*/ \
+  "paddw %%mm2,%%mm1\n\t" \
+  /*r2=NR2*/ \
+  "psraw $4,%%mm2\n\t" \
+  /*r4=E'=E-G*/ \
+  "psubw %%mm7,%%mm4\n\t" \
+  /*r1=NR1*/ \
+  "psraw $4,%%mm1\n\t" \
+  /*r3=D'*/ \
+  "movq "OC_I(2)",%%mm3\n\t" \
+  /*r7=G+G*/ \
+  "paddw %%mm7,%%mm7\n\t" \
+  /*Store NR2 at I(2).*/ \
+  "movq %%mm2,"OC_I(2)"\n\t" \
+  /*r7=G'=E+G*/ \
+  "paddw %%mm4,%%mm7\n\t" \
+  /*Store NR1 at I(1).*/ \
+  "movq %%mm1,"OC_I(1)"\n\t" \
+  /*r4=R4=E'-D'*/ \
+  "psubw %%mm3,%%mm4\n\t" \
+  "paddw "OC_8",%%mm4\n\t" \
+  /*r3=D'+D'*/ \
+  "paddw %%mm3,%%mm3\n\t" \
+  /*r3=R3=E'+D'*/ \
+  "paddw %%mm4,%%mm3\n\t" \
+  /*r4=NR4*/ \
+  "psraw $4,%%mm4\n\t" \
+  /*r6=R6=F'-B''*/ \
+  "psubw %%mm5,%%mm6\n\t" \
+  /*r3=NR3*/ \
+  "psraw $4,%%mm3\n\t" \
+  "paddw "OC_8",%%mm6\n\t" \
+  /*r5=B''+B''*/ \
+  "paddw %%mm5,%%mm5\n\t" \
+  /*r5=R5=F'+B''*/ \
+  "paddw %%mm6,%%mm5\n\t" \
+  /*r6=NR6*/ \
+  "psraw $4,%%mm6\n\t" \
+  /*Store NR4 at J(4).*/ \
+  "movq %%mm4,"OC_J(4)"\n\t" \
+  /*r5=NR5*/ \
+  "psraw $4,%%mm5\n\t" \
+  /*Store NR3 at I(3).*/ \
+  "movq %%mm3,"OC_I(3)"\n\t" \
+  /*r7=R7=G'-C'*/ \
+  "psubw %%mm0,%%mm7\n\t" \
+  "paddw "OC_8",%%mm7\n\t" \
+  /*r0=C'+C'*/ \
+  "paddw %%mm0,%%mm0\n\t" \
+  /*r0=R0=G'+C'*/ \
+  "paddw %%mm7,%%mm0\n\t" \
+  /*r7=NR7*/ \
+  "psraw $4,%%mm7\n\t" \
+  /*Store NR6 at J(6).*/ \
+  "movq %%mm6,"OC_J(6)"\n\t" \
+  /*r0=NR0*/ \
+  "psraw $4,%%mm0\n\t" \
+  /*Store NR5 at J(5).*/ \
+  "movq %%mm5,"OC_J(5)"\n\t" \
+  /*Store NR7 at J(7).*/ \
+  "movq %%mm7,"OC_J(7)"\n\t" \
+  /*Store NR0 at I(0).*/ \
+  "movq %%mm0,"OC_I(0)"\n\t" \
+  "#end OC_COLUMN_IDCT\n\t" \
+
+#define OC_MID(_m,_i) OC_M2STR(_m+(_i)*8)"(%[c])"
+#define OC_C(_i)      OC_MID(OC_COSINE_OFFSET,_i-1)
+#define OC_8          OC_MID(OC_EIGHT_OFFSET,0)
+
+static void oc_idct8x8_slow(ogg_int16_t _y[64]){
+  /*This routine accepts an 8x8 matrix, but in partially transposed form.
+    Every 4x4 block is transposed.*/
+  __asm__ __volatile__(
+#define OC_I(_k)      OC_M2STR((_k*16))"(%[y])"
+#define OC_J(_k)      OC_M2STR(((_k-4)*16)+8)"(%[y])"
+    OC_ROW_IDCT
+    OC_TRANSPOSE
+#undef  OC_I
+#undef  OC_J
+#define OC_I(_k)      OC_M2STR((_k*16)+64)"(%[y])"
+#define OC_J(_k)      OC_M2STR(((_k-4)*16)+72)"(%[y])"
+    OC_ROW_IDCT
+    OC_TRANSPOSE
+#undef  OC_I
+#undef  OC_J
+#define OC_I(_k)      OC_M2STR((_k*16))"(%[y])"
+#define OC_J(_k)      OC_I(_k)
+    OC_COLUMN_IDCT
+#undef  OC_I
+#undef  OC_J
+#define OC_I(_k)      OC_M2STR((_k*16)+8)"(%[y])"
+#define OC_J(_k)      OC_I(_k)
+    OC_COLUMN_IDCT
+#undef  OC_I
+#undef  OC_J
+    :
+    :[y]"r"(_y),[c]"r"(OC_IDCT_CONSTS)
+  );
+}
+
+/*25 cycles.*/
+#define OC_IDCT_BEGIN_10 \
+ "#OC_IDCT_BEGIN_10\n\t" \
+ "movq "OC_I(3)",%%mm2\n\t" \
+ "nop\n\t" \
+ "movq "OC_C(3)",%%mm6\n\t" \
+ "movq %%mm2,%%mm4\n\t" \
+ "movq "OC_C(5)",%%mm1\n\t" \
+ "pmulhw %%mm6,%%mm4\n\t" \
+ "movq "OC_I(1)",%%mm3\n\t" \
+ "pmulhw %%mm2,%%mm1\n\t" \
+ "movq "OC_C(1)",%%mm0\n\t" \
+ "paddw %%mm2,%%mm4\n\t" \
+ "pxor %%mm6,%%mm6\n\t" \
+ "paddw %%mm1,%%mm2\n\t" \
+ "movq "OC_I(2)",%%mm5\n\t" \
+ "pmulhw %%mm3,%%mm0\n\t" \
+ "movq %%mm5,%%mm1\n\t" \
+ "paddw %%mm3,%%mm0\n\t" \
+ "pmulhw "OC_C(7)",%%mm3\n\t" \
+ "psubw %%mm2,%%mm6\n\t" \
+ "pmulhw "OC_C(2)",%%mm5\n\t" \
+ "psubw %%mm4,%%mm0\n\t" \
+ "movq "OC_I(2)",%%mm7\n\t" \
+ "paddw %%mm4,%%mm4\n\t" \
+ "paddw %%mm5,%%mm7\n\t" \
+ "paddw %%mm0,%%mm4\n\t" \
+ "pmulhw "OC_C(6)",%%mm1\n\t" \
+ "psubw %%mm6,%%mm3\n\t" \
+ "movq %%mm4,"OC_I(1)"\n\t" \
+ "paddw %%mm6,%%mm6\n\t" \
+ "movq "OC_C(4)",%%mm4\n\t" \
+ "paddw %%mm3,%%mm6\n\t" \
+ "movq %%mm3,%%mm5\n\t" \
+ "pmulhw %%mm4,%%mm3\n\t" \
+ "movq %%mm6,"OC_I(2)"\n\t" \
+ "movq %%mm0,%%mm2\n\t" \
+ "movq "OC_I(0)",%%mm6\n\t" \
+ "pmulhw %%mm4,%%mm0\n\t" \
+ "paddw %%mm3,%%mm5\n\t" \
+ "paddw %%mm0,%%mm2\n\t" \
+ "psubw %%mm1,%%mm5\n\t" \
+ "pmulhw %%mm4,%%mm6\n\t" \
+ "paddw "OC_I(0)",%%mm6\n\t" \
+ "paddw %%mm1,%%mm1\n\t" \
+ "movq %%mm6,%%mm4\n\t" \
+ "paddw %%mm5,%%mm1\n\t" \
+ "psubw %%mm2,%%mm6\n\t" \
+ "paddw %%mm2,%%mm2\n\t" \
+ "movq "OC_I(1)",%%mm0\n\t" \
+ "paddw %%mm6,%%mm2\n\t" \
+ "psubw %%mm1,%%mm2\n\t" \
+ "nop\n\t" \
+ "#end OC_IDCT_BEGIN_10\n\t" \
+
+/*25+8=33 cycles.*/
+#define OC_ROW_IDCT_10 \
+ "#OC_ROW_IDCT_10\n\t" \
+ OC_IDCT_BEGIN_10 \
+ /*r3=D'*/ \
+ "movq "OC_I(2)",%%mm3\n\t" \
+ /*r4=E'=E-G*/ \
+ "psubw %%mm7,%%mm4\n\t" \
+ /*r1=H'+H'*/ \
+ "paddw %%mm1,%%mm1\n\t" \
+ /*r7=G+G*/ \
+ "paddw %%mm7,%%mm7\n\t" \
+ /*r1=R1=A''+H'*/ \
+ "paddw %%mm2,%%mm1\n\t" \
+ /*r7=G'=E+G*/ \
+ "paddw %%mm4,%%mm7\n\t" \
+ /*r4=R4=E'-D'*/ \
+ "psubw %%mm3,%%mm4\n\t" \
+ "paddw %%mm3,%%mm3\n\t" \
+ /*r6=R6=F'-B''*/ \
+ "psubw %%mm5,%%mm6\n\t" \
+ "paddw %%mm5,%%mm5\n\t" \
+ /*r3=R3=E'+D'*/ \
+ "paddw %%mm4,%%mm3\n\t" \
+ /*r5=R5=F'+B''*/ \
+ "paddw %%mm6,%%mm5\n\t" \
+ /*r7=R7=G'-C'*/ \
+ "psubw %%mm0,%%mm7\n\t" \
+ "paddw %%mm0,%%mm0\n\t" \
+ /*Save R1.*/ \
+ "movq %%mm1,"OC_I(1)"\n\t" \
+ /*r0=R0=G'+C'*/ \
+ "paddw %%mm7,%%mm0\n\t" \
+ "#end OC_ROW_IDCT_10\n\t" \
+
+/*25+19=44 cycles'*/
+#define OC_COLUMN_IDCT_10 \
+ "#OC_COLUMN_IDCT_10\n\t" \
+ OC_IDCT_BEGIN_10 \
+ "paddw "OC_8",%%mm2\n\t" \
+ /*r1=H'+H'*/ \
+ "paddw %%mm1,%%mm1\n\t" \
+ /*r1=R1=A''+H'*/ \
+ "paddw %%mm2,%%mm1\n\t" \
+ /*r2=NR2*/ \
+ "psraw $4,%%mm2\n\t" \
+ /*r4=E'=E-G*/ \
+ "psubw %%mm7,%%mm4\n\t" \
+ /*r1=NR1*/ \
+ "psraw $4,%%mm1\n\t" \
+ /*r3=D'*/ \
+ "movq "OC_I(2)",%%mm3\n\t" \
+ /*r7=G+G*/ \
+ "paddw %%mm7,%%mm7\n\t" \
+ /*Store NR2 at I(2).*/ \
+ "movq %%mm2,"OC_I(2)"\n\t" \
+ /*r7=G'=E+G*/ \
+ "paddw %%mm4,%%mm7\n\t" \
+ /*Store NR1 at I(1).*/ \
+ "movq %%mm1,"OC_I(1)"\n\t" \
+ /*r4=R4=E'-D'*/ \
+ "psubw %%mm3,%%mm4\n\t" \
+ "paddw "OC_8",%%mm4\n\t" \
+ /*r3=D'+D'*/ \
+ "paddw %%mm3,%%mm3\n\t" \
+ /*r3=R3=E'+D'*/ \
+ "paddw %%mm4,%%mm3\n\t" \
+ /*r4=NR4*/ \
+ "psraw $4,%%mm4\n\t" \
+ /*r6=R6=F'-B''*/ \
+ "psubw %%mm5,%%mm6\n\t" \
+ /*r3=NR3*/ \
+ "psraw $4,%%mm3\n\t" \
+ "paddw "OC_8",%%mm6\n\t" \
+ /*r5=B''+B''*/ \
+ "paddw %%mm5,%%mm5\n\t" \
+ /*r5=R5=F'+B''*/ \
+ "paddw %%mm6,%%mm5\n\t" \
+ /*r6=NR6*/ \
+ "psraw $4,%%mm6\n\t" \
+ /*Store NR4 at J(4).*/ \
+ "movq %%mm4,"OC_J(4)"\n\t" \
+ /*r5=NR5*/ \
+ "psraw $4,%%mm5\n\t" \
+ /*Store NR3 at I(3).*/ \
+ "movq %%mm3,"OC_I(3)"\n\t" \
+ /*r7=R7=G'-C'*/ \
+ "psubw %%mm0,%%mm7\n\t" \
+ "paddw "OC_8",%%mm7\n\t" \
+ /*r0=C'+C'*/ \
+ "paddw %%mm0,%%mm0\n\t" \
+ /*r0=R0=G'+C'*/ \
+ "paddw %%mm7,%%mm0\n\t" \
+ /*r7=NR7*/ \
+ "psraw $4,%%mm7\n\t" \
+ /*Store NR6 at J(6).*/ \
+ "movq %%mm6,"OC_J(6)"\n\t" \
+ /*r0=NR0*/ \
+ "psraw $4,%%mm0\n\t" \
+ /*Store NR5 at J(5).*/ \
+ "movq %%mm5,"OC_J(5)"\n\t" \
+ /*Store NR7 at J(7).*/ \
+ "movq %%mm7,"OC_J(7)"\n\t" \
+ /*Store NR0 at I(0).*/ \
+ "movq %%mm0,"OC_I(0)"\n\t" \
+ "#end OC_COLUMN_IDCT_10\n\t" \
+
+static void oc_idct8x8_10(ogg_int16_t _y[64]){
+  __asm__ __volatile__(
+#define OC_I(_k) OC_M2STR((_k*16))"(%[y])"
+#define OC_J(_k) OC_M2STR(((_k-4)*16)+8)"(%[y])"
+    /*Done with dequant, descramble, and partial transpose.
+      Now do the iDCT itself.*/
+    OC_ROW_IDCT_10
+    OC_TRANSPOSE
+#undef  OC_I
+#undef  OC_J
+#define OC_I(_k) OC_M2STR((_k*16))"(%[y])"
+#define OC_J(_k) OC_I(_k)
+    OC_COLUMN_IDCT_10
+#undef  OC_I
+#undef  OC_J
+#define OC_I(_k) OC_M2STR((_k*16)+8)"(%[y])"
+#define OC_J(_k) OC_I(_k)
+    OC_COLUMN_IDCT_10
+#undef  OC_I
+#undef  OC_J
+    :
+    :[y]"r"(_y),[c]"r"(OC_IDCT_CONSTS)
+  );
+}
+
+/*This table has been modified from OC_FZIG_ZAG by baking a 4x4 transpose into
+   each quadrant of the destination.*/
+static const unsigned char OC_FZIG_ZAG_MMX[64]={
+   0, 8, 1, 2, 9,16,24,17,
+  10, 3,32,11,18,25, 4,12,
+   5,26,19,40,33,34,41,48,
+  27, 6,13,20,28,21,14, 7,
+  56,49,42,35,43,50,57,36,
+  15,22,29,30,23,44,37,58,
+  51,59,38,45,52,31,60,53,
+  46,39,47,54,61,62,55,63
+};
+
+/*Performs an inverse 8x8 Type-II DCT transform.
+  The input is assumed to be scaled by a factor of 4 relative to orthonormal
+   version of the transform.
+  _y: The buffer to store the result in.
+      This must not be the same as _x.
+  _x: The input coefficients.*/
+void oc_dequant_idct8x8_mmx(ogg_int16_t _y[64],const ogg_int16_t _x[64],
+ int _last_zzi,int _ncoefs,ogg_uint16_t _dc_quant,
+ const ogg_uint16_t _ac_quant[64]){
+  /*_last_zzi is subtly different from an actual count of the number of
+     coefficients we decoded for this block.
+    It contains the value of zzi BEFORE the final token in the block was
+     decoded.
+    In most cases this is an EOB token (the continuation of an EOB run from a
+     previous block counts), and so this is the same as the coefficient count.
+    However, in the case that the last token was NOT an EOB token, but filled
+     the block up with exactly 64 coefficients, _last_zzi will be less than 64.
+    Provided the last token was not a pure zero run, the minimum value it can
+     be is 46, and so that doesn't affect any of the cases in this routine.
+    However, if the last token WAS a pure zero run of length 63, then _last_zzi
+     will be 1 while the number of coefficients decoded is 64.
+    Thus, we will trigger the following special case, where the real
+     coefficient count would not.
+    Note also that a zero run of length 64 will give _last_zzi a value of 0,
+     but we still process the DC coefficient, which might have a non-zero value
+     due to DC prediction.
+    Although convoluted, this is arguably the correct behavior: it allows us to
+     dequantize fewer coefficients and use a smaller transform when the block
+     ends with a long zero run instead of a normal EOB token.
+    It could be smarter... multiple separate zero runs at the end of a block
+     will fool it, but an encoder that generates these really deserves what it
+     gets.
+    Needless to say we inherited this approach from VP3.*/
+  /*Special case only having a DC component.*/
+  if(_last_zzi<2){
+    /*Note that this value must be unsigned, to keep the __asm__ block from
+       sign-extending it when it puts it in a register.*/
+    ogg_uint16_t p;
+    /*We round this dequant product (and not any of the others) because there's
+       no iDCT rounding.*/
+    p=(ogg_int16_t)(_x[0]*(ogg_int32_t)_dc_quant+15>>5);
+    /*Fill _y with p.*/
+    __asm__ __volatile__(
+      /*mm0=0000 0000 0000 AAAA*/
+      "movd %[p],%%mm0\n\t"
+      /*mm0=0000 0000 AAAA AAAA*/
+      "punpcklwd %%mm0,%%mm0\n\t"
+      /*mm0=AAAA AAAA AAAA AAAA*/
+      "punpckldq %%mm0,%%mm0\n\t"
+      "movq %%mm0,(%[y])\n\t"
+      "movq %%mm0,8(%[y])\n\t"
+      "movq %%mm0,16(%[y])\n\t"
+      "movq %%mm0,24(%[y])\n\t"
+      "movq %%mm0,32(%[y])\n\t"
+      "movq %%mm0,40(%[y])\n\t"
+      "movq %%mm0,48(%[y])\n\t"
+      "movq %%mm0,56(%[y])\n\t"
+      "movq %%mm0,64(%[y])\n\t"
+      "movq %%mm0,72(%[y])\n\t"
+      "movq %%mm0,80(%[y])\n\t"
+      "movq %%mm0,88(%[y])\n\t"
+      "movq %%mm0,96(%[y])\n\t"
+      "movq %%mm0,104(%[y])\n\t"
+      "movq %%mm0,112(%[y])\n\t"
+      "movq %%mm0,120(%[y])\n\t"
+      :
+      :[y]"r"(_y),[p]"r"((unsigned)p)
+      :"memory"
+    );
+  }
+  else{
+    int zzi;
+    /*First zero the buffer.*/
+    /*On K7, etc., this could be replaced with movntq and sfence.*/
+    __asm__ __volatile__(
+      "pxor %%mm0,%%mm0\n\t"
+      "movq %%mm0,(%[y])\n\t"
+      "movq %%mm0,8(%[y])\n\t"
+      "movq %%mm0,16(%[y])\n\t"
+      "movq %%mm0,24(%[y])\n\t"
+      "movq %%mm0,32(%[y])\n\t"
+      "movq %%mm0,40(%[y])\n\t"
+      "movq %%mm0,48(%[y])\n\t"
+      "movq %%mm0,56(%[y])\n\t"
+      "movq %%mm0,64(%[y])\n\t"
+      "movq %%mm0,72(%[y])\n\t"
+      "movq %%mm0,80(%[y])\n\t"
+      "movq %%mm0,88(%[y])\n\t"
+      "movq %%mm0,96(%[y])\n\t"
+      "movq %%mm0,104(%[y])\n\t"
+      "movq %%mm0,112(%[y])\n\t"
+      "movq %%mm0,120(%[y])\n\t"
+      :
+      :[y]"r"(_y)
+      :"memory"
+    );
+    /*Dequantize the coefficients.*/
+    _y[0]=(ogg_int16_t)(_x[0]*(int)_dc_quant);
+    for(zzi=1;zzi<_ncoefs;zzi++){
+      _y[OC_FZIG_ZAG_MMX[zzi]]=(ogg_int16_t)(_x[zzi]*(int)_ac_quant[zzi]);
+    }
+    /*Then perform the iDCT.*/
+    if(_last_zzi<10)oc_idct8x8_10(_y);
+    else oc_idct8x8_slow(_y);
+  }
+}
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/mmxloop.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/mmxloop.h
new file mode 100644
index 0000000..62088e1
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/mmxloop.h
@@ -0,0 +1,215 @@
+#if !defined(_x86_mmxloop_H)
+# define _x86_mmxloop_H (1)
+# include <stddef.h>
+# include "x86int.h"
+
+#if defined(OC_X86_ASM)
+
+/*On entry, mm0={a0,...,a7}, mm1={b0,...,b7}, mm2={c0,...,c7}, mm3={d0,...d7}.
+  On exit, mm1={b0+lflim(R_0,L),...,b7+lflim(R_7,L)} and
+   mm2={c0-lflim(R_0,L),...,c7-lflim(R_7,L)}; mm0 and mm3 are clobbered.*/
+#define OC_LOOP_FILTER8_MMX \
+ "#OC_LOOP_FILTER8_MMX\n\t" \
+ /*mm7=0*/ \
+ "pxor %%mm7,%%mm7\n\t" \
+ /*mm6:mm0={a0,...,a7}*/ \
+ "movq %%mm0,%%mm6\n\t" \
+ "punpcklbw %%mm7,%%mm0\n\t" \
+ "punpckhbw %%mm7,%%mm6\n\t" \
+ /*mm3:mm5={d0,...,d7}*/ \
+ "movq %%mm3,%%mm5\n\t" \
+ "punpcklbw %%mm7,%%mm3\n\t" \
+ "punpckhbw %%mm7,%%mm5\n\t" \
+ /*mm6:mm0={a0-d0,...,a7-d7}*/ \
+ "psubw %%mm3,%%mm0\n\t" \
+ "psubw %%mm5,%%mm6\n\t" \
+ /*mm3:mm1={b0,...,b7}*/ \
+ "movq %%mm1,%%mm3\n\t" \
+ "punpcklbw %%mm7,%%mm1\n\t" \
+ "movq %%mm2,%%mm4\n\t" \
+ "punpckhbw %%mm7,%%mm3\n\t" \
+ /*mm5:mm4={c0,...,c7}*/ \
+ "movq %%mm2,%%mm5\n\t" \
+ "punpcklbw %%mm7,%%mm4\n\t" \
+ "punpckhbw %%mm7,%%mm5\n\t" \
+ /*mm7={3}x4 \
+   mm5:mm4={c0-b0,...,c7-b7}*/ \
+ "pcmpeqw %%mm7,%%mm7\n\t" \
+ "psubw %%mm1,%%mm4\n\t" \
+ "psrlw $14,%%mm7\n\t" \
+ "psubw %%mm3,%%mm5\n\t" \
+ /*Scale by 3.*/ \
+ "pmullw %%mm7,%%mm4\n\t" \
+ "pmullw %%mm7,%%mm5\n\t" \
+ /*mm7={4}x4 \
+   mm5:mm4=f={a0-d0+3*(c0-b0),...,a7-d7+3*(c7-b7)}*/ \
+ "psrlw $1,%%mm7\n\t" \
+ "paddw %%mm0,%%mm4\n\t" \
+ "psllw $2,%%mm7\n\t" \
+ "movq (%[ll]),%%mm0\n\t" \
+ "paddw %%mm6,%%mm5\n\t" \
+ /*R_i has the range [-127,128], so we compute -R_i instead. \
+   mm4=-R_i=-(f+4>>3)=0xFF^(f-4>>3)*/ \
+ "psubw %%mm7,%%mm4\n\t" \
+ "psubw %%mm7,%%mm5\n\t" \
+ "psraw $3,%%mm4\n\t" \
+ "psraw $3,%%mm5\n\t" \
+ "pcmpeqb %%mm7,%%mm7\n\t" \
+ "packsswb %%mm5,%%mm4\n\t" \
+ "pxor %%mm6,%%mm6\n\t" \
+ "pxor %%mm7,%%mm4\n\t" \
+ "packuswb %%mm3,%%mm1\n\t" \
+ /*Now compute lflim of -mm4 cf. Section 7.10 of the sepc.*/ \
+ /*There's no unsigned byte+signed byte with unsigned saturation op code, so \
+    we have to split things by sign (the other option is to work in 16 bits, \
+    but working in 8 bits gives much better parallelism). \
+   We compute abs(R_i), but save a mask of which terms were negative in mm6. \
+   Then we compute mm4=abs(lflim(R_i,L))=min(abs(R_i),max(2*L-abs(R_i),0)). \
+   Finally, we split mm4 into positive and negative pieces using the mask in \
+    mm6, and add and subtract them as appropriate.*/ \
+ /*mm4=abs(-R_i)*/ \
+ /*mm7=255-2*L*/ \
+ "pcmpgtb %%mm4,%%mm6\n\t" \
+ "psubb %%mm0,%%mm7\n\t" \
+ "pxor %%mm6,%%mm4\n\t" \
+ "psubb %%mm0,%%mm7\n\t" \
+ "psubb %%mm6,%%mm4\n\t" \
+ /*mm7=255-max(2*L-abs(R_i),0)*/ \
+ "paddusb %%mm4,%%mm7\n\t" \
+ /*mm4=min(abs(R_i),max(2*L-abs(R_i),0))*/ \
+ "paddusb %%mm7,%%mm4\n\t" \
+ "psubusb %%mm7,%%mm4\n\t" \
+ /*Now split mm4 by the original sign of -R_i.*/ \
+ "movq %%mm4,%%mm5\n\t" \
+ "pand %%mm6,%%mm4\n\t" \
+ "pandn %%mm5,%%mm6\n\t" \
+ /*mm1={b0+lflim(R_0,L),...,b7+lflim(R_7,L)}*/ \
+ /*mm2={c0-lflim(R_0,L),...,c7-lflim(R_7,L)}*/ \
+ "paddusb %%mm4,%%mm1\n\t" \
+ "psubusb %%mm4,%%mm2\n\t" \
+ "psubusb %%mm6,%%mm1\n\t" \
+ "paddusb %%mm6,%%mm2\n\t" \
+
+#define OC_LOOP_FILTER_V_MMX(_pix,_ystride,_ll) \
+  do{ \
+    ptrdiff_t ystride3; \
+    __asm__ __volatile__( \
+      /*mm0={a0,...,a7}*/ \
+      "movq (%[pix]),%%mm0\n\t" \
+      /*ystride3=_ystride*3*/ \
+      "lea (%[ystride],%[ystride],2),%[ystride3]\n\t" \
+      /*mm3={d0,...,d7}*/ \
+      "movq (%[pix],%[ystride3]),%%mm3\n\t" \
+      /*mm1={b0,...,b7}*/ \
+      "movq (%[pix],%[ystride]),%%mm1\n\t" \
+      /*mm2={c0,...,c7}*/ \
+      "movq (%[pix],%[ystride],2),%%mm2\n\t" \
+      OC_LOOP_FILTER8_MMX \
+      /*Write it back out.*/ \
+      "movq %%mm1,(%[pix],%[ystride])\n\t" \
+      "movq %%mm2,(%[pix],%[ystride],2)\n\t" \
+      :[ystride3]"=&r"(ystride3) \
+      :[pix]"r"(_pix-_ystride*2),[ystride]"r"((ptrdiff_t)(_ystride)), \
+       [ll]"r"(_ll) \
+      :"memory" \
+    ); \
+  } \
+  while(0)
+
+#define OC_LOOP_FILTER_H_MMX(_pix,_ystride,_ll) \
+  do{ \
+    unsigned char *pix; \
+    ptrdiff_t      ystride3; \
+    ptrdiff_t      d; \
+    pix=(_pix)-2; \
+    __asm__ __volatile__( \
+      /*x x x x d0 c0 b0 a0*/ \
+      "movd (%[pix]),%%mm0\n\t" \
+      /*x x x x d1 c1 b1 a1*/ \
+      "movd (%[pix],%[ystride]),%%mm1\n\t" \
+      /*ystride3=_ystride*3*/ \
+      "lea (%[ystride],%[ystride],2),%[ystride3]\n\t" \
+      /*x x x x d2 c2 b2 a2*/ \
+      "movd (%[pix],%[ystride],2),%%mm2\n\t" \
+      /*x x x x d3 c3 b3 a3*/ \
+      "lea (%[pix],%[ystride],4),%[d]\n\t" \
+      "movd (%[pix],%[ystride3]),%%mm3\n\t" \
+      /*x x x x d4 c4 b4 a4*/ \
+      "movd (%[d]),%%mm4\n\t" \
+      /*x x x x d5 c5 b5 a5*/ \
+      "movd (%[d],%[ystride]),%%mm5\n\t" \
+      /*x x x x d6 c6 b6 a6*/ \
+      "movd (%[d],%[ystride],2),%%mm6\n\t" \
+      /*x x x x d7 c7 b7 a7*/ \
+      "movd (%[d],%[ystride3]),%%mm7\n\t" \
+      /*mm0=d1 d0 c1 c0 b1 b0 a1 a0*/ \
+      "punpcklbw %%mm1,%%mm0\n\t" \
+      /*mm2=d3 d2 c3 c2 b3 b2 a3 a2*/ \
+      "punpcklbw %%mm3,%%mm2\n\t" \
+      /*mm3=d1 d0 c1 c0 b1 b0 a1 a0*/ \
+      "movq %%mm0,%%mm3\n\t" \
+      /*mm0=b3 b2 b1 b0 a3 a2 a1 a0*/ \
+      "punpcklwd %%mm2,%%mm0\n\t" \
+      /*mm3=d3 d2 d1 d0 c3 c2 c1 c0*/ \
+      "punpckhwd %%mm2,%%mm3\n\t" \
+      /*mm1=b3 b2 b1 b0 a3 a2 a1 a0*/ \
+      "movq %%mm0,%%mm1\n\t" \
+      /*mm4=d5 d4 c5 c4 b5 b4 a5 a4*/ \
+      "punpcklbw %%mm5,%%mm4\n\t" \
+      /*mm6=d7 d6 c7 c6 b7 b6 a7 a6*/ \
+      "punpcklbw %%mm7,%%mm6\n\t" \
+      /*mm5=d5 d4 c5 c4 b5 b4 a5 a4*/ \
+      "movq %%mm4,%%mm5\n\t" \
+      /*mm4=b7 b6 b5 b4 a7 a6 a5 a4*/ \
+      "punpcklwd %%mm6,%%mm4\n\t" \
+      /*mm5=d7 d6 d5 d4 c7 c6 c5 c4*/ \
+      "punpckhwd %%mm6,%%mm5\n\t" \
+      /*mm2=d3 d2 d1 d0 c3 c2 c1 c0*/ \
+      "movq %%mm3,%%mm2\n\t" \
+      /*mm0=a7 a6 a5 a4 a3 a2 a1 a0*/ \
+      "punpckldq %%mm4,%%mm0\n\t" \
+      /*mm1=b7 b6 b5 b4 b3 b2 b1 b0*/ \
+      "punpckhdq %%mm4,%%mm1\n\t" \
+      /*mm2=c7 c6 c5 c4 c3 c2 c1 c0*/ \
+      "punpckldq %%mm5,%%mm2\n\t" \
+      /*mm3=d7 d6 d5 d4 d3 d2 d1 d0*/ \
+      "punpckhdq %%mm5,%%mm3\n\t" \
+      OC_LOOP_FILTER8_MMX \
+      /*mm2={b0+R_0'',...,b7+R_7''}*/ \
+      "movq %%mm1,%%mm0\n\t" \
+      /*mm1={b0+R_0'',c0-R_0'',...,b3+R_3'',c3-R_3''}*/ \
+      "punpcklbw %%mm2,%%mm1\n\t" \
+      /*mm2={b4+R_4'',c4-R_4'',...,b7+R_7'',c7-R_7''}*/ \
+      "punpckhbw %%mm2,%%mm0\n\t" \
+      /*[d]=c1 b1 c0 b0*/ \
+      "movd %%mm1,%[d]\n\t" \
+      "movw %w[d],1(%[pix])\n\t" \
+      "psrlq $32,%%mm1\n\t" \
+      "shr $16,%[d]\n\t" \
+      "movw %w[d],1(%[pix],%[ystride])\n\t" \
+      /*[d]=c3 b3 c2 b2*/ \
+      "movd %%mm1,%[d]\n\t" \
+      "movw %w[d],1(%[pix],%[ystride],2)\n\t" \
+      "shr $16,%[d]\n\t" \
+      "movw %w[d],1(%[pix],%[ystride3])\n\t" \
+      "lea (%[pix],%[ystride],4),%[pix]\n\t" \
+      /*[d]=c5 b5 c4 b4*/ \
+      "movd %%mm0,%[d]\n\t" \
+      "movw %w[d],1(%[pix])\n\t" \
+      "psrlq $32,%%mm0\n\t" \
+      "shr $16,%[d]\n\t" \
+      "movw %w[d],1(%[pix],%[ystride])\n\t" \
+      /*[d]=c7 b7 c6 b6*/ \
+      "movd %%mm0,%[d]\n\t" \
+      "movw %w[d],1(%[pix],%[ystride],2)\n\t" \
+      "shr $16,%[d]\n\t" \
+      "movw %w[d],1(%[pix],%[ystride3])\n\t" \
+      :[pix]"+r"(pix),[ystride3]"=&r"(ystride3),[d]"=&r"(d) \
+      :[ystride]"r"((ptrdiff_t)(_ystride)),[ll]"r"(_ll) \
+      :"memory" \
+    ); \
+  } \
+  while(0)
+
+# endif
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/x86int.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/x86int.h
new file mode 100644
index 0000000..64e0775
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86/x86int.h
@@ -0,0 +1,45 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: x86int.h 15977 2009-05-02 17:49:35Z tterribe $
+
+ ********************************************************************/
+
+#if !defined(_x86_x86int_H)
+# define _x86_x86int_H (1)
+# include "../../internal.h"
+
+void oc_state_vtable_init_x86(oc_theora_state *_state);
+
+void oc_frag_copy_mmx(unsigned char *_dst,
+ const unsigned char *_src,int _ystride);
+void oc_frag_recon_intra_mmx(unsigned char *_dst,int _ystride,
+ const ogg_int16_t *_residue);
+void oc_frag_recon_inter_mmx(unsigned char *_dst,
+ const unsigned char *_src,int _ystride,const ogg_int16_t *_residue);
+void oc_frag_recon_inter2_mmx(unsigned char *_dst,const unsigned char *_src1,
+ const unsigned char *_src2,int _ystride,const ogg_int16_t *_residue);
+void oc_dequant_idct8x8_mmx(ogg_int16_t _y[64],const ogg_int16_t _x[64],
+ int _last_zzi,int _ncoefs,ogg_uint16_t _dc_quant,
+ const ogg_uint16_t _ac_quant[64]);
+void oc_state_frag_recon_mmx(const oc_theora_state *_state,ptrdiff_t _fragi,
+ int _pli,ogg_int16_t _dct_coeffs[64],int _last_zzi,int _ncoefs,
+ ogg_uint16_t _dc_quant,const ogg_uint16_t _ac_quant[64]);
+void oc_state_frag_copy_list_mmx(const oc_theora_state *_state,
+ const ptrdiff_t *_fragis,ptrdiff_t _nfragis,
+ int _dst_frame,int _src_frame,int _pli);
+void oc_state_loop_filter_frag_rows_mmx(const oc_theora_state *_state,
+ int _bv[256],int _refi,int _pli,int _fragy0,int _fragy_end);
+void oc_restore_fpu_mmx(void);
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/mmxfrag.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/mmxfrag.c
new file mode 100644
index 0000000..e87e064
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/mmxfrag.c
@@ -0,0 +1,214 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id:
+
+ ********************************************************************/
+#include "../../internal.h"
+
+/* ------------------------------------------------------------------------
+  MMX reconstruction fragment routines for Visual Studio.
+  Tested with VS2005. Should compile for VS2003 and VC6 as well.
+
+  Initial implementation 2007 by Nils Pipenbrinck.
+  ---------------------------------------------------------------------*/
+
+#if defined(USE_ASM)
+
+void oc_frag_recon_intra_mmx(unsigned char *_dst,int _dst_ystride,
+ const ogg_int16_t *_residue){
+  /* ---------------------------------------------------------------------
+  This function does the inter reconstruction step with 8 iterations
+  unrolled. The iteration for each instruction is noted by the #id in the
+  comments (in case you want to reconstruct it)
+  --------------------------------------------------------------------- */
+  _asm{
+    mov       edi, [_residue]     /* load residue ptr     */
+    mov       eax, 0x00800080     /* generate constant    */
+    mov       ebx, [_dst_ystride] /* load dst-stride      */
+    mov       edx, [_dst]         /* load dest pointer    */
+
+    /* unrolled loop begins here */
+
+    movd      mm0, eax            /* load constant        */
+    movq      mm1, [edi+ 8*0]     /* #1 load low residue  */
+    movq      mm2, [edi+ 8*1]     /* #1 load high residue */
+    punpckldq mm0, mm0            /* build constant       */
+    movq      mm3, [edi+ 8*2]     /* #2 load low residue  */
+    movq      mm4, [edi+ 8*3]     /* #2 load high residue */
+    movq      mm5, [edi+ 8*4]     /* #3 load low residue  */
+    movq      mm6, [edi+ 8*5]     /* #3 load high residue */
+    paddsw    mm1, mm0            /* #1 bias low  residue */
+    paddsw    mm2, mm0            /* #1 bias high residue */
+    packuswb  mm1, mm2            /* #1 pack to byte      */
+    paddsw    mm3, mm0            /* #2 bias low  residue */
+    paddsw    mm4, mm0            /* #2 bias high residue */
+    packuswb  mm3, mm4            /* #2 pack to byte      */
+    paddsw    mm5, mm0            /* #3 bias low  residue */
+    paddsw    mm6, mm0            /* #3 bias high residue */
+    packuswb  mm5, mm6            /* #3 pack to byte      */
+    movq      [edx], mm1          /* #1 write row         */
+    movq      [edx + ebx], mm3    /* #2 write row         */
+    movq      [edx + ebx*2], mm5  /* #3 write row         */
+    movq      mm1, [edi+ 8*6]     /* #4 load low residue  */
+    lea       ecx, [ebx + ebx*2]  /* make dst_ystride * 3 */
+    movq      mm2, [edi+ 8*7]     /* #4 load high residue */
+    movq      mm3, [edi+ 8*8]     /* #5 load low residue  */
+    lea       esi, [ebx*4 + ebx]  /* make dst_ystride * 5 */
+    movq      mm4, [edi+ 8*9]     /* #5 load high residue */
+    movq      mm5, [edi+ 8*10]    /* #6 load low residue  */
+    lea       eax, [ecx*2 + ebx]  /* make dst_ystride * 7 */
+    movq      mm6, [edi+ 8*11]    /* #6 load high residue */
+    paddsw    mm1, mm0            /* #4 bias low  residue */
+    paddsw    mm2, mm0            /* #4 bias high residue */
+    packuswb  mm1, mm2            /* #4 pack to byte      */
+    paddsw    mm3, mm0            /* #5 bias low  residue */
+    paddsw    mm4, mm0            /* #5 bias high residue */
+    packuswb  mm3, mm4            /* #5 pack to byte      */
+    paddsw    mm5, mm0            /* #6 bias low  residue */
+    paddsw    mm6, mm0            /* #6 bias high residue */
+    packuswb  mm5, mm6            /* #6 pack to byte      */
+    movq      [edx + ecx], mm1    /* #4 write row         */
+    movq      [edx + ebx*4], mm3  /* #5 write row         */
+    movq      [edx + esi], mm5    /* #6 write row         */
+    movq      mm1, [edi+ 8*12]    /* #7 load low residue  */
+    movq      mm2, [edi+ 8*13]    /* #7 load high residue */
+    movq      mm3, [edi+ 8*14]    /* #8 load low residue  */
+    movq      mm4, [edi+ 8*15]    /* #8 load high residue */
+    paddsw    mm1, mm0            /* #7 bias low  residue */
+    paddsw    mm2, mm0            /* #7 bias high residue */
+    packuswb  mm1, mm2            /* #7 pack to byte      */
+    paddsw    mm3, mm0            /* #8 bias low  residue */
+    paddsw    mm4, mm0            /* #8 bias high residue */
+    packuswb  mm3, mm4            /* #8 pack to byte      */
+    movq      [edx + ecx*2], mm1  /* #7 write row         */
+    movq      [edx + eax], mm3    /* #8 write row         */
+  }
+}
+
+
+
+void oc_frag_recon_inter_mmx (unsigned char *_dst, int _dst_ystride,
+ const unsigned char *_src, int _src_ystride, const ogg_int16_t *_residue){
+  /* ---------------------------------------------------------------------
+  This function does the inter reconstruction step with two iterations
+  running in parallel to hide some load-latencies and break the dependency
+  chains. The iteration for each instruction is noted by the #id in the
+  comments (in case you want to reconstruct it)
+  --------------------------------------------------------------------- */
+  _asm{
+    pxor      mm0, mm0          /* generate constant 0 */
+    mov       esi, [_src]
+    mov       edi, [_residue]
+    mov       eax, [_src_ystride]
+    mov       edx, [_dst]
+    mov       ebx, [_dst_ystride]
+    mov       ecx, 4
+
+    align 16
+
+nextchunk:
+    movq      mm3, [esi]        /* #1 load source        */
+    movq      mm1, [edi+0]      /* #1 load residium low  */
+    movq      mm2, [edi+8]      /* #1 load residium high */
+    movq      mm7, [esi+eax]    /* #2 load source        */
+    movq      mm4, mm3          /* #1 get copy of src    */
+    movq      mm5, [edi+16]     /* #2 load residium low  */
+    punpckhbw mm4, mm0          /* #1 expand high source */
+    movq      mm6, [edi+24]     /* #2 load residium high */
+    punpcklbw mm3, mm0          /* #1 expand low  source */
+    paddsw    mm4, mm2          /* #1 add residium high  */
+    movq      mm2, mm7          /* #2 get copy of src    */
+    paddsw    mm3, mm1          /* #1 add residium low   */
+    punpckhbw mm2, mm0          /* #2 expand high source */
+    packuswb  mm3, mm4          /* #1 final row pixels   */
+    punpcklbw mm7, mm0          /* #2 expand low  source */
+    movq      [edx], mm3        /* #1 write row          */
+    paddsw    mm2, mm6          /* #2 add residium high  */
+    add       edi, 32           /* residue += 4          */
+    paddsw    mm7, mm5          /* #2 add residium low   */
+    sub       ecx, 1            /* update loop counter   */
+    packuswb  mm7, mm2          /* #2 final row          */
+    lea       esi, [esi+eax*2]  /* src += stride * 2     */
+    movq      [edx + ebx], mm7  /* #2 write row          */
+    lea       edx, [edx+ebx*2]  /* dst += stride * 2     */
+    jne       nextchunk
+  }
+}
+
+
+void oc_frag_recon_inter2_mmx(unsigned char *_dst,  int _dst_ystride,
+ const unsigned char *_src1,  int _src1_ystride, const unsigned char *_src2,
+ int _src2_ystride,const ogg_int16_t *_residue){
+  /* ---------------------------------------------------------------------
+  This function does the inter2 reconstruction step.The building of the
+  average is done with a bit-twiddeling trick to avoid excessive register
+  copy work during byte to word conversion.
+
+              average = (a & b) + (((a ^ b) & 0xfe) >> 1);
+
+  (shown for a single byte; it's done with 8 of them at a time)
+
+  Slightly faster than the obvious method using add and shift, but not
+  earthshaking improvement either.
+
+  If anyone comes up with a way that produces bit-identical outputs
+  using the pavgb instruction let me know and I'll do the 3dnow codepath.
+  --------------------------------------------------------------------- */
+ _asm{
+   mov        eax, 0xfefefefe
+   mov        esi, [_src1]
+   mov        edi, [_src2]
+   movd       mm1, eax
+   mov        ebx, [_residue]
+   mov        edx, [_dst]
+   mov        eax, [_dst_ystride]
+   punpckldq  mm1, mm1            /* replicate lsb32     */
+   mov        ecx, 8              /* init loop counter   */
+   pxor       mm0, mm0            /* constant zero       */
+   sub        edx, eax            /* dst -= dst_stride   */
+
+   align      16
+
+nextrow:
+   movq       mm2,  [esi]         /* load source1        */
+   movq       mm3,  [edi]         /* load source2        */
+   movq       mm5,  [ebx + 0]     /* load lower residue  */
+   movq       mm6,  [ebx + 8]     /* load higer residue  */
+   add        esi,  _src1_ystride /* src1 += src1_stride */
+   add        edi,  _src2_ystride /* src2 += src1_stride */
+   movq       mm4,  mm2           /* get copy of source1 */
+   pand       mm2,  mm3           /* s1 & s2 (avg part)  */
+   pxor       mm3,  mm4           /* s1 ^ s2 (avg part)  */
+   add        ebx,  16            /* residue++           */
+   pand       mm3,  mm1           /* mask out low bits   */
+   psrlq      mm3,  1             /* shift xor avg-part  */
+   paddd      mm3,  mm2           /* build final average */
+   add        edx,  eax           /* dst += dst_stride   */
+   movq       mm2,  mm3           /* get copy of average */
+   punpckhbw  mm3,  mm0           /* average high        */
+   punpcklbw  mm2,  mm0           /* average low         */
+   paddsw     mm3,  mm6           /* high + residue      */
+   paddsw     mm2,  mm5           /* low  + residue      */
+   sub        ecx,  1             /* update loop counter */
+   packuswb   mm2,  mm3           /* pack and saturate   */
+   movq       [edx], mm2          /* write row           */
+   jne        nextrow
+ }
+}
+
+void oc_restore_fpu_mmx(void){
+  _asm { emms }
+}
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/mmxidct.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/mmxidct.c
new file mode 100644
index 0000000..c1e023a
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/mmxidct.c
@@ -0,0 +1,1007 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id:
+
+ ********************************************************************/
+
+/* -------------------------------------------------------------------
+  MMX based IDCT for the theora codec.
+
+  Originally written by Rudolf Marek, based on code from On2's VP3.
+  Converted to Visual Studio inline assembly by Nils Pipenbrinck.
+
+  ---------------------------------------------------------------------*/
+#if defined(USE_ASM)
+
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+#include <vtkoggtheora/include/ogg/ogg.h>
+#include "../dct.h"
+#include "../idct.h"
+#include "x86int.h"
+
+/*A table of constants used by the MMX routines.*/
+static const __declspec(align(16)) ogg_uint16_t
+ OC_IDCT_CONSTS[(7+1)*4]={
+  (ogg_uint16_t)OC_C1S7,(ogg_uint16_t)OC_C1S7,
+  (ogg_uint16_t)OC_C1S7,(ogg_uint16_t)OC_C1S7,
+  (ogg_uint16_t)OC_C2S6,(ogg_uint16_t)OC_C2S6,
+  (ogg_uint16_t)OC_C2S6,(ogg_uint16_t)OC_C2S6,
+  (ogg_uint16_t)OC_C3S5,(ogg_uint16_t)OC_C3S5,
+  (ogg_uint16_t)OC_C3S5,(ogg_uint16_t)OC_C3S5,
+  (ogg_uint16_t)OC_C4S4,(ogg_uint16_t)OC_C4S4,
+  (ogg_uint16_t)OC_C4S4,(ogg_uint16_t)OC_C4S4,
+  (ogg_uint16_t)OC_C5S3,(ogg_uint16_t)OC_C5S3,
+  (ogg_uint16_t)OC_C5S3,(ogg_uint16_t)OC_C5S3,
+  (ogg_uint16_t)OC_C6S2,(ogg_uint16_t)OC_C6S2,
+  (ogg_uint16_t)OC_C6S2,(ogg_uint16_t)OC_C6S2,
+  (ogg_uint16_t)OC_C7S1,(ogg_uint16_t)OC_C7S1,
+  (ogg_uint16_t)OC_C7S1,(ogg_uint16_t)OC_C7S1,
+      8,    8,    8,    8
+};
+
+
+void oc_idct8x8_10_mmx(ogg_int16_t _y[64]){
+  _asm {
+    mov     edx, [_y]
+    mov     eax, offset OC_IDCT_CONSTS
+    movq    mm2, [edx + 30H]
+    movq    mm6, [eax + 10H]
+    movq    mm4, mm2
+    movq    mm7, [edx + 18H]
+    pmulhw  mm4, mm6
+    movq    mm1, [eax + 20H]
+    pmulhw  mm6, mm7
+    movq    mm5, mm1
+    pmulhw  mm1, mm2
+    movq    mm3, [edx + 10H]
+    pmulhw  mm5, mm7
+    movq    mm0, [eax]
+    paddw   mm4, mm2
+    paddw   mm6, mm7
+    paddw   mm2, mm1
+    movq    mm1, [edx + 38H]
+    paddw   mm7, mm5
+    movq    mm5, mm0
+    pmulhw  mm0, mm3
+    paddw   mm4, mm7
+    pmulhw  mm5, mm1
+    movq    mm7, [eax + 30H]
+    psubw   mm6, mm2
+    paddw   mm0, mm3
+    pmulhw  mm3, mm7
+    movq    mm2, [edx + 20H]
+    pmulhw  mm7, mm1
+    paddw   mm5, mm1
+    movq    mm1, mm2
+    pmulhw  mm2, [eax + 08H]
+    psubw   mm3, mm5
+    movq    mm5, [edx + 28H]
+    paddw   mm0, mm7
+    movq    mm7, mm5
+    psubw   mm0, mm4
+    pmulhw  mm5, [eax + 08H]
+    paddw   mm2, mm1
+    pmulhw  mm1, [eax + 28H]
+    paddw   mm4, mm4
+    paddw   mm4, mm0
+    psubw   mm3, mm6
+    paddw   mm5, mm7
+    paddw   mm6, mm6
+    pmulhw  mm7, [eax + 28H]
+    paddw   mm6, mm3
+    movq    [edx + 10H], mm4
+    psubw   mm1, mm5
+    movq    mm4, [eax + 18H]
+    movq    mm5, mm3
+    pmulhw  mm3, mm4
+    paddw   mm7, mm2
+    movq    [edx + 20H], mm6
+    movq    mm2, mm0
+    movq    mm6, [edx]
+    pmulhw  mm0, mm4
+    paddw   mm5, mm3
+    movq    mm3, [edx + 08H]
+    psubw   mm5, mm1
+    paddw   mm2, mm0
+    psubw   mm6, mm3
+    movq    mm0, mm6
+    pmulhw  mm6, mm4
+    paddw   mm3, mm3
+    paddw   mm1, mm1
+    paddw   mm3, mm0
+    paddw   mm1, mm5
+    pmulhw  mm4, mm3
+    paddw   mm6, mm0
+    psubw   mm6, mm2
+    paddw   mm2, mm2
+    movq    mm0, [edx + 10H]
+    paddw   mm2, mm6
+    paddw   mm4, mm3
+    psubw   mm2, mm1
+    movq    mm3, [edx + 20H]
+    psubw   mm4, mm7
+    paddw   mm1, mm1
+    paddw   mm7, mm7
+    paddw   mm1, mm2
+    paddw   mm7, mm4
+    psubw   mm4, mm3
+    paddw   mm3, mm3
+    psubw   mm6, mm5
+    paddw   mm5, mm5
+    paddw   mm3, mm4
+    paddw   mm5, mm6
+    psubw   mm7, mm0
+    paddw   mm0, mm0
+    movq    [edx + 10H], mm1
+    paddw   mm0, mm7
+    movq    mm1, mm4
+    punpcklwd mm4, mm5
+    movq    [edx], mm0
+    punpckhwd mm1, mm5
+    movq    mm0, mm6
+    punpcklwd mm6, mm7
+    movq    mm5, mm4
+    punpckldq mm4, mm6
+    punpckhdq mm5, mm6
+    movq    mm6, mm1
+    movq    [edx + 08H], mm4
+    punpckhwd mm0, mm7
+    movq    [edx + 18H], mm5
+    punpckhdq mm6, mm0
+    movq    mm4, [edx]
+    punpckldq mm1, mm0
+    movq    mm5, [edx + 10H]
+    movq    mm0, mm4
+    movq    [edx + 38H], mm6
+    punpcklwd mm0, mm5
+    movq    [edx + 28H], mm1
+    punpckhwd mm4, mm5
+    movq    mm5, mm2
+    punpcklwd mm2, mm3
+    movq    mm1, mm0
+    punpckldq mm0, mm2
+    punpckhdq mm1, mm2
+    movq    mm2, mm4
+    movq    [edx], mm0
+    punpckhwd mm5, mm3
+    movq    [edx + 10H], mm1
+    punpckhdq mm4, mm5
+    punpckldq mm2, mm5
+    movq    [edx + 30H], mm4
+    movq    [edx + 20H], mm2
+    movq    mm2, [edx + 70H]
+    movq    mm6, [eax + 10H]
+    movq    mm4, mm2
+    movq    mm7, [edx + 58H]
+    pmulhw  mm4, mm6
+    movq    mm1, [eax + 20H]
+    pmulhw  mm6, mm7
+    movq    mm5, mm1
+    pmulhw  mm1, mm2
+    movq    mm3, [edx + 50H]
+    pmulhw  mm5, mm7
+    movq    mm0, [eax]
+    paddw   mm4, mm2
+    paddw   mm6, mm7
+    paddw   mm2, mm1
+    movq    mm1, [edx + 78H]
+    paddw   mm7, mm5
+    movq    mm5, mm0
+    pmulhw  mm0, mm3
+    paddw   mm4, mm7
+    pmulhw  mm5, mm1
+    movq    mm7, [eax + 30H]
+    psubw   mm6, mm2
+    paddw   mm0, mm3
+    pmulhw  mm3, mm7
+    movq    mm2, [edx + 60H]
+    pmulhw  mm7, mm1
+    paddw   mm5, mm1
+    movq    mm1, mm2
+    pmulhw  mm2, [eax + 08H]
+    psubw   mm3, mm5
+    movq    mm5, [edx + 68H]
+    paddw   mm0, mm7
+    movq    mm7, mm5
+    psubw   mm0, mm4
+    pmulhw  mm5, [eax + 08H]
+    paddw   mm2, mm1
+    pmulhw  mm1, [eax + 28H]
+    paddw   mm4, mm4
+    paddw   mm4, mm0
+    psubw   mm3, mm6
+    paddw   mm5, mm7
+    paddw   mm6, mm6
+    pmulhw  mm7, [eax + 28H]
+    paddw   mm6, mm3
+    movq    [edx + 50H], mm4
+    psubw   mm1, mm5
+    movq    mm4, [eax + 18H]
+    movq    mm5, mm3
+    pmulhw  mm3, mm4
+    paddw   mm7, mm2
+    movq    [edx + 60H], mm6
+    movq    mm2, mm0
+    movq    mm6, [edx + 40H]
+    pmulhw  mm0, mm4
+    paddw   mm5, mm3
+    movq    mm3, [edx + 48H]
+    psubw   mm5, mm1
+    paddw   mm2, mm0
+    psubw   mm6, mm3
+    movq    mm0, mm6
+    pmulhw  mm6, mm4
+    paddw   mm3, mm3
+    paddw   mm1, mm1
+    paddw   mm3, mm0
+    paddw   mm1, mm5
+    pmulhw  mm4, mm3
+    paddw   mm6, mm0
+    psubw   mm6, mm2
+    paddw   mm2, mm2
+    movq    mm0, [edx + 50H]
+    paddw   mm2, mm6
+    paddw   mm4, mm3
+    psubw   mm2, mm1
+    movq    mm3, [edx + 60H]
+    psubw   mm4, mm7
+    paddw   mm1, mm1
+    paddw   mm7, mm7
+    paddw   mm1, mm2
+    paddw   mm7, mm4
+    psubw   mm4, mm3
+    paddw   mm3, mm3
+    psubw   mm6, mm5
+    paddw   mm5, mm5
+    paddw   mm3, mm4
+    paddw   mm5, mm6
+    psubw   mm7, mm0
+    paddw   mm0, mm0
+    movq    [edx + 50H], mm1
+    paddw   mm0, mm7
+    movq    mm1, mm4
+    punpcklwd mm4, mm5
+    movq    [edx + 40H], mm0
+    punpckhwd mm1, mm5
+    movq    mm0, mm6
+    punpcklwd mm6, mm7
+    movq    mm5, mm4
+    punpckldq mm4, mm6
+    punpckhdq mm5, mm6
+    movq    mm6, mm1
+    movq    [edx + 48H], mm4
+    punpckhwd mm0, mm7
+    movq    [edx + 58H], mm5
+    punpckhdq mm6, mm0
+    movq    mm4, [edx + 40H]
+    punpckldq mm1, mm0
+    movq    mm5, [edx + 50H]
+    movq    mm0, mm4
+    movq    [edx + 78H], mm6
+    punpcklwd mm0, mm5
+    movq    [edx + 68H], mm1
+    punpckhwd mm4, mm5
+    movq    mm5, mm2
+    punpcklwd mm2, mm3
+    movq    mm1, mm0
+    punpckldq mm0, mm2
+    punpckhdq mm1, mm2
+    movq    mm2, mm4
+    movq    [edx + 40H], mm0
+    punpckhwd mm5, mm3
+    movq    [edx + 50H], mm1
+    punpckhdq mm4, mm5
+    punpckldq mm2, mm5
+    movq    [edx + 70H], mm4
+    movq    [edx + 60H], mm2
+    movq    mm2, [edx + 30H]
+    movq    mm6, [eax + 10H]
+    movq    mm4, mm2
+    movq    mm7, [edx + 50H]
+    pmulhw  mm4, mm6
+    movq    mm1, [eax + 20H]
+    pmulhw  mm6, mm7
+    movq    mm5, mm1
+    pmulhw  mm1, mm2
+    movq    mm3, [edx + 10H]
+    pmulhw  mm5, mm7
+    movq    mm0, [eax]
+    paddw   mm4, mm2
+    paddw   mm6, mm7
+    paddw   mm2, mm1
+    movq    mm1, [edx + 70H]
+    paddw   mm7, mm5
+    movq    mm5, mm0
+    pmulhw  mm0, mm3
+    paddw   mm4, mm7
+    pmulhw  mm5, mm1
+    movq    mm7, [eax + 30H]
+    psubw   mm6, mm2
+    paddw   mm0, mm3
+    pmulhw  mm3, mm7
+    movq    mm2, [edx + 20H]
+    pmulhw  mm7, mm1
+    paddw   mm5, mm1
+    movq    mm1, mm2
+    pmulhw  mm2, [eax + 08H]
+    psubw   mm3, mm5
+    movq    mm5, [edx + 60H]
+    paddw   mm0, mm7
+    movq    mm7, mm5
+    psubw   mm0, mm4
+    pmulhw  mm5, [eax + 08H]
+    paddw   mm2, mm1
+    pmulhw  mm1, [eax + 28H]
+    paddw   mm4, mm4
+    paddw   mm4, mm0
+    psubw   mm3, mm6
+    paddw   mm5, mm7
+    paddw   mm6, mm6
+    pmulhw  mm7, [eax + 28H]
+    paddw   mm6, mm3
+    movq    [edx + 10H], mm4
+    psubw   mm1, mm5
+    movq    mm4, [eax + 18H]
+    movq    mm5, mm3
+    pmulhw  mm3, mm4
+    paddw   mm7, mm2
+    movq    [edx + 20H], mm6
+    movq    mm2, mm0
+    movq    mm6, [edx]
+    pmulhw  mm0, mm4
+    paddw   mm5, mm3
+    movq    mm3, [edx + 40H]
+    psubw   mm5, mm1
+    paddw   mm2, mm0
+    psubw   mm6, mm3
+    movq    mm0, mm6
+    pmulhw  mm6, mm4
+    paddw   mm3, mm3
+    paddw   mm1, mm1
+    paddw   mm3, mm0
+    paddw   mm1, mm5
+    pmulhw  mm4, mm3
+    paddw   mm6, mm0
+    psubw   mm6, mm2
+    paddw   mm2, mm2
+    movq    mm0, [edx + 10H]
+    paddw   mm2, mm6
+    paddw   mm4, mm3
+    psubw   mm2, mm1
+    paddw   mm2, [eax + 38H]
+    paddw   mm1, mm1
+    paddw   mm1, mm2
+    psraw   mm2, 4
+    psubw   mm4, mm7
+    psraw   mm1, 4
+    movq    mm3, [edx + 20H]
+    paddw   mm7, mm7
+    movq    [edx + 20H], mm2
+    paddw   mm7, mm4
+    movq    [edx + 10H], mm1
+    psubw   mm4, mm3
+    paddw   mm4, [eax + 38H]
+    paddw   mm3, mm3
+    paddw   mm3, mm4
+    psraw   mm4, 4
+    psubw   mm6, mm5
+    psraw   mm3, 4
+    paddw   mm6, [eax + 38H]
+    paddw   mm5, mm5
+    paddw   mm5, mm6
+    psraw   mm6, 4
+    movq    [edx + 40H], mm4
+    psraw   mm5, 4
+    movq    [edx + 30H], mm3
+    psubw   mm7, mm0
+    paddw   mm7, [eax + 38H]
+    paddw   mm0, mm0
+    paddw   mm0, mm7
+    psraw   mm7, 4
+    movq    [edx + 60H], mm6
+    psraw   mm0, 4
+    movq    [edx + 50H], mm5
+    movq    [edx + 70H], mm7
+    movq    [edx], mm0
+    movq    mm2, [edx + 38H]
+    movq    mm6, [eax + 10H]
+    movq    mm4, mm2
+    movq    mm7, [edx + 58H]
+    pmulhw  mm4, mm6
+    movq    mm1, [eax + 20H]
+    pmulhw  mm6, mm7
+    movq    mm5, mm1
+    pmulhw  mm1, mm2
+    movq    mm3, [edx + 18H]
+    pmulhw  mm5, mm7
+    movq    mm0, [eax]
+    paddw   mm4, mm2
+    paddw   mm6, mm7
+    paddw   mm2, mm1
+    movq    mm1, [edx + 78H]
+    paddw   mm7, mm5
+    movq    mm5, mm0
+    pmulhw  mm0, mm3
+    paddw   mm4, mm7
+    pmulhw  mm5, mm1
+    movq    mm7, [eax + 30H]
+    psubw   mm6, mm2
+    paddw   mm0, mm3
+    pmulhw  mm3, mm7
+    movq    mm2, [edx + 28H]
+    pmulhw  mm7, mm1
+    paddw   mm5, mm1
+    movq    mm1, mm2
+    pmulhw  mm2, [eax + 08H]
+    psubw   mm3, mm5
+    movq    mm5, [edx + 68H]
+    paddw   mm0, mm7
+    movq    mm7, mm5
+    psubw   mm0, mm4
+    pmulhw  mm5, [eax + 08H]
+    paddw   mm2, mm1
+    pmulhw  mm1, [eax + 28H]
+    paddw   mm4, mm4
+    paddw   mm4, mm0
+    psubw   mm3, mm6
+    paddw   mm5, mm7
+    paddw   mm6, mm6
+    pmulhw  mm7, [eax + 28H]
+    paddw   mm6, mm3
+    movq    [edx + 18H], mm4
+    psubw   mm1, mm5
+    movq    mm4, [eax + 18H]
+    movq    mm5, mm3
+    pmulhw  mm3, mm4
+    paddw   mm7, mm2
+    movq    [edx + 28H], mm6
+    movq    mm2, mm0
+    movq    mm6, [edx + 08H]
+    pmulhw  mm0, mm4
+    paddw   mm5, mm3
+    movq    mm3, [edx + 48H]
+    psubw   mm5, mm1
+    paddw   mm2, mm0
+    psubw   mm6, mm3
+    movq    mm0, mm6
+    pmulhw  mm6, mm4
+    paddw   mm3, mm3
+    paddw   mm1, mm1
+    paddw   mm3, mm0
+    paddw   mm1, mm5
+    pmulhw  mm4, mm3
+    paddw   mm6, mm0
+    psubw   mm6, mm2
+    paddw   mm2, mm2
+    movq    mm0, [edx + 18H]
+    paddw   mm2, mm6
+    paddw   mm4, mm3
+    psubw   mm2, mm1
+    paddw   mm2, [eax + 38H]
+    paddw   mm1, mm1
+    paddw   mm1, mm2
+    psraw   mm2, 4
+    psubw   mm4, mm7
+    psraw   mm1, 4
+    movq    mm3, [edx + 28H]
+    paddw   mm7, mm7
+    movq    [edx + 28H], mm2
+    paddw   mm7, mm4
+    movq    [edx + 18H], mm1
+    psubw   mm4, mm3
+    paddw   mm4, [eax + 38H]
+    paddw   mm3, mm3
+    paddw   mm3, mm4
+    psraw   mm4, 4
+    psubw   mm6, mm5
+    psraw   mm3, 4
+    paddw   mm6, [eax + 38H]
+    paddw   mm5, mm5
+    paddw   mm5, mm6
+    psraw   mm6, 4
+    movq    [edx + 48H], mm4
+    psraw   mm5, 4
+    movq    [edx + 38H], mm3
+    psubw   mm7, mm0
+    paddw   mm7, [eax + 38H]
+    paddw   mm0, mm0
+    paddw   mm0, mm7
+    psraw   mm7, 4
+    movq    [edx + 68H], mm6
+    psraw   mm0, 4
+    movq    [edx + 58H], mm5
+    movq    [edx + 78H], mm7
+    movq    [edx + 08H], mm0
+    /* emms  */
+  }
+}
+
+
+void oc_idct8x8_mmx(ogg_int16_t _y[64]){
+  _asm {
+    mov     edx, [_y]
+    mov     eax, offset OC_IDCT_CONSTS
+    movq    mm2, [edx + 30H]
+    movq    mm6, [eax + 10H]
+    movq    mm4, mm2
+    movq    mm7, [edx + 18H]
+    pmulhw  mm4, mm6
+    movq    mm1, [eax + 20H]
+    pmulhw  mm6, mm7
+    movq    mm5, mm1
+    pmulhw  mm1, mm2
+    movq    mm3, [edx + 10H]
+    pmulhw  mm5, mm7
+    movq    mm0, [eax]
+    paddw   mm4, mm2
+    paddw   mm6, mm7
+    paddw   mm2, mm1
+    movq    mm1, [edx + 38H]
+    paddw   mm7, mm5
+    movq    mm5, mm0
+    pmulhw  mm0, mm3
+    paddw   mm4, mm7
+    pmulhw  mm5, mm1
+    movq    mm7, [eax + 30H]
+    psubw   mm6, mm2
+    paddw   mm0, mm3
+    pmulhw  mm3, mm7
+    movq    mm2, [edx + 20H]
+    pmulhw  mm7, mm1
+    paddw   mm5, mm1
+    movq    mm1, mm2
+    pmulhw  mm2, [eax + 08H]
+    psubw   mm3, mm5
+    movq    mm5, [edx + 28H]
+    paddw   mm0, mm7
+    movq    mm7, mm5
+    psubw   mm0, mm4
+    pmulhw  mm5, [eax + 08H]
+    paddw   mm2, mm1
+    pmulhw  mm1, [eax + 28H]
+    paddw   mm4, mm4
+    paddw   mm4, mm0
+    psubw   mm3, mm6
+    paddw   mm5, mm7
+    paddw   mm6, mm6
+    pmulhw  mm7, [eax + 28H]
+    paddw   mm6, mm3
+    movq    [edx + 10H], mm4
+    psubw   mm1, mm5
+    movq    mm4, [eax + 18H]
+    movq    mm5, mm3
+    pmulhw  mm3, mm4
+    paddw   mm7, mm2
+    movq    [edx + 20H], mm6
+    movq    mm2, mm0
+    movq    mm6, [edx]
+    pmulhw  mm0, mm4
+    paddw   mm5, mm3
+    movq    mm3, [edx + 08H]
+    psubw   mm5, mm1
+    paddw   mm2, mm0
+    psubw   mm6, mm3
+    movq    mm0, mm6
+    pmulhw  mm6, mm4
+    paddw   mm3, mm3
+    paddw   mm1, mm1
+    paddw   mm3, mm0
+    paddw   mm1, mm5
+    pmulhw  mm4, mm3
+    paddw   mm6, mm0
+    psubw   mm6, mm2
+    paddw   mm2, mm2
+    movq    mm0, [edx + 10H]
+    paddw   mm2, mm6
+    paddw   mm4, mm3
+    psubw   mm2, mm1
+    movq    mm3, [edx + 20H]
+    psubw   mm4, mm7
+    paddw   mm1, mm1
+    paddw   mm7, mm7
+    paddw   mm1, mm2
+    paddw   mm7, mm4
+    psubw   mm4, mm3
+    paddw   mm3, mm3
+    psubw   mm6, mm5
+    paddw   mm5, mm5
+    paddw   mm3, mm4
+    paddw   mm5, mm6
+    psubw   mm7, mm0
+    paddw   mm0, mm0
+    movq    [edx + 10H], mm1
+    paddw   mm0, mm7
+    movq    mm1, mm4
+    punpcklwd mm4, mm5
+    movq    [edx], mm0
+    punpckhwd mm1, mm5
+    movq    mm0, mm6
+    punpcklwd mm6, mm7
+    movq    mm5, mm4
+    punpckldq mm4, mm6
+    punpckhdq mm5, mm6
+    movq    mm6, mm1
+    movq    [edx + 08H], mm4
+    punpckhwd mm0, mm7
+    movq    [edx + 18H], mm5
+    punpckhdq mm6, mm0
+    movq    mm4, [edx]
+    punpckldq mm1, mm0
+    movq    mm5, [edx + 10H]
+    movq    mm0, mm4
+    movq    [edx + 38H], mm6
+    punpcklwd mm0, mm5
+    movq    [edx + 28H], mm1
+    punpckhwd mm4, mm5
+    movq    mm5, mm2
+    punpcklwd mm2, mm3
+    movq    mm1, mm0
+    punpckldq mm0, mm2
+    punpckhdq mm1, mm2
+    movq    mm2, mm4
+    movq    [edx], mm0
+    punpckhwd mm5, mm3
+    movq    [edx + 10H], mm1
+    punpckhdq mm4, mm5
+    punpckldq mm2, mm5
+    movq    [edx + 30H], mm4
+    movq    [edx + 20H], mm2
+    movq    mm2, [edx + 70H]
+    movq    mm6, [eax + 10H]
+    movq    mm4, mm2
+    movq    mm7, [edx + 58H]
+    pmulhw  mm4, mm6
+    movq    mm1, [eax + 20H]
+    pmulhw  mm6, mm7
+    movq    mm5, mm1
+    pmulhw  mm1, mm2
+    movq    mm3, [edx + 50H]
+    pmulhw  mm5, mm7
+    movq    mm0, [eax]
+    paddw   mm4, mm2
+    paddw   mm6, mm7
+    paddw   mm2, mm1
+    movq    mm1, [edx + 78H]
+    paddw   mm7, mm5
+    movq    mm5, mm0
+    pmulhw  mm0, mm3
+    paddw   mm4, mm7
+    pmulhw  mm5, mm1
+    movq    mm7, [eax + 30H]
+    psubw   mm6, mm2
+    paddw   mm0, mm3
+    pmulhw  mm3, mm7
+    movq    mm2, [edx + 60H]
+    pmulhw  mm7, mm1
+    paddw   mm5, mm1
+    movq    mm1, mm2
+    pmulhw  mm2, [eax + 08H]
+    psubw   mm3, mm5
+    movq    mm5, [edx + 68H]
+    paddw   mm0, mm7
+    movq    mm7, mm5
+    psubw   mm0, mm4
+    pmulhw  mm5, [eax + 08H]
+    paddw   mm2, mm1
+    pmulhw  mm1, [eax + 28H]
+    paddw   mm4, mm4
+    paddw   mm4, mm0
+    psubw   mm3, mm6
+    paddw   mm5, mm7
+    paddw   mm6, mm6
+    pmulhw  mm7, [eax + 28H]
+    paddw   mm6, mm3
+    movq    [edx + 50H], mm4
+    psubw   mm1, mm5
+    movq    mm4, [eax + 18H]
+    movq    mm5, mm3
+    pmulhw  mm3, mm4
+    paddw   mm7, mm2
+    movq    [edx + 60H], mm6
+    movq    mm2, mm0
+    movq    mm6, [edx + 40H]
+    pmulhw  mm0, mm4
+    paddw   mm5, mm3
+    movq    mm3, [edx + 48H]
+    psubw   mm5, mm1
+    paddw   mm2, mm0
+    psubw   mm6, mm3
+    movq    mm0, mm6
+    pmulhw  mm6, mm4
+    paddw   mm3, mm3
+    paddw   mm1, mm1
+    paddw   mm3, mm0
+    paddw   mm1, mm5
+    pmulhw  mm4, mm3
+    paddw   mm6, mm0
+    psubw   mm6, mm2
+    paddw   mm2, mm2
+    movq    mm0, [edx + 50H]
+    paddw   mm2, mm6
+    paddw   mm4, mm3
+    psubw   mm2, mm1
+    movq    mm3, [edx + 60H]
+    psubw   mm4, mm7
+    paddw   mm1, mm1
+    paddw   mm7, mm7
+    paddw   mm1, mm2
+    paddw   mm7, mm4
+    psubw   mm4, mm3
+    paddw   mm3, mm3
+    psubw   mm6, mm5
+    paddw   mm5, mm5
+    paddw   mm3, mm4
+    paddw   mm5, mm6
+    psubw   mm7, mm0
+    paddw   mm0, mm0
+    movq    [edx + 50H], mm1
+    paddw   mm0, mm7
+    movq    mm1, mm4
+    punpcklwd mm4, mm5
+    movq    [edx + 40H], mm0
+    punpckhwd mm1, mm5
+    movq    mm0, mm6
+    punpcklwd mm6, mm7
+    movq    mm5, mm4
+    punpckldq mm4, mm6
+    punpckhdq mm5, mm6
+    movq    mm6, mm1
+    movq    [edx + 48H], mm4
+    punpckhwd mm0, mm7
+    movq    [edx + 58H], mm5
+    punpckhdq mm6, mm0
+    movq    mm4, [edx + 40H]
+    punpckldq mm1, mm0
+    movq    mm5, [edx + 50H]
+    movq    mm0, mm4
+    movq    [edx + 78H], mm6
+    punpcklwd mm0, mm5
+    movq    [edx + 68H], mm1
+    punpckhwd mm4, mm5
+    movq    mm5, mm2
+    punpcklwd mm2, mm3
+    movq    mm1, mm0
+    punpckldq mm0, mm2
+    punpckhdq mm1, mm2
+    movq    mm2, mm4
+    movq    [edx + 40H], mm0
+    punpckhwd mm5, mm3
+    movq    [edx + 50H], mm1
+    punpckhdq mm4, mm5
+    punpckldq mm2, mm5
+    movq    [edx + 70H], mm4
+    movq    [edx + 60H], mm2
+    movq    mm2, [edx + 30H]
+    movq    mm6, [eax + 10H]
+    movq    mm4, mm2
+    movq    mm7, [edx + 50H]
+    pmulhw  mm4, mm6
+    movq    mm1, [eax + 20H]
+    pmulhw  mm6, mm7
+    movq    mm5, mm1
+    pmulhw  mm1, mm2
+    movq    mm3, [edx + 10H]
+    pmulhw  mm5, mm7
+    movq    mm0, [eax]
+    paddw   mm4, mm2
+    paddw   mm6, mm7
+    paddw   mm2, mm1
+    movq    mm1, [edx + 70H]
+    paddw   mm7, mm5
+    movq    mm5, mm0
+    pmulhw  mm0, mm3
+    paddw   mm4, mm7
+    pmulhw  mm5, mm1
+    movq    mm7, [eax + 30H]
+    psubw   mm6, mm2
+    paddw   mm0, mm3
+    pmulhw  mm3, mm7
+    movq    mm2, [edx + 20H]
+    pmulhw  mm7, mm1
+    paddw   mm5, mm1
+    movq    mm1, mm2
+    pmulhw  mm2, [eax + 08H]
+    psubw   mm3, mm5
+    movq    mm5, [edx + 60H]
+    paddw   mm0, mm7
+    movq    mm7, mm5
+    psubw   mm0, mm4
+    pmulhw  mm5, [eax + 08H]
+    paddw   mm2, mm1
+    pmulhw  mm1, [eax + 28H]
+    paddw   mm4, mm4
+    paddw   mm4, mm0
+    psubw   mm3, mm6
+    paddw   mm5, mm7
+    paddw   mm6, mm6
+    pmulhw  mm7, [eax + 28H]
+    paddw   mm6, mm3
+    movq    [edx + 10H], mm4
+    psubw   mm1, mm5
+    movq    mm4, [eax + 18H]
+    movq    mm5, mm3
+    pmulhw  mm3, mm4
+    paddw   mm7, mm2
+    movq    [edx + 20H], mm6
+    movq    mm2, mm0
+    movq    mm6, [edx]
+    pmulhw  mm0, mm4
+    paddw   mm5, mm3
+    movq    mm3, [edx + 40H]
+    psubw   mm5, mm1
+    paddw   mm2, mm0
+    psubw   mm6, mm3
+    movq    mm0, mm6
+    pmulhw  mm6, mm4
+    paddw   mm3, mm3
+    paddw   mm1, mm1
+    paddw   mm3, mm0
+    paddw   mm1, mm5
+    pmulhw  mm4, mm3
+    paddw   mm6, mm0
+    psubw   mm6, mm2
+    paddw   mm2, mm2
+    movq    mm0, [edx + 10H]
+    paddw   mm2, mm6
+    paddw   mm4, mm3
+    psubw   mm2, mm1
+    paddw   mm2, [eax + 38H]
+    paddw   mm1, mm1
+    paddw   mm1, mm2
+    psraw   mm2, 4
+    psubw   mm4, mm7
+    psraw   mm1, 4
+    movq    mm3, [edx + 20H]
+    paddw   mm7, mm7
+    movq    [edx + 20H], mm2
+    paddw   mm7, mm4
+    movq    [edx + 10H], mm1
+    psubw   mm4, mm3
+    paddw   mm4, [eax + 38H]
+    paddw   mm3, mm3
+    paddw   mm3, mm4
+    psraw   mm4, 4
+    psubw   mm6, mm5
+    psraw   mm3, 4
+    paddw   mm6, [eax + 38H]
+    paddw   mm5, mm5
+    paddw   mm5, mm6
+    psraw   mm6, 4
+    movq    [edx + 40H], mm4
+    psraw   mm5, 4
+    movq    [edx + 30H], mm3
+    psubw   mm7, mm0
+    paddw   mm7, [eax + 38H]
+    paddw   mm0, mm0
+    paddw   mm0, mm7
+    psraw   mm7, 4
+    movq    [edx + 60H], mm6
+    psraw   mm0, 4
+    movq    [edx + 50H], mm5
+    movq    [edx + 70H], mm7
+    movq    [edx], mm0
+    movq    mm2, [edx + 38H]
+    movq    mm6, [eax + 10H]
+    movq    mm4, mm2
+    movq    mm7, [edx + 58H]
+    pmulhw  mm4, mm6
+    movq    mm1, [eax + 20H]
+    pmulhw  mm6, mm7
+    movq    mm5, mm1
+    pmulhw  mm1, mm2
+    movq    mm3, [edx + 18H]
+    pmulhw  mm5, mm7
+    movq    mm0, [eax]
+    paddw   mm4, mm2
+    paddw   mm6, mm7
+    paddw   mm2, mm1
+    movq    mm1, [edx + 78H]
+    paddw   mm7, mm5
+    movq    mm5, mm0
+    pmulhw  mm0, mm3
+    paddw   mm4, mm7
+    pmulhw  mm5, mm1
+    movq    mm7, [eax + 30H]
+    psubw   mm6, mm2
+    paddw   mm0, mm3
+    pmulhw  mm3, mm7
+    movq    mm2, [edx + 28H]
+    pmulhw  mm7, mm1
+    paddw   mm5, mm1
+    movq    mm1, mm2
+    pmulhw  mm2, [eax + 08H]
+    psubw   mm3, mm5
+    movq    mm5, [edx + 68H]
+    paddw   mm0, mm7
+    movq    mm7, mm5
+    psubw   mm0, mm4
+    pmulhw  mm5, [eax + 08H]
+    paddw   mm2, mm1
+    pmulhw  mm1, [eax + 28H]
+    paddw   mm4, mm4
+    paddw   mm4, mm0
+    psubw   mm3, mm6
+    paddw   mm5, mm7
+    paddw   mm6, mm6
+    pmulhw  mm7, [eax + 28H]
+    paddw   mm6, mm3
+    movq    [edx + 18H], mm4
+    psubw   mm1, mm5
+    movq    mm4, [eax + 18H]
+    movq    mm5, mm3
+    pmulhw  mm3, mm4
+    paddw   mm7, mm2
+    movq    [edx + 28H], mm6
+    movq    mm2, mm0
+    movq    mm6, [edx + 08H]
+    pmulhw  mm0, mm4
+    paddw   mm5, mm3
+    movq    mm3, [edx + 48H]
+    psubw   mm5, mm1
+    paddw   mm2, mm0
+    psubw   mm6, mm3
+    movq    mm0, mm6
+    pmulhw  mm6, mm4
+    paddw   mm3, mm3
+    paddw   mm1, mm1
+    paddw   mm3, mm0
+    paddw   mm1, mm5
+    pmulhw  mm4, mm3
+    paddw   mm6, mm0
+    psubw   mm6, mm2
+    paddw   mm2, mm2
+    movq    mm0, [edx + 18H]
+    paddw   mm2, mm6
+    paddw   mm4, mm3
+    psubw   mm2, mm1
+    paddw   mm2, [eax + 38H]
+    paddw   mm1, mm1
+    paddw   mm1, mm2
+    psraw   mm2, 4
+    psubw   mm4, mm7
+    psraw   mm1, 4
+    movq    mm3, [edx + 28H]
+    paddw   mm7, mm7
+    movq    [edx + 28H], mm2
+    paddw   mm7, mm4
+    movq    [edx + 18H], mm1
+    psubw   mm4, mm3
+    paddw   mm4, [eax + 38H]
+    paddw   mm3, mm3
+    paddw   mm3, mm4
+    psraw   mm4, 4
+    psubw   mm6, mm5
+    psraw   mm3, 4
+    paddw   mm6, [eax + 38H]
+    paddw   mm5, mm5
+    paddw   mm5, mm6
+    psraw   mm6, 4
+    movq    [edx + 48H], mm4
+    psraw   mm5, 4
+    movq    [edx + 38H], mm3
+    psubw   mm7, mm0
+    paddw   mm7, [eax + 38H]
+    paddw   mm0, mm0
+    paddw   mm0, mm7
+    psraw   mm7, 4
+    movq    [edx + 68H], mm6
+    psraw   mm0, 4
+    movq    [edx + 58H], mm5
+    movq    [edx + 78H], mm7
+    movq    [edx + 08H], mm0
+    /* emms  */
+  }
+}
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/mmxloopfilter.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/mmxloopfilter.c
new file mode 100644
index 0000000..62d06dc
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/mmxloopfilter.c
@@ -0,0 +1,377 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id:
+
+ ********************************************************************/
+
+/* -------------------------------------------------------------------
+  MMX based loop filter for the theora codec.
+
+  Originally written by Rudolf Marek, based on code from On2's VP3.
+  Converted to Visual Studio inline assembly by Nils Pipenbrinck.
+
+  Note: I can't test these since my example files never get into the
+  loop filters, but the code has been converted semi-automatic from
+  the GCC sources, so it ought to work.
+  ---------------------------------------------------------------------*/
+#include "../../internal.h"
+#include "x86int.h"
+#include <mmintrin.h>
+
+#if defined(USE_ASM)
+
+
+
+static void loop_filter_v(unsigned char *_pix,int _ystride,
+                          const ogg_int16_t *_ll){
+  _asm {
+    mov       eax,  [_pix]
+    mov       edx,  [_ystride]
+    mov       ebx,  [_ll]
+
+    /* _pix -= ystride */
+    sub       eax,   edx
+    /*  mm0=0          */
+    pxor      mm0,   mm0
+    /* _pix -= ystride */
+    sub       eax,   edx
+    /*  esi=_ystride*3 */
+    lea       esi, [edx + edx*2]
+
+    /*  mm7=_pix[0...8]*/
+    movq      mm7, [eax]
+    /*  mm4=_pix[0...8+_ystride*3]*/
+    movq      mm4, [eax + esi]
+    /*  mm6=_pix[0...8]*/
+    movq      mm6, mm7
+    /*  Expand unsigned _pix[0...3] to 16 bits.*/
+    punpcklbw mm6, mm0
+    movq      mm5, mm4
+    /*  Expand unsigned _pix[4...7] to 16 bits.*/
+    punpckhbw mm7, mm0
+    punpcklbw mm4, mm0
+    /*  Expand other arrays too.*/
+    punpckhbw mm5, mm0
+    /*mm7:mm6=_p[0...7]-_p[0...7+_ystride*3]:*/
+    psubw     mm6, mm4
+    psubw     mm7, mm5
+    /*mm5=mm4=_pix[0...7+_ystride]*/
+    movq      mm4, [eax + edx]
+    /*mm1=mm3=mm2=_pix[0..7]+_ystride*2]*/
+    movq      mm2, [eax + edx*2]
+    movq      mm5, mm4
+    movq      mm3, mm2
+    movq      mm1, mm2
+    /*Expand these arrays.*/
+    punpckhbw mm5, mm0
+    punpcklbw mm4, mm0
+    punpckhbw mm3, mm0
+    punpcklbw mm2, mm0
+    pcmpeqw   mm0, mm0
+    /*mm0=3 3 3 3
+    mm3:mm2=_pix[0...8+_ystride*2]-_pix[0...8+_ystride]*/
+    psubw     mm3, mm5
+    psrlw     mm0, 14
+    psubw     mm2, mm4
+    /*Scale by 3.*/
+    pmullw    mm3, mm0
+    pmullw    mm2, mm0
+    /*mm0=4 4 4 4
+    f=mm3:mm2==_pix[0...8]-_pix[0...8+_ystride*3]+
+     3*(_pix[0...8+_ystride*2]-_pix[0...8+_ystride])*/
+    psrlw     mm0, 1
+    paddw     mm3, mm7
+    psllw     mm0, 2
+    paddw     mm2, mm6
+    /*Add 4.*/
+    paddw     mm3, mm0
+    paddw     mm2, mm0
+    /*"Divide" by 8.*/
+    psraw     mm3, 3
+    psraw     mm2, 3
+    /*Now compute lflim of mm3:mm2 cf. Section 7.10 of the sepc.*/
+    /*Free up mm5.*/
+    packuswb  mm4, mm5
+    /*mm0=L L L L*/
+    movq      mm0, [ebx]
+    /*if(R_i<-2L||R_i>2L)R_i=0:*/
+    movq      mm5, mm2
+    pxor      mm6, mm6
+    movq      mm7, mm0
+    psubw     mm6, mm0
+    psllw     mm7, 1
+    psllw     mm6, 1
+    /*mm2==R_3 R_2 R_1 R_0*/
+    /*mm5==R_3 R_2 R_1 R_0*/
+    /*mm6==-2L -2L -2L -2L*/
+    /*mm7==2L 2L 2L 2L*/
+    pcmpgtw   mm7, mm2
+    pcmpgtw   mm5, mm6
+    pand      mm2, mm7
+    movq      mm7, mm0
+    pand      mm2, mm5
+    psllw     mm7, 1
+    movq      mm5, mm3
+    /*mm3==R_7 R_6 R_5 R_4*/
+    /*mm5==R_7 R_6 R_5 R_4*/
+    /*mm6==-2L -2L -2L -2L*/
+    /*mm7==2L 2L 2L 2L*/
+    pcmpgtw   mm7, mm3
+    pcmpgtw   mm5, mm6
+    pand      mm3, mm7
+    movq      mm7, mm0
+    pand      mm3, mm5
+   /*if(R_i<-L)R_i'=R_i+2L;
+     if(R_i>L)R_i'=R_i-2L;
+     if(R_i<-L||R_i>L)R_i=-R_i':*/
+    psraw     mm6, 1
+    movq      mm5, mm2
+    psllw     mm7, 1
+    /*mm2==R_3 R_2 R_1 R_0*/
+    /*mm5==R_3 R_2 R_1 R_0*/
+    /*mm6==-L -L -L -L*/
+    /*mm0==L L L L*/
+    /*mm5=R_i>L?FF:00*/
+    pcmpgtw   mm5, mm0
+    /*mm6=-L>R_i?FF:00*/
+    pcmpgtw   mm6, mm2
+    /*mm7=R_i>L?2L:0*/
+    pand      mm7, mm5
+    /*mm2=R_i>L?R_i-2L:R_i*/
+    psubw     mm2, mm7
+    movq      mm7, mm0
+    /*mm5=-L>R_i||R_i>L*/
+    por       mm5, mm6
+    psllw     mm7, 1
+    /*mm7=-L>R_i?2L:0*/
+    pand      mm7, mm6
+    pxor      mm6, mm6
+    /*mm2=-L>R_i?R_i+2L:R_i*/
+    paddw     mm2, mm7
+    psubw     mm6, mm0
+    /*mm5=-L>R_i||R_i>L?-R_i':0*/
+    pand      mm5, mm2
+    movq      mm7, mm0
+    /*mm2=-L>R_i||R_i>L?0:R_i*/
+    psubw     mm2, mm5
+    psllw     mm7, 1
+    /*mm2=-L>R_i||R_i>L?-R_i':R_i*/
+    psubw     mm2, mm5
+    movq      mm5, mm3
+    /*mm3==R_7 R_6 R_5 R_4*/
+    /*mm5==R_7 R_6 R_5 R_4*/
+    /*mm6==-L -L -L -L*/
+    /*mm0==L L L L*/
+    /*mm6=-L>R_i?FF:00*/
+    pcmpgtw   mm6, mm3
+    /*mm5=R_i>L?FF:00*/
+    pcmpgtw   mm5, mm0
+    /*mm7=R_i>L?2L:0*/
+    pand      mm7, mm5
+    /*mm2=R_i>L?R_i-2L:R_i*/
+    psubw     mm3, mm7
+    psllw     mm0, 1
+    /*mm5=-L>R_i||R_i>L*/
+    por       mm5, mm6
+    /*mm0=-L>R_i?2L:0*/
+    pand      mm0, mm6
+    /*mm3=-L>R_i?R_i+2L:R_i*/
+    paddw     mm3, mm0
+    /*mm5=-L>R_i||R_i>L?-R_i':0*/
+    pand      mm5, mm3
+    /*mm2=-L>R_i||R_i>L?0:R_i*/
+    psubw     mm3, mm5
+    /*mm3=-L>R_i||R_i>L?-R_i':R_i*/
+    psubw     mm3, mm5
+    /*Unfortunately, there's no unsigned byte+signed byte with unsigned
+       saturation op code, so we have to promote things back 16 bits.*/
+    pxor      mm0, mm0
+    movq      mm5, mm4
+    punpcklbw mm4, mm0
+    punpckhbw mm5, mm0
+    movq      mm6, mm1
+    punpcklbw mm1, mm0
+    punpckhbw mm6, mm0
+    /*_pix[0...8+_ystride]+=R_i*/
+    paddw     mm4, mm2
+    paddw     mm5, mm3
+    /*_pix[0...8+_ystride*2]-=R_i*/
+    psubw     mm1, mm2
+    psubw     mm6, mm3
+    packuswb  mm4, mm5
+    packuswb  mm1, mm6
+    /*Write it back out.*/
+    movq    [eax + edx], mm4
+    movq    [eax + edx*2], mm1
+  }
+}
+
+/*This code implements the bulk of loop_filter_h().
+  Data are striped p0 p1 p2 p3 ... p0 p1 p2 p3 ..., so in order to load all
+   four p0's to one register we must transpose the values in four mmx regs.
+  When half is done we repeat this for the rest.*/
+static void loop_filter_h4(unsigned char *_pix,long _ystride,
+                           const ogg_int16_t *_ll){
+  /* todo: merge the comments from the GCC sources */
+  _asm {
+    mov   ecx, [_pix]
+    mov   edx, [_ystride]
+    mov   eax, [_ll]
+    /*esi=_ystride*3*/
+    lea     esi, [edx + edx*2]
+
+    movd    mm0, dword ptr [ecx]
+    movd    mm1, dword ptr [ecx + edx]
+    movd    mm2, dword ptr [ecx + edx*2]
+    movd    mm3, dword ptr [ecx + esi]
+    punpcklbw mm0, mm1
+    punpcklbw mm2, mm3
+    movq    mm1, mm0
+    punpckhwd mm0, mm2
+    punpcklwd mm1, mm2
+    pxor    mm7, mm7
+    movq    mm5, mm1
+    punpcklbw mm1, mm7
+    punpckhbw mm5, mm7
+    movq    mm3, mm0
+    punpcklbw mm0, mm7
+    punpckhbw mm3, mm7
+    psubw   mm1, mm3
+    movq    mm4, mm0
+    pcmpeqw mm2, mm2
+    psubw   mm0, mm5
+    psrlw   mm2, 14
+    pmullw  mm0, mm2
+    psrlw   mm2, 1
+    paddw   mm0, mm1
+    psllw   mm2, 2
+    paddw   mm0, mm2
+    psraw   mm0, 3
+    movq    mm6, qword ptr [eax]
+    movq    mm1, mm0
+    pxor    mm2, mm2
+    movq    mm3, mm6
+    psubw   mm2, mm6
+    psllw   mm3, 1
+    psllw   mm2, 1
+    pcmpgtw mm3, mm0
+    pcmpgtw mm1, mm2
+    pand    mm0, mm3
+    pand    mm0, mm1
+    psraw   mm2, 1
+    movq    mm1, mm0
+    movq    mm3, mm6
+    pcmpgtw mm2, mm0
+    pcmpgtw mm1, mm6
+    psllw   mm3, 1
+    psllw   mm6, 1
+    pand    mm3, mm1
+    pand    mm6, mm2
+    psubw   mm0, mm3
+    por     mm1, mm2
+    paddw   mm0, mm6
+    pand    mm1, mm0
+    psubw   mm0, mm1
+    psubw   mm0, mm1
+    paddw   mm5, mm0
+    psubw   mm4, mm0
+    packuswb mm5, mm7
+    packuswb mm4, mm7
+    punpcklbw mm5, mm4
+    movd    edi, mm5
+    mov     word ptr [ecx + 01H], di
+    psrlq   mm5, 32
+    shr     edi, 16
+    mov     word ptr [ecx + edx + 01H], di
+    movd    edi, mm5
+    mov     word ptr [ecx + edx*2 + 01H], di
+    shr     edi, 16
+    mov     word ptr [ecx + esi + 01H], di
+  }
+}
+
+static void loop_filter_h(unsigned char *_pix,int _ystride,
+                          const ogg_int16_t *_ll){
+  _pix-=2;
+  loop_filter_h4(_pix,_ystride,_ll);
+  loop_filter_h4(_pix+(_ystride<<2),_ystride,_ll);
+}
+
+
+/*We copy the whole function because the MMX routines will be inlined 4 times,
+   and we can do just a single emms call at the end this way.
+  We also do not use the _bv lookup table, instead computing the values that
+   would lie in it on the fly.*/
+
+/*Apply the loop filter to a given set of fragment rows in the given plane.
+  The filter may be run on the bottom edge, affecting pixels in the next row of
+   fragments, so this row also needs to be available.
+  _bv:        The bounding values array.
+  _refi:      The index of the frame buffer to filter.
+  _pli:       The color plane to filter.
+  _fragy0:    The Y coordinate of the first fragment row to filter.
+  _fragy_end: The Y coordinate of the fragment row to stop filtering at.*/
+void oc_state_loop_filter_frag_rows_mmx(oc_theora_state *_state,int *_bv,
+ int _refi,int _pli,int _fragy0,int _fragy_end){
+  ogg_int16_t __declspec(align(8))        ll[4];
+  th_img_plane                            *iplane;
+  oc_fragment_plane                       *fplane;
+  oc_fragment                             *frag_top;
+  oc_fragment                             *frag0;
+  oc_fragment                             *frag;
+  oc_fragment                             *frag_end;
+  oc_fragment                             *frag0_end;
+  oc_fragment                             *frag_bot;
+  ll[0]=ll[1]=ll[2]=ll[3]=
+   (ogg_int16_t)_state->loop_filter_limits[_state->qis[0]];
+  iplane=_state->ref_frame_bufs[_refi]+_pli;
+  fplane=_state->fplanes+_pli;
+  /*The following loops are constructed somewhat non-intuitively on purpose.
+    The main idea is: if a block boundary has at least one coded fragment on
+     it, the filter is applied to it.
+    However, the order that the filters are applied in matters, and VP3 chose
+     the somewhat strange ordering used below.*/
+  frag_top=_state->frags+fplane->froffset;
+  frag0=frag_top+_fragy0*fplane->nhfrags;
+  frag0_end=frag0+(_fragy_end-_fragy0)*fplane->nhfrags;
+  frag_bot=_state->frags+fplane->froffset+fplane->nfrags;
+  while(frag0<frag0_end){
+    frag=frag0;
+    frag_end=frag+fplane->nhfrags;
+    while(frag<frag_end){
+      if(frag->coded){
+        if(frag>frag0){
+          loop_filter_h(frag->buffer[_refi],iplane->stride,ll);
+        }
+        if(frag0>frag_top){
+          loop_filter_v(frag->buffer[_refi],iplane->stride,ll);
+        }
+        if(frag+1<frag_end&&!(frag+1)->coded){
+          loop_filter_h(frag->buffer[_refi]+8,iplane->stride,ll);
+        }
+        if(frag+fplane->nhfrags<frag_bot&&!(frag+fplane->nhfrags)->coded){
+          loop_filter_v((frag+fplane->nhfrags)->buffer[_refi],
+           iplane->stride,ll);
+        }
+      }
+      frag++;
+    }
+    frag0+=fplane->nhfrags;
+  }
+
+  /*This needs to be removed when decode specific functions are implemented:*/
+  _mm_empty();
+}
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/mmxstate.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/mmxstate.c
new file mode 100644
index 0000000..526ef53
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/mmxstate.c
@@ -0,0 +1,189 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2008                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: mmxstate.c 15400 2008-10-15 12:10:58Z tterribe $
+
+ ********************************************************************/
+
+/* ------------------------------------------------------------------------
+  MMX acceleration of complete fragment reconstruction algorithm.
+    Originally written by Rudolf Marek.
+
+  Conversion to MSC intrinsics by Nils Pipenbrinck.
+  ---------------------------------------------------------------------*/
+#if defined(USE_ASM)
+
+#include "../../internal.h"
+#include "../idct.h"
+#include "x86int.h"
+#include <mmintrin.h>
+
+static const unsigned char OC_FZIG_ZAGMMX[64]=
+{
+   0, 8, 1, 2, 9,16,24,17,
+  10, 3,32,11,18,25, 4,12,
+   5,26,19,40,33,34,41,48,
+  27, 6,13,20,28,21,14, 7,
+  56,49,42,35,43,50,57,36,
+  15,22,29,30,23,44,37,58,
+  51,59,38,45,52,31,60,53,
+  46,39,47,54,61,62,55,63
+};
+
+/* Fill a block with value */
+static __inline void loc_fill_mmx_value (__m64 * _dst, __m64 _value){
+  __m64 t   = _value;
+  _dst[0]  = t;  _dst[1]  = t;  _dst[2]  = t;  _dst[3]  = t;
+  _dst[4]  = t;  _dst[5]  = t;  _dst[6]  = t;  _dst[7]  = t;
+  _dst[8]  = t;  _dst[9]  = t;  _dst[10] = t;  _dst[11] = t;
+  _dst[12] = t;  _dst[13] = t;  _dst[14] = t;  _dst[15] = t;
+}
+
+/* copy a block of 8 byte elements using different strides */
+static __inline void loc_blockcopy_mmx (unsigned char * _dst, int _dst_ystride,
+                                        unsigned char * _src, int _src_ystride){
+  __m64 a,b,c,d,e,f,g,h;
+  a = *(__m64*)(_src + 0 * _src_ystride);
+  b = *(__m64*)(_src + 1 * _src_ystride);
+  c = *(__m64*)(_src + 2 * _src_ystride);
+  d = *(__m64*)(_src + 3 * _src_ystride);
+  e = *(__m64*)(_src + 4 * _src_ystride);
+  f = *(__m64*)(_src + 5 * _src_ystride);
+  g = *(__m64*)(_src + 6 * _src_ystride);
+  h = *(__m64*)(_src + 7 * _src_ystride);
+  *(__m64*)(_dst + 0 * _dst_ystride) = a;
+  *(__m64*)(_dst + 1 * _dst_ystride) = b;
+  *(__m64*)(_dst + 2 * _dst_ystride) = c;
+  *(__m64*)(_dst + 3 * _dst_ystride) = d;
+  *(__m64*)(_dst + 4 * _dst_ystride) = e;
+  *(__m64*)(_dst + 5 * _dst_ystride) = f;
+  *(__m64*)(_dst + 6 * _dst_ystride) = g;
+  *(__m64*)(_dst + 7 * _dst_ystride) = h;
+}
+
+void oc_state_frag_recon_mmx(oc_theora_state *_state,const oc_fragment *_frag,
+ int _pli,ogg_int16_t _dct_coeffs[128],int _last_zzi,int _ncoefs,
+ ogg_uint16_t _dc_iquant,const ogg_uint16_t _ac_iquant[64]){
+  ogg_int16_t __declspec(align(16)) res_buf[64];
+  int dst_framei;
+  int dst_ystride;
+  int zzi;
+  /*_last_zzi is subtly different from an actual count of the number of
+     coefficients we decoded for this block.
+    It contains the value of zzi BEFORE the final token in the block was
+     decoded.
+    In most cases this is an EOB token (the continuation of an EOB run from a
+     previous block counts), and so this is the same as the coefficient count.
+    However, in the case that the last token was NOT an EOB token, but filled
+     the block up with exactly 64 coefficients, _last_zzi will be less than 64.
+    Provided the last token was not a pure zero run, the minimum value it can
+     be is 46, and so that doesn't affect any of the cases in this routine.
+    However, if the last token WAS a pure zero run of length 63, then _last_zzi
+     will be 1 while the number of coefficients decoded is 64.
+    Thus, we will trigger the following special case, where the real
+     coefficient count would not.
+    Note also that a zero run of length 64 will give _last_zzi a value of 0,
+     but we still process the DC coefficient, which might have a non-zero value
+     due to DC prediction.
+    Although convoluted, this is arguably the correct behavior: it allows us to
+     dequantize fewer coefficients and use a smaller transform when the block
+     ends with a long zero run instead of a normal EOB token.
+    It could be smarter... multiple separate zero runs at the end of a block
+     will fool it, but an encoder that generates these really deserves what it
+     gets.
+    Needless to say we inherited this approach from VP3.*/
+  /*Special case only having a DC component.*/
+  if(_last_zzi<2){
+    __m64 p;
+    /*Why is the iquant product rounded in this case and no others? Who knows.*/
+    p = _m_from_int((ogg_int32_t)_frag->dc*_dc_iquant+15>>5);
+    /* broadcast 16 bits into all 4 mmx subregisters */
+    p = _m_punpcklwd (p,p);
+    p = _m_punpckldq (p,p);
+    loc_fill_mmx_value ((__m64 *)res_buf, p);
+  }
+  else{
+    /*Then, fill in the remainder of the coefficients with 0's, and perform
+       the iDCT.*/
+    /*First zero the buffer.*/
+    /*On K7, etc., this could be replaced with movntq and sfence.*/
+    loc_fill_mmx_value ((__m64 *)res_buf, _mm_setzero_si64());
+
+    res_buf[0]=(ogg_int16_t)((ogg_int32_t)_frag->dc*_dc_iquant);
+    /*This is planned to be rewritten in MMX.*/
+    for(zzi=1;zzi<_ncoefs;zzi++)
+    {
+      int ci;
+      ci=OC_FZIG_ZAG[zzi];
+      res_buf[OC_FZIG_ZAGMMX[zzi]]=(ogg_int16_t)((ogg_int32_t)_dct_coeffs[zzi]*
+       _ac_iquant[ci]);
+    }
+
+    if(_last_zzi<10){
+      oc_idct8x8_10_mmx(res_buf);
+    }
+    else {
+      oc_idct8x8_mmx(res_buf);
+    }
+  }
+  /*Fill in the target buffer.*/
+  dst_framei=_state->ref_frame_idx[OC_FRAME_SELF];
+  dst_ystride=_state->ref_frame_bufs[dst_framei][_pli].stride;
+  /*For now ystride values in all ref frames assumed to be equal.*/
+  if(_frag->mbmode==OC_MODE_INTRA){
+    oc_frag_recon_intra_mmx(_frag->buffer[dst_framei],dst_ystride,res_buf);
+  }
+  else{
+    int ref_framei;
+    int ref_ystride;
+    int mvoffsets[2];
+    ref_framei=_state->ref_frame_idx[OC_FRAME_FOR_MODE[_frag->mbmode]];
+    ref_ystride=_state->ref_frame_bufs[ref_framei][_pli].stride;
+    if(oc_state_get_mv_offsets(_state,mvoffsets,_frag->mv[0],
+     _frag->mv[1],ref_ystride,_pli)>1){
+      oc_frag_recon_inter2_mmx(_frag->buffer[dst_framei],dst_ystride,
+       _frag->buffer[ref_framei]+mvoffsets[0],ref_ystride,
+       _frag->buffer[ref_framei]+mvoffsets[1],ref_ystride,res_buf);
+    }
+    else{
+      oc_frag_recon_inter_mmx(_frag->buffer[dst_framei],dst_ystride,
+       _frag->buffer[ref_framei]+mvoffsets[0],ref_ystride,res_buf);
+    }
+  }
+
+  _mm_empty();
+}
+
+
+void oc_state_frag_copy_mmx(const oc_theora_state *_state,const int *_fragis,
+ int _nfragis,int _dst_frame,int _src_frame,int _pli){
+  const int *fragi;
+  const int *fragi_end;
+  int        dst_framei;
+  int        dst_ystride;
+  int        src_framei;
+  int        src_ystride;
+  dst_framei=_state->ref_frame_idx[_dst_frame];
+  src_framei=_state->ref_frame_idx[_src_frame];
+  dst_ystride=_state->ref_frame_bufs[dst_framei][_pli].stride;
+  src_ystride=_state->ref_frame_bufs[src_framei][_pli].stride;
+  fragi_end=_fragis+_nfragis;
+  for(fragi=_fragis;fragi<fragi_end;fragi++){
+    oc_fragment *frag = _state->frags+*fragi;
+    loc_blockcopy_mmx (frag->buffer[dst_framei], dst_ystride,
+                       frag->buffer[src_framei], src_ystride);
+  }
+  _m_empty();
+}
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/x86int.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/x86int.h
new file mode 100644
index 0000000..be50161
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/x86int.h
@@ -0,0 +1,49 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: x86int.h 15400 2008-10-15 12:10:58Z tterribe $
+
+ ********************************************************************/
+
+#if !defined(_x86_x86int_vc_H)
+# define _x86_x86int_vc_H (1)
+# include "../../internal.h"
+
+void oc_state_vtable_init_x86(oc_theora_state *_state);
+
+void oc_frag_recon_intra_mmx(unsigned char *_dst,int _dst_ystride,
+ const ogg_int16_t *_residue);
+
+void oc_frag_recon_inter_mmx(unsigned char *_dst,int _dst_ystride,
+ const unsigned char *_src,int _src_ystride,const ogg_int16_t *_residue);
+
+void oc_frag_recon_inter2_mmx(unsigned char *_dst,int _dst_ystride,
+ const unsigned char *_src1,int _src1_ystride,const unsigned char *_src2,
+ int _src2_ystride,const ogg_int16_t *_residue);
+
+void oc_state_frag_copy_mmx(const oc_theora_state *_state,const int *_fragis,
+ int _nfragis,int _dst_frame,int _src_frame,int _pli);
+
+void oc_restore_fpu_mmx(void);
+
+void oc_state_frag_recon_mmx(oc_theora_state *_state,const oc_fragment *_frag,                                               
+ int _pli,ogg_int16_t _dct_coeffs[128],int _last_zzi,int _ncoefs,                                                             
+ ogg_uint16_t _dc_iquant,const ogg_uint16_t _ac_iquant[64]);
+
+void oc_idct8x8_mmx(ogg_int16_t _y[64]);
+void oc_idct8x8_10_mmx(ogg_int16_t _y[64]);
+
+void oc_state_loop_filter_frag_rows_mmx(oc_theora_state *_state,int *_bv,                                                    
+  int _refi,int _pli,int _fragy0,int _fragy_end);
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/x86state.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/x86state.c
new file mode 100644
index 0000000..7353908
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/dec/x86_vc/x86state.c
@@ -0,0 +1,41 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2008                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: x86state.c 15427 2008-10-21 02:36:19Z xiphmont $
+
+ ********************************************************************/
+
+#if defined(USE_ASM)
+
+#include "x86int.h"
+#include "../../cpu.c"
+
+void oc_state_vtable_init_x86(oc_theora_state *_state){
+  _state->cpu_flags=oc_cpu_flags_get();
+
+  /* fill with defaults */
+  oc_state_vtable_init_c(_state);
+
+  /* patch MMX functions */
+  if(_state->cpu_flags&OC_CPU_X86_MMX){
+    _state->opt_vtable.frag_recon_intra=oc_frag_recon_intra_mmx;
+    _state->opt_vtable.frag_recon_inter=oc_frag_recon_inter_mmx;
+    _state->opt_vtable.frag_recon_inter2=oc_frag_recon_inter2_mmx;
+    _state->opt_vtable.restore_fpu=oc_restore_fpu_mmx;
+    _state->opt_vtable.state_frag_copy=oc_state_frag_copy_mmx;
+    _state->opt_vtable.state_frag_recon=oc_state_frag_recon_mmx;
+    _state->opt_vtable.state_loop_filter_frag_rows=oc_state_loop_filter_frag_rows_mmx;
+  }
+}
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/codec_internal.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/codec_internal.h
new file mode 100644
index 0000000..7e28236
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/codec_internal.h
@@ -0,0 +1,531 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2008                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: codec_internal.h 16044 2009-05-27 02:05:43Z tterribe $
+
+ ********************************************************************/
+
+#ifndef ENCODER_INTERNAL_H
+#define ENCODER_INTERNAL_H
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/*#define OC_COLLECT_METRICS*/
+
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+#include "vtkoggtheora/include/theora/theora.h"
+#include "../internal.h"
+#include "encoder_huffman.h"
+#include "huffenc.h"
+#include "../dec/ocintrin.h"
+
+
+
+typedef struct oc_enc_opt_vtable oc_enc_opt_vtable;
+typedef struct CP_INSTANCE       CP_INSTANCE;
+
+
+struct oc_enc_opt_vtable{
+  unsigned (*frag_sad)(const unsigned char *_src,
+   const unsigned char *_ref,int _ystride);
+  unsigned (*frag_sad_thresh)(const unsigned char *_src,
+   const unsigned char *_ref,int _ystride,unsigned _thresh);
+  unsigned (*frag_sad2_thresh)(const unsigned char *_src,
+   const unsigned char *_ref1,const unsigned char *_ref2,int _ystride,
+   unsigned _thresh);
+  unsigned (*frag_satd_thresh)(const unsigned char *_src,
+   const unsigned char *_ref,int _ystride,unsigned _thresh);
+  unsigned (*frag_satd2_thresh)(const unsigned char *_src,
+   const unsigned char *_ref1,const unsigned char *_ref2,int _ystride,
+   unsigned _thresh);
+  unsigned (*frag_intra_satd)(const unsigned char *_src,int _ystride);
+  void     (*frag_sub)(ogg_int16_t _diff[64],const unsigned char *_src,
+   const unsigned char *_ref,int _ystride);
+  void     (*frag_sub_128)(ogg_int16_t _diff[64],
+   const unsigned char *_src,int _ystride);
+  void     (*frag_copy)(unsigned char *_dst,
+   const unsigned char *_src,int _ystride);
+  void     (*frag_copy2)(unsigned char *_dst,
+   const unsigned char *_src1,const unsigned char *_src2,int _ystride);
+  void     (*frag_recon_intra)(unsigned char *_dst,int _ystride,
+   const ogg_int16_t _residue[64]);
+  void     (*frag_recon_inter)(unsigned char *_dst,
+   const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]);
+  void     (*fdct8x8)(ogg_int16_t _y[64],const ogg_int16_t _x[64]);
+  void     (*dequant_idct8x8)(ogg_int16_t _y[64],const ogg_int16_t _x[64],
+   int _last_zzi,int _ncoefs,ogg_uint16_t _dc_quant,
+   const ogg_uint16_t _ac_quant[64]);
+  void     (*enc_loop_filter)(CP_INSTANCE *cpi,int _flimit);
+  void     (*restore_fpu)(void);
+};
+
+
+void oc_enc_vtable_init(CP_INSTANCE *_cpi);
+
+/* Baseline dct height and width. */
+#define BLOCK_HEIGHT_WIDTH          8
+#define HFRAGPIXELS                 8
+#define VFRAGPIXELS                 8
+
+/* Baseline dct block size */
+#define BLOCK_SIZE              (BLOCK_HEIGHT_WIDTH * BLOCK_HEIGHT_WIDTH)
+
+/* Border is for unrestricted mv's */
+#define UMV_BORDER              16
+#define STRIDE_EXTRA            (UMV_BORDER * 2)
+
+#define KEY_FRAME               0
+#define DELTA_FRAME             1
+
+#define MAX_MODES               8
+#define MODE_BITS               3
+#define MODE_METHODS            8
+#define MODE_METHOD_BITS        3
+
+#define MAX_MV_EXTENT 31  /* Max search distance in half pixel increments */
+
+/** block coding modes */
+typedef enum{
+  CODE_INTER_NO_MV        = 0x0, /* INTER prediction, (0,0) motion
+                                    vector implied.  */
+    CODE_INTRA            = 0x1, /* INTRA i.e. no prediction. */
+    CODE_INTER_PLUS_MV    = 0x2, /* INTER prediction, non zero motion
+                                    vector. */
+    CODE_INTER_LAST_MV    = 0x3, /* Use Last Motion vector */
+    CODE_INTER_PRIOR_LAST = 0x4, /* Prior last motion vector */
+    CODE_USING_GOLDEN     = 0x5, /* 'Golden frame' prediction (no MV). */
+    CODE_GOLDEN_MV        = 0x6, /* 'Golden frame' prediction plus MV. */
+    CODE_INTER_FOURMV     = 0x7  /* Inter prediction 4MV per macro block. */
+} coding_mode_t;
+
+/** Huffman table entry */
+typedef struct HUFF_ENTRY {
+  struct HUFF_ENTRY *ZeroChild;
+  struct HUFF_ENTRY *OneChild;
+  struct HUFF_ENTRY *Previous;
+  struct HUFF_ENTRY *Next;
+  ogg_int32_t        Value;
+  ogg_uint32_t       Frequency;
+} HUFF_ENTRY;
+
+typedef struct mc_state mc_state;
+
+struct mc_state{
+  int                candidates[12][2];
+  int                setb0;
+  int                ncandidates;
+  ogg_int32_t        mvapw1[2];
+  ogg_int32_t        mvapw2[2];
+};
+
+typedef struct macroblock {
+  /* the blocks comprising this macroblock */
+  int Ryuv[3][4]; /* [Y,U,V][raster order] */
+  int Hyuv[3][4]; /* [Y,U,V][hilbert order] */
+  int ysb;
+  int usb;
+  int vsb;
+
+  int cneighbors[4];
+  int ncneighbors;
+  int pneighbors[4];
+  int npneighbors; 
+
+  coding_mode_t mode;
+
+  oc_mv block_mv[4];
+  oc_mv ref_mv[4];
+  /* per-block final motion vectors */
+  /* raster order */
+  oc_mv mv[4];
+  /*Per-block final chroma motion vectors.*/
+  oc_mv cbmvs[4];
+
+  /* Motion vectors for a macro block for the current frame and the
+     previous two frames.
+
+     Each is a set of 2 vectors against the previous frame and against
+     the golden frame, which can be used to judge constant velocity
+     and constant acceleration.
+
+     Uninitialized MVs are (0,0).*/
+  oc_mv analysis_mv[3][2]; /* [cur,prev,prev2][frame,golden] */
+  oc_mv unref_mv[2];
+  /*Minimum motion estimation error from the analysis stage.*/
+  int    aerror;
+  int    gerror;
+  int    asatd;
+  int    gsatd;
+  int    block_satd[4];
+
+  char coded;
+  char refined;
+} macroblock_t;
+
+#define SB_MB_BLFRAG(sb,mbnum) ((sb).f[ ((mbnum)<2? ((mbnum)==0?0:4) : ((mbnum)==2?8:14)) ])
+typedef struct superblock {
+  int f[16]; // hilbert order
+  int m[16]; // hilbert order: only 4 for luma, but 16 for U/V (to match f) */
+} superblock_t;
+
+typedef ogg_int16_t    quant_table[64];
+typedef quant_table    quant_tables[64]; /* [zigzag][qi] */
+
+#include "enquant.h"
+
+typedef struct oc_mode_scheme_chooser oc_mode_scheme_chooser;
+
+struct oc_mode_scheme_chooser{
+  /*Pointers to the a list containing the index of each mode in the mode
+    alphabet used by each scheme.
+    The first entry points to the dynamic scheme0_ranks, while the remaining
+    7 point to the constant entries stored in OC_MODE_SCHEMES.*/
+  const unsigned char *mode_ranks[8];
+  /*The ranks for each mode when coded with scheme 0.
+    These are optimized so that the more frequent modes have lower ranks.*/
+  unsigned char        scheme0_ranks[OC_NMODES];
+  /*The list of modes, sorted in descending order of frequency, that
+    corresponds to the ranks above.*/
+  unsigned char        scheme0_list[OC_NMODES];
+  /*The number of times each mode has been chosen so far.*/
+  int                  mode_counts[OC_NMODES];
+  /*The list of mode coding schemes, sorted in ascending order of bit cost.*/
+  unsigned char        scheme_list[8];
+  /*The number of bits used by each mode coding scheme.*/
+  int                  scheme_bits[8];
+};
+
+void oc_mode_scheme_chooser_init(oc_mode_scheme_chooser *_chooser);
+
+typedef struct oc_rc_state oc_rc_state;
+
+struct oc_rc_state{
+  ogg_int64_t bits_per_frame;
+  ogg_int64_t fullness;
+  ogg_int64_t target;
+  ogg_int64_t max;
+  ogg_int64_t log_npixels;
+  unsigned    exp[2];
+  ogg_int64_t log_scale[2];
+  ogg_int64_t log_qtarget;
+  int         buf_delay;
+};
+
+/* Encoder (Compressor) instance -- installed in a theora_state */
+struct CP_INSTANCE {
+  /*This structure must be first.
+    It contains entry points accessed by the decoder library's API wrapper, and
+     is the only assumption that library makes about our internal format.*/
+  oc_state_dispatch_vtable  dispatch_vtbl;
+
+  theora_info               info;
+
+  /* ogg bitpacker for use in packet coding, other API state */
+  oggpack_buffer           *oggbuffer;
+  /*The number of duplicates to produce for the next frame.*/
+  int                       dup_count;
+  /*The number of duplicates remaining to be emitted for the current frame.*/
+  int                       nqueued_dups;
+
+  unsigned char            *frame;
+  unsigned char            *recon;
+  unsigned char            *golden;
+  unsigned char            *lastrecon;
+  ogg_uint32_t              frame_size;
+
+  /*Superblock, macroblock and fragment Information.*/
+  unsigned char            *frag_coded;
+  ogg_uint32_t             *frag_buffer_index;
+  ogg_int16_t              *frag_dc;
+  ogg_int16_t              *frag_dc_tmp;
+
+  macroblock_t             *macro;
+  superblock_t             *super[3];
+
+  ogg_uint32_t              frag_h[3];
+  ogg_uint32_t              frag_v[3];
+  ogg_uint32_t              frag_n[3];
+  ogg_uint32_t              frag_total;
+
+  ogg_uint32_t              macro_h;
+  ogg_uint32_t              macro_v;
+  ogg_uint32_t              macro_total;
+  
+  ogg_uint32_t              super_h[3];
+  ogg_uint32_t              super_v[3];
+  ogg_uint32_t              super_n[3];
+  ogg_uint32_t              super_total;
+
+  /*Stride of image and recon planes, accounting for borders.*/
+  ogg_uint32_t              stride[3];
+  /*Data offset of first coded pixel in plane.*/
+  ogg_uint32_t              offset[3];
+
+  /*********************************************************************/
+  /* state and stats */
+
+  int                       HeadersWritten;
+  ogg_uint32_t              LastKeyFrame;
+  ogg_int64_t               CurrentFrame;
+  unsigned char             FrameType;
+  int                       readyflag;
+  int                       packetflag;
+  int                       doneflag;
+  int                       first_inter_frame;
+
+  /*Indexed via [key/inter][dc/ac][luma/chroma].*/
+  int                       huffchoice[2][2][2];
+
+  ogg_uint32_t              dc_bits[2][DC_HUFF_CHOICES];
+  ogg_uint32_t              ac1_bits[2][AC_HUFF_CHOICES];
+  ogg_uint32_t              acN_bits[2][AC_HUFF_CHOICES];
+  /*Count of bits used by MV coding mode 0.*/
+  ogg_uint32_t              MVBits_0;
+  /*Count of bits used by MV coding mode 1.*/
+  ogg_uint32_t              MVBits_1;
+  oc_mode_scheme_chooser    chooser;
+
+  /*********************************************************************/
+  /* Token Buffers */
+  int                      *fr_partial;
+  unsigned char            *fr_partial_bits;
+  int                      *fr_full;
+  unsigned char            *fr_full_bits;
+  ogg_int16_t              *fr_block;
+  unsigned char            *fr_block_bits;
+  int                       fr_partial_count;
+  int                       fr_full_count;
+  int                       fr_block_count;
+
+
+  int                       stack_offset;
+  unsigned char            *dct_token_storage;
+  ogg_uint16_t             *dct_token_eb_storage;
+  unsigned char            *dct_token[64];
+  ogg_uint16_t             *dct_token_eb[64];
+
+  ogg_int32_t               dct_token_count[64];
+  ogg_int32_t               dct_token_ycount[64];
+
+  int                       eob_run[64];
+  int                       eob_pre[64];
+  int                       eob_ypre[64];
+
+  /********************************************************************/
+  /* Fragment SAD->bitrate estimation tracking metrics */
+  long                      rho_count[65]; 
+
+#if defined(OC_COLLECT_METRICS)
+  long                      rho_postop;
+  int                      *frag_mbi;
+  int                      *frag_sad;
+  int                      *frag_ssd;
+  int                      *dct_token_frag_storage;
+  int                      *dct_token_frag[64];
+  int                      *dct_eob_fi_storage;
+  int                      *dct_eob_fi_stack[64];
+  int                       dct_eob_fi_count[64];
+  ogg_int64_t               dist_dist[3][8];
+  ogg_int64_t               dist_bits[3][8];
+#endif
+
+  /********************************************************************/
+  /* Setup */
+  int                     keyframe_granule_shift;
+  int                     lambda;
+  int                     BaseQ;
+  int                     MinQ;
+  int                     GoldenFrameEnabled;
+  int                     InterPrediction;
+  int                     MotionCompensation;
+
+  /* hufftables and quant setup ****************************************/
+
+  th_huff_code            huff_codes[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS];
+
+  th_quant_info           quant_info;
+  quant_tables            quant_tables[2][3];
+  oc_iquant_tables        iquant_tables[2][3];
+  /*An "average" quantizer for each quantizer type (INTRA or INTER) and QI
+     value.
+    This is used to paramterize the rate control decisions.
+    They are kept in the log domain to simplify later processing.
+    Keep in mind these are DCT domain quantizers, and so are scaled by an
+     additional factor of 4 from the pixel domain.*/
+  ogg_int64_t             log_qavg[2][64];
+  /*The buffer state used to drive rate control.*/
+  oc_rc_state             rc;
+  /*Table for encoder acceleration functions.*/
+  oc_enc_opt_vtable       opt_vtable;
+};
+
+extern void ReconRefFrames (CP_INSTANCE *cpi);
+
+typedef struct {
+  int coeff;
+  int count; /* -1 indicates no token, ie, midst of an EOB run */
+  int chroma;
+  int pre;
+  int run;
+#if defined(OC_COLLECT_METRICS)
+  int runstack;
+#endif
+} token_checkpoint_t;
+
+extern void tokenlog_commit(CP_INSTANCE *cpi, 
+			    token_checkpoint_t *stack, 
+			    int n);
+extern void tokenlog_rollback(CP_INSTANCE *cpi, 
+			      token_checkpoint_t *stack,
+			      int n);
+extern void dct_tokenize_init (CP_INSTANCE *cpi);
+extern int dct_tokenize_AC (CP_INSTANCE *cpi, 
+			    const int fi, 
+			    ogg_int16_t *dct, 
+			    const ogg_int16_t *dequant, 
+			    const ogg_int16_t *origdct, 
+			    const int chroma, 
+			    token_checkpoint_t **stack,int _acmin);
+extern void dct_tokenize_finish (CP_INSTANCE *cpi);
+extern void dct_tokenize_mark_ac_chroma (CP_INSTANCE *cpi);
+
+extern void InitQTables( CP_INSTANCE *cpi );
+
+extern void WriteFrameHeader( CP_INSTANCE *cpi) ;
+
+extern void EncodeData(CP_INSTANCE *cpi);
+
+extern void oc_mcenc_start(CP_INSTANCE *cpi,
+			   mc_state *mcenc);
+
+extern void oc_mcenc_search(CP_INSTANCE *cpi, 
+			    mc_state *_mcenc,
+			    int _mbi,
+			    int _goldenp,
+			    oc_mv _bmvs[4],
+			    int *best_err,
+			    int best_block_err[4]);
+
+extern void oc_mcenc_refine1mv(CP_INSTANCE *cpi, 
+			      int _mbi,
+			      int _goldenp,
+			      int err);
+
+extern void oc_mcenc_refine4mv(CP_INSTANCE *cpi, 
+			      int _mbi,
+			      int err[4]);
+
+extern int PickModes(CP_INSTANCE *cpi, int recode);
+
+extern void InitFrameInfo(CP_INSTANCE *cpi);
+
+extern void ClearFrameInfo (CP_INSTANCE *cpi);
+
+typedef struct {
+  ogg_uint16_t sb_partial_count;
+  ogg_uint16_t sb_full_count;
+
+  signed char sb_partial_last;
+  signed char sb_full_last;
+  signed char b_last;
+  signed char b_count;
+  signed char b_pend;
+
+  char sb_partial_break;
+  char sb_full_break;
+  char sb_partial;
+  char sb_coded;
+
+  int cost;
+} fr_state_t;
+
+extern void fr_clear(CP_INSTANCE *cpi, fr_state_t *fr);
+extern void fr_skipblock(CP_INSTANCE *cpi, fr_state_t *fr);
+extern void fr_codeblock(CP_INSTANCE *cpi, fr_state_t *fr);
+extern void fr_finishsb(CP_INSTANCE *cpi, fr_state_t *fr);
+extern void fr_write(CP_INSTANCE *cpi, fr_state_t *fr);
+
+extern int fr_cost1(fr_state_t *fr);
+extern int fr_cost4(fr_state_t *pre, fr_state_t *post);
+
+#if defined(OC_COLLECT_METRICS)
+extern void ModeMetrics(CP_INSTANCE *cpi);
+extern void oc_enc_mode_metrics_dump(CP_INSTANCE *cpi);
+#endif
+
+/*Encoder-specific accelerated functions.*/
+void oc_enc_frag_sub(const CP_INSTANCE *_cpi,ogg_int16_t _diff[64],
+ const unsigned char *_src,const unsigned char *_ref,int _ystride);
+void oc_enc_frag_sub_128(const CP_INSTANCE *_cpi,ogg_int16_t _diff[64],
+ const unsigned char *_src,int _ystride);
+unsigned oc_enc_frag_sad(const CP_INSTANCE *_cpi,const unsigned char *_src,
+ const unsigned char *_ref,int _ystride);
+unsigned oc_enc_frag_sad_thresh(const CP_INSTANCE *_cpi,
+ const unsigned char *_src,const unsigned char *_ref,int _ystride,
+ unsigned _thresh);
+unsigned oc_enc_frag_sad2_thresh(const CP_INSTANCE *_cpi,
+ const unsigned char *_src,const unsigned char *_ref1,
+ const unsigned char *_ref2,int _ystride,unsigned _thresh);
+unsigned oc_enc_frag_satd_thresh(const CP_INSTANCE *_cpi,
+ const unsigned char *_src,const unsigned char *_ref,int _ystride,
+ unsigned _thresh);
+unsigned oc_enc_frag_satd2_thresh(const CP_INSTANCE *_cpi,
+ const unsigned char *_src,const unsigned char *_ref1,
+ const unsigned char *_ref2,int _ystride,unsigned _thresh);
+unsigned oc_enc_frag_intra_satd(const CP_INSTANCE *_cpi,
+ const unsigned char *_src,int _ystride);
+void oc_enc_frag_copy(const CP_INSTANCE *_cpi,unsigned char *_dst,
+ const unsigned char *_src,int _ystride);
+void oc_enc_frag_copy2(const CP_INSTANCE *_cpi,unsigned char *_dst,
+ const unsigned char *_src1,const unsigned char *_src2,int _ystride);
+void oc_enc_frag_recon_intra(const CP_INSTANCE *_cpi,
+ unsigned char *_dst,int _ystride,const ogg_int16_t _residue[64]);
+void oc_enc_frag_recon_inter(const CP_INSTANCE *_cpi,unsigned char *_dst,
+ const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]);
+void oc_enc_fdct8x8(const CP_INSTANCE *_cpi,ogg_int16_t _y[64],
+ const ogg_int16_t _x[64]);
+void oc_enc_dequant_idct8x8(const CP_INSTANCE *_cpi,ogg_int16_t _y[64],
+ const ogg_int16_t _x[64],int _last_zzi,int _ncoefs,
+ ogg_uint16_t _dc_quant,const ogg_uint16_t _ac_quant[64]);
+void oc_enc_loop_filter(CP_INSTANCE *_cpi,int _flimit);
+void oc_enc_restore_fpu(const CP_INSTANCE *_cpi);
+
+/*Default pure-C implementations.*/
+void oc_enc_vtable_init_c(CP_INSTANCE *_cpi);
+
+void oc_enc_frag_sub_c(ogg_int16_t _diff[64],
+ const unsigned char *_src,const unsigned char *_ref,int _ystride);
+void oc_enc_frag_sub_128_c(ogg_int16_t _diff[64],
+ const unsigned char *_src,int _ystride);
+void oc_enc_frag_copy2_c(unsigned char *_dst,
+ const unsigned char *_src1,const unsigned char *_src2,int _ystride);
+unsigned oc_enc_frag_sad_c(const unsigned char *_src,
+ const unsigned char *_ref,int _ystride);
+unsigned oc_enc_frag_sad_thresh_c(const unsigned char *_src,
+ const unsigned char *_ref,int _ystride,unsigned _thresh);
+unsigned oc_enc_frag_sad2_thresh_c(const unsigned char *_src,
+ const unsigned char *_ref1,const unsigned char *_ref2,int _ystride,
+ unsigned _thresh);
+unsigned oc_enc_frag_satd_thresh_c(const unsigned char *_src,
+ const unsigned char *_ref,int _ystride,unsigned _thresh);
+unsigned oc_enc_frag_satd2_thresh_c(const unsigned char *_src,
+ const unsigned char *_ref1,const unsigned char *_ref2,int _ystride,
+ unsigned _thresh);
+unsigned oc_enc_frag_intra_satd_c(const unsigned char *_src,int _ystride);
+void oc_enc_fdct8x8_c(ogg_int16_t _y[64],const ogg_int16_t _x[64]);
+void oc_enc_loop_filter_c(CP_INSTANCE *_cpi,int _flimit);
+void oc_enc_restore_fpu_c(void);
+
+#endif /* ENCODER_INTERNAL_H */
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/dct.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/dct.c
new file mode 100644
index 0000000..f6b7567
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/dct.c
@@ -0,0 +1,158 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: dct.c 15953 2009-04-26 14:30:15Z tterribe $
+
+ ********************************************************************/
+
+#include "codec_internal.h"
+#include "../dec/dct.h"
+
+
+
+/*Performs a forward 8 point Type-II DCT transform.
+  The output is scaled by a factor of 2 from the orthonormal version of the
+   transform.
+  _y: The buffer to store the result in.
+      Data will be placed in every 8th entry (e.g., in a column of an 8x8
+       block).
+  _x: The input coefficients.
+      The first 8 entries are used (e.g., from a row of an 8x8 block).*/
+static void oc_fdct8(ogg_int16_t *_y,const ogg_int16_t _x[8]){
+  int t0;
+  int t1;
+  int t2;
+  int t3;
+  int t4;
+  int t5;
+  int t6;
+  int t7;
+  int r;
+  int s;
+  int u;
+  int v;
+  /*Stage 1:*/
+  /*0-7 butterfly.*/
+  t0=_x[0<<3]+(int)_x[7<<3];
+  t7=_x[0<<3]-(int)_x[7<<3];
+  /*1-6 butterfly.*/
+  t1=_x[1<<3]+(int)_x[6<<3];
+  t6=_x[1<<3]-(int)_x[6<<3];
+  /*2-5 butterfly.*/
+  t2=_x[2<<3]+(int)_x[5<<3];
+  t5=_x[2<<3]-(int)_x[5<<3];
+  /*3-4 butterfly.*/
+  t3=_x[3<<3]+(int)_x[4<<3];
+  t4=_x[3<<3]-(int)_x[4<<3];
+  /*Stage 2:*/
+  /*0-3 butterfly.*/
+  r=t0+t3;
+  t3=t0-t3;
+  t0=r;
+  /*1-2 butterfly.*/
+  r=t1+t2;
+  t2=t1-t2;
+  t1=r;
+  /*6-5 butterfly.*/
+  r=t6+t5;
+  t5=t6-t5;
+  t6=r;
+  /*Stages 3 and 4 are where all the approximation occurs.
+    These are chosen to be as close to an exact inverse of the approximations
+     made in the iDCT as possible, while still using mostly 16-bit arithmetic.
+    We use some 16x16->32 signed MACs, but those still commonly execute in 1
+     cycle on a 16-bit DSP.
+    For example, s=(27146*t5+0x4000>>16)+t5+(t5!=0) is an exact inverse of
+     t5=(OC_C4S4*s>>16).
+    That is, applying the latter to the output of the former will recover t5
+     exactly (over the valid input range of t5, -23171...23169).
+    We increase the rounding bias to 0xB500 in this particular case so that
+     errors inverting the subsequent butterfly are not one-sided (e.g., the
+     mean error is very close to zero).
+    The (t5!=0) term could be replaced simply by 1, but we want to send 0 to 0.
+    The fDCT of an all-zeros block will still not be zero, because of the
+     biases we added at the very beginning of the process, but it will be close
+     enough that it is guaranteed to round to zero.*/
+  /*Stage 3:*/
+  /*4-5 butterfly.*/
+  s=(27146*t5+0xB500>>16)+t5+(t5!=0)>>1;
+  r=t4+s;
+  t5=t4-s;
+  t4=r;
+  /*7-6 butterfly.*/
+  s=(27146*t6+0xB500>>16)+t6+(t6!=0)>>1;
+  r=t7+s;
+  t6=t7-s;
+  t7=r;
+  /*Stage 4:*/
+  /*0-1 butterfly.*/
+  r=(27146*t0+0x4000>>16)+t0+(t0!=0);
+  s=(27146*t1+0xB500>>16)+t1+(t1!=0);
+  u=r+s>>1;
+  v=r-u;
+  _y[0]=u;
+  _y[4]=v;
+  /*3-2 rotation by 6pi/16*/
+  u=(OC_C6S2*t2+OC_C2S6*t3+0x6CB7>>16)+(t3!=0);
+  s=(OC_C6S2*u>>16)-t2;
+  v=(s*21600+0x2800>>18)+s+(s!=0);
+  _y[2]=u;
+  _y[6]=v;
+  /*6-5 rotation by 3pi/16*/
+  u=(OC_C5S3*t6+OC_C3S5*t5+0x0E3D>>16)+(t5!=0);
+  s=t6-(OC_C5S3*u>>16);
+  v=(s*26568+0x3400>>17)+s+(s!=0);
+  _y[5]=u;
+  _y[3]=v;
+  /*7-4 rotation by 7pi/16*/
+  u=(OC_C7S1*t4+OC_C1S7*t7+0x7B1B>>16)+(t7!=0);
+  s=(OC_C7S1*u>>16)-t4;
+  v=(s*20539+0x3000>>20)+s+(s!=0);
+  _y[1]=u;
+  _y[7]=v;
+}
+
+void oc_enc_fdct8x8(const CP_INSTANCE *_cpi,ogg_int16_t _y[64],
+ const ogg_int16_t _x[64]){
+  (*_cpi->opt_vtable.fdct8x8)(_y,_x);
+}
+
+/*Performs a forward 8x8 Type-II DCT transform.
+  The output is scaled by a factor of 4 relative to the orthonormal version
+   of the transform.
+  _y: The buffer to store the result in.
+      This may be the same as _x.
+  _x: The input coefficients. */
+void oc_enc_fdct8x8_c(ogg_int16_t _y[64],const ogg_int16_t _x[64]){
+  const ogg_int16_t *in;
+  ogg_int16_t       *end;
+  ogg_int16_t       *out;
+  ogg_int16_t        w[64];
+  int                i;
+  /*Add two extra bits of working precision to improve accuracy; any more and
+     we could overflow.*/
+  for(i=0;i<64;i++)w[i]=_x[i]<<2;
+  /*These biases correct for some systematic error that remains in the full
+     fDCT->iDCT round trip.*/
+  w[0]+=(w[0]!=0)+1;
+  w[1]++;
+  w[8]--;
+  /*Transform columns of w into rows of _y.*/
+  for(in=w,out=_y,end=out+64;out<end;in++,out+=8)oc_fdct8(out,in);
+  /*Transform columns of _y into rows of w.*/
+  for(in=_y,out=w,end=out+64;out<end;in++,out+=8)oc_fdct8(out,in);
+  /*Round the result back to the external working precision (which is still
+     scaled by four relative to the orthogonal result).
+    TODO: We should just update the external working precision.*/
+  for(i=0;i<64;i++)_y[i]=w[i]+2>>2;
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/dct_decode.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/dct_decode.c
new file mode 100644
index 0000000..69e0056
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/dct_decode.c
@@ -0,0 +1,232 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: dct_decode.c 15953 2009-04-26 14:30:15Z tterribe $
+
+ ********************************************************************/
+
+#include <stdlib.h>
+#include <string.h>
+#include "codec_internal.h"
+#include "quant_lookup.h"
+
+static void SetupBoundingValueArray_Generic(ogg_int16_t *BoundingValuePtr,
+                                            ogg_int32_t FLimit){
+
+  ogg_int32_t i;
+
+  /* Set up the bounding value array. */
+  memset ( BoundingValuePtr, 0, (256*sizeof(*BoundingValuePtr)) );
+  for ( i = 0; i < FLimit; i++ ){
+    BoundingValuePtr[127-i-FLimit] = (-FLimit+i);
+    BoundingValuePtr[127-i] = -i;
+    BoundingValuePtr[127+i] = i;
+    BoundingValuePtr[127+i+FLimit] = FLimit-i;
+  }
+}
+
+static void UpdateUMV_HBorders( CP_INSTANCE *cpi,
+                                unsigned char *DestReconPtr,
+				int plane){
+  ogg_uint32_t  i;
+  ogg_uint32_t  PixelIndex;
+
+  ogg_uint32_t  PlaneStride = cpi->stride[plane];
+  ogg_uint32_t  BlockVStep = cpi->stride[plane] * (VFRAGPIXELS - 1);
+  ogg_uint32_t  PlaneFragments = cpi->frag_n[plane];
+  ogg_uint32_t  LineFragments = cpi->frag_h[plane];
+  ogg_uint32_t  PlaneBorderWidth = (plane ? UMV_BORDER / 2 : UMV_BORDER );
+
+  unsigned char   *SrcPtr1;
+  unsigned char   *SrcPtr2;
+  unsigned char   *DestPtr1;
+  unsigned char   *DestPtr2;
+  ogg_uint32_t    *bp = cpi->frag_buffer_index;
+
+  if(plane) bp += cpi->frag_n[0];
+  if(plane>1) bp += cpi->frag_n[1];
+
+  /* Setup the source and destination pointers for the top and bottom
+     borders */
+  PixelIndex = bp[0];
+  SrcPtr1 = &DestReconPtr[ PixelIndex - PlaneBorderWidth ];
+  DestPtr1 = SrcPtr1 - (PlaneBorderWidth * PlaneStride);
+
+  PixelIndex = bp[PlaneFragments - LineFragments] + BlockVStep;
+  SrcPtr2 = &DestReconPtr[ PixelIndex - PlaneBorderWidth];
+  DestPtr2 = SrcPtr2 + PlaneStride;
+
+  /* Now copy the top and bottom source lines into each line of the
+     respective borders */
+  for ( i = 0; i < PlaneBorderWidth; i++ ) {
+    memcpy( DestPtr1, SrcPtr1, PlaneStride );
+    memcpy( DestPtr2, SrcPtr2, PlaneStride );
+    DestPtr1 += PlaneStride;
+    DestPtr2 += PlaneStride;
+  }
+}
+
+static void UpdateUMV_VBorders( CP_INSTANCE *cpi,
+                                unsigned char * DestReconPtr,
+                                int plane){
+  ogg_uint32_t   i;
+  ogg_uint32_t   PixelIndex;
+
+  ogg_uint32_t   PlaneStride = cpi->stride[plane];
+  ogg_uint32_t   LineFragments = cpi->frag_h[plane];
+  ogg_uint32_t   PlaneBorderWidth = (plane ? UMV_BORDER / 2 : UMV_BORDER );
+  ogg_uint32_t   PlaneHeight = (plane ? cpi->info.height/2 : cpi->info.height );
+
+  unsigned char   *SrcPtr1;
+  unsigned char   *SrcPtr2;
+  unsigned char   *DestPtr1;
+  unsigned char   *DestPtr2;
+  ogg_uint32_t    *bp = cpi->frag_buffer_index;
+
+  if(plane) bp += cpi->frag_n[0];
+  if(plane>1) bp += cpi->frag_n[1];
+
+  /* Setup the source data values and destination pointers for the
+     left and right edge borders */
+  PixelIndex = bp[0];
+  SrcPtr1 = &DestReconPtr[ PixelIndex ];
+  DestPtr1 = &DestReconPtr[ PixelIndex - PlaneBorderWidth ];
+
+  PixelIndex = bp[LineFragments - 1] + (HFRAGPIXELS - 1);
+  SrcPtr2 = &DestReconPtr[ PixelIndex ];
+  DestPtr2 = &DestReconPtr[ PixelIndex + 1 ];
+
+  /* Now copy the top and bottom source lines into each line of the
+     respective borders */
+  for ( i = 0; i < PlaneHeight; i++ ) {
+    memset( DestPtr1, SrcPtr1[0], PlaneBorderWidth );
+    memset( DestPtr2, SrcPtr2[0], PlaneBorderWidth );
+    SrcPtr1 += PlaneStride;
+    SrcPtr2 += PlaneStride;
+    DestPtr1 += PlaneStride;
+    DestPtr2 += PlaneStride;
+  }
+}
+
+void UpdateUMVBorder( CP_INSTANCE *cpi,
+                      unsigned char * DestReconPtr ) {
+  /* Y plane */
+  UpdateUMV_VBorders( cpi, DestReconPtr, 0);
+  UpdateUMV_HBorders( cpi, DestReconPtr, 0);
+
+  /* Then the U and V Planes */
+  UpdateUMV_VBorders( cpi, DestReconPtr, 1);
+  UpdateUMV_HBorders( cpi, DestReconPtr, 1);
+
+  UpdateUMV_VBorders( cpi, DestReconPtr, 2);
+  UpdateUMV_HBorders( cpi, DestReconPtr, 2);
+}
+
+static void loop_filter_h(unsigned char * PixelPtr,
+			  ogg_int32_t LineLength,
+			  ogg_int16_t *BoundingValuePtr){
+  ogg_int32_t j;
+  ogg_int32_t FiltVal;
+  PixelPtr-=2;
+
+  for ( j = 0; j < 8; j++ ){
+    FiltVal =
+      ( PixelPtr[0] ) -
+      ( PixelPtr[1] * 3 ) +
+      ( PixelPtr[2] * 3 ) -
+      ( PixelPtr[3] );
+
+    FiltVal = *(BoundingValuePtr+((FiltVal + 4) >> 3));
+
+    PixelPtr[1] = OC_CLAMP255(PixelPtr[1] + FiltVal);
+    PixelPtr[2] = OC_CLAMP255(PixelPtr[2] - FiltVal);
+
+    PixelPtr += LineLength;
+  }
+}
+
+static void loop_filter_v(unsigned char * PixelPtr,
+			  ogg_int32_t LineLength,
+			  ogg_int16_t *BoundingValuePtr){
+  ogg_int32_t j;
+  ogg_int32_t FiltVal;
+  PixelPtr -= 2*LineLength;
+
+  for ( j = 0; j < 8; j++ ) {
+    FiltVal = ( (ogg_int32_t)PixelPtr[0] ) -
+      ( (ogg_int32_t)PixelPtr[LineLength] * 3 ) +
+      ( (ogg_int32_t)PixelPtr[2 * LineLength] * 3 ) -
+      ( (ogg_int32_t)PixelPtr[3 * LineLength] );
+
+    FiltVal = *(BoundingValuePtr+((FiltVal + 4) >> 3));
+
+    PixelPtr[LineLength] = OC_CLAMP255(PixelPtr[LineLength] + FiltVal);
+    PixelPtr[2 * LineLength] = OC_CLAMP255(PixelPtr[2*LineLength] - FiltVal);
+
+    PixelPtr ++;
+  }
+}
+
+void oc_enc_loop_filter_c(CP_INSTANCE *cpi, int FLimit){
+
+  int j;
+  ogg_int16_t BoundingValues[256];
+  ogg_int16_t *bvp = BoundingValues+127;
+  unsigned char *cp = cpi->frag_coded;
+  ogg_uint32_t *bp = cpi->frag_buffer_index;
+
+  if ( FLimit == 0 ) return;
+  SetupBoundingValueArray_Generic(BoundingValues, FLimit);
+
+  for ( j = 0; j < 3 ; j++){
+    ogg_uint32_t *bp_begin = bp;
+    ogg_uint32_t *bp_end = bp + cpi->frag_n[j];
+    int stride = cpi->stride[j];
+    int h = cpi->frag_h[j];
+
+    while(bp<bp_end){
+      ogg_uint32_t *bp_left = bp;
+      ogg_uint32_t *bp_right = bp + h;
+      while(bp<bp_right){
+        if(cp[0]){
+          if(bp>bp_left)
+            loop_filter_h(&cpi->lastrecon[bp[0]],stride,bvp);
+          if(bp_left>bp_begin)
+            loop_filter_v(&cpi->lastrecon[bp[0]],stride,bvp);
+          if(bp+1<bp_right && !cp[1])
+            loop_filter_h(&cpi->lastrecon[bp[0]]+8,stride,bvp);
+          if(bp+h<bp_end && !cp[h])
+            loop_filter_v(&cpi->lastrecon[bp[h]],stride,bvp);
+        }
+        bp++;
+        cp++;
+      }
+    }
+  }
+}
+
+void ReconRefFrames (CP_INSTANCE *cpi){
+  unsigned char *temp;
+  /*Swap.*/
+  temp=cpi->lastrecon;
+  cpi->lastrecon=cpi->recon;
+  cpi->recon=temp;
+  /* Apply a loop filter to edge pixels of updated blocks */
+  oc_enc_loop_filter(cpi,cpi->quant_info.loop_filter_limits[cpi->BaseQ]);
+  /* We may need to update the UMV border */
+  UpdateUMVBorder(cpi, cpi->lastrecon);
+  /*Swap back.*/
+  temp=cpi->lastrecon;
+  cpi->lastrecon=cpi->recon;
+  cpi->recon=temp;
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/dct_encode.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/dct_encode.c
new file mode 100644
index 0000000..88e2f01
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/dct_encode.c
@@ -0,0 +1,783 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2008                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: dct_encode.c 16044 2009-05-27 02:05:43Z tterribe $
+
+ ********************************************************************/
+
+#include <stdlib.h>
+#include <string.h>
+#include "codec_internal.h"
+#include "quant_lookup.h"
+
+static void make_eobrun_token(int run, int *token, int *eb){
+  if ( run <= 3 ) {
+    if ( run == 1 ) {
+      *token = DCT_EOB_TOKEN;
+    } else if ( run == 2 ) {
+      *token = DCT_EOB_PAIR_TOKEN;
+    } else {
+      *token = DCT_EOB_TRIPLE_TOKEN;
+    }
+    *eb=0;
+    
+  } else {
+    
+    if ( run < 8 ) {
+      *token = DCT_REPEAT_RUN_TOKEN;
+      *eb = run-4;
+    } else if ( run < 16 ) {
+      *token = DCT_REPEAT_RUN2_TOKEN;
+      *eb = run-8;
+    } else if ( run < 32 ) {
+      *token = DCT_REPEAT_RUN3_TOKEN;
+      *eb = run-16;
+    } else if ( run < 4096) {
+      *token = DCT_REPEAT_RUN4_TOKEN;
+      *eb = run;
+    }
+  }
+}
+
+static int make_dct_token(CP_INSTANCE *cpi, 
+			  int coeff,
+			  int coeff2,
+			  int val,
+			  int *eb){
+  
+  ogg_uint32_t absval = abs(val);
+  int neg = (val<0);
+  int zero_run = coeff2-coeff;
+  int token;
+  *eb=0;
+
+  if (zero_run){
+    int adj = (coeff!=1); /* implement a minor restriction on
+			     stack 1 so that we know during DC
+			     fixups that extended a dctrun token
+			     from stack 1 will never overflow */
+    if ((absval==1) && (zero_run<17+adj)){
+      if ( zero_run <= 5 ) {
+	token = DCT_RUN_CATEGORY1+zero_run-1; 
+	*eb   = neg;
+      }else if ( zero_run <= 9 ) {
+	token = DCT_RUN_CATEGORY1B; 
+	*eb   = zero_run-6+(neg<<2);
+      }else{
+	token = DCT_RUN_CATEGORY1C;
+	*eb   = zero_run-10+(neg<<3);
+      }
+    }else if((absval==2 || absval==3) && (zero_run < 3+adj)){
+      if ( zero_run == 1 ) {
+	token = DCT_RUN_CATEGORY2;
+	*eb   = absval-2+(neg<<1);
+      }else{
+	token = DCT_RUN_CATEGORY2B;
+	*eb   = (neg<<2)+((absval-2)<<1)+zero_run-2;
+      }
+    }else{
+      if ( zero_run <= 8 )
+	token = DCT_SHORT_ZRL_TOKEN;
+      else
+	token = DCT_ZRL_TOKEN;
+      *eb = zero_run-1;
+    }
+  } else if ( absval == 1 ){
+    token = (neg ? MINUS_ONE_TOKEN : ONE_TOKEN);
+  } else if ( absval == 2 ) {
+    token = (neg ? MINUS_TWO_TOKEN : TWO_TOKEN);
+  } else if ( absval <= MAX_SINGLE_TOKEN_VALUE ) {
+    token = LOW_VAL_TOKENS + (absval - DCT_VAL_CAT2_MIN);
+    *eb   = neg;
+  } else if ( absval <= 8 ) {
+    token = DCT_VAL_CATEGORY3;
+    *eb   = (absval - DCT_VAL_CAT3_MIN) + (neg << 1);
+  } else if ( absval <= 12 ) {
+    token = DCT_VAL_CATEGORY4;
+    *eb   = (absval - DCT_VAL_CAT4_MIN) + (neg << 2);
+  } else if ( absval <= 20 ) {
+    token = DCT_VAL_CATEGORY5;
+    *eb   = (absval - DCT_VAL_CAT5_MIN) + (neg << 3);
+  } else if ( absval <= 36 ) {
+    token = DCT_VAL_CATEGORY6;
+    *eb   = (absval - DCT_VAL_CAT6_MIN) + (neg << 4);
+  } else if ( absval <= 68 ) {
+    token = DCT_VAL_CATEGORY7;
+    *eb   = (absval - DCT_VAL_CAT7_MIN) + (neg << 5);
+  } else {
+    token = DCT_VAL_CATEGORY8;
+    *eb   = (absval - DCT_VAL_CAT8_MIN) + (neg << 9);
+  } 
+
+  return token;
+}
+
+static int decode_eob_token(int token, int eb){
+  switch(token){
+  case DCT_EOB_TOKEN:
+    return 1;
+  case DCT_EOB_PAIR_TOKEN:
+    return 2; 
+  case DCT_EOB_TRIPLE_TOKEN:
+    return 3;
+  case DCT_REPEAT_RUN_TOKEN:
+    return eb+4;
+  case DCT_REPEAT_RUN2_TOKEN:
+    return eb+8;
+  case DCT_REPEAT_RUN3_TOKEN:
+    return eb+16;	
+  case DCT_REPEAT_RUN4_TOKEN:
+    return eb;
+  default:
+    return 0;
+  }
+}
+
+static int decode_token(int token, int eb, int *val){
+  switch(token){
+  case DCT_SHORT_ZRL_TOKEN:
+  case DCT_ZRL_TOKEN:
+    *val=0;
+    return eb+1;
+  case ONE_TOKEN:
+    *val = 1;
+    return 0;
+  case MINUS_ONE_TOKEN:
+    *val = -1;
+    return 0;
+  case TWO_TOKEN:
+    *val = 2;
+    return 0;
+  case MINUS_TWO_TOKEN:
+    *val = -2;
+    return 0;
+  case LOW_VAL_TOKENS:
+  case LOW_VAL_TOKENS+1:
+  case LOW_VAL_TOKENS+2:
+  case LOW_VAL_TOKENS+3:
+    *val = (eb ? -(DCT_VAL_CAT2_MIN+token-LOW_VAL_TOKENS) : DCT_VAL_CAT2_MIN+token-LOW_VAL_TOKENS);
+    return 0;
+  case DCT_VAL_CATEGORY3:
+    *val = ((eb & 0x2) ? -(DCT_VAL_CAT3_MIN+(eb&0x1)) : DCT_VAL_CAT3_MIN+(eb&0x1));
+    return 0;
+  case DCT_VAL_CATEGORY4:
+    *val = ((eb & 0x4) ? -(DCT_VAL_CAT4_MIN+(eb&0x3)) : DCT_VAL_CAT4_MIN+(eb&0x3));
+    return 0;
+  case DCT_VAL_CATEGORY5:
+    *val = ((eb & 0x8) ? -(DCT_VAL_CAT5_MIN+(eb&0x7)) : DCT_VAL_CAT5_MIN+(eb&0x7));
+    return 0;
+  case DCT_VAL_CATEGORY6:
+    *val = ((eb & 0x10) ? -(DCT_VAL_CAT6_MIN+(eb&0xf)) : DCT_VAL_CAT6_MIN+(eb&0xf));
+    return 0;
+  case DCT_VAL_CATEGORY7:
+    *val = ((eb & 0x20) ? -(DCT_VAL_CAT7_MIN+(eb&0x1f)) : DCT_VAL_CAT7_MIN+(eb&0x1f));
+    return 0;
+  case DCT_VAL_CATEGORY8:
+    *val = ((eb & 0x200) ? -(DCT_VAL_CAT8_MIN+(eb&0x1ff)) : DCT_VAL_CAT8_MIN+(eb&0x1ff));
+    return 0;
+  case DCT_RUN_CATEGORY1:
+  case DCT_RUN_CATEGORY1+1:
+  case DCT_RUN_CATEGORY1+2:
+  case DCT_RUN_CATEGORY1+3:
+  case DCT_RUN_CATEGORY1+4:
+    *val = (eb ? -1 : 1);
+    return token - DCT_RUN_CATEGORY1 + 1;
+  case DCT_RUN_CATEGORY1B:
+    *val = ((eb&0x4) ? -1 : 1);
+    return (eb&0x3)+6;
+  case DCT_RUN_CATEGORY1C:
+    *val = ((eb&0x8) ? -1 : 1);
+    return (eb&0x7)+10;
+  case DCT_RUN_CATEGORY2:
+    *val = ( (eb&0x2) ? -((eb&0x1)+2) : (eb&0x1)+2 );
+    return 1;
+  case DCT_RUN_CATEGORY2B:
+    *val = ( (eb&0x4) ? -(((eb&0x2)>>1)+2) : ((eb&0x2)>>1)+2);
+    return (eb&0x1)+2;
+  default:
+    *val = 0;
+    return 0;
+  }
+}
+
+/* token logging to allow a few fragments of efficient rollback.  SKIP
+   analysis is tied up in the tokenization process, so we need to be
+   able to undo a fragment's tokens on a whim */
+
+static int acoffset[64]={
+  00,00,00,00,00,00,16,16,
+  16,16,16,16,16,16,16,32,
+  32,32,32,32,32,32,32,32,
+  32,32,32,32,48,48,48,48,
+  48,48,48,48,48,48,48,48,
+  48,48,48,48,48,48,48,48,
+  48,48,48,48,48,48,48,48};
+
+/* only counts bits */
+static int tokencost(CP_INSTANCE *cpi, int huff, int coeff, int token){
+  huff += acoffset[coeff];
+  return cpi->huff_codes[huff][token].nbits+OC_DCT_TOKEN_EXTRA_BITS[token];
+}
+
+void tokenlog_rollback(CP_INSTANCE *cpi, token_checkpoint_t *stack,int n){
+  int i;
+  for(i=n-1;i>=0;i--){
+    int coeff = stack[i].coeff;
+    if(stack[i].count>=0) cpi->dct_token_count[coeff] = stack[i].count; 
+    cpi->eob_run[coeff] = stack[i].run;
+    cpi->eob_pre[coeff] = stack[i].pre;
+#if defined(OC_COLLECT_METRICS)
+    cpi->dct_eob_fi_count[coeff] = stack[i].runstack;
+#endif
+  }
+}
+
+static void tokenlog_metrics(CP_INSTANCE *cpi, int coeff, int chroma, int token){
+  if(coeff == 0){
+    /* DC */
+    int i;
+    for ( i = 0; i < DC_HUFF_CHOICES; i++)
+      cpi->dc_bits[chroma][i] += cpi->huff_codes[i][token].nbits;
+  }else if (coeff == 1){
+    /* AC == 1*/
+    int i,offset = acoffset[1]+AC_HUFF_OFFSET;
+    for ( i = 0; i < AC_HUFF_CHOICES; i++)
+      cpi->ac1_bits[chroma][i] += cpi->huff_codes[offset+i][token].nbits;
+  }else{
+    /* AC > 1*/
+    int i,offset = acoffset[coeff]+AC_HUFF_OFFSET;
+    for ( i = 0; i < AC_HUFF_CHOICES; i++)
+      cpi->acN_bits[chroma][i] += cpi->huff_codes[offset+i][token].nbits;
+  }
+}
+
+void tokenlog_commit(CP_INSTANCE *cpi, token_checkpoint_t *stack, int n){
+  int i;
+  for(i=0;i<n;i++){
+    int pos = stack[i].count;
+    if(pos>=0){
+      int coeff = stack[i].coeff;
+      int token = cpi->dct_token[coeff][pos];
+      int chroma = stack[i].chroma;
+      tokenlog_metrics(cpi,coeff,chroma,token);
+    }
+  }
+}
+
+static void tokenlog_mark(CP_INSTANCE *cpi, int coeff, token_checkpoint_t **stack){
+  (*stack)->coeff = coeff;
+  (*stack)->count = -1;
+  (*stack)->run = cpi->eob_run[coeff];
+  (*stack)->pre = cpi->eob_pre[coeff];
+#if defined(OC_COLLECT_METRICS)
+  (*stack)->runstack = cpi->dct_eob_fi_count[coeff];
+#endif
+  (*stack)++;
+}
+
+static void token_add(CP_INSTANCE *cpi, int chroma, int coeff, 
+			 unsigned char token, ogg_uint16_t eb,
+			 token_checkpoint_t **stack){
+  int pos = cpi->dct_token_count[coeff]++;
+  cpi->dct_token[coeff][pos] = token;
+  cpi->dct_token_eb[coeff][pos] = eb;
+  if(stack){
+    (*stack)->coeff = coeff;
+    (*stack)->count = pos;
+    (*stack)->chroma = chroma;
+    (*stack)->run = cpi->eob_run[coeff];
+    (*stack)->pre = cpi->eob_pre[coeff];
+#if defined(OC_COLLECT_METRICS)
+    (*stack)->runstack = cpi->dct_eob_fi_count[coeff];
+#endif
+    (*stack)++;
+  }else{
+    tokenlog_metrics(cpi,coeff,chroma,token);
+  }
+}
+
+/* does not offer logging option; only used in nonconditional EOBrun welding */
+static void token_prepend(CP_INSTANCE *cpi, int chroma, int coeff, 
+			  unsigned char token, ogg_uint16_t eb){
+  
+  cpi->dct_token[coeff]--;
+  cpi->dct_token_eb[coeff]--;
+#if defined(OC_COLLECT_METRICS)
+  cpi->dct_token_frag[coeff]--;
+#endif
+  cpi->dct_token[coeff][0] = token;
+  cpi->dct_token_eb[coeff][0] = eb;
+  cpi->dct_token_count[coeff]++;
+  tokenlog_metrics(cpi,coeff,chroma,token);
+}
+
+static int tokenize_eobrun(CP_INSTANCE *cpi, int pos, int run, token_checkpoint_t **stack){
+  int token=0,eb=0;
+  int chroma = !(run&0x8000);
+  int huff = cpi->huffchoice[cpi->FrameType!=KEY_FRAME][1][chroma];
+
+  make_eobrun_token(run&0x7fff, &token, &eb);
+  token_add(cpi, chroma, pos, token, eb, stack);
+
+  return tokencost(cpi,huff,pos,token);
+}
+
+
+static void tokenize_prepend_eobrun(CP_INSTANCE *cpi, int chroma, int pos, int run){
+  int token=0,eb=0;
+  make_eobrun_token(run, &token, &eb);
+  token_prepend(cpi, chroma, pos, token, eb);
+}
+
+/* only used in nonconditional DC/stack1 fixups */
+static void token_add_raw(CP_INSTANCE *cpi, 
+			  int chroma,
+			  int fi,
+			  int coeff,
+			  int token,
+			  int eb){
+  
+  /* Emit pending EOB run if any */
+  if(cpi->eob_run[coeff]){
+    tokenize_eobrun(cpi,coeff,cpi->eob_run[coeff],NULL);
+    cpi->eob_run[coeff]=0;
+  }
+#if defined(OC_COLLECT_METRICS)
+  cpi->dct_token_frag[coeff][cpi->dct_token_count[coeff]] = fi;
+#endif
+  token_add(cpi,chroma,coeff,token,eb,NULL);
+  
+}
+
+/* NULL stack to force commit */
+static int tokenize_dctval(CP_INSTANCE *cpi, 
+			   int chroma,
+			   int fi,
+			   int coeff,
+			   int coeff2,
+			   int val,
+			   token_checkpoint_t **stack){
+  int eb=0;
+  int token=make_dct_token(cpi,coeff,coeff2,val,&eb);
+
+  /* Emit pending EOB run if any */
+  if(cpi->eob_run[coeff]){
+    tokenize_eobrun(cpi,coeff,cpi->eob_run[coeff],stack);
+    cpi->eob_run[coeff]=0;
+  }
+#if defined(OC_COLLECT_METRICS)
+  cpi->dct_token_frag[coeff][cpi->dct_token_count[coeff]] = fi;
+#endif
+  
+  token_add(cpi,chroma,coeff,token,eb,stack);
+  
+  if( ((token==DCT_SHORT_ZRL_TOKEN) || (token==DCT_ZRL_TOKEN)) && val)
+    return 0; /* we only flushed a preceeding zero run, not the value token. */
+  
+  return 1;
+}
+
+static int tokenize_mark_run(CP_INSTANCE *cpi, 
+			      int chroma,
+			      int fi,
+			      int pre,
+			      int coeff,
+			      token_checkpoint_t **stack){
+  int cost = 0;
+
+  if(pre && cpi->dct_token_count[coeff] == 0){
+    if(stack)tokenlog_mark(cpi,coeff,stack); /* log an undo without logging a token */
+    cpi->eob_pre[coeff]++;
+  }else{
+    if((cpi->eob_run[coeff]&0x7fff) == 4095){
+      cost += tokenize_eobrun(cpi,coeff,cpi->eob_run[coeff],stack);
+      cpi->eob_run[coeff] = 0;
+    }
+    
+    if(stack)tokenlog_mark(cpi,coeff,stack); /* log an undo without logging a token */
+    cpi->eob_run[coeff]++;
+    cpi->eob_run[coeff]|= !chroma<<15;
+  }	  
+#if defined(OC_COLLECT_METRICS)
+  cpi->dct_eob_fi_stack[coeff][cpi->dct_eob_fi_count[coeff]++]=fi;
+#endif
+  return cost;
+}
+
+static int tokenize_dctcost(CP_INSTANCE *cpi,int chroma,
+			     int coeff, int coeff2, int val){
+  int huff = cpi->huffchoice[cpi->FrameType!=KEY_FRAME][1][chroma];
+  int eb=0,token=0;
+  int cost = 0;
+  
+  /* if there was an EOB run pending, count the cost of flushing it */
+  if(cpi->eob_run[coeff]){
+    int rchroma = !(cpi->eob_run[coeff]&0x8000); 
+    int rhuff = cpi->huffchoice[cpi->FrameType!=KEY_FRAME][1][rchroma];
+    make_eobrun_token(cpi->eob_run[coeff]&0x7fff,&token,&eb);
+    cost += tokencost(cpi,rhuff,coeff,token);
+  }
+
+  /* count cost of token */
+  token = make_dct_token(cpi,coeff,coeff2,val,&eb);
+  cost += tokencost(cpi,huff, coeff, token);
+  
+  /* if token was a zero run, we've not yet coded up to the value */
+  if( (token==DCT_SHORT_ZRL_TOKEN) || (token==DCT_ZRL_TOKEN))
+    return cost + tokenize_dctcost(cpi,chroma,coeff2,coeff2,val);
+  else
+    return cost;
+}
+
+/* The opportunity cost of an in-progress EOB run is the cost to flush
+   the run up to 'n+1' minus the cost of flushing the run up to 'n' */
+static int tokenize_eobcost(CP_INSTANCE *cpi,int chroma, int coeff){
+  int n = cpi->eob_run[coeff];
+  int eb=0,token=0;
+  int cost0=0,cost1;
+  
+  if(n>0){
+    int huff = cpi->huffchoice[cpi->FrameType!=KEY_FRAME][1][!(n&0x8000)];
+
+    make_eobrun_token(n&0x7fff, &token, &eb);
+    cost0 = tokencost(cpi,huff,coeff,token);
+
+    make_eobrun_token((n+1)&0x7fff, &token, &eb);
+    cost1 = tokencost(cpi,huff,coeff,token);
+    
+  }else{
+    int huff = cpi->huffchoice[cpi->FrameType!=KEY_FRAME][1][chroma];
+    cost1 = tokencost(cpi,huff,coeff,DCT_EOB_TOKEN);
+  }    
+
+  return cost1-cost0;
+}
+
+/* No final DC to encode yet (DC prediction hasn't been done) So
+   simply assume there will be a nonzero DC value and code.  That's
+   not a true assumption but it can be fixed-up as DC is tokenized
+   later */
+int dct_tokenize_AC(CP_INSTANCE *cpi, const int fi, 
+		    ogg_int16_t *dct, const ogg_int16_t *dequant, 
+		    const ogg_int16_t *origdct, const int chroma, 
+		    token_checkpoint_t **stack,int _acmin){
+  int coeff = 1; /* skip DC for now */
+  int i = coeff;
+  int retcost = 0;
+
+  while( !dct[i] && (++i < BLOCK_SIZE) );
+    
+  while(i < BLOCK_SIZE){
+    int ret;
+    int od = origdct[dezigzag_index[i]];
+    int bestd=0,d = dct[i];
+    int bestmin;
+    int cost,cost2=0,bestcost=0;
+    int j=i+1,k;
+
+    while((j < BLOCK_SIZE) && !dct[j] ) j++;
+
+  if(i>=_acmin){
+    if(j==BLOCK_SIZE){
+      cost = tokenize_eobcost(cpi,chroma,coeff);
+      if(i+1<BLOCK_SIZE) 
+	cost2 = tokenize_eobcost(cpi,chroma,i+1);
+    }else{
+      cost = tokenize_dctcost(cpi,chroma,coeff,j,dct[j]);
+      cost2 = tokenize_dctcost(cpi,chroma,i+1,j,dct[j]);
+    }
+    bestmin = od*od+cost*cpi->lambda;
+    
+
+    for(k=1;k<=abs(d);k++){
+      int dval = (d>0 ? k : -k);
+      int dd = dval*dequant[i] - od;
+      int min = dd*dd;
+      cost = tokenize_dctcost(cpi,chroma,coeff,i,dval);
+
+      min += (cost+cost2)*cpi->lambda;
+      if(min<bestmin){
+	bestmin=min;
+	bestcost=cost;
+	bestd=dval;
+      }
+    }
+
+    dct[i]=bestd;
+    if(bestd==0){
+      if(j==BLOCK_SIZE) break;
+      i=j;
+      continue;
+    }
+  }
+  else{
+    bestcost = tokenize_dctcost(cpi,chroma,coeff,i,d);
+  }
+    
+    retcost+=bestcost;
+	
+    ret = tokenize_dctval(cpi, chroma, fi, coeff, i, dct[i], stack);
+    if(!ret)
+      tokenize_dctval(cpi, chroma, fi, i, i, dct[i], stack);
+    coeff=i+1;
+    i=j;
+    
+  }
+  if(coeff<BLOCK_SIZE) retcost+=tokenize_mark_run(cpi,chroma,fi,coeff>1,coeff,stack);
+  return retcost;
+}
+
+/* called after AC tokenization is complete, because DC coding has to
+   happen after DC predict, which has to happen after the
+   Hilbert-ordered TQT loop */
+/* Convention: All tokens and runs in the coeff1 stack are
+   'regenerated' as the stack is tracked. This can be done in-place;
+   stack 1 can only shrink or stay the same size */
+static void tokenize_DC(CP_INSTANCE *cpi, int fi, int chroma,
+			int *idx1, int *run1){
+  
+  int val = cpi->frag_dc[fi];
+  int token1 = cpi->dct_token[1][*idx1];
+  int eb1 = cpi->dct_token_eb[1][*idx1];
+  
+  if(!*run1) *run1 = decode_eob_token(token1, eb1);
+  
+  if(val){
+    /* nonzero DC val, no coeff 1 stack 'fixup'. */
+    
+    tokenize_dctval(cpi,chroma,fi,0,0,val,NULL);
+    
+    /* there was a nonzero DC value, so there's no alteration to the
+       track1 stack for this fragment; track/regenerate stack 1
+	 state unchanged */
+    if(*run1){
+      /* in the midst of an EOB run in stack 1 */
+      tokenize_mark_run(cpi,chroma,fi,1,1,NULL);
+      (*run1)--;
+      
+    }else{
+      
+      /* non-EOB run token to emit for stack 1 */
+      token_add_raw(cpi,chroma,fi,1,token1,eb1);
+      
+    }
+    
+  }else{
+
+    /* zero DC value; that means the entry in coeff position 1
+       should have been coded from the DC coeff position. This
+       requires a stack 1 fixup. */
+    
+    if(*run1){
+      
+      /* current stack 1 token an EOB run; conceptually move this fragment's EOBness to stack 0 */
+      tokenize_mark_run(cpi,chroma,fi,0,0,NULL);
+      
+      /* decrement current EOB run for coeff 1 without adding to coded run */
+      (*run1)--;
+      
+    }else{
+      int run,val=0;
+      
+      /* stack 1 token is one of: zerorun, dctrun or dctval */
+      /* A zero-run token is expanded and moved to token stack 0 (stack 1 entry dropped) */
+      /* A dctval may be transformed into a single dctrun that is moved to stack 0,
+	 or if it does not fit in a dctrun, we leave the stack 1 entry alone and emit 
+	 a single length-1 zerorun token for stack 0 */
+      /* A dctrun is extended and moved to stack 0.  During AC
+	 coding, we restrict the run lengths on dctruns for stack 1
+	 so we know there's no chance of overrunning the
+	 representable range */
+      
+      run = decode_token(token1,eb1,&val)+1;
+      
+      if(!tokenize_dctval(cpi,chroma,fi,0,run,val,NULL)){
+	token_add_raw(cpi,chroma,fi,1,token1,eb1);
+      }
+    }
+  }
+  
+  /* update token counter if not in a run */
+  if (!*run1) (*idx1)++;
+}
+
+void dct_tokenize_init (CP_INSTANCE *cpi){
+  int i;
+
+  memset(cpi->eob_run, 0, sizeof(cpi->eob_run));
+  memset(cpi->eob_pre, 0, sizeof(cpi->eob_pre));
+  memset(cpi->dc_bits, 0, sizeof(cpi->dc_bits));
+  memset(cpi->ac1_bits, 0, sizeof(cpi->ac1_bits));
+  memset(cpi->acN_bits, 0, sizeof(cpi->acN_bits));
+  memset(cpi->dct_token_count, 0, sizeof(cpi->dct_token_count));
+#if defined(OC_COLLECT_METRICS)
+  memset(cpi->dct_eob_fi_count, 0, sizeof(cpi->dct_eob_fi_count));
+#endif
+
+  for(i=0;i<BLOCK_SIZE;i++){
+    cpi->dct_token[i] = cpi->dct_token_storage + cpi->stack_offset*i;
+    cpi->dct_token_eb[i] = cpi->dct_token_eb_storage + cpi->stack_offset*i;
+
+#if defined(OC_COLLECT_METRICS)
+    cpi->dct_eob_fi_stack[i] = cpi->dct_eob_fi_storage + cpi->frag_total*i;
+    cpi->dct_token_frag[i] = cpi->dct_token_frag_storage + cpi->stack_offset*i;
+#endif
+  }
+}
+
+void dct_tokenize_mark_ac_chroma (CP_INSTANCE *cpi){
+  int i;
+  for(i=1;i<64;i++){
+    cpi->dct_token_ycount[i]=cpi->dct_token_count[i];
+    if(cpi->eob_run[i])
+      cpi->dct_token_ycount[i]++; /* there will be another y plane token after welding */
+    cpi->eob_ypre[i]=cpi->eob_pre[i];
+  }
+}
+
+/* post-facto DC tokenization (has to be completed after DC predict)
+   coeff 1 fixups and eobrun welding */
+void dct_tokenize_finish (CP_INSTANCE *cpi){
+  int i,sbi;
+  int idx1=0,run1=0;
+  unsigned char *cp=cpi->frag_coded;
+  
+  /* we parse the token stack for coeff1 to stay in sync, and re-use
+     the token stack counters to track */
+  /* emit an eob run for the end run of stack 1; this is used to
+     reparse the stack in the DC code loop.  The current state will be
+     recreated by the end of DC encode */
+
+  if(cpi->eob_run[1]) tokenize_eobrun(cpi,1,cpi->eob_run[1],NULL);
+  memset(cpi->ac1_bits, 0, sizeof(cpi->ac1_bits));
+  cpi->dct_token_count[1]=0;
+  cpi->eob_pre[1]=cpi->eob_run[1]=0;
+#if defined(OC_COLLECT_METRICS)
+  /* reset and reuse as a counter */
+  cpi->dct_eob_fi_count[1]=0;
+#endif
+  
+  for (sbi=0; sbi < cpi->super_n[0]; sbi++ ){
+    superblock_t *sb = &cpi->super[0][sbi];
+    int bi;
+    for (bi=0; bi<16; bi++, i++ ) {
+      int fi = sb->f[bi];
+      if(cp[fi]) 
+        tokenize_DC(cpi, fi, 0, &idx1, &run1);
+    }
+  }
+
+  for(i=0;i<2;i++){
+    cpi->dct_token_ycount[i]=cpi->dct_token_count[i];
+    if(cpi->eob_run[i])
+      cpi->dct_token_ycount[i]++; /* there will be another y plane token after welding */
+    cpi->eob_ypre[i]=cpi->eob_pre[i];
+  }
+
+  for (; sbi < cpi->super_total; sbi++ ){
+    superblock_t *sb = &cpi->super[0][sbi];
+    int bi;
+    for (bi=0; bi<16; bi++,i++ ) {
+      int fi = sb->f[bi];
+      if(cp[fi]) 
+	tokenize_DC(cpi, fi, 1, &idx1, &run1);
+    }
+  }
+
+  /* DC coded, AC coeff 1 state fixed up/regenerated */
+
+  /* tie together eob runs at the beginnings/ends of coeff groups */
+  {
+    int coeff = 0;
+    int run = 0;
+    
+    for(i=0;i<BLOCK_SIZE;i++){
+      if(cpi->eob_pre[i]){
+	/* group begins with an EOB run */
+	
+	/* special case the ongoing run + eob is at or over the max run size;
+	   we know the ongoing run is < 4095 or it would have been flushed already. */
+	if(run && (run&0x7fff) + cpi->eob_pre[i] >= 4095){ /* 1 */
+	  tokenize_eobrun(cpi,coeff,4095 | (run&0x8000),NULL);
+	  cpi->eob_pre[i] -= 4095-(run&0x7fff); 
+	  cpi->eob_ypre[i] -= 4095-(run&0x7fff); 
+	  run = 0;
+	  coeff = i;
+	}
+	
+	if(run){
+	  if(cpi->dct_token_count[i]){ /* 2 */
+	    /* group is not only an EOB run; emit the run token */
+	    tokenize_eobrun(cpi,coeff,run + cpi->eob_pre[i],NULL);
+	    cpi->eob_ypre[i] = 0;
+	    cpi->eob_pre[i] = 0;
+	    run = cpi->eob_run[i];
+	    coeff = i;
+	  }else{ /* 3 */
+	    /* group consists entirely of EOB run.  Add, iterate */
+	    run += cpi->eob_pre[i];
+	    cpi->eob_pre[i] = 0;
+	    cpi->eob_ypre[i] = 0;
+	  }
+	}else{
+	    
+	  if(cpi->dct_token_count[i]){
+	    /* there are other tokens in this group; work backwards as we need to prepend */
+	    while(cpi->eob_pre[i] >= 4095){ /* 4 */
+	      int lchroma = (cpi->eob_pre[i]-4095 >= cpi->eob_ypre[i]);
+	      tokenize_prepend_eobrun(cpi,lchroma,i,4095);
+	      if(!lchroma)cpi->dct_token_ycount[i]++;
+	      cpi->eob_pre[i] -= 4095;
+	    }
+	    if(cpi->eob_pre[i]){ /* 5 */
+	      int lchroma = (cpi->eob_ypre[i]<=0); /* possible when case 1 triggered */
+	      tokenize_prepend_eobrun(cpi, lchroma, i, cpi->eob_pre[i]);
+	      if(!lchroma)cpi->dct_token_ycount[i]++;
+	      cpi->eob_pre[i] = 0;
+	      cpi->eob_ypre[i] = 0;
+	    }
+	    run = cpi->eob_run[i];
+	    coeff = i;
+	  }else{
+	    /* group consists entirely of EOB run.  Add, flush overs, iterate */
+	    int lchroma = (cpi->eob_ypre[i]<=0);
+	    while(cpi->eob_pre[i] >= 4095){
+	      tokenize_eobrun(cpi,i,4095|(!lchroma<<15),NULL);
+	      if(!lchroma)cpi->dct_token_ycount[i]++;
+	      cpi->eob_pre[i] -= 4095;
+	      cpi->eob_ypre[i] -= 4095;
+	      lchroma = (cpi->eob_ypre[i]<=0);
+	    }
+	    run = cpi->eob_pre[i] | (!lchroma<<15);
+	    coeff = i;
+	    /* source is pre-run, so the eventual eob_emit_run also needs to increment ycount if coded into Y plane */
+	    if(!lchroma)cpi->dct_token_ycount[i]++;
+	  }
+	}
+      }else{
+	/* no eob run to begin group */
+	if(i==0 || cpi->dct_token_count[i]){
+	  if(run)
+	    tokenize_eobrun(cpi,coeff,run,NULL);
+	  
+	  run = cpi->eob_run[i];
+	  coeff = i;
+	}
+      }
+    }
+    
+    if(run)
+      tokenize_eobrun(cpi,coeff,run,NULL);
+    
+  }
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encapiwrapper.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encapiwrapper.c
new file mode 100644
index 0000000..b0d66aa
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encapiwrapper.c
@@ -0,0 +1,330 @@
+#include <string.h>
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+#include "vtkoggtheora/include/theora/theoraenc.h"
+#include "vtkoggtheora/include/theora/theora.h"
+#include "codec_internal.h"
+#include "mathops.h"
+#include "../dec/ocintrin.h"
+
+/*Wrapper to translate the new API into the old API.
+  Eventually we need to convert the old functions to support the new API
+   natively and do the translation the other way.
+  theora-exp already has the necessary code to do so.*/
+
+
+
+static void th_info2theora_info(theora_info *_ci,const th_info *_info){
+  _ci->version_major=_info->version_major;
+  _ci->version_minor=_info->version_minor;
+  _ci->version_subminor=_info->version_subminor;
+  _ci->width=_info->frame_width;
+  _ci->height=_info->frame_height;
+  _ci->frame_width=_info->pic_width;
+  _ci->frame_height=_info->pic_height;
+  _ci->offset_x=_info->pic_x;
+  _ci->offset_y=_info->pic_y;
+  _ci->fps_numerator=_info->fps_numerator;
+  _ci->fps_denominator=_info->fps_denominator;
+  _ci->aspect_numerator=_info->aspect_numerator;
+  _ci->aspect_denominator=_info->aspect_denominator;
+  switch(_info->colorspace){
+    case TH_CS_ITU_REC_470M:_ci->colorspace=OC_CS_ITU_REC_470M;break;
+    case TH_CS_ITU_REC_470BG:_ci->colorspace=OC_CS_ITU_REC_470BG;break;
+    default:_ci->colorspace=OC_CS_UNSPECIFIED;break;
+  }
+  switch(_info->pixel_fmt){
+    case TH_PF_420:_ci->pixelformat=OC_PF_420;break;
+    case TH_PF_422:_ci->pixelformat=OC_PF_422;break;
+    case TH_PF_444:_ci->pixelformat=OC_PF_444;break;
+    default:_ci->pixelformat=OC_PF_RSVD;
+  }
+  _ci->target_bitrate=_info->target_bitrate;
+  _ci->quality=_info->quality;
+  _ci->codec_setup=NULL;
+  /*Defaults from old encoder_example... eventually most of these should go
+     away when we make the encoder no longer use them.*/
+  _ci->dropframes_p=0;
+  _ci->keyframe_auto_p=1;
+  _ci->keyframe_frequency=1<<_info->keyframe_granule_shift;
+  _ci->keyframe_frequency_force=1<<_info->keyframe_granule_shift;
+  _ci->keyframe_data_target_bitrate=
+   _info->target_bitrate+(_info->target_bitrate>>1);
+  _ci->keyframe_auto_threshold=80;
+  _ci->keyframe_mindistance=8;
+  _ci->noise_sensitivity=1;
+  _ci->sharpness=0;
+  _ci->quick_p=1;
+}
+
+
+
+struct th_enc_ctx{
+  /*This is required at the start of the struct for the common functions to
+     work.*/
+  th_info        info;
+  /*The actual encoder.*/
+  theora_state   state;
+  /*A temporary buffer for input frames.
+    This is needed if the U and V strides differ, or padding is required.*/
+  unsigned char *buf;
+};
+
+
+th_enc_ctx *th_encode_alloc(const th_info *_info){
+  theora_info  ci;
+  th_enc_ctx  *enc;
+  th_info2theora_info(&ci,_info);
+  /*Do a bunch of checks the new API does, but the old one didn't.*/
+  if((_info->frame_width&0xF)||(_info->frame_height&0xF)||
+   _info->frame_width>=0x100000||_info->frame_height>=0x100000||
+   _info->pic_x+_info->pic_width>_info->frame_width||
+   _info->pic_y+_info->pic_height>_info->frame_height||
+   _info->pic_x>255||
+   _info->frame_height-_info->pic_height-_info->pic_y>255||
+   _info->colorspace<0||_info->colorspace>=TH_CS_NSPACES||
+   _info->pixel_fmt<0||_info->pixel_fmt>=TH_PF_NFORMATS){
+    enc=NULL;
+  }
+  else{
+    enc=(th_enc_ctx *)_ogg_malloc(sizeof(*enc));
+    if(theora_encode_init(&enc->state,&ci)<0){
+      _ogg_free(enc);
+      enc=NULL;
+    }
+    else{
+      if(_info->frame_width>_info->pic_width||
+       _info->frame_height>_info->pic_height){
+        enc->buf=_ogg_malloc((_info->frame_width*_info->frame_height+
+         ((_info->frame_width>>!(_info->pixel_fmt&1))*
+         (_info->frame_height>>!(_info->pixel_fmt&2))<<1))*sizeof(*enc->buf));
+      }
+      else enc->buf=NULL;
+      memcpy(&enc->info,_info,sizeof(enc->info));
+      /*Overwrite values theora_encode_init() can change; don't trust the user.*/
+      enc->info.version_major=ci.version_major;
+      enc->info.version_minor=ci.version_minor;
+      enc->info.version_subminor=ci.version_subminor;
+      enc->info.quality=ci.quality;
+      enc->info.target_bitrate=ci.target_bitrate;
+      enc->info.fps_numerator=ci.fps_numerator;
+      enc->info.fps_denominator=ci.fps_denominator;
+      enc->info.keyframe_granule_shift=
+       OC_ILOG_32(ci.keyframe_frequency_force-1);
+    }
+  }
+  return enc;
+}
+
+int th_encode_ctl(th_enc_ctx *_enc,int _req,void *_buf,size_t _buf_sz){
+  return theora_control(&_enc->state,_req,_buf,_buf_sz);
+}
+
+int th_encode_flushheader(th_enc_ctx *_enc,th_comment *_comments,
+ ogg_packet *_op){
+  theora_state *te;
+  CP_INSTANCE  *cpi;
+  if(_enc==NULL||_op==NULL)return OC_FAULT;
+  te=&_enc->state;
+  cpi=(CP_INSTANCE *)te->internal_encode;
+  switch(cpi->doneflag){
+    case -3:{
+      theora_encode_header(te,_op);
+      return -cpi->doneflag++;
+    }break;
+    case -2:{
+      if(_comments==NULL)return OC_FAULT;
+      theora_encode_comment((theora_comment *)_comments,_op);
+      /*The old API does not require a theora_state struct when writing the
+         comment header, so it can't use its internal buffer and relies on the
+         application to free it.
+        The old documentation is wrong on this subject, and this breaks on
+         Windows when linking against multiple versions of libc (which is
+         almost always done when, e.g., using DLLs built with mingw32).
+        The new API _does_ require a th_enc_ctx, and states that libtheora owns
+         the memory.
+        Thus we move the contents of this packet into our internal
+         oggpack_buffer so it can be properly reclaimed.*/
+      oggpackB_reset(cpi->oggbuffer);
+      oggpackB_writecopy(cpi->oggbuffer,_op->packet,_op->bytes*8);
+      _ogg_free(_op->packet);
+      _op->packet=oggpackB_get_buffer(cpi->oggbuffer);
+      return -cpi->doneflag++;
+    }break;
+    case -1:{
+      theora_encode_tables(te,_op);
+      return -cpi->doneflag++;
+    }break;
+    case 0:return 0;
+    default:return OC_EINVAL;
+  }
+}
+
+/*Copies the picture region of the _src image plane into _dst and pads the rest
+   of _dst using a diffusion extension method.
+  We could do much better (e.g., the DCT-based low frequency extension method
+   in theora-exp's fdct.c) if we were to pad after motion compensation, but
+   that would require significant changes to the encoder.*/
+static unsigned char *th_encode_copy_pad_plane(th_img_plane *_dst,
+ unsigned char *_buf,th_img_plane *_src,
+ ogg_uint32_t _pic_x,ogg_uint32_t _pic_y,
+ ogg_uint32_t _pic_width,ogg_uint32_t _pic_height){
+  size_t buf_sz;
+  _dst->width=_src->width;
+  _dst->height=_src->height;
+  _dst->stride=_src->width;
+  _dst->data=_buf;
+  buf_sz=_dst->width*_dst->height*sizeof(*_dst->data);
+  /*If we have _no_ data, just encode a dull green.*/
+  if(_pic_width==0||_pic_height==0)memset(_dst->data,0,buf_sz);
+  else{
+    unsigned char *dst;
+    unsigned char *src;
+    ogg_uint32_t   x;
+    ogg_uint32_t   y;
+    int            dstride;
+    int            sstride;
+    /*Step 1: Copy the data we do have.*/
+    dstride=_dst->stride;
+    sstride=_src->stride;
+    dst=_dst->data+_pic_y*dstride+_pic_x;
+    src=_src->data+_pic_y*sstride+_pic_x;
+    for(y=0;y<_pic_height;y++){
+      memcpy(dst,src,_pic_width);
+      dst+=dstride;
+      src+=sstride;
+    }
+    /*Step 2: Copy the border into any blocks that are 100% padding.
+      There's probably smarter things we could do than this.*/
+    /*Left side.*/
+    for(x=_pic_x;x-->0;){
+      dst=_dst->data+_pic_y*dstride+x;
+      for(y=0;y<_pic_height;y++){
+        dst[0]=(dst[1]<<1)+(dst-(dstride&-(y>0)))[1]+
+         (dst+(dstride&-(y+1<_pic_height)))[1]+2>>2;
+        dst+=dstride;
+      }
+    }
+    /*Right side.*/
+    for(x=_pic_x+_pic_width;x<_dst->width;x++){
+      dst=_dst->data+_pic_y*dstride+x-1;
+      for(y=0;y<_pic_height;y++){
+        dst[1]=(dst[0]<<1)+(dst-(dstride&-(y>0)))[0]+
+         (dst+(dstride&-(y+1<_pic_height)))[0]+2>>2;
+        dst+=dstride;
+      }
+    }
+    /*Top.*/
+    dst=_dst->data+_pic_y*dstride;
+    for(y=_pic_y;y-->0;){
+      for(x=0;x<_dst->width;x++){
+        (dst-dstride)[x]=(dst[x]<<1)+dst[x-(x>0)]+dst[x+(x+1<_dst->width)]+2>>2;
+      }
+      dst-=dstride;
+    }
+    /*Bottom.*/
+    dst=_dst->data+(_pic_y+_pic_height)*dstride;
+    for(y=_pic_y+_pic_height;y<_dst->height;y++){
+      for(x=0;x<_dst->width;x++){
+        dst[x]=((dst-dstride)[x]<<1)+(dst-dstride)[x-(x>0)]+
+         (dst-dstride)[x+(x+1<_dst->width)]+2>>2;
+      }
+      dst+=dstride;
+    }
+  }
+  _buf+=buf_sz;
+  return _buf;
+}
+
+int th_encode_ycbcr_in(th_enc_ctx *_enc,th_ycbcr_buffer _ycbcr){
+  CP_INSTANCE     *cpi;
+  theora_state    *te;
+  th_img_plane    *pycbcr;
+  th_ycbcr_buffer  ycbcr;
+  yuv_buffer       yuv;
+  ogg_uint32_t     pic_width;
+  ogg_uint32_t     pic_height;
+  int              hdec;
+  int              vdec;
+  int              ret;
+  if(_enc==NULL||_ycbcr==NULL)return OC_FAULT;
+  te=&_enc->state;
+  /*theora_encode_YUVin() does not bother to check uv_width and uv_height, and
+     then uses them.
+    This is arguably okay (it will most likely lead to a crash if they're
+     wrong, which will make the developer who passed them fix the problem), but
+     our API promises to return an error code instead.*/
+  cpi=(CP_INSTANCE *)te->internal_encode;
+  hdec=!(cpi->info.pixelformat&1);
+  vdec=!(cpi->info.pixelformat&2);
+  if(_ycbcr[0].width!=cpi->info.width||
+   _ycbcr[0].height!=cpi->info.height||
+   _ycbcr[1].width!=_ycbcr[0].width>>hdec||
+   _ycbcr[1].height!=_ycbcr[0].height>>vdec||
+   _ycbcr[2].width!=_ycbcr[1].width||_ycbcr[2].height!=_ycbcr[1].height){
+    return OC_EINVAL;
+  }
+  pic_width=cpi->info.frame_width;
+  pic_height=cpi->info.frame_height;
+  /*We can only directly use the input buffer if no padding is required (since
+     the new API is documented not to use values outside the picture region)
+     and if the strides for the Cb and Cr planes are the same, since the old
+     API had no way to specify different ones.*/
+  if(_ycbcr[0].width==pic_width&&_ycbcr[0].height==pic_height&&
+   _ycbcr[1].stride==_ycbcr[2].stride){
+    pycbcr=_ycbcr;
+  }
+  else{
+    unsigned char *buf;
+    int            pic_x;
+    int            pic_y;
+    int            pli;
+    pic_x=cpi->info.offset_x;
+    pic_y=cpi->info.offset_y;
+    if(_ycbcr[0].width>pic_width||_ycbcr[0].height>pic_height){
+      buf=th_encode_copy_pad_plane(ycbcr+0,_enc->buf,_ycbcr+0,
+       pic_x,pic_y,pic_width,pic_height);
+    }
+    else{
+      /*If only the strides differ, we can still avoid copying the luma plane.*/
+      memcpy(ycbcr+0,_ycbcr+0,sizeof(ycbcr[0]));
+      if(_enc->buf==NULL){
+        _enc->buf=(unsigned char *)_ogg_malloc(
+         (_ycbcr[1].width*_ycbcr[1].height<<1)*sizeof(*_enc->buf));
+      }
+      buf=_enc->buf;
+    }
+    for(pli=1;pli<3;pli++){
+      int x0;
+      int y0;
+      x0=pic_x>>hdec;
+      y0=pic_y>>vdec;
+      buf=th_encode_copy_pad_plane(ycbcr+pli,buf,_ycbcr+pli,
+       x0,y0,(pic_x+pic_width+hdec>>hdec)-x0,(pic_y+pic_height+vdec>>vdec)-y0);
+    }
+    pycbcr=ycbcr;
+  }
+  yuv.y_width=pycbcr[0].width;
+  yuv.y_height=pycbcr[0].height;
+  yuv.uv_width=pycbcr[1].width;
+  yuv.uv_height=pycbcr[1].height;
+  yuv.y_stride=pycbcr[0].stride;
+  yuv.y=pycbcr[0].data;
+  yuv.uv_stride=pycbcr[1].stride;
+  yuv.u=pycbcr[1].data;
+  yuv.v=pycbcr[2].data;
+  ret=theora_encode_YUVin(te,&yuv);
+  return ret;
+}
+
+int th_encode_packetout(th_enc_ctx *_enc,int _last,ogg_packet *_op){
+  if(_enc==NULL)return OC_FAULT;
+  return theora_encode_packetout(&_enc->state,_last,_op);
+}
+
+void th_encode_free(th_enc_ctx *_enc){
+  if(_enc!=NULL){
+    theora_clear(&_enc->state);
+    _ogg_free(_enc->buf);
+    _ogg_free(_enc);
+  }
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encfrag.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encfrag.c
new file mode 100644
index 0000000..512ab3a
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encfrag.c
@@ -0,0 +1,397 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: encfrag.c 16019 2009-05-20 01:36:41Z tterribe $
+
+ ********************************************************************/
+#include <stdlib.h>
+#include <string.h>
+#include "codec_internal.h"
+
+
+void oc_enc_frag_sub(const CP_INSTANCE *_cpi,ogg_int16_t _diff[64],
+ const unsigned char *_src,const unsigned char *_ref,int _ystride){
+  (*_cpi->opt_vtable.frag_sub)(_diff,_src,_ref,_ystride);
+}
+
+void oc_enc_frag_sub_c(ogg_int16_t _diff[64],const unsigned char *_src,
+ const unsigned char *_ref,int _ystride){
+  int i;
+  for(i=0;i<8;i++){
+    int j;
+    for(j=0;j<8;j++)_diff[i*8+j]=(ogg_int16_t)(_src[j]-_ref[j]);
+    _src+=_ystride;
+    _ref+=_ystride;
+  }
+}
+
+void oc_enc_frag_sub_128(const CP_INSTANCE *_cpi,ogg_int16_t _diff[64],
+ const unsigned char *_src,int _ystride){
+  (*_cpi->opt_vtable.frag_sub_128)(_diff,_src,_ystride);
+}
+
+void oc_enc_frag_sub_128_c(ogg_int16_t *_diff,
+ const unsigned char *_src,int _ystride){
+  int i;
+  for(i=0;i<8;i++){
+    int j;
+    for(j=0;j<8;j++)_diff[i*8+j]=(ogg_int16_t)(_src[j]-128);
+    _src+=_ystride;
+  }
+}
+
+unsigned oc_enc_frag_sad(const CP_INSTANCE *_cpi,const unsigned char *_x,
+ const unsigned char *_y,int _ystride){
+  return (*_cpi->opt_vtable.frag_sad)(_x,_y,_ystride);
+}
+
+unsigned oc_enc_frag_sad_c(const unsigned char *_src,
+ const unsigned char *_ref,int _ystride){
+  unsigned sad;
+  int      i;
+  sad=0;
+  for(i=8;i-->0;){
+    int j;
+    for(j=0;j<8;j++)sad+=abs(_src[j]-_ref[j]);
+    _src+=_ystride;
+    _ref+=_ystride;
+  }
+  return sad;
+}
+
+unsigned oc_enc_frag_sad_thresh(const CP_INSTANCE *_cpi,
+ const unsigned char *_src,const unsigned char *_ref,int _ystride,
+ unsigned _thresh){
+  return (*_cpi->opt_vtable.frag_sad_thresh)(_src,_ref,_ystride,_thresh);
+}
+
+unsigned oc_enc_frag_sad_thresh_c(const unsigned char *_src,
+ const unsigned char *_ref,int _ystride,unsigned _thresh){
+  unsigned sad;
+  int      i;
+  sad=0;
+  for(i=8;i-->0;){
+    int j;
+    for(j=0;j<8;j++)sad+=abs(_src[j]-_ref[j]);
+    if(sad>_thresh)break;
+    _src+=_ystride;
+    _ref+=_ystride;
+  }
+  return sad;
+}
+
+unsigned oc_enc_frag_sad2_thresh(const CP_INSTANCE *_cpi,
+ const unsigned char *_src,const unsigned char *_ref1,
+ const unsigned char *_ref2,int _ystride,unsigned _thresh){
+  return (*_cpi->opt_vtable.frag_sad2_thresh)(_src,_ref1,_ref2,_ystride,
+   _thresh);
+}
+
+unsigned oc_enc_frag_sad2_thresh_c(const unsigned char *_src,
+ const unsigned char *_ref1,const unsigned char *_ref2,int _ystride,
+ unsigned _thresh){
+  unsigned sad;
+  int      i;
+  sad=0;
+  for(i=8;i-->0;){
+    int j;
+    for(j=0;j<8;j++)sad+=abs(_src[j]-(_ref1[j]+_ref2[j]>>1));
+    if(sad>_thresh)break;
+    _src+=_ystride;
+    _ref1+=_ystride;
+    _ref2+=_ystride;
+  }
+  return sad;
+}
+
+static void oc_diff_hadamard(ogg_int16_t _buf[64],const unsigned char *_src,
+ const unsigned char *_ref,int _ystride){
+  int i;
+  for(i=0;i<8;i++){
+    int t0;
+    int t1;
+    int t2;
+    int t3;
+    int t4;
+    int t5;
+    int t6;
+    int t7;
+    int r;
+    /*Hadamard stage 1:*/
+    t0=_src[0]-_ref[0]+_src[4]-_ref[4];
+    t4=_src[0]-_ref[0]-_src[4]+_ref[4];
+    t1=_src[1]-_ref[1]+_src[5]-_ref[5];
+    t5=_src[1]-_ref[1]-_src[5]+_ref[5];
+    t2=_src[2]-_ref[2]+_src[6]-_ref[6];
+    t6=_src[2]-_ref[2]-_src[6]+_ref[6];
+    t3=_src[3]-_ref[3]+_src[7]-_ref[7];
+    t7=_src[3]-_ref[3]-_src[7]+_ref[7];
+    /*Hadamard stage 2:*/
+    r=t0;
+    t0+=t2;
+    t2=r-t2;
+    r=t1;
+    t1+=t3;
+    t3=r-t3;
+    r=t4;
+    t4+=t6;
+    t6=r-t6;
+    r=t5;
+    t5+=t7;
+    t7=r-t7;
+    /*Hadamard stage 3:*/
+    _buf[0*8+i]=(ogg_int16_t)(t0+t1);
+    _buf[1*8+i]=(ogg_int16_t)(t0-t1);
+    _buf[2*8+i]=(ogg_int16_t)(t2+t3);
+    _buf[3*8+i]=(ogg_int16_t)(t2-t3);
+    _buf[4*8+i]=(ogg_int16_t)(t4+t5);
+    _buf[5*8+i]=(ogg_int16_t)(t4-t5);
+    _buf[6*8+i]=(ogg_int16_t)(t6+t7);
+    _buf[7*8+i]=(ogg_int16_t)(t6-t7);
+    _src+=_ystride;
+    _ref+=_ystride;
+  }
+}
+
+static void oc_diff_hadamard2(ogg_int16_t _buf[64],const unsigned char *_src,
+ const unsigned char *_ref1,const unsigned char *_ref2,int _ystride){
+  int i;
+  for(i=0;i<8;i++){
+    int t0;
+    int t1;
+    int t2;
+    int t3;
+    int t4;
+    int t5;
+    int t6;
+    int t7;
+    int r;
+    /*Hadamard stage 1:*/
+    r=_ref1[0]+_ref2[0]>>1;
+    t4=_ref1[4]+_ref2[4]>>1;
+    t0=_src[0]-r+_src[4]-t4;
+    t4=_src[0]-r-_src[4]+t4;
+    r=_ref1[1]+_ref2[1]>>1;
+    t5=_ref1[5]+_ref2[5]>>1;
+    t1=_src[1]-r+_src[5]-t5;
+    t5=_src[1]-r-_src[5]+t5;
+    r=_ref1[2]+_ref2[2]>>1;
+    t6=_ref1[6]+_ref2[6]>>1;
+    t2=_src[2]-r+_src[6]-t6;
+    t6=_src[2]-r-_src[6]+t6;
+    r=_ref1[3]+_ref2[3]>>1;
+    t7=_ref1[7]+_ref2[7]>>1;
+    t3=_src[3]-r+_src[7]-t7;
+    t7=_src[3]-r-_src[7]+t7;
+    /*Hadamard stage 2:*/
+    r=t0;
+    t0+=t2;
+    t2=r-t2;
+    r=t1;
+    t1+=t3;
+    t3=r-t3;
+    r=t4;
+    t4+=t6;
+    t6=r-t6;
+    r=t5;
+    t5+=t7;
+    t7=r-t7;
+    /*Hadamard stage 3:*/
+    _buf[0*8+i]=(ogg_int16_t)(t0+t1);
+    _buf[1*8+i]=(ogg_int16_t)(t0-t1);
+    _buf[2*8+i]=(ogg_int16_t)(t2+t3);
+    _buf[3*8+i]=(ogg_int16_t)(t2-t3);
+    _buf[4*8+i]=(ogg_int16_t)(t4+t5);
+    _buf[5*8+i]=(ogg_int16_t)(t4-t5);
+    _buf[6*8+i]=(ogg_int16_t)(t6+t7);
+    _buf[7*8+i]=(ogg_int16_t)(t6-t7);
+    _src+=_ystride;
+    _ref1+=_ystride;
+    _ref2+=_ystride;
+  }
+}
+
+static void oc_intra_hadamard(ogg_int16_t _buf[64],const unsigned char *_src,
+ int _ystride){
+  int i;
+  for(i=0;i<8;i++){
+    int t0;
+    int t1;
+    int t2;
+    int t3;
+    int t4;
+    int t5;
+    int t6;
+    int t7;
+    int r;
+    /*Hadamard stage 1:*/
+    t0=_src[0]+_src[4];
+    t4=_src[0]-_src[4];
+    t1=_src[1]+_src[5];
+    t5=_src[1]-_src[5];
+    t2=_src[2]+_src[6];
+    t6=_src[2]-_src[6];
+    t3=_src[3]+_src[7];
+    t7=_src[3]-_src[7];
+    /*Hadamard stage 2:*/
+    r=t0;
+    t0+=t2;
+    t2=r-t2;
+    r=t1;
+    t1+=t3;
+    t3=r-t3;
+    r=t4;
+    t4+=t6;
+    t6=r-t6;
+    r=t5;
+    t5+=t7;
+    t7=r-t7;
+    /*Hadamard stage 3:*/
+    _buf[0*8+i]=(ogg_int16_t)(t0+t1);
+    _buf[1*8+i]=(ogg_int16_t)(t0-t1);
+    _buf[2*8+i]=(ogg_int16_t)(t2+t3);
+    _buf[3*8+i]=(ogg_int16_t)(t2-t3);
+    _buf[4*8+i]=(ogg_int16_t)(t4+t5);
+    _buf[5*8+i]=(ogg_int16_t)(t4-t5);
+    _buf[6*8+i]=(ogg_int16_t)(t6+t7);
+    _buf[7*8+i]=(ogg_int16_t)(t6-t7);
+    _src+=_ystride;
+  }
+}
+
+unsigned oc_hadamard_sad_thresh(const ogg_int16_t _buf[64],unsigned _thresh){
+  unsigned    sad;
+  int         t0;
+  int         t1;
+  int         t2;
+  int         t3;
+  int         t4;
+  int         t5;
+  int         t6;
+  int         t7;
+  int         r;
+  int         i;
+  sad=0;
+  for(i=0;i<8;i++){
+    /*Hadamard stage 1:*/
+    t0=_buf[i*8+0]+_buf[i*8+4];
+    t4=_buf[i*8+0]-_buf[i*8+4];
+    t1=_buf[i*8+1]+_buf[i*8+5];
+    t5=_buf[i*8+1]-_buf[i*8+5];
+    t2=_buf[i*8+2]+_buf[i*8+6];
+    t6=_buf[i*8+2]-_buf[i*8+6];
+    t3=_buf[i*8+3]+_buf[i*8+7];
+    t7=_buf[i*8+3]-_buf[i*8+7];
+    /*Hadamard stage 2:*/
+    r=t0;
+    t0+=t2;
+    t2=r-t2;
+    r=t1;
+    t1+=t3;
+    t3=r-t3;
+    r=t4;
+    t4+=t6;
+    t6=r-t6;
+    r=t5;
+    t5+=t7;
+    t7=r-t7;
+    /*Hadamard stage 3:*/
+    r=abs(t0+t1);
+    r+=abs(t0-t1);
+    r+=abs(t2+t3);
+    r+=abs(t2-t3);
+    r+=abs(t4+t5);
+    r+=abs(t4-t5);
+    r+=abs(t6+t7);
+    r+=abs(t6-t7);
+    sad+=r;
+    if(sad>_thresh)break;
+  }
+  return sad;
+}
+
+unsigned oc_enc_frag_satd_thresh(const CP_INSTANCE *_cpi,
+ const unsigned char *_src,const unsigned char *_ref,int _ystride,
+ unsigned _thresh){
+  return (*_cpi->opt_vtable.frag_satd_thresh)(_src,_ref,_ystride,_thresh);
+}
+
+unsigned oc_enc_frag_satd_thresh_c(const unsigned char *_src,
+ const unsigned char *_ref,int _ystride,unsigned _thresh){
+  ogg_int16_t buf[64];
+  oc_diff_hadamard(buf,_src,_ref,_ystride);
+  return oc_hadamard_sad_thresh(buf,_thresh)
+   -abs(buf[0]+buf[1]+buf[2]+buf[3]+buf[4]+buf[5]+buf[6]+buf[7]);
+}
+
+unsigned oc_enc_frag_satd2_thresh(const CP_INSTANCE *_cpi,
+ const unsigned char *_src,const unsigned char *_ref1,
+ const unsigned char *_ref2,int _ystride,unsigned _thresh){
+  return (*_cpi->opt_vtable.frag_satd2_thresh)(_src,_ref1,_ref2,_ystride,
+   _thresh);
+}
+
+unsigned oc_enc_frag_satd2_thresh_c(const unsigned char *_src,
+ const unsigned char *_ref1,const unsigned char *_ref2,int _ystride,
+ unsigned _thresh){
+  ogg_int16_t buf[64];
+  oc_diff_hadamard2(buf,_src,_ref1,_ref2,_ystride);
+  return oc_hadamard_sad_thresh(buf,_thresh);
+}
+
+unsigned oc_enc_frag_intra_satd(const CP_INSTANCE *_cpi,
+ const unsigned char *_src,int _ystride){
+  return (*_cpi->opt_vtable.frag_intra_satd)(_src,_ystride);
+}
+
+unsigned oc_enc_frag_intra_satd_c(const unsigned char *_src,int _ystride){
+  ogg_int16_t buf[64];
+  oc_intra_hadamard(buf,_src,_ystride);
+  return oc_hadamard_sad_thresh(buf,0xFF000);
+}
+
+void oc_enc_frag_copy(const CP_INSTANCE *_cpi,unsigned char *_dst,
+ const unsigned char *_src,int _ystride){
+  (*_cpi->opt_vtable.frag_copy)(_dst,_src,_ystride);
+}
+
+void oc_enc_frag_copy2(const CP_INSTANCE *_cpi,unsigned char *_dst,
+ const unsigned char *_src1,const unsigned char *_src2,int _ystride){
+  (*_cpi->opt_vtable.frag_copy2)(_dst,_src1,_src2,_ystride);
+}
+
+void oc_enc_frag_copy2_c(unsigned char *_dst,
+ const unsigned char *_src1,const unsigned char *_src2,int _ystride){
+  int i;
+  int j;
+  for(i=8;i-->0;){
+    for(j=0;j<8;j++)_dst[j]=_src1[j]+_src2[j]>>1;
+    _dst+=_ystride;
+    _src1+=_ystride;
+    _src2+=_ystride;
+  }
+}
+
+void oc_enc_frag_recon_intra(const CP_INSTANCE *_cpi,
+ unsigned char *_dst,int _ystride,const ogg_int16_t _residue[64]){
+  (*_cpi->opt_vtable.frag_recon_intra)(_dst,_ystride,_residue);
+}
+
+void oc_enc_frag_recon_inter(const CP_INSTANCE *_cpi,unsigned char *_dst,
+ const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]){
+  (*_cpi->opt_vtable.frag_recon_inter)(_dst,_src,_ystride,_residue);
+}
+
+void oc_enc_restore_fpu(const CP_INSTANCE *_cpi){
+  (*_cpi->opt_vtable.restore_fpu)();
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encode.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encode.c
new file mode 100644
index 0000000..1287eef
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encode.c
@@ -0,0 +1,460 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: encode.c 16019 2009-05-20 01:36:41Z tterribe $
+
+ ********************************************************************/
+
+#include <stdlib.h>
+#include <string.h>
+#include "codec_internal.h"
+#include "encoder_lookup.h"
+
+static int predict_frag(int wpc,
+                        ogg_int16_t *dc,
+                        ogg_int16_t *down,
+                        int *last){
+
+  if(wpc){
+    ogg_int16_t DC = 0;
+
+    if(wpc&0x1) DC += pc[wpc][0]* *(dc-1);
+    if(wpc&0x2) DC += pc[wpc][1]* *(down-1);
+    if(wpc&0x4) DC += pc[wpc][2]* *(down);
+    if(wpc&0x8) DC += pc[wpc][3]* *(down+1);
+
+    /* if we need to do a shift */
+    if(pc[wpc][4]) {
+      /* If negative add in the negative correction factor */
+      DC += (HIGHBITDUPPED(DC) & pc[wpc][5]);
+      /* Shift in lieu of a divide */
+      DC >>= pc[wpc][4];
+    }
+
+    /* check for outranging on the two predictors that can outrange */
+    if((wpc&(PU|PUL|PL)) == (PU|PUL|PL)){
+      if( abs(DC - *down) > 128) {
+        DC = *down;
+      } else if( abs(DC - *(dc-1)) > 128) {
+        DC = *(dc-1);
+      } else if( abs(DC - *(down-1)) > 128) {
+        DC = *(down-1);
+      }
+    }
+
+    *last = *dc;
+    return *dc - DC;
+  }else{
+    int ret = *dc - *last;
+    *last = *dc;
+    return ret;
+  }
+}
+
+static void PredictDC(CP_INSTANCE *cpi){
+  ogg_int32_t pi;
+  int last[3];  /* last value used for given frame */
+  int y,x,fi = 0;
+  unsigned char *cp = cpi->frag_coded;
+
+  /* for y,u,v; handles arbitrary plane subsampling arrangement.  Shouldn't need to be altered for 4:2:2 or 4:4:4 */
+  for (pi=0; pi<3; pi++) {
+    int v = cpi->frag_v[pi];
+    int h = cpi->frag_h[pi];
+    int subh = !(pi && cpi->info.pixelformat != OC_PF_444);
+    int subv = !(pi && cpi->info.pixelformat == OC_PF_420);
+    ogg_int16_t *dc;
+    ogg_int16_t *down;
+    dc=cpi->frag_dc_tmp;
+    down=cpi->frag_dc_tmp+h;
+
+    for(x=0;x<3;x++)last[x]=0;
+
+    for (y=0; y<v ; y++) {
+      macroblock_t *mb_row = cpi->macro + (y>>subv)*cpi->macro_h;
+      macroblock_t *mb_down = cpi->macro + ((y-1)>>subv)*cpi->macro_h;
+
+      memcpy(down,dc,h*sizeof(*down));
+      memcpy(dc,cpi->frag_dc+fi,h*sizeof(*dc));
+
+      for (x=0; x<h; x++, fi++) {
+        if(cp[fi]) {
+          int wpc=0;
+          int wf = Mode2Frame[mb_row[x>>subh].mode];
+
+          if(x>0){
+            if(cp[fi-1] && Mode2Frame[mb_row[(x-1)>>subh].mode] == wf) wpc|=1; /* left */
+            if(y>0 && cp[fi-h-1] && Mode2Frame[mb_down[(x-1)>>subh].mode] == wf) wpc|=2; /* down left */
+          }
+          if(y>0){
+            if(cp[fi-h] && Mode2Frame[mb_down[x>>subh].mode] == wf) wpc|=4; /* down */
+            if(x+1<h && cp[fi-h+1] && Mode2Frame[mb_down[(x+1)>>subh].mode] == wf) wpc|=8; /* down right */
+          }
+          cpi->frag_dc[fi]=predict_frag(wpc,dc+x,down+x,last+wf);
+        }
+      }
+    }
+  }
+}
+
+static void ChooseTokenTables (CP_INSTANCE *cpi) {
+  int interp = (cpi->FrameType!=KEY_FRAME);
+  int i,plane;
+  int best;
+
+  for(plane = 0; plane<2; plane++){
+
+    /* Work out which table options are best for DC */
+    best = cpi->dc_bits[plane][0];
+    cpi->huffchoice[interp][0][plane] = DC_HUFF_OFFSET;
+    for ( i = 1; i < DC_HUFF_CHOICES; i++ ) {
+      if ( cpi->dc_bits[plane][i] < best ) {
+        best = cpi->dc_bits[plane][i];
+        cpi->huffchoice[interp][0][plane] = i + DC_HUFF_OFFSET;
+      }
+    }
+
+    /* Work out which table options are best for AC */
+    best = cpi->ac1_bits[plane][0]+cpi->acN_bits[plane][0];
+    cpi->huffchoice[interp][1][plane] = AC_HUFF_OFFSET;
+    for ( i = 1; i < AC_HUFF_CHOICES; i++ ) {
+      int test = cpi->ac1_bits[plane][i] + cpi->acN_bits[plane][i];
+      if ( test < best ){
+        best = test;
+        cpi->huffchoice[interp][1][plane] = i + AC_HUFF_OFFSET;
+      }
+    }
+  }
+}
+
+static void EncodeTokenGroup(CP_INSTANCE *cpi,
+                             int group,
+                             int huffY,
+                             int huffC){
+
+  int i;
+  oggpack_buffer *opb=cpi->oggbuffer;
+  unsigned char *token = cpi->dct_token[group];
+  ogg_uint16_t *eb = cpi->dct_token_eb[group];
+
+  for(i=0; i<cpi->dct_token_ycount[group]; i++){
+    if(token[i] < DCT_NOOP){
+      oggpackB_write(opb,cpi->huff_codes[huffY][token[i]].pattern,
+       cpi->huff_codes[huffY][token[i]].nbits);
+      if(OC_DCT_TOKEN_EXTRA_BITS[token[i]]>0){
+        oggpackB_write(opb,eb[i],OC_DCT_TOKEN_EXTRA_BITS[token[i]]);
+      }
+    }
+  }
+
+  for(; i<cpi->dct_token_count[group]; i++){
+    if(token[i] < DCT_NOOP){
+      oggpackB_write(opb,cpi->huff_codes[huffC][token[i]].pattern,
+       cpi->huff_codes[huffC][token[i]].nbits);
+      if (OC_DCT_TOKEN_EXTRA_BITS[token[i]] > 0)
+        oggpackB_write( opb, eb[i], OC_DCT_TOKEN_EXTRA_BITS[token[i]] );
+    }
+  }
+}
+
+static long EncodeTokenList (CP_INSTANCE *cpi) {
+  int i;
+  int interp = (cpi->FrameType!=KEY_FRAME);
+  oggpack_buffer *opb=cpi->oggbuffer;
+  long bits0,bits1;
+
+  /* DC tokens aren't special, they just come first */
+  oggpackB_write( opb, cpi->huffchoice[interp][0][0] - DC_HUFF_OFFSET, DC_HUFF_CHOICE_BITS );
+  oggpackB_write( opb, cpi->huffchoice[interp][0][1] - DC_HUFF_OFFSET, DC_HUFF_CHOICE_BITS );
+
+  bits0 = oggpackB_bits(opb);
+  EncodeTokenGroup(cpi, 0,  cpi->huffchoice[interp][0][0], cpi->huffchoice[interp][0][1]);
+  bits0 = oggpackB_bits(opb)-bits0;
+
+  /* AC tokens */
+  oggpackB_write( opb, cpi->huffchoice[interp][1][0] - AC_HUFF_OFFSET, AC_HUFF_CHOICE_BITS );
+  oggpackB_write( opb, cpi->huffchoice[interp][1][1] - AC_HUFF_OFFSET, AC_HUFF_CHOICE_BITS );
+
+  bits1 = oggpackB_bits(opb);
+  for(i=1;i<=AC_TABLE_2_THRESH;i++)
+    EncodeTokenGroup(cpi, i,  cpi->huffchoice[interp][1][0],
+                     cpi->huffchoice[interp][1][1]);
+
+  for(;i<=AC_TABLE_3_THRESH;i++)
+    EncodeTokenGroup(cpi, i,  cpi->huffchoice[interp][1][0]+AC_HUFF_CHOICES,
+                     cpi->huffchoice[interp][1][1]+AC_HUFF_CHOICES);
+
+  for(;i<=AC_TABLE_4_THRESH;i++)
+    EncodeTokenGroup(cpi, i,  cpi->huffchoice[interp][1][0]+AC_HUFF_CHOICES*2,
+                     cpi->huffchoice[interp][1][1]+AC_HUFF_CHOICES*2);
+
+  for(;i<BLOCK_SIZE;i++)
+    EncodeTokenGroup(cpi, i,  cpi->huffchoice[interp][1][0]+AC_HUFF_CHOICES*3,
+                     cpi->huffchoice[interp][1][1]+AC_HUFF_CHOICES*3);
+  bits1 = oggpackB_bits(opb)-bits1;
+
+  return bits1;
+}
+
+static const unsigned char NoOpModeWords[8] = {0,1,2,3,4,5,6,7};
+static const unsigned char NoOpModeBits[8] = {3,3,3,3,3,3,3,3};
+static const unsigned char NoOpScheme[8] = {0,1,2,3,4,5,6,7};
+
+static void PackModes (CP_INSTANCE *cpi) {
+  ogg_uint32_t    j;
+  ogg_uint32_t    BestScheme = cpi->chooser.scheme_list[0];
+
+  const unsigned char *ModeWords;
+  const unsigned char *ModeBits;
+  const unsigned char  *ModeScheme;
+  int SB,MB;
+
+  oggpack_buffer *opb=cpi->oggbuffer;
+
+  /* Encode the best scheme. */
+  oggpackB_write( opb, BestScheme, (ogg_uint32_t)MODE_METHOD_BITS );
+
+  /* If the chosen scheme is scheme 0 send details of the mode
+     frequency order */
+  if ( BestScheme == 0 ) {
+    for ( j = 0; j < MAX_MODES; j++ ){
+      /* Note that the last two entries are implicit */
+      oggpackB_write( opb, cpi->chooser.scheme0_ranks[j], (ogg_uint32_t)MODE_BITS );
+    }
+    ModeScheme = cpi->chooser.scheme0_ranks;
+    ModeWords = ModeBitPatterns;
+    ModeBits = ModeBitLengths;
+  }
+  else if ( BestScheme < (MODE_METHODS - 1)) {
+    ModeScheme = ModeSchemes[BestScheme-1];
+    ModeWords = ModeBitPatterns;
+    ModeBits = ModeBitLengths;
+  }else{
+    ModeScheme = NoOpScheme;
+    ModeWords = NoOpModeWords;
+    ModeBits = NoOpModeBits;
+  }
+
+  /* modes coded in hilbert order; use superblock addressing */
+  for ( SB=0 ; SB < cpi->super_n[0]; SB++ ){
+    superblock_t *sp = &cpi->super[0][SB];
+    for ( MB=0; MB<4; MB++ ) {
+      macroblock_t *mbp = &cpi->macro[sp->m[MB]];
+      if(mbp->coded){
+        /* Add the appropriate mode entropy token. */
+        int index = ModeScheme[mbp->mode];
+        oggpackB_write( opb, ModeWords[index],
+                        (ogg_uint32_t)ModeBits[index] );
+      }
+    }
+  }
+}
+
+static void PackMotionVectors (CP_INSTANCE *cpi) {
+  const ogg_uint32_t * MvPatternPtr;
+  const ogg_uint32_t * MvBitsPtr;
+
+  ogg_uint32_t SB, MB, B;
+  oggpack_buffer *opb=cpi->oggbuffer;
+
+  /* Choose the coding method */
+  if ( cpi->MVBits_0 < cpi->MVBits_1 ) {
+    oggpackB_write( opb, 0, 1 );
+    MvBitsPtr = &MvBits[MAX_MV_EXTENT];
+    MvPatternPtr = &MvPattern[MAX_MV_EXTENT];
+  }else{
+    oggpackB_write( opb, 1, 1 );
+    MvBitsPtr = &MvBits2[MAX_MV_EXTENT];
+    MvPatternPtr = &MvPattern2[MAX_MV_EXTENT];
+  }
+
+  /* Pack and encode the motion vectors */
+  /* MBs are iterated in Hilbert scan order, but the MVs within the MB are coded in raster order */
+
+  for ( SB=0 ; SB < cpi->super_n[0]; SB++ ){
+    superblock_t *sp = &cpi->super[0][SB];
+    for ( MB=0; MB<4; MB++ ) {
+      macroblock_t *mbp = &cpi->macro[sp->m[MB]];
+      if(!mbp->coded) continue;
+
+      if(mbp->mode==CODE_INTER_PLUS_MV || mbp->mode==CODE_GOLDEN_MV){
+        /* One MV for the macroblock */
+        for(B=0; B<4; B++ ){
+          if(mbp->coded & (1<<B)){
+            oggpackB_write( opb, MvPatternPtr[mbp->mv[B][0]], MvBitsPtr[mbp->mv[B][0]] );
+            oggpackB_write( opb, MvPatternPtr[mbp->mv[B][1]], MvBitsPtr[mbp->mv[B][1]] );
+            break;
+          }
+        }
+
+      }else if (mbp->mode == CODE_INTER_FOURMV){
+        /* MV for each codedblock */
+        for(B=0; B<4; B++ ){
+          if(mbp->coded & (1<<B)){
+            oggpackB_write( opb, MvPatternPtr[mbp->mv[B][0]], MvBitsPtr[mbp->mv[B][0]] );
+            oggpackB_write( opb, MvPatternPtr[mbp->mv[B][1]], MvBitsPtr[mbp->mv[B][1]] );
+          }
+        }
+      }
+    }
+  }
+}
+
+#include <stdio.h>
+void EncodeData(CP_INSTANCE *cpi){
+  long modebits=0;
+  long mvbits=0;
+  long dctbits;
+  long bits;
+
+  PredictDC(cpi);
+  dct_tokenize_finish(cpi);
+
+  /* Mode and MV data not needed for key frames. */
+  if ( cpi->FrameType != KEY_FRAME ){
+    int prebits = oggpackB_bits(cpi->oggbuffer);
+    PackModes(cpi);
+    modebits = oggpackB_bits(cpi->oggbuffer)-prebits;
+    prebits = oggpackB_bits(cpi->oggbuffer);
+    PackMotionVectors (cpi);
+    mvbits = oggpackB_bits(cpi->oggbuffer)-prebits;
+  }
+  ChooseTokenTables(cpi);
+  {
+    int prebits = oggpackB_bits(cpi->oggbuffer);
+    EncodeTokenList(cpi);
+    dctbits = oggpackB_bits(cpi->oggbuffer)-prebits;
+  }
+  bits = oggpackB_bits(cpi->oggbuffer);
+  ReconRefFrames(cpi);
+
+#if defined(OC_COLLECT_METRICS)
+  ModeMetrics(cpi);
+
+#if 0
+  {
+    int total = cpi->frag_total*64;
+    int fi=0,pi,x,y;
+    ogg_int64_t ssd=0;
+    double minimize;
+
+    for(pi=0;pi<3;pi++){
+      int bi = cpi->frag_buffer_index[fi];
+      unsigned char *frame = cpi->frame+bi;
+      unsigned char *recon = cpi->lastrecon+bi;
+      int stride = cpi->stride[pi];
+      int h = cpi->frag_h[pi]*8;
+      int v = cpi->frag_v[pi]*8;
+
+      for(y=0;y<v;y++){
+        int lssd=0;
+        for(x=0;x<h;x++)
+          lssd += (frame[x]-recon[x])*(frame[x]-recon[x]);
+        ssd+=lssd;
+        frame+=stride;
+        recon+=stride;
+      }
+      fi+=cpi->frag_n[pi];
+    }
+
+    minimize = ssd + (float)bits*cpi->token_lambda*16;
+
+    fprintf(stdout,"%d %d %d %d %f %f %f %ld %ld %ld %ld %f %f  %.0f %.0f %.0f %.0f %.0f %.0f %.0f %.0f  %.0f %.0f %.0f %.0f %.0f %.0f %.0f %.0f  \n",
+            (int)cpi->CurrentFrame, // 0
+            cpi->BaseQ,             // 1
+            cpi->token_lambda,      // 2
+            cpi->skip_lambda,       // 3
+            (double)cpi->rho_count[cpi->BaseQ]/total,           // 4
+            (double)cpi->rho_postop/total,                      // 5
+            (double)cpi->rho_postop/cpi->rho_count[cpi->BaseQ], // 6
+            modebits,               // 7
+            mvbits,                 // 8
+            dctbits,                // 9
+            oggpackB_bits(cpi->oggbuffer), // 10
+            (double)ssd,              // 11
+            (double)0,
+            (double)cpi->dist_dist[0][0],//13
+            (double)cpi->dist_dist[0][1],
+            (double)cpi->dist_dist[0][2],
+            (double)cpi->dist_dist[0][3],
+            (double)cpi->dist_dist[0][4],
+            (double)cpi->dist_dist[0][5],
+            (double)cpi->dist_dist[0][6],
+            (double)cpi->dist_dist[0][7],
+            (double)(cpi->dist_bits[0][0]>>7),//21
+            (double)(cpi->dist_bits[0][1]>>7),
+            (double)(cpi->dist_bits[0][2]>>7),
+            (double)(cpi->dist_bits[0][3]>>7),
+            (double)(cpi->dist_bits[0][4]>>7),
+            (double)(cpi->dist_bits[0][5]>>7),
+            (double)(cpi->dist_bits[0][6]>>7),
+            (double)(cpi->dist_bits[0][7]>>7)
+
+
+            );
+  }
+#endif
+#endif
+  oc_enc_restore_fpu(cpi);
+}
+
+void WriteFrameHeader( CP_INSTANCE *cpi) {
+  oggpack_buffer *opb=cpi->oggbuffer;
+
+  /* Output the frame type (base/key frame or inter frame) */
+  oggpackB_write( opb, cpi->FrameType, 1 );
+
+  /* Write out details of the current value of Q... variable resolution. */
+  oggpackB_write( opb, cpi->BaseQ, 6 ); // temporary
+
+  /* we only support one Q index per frame */
+  oggpackB_write( opb, 0, 1 );
+
+  /* If the frame was a base frame then write out the frame dimensions. */
+  if ( cpi->FrameType == KEY_FRAME ) {
+    /* all bits reserved! */
+    oggpackB_write( opb, 0, 3 );
+  }
+}
+
+void oc_enc_dequant_idct8x8(const CP_INSTANCE *_cpi,ogg_int16_t _y[64],
+ const ogg_int16_t _x[64],int _last_zzi,int _ncoefs,
+ ogg_uint16_t _dc_quant,const ogg_uint16_t _ac_quant[64]){
+  (*_cpi->opt_vtable.dequant_idct8x8)(_y,_x,_last_zzi,_ncoefs,
+   _dc_quant,_ac_quant);
+}
+
+void oc_enc_loop_filter(CP_INSTANCE *_cpi,int _flimit){
+  (*_cpi->opt_vtable.enc_loop_filter)(_cpi,_flimit);
+}
+
+void oc_enc_vtable_init_c(CP_INSTANCE *_cpi){
+  /*The implementations prefixed with oc_enc_ are encoder-specific.
+    The rest we re-use from the decoder.*/
+  _cpi->opt_vtable.frag_sad=oc_enc_frag_sad_c;
+  _cpi->opt_vtable.frag_sad_thresh=oc_enc_frag_sad_thresh_c;
+  _cpi->opt_vtable.frag_sad2_thresh=oc_enc_frag_sad2_thresh_c;
+  _cpi->opt_vtable.frag_satd_thresh=oc_enc_frag_satd_thresh_c;
+  _cpi->opt_vtable.frag_satd2_thresh=oc_enc_frag_satd2_thresh_c;
+  _cpi->opt_vtable.frag_intra_satd=oc_enc_frag_intra_satd_c;
+  _cpi->opt_vtable.frag_sub=oc_enc_frag_sub_c;
+  _cpi->opt_vtable.frag_sub_128=oc_enc_frag_sub_128_c;
+  _cpi->opt_vtable.frag_copy=oc_frag_copy_c;
+  _cpi->opt_vtable.frag_copy2=oc_enc_frag_copy2_c;
+  _cpi->opt_vtable.frag_recon_intra=oc_frag_recon_intra_c;
+  _cpi->opt_vtable.frag_recon_inter=oc_frag_recon_inter_c;
+  _cpi->opt_vtable.fdct8x8=oc_enc_fdct8x8_c;
+  _cpi->opt_vtable.dequant_idct8x8=oc_dequant_idct8x8_c;
+  _cpi->opt_vtable.enc_loop_filter=oc_enc_loop_filter_c;
+  _cpi->opt_vtable.restore_fpu=oc_restore_fpu_c;
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_disabled.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_disabled.c
new file mode 100644
index 0000000..74fd37f
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_disabled.c
@@ -0,0 +1,51 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: encoder_disabled.c 13884 2007-09-22 08:38:10Z giles $
+
+ ********************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "toplevel_lookup.h"
+#include "codec_internal.h"
+
+int theora_encode_init(theora_state *th, theora_info *c){
+  return OC_DISABLED;
+}
+
+int theora_encode_YUVin(theora_state *t, yuv_buffer *yuv){
+  return OC_DISABLED;
+}
+
+int theora_encode_packetout( theora_state *t, int last_p, ogg_packet *op){
+  return OC_DISABLED;
+}
+
+int theora_encode_header(theora_state *t, ogg_packet *op){
+  return OC_DISABLED;
+}
+
+int theora_encode_comment(theora_comment *tc, ogg_packet *op){
+  return OC_DISABLED;
+}
+
+int theora_encode_tables(theora_state *t, ogg_packet *op){
+  return OC_DISABLED;
+}
+
+void theora_encoder_clear (CP_INSTANCE * cpi)
+{
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_huffman.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_huffman.h
new file mode 100644
index 0000000..445dd52
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_huffman.h
@@ -0,0 +1,76 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: encoder_huffman.h 15071 2008-06-26 11:28:07Z xiphmont $
+
+ ********************************************************************/
+
+/********************************************************************
+ *  Constants
+ ********************************************************************/
+#define NUM_HUFF_TABLES         80
+#define DC_HUFF_OFFSET          0
+#define AC_HUFF_OFFSET          16
+#define AC_TABLE_2_THRESH       5
+#define AC_TABLE_3_THRESH       14
+#define AC_TABLE_4_THRESH       27
+
+#define DC_HUFF_CHOICES         16
+#define DC_HUFF_CHOICE_BITS     4
+
+#define AC_HUFF_CHOICES         16
+#define AC_HUFF_CHOICE_BITS     4
+
+/* Constants assosciated with entropy tokenisation. */
+#define MAX_SINGLE_TOKEN_VALUE  6
+#define DCT_VAL_CAT2_MIN        3
+#define DCT_VAL_CAT3_MIN        7
+#define DCT_VAL_CAT4_MIN        9
+#define DCT_VAL_CAT5_MIN        13
+#define DCT_VAL_CAT6_MIN        21
+#define DCT_VAL_CAT7_MIN        37
+#define DCT_VAL_CAT8_MIN        69
+
+#define DCT_EOB_TOKEN           0
+#define DCT_EOB_PAIR_TOKEN      1
+#define DCT_EOB_TRIPLE_TOKEN    2
+#define DCT_REPEAT_RUN_TOKEN    3
+#define DCT_REPEAT_RUN2_TOKEN   4
+#define DCT_REPEAT_RUN3_TOKEN   5
+#define DCT_REPEAT_RUN4_TOKEN   6
+
+#define DCT_SHORT_ZRL_TOKEN     7
+#define DCT_ZRL_TOKEN           8
+
+#define ONE_TOKEN               9       /* Special tokens for -1,1,-2,2 */
+#define MINUS_ONE_TOKEN         10
+#define TWO_TOKEN               11
+#define MINUS_TWO_TOKEN         12
+
+#define LOW_VAL_TOKENS          (MINUS_TWO_TOKEN + 1)   /* 13-16 */
+#define DCT_VAL_CATEGORY3       (LOW_VAL_TOKENS + 4)    /* 17 */
+#define DCT_VAL_CATEGORY4       (DCT_VAL_CATEGORY3 + 1) /* 18 */
+#define DCT_VAL_CATEGORY5       (DCT_VAL_CATEGORY4 + 1) /* 19 */
+#define DCT_VAL_CATEGORY6       (DCT_VAL_CATEGORY5 + 1) /* 20 */
+#define DCT_VAL_CATEGORY7       (DCT_VAL_CATEGORY6 + 1) /* 21 */
+#define DCT_VAL_CATEGORY8       (DCT_VAL_CATEGORY7 + 1) /* 22 */
+
+#define DCT_RUN_CATEGORY1       (DCT_VAL_CATEGORY8 + 1) /* 23-27 */
+#define DCT_RUN_CATEGORY1B      (DCT_RUN_CATEGORY1 + 5) /* 28 */
+#define DCT_RUN_CATEGORY1C      (DCT_RUN_CATEGORY1B+ 1) /* 29 */
+#define DCT_RUN_CATEGORY2       (DCT_RUN_CATEGORY1C+ 1) /* 30 */
+#define DCT_RUN_CATEGORY2B      (DCT_RUN_CATEGORY2 + 1) /* 31 */
+
+/* 32 */
+#define MAX_ENTROPY_TOKENS      (DCT_RUN_CATEGORY2B + 1) /* 32 */
+#define DCT_NOOP                MAX_ENTROPY_TOKENS
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_lookup.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_lookup.h
new file mode 100644
index 0000000..2760f07
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_lookup.h
@@ -0,0 +1,161 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function: simple static lookups for VP3 frame encoder
+  last mod: $Id: encoder_lookup.h 15040 2008-06-15 10:31:44Z xiphmont $
+
+ ********************************************************************/
+
+#include "codec_internal.h"
+
+static const ogg_uint32_t MvPattern[(MAX_MV_EXTENT * 2) + 1] = {
+  0x000000ff, 0x000000fd, 0x000000fb, 0x000000f9,
+  0x000000f7, 0x000000f5, 0x000000f3, 0x000000f1,
+  0x000000ef, 0x000000ed, 0x000000eb, 0x000000e9,
+  0x000000e7, 0x000000e5, 0x000000e3, 0x000000e1,
+  0x0000006f, 0x0000006d, 0x0000006b, 0x00000069,
+  0x00000067, 0x00000065, 0x00000063, 0x00000061,
+  0x0000002f, 0x0000002d, 0x0000002b, 0x00000029,
+  0x00000009, 0x00000007, 0x00000002, 0x00000000,
+  0x00000001, 0x00000006, 0x00000008, 0x00000028,
+  0x0000002a, 0x0000002c, 0x0000002e, 0x00000060,
+  0x00000062, 0x00000064, 0x00000066, 0x00000068,
+  0x0000006a, 0x0000006c, 0x0000006e, 0x000000e0,
+  0x000000e2, 0x000000e4, 0x000000e6, 0x000000e8,
+  0x000000ea, 0x000000ec, 0x000000ee, 0x000000f0,
+  0x000000f2, 0x000000f4, 0x000000f6, 0x000000f8,
+  0x000000fa, 0x000000fc, 0x000000fe,
+};
+
+static const ogg_uint32_t MvBits[(MAX_MV_EXTENT * 2) + 1] = {
+  8, 8, 8, 8, 8, 8, 8, 8,
+  8, 8, 8, 8, 8, 8, 8, 8,
+  7, 7, 7, 7, 7, 7, 7, 7,
+  6, 6, 6, 6, 4, 4, 3, 3,
+  3, 4, 4, 6, 6, 6, 6, 7,
+  7, 7, 7, 7, 7, 7, 7, 8,
+  8, 8, 8, 8, 8, 8, 8, 8,
+  8, 8, 8, 8, 8, 8, 8,
+};
+
+static const ogg_uint32_t MvPattern2[(MAX_MV_EXTENT * 2) + 1] = {
+  0x0000003f, 0x0000003d, 0x0000003b, 0x00000039,
+  0x00000037, 0x00000035, 0x00000033, 0x00000031,
+  0x0000002f, 0x0000002d, 0x0000002b, 0x00000029,
+  0x00000027, 0x00000025, 0x00000023, 0x00000021,
+  0x0000001f, 0x0000001d, 0x0000001b, 0x00000019,
+  0x00000017, 0x00000015, 0x00000013, 0x00000011,
+  0x0000000f, 0x0000000d, 0x0000000b, 0x00000009,
+  0x00000007, 0x00000005, 0x00000003, 0x00000000,
+  0x00000002, 0x00000004, 0x00000006, 0x00000008,
+  0x0000000a, 0x0000000c, 0x0000000e, 0x00000010,
+  0x00000012, 0x00000014, 0x00000016, 0x00000018,
+  0x0000001a, 0x0000001c, 0x0000001e, 0x00000020,
+  0x00000022, 0x00000024, 0x00000026, 0x00000028,
+  0x0000002a, 0x0000002c, 0x0000002e, 0x00000030,
+  0x00000032, 0x00000034, 0x00000036, 0x00000038,
+  0x0000003a, 0x0000003c, 0x0000003e,
+};
+
+static const ogg_uint32_t MvBits2[(MAX_MV_EXTENT * 2) + 1] = {
+  6, 6, 6, 6, 6, 6, 6, 6,
+  6, 6, 6, 6, 6, 6, 6, 6,
+  6, 6, 6, 6, 6, 6, 6, 6,
+  6, 6, 6, 6, 6, 6, 6, 6,
+  6, 6, 6, 6, 6, 6, 6, 6,
+  6, 6, 6, 6, 6, 6, 6, 6,
+  6, 6, 6, 6, 6, 6, 6, 6,
+  6, 6, 6, 6, 6, 6, 6,
+};
+
+static const unsigned char ModeBitPatterns[MAX_MODES] = {
+  0x00, 0x02, 0x06, 0x0E, 0x1E, 0x3E, 0x7E, 0x7F };
+
+static const unsigned char ModeBitLengths[MAX_MODES] =  {
+  1,    2,    3,    4,    5,    6,    7,    7 };
+
+static const unsigned char ModeBitLengthsD[MAX_MODES] =  {
+  3,    3,    3,    3,    3,    3,    3,    3 };
+
+static const unsigned char ModeSchemes[MODE_METHODS-1][MAX_MODES] =  {
+  /* Last Mv dominates */
+  { 3,    4,    2,    0,    1,    5,    6,    7 },    /* L P  M N I G GM 4 */
+  { 2,    4,    3,    0,    1,    5,    6,    7 },    /* L P  N M I G GM 4 */
+  { 3,    4,    1,    0,    2,    5,    6,    7 },    /* L M  P N I G GM 4 */
+  { 2,    4,    1,    0,    3,    5,    6,    7 },    /* L M  N P I G GM 4 */
+
+  /* No MV dominates */
+  { 0,    4,    3,    1,    2,    5,    6,    7 },    /* N L  P M I G GM 4 */
+  { 0,    5,    4,    2,    3,    1,    6,    7 },    /* N G  L P M I GM 4 */
+  
+  /* fallback */
+  { 0,    1,    2,    3,    4,    5,    6,    7 }
+};
+
+#define PUR 8
+#define PU 4
+#define PUL 2
+#define PL 1
+#define HIGHBITDUPPED(X) (((ogg_int16_t) X)  >> 15)
+
+/* predictor multiplier up-left, up, up-right,left, shift
+   Entries are unpacked in the order L, UL, U, UR */
+static const ogg_int16_t pc[16][6]={
+  {0,0,0,0,0,0},
+  {1,0,0,0,0,0},      /* PL */
+  {0,1,0,0,0,0},      /* PUL */
+  {1,0,0,0,0,0},      /* PUL|PL */
+  {0,0,1,0,0,0},      /* PU */
+  {1,0,1,0,1,1},      /* PU|PL */
+  {0,0,1,0,0,0},      /* PU|PUL */
+  {29,-26,29,0,5,31}, /* PU|PUL|PL */
+  {0,0,0,1,0,0},      /* PUR */
+  {75,0,0,53,7,127},  /* PUR|PL */
+  {0,1,0,1,1,1},      /* PUR|PUL */
+  {75,0,0,53,7,127},  /* PUR|PUL|PL */
+  {0,0,1,0,0,0},      /* PUR|PU */
+  {75,0,0,53,7,127},  /* PUR|PU|PL */
+  {0,3,10,3,4,15},    /* PUR|PU|PUL */
+  {29,-26,29,0,5,31}  /* PUR|PU|PUL|PL */
+};
+
+/* boundary case bit masks. */
+static const int bc_mask[8]={
+  /* normal case no boundary condition */
+  PUR|PU|PUL|PL,
+  /* left column */
+  PUR|PU,
+  /* top row */
+  PL,
+  /* top row, left column */
+  0,
+  /* right column */
+  PU|PUL|PL,
+  /* right and left column */
+  PU,
+  /* top row, right column */
+  PL,
+  /* top row, right and left column */
+  0
+};
+
+static const ogg_int16_t Mode2Frame[] = {
+  1,  /* CODE_INTER_NO_MV     0 => Encoded diff from same MB last frame  */
+  0,  /* CODE_INTRA           1 => DCT Encoded Block */
+  1,  /* CODE_INTER_PLUS_MV   2 => Encoded diff from included MV MB last frame */
+  1,  /* CODE_INTER_LAST_MV   3 => Encoded diff from MRU MV MB last frame */
+  1,  /* CODE_INTER_PRIOR_MV  4 => Encoded diff from included 4 separate MV blocks */
+  2,  /* CODE_USING_GOLDEN    5 => Encoded diff from same MB golden frame */
+  2,  /* CODE_GOLDEN_MV       6 => Encoded diff from included MV MB golden frame */
+  1   /* CODE_INTER_FOUR_MV   7 => Encoded diff from included 4 separate MV blocks */
+};
+
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_quant.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_quant.c
new file mode 100644
index 0000000..5be3884
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_quant.c
@@ -0,0 +1,293 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2005                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: encoder_quant.c 15953 2009-04-26 14:30:15Z tterribe $
+
+ ********************************************************************/
+
+#include <stdlib.h>
+#include <string.h>
+#include "codec_internal.h"
+#include "quant_lookup.h"
+#include "mathops.h"
+
+#define OC_QUANT_MAX        (1024<<2)
+static const unsigned OC_DC_QUANT_MIN[2]={4<<2,8<<2};
+static const unsigned OC_AC_QUANT_MIN[2]={2<<2,4<<2};
+
+void oc_quant_params_pack(oggpack_buffer *_opb,const th_quant_info *_qinfo){
+  const th_quant_ranges *qranges;
+  const th_quant_base   *base_mats[2*3*64];
+  int                    indices[2][3][64];
+  int                    nbase_mats;
+  int                    nbits;
+  int                    ci;
+  int                    qi;
+  int                    qri;
+  int                    qti;
+  int                    pli;
+  int                    qtj;
+  int                    plj;
+  int                    bmi;
+  int                    i;
+  /*Unlike the scale tables, we can't assume the maximum value will be in
+     index 0, so search for it here.*/
+  i=_qinfo->loop_filter_limits[0];
+  for(qi=1;qi<64;qi++)i=OC_MAXI(i,_qinfo->loop_filter_limits[qi]);
+  nbits=OC_ILOG_32(i);
+  oggpackB_write(_opb,nbits,3);
+  for(qi=0;qi<64;qi++){
+    oggpackB_write(_opb,_qinfo->loop_filter_limits[qi],nbits);
+  }
+  /*580 bits for VP3.*/
+  nbits=OC_MAXI(OC_ILOG_32(_qinfo->ac_scale[0]),1);
+  oggpackB_write(_opb,nbits-1,4);
+  for(qi=0;qi<64;qi++)oggpackB_write(_opb,_qinfo->ac_scale[qi],nbits);
+  /*516 bits for VP3.*/
+  nbits=OC_MAXI(OC_ILOG_32(_qinfo->dc_scale[0]),1);
+  oggpackB_write(_opb,nbits-1,4);
+  for(qi=0;qi<64;qi++)oggpackB_write(_opb,_qinfo->dc_scale[qi],nbits);
+  /*Consolidate any duplicate base matrices.*/
+  nbase_mats=0;
+  for(qti=0;qti<2;qti++)for(pli=0;pli<3;pli++){
+    qranges=_qinfo->qi_ranges[qti]+pli;
+    for(qri=0;qri<=qranges->nranges;qri++){
+      for(bmi=0;;bmi++){
+        if(bmi>=nbase_mats){
+          base_mats[bmi]=qranges->base_matrices+qri;
+          indices[qti][pli][qri]=nbase_mats++;
+          break;
+        }
+        else if(memcmp(base_mats[bmi][0],qranges->base_matrices[qri],
+         sizeof(base_mats[bmi][0]))==0){
+          indices[qti][pli][qri]=bmi;
+          break;
+        }
+      }
+    }
+  }
+  /*Write out the list of unique base matrices.
+    1545 bits for VP3 matrices.*/
+  oggpackB_write(_opb,nbase_mats-1,9);
+  for(bmi=0;bmi<nbase_mats;bmi++){
+    for(ci=0;ci<64;ci++)oggpackB_write(_opb,base_mats[bmi][0][ci],8);
+  }
+  /*Now store quant ranges and their associated indices into the base matrix
+     list.
+    46 bits for VP3 matrices.*/
+  nbits=OC_ILOG_32(nbase_mats-1);
+  for(i=0;i<6;i++){
+    qti=i/3;
+    pli=i%3;
+    qranges=_qinfo->qi_ranges[qti]+pli;
+    if(i>0){
+      if(qti>0){
+        if(qranges->nranges==_qinfo->qi_ranges[qti-1][pli].nranges&&
+         memcmp(qranges->sizes,_qinfo->qi_ranges[qti-1][pli].sizes,
+         qranges->nranges*sizeof(qranges->sizes[0]))==0&&
+         memcmp(indices[qti][pli],indices[qti-1][pli],
+         (qranges->nranges+1)*sizeof(indices[qti][pli][0]))==0){
+          oggpackB_write(_opb,1,2);
+          continue;
+        }
+      }
+      qtj=(i-1)/3;
+      plj=(i-1)%3;
+      if(qranges->nranges==_qinfo->qi_ranges[qtj][plj].nranges&&
+       memcmp(qranges->sizes,_qinfo->qi_ranges[qtj][plj].sizes,
+       qranges->nranges*sizeof(qranges->sizes[0]))==0&&
+       memcmp(indices[qti][pli],indices[qtj][plj],
+       (qranges->nranges+1)*sizeof(indices[qti][pli][0]))==0){
+        oggpackB_write(_opb,0,1+(qti>0));
+        continue;
+      }
+      oggpackB_write(_opb,1,1);
+    }
+    oggpackB_write(_opb,indices[qti][pli][0],nbits);
+    for(qi=qri=0;qi<63;qri++){
+      oggpackB_write(_opb,qranges->sizes[qri]-1,OC_ILOG_32(62-qi));
+      qi+=qranges->sizes[qri];
+      oggpackB_write(_opb,indices[qti][pli][qri+1],nbits);
+    }
+  }
+}
+
+static void oc_iquant_init(oc_iquant *_this,ogg_uint16_t _d){
+  ogg_uint32_t t;
+  int          l;
+  _d<<=1;
+  l=OC_ILOG_32(_d)-1;
+  t=1+((ogg_uint32_t)1<<16+l)/_d;
+  _this->m=(ogg_int16_t)(t-0x10000);
+  _this->l=l;
+}
+
+/*This table gives the square root of the fraction of the squared magnitude of
+   each DCT coefficient relative to the total, scaled by 2**16, for both INTRA
+   and INTER modes.
+  These values were measured after motion-compensated prediction, before
+   quantization, over a large set of test video (from QCIF to 1080p) encoded at
+   all possible rates.
+  The DC coefficient takes into account the DPCM prediction (using the
+   quantized values from neighboring blocks, as the encoder does, but still
+   before quantization of the coefficient in the current block).
+  The results differ significantly from the expected variance (e.g., using an
+   AR(1) model of the signal with rho=0.95, as is frequently done to compute
+   the coding gain of the DCT).
+  We use them to estimate an "average" quantizer for a given quantizer matrix,
+   as this is used to parameterize a number of the rate control decisions.
+  These values are themselves probably quantizer-matrix dependent, since the
+   shape of the matrix affects the noise distribution in the reference frames,
+   but they should at least give us _some_ amount of adaptivity to different
+   matrices, as opposed to hard-coding a table of average Q values for the
+   current set.
+  The main features they capture are that a) only a few of the quantizers in
+   the upper-left corner contribute anything significant at all (though INTER
+   mode is significantly flatter) and b) the DPCM prediction of the DC
+   coefficient gives a very minor improvement in the INTRA case and a quite
+   significant one in the INTER case (over the expected variance).*/
+static ogg_uint16_t OC_RPSD[2][64]={
+  {
+    52725,17370,10399, 6867, 5115, 3798, 2942, 2076,
+    17370, 9900, 6948, 4994, 3836, 2869, 2229, 1619,
+    10399, 6948, 5516, 4202, 3376, 2573, 2015, 1461,
+     6867, 4994, 4202, 3377, 2800, 2164, 1718, 1243,
+     5115, 3836, 3376, 2800, 2391, 1884, 1530, 1091,
+     3798, 2869, 2573, 2164, 1884, 1495, 1212,  873,
+     2942, 2229, 2015, 1718, 1530, 1212, 1001,  704,
+     2076, 1619, 1461, 1243, 1091,  873,  704,  474
+  },
+  {
+    23411,15604,13529,11601,10683, 8958, 7840, 6142,
+    15604,11901,10718, 9108, 8290, 6961, 6023, 4487,
+    13529,10718, 9961, 8527, 7945, 6689, 5742, 4333,
+    11601, 9108, 8527, 7414, 7084, 5923, 5175, 3743,
+    10683, 8290, 7945, 7084, 6771, 5754, 4793, 3504,
+     8958, 6961, 6689, 5923, 5754, 4679, 3936, 2989,
+     7840, 6023, 5742, 5175, 4793, 3936, 3522, 2558,
+     6142, 4487, 4333, 3743, 3504, 2989, 2558, 1829
+  }
+};
+
+/*The fraction of the squared magnitude of the residuals in each color channel
+   relative to the total, scaled by 2**16, for each pixel format.
+  These values were measured after motion-compensated prediction, before
+   quantization, over a large set of test video encoded at all possible rates.
+  TODO: These values are only from INTER frames; it should be re-measured for
+   INTRA frames.*/
+static ogg_uint16_t OC_PCD[4][3]={
+  {59926, 3038, 2572},
+  {55201, 5597, 4738},
+  {55201, 5597, 4738},
+  {47682, 9669, 8185}
+};
+
+
+
+/* a copied/reconciled version of derf's theora-exp code; redundancy
+   should be eliminated at some point */
+void InitQTables( CP_INSTANCE *cpi ){
+  /*Coding mode: intra or inter.*/
+  int qti;
+  /*Y', Cb, Cr.*/
+  int pli;
+  th_quant_info *qinfo = &cpi->quant_info;
+  for(qti=0;qti<2;qti++){
+    /*Quality index.*/
+    int qi;
+    int ci;
+    for(pli=0;pli<3;pli++){
+      /*Range iterator.*/
+      int qri;
+      for(qi=0,qri=0;qri<=qinfo->qi_ranges[qti][pli].nranges;qri++){
+        th_quant_base base;
+        ogg_uint32_t  q;
+        int           qi_start;
+        int           qi_end;
+        memcpy(base,qinfo->qi_ranges[qti][pli].base_matrices[qri],
+         sizeof(base));
+        qi_start=qi;
+        if(qri==qinfo->qi_ranges[qti][pli].nranges)qi_end=qi+1;
+        else qi_end=qi+qinfo->qi_ranges[qti][pli].sizes[qri];
+        /*Iterate over quality indicies in this range.*/
+        for(;;){
+          /*In the original VP3.2 code, the rounding offset and the size of the
+             dead zone around 0 were controlled by a "sharpness" parameter.
+            We now R-D optimize the tokens for each block after quantization,
+             so the rounding offset should always be 1/2, and an explicit dead
+             zone is unnecessary.
+            Hence, all of that VP3.2 code is gone from here, and the remaining
+             floating point code has been implemented as equivalent integer
+             code with exact precision.*/
+          /*Scale DC the coefficient from the proper table.*/
+          q=((ogg_uint32_t)qinfo->dc_scale[qi]*base[0]/100)<<2;
+          q=OC_CLAMPI(OC_DC_QUANT_MIN[qti],q,OC_QUANT_MAX);
+          cpi->quant_tables[qti][pli][0][qi]=(ogg_uint16_t)q;
+          oc_iquant_init(cpi->iquant_tables[qti][pli][qi]+0,(ogg_uint16_t)q);
+          /*Now scale AC coefficients from the proper table.*/
+          for(ci=1;ci<64;ci++){
+            int zzi;
+            q=((ogg_uint32_t)qinfo->ac_scale[qi]*base[ci]/100)<<2;
+            q=OC_CLAMPI(OC_AC_QUANT_MIN[qti],q,OC_QUANT_MAX);
+            zzi=zigzag_index[ci];
+            cpi->quant_tables[qti][pli][zzi][qi]=(ogg_uint16_t)q;
+            oc_iquant_init(cpi->iquant_tables[qti][pli][qi]+zzi,
+             (ogg_uint16_t)q);
+          }
+          if(++qi>=qi_end)break;
+          /*Interpolate the next base matrix.*/
+          for(ci=0;ci<64;ci++){
+            unsigned a;
+            unsigned b;
+            unsigned r;
+            unsigned s;
+            a=qinfo->qi_ranges[qti][pli].base_matrices[qri][ci];
+            b=qinfo->qi_ranges[qti][pli].base_matrices[qri+1][ci];
+            r=qi-qi_start;
+            s=qi_end-qi_start;
+            base[ci]=(unsigned char)((2*((s-r)*a+r*b)+s)/(2*s));
+          }
+        }
+      }
+    }
+    /*Now compute an "average" quantizer for each qi level.
+      We do one for INTER and one for INTRA, since their behavior is very
+       different, but average across chroma channels.
+      The basic approach is to compute a harmonic average of the squared
+       quantizer, weighted by the expected squared magnitude of the DCT
+       coefficients.
+      Under the (not quite true) assumption that DCT coefficients are
+       Laplacian-distributed, this preserves the product Q*lambda, where
+       lambda=sqrt(2/sigma**2) is the Laplacian distribution parameter.
+      The value Q*lambda completely determines the entropy of the
+       coefficients.*/
+    for(qi=0;qi<64;qi++){
+      ogg_int64_t q2;
+      q2=0;
+      for(pli=0;pli<3;pli++){
+        ogg_uint32_t qp;
+        qp=0;
+        for(ci=0;ci<64;ci++){
+          unsigned rq;
+          unsigned qd;
+          qd=cpi->quant_tables[qti][pli][zigzag_index[ci]][qi];
+          rq=(OC_RPSD[qti][ci]+(qd>>1))/qd;
+          qp+=rq*(ogg_uint32_t)rq;
+        }
+        q2+=OC_PCD[cpi->info.pixelformat][pli]*(ogg_int64_t)qp;
+      }
+      /*qavg=1.0/sqrt(q2).*/
+      cpi->log_qavg[qti][qi]=OC_Q57(48)-oc_blog64(q2)>>1;
+    }
+  }
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_toplevel.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_toplevel.c
new file mode 100644
index 0000000..27e4990
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/encoder_toplevel.c
@@ -0,0 +1,835 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: encoder_toplevel.c 16044 2009-05-27 02:05:43Z tterribe $
+
+ ********************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+#include "toplevel_lookup.h"
+#include "../internal.h"
+#include "codec_internal.h"
+#include "mathops.h"
+#include "../dec/ocintrin.h"
+#if defined(OC_X86_ASM)
+# include "x86/x86enc.h"
+#endif
+
+
+
+static void oc_enc_calc_lambda(CP_INSTANCE *cpi){
+  ogg_int64_t l;
+  int         qti;
+  qti=cpi->FrameType!=KEY_FRAME;
+  /*For now, lambda is fixed depending on the qi value and frame type:
+      lambda=scale[qti]*(qavg[qti][qi]**1.5),
+     where scale={2.25,1.125}.
+    A more adaptive scheme might perform better, but Theora's behavior does not
+     seem to conform to existing models in the literature.*/
+  /*If rate control is active, use the lambda for the _target_ quantizer.
+    This allows us to scale to rates slightly lower than we'd normally be able
+     to reach, and give the rate control a semblance of "fractional QI"
+     precision.*/
+  if(cpi->info.target_bitrate>0)l=cpi->rc.log_qtarget;
+  else l=cpi->log_qavg[qti][cpi->BaseQ];
+  /*Raise to the 1.5 power.*/
+  l+=l>>1;
+  /*Multiply by 1.125.*/
+  l+=0x00570068E7EF5A1ELL;
+  /*And multiply by an extra factor of 2 for INTRA frames.*/
+  if(!qti)l+=OC_Q57(1);
+  /*The upper bound here is 0x48000.*/
+  cpi->lambda=(int)oc_bexp64(l);
+}
+
+
+
+static void oc_rc_state_init(oc_rc_state *_rc,const theora_info *_info){
+  ogg_int64_t npixels;
+  ogg_int64_t ibpp;
+  /*TODO: These parameters should be exposed in a th_enc_ctl() API.*/
+  _rc->bits_per_frame=(_info->target_bitrate*
+   (ogg_int64_t)_info->fps_denominator)/_info->fps_numerator;
+  /*Insane framerates or frame sizes mean insane bitrates.
+    Let's not get carried away.*/
+  if(_rc->bits_per_frame>0x40000000000000LL){
+    _rc->bits_per_frame=(ogg_int64_t)0x40000000000000LL;
+  }
+  else if(_rc->bits_per_frame<32)_rc->bits_per_frame=32;
+  /*The buffer size is set equal to the keyframe interval, clamped to the range
+     [8,256] frames.
+    The 8 frame minimum gives us some chance to distribute bit estimation
+     errors.
+    The 256 frame maximum means we'll require 8-10 seconds of pre-buffering at
+     24-30 fps, which is not unreasonable.*/
+  _rc->buf_delay=_info->keyframe_frequency_force>256?
+   256:_info->keyframe_frequency_force;
+  _rc->buf_delay=OC_MAXI(_rc->buf_delay,12);
+  _rc->max=_rc->bits_per_frame*_rc->buf_delay;
+  /*Start with a buffer fullness of 75%.
+    We can require fully half the buffer for a keyframe, and so this initial
+     level gives us maximum flexibility for over/under-shooting in subsequent
+     frames.*/
+  _rc->target=_rc->fullness=(_rc->max+1>>1)+(_rc->max+2>>2);
+  /*Pick exponents and initial scales for quantizer selection.
+    TODO: These still need to be tuned.*/
+  npixels=_info->width*(ogg_int64_t)_info->height;
+  _rc->log_npixels=oc_blog64(npixels);
+  ibpp=npixels/_rc->bits_per_frame;
+  if(ibpp<1){
+    _rc->exp[0]=59;
+    _rc->log_scale[0]=oc_blog64(1997)-OC_Q57(8);
+  }
+  else if(ibpp<2){
+    _rc->exp[0]=55;
+    _rc->log_scale[0]=oc_blog64(1604)-OC_Q57(8);
+  }
+  else{
+    _rc->exp[0]=48;
+    _rc->log_scale[0]=oc_blog64(834)-OC_Q57(8);
+  }
+  if(ibpp<4){
+    _rc->exp[1]=100;
+    _rc->log_scale[1]=oc_blog64(2249)-OC_Q57(8);
+  }
+  else if(ibpp<8){
+    _rc->exp[1]=95;
+    _rc->log_scale[1]=oc_blog64(1751)-OC_Q57(8);
+  }
+  else{
+    _rc->exp[1]=73;
+    _rc->log_scale[1]=oc_blog64(1260)-OC_Q57(8);
+  }
+}
+
+static void oc_enc_update_rc_state(CP_INSTANCE *cpi,
+ long _bits,int _qti,int _qi,int _trial){
+  /*Note, setting OC_SCALE_SMOOTHING[1] to 0x80 (0.5), which one might expect
+     to be a reasonable value, actually causes a feedback loop with, e.g., 12
+     fps content encoded at 24 fps; use values near 0 or near 1 for now.
+    TODO: Should probably revisit using an exponential moving average in the
+     first place at some point.*/
+  static const unsigned OC_SCALE_SMOOTHING[2]={0x13,0x00};
+  ogg_int64_t   log_scale;
+  ogg_int64_t   log_bits;
+  ogg_int64_t   log_qexp;
+  /*Compute the estimated scale factor for this frame type.*/
+  log_bits=oc_blog64(_bits);
+  log_qexp=cpi->log_qavg[_qti][_qi]-OC_Q57(2);
+  log_qexp=(log_qexp>>6)*(cpi->rc.exp[_qti]);
+  log_scale=OC_MINI(log_bits-cpi->rc.log_npixels+log_qexp,OC_Q57(16));
+  /*Use it to set that factor directly if this was a trial.*/
+  if(_trial)cpi->rc.log_scale[_qti]=log_scale;
+  else{
+    /*Otherwise update an exponential moving average.*/
+    cpi->rc.log_scale[_qti]=log_scale
+     +(cpi->rc.log_scale[_qti]-log_scale+128>>8)*OC_SCALE_SMOOTHING[_qti];
+    /*And update the buffer fullness level.*/
+    cpi->rc.fullness+=cpi->rc.bits_per_frame*(1+cpi->dup_count)-_bits;
+    /*If we're too quick filling the buffer, that rate is lost forever.*/
+    if(cpi->rc.fullness>cpi->rc.max)cpi->rc.fullness=cpi->rc.max;
+  }
+}
+
+static int oc_enc_select_qi(CP_INSTANCE *cpi,int _qti,int _trial){
+  ogg_int64_t  rate_total;
+  ogg_uint32_t next_key_frame;
+  int          nframes[2];
+  int          buf_delay;
+  ogg_int64_t  log_qtarget;
+  int          best_qi;
+  ogg_int64_t  best_qdiff;
+  int          qi;
+  /*Figure out how to re-distribute bits so that we hit our fullness target
+     before the last keyframe in our current buffer window (after the current
+     frame), or the end of the buffer window, whichever comes first.*/
+  next_key_frame=_qti?cpi->info.keyframe_frequency_force-cpi->LastKeyFrame:0;
+  nframes[0]=(cpi->rc.buf_delay-OC_MINI(next_key_frame,cpi->rc.buf_delay)
+   +cpi->info.keyframe_frequency_force-1)/cpi->info.keyframe_frequency_force;
+  if(nframes[0]+_qti>1){
+    buf_delay=next_key_frame+(nframes[0]-1)*cpi->info.keyframe_frequency_force;
+    nframes[0]--;
+  }
+  else buf_delay=cpi->rc.buf_delay;
+  nframes[1]=buf_delay-nframes[0];
+  rate_total=cpi->rc.fullness-cpi->rc.target
+   +buf_delay*cpi->rc.bits_per_frame;
+  /*Downgrade the delta frame rate to correspond to the current dup count.
+    This will way over-estimate the bits to use for an occasional dup (as
+     opposed to a consistent dup count, as used with VFR input), but the
+     hysteresis on the quantizer below will keep us from going out of control,
+     and we _do_ have more bits to spend after all.*/
+  if(cpi->dup_count>0)nframes[1]=(nframes[1]+cpi->dup_count)/(cpi->dup_count+1);
+  /*If there aren't enough bits to achieve our desired fullness level, use the
+     minimum quality permitted.*/
+  if(rate_total<=0)log_qtarget=OC_QUANT_MAX_LOG;
+  else{
+    static const unsigned char KEY_RATIO[2]={32,17};
+    ogg_int64_t   log_scale0;
+    ogg_int64_t   log_scale1;
+    ogg_int64_t   prevr;
+    ogg_int64_t   curr;
+    ogg_int64_t   realr;
+    int           i;
+    log_scale0=cpi->rc.log_scale[_qti]+cpi->rc.log_npixels;
+    log_scale1=cpi->rc.log_scale[1-_qti]+cpi->rc.log_npixels;
+    curr=(rate_total+(buf_delay>>1))/buf_delay;
+    realr=curr*KEY_RATIO[_qti]+16>>5;
+    for(i=0;i<10;i++){
+      ogg_int64_t rdiff;
+      ogg_int64_t rderiv;
+      ogg_int64_t log_rpow;
+      ogg_int64_t rscale;
+      ogg_int64_t drscale;
+      ogg_int64_t bias;
+      prevr=curr;
+      log_rpow=oc_blog64(prevr)-log_scale0;
+      log_rpow=(log_rpow+(cpi->rc.exp[_qti]>>1))/cpi->rc.exp[_qti]*
+       cpi->rc.exp[1-_qti];
+      rscale=nframes[1-_qti]*KEY_RATIO[1-_qti]*
+       oc_bexp64(log_scale1+log_rpow);
+      rdiff=nframes[_qti]*KEY_RATIO[_qti]*prevr+rscale-(rate_total<<5);
+      drscale=(rscale+(cpi->rc.exp[_qti]>>1))/cpi->rc.exp[_qti]*
+       cpi->rc.exp[1-_qti]/prevr;
+      rderiv=nframes[_qti]*KEY_RATIO[_qti]+drscale;
+      if(rderiv==0)break;
+      bias=rderiv+OC_SIGNMASK(rdiff^rderiv)^OC_SIGNMASK(rdiff^rderiv);
+      curr=prevr-((rdiff<<1)+bias)/(rderiv<<1);
+      realr=curr*KEY_RATIO[_qti]+16>>5;
+      if(curr<=0||realr>rate_total||prevr==curr)break;
+    }
+    log_qtarget=OC_Q57(2)-((oc_blog64(realr)-log_scale0+(cpi->rc.exp[_qti]>>1))/
+     cpi->rc.exp[_qti]<<6);
+    log_qtarget=OC_MINI(log_qtarget,OC_QUANT_MAX_LOG);
+  }
+  /*If this was not one of the initial frames, limit the change in quality.*/
+  if(!_trial){
+    ogg_int64_t log_qmin;
+    ogg_int64_t log_qmax;
+    /*Clamp the target quantizer to within [0.8*Q,1.2*Q], where Q is the
+       current quantizer.
+      TODO: With user-specified quant matrices, we need to enlarge these limits
+       if they don't actually let us change qi values.*/
+    log_qmin=cpi->log_qavg[_qti][cpi->BaseQ]-0x00A4D3C25E68DC58LL;
+    log_qmax=cpi->log_qavg[_qti][cpi->BaseQ]+0x00A4D3C25E68DC58LL;
+    log_qtarget=OC_CLAMPI(log_qmin,log_qtarget,log_qmax);
+  }
+  /*Search for the quantizer that matches the target most closely.
+    We don't assume a linear ordering, but when there are ties we do pick the
+     quantizer closest to the current one.*/
+  best_qi=cpi->info.quality;
+  best_qdiff=cpi->log_qavg[_qti][best_qi]-log_qtarget;
+  best_qdiff=best_qdiff+OC_SIGNMASK(best_qdiff)^OC_SIGNMASK(best_qdiff);
+  for(qi=cpi->info.quality+1;qi<64;qi++){
+    ogg_int64_t qdiff;
+    qdiff=cpi->log_qavg[_qti][qi]-log_qtarget;
+    qdiff=qdiff+OC_SIGNMASK(qdiff)^OC_SIGNMASK(qdiff);
+    if(qdiff<best_qdiff||
+     qdiff==best_qdiff&&abs(qi-cpi->BaseQ)<abs(best_qi-cpi->BaseQ)){
+      best_qi=qi;
+      best_qdiff=qdiff;
+    }
+  }
+  /*Save the quantizer target for lambda calculations.*/
+  cpi->rc.log_qtarget=log_qtarget;
+  return best_qi;
+}
+
+
+
+static void CompressKeyFrame(CP_INSTANCE *cpi, int recode){
+  oggpackB_reset(cpi->oggbuffer);
+  cpi->FrameType = KEY_FRAME;
+  if(cpi->info.target_bitrate>0){
+    cpi->BaseQ=oc_enc_select_qi(cpi,0,cpi->CurrentFrame==1);
+  }
+  oc_enc_calc_lambda(cpi);
+  cpi->LastKeyFrame = 0;
+
+  /* mark as video frame */
+  oggpackB_write(cpi->oggbuffer,0,1);
+
+  WriteFrameHeader(cpi);
+  PickModes(cpi,recode);
+  EncodeData(cpi);
+
+  cpi->LastKeyFrame = 1;
+}
+
+static int CompressFrame( CP_INSTANCE *cpi, int recode ) {
+  oggpackB_reset(cpi->oggbuffer);
+  cpi->FrameType = DELTA_FRAME;
+  if(cpi->info.target_bitrate>0){
+    cpi->BaseQ=oc_enc_select_qi(cpi,1,0);
+  }
+  oc_enc_calc_lambda(cpi);
+
+  /* mark as video frame */
+  oggpackB_write(cpi->oggbuffer,0,1);
+
+  WriteFrameHeader(cpi);
+  if(PickModes(cpi,recode)){
+    /* mode analysis thinks this should have been a keyframe; start over and code as a keyframe instead */
+
+    oggpackB_reset(cpi->oggbuffer);
+    cpi->FrameType = KEY_FRAME;
+    if(cpi->info.target_bitrate>0)cpi->BaseQ=oc_enc_select_qi(cpi,0,0);
+    oc_enc_calc_lambda(cpi);
+    cpi->LastKeyFrame = 0;
+
+    /* mark as video frame */
+    oggpackB_write(cpi->oggbuffer,0,1);
+
+    WriteFrameHeader(cpi);
+
+    PickModes(cpi,1);
+    EncodeData(cpi);
+
+    cpi->LastKeyFrame = 1;
+
+    return 0;
+  }
+
+  if(cpi->first_inter_frame == 0){
+    cpi->first_inter_frame = 1;
+    EncodeData(cpi);
+    if(cpi->info.target_bitrate>0){
+      oc_enc_update_rc_state(cpi,oggpackB_bytes(cpi->oggbuffer)<<3,
+       1,cpi->BaseQ,1);
+    }
+    CompressFrame(cpi,1);
+    return 0;
+  }
+
+  cpi->LastKeyFrame++;
+  EncodeData(cpi);
+
+  return 0;
+}
+
+/********************** The toplevel: encode ***********************/
+
+static void theora_encode_dispatch_init(CP_INSTANCE *cpi);
+
+int theora_encode_init(theora_state *th, theora_info *c){
+  CP_INSTANCE *cpi;
+
+  memset(th, 0, sizeof(*th));
+  /*Currently only the 4:2:0 format is supported.*/
+  if(c->pixelformat!=OC_PF_420)return OC_IMPL;
+  th->internal_encode=cpi=_ogg_calloc(1,sizeof(*cpi));
+  theora_encode_dispatch_init(cpi);
+  oc_mode_scheme_chooser_init(&cpi->chooser);
+#if defined(OC_X86_ASM)
+  oc_enc_vtable_init_x86(cpi);
+#else
+  oc_enc_vtable_init_c(cpi);
+#endif
+
+  c->version_major=TH_VERSION_MAJOR;
+  c->version_minor=TH_VERSION_MINOR;
+  c->version_subminor=TH_VERSION_SUB;
+
+  if(c->quality>63)c->quality=63;
+  if(c->quality<0)c->quality=32;
+  if(c->target_bitrate<0)c->target_bitrate=0;
+  cpi->BaseQ = c->quality;
+
+  /* Set encoder flags. */
+  /* if not AutoKeyframing cpi->ForceKeyFrameEvery = is frequency */
+  if(!c->keyframe_auto_p)
+    c->keyframe_frequency_force = c->keyframe_frequency;
+
+  /* Set the frame rate variables. */
+  if ( c->fps_numerator < 1 )
+    c->fps_numerator = 1;
+  if ( c->fps_denominator < 1 )
+    c->fps_denominator = 1;
+
+  /* don't go too nuts on keyframe spacing; impose a high limit to
+     make certain the granulepos encoding strategy works */
+  if(c->keyframe_frequency_force>32768)c->keyframe_frequency_force=32768;
+  if(c->keyframe_mindistance>32768)c->keyframe_mindistance=32768;
+  if(c->keyframe_mindistance>c->keyframe_frequency_force)
+    c->keyframe_mindistance=c->keyframe_frequency_force;
+  cpi->keyframe_granule_shift=OC_ILOG_32(c->keyframe_frequency_force-1);
+
+
+  /* copy in config */
+  memcpy(&cpi->info,c,sizeof(*c));
+  th->i=&cpi->info;
+  th->granulepos=-1;
+
+  /* Set up an encode buffer */
+  cpi->oggbuffer = _ogg_malloc(sizeof(oggpack_buffer));
+  oggpackB_writeinit(cpi->oggbuffer);
+  cpi->dup_count=0;
+  cpi->nqueued_dups=0;
+  cpi->packetflag=0;
+
+  InitFrameInfo(cpi);
+
+  /* Initialise the compression process. */
+  /* We always start at frame 1 */
+  cpi->CurrentFrame = 1;
+
+  memcpy(cpi->huff_codes,TH_VP31_HUFF_CODES,sizeof(cpi->huff_codes));
+
+  /* This makes sure encoder version specific tables are initialised */
+  memcpy(&cpi->quant_info, &TH_VP31_QUANT_INFO, sizeof(th_quant_info));
+  InitQTables(cpi);
+  if(cpi->info.target_bitrate>0)oc_rc_state_init(&cpi->rc,&cpi->info);
+
+  /* Indicate that the next frame to be compressed is the first in the
+     current clip. */
+  cpi->LastKeyFrame = -1;
+  cpi->readyflag = 1;
+
+  cpi->HeadersWritten = 0;
+  /*We overload this flag to track header output.*/
+  cpi->doneflag=-3;
+
+  return 0;
+}
+
+int theora_encode_YUVin(theora_state *t,
+                         yuv_buffer *yuv){
+  int dropped = 0;
+  ogg_int32_t i;
+  unsigned char *LocalDataPtr;
+  unsigned char *InputDataPtr;
+  CP_INSTANCE *cpi=(CP_INSTANCE *)(t->internal_encode);
+
+  if(!cpi->readyflag)return OC_EINVAL;
+  if(cpi->doneflag>0)return OC_EINVAL;
+
+  /* If frame size has changed, abort out for now */
+  if (yuv->y_height != (int)cpi->info.height ||
+      yuv->y_width != (int)cpi->info.width )
+    return(-1);
+
+  /* Copy over input YUV to internal YUV buffers. */
+  /* we invert the image for backward compatibility with VP3 */
+  /* First copy over the Y data */
+  LocalDataPtr = cpi->frame + cpi->offset[0] + cpi->stride[0]*(yuv->y_height - 1);
+  InputDataPtr = yuv->y;
+  for ( i = 0; i < yuv->y_height; i++ ){
+    memcpy( LocalDataPtr, InputDataPtr, yuv->y_width );
+    LocalDataPtr -= cpi->stride[0];
+    InputDataPtr += yuv->y_stride;
+  }
+
+  /* Now copy over the U data */
+  LocalDataPtr = cpi->frame + cpi->offset[1] + cpi->stride[1]*(yuv->uv_height - 1);
+  InputDataPtr = yuv->u;
+  for ( i = 0; i < yuv->uv_height; i++ ){
+    memcpy( LocalDataPtr, InputDataPtr, yuv->uv_width );
+    LocalDataPtr -= cpi->stride[1];
+    InputDataPtr += yuv->uv_stride;
+  }
+
+  /* Now copy over the V data */
+  LocalDataPtr = cpi->frame + cpi->offset[2] + cpi->stride[2]*(yuv->uv_height - 1);
+  InputDataPtr = yuv->v;
+  for ( i = 0; i < yuv->uv_height; i++ ){
+    memcpy( LocalDataPtr, InputDataPtr, yuv->uv_width );
+    LocalDataPtr -= cpi->stride[2];
+    InputDataPtr += yuv->uv_stride;
+  }
+
+  /* don't allow generating invalid files that overflow the p-frame
+     shift, even if keyframe_auto_p is turned off */
+  if(cpi->LastKeyFrame==-1 || cpi->LastKeyFrame+cpi->dup_count>= (ogg_uint32_t)
+     cpi->info.keyframe_frequency_force){
+
+    CompressKeyFrame(cpi,0);
+    if(cpi->info.target_bitrate>0){
+      oc_enc_update_rc_state(cpi,oggpackB_bytes(cpi->oggbuffer)<<3,
+       0,cpi->BaseQ,1);
+    }
+
+    /* On first frame, the previous was a initial dry-run to prime
+       feed-forward statistics */
+    if(cpi->CurrentFrame==1)CompressKeyFrame(cpi,1);
+
+  }
+  else{
+    /*Compress the frame.*/
+    dropped=CompressFrame(cpi,0);
+  }
+  oc_enc_restore_fpu(cpi);
+
+
+  /* Update stats variables. */
+  {
+    /* swap */
+    unsigned char *temp;
+    temp=cpi->lastrecon;
+    cpi->lastrecon=cpi->recon;
+    cpi->recon=temp;
+  }
+  if(cpi->FrameType==KEY_FRAME){
+    memcpy(cpi->golden,cpi->lastrecon,sizeof(*cpi->lastrecon)*cpi->frame_size);
+  }
+  cpi->CurrentFrame++;
+  cpi->packetflag=1;
+  if(cpi->info.target_bitrate>0){
+    oc_enc_update_rc_state(cpi,oggpackB_bytes(cpi->oggbuffer)<<3,
+     cpi->FrameType!=KEY_FRAME,cpi->BaseQ,0);
+  }
+
+  t->granulepos=
+    ((cpi->CurrentFrame - cpi->LastKeyFrame)<<cpi->keyframe_granule_shift)+
+    cpi->LastKeyFrame - 1;
+  cpi->nqueued_dups=cpi->dup_count;
+  cpi->dup_count=0;
+
+  return 0;
+}
+
+int theora_encode_packetout(theora_state *_t,int _last_p,ogg_packet *_op){
+  CP_INSTANCE *cpi;
+  cpi=(CP_INSTANCE *)_t->internal_encode;
+  if(cpi->doneflag>0)return -1;
+  if(cpi->packetflag){
+    cpi->packetflag=0;
+    _op->packet=oggpackB_get_buffer(cpi->oggbuffer);
+    _op->bytes=oggpackB_bytes(cpi->oggbuffer);
+  }
+  else if(cpi->nqueued_dups>0){
+    cpi->nqueued_dups--;
+    cpi->CurrentFrame++;
+    cpi->LastKeyFrame++;
+    _t->granulepos=cpi->LastKeyFrame-1
+     +(cpi->CurrentFrame-cpi->LastKeyFrame<<cpi->keyframe_granule_shift);
+    _op->packet=NULL;
+    _op->bytes=0;
+  }
+  else{
+    if(_last_p){
+      cpi->doneflag=1;
+#if defined(OC_COLLECT_METRICS)
+      oc_enc_mode_metrics_dump(cpi);
+#endif
+    }
+    return 0;
+  }
+  _last_p=_last_p&&cpi->nqueued_dups<=0;
+  _op->b_o_s=0;
+  _op->e_o_s=_last_p;
+  _op->packetno=cpi->CurrentFrame;
+  _op->granulepos=_t->granulepos;
+  return 1+cpi->nqueued_dups;
+}
+
+static void _tp_writebuffer(oggpack_buffer *opb, const char *buf, const long len)
+{
+  long i;
+
+  for (i = 0; i < len; i++)
+    oggpackB_write(opb, *buf++, 8);
+}
+
+static void _tp_writelsbint(oggpack_buffer *opb, long value)
+{
+  oggpackB_write(opb, value&0xFF, 8);
+  oggpackB_write(opb, value>>8&0xFF, 8);
+  oggpackB_write(opb, value>>16&0xFF, 8);
+  oggpackB_write(opb, value>>24&0xFF, 8);
+}
+
+/* build the initial short header for stream recognition and format */
+int theora_encode_header(theora_state *t, ogg_packet *op){
+  CP_INSTANCE *cpi=(CP_INSTANCE *)(t->internal_encode);
+  int offset_y;
+
+  oggpackB_reset(cpi->oggbuffer);
+  oggpackB_write(cpi->oggbuffer,0x80,8);
+  _tp_writebuffer(cpi->oggbuffer, "theora", 6);
+
+  oggpackB_write(cpi->oggbuffer,TH_VERSION_MAJOR,8);
+  oggpackB_write(cpi->oggbuffer,TH_VERSION_MINOR,8);
+  oggpackB_write(cpi->oggbuffer,TH_VERSION_SUB,8);
+
+  oggpackB_write(cpi->oggbuffer,cpi->info.width>>4,16);
+  oggpackB_write(cpi->oggbuffer,cpi->info.height>>4,16);
+  oggpackB_write(cpi->oggbuffer,cpi->info.frame_width,24);
+  oggpackB_write(cpi->oggbuffer,cpi->info.frame_height,24);
+  oggpackB_write(cpi->oggbuffer,cpi->info.offset_x,8);
+  /* Applications use offset_y to mean offset from the top of the image; the
+   * meaning in the bitstream is the opposite (from the bottom). Transform.
+   */
+  offset_y = cpi->info.height - cpi->info.frame_height -
+    cpi->info.offset_y;
+  oggpackB_write(cpi->oggbuffer,offset_y,8);
+
+  oggpackB_write(cpi->oggbuffer,cpi->info.fps_numerator,32);
+  oggpackB_write(cpi->oggbuffer,cpi->info.fps_denominator,32);
+  oggpackB_write(cpi->oggbuffer,cpi->info.aspect_numerator,24);
+  oggpackB_write(cpi->oggbuffer,cpi->info.aspect_denominator,24);
+
+  oggpackB_write(cpi->oggbuffer,cpi->info.colorspace,8);
+
+  /* The header target_bitrate is limited to 24 bits, so we clamp here */
+  oggpackB_write(cpi->oggbuffer,(cpi->info.target_bitrate>(1<<24)-1) ? ((1<<24)-1) : cpi->info.target_bitrate ,24);
+
+  oggpackB_write(cpi->oggbuffer,cpi->info.quality,6);
+
+  oggpackB_write(cpi->oggbuffer,cpi->keyframe_granule_shift,5);
+
+  oggpackB_write(cpi->oggbuffer,cpi->info.pixelformat,2);
+
+  oggpackB_write(cpi->oggbuffer,0,3); /* spare config bits */
+
+  op->packet=oggpackB_get_buffer(cpi->oggbuffer);
+  op->bytes=oggpackB_bytes(cpi->oggbuffer);
+
+  op->b_o_s=1;
+  op->e_o_s=0;
+
+  op->packetno=0;
+
+  op->granulepos=0;
+  cpi->packetflag=0;
+
+  return(0);
+}
+
+/* build the comment header packet from the passed metadata */
+int theora_encode_comment(theora_comment *tc, ogg_packet *op)
+{
+  const char *vendor = theora_version_string();
+  const int vendor_length = strlen(vendor);
+  oggpack_buffer *opb;
+
+  opb = _ogg_malloc(sizeof(oggpack_buffer));
+  oggpackB_writeinit(opb);
+  oggpackB_write(opb, 0x81, 8);
+  _tp_writebuffer(opb, "theora", 6);
+
+  _tp_writelsbint(opb, vendor_length);
+  _tp_writebuffer(opb, vendor, vendor_length);
+
+  _tp_writelsbint(opb, tc->comments);
+  if(tc->comments){
+    int i;
+    for(i=0;i<tc->comments;i++){
+      if(tc->user_comments[i]){
+        _tp_writelsbint(opb,tc->comment_lengths[i]);
+        _tp_writebuffer(opb,tc->user_comments[i],tc->comment_lengths[i]);
+      }else{
+        oggpackB_write(opb,0,32);
+      }
+    }
+  }
+  op->bytes=oggpack_bytes(opb);
+
+  /* So we're expecting the application will free this? */
+  op->packet=_ogg_malloc(oggpack_bytes(opb));
+  memcpy(op->packet, oggpack_get_buffer(opb), oggpack_bytes(opb));
+  oggpack_writeclear(opb);
+
+  _ogg_free(opb);
+
+  op->b_o_s=0;
+  op->e_o_s=0;
+
+  op->packetno=0;
+  op->granulepos=0;
+
+  return (0);
+}
+
+/* build the final header packet with the tables required
+   for decode */
+int theora_encode_tables(theora_state *t, ogg_packet *op){
+  CP_INSTANCE *cpi=(CP_INSTANCE *)(t->internal_encode);
+
+  oggpackB_reset(cpi->oggbuffer);
+  oggpackB_write(cpi->oggbuffer,0x82,8);
+  _tp_writebuffer(cpi->oggbuffer,"theora",6);
+
+  oc_quant_params_pack(cpi->oggbuffer,&cpi->quant_info);
+  oc_huff_codes_pack(cpi->oggbuffer,(const th_huff_table *)cpi->huff_codes);
+
+  op->packet=oggpackB_get_buffer(cpi->oggbuffer);
+  op->bytes=oggpackB_bytes(cpi->oggbuffer);
+
+  op->b_o_s=0;
+  op->e_o_s=0;
+
+  op->packetno=0;
+
+  op->granulepos=0;
+  cpi->packetflag=0;
+
+  cpi->HeadersWritten = 1;
+
+  return(0);
+}
+
+static void theora_encode_clear (theora_state  *th){
+  CP_INSTANCE *cpi;
+  cpi=(CP_INSTANCE *)th->internal_encode;
+  if(cpi){
+
+    ClearFrameInfo(cpi);
+
+    oggpackB_writeclear(cpi->oggbuffer);
+    _ogg_free(cpi->oggbuffer);
+
+    memset(cpi,0,sizeof(cpi));
+    _ogg_free(cpi);
+  }
+
+  memset(th,0,sizeof(*th));
+}
+
+
+/* returns, in seconds, absolute time of current packet in given
+   logical stream */
+static double theora_encode_granule_time(theora_state *th,
+ ogg_int64_t granulepos){
+#ifndef THEORA_DISABLE_FLOAT
+  CP_INSTANCE *cpi=(CP_INSTANCE *)(th->internal_encode);
+
+  if(granulepos>=0){
+    ogg_int64_t iframe=granulepos>>cpi->keyframe_granule_shift;
+    ogg_int64_t pframe=granulepos-(iframe<<cpi->keyframe_granule_shift);
+
+    return (iframe+pframe)*
+      ((double)cpi->info.fps_denominator/cpi->info.fps_numerator);
+
+  }
+#endif
+
+  return(-1); /* negative granulepos or float calculations disabled */
+}
+
+/* returns frame number of current packet in given logical stream */
+static ogg_int64_t theora_encode_granule_frame(theora_state *th,
+ ogg_int64_t granulepos){
+  CP_INSTANCE *cpi=(CP_INSTANCE *)(th->internal_encode);
+
+  if(granulepos>=0){
+    ogg_int64_t iframe=granulepos>>cpi->keyframe_granule_shift;
+    ogg_int64_t pframe=granulepos-(iframe<<cpi->keyframe_granule_shift);
+
+    return (iframe+pframe-1);
+  }
+
+  return(-1);
+}
+
+
+static int theora_encode_control(theora_state *th,int req,
+ void *buf,size_t buf_sz) {
+  CP_INSTANCE *cpi;
+  int value;
+
+  if(th == NULL)
+    return TH_EFAULT;
+
+  cpi = th->internal_encode;
+
+  switch(req) {
+    case TH_ENCCTL_SET_QUANT_PARAMS:
+      if( ( buf==NULL&&buf_sz!=0 )
+  	   || ( buf!=NULL&&buf_sz!=sizeof(th_quant_info) )
+  	   || cpi->HeadersWritten ){
+        return TH_EINVAL;
+      }
+
+      memcpy(&cpi->quant_info, buf, sizeof(th_quant_info));
+      InitQTables(cpi);
+
+      return 0;
+    case TH_ENCCTL_SET_KEYFRAME_FREQUENCY_FORCE:{
+      ogg_uint32_t keyframe_frequency_force;
+      if(buf==NULL)return TH_EFAULT;
+      if(buf_sz!=sizeof(keyframe_frequency_force))return TH_EINVAL;
+      keyframe_frequency_force=*(ogg_uint32_t *)buf;
+      if(cpi->HeadersWritten){
+        /*It's still early enough to enlarge keyframe_granule_shift.*/
+        cpi->keyframe_granule_shift=OC_CLAMPI(cpi->keyframe_granule_shift,
+         OC_ILOG_32(keyframe_frequency_force-1),31);
+      }
+      cpi->info.keyframe_frequency_force=OC_MINI(keyframe_frequency_force,
+       (ogg_uint32_t)1U<<cpi->keyframe_granule_shift);
+      *(ogg_uint32_t *)buf=cpi->info.keyframe_frequency_force;
+      return 0;
+    }
+    case TH_ENCCTL_SET_VP3_COMPATIBLE:
+      if(cpi->HeadersWritten)
+        return TH_EINVAL;
+
+      memcpy(&cpi->quant_info, &TH_VP31_QUANT_INFO, sizeof(th_quant_info));
+      InitQTables(cpi);
+
+      return 0;
+    case TH_ENCCTL_SET_SPLEVEL:
+      if(buf == NULL || buf_sz != sizeof(int))
+        return TH_EINVAL;
+
+      memcpy(&value, buf, sizeof(int));
+
+      switch(value) {
+        case 0:
+          cpi->MotionCompensation = 1;
+          cpi->info.quick_p = 0;
+        break;
+
+        case 1:
+          cpi->MotionCompensation = 1;
+          cpi->info.quick_p = 1;
+        break;
+
+        case 2:
+          cpi->MotionCompensation = 0;
+          cpi->info.quick_p = 1;
+        break;
+
+        default:
+          return TH_EINVAL;
+      }
+
+      return 0;
+    case TH_ENCCTL_GET_SPLEVEL_MAX:
+      value = 2;
+      memcpy(buf, &value, sizeof(int));
+      return 0;
+    case TH_ENCCTL_SET_DUP_COUNT:{
+      int dup_count;
+      if(buf==NULL)return TH_EFAULT;
+      if(buf_sz!=sizeof(int))return TH_EINVAL;
+      dup_count=*(int *)buf;
+      if(dup_count>=cpi->info.keyframe_frequency_force)return TH_EINVAL;
+      cpi->dup_count=OC_MAXI(dup_count,0);
+      return 0;
+    }break;
+    default:
+      return TH_EIMPL;
+  }
+}
+
+static void theora_encode_dispatch_init(CP_INSTANCE *cpi){
+  cpi->dispatch_vtbl.clear=theora_encode_clear;
+  cpi->dispatch_vtbl.control=theora_encode_control;
+  cpi->dispatch_vtbl.granule_frame=theora_encode_granule_frame;
+  cpi->dispatch_vtbl.granule_time=theora_encode_granule_time;
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/enquant.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/enquant.h
new file mode 100644
index 0000000..c5d989a
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/enquant.h
@@ -0,0 +1,26 @@
+#if !defined(_enquant_H)
+# define _enquant_H (1)
+# include "../dec/quant.h"
+
+typedef struct oc_iquant oc_iquant;
+
+#define OC_QUANT_MAX_LOG (OC_Q57(OC_STATIC_ILOG_32(OC_QUANT_MAX)-1))
+
+/*Used to compute x/d via ((x*m>>16)+x>>l)+(x<0))
+   (i.e., one 16x16->16 mul, 2 shifts, and 2 adds).
+  This is not an approximation; for 16-bit x and d, it is exact.*/
+struct oc_iquant{
+  ogg_int16_t m;
+  ogg_int16_t l;
+};
+
+typedef oc_iquant        oc_iquant_table[64];
+typedef oc_iquant_table  oc_iquant_tables[64];
+
+
+
+void oc_quant_params_pack(oggpack_buffer *_opb,const th_quant_info *_qinfo);
+void oc_enquant_tables_init(oc_quant_table *_dequant[2][3],
+ oc_quant_table *_enquant[2][3],const th_quant_info *_qinfo);
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/frarray.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/frarray.c
new file mode 100644
index 0000000..4e6c8b8
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/frarray.c
@@ -0,0 +1,418 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: frarray.c 15985 2009-05-07 19:37:05Z tterribe $
+
+ ********************************************************************/
+
+#include <string.h>
+#include "codec_internal.h"
+#include <stdio.h>
+
+void fr_clear(CP_INSTANCE *cpi, fr_state_t *fr){
+  fr->sb_partial_last = -1;
+  fr->sb_partial_count = 0;
+  fr->sb_partial_break = 0;
+
+  fr->sb_full_last = -1;
+  fr->sb_full_count = 0;
+  fr->sb_full_break = 0;
+
+  fr->b_last = -1;
+  fr->b_count = 0;
+  fr->b_pend = 0;
+
+  fr->sb_partial=0;
+  fr->sb_coded=0;
+
+  fr->cost=0;
+}
+
+static int BRun( ogg_uint32_t value, ogg_int16_t *token) {
+  
+  /* Coding scheme:
+     Codeword                                RunLength
+     0x                                      1-2
+     10x                                     3-4
+     110x                                    5-6
+     1110xx                                  7-10
+     11110xx                                 11-14
+     11111xxxx                               15-30 */
+
+  if ( value <= 2 ) {
+    *token = value - 1;
+    return 2;
+  } else if ( value <= 4 ) {
+    *token = 0x0004 + (value - 3);
+    return 3;
+  } else if ( value <= 6 ) {
+    *token = 0x000C + (value - 5);
+    return 4;
+  } else if ( value <= 10 ) {
+    *token = 0x0038 + (value - 7);
+    return 6;
+  } else if ( value <= 14 ) {
+    *token = 0x0078 + (value - 11);
+    return 7;
+  } else {
+    *token = 0x01F0 + (value - 15);
+    return 9;
+ }
+}
+
+static int BRunCost( ogg_uint32_t value ) {
+  
+  if ( value <= 0 ) {
+    return 0;
+  } else if ( value <= 2 ) {
+    return 2;
+  } else if ( value <= 4 ) {
+    return 3;
+  } else if ( value <= 6 ) {
+    return 4;
+  } else if ( value <= 10 ) {
+    return 6;
+  } else if ( value <= 14 ) {
+    return 7;
+  } else {
+    return 9;
+ }
+}
+
+static int SBRun(ogg_uint32_t value, int *token){
+
+  /* Coding scheme:
+        Codeword              RunLength
+      0                       1
+      10x                     2-3
+      110x                    4-5
+      1110xx                  6-9
+      11110xxx                10-17
+      111110xxxx              18-33
+      111111xxxxxxxxxxxx      34-4129 */
+
+  if ( value == 1 ){
+    *token = 0;
+    return 1;
+  } else if ( value <= 3 ) {
+    *token = 0x0004 + (value - 2);
+    return 3;
+  } else if ( value <= 5 ) {
+    *token = 0x000C + (value - 4);
+    return 4;
+  } else if ( value <= 9 ) {
+    *token = 0x0038 + (value - 6);
+    return 6;
+  } else if ( value <= 17 ) {
+    *token = 0x00F0 + (value - 10);
+    return 8;
+  } else if ( value <= 33 ) {
+    *token = 0x03E0 + (value - 18);
+    return 10;
+  } else {
+    *token = 0x3F000 + (value - 34);
+    return 18;
+  }
+}
+
+static int SBRunCost(ogg_uint32_t value){
+
+  if ( value == 0 ){
+    return 0;
+  } else if ( value == 1 ){
+    return 1;
+  } else if ( value <= 3 ) {
+    return 3;
+  } else if ( value <= 5 ) {
+    return 4;
+  } else if ( value <= 9 ) {
+    return 6;
+  } else if ( value <= 17 ) {
+    return 8;
+  } else if ( value <= 33 ) {
+    return 10;
+  } else {
+    return 18;
+  }
+}
+
+void fr_skipblock(CP_INSTANCE *cpi, fr_state_t *fr){
+  if(fr->sb_coded){
+    if(!fr->sb_partial){
+
+      /* superblock was previously fully coded */
+
+      if(fr->b_last==-1){
+	/* first run of the frame */
+	if(cpi){
+	  cpi->fr_block[cpi->fr_block_count]=1;
+	  cpi->fr_block_bits[cpi->fr_block_count++]=1;
+	}
+	fr->cost++;
+	fr->b_last = 1;
+      }
+
+      if(fr->b_last==1){
+	/* in-progress run also a coded run */
+	fr->b_count += fr->b_pend;
+      }else{
+	/* in-progress run an uncoded run; flush */
+	if(cpi){
+	  fr->cost +=
+	    cpi->fr_block_bits[cpi->fr_block_count] = 
+	    BRun(fr->b_count, cpi->fr_block+cpi->fr_block_count);
+	  cpi->fr_block_count++;
+	}else
+	  fr->cost += BRunCost(fr->b_count);
+	  
+	fr->b_count=fr->b_pend;
+	fr->b_last = 1;
+      }
+    }
+
+    /* add a skip block */
+    if(fr->b_last == 0){
+      fr->b_count++;
+    }else{
+      if(cpi){
+	fr->cost+=
+	  cpi->fr_block_bits[cpi->fr_block_count] = 
+	  BRun(fr->b_count, cpi->fr_block+cpi->fr_block_count);
+	cpi->fr_block_count++;
+      }else
+	fr->cost+=BRunCost(fr->b_count);
+      fr->b_count = 1;
+      fr->b_last = 0;
+    }
+  }
+   
+  fr->b_pend++;
+  fr->sb_partial=1;
+}
+
+void fr_codeblock(CP_INSTANCE *cpi, fr_state_t *fr){
+  if(fr->sb_partial){
+    if(!fr->sb_coded){
+
+      /* superblock was previously completely uncoded */
+
+      if(fr->b_last==-1){
+	/* first run of the frame */
+	if(cpi){
+	  cpi->fr_block[cpi->fr_block_count]=0;
+	  cpi->fr_block_bits[cpi->fr_block_count++]=1;
+	}
+	fr->cost++;
+	fr->b_last = 0;
+      }
+
+      if(fr->b_last==0){
+	/* in-progress run also an uncoded run */
+	fr->b_count += fr->b_pend;
+      }else{
+	/* in-progress run a coded run; flush */
+	if(cpi){
+	  fr->cost+=
+	    cpi->fr_block_bits[cpi->fr_block_count] = 
+	    BRun(fr->b_count, cpi->fr_block+cpi->fr_block_count);
+	  cpi->fr_block_count++;
+	}else
+	  fr->cost+=BRunCost(fr->b_count);
+	fr->b_count=fr->b_pend;
+	fr->b_last = 0;
+      }
+    }
+    
+    /* add a coded block */
+    if(fr->b_last == 1){
+      fr->b_count++;
+    }else{
+      if(cpi){
+	fr->cost+=
+	  cpi->fr_block_bits[cpi->fr_block_count] = 
+	  BRun(fr->b_count, cpi->fr_block+cpi->fr_block_count);
+	cpi->fr_block_count++;
+      }else
+	fr->cost+=BRunCost(fr->b_count);
+      fr->b_count = 1;
+      fr->b_last = 1;
+    }
+  }
+   
+  fr->b_pend++;
+  fr->sb_coded=1;
+}
+
+void fr_finishsb(CP_INSTANCE *cpi, fr_state_t *fr){
+  /* update partial state */
+  int partial = (fr->sb_partial & fr->sb_coded); 
+  if(fr->sb_partial_last == -1){
+    if(cpi){
+      cpi->fr_partial[cpi->fr_partial_count] = partial;
+      cpi->fr_partial_bits[cpi->fr_partial_count++] = 1;
+    }
+    fr->cost++;
+    fr->sb_partial_last = partial;
+  }
+
+  if(fr->sb_partial_break){
+    if(cpi){
+      cpi->fr_partial[cpi->fr_partial_count] = partial;
+      cpi->fr_partial_bits[cpi->fr_partial_count++] = 1;
+    }
+    fr->cost++;
+    fr->sb_partial_break=0;
+  }
+  if(fr->sb_partial_last == partial && fr->sb_partial_count < 4129){
+    fr->sb_partial_count++;
+  }else{
+    if(cpi){
+      fr->cost+=
+	cpi->fr_partial_bits[cpi->fr_partial_count] = 
+	SBRun( fr->sb_partial_count, cpi->fr_partial+cpi->fr_partial_count);
+      cpi->fr_partial_count++;
+    }else
+      fr->cost+=SBRunCost(fr->sb_partial_count);
+    if(fr->sb_partial_count >= 4129) fr->sb_partial_break = 1;
+    fr->sb_partial_count=1;
+  }
+  fr->sb_partial_last=partial;
+  
+  /* fully coded/uncoded state */
+  if(!fr->sb_partial || !fr->sb_coded){
+    
+    if(fr->sb_full_last == -1){
+      if(cpi){
+	cpi->fr_full[cpi->fr_full_count] = fr->sb_coded;
+	cpi->fr_full_bits[cpi->fr_full_count++] = 1;
+      }
+      fr->cost++;
+      fr->sb_full_last = fr->sb_coded;
+    }
+    if(fr->sb_full_break){
+      if(cpi){
+        cpi->fr_full[cpi->fr_full_count] = fr->sb_coded;
+        cpi->fr_full_bits[cpi->fr_full_count++] = 1;
+      }
+      fr->cost++;
+      fr->sb_full_break=0;
+    }
+    if(fr->sb_full_last == fr->sb_coded && fr->sb_full_count < 4129){
+      fr->sb_full_count++;
+    }else{
+      if(cpi){
+	fr->cost+=
+	  cpi->fr_full_bits[cpi->fr_full_count] = 
+	  SBRun( fr->sb_full_count, cpi->fr_full+cpi->fr_full_count);
+	cpi->fr_full_count++;
+      }else
+	fr->cost+= SBRunCost( fr->sb_full_count);
+      if(fr->sb_full_count >= 4129) fr->sb_full_break = 1;
+      fr->sb_full_count=1;
+    }
+    fr->sb_full_last=fr->sb_coded;
+
+  }
+
+  fr->b_pend=0;
+  fr->sb_partial=0;
+  fr->sb_coded=0;
+}
+
+static void fr_flush(CP_INSTANCE *cpi, fr_state_t *fr){
+  /* flush any pending partial run */
+  if(fr->sb_partial_break){
+    if(cpi){
+      cpi->fr_partial[cpi->fr_partial_count] = fr->sb_partial_last;
+      cpi->fr_partial_bits[cpi->fr_partial_count++] = 1;
+    }
+    fr->cost++;
+  }
+  if(fr->sb_partial_count){
+    if(cpi){
+      fr->cost+=
+	cpi->fr_partial_bits[cpi->fr_partial_count] = 
+	SBRun( fr->sb_partial_count, cpi->fr_partial+cpi->fr_partial_count);
+      cpi->fr_partial_count++;
+    }else
+      fr->cost+=SBRunCost( fr->sb_partial_count );
+  }
+  
+  /* flush any pending full run */
+  if(fr->sb_full_break){
+    if(cpi){
+      cpi->fr_full[cpi->fr_full_count] = fr->sb_full_last;
+      cpi->fr_full_bits[cpi->fr_full_count++] = 1;
+    }
+    fr->cost++;
+  }
+  if(fr->sb_full_count){
+    if(cpi){
+      fr->cost+=
+	cpi->fr_full_bits[cpi->fr_full_count] = 
+	SBRun( fr->sb_full_count, cpi->fr_full+cpi->fr_full_count);
+      cpi->fr_full_count++;
+    }else
+      fr->cost+=SBRunCost(fr->sb_full_count);
+  }
+  
+  /* flush any pending block run */
+  if(fr->b_count){
+    if(cpi){
+      fr->cost+=
+	cpi->fr_block_bits[cpi->fr_block_count] = 
+	BRun(fr->b_count, cpi->fr_block+cpi->fr_block_count);
+      cpi->fr_block_count++;
+    }else
+      fr->cost+=BRunCost(fr->b_count);
+  }
+}
+
+void fr_write(CP_INSTANCE *cpi, fr_state_t *fr){
+  int i;
+
+  fr_flush(cpi,fr);
+
+  for(i=0;i<cpi->fr_partial_count;i++)
+    oggpackB_write( cpi->oggbuffer, cpi->fr_partial[i], cpi->fr_partial_bits[i]);      
+  for(i=0;i<cpi->fr_full_count;i++)
+    oggpackB_write( cpi->oggbuffer, cpi->fr_full[i], cpi->fr_full_bits[i]);      
+  for(i=0;i<cpi->fr_block_count;i++)
+    oggpackB_write( cpi->oggbuffer, cpi->fr_block[i], cpi->fr_block_bits[i]);      
+}
+
+int fr_cost1(fr_state_t *fr){
+  fr_state_t temp = *fr;
+  int cost;
+
+  fr_skipblock(NULL,&temp);
+  cost=temp.cost;
+  temp=*fr;
+  fr_codeblock(NULL,&temp);
+  return temp.cost - cost;
+}
+
+int fr_cost4(fr_state_t *pre, fr_state_t *post){
+  fr_state_t temp = *pre;
+  int cost;
+
+  fr_skipblock(NULL,&temp);
+  fr_skipblock(NULL,&temp);
+  fr_skipblock(NULL,&temp);
+  fr_skipblock(NULL,&temp);
+  //fr_finishsb(NULL,&temp);
+  cost=temp.cost;
+  temp=*post;
+  //fr_finishsb(NULL,&temp);
+  return temp.cost - cost;
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/frinit.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/frinit.c
new file mode 100644
index 0000000..41b6cd8
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/frinit.c
@@ -0,0 +1,417 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2008                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: frinit.c 16019 2009-05-20 01:36:41Z tterribe $
+
+ ********************************************************************/
+
+#include <stdlib.h>
+#include <string.h>
+#include "codec_internal.h"
+
+
+void ClearFrameInfo(CP_INSTANCE *cpi){
+
+  if(cpi->frame) _ogg_free(cpi->frame);
+  if(cpi->lastrecon ) _ogg_free(cpi->lastrecon );
+  if(cpi->golden) _ogg_free(cpi->golden);
+  if(cpi->recon) _ogg_free(cpi->recon);
+  if(cpi->dct_token_storage) _ogg_free(cpi->dct_token_storage);
+  if(cpi->dct_token_eb_storage) _ogg_free(cpi->dct_token_eb_storage);
+  if(cpi->frag_coded) _ogg_free(cpi->frag_coded);
+  if(cpi->frag_buffer_index) _ogg_free(cpi->frag_buffer_index);
+  if(cpi->frag_dc) _ogg_free(cpi->frag_dc);
+  if(cpi->frag_dc_tmp) _ogg_free(cpi->frag_dc_tmp);
+#if defined(OC_COLLECT_METRICS)
+  if(cpi->frag_mbi) _ogg_free(cpi->frag_mbi);
+  if(cpi->frag_sad) _ogg_free(cpi->frag_sad);
+  if(cpi->frag_ssd) _ogg_free(cpi->frag_ssd);
+  if(cpi->dct_token_frag_storage) _ogg_free(cpi->dct_token_frag_storage);
+  if(cpi->dct_eob_fi_storage) _ogg_free(cpi->dct_eob_fi_storage);
+#endif
+
+  if(cpi->macro) _ogg_free(cpi->macro);
+  if(cpi->super[0]) _ogg_free(cpi->super[0]);
+
+  if(cpi->fr_partial)_ogg_free(cpi->fr_partial);
+  if(cpi->fr_partial_bits)_ogg_free(cpi->fr_partial_bits);
+  if(cpi->fr_full)_ogg_free(cpi->fr_full);
+  if(cpi->fr_full_bits)_ogg_free(cpi->fr_full_bits);
+  if(cpi->fr_block)_ogg_free(cpi->fr_block);
+  if(cpi->fr_block_bits)_ogg_free(cpi->fr_block_bits);
+}
+
+/* A note to people reading and wondering why malloc returns aren't
+   checked:
+
+   lines like the following that implement a general strategy of
+   'check the return of malloc; a zero pointer means we're out of
+   memory!'...:
+
+   if(!cpi->extra_fragments) { EDeleteFragmentInfo(cpi); return FALSE; }
+
+   ...are not useful.  It's true that many platforms follow this
+   malloc behavior, but many do not.  The more modern malloc
+   strategy is only to allocate virtual pages, which are not mapped
+   until the memory on that page is touched.  At *that* point, if
+   the machine is out of heap, the page fails to be mapped and a
+   SEGV is generated.
+
+   That means that if we want to deal with out of memory conditions,
+   we *must* be prepared to process a SEGV.  If we implement the
+   SEGV handler, there's no reason to to check malloc return; it is
+   a waste of code. */
+
+void InitFrameInfo(CP_INSTANCE *cpi){
+
+  cpi->stride[0] = (cpi->info.width + STRIDE_EXTRA);
+  cpi->stride[1] = (cpi->info.width + STRIDE_EXTRA) / 2;
+  cpi->stride[2] = (cpi->info.width + STRIDE_EXTRA) / 2;
+
+  {
+    ogg_uint32_t ry_size = cpi->stride[0] * (cpi->info.height + STRIDE_EXTRA);
+    ogg_uint32_t ruv_size = ry_size / 4;
+
+    cpi->frame_size = ry_size + 2 * ruv_size;
+    cpi->offset[0] = (cpi->stride[0] * UMV_BORDER) + UMV_BORDER;
+    cpi->offset[1] = ry_size + cpi->stride[1] * (UMV_BORDER/2) + (UMV_BORDER/2);
+    cpi->offset[2] = ry_size + ruv_size + cpi->stride[2] * (UMV_BORDER/2) + (UMV_BORDER/2);
+  }
+
+  cpi->frag_h[0] = (cpi->info.width >> 3);
+  cpi->frag_v[0] = (cpi->info.height >> 3);
+  cpi->frag_n[0] = cpi->frag_h[0] * cpi->frag_v[0];
+  cpi->frag_h[1] = (cpi->info.width >> 4);
+  cpi->frag_v[1] = (cpi->info.height >> 4);
+  cpi->frag_n[1] = cpi->frag_h[1] * cpi->frag_v[1];
+  cpi->frag_h[2] = (cpi->info.width >> 4);
+  cpi->frag_v[2] = (cpi->info.height >> 4);
+  cpi->frag_n[2] = cpi->frag_h[2] * cpi->frag_v[2];
+  cpi->frag_total = cpi->frag_n[0] + cpi->frag_n[1] + cpi->frag_n[2];
+
+  cpi->macro_h = (cpi->frag_h[0] >> 1);
+  cpi->macro_v = (cpi->frag_v[0] >> 1);
+  cpi->macro_total = cpi->macro_h * cpi->macro_v;
+
+  cpi->super_h[0] = (cpi->info.width >> 5) + ((cpi->info.width & 0x1f) ? 1 : 0);
+  cpi->super_v[0] = (cpi->info.height >> 5) + ((cpi->info.height & 0x1f) ? 1 : 0);
+  cpi->super_n[0] = cpi->super_h[0] * cpi->super_v[0];
+  cpi->super_h[1] = (cpi->info.width >> 6) + ((cpi->info.width & 0x3f) ? 1 : 0);
+  cpi->super_v[1] = (cpi->info.height >> 6) + ((cpi->info.height & 0x3f) ? 1 : 0);
+  cpi->super_n[1] = cpi->super_h[1] * cpi->super_v[1];
+  cpi->super_h[2] = (cpi->info.width >> 6) + ((cpi->info.width & 0x3f) ? 1 : 0);
+  cpi->super_v[2] = (cpi->info.height >> 6) + ((cpi->info.height & 0x3f) ? 1 : 0);
+  cpi->super_n[2] = cpi->super_h[2] * cpi->super_v[2];
+  cpi->super_total = cpi->super_n[0] + cpi->super_n[1] + cpi->super_n[2];
+
+  /* +1; the last entry is the 'invalid' frag, which is always set to not coded as it doesn't really exist */
+  cpi->frag_coded = calloc(cpi->frag_total+1, sizeof(*cpi->frag_coded));
+  cpi->frag_buffer_index = calloc(cpi->frag_total, sizeof(*cpi->frag_buffer_index));
+  cpi->frag_dc = calloc(cpi->frag_total, sizeof(*cpi->frag_dc));
+  cpi->frag_dc_tmp = calloc(2*cpi->frag_h[0], sizeof(*cpi->frag_dc_tmp));
+
+  /* +1; the last entry is the 'invalid' mb, which contains only 'invalid' frags */
+  cpi->macro = calloc(cpi->macro_total+1, sizeof(*cpi->macro));
+
+  cpi->super[0] = calloc(cpi->super_total, sizeof(**cpi->super));
+  cpi->super[1] = cpi->super[0] + cpi->super_n[0];
+  cpi->super[2] = cpi->super[1] + cpi->super_n[1];
+
+  cpi->stack_offset = (cpi->frag_total + (cpi->frag_total+4094)/4095 + 1);
+  cpi->dct_token_storage = _ogg_malloc( cpi->stack_offset*BLOCK_SIZE*sizeof(*cpi->dct_token_storage));
+  cpi->dct_token_eb_storage = _ogg_malloc(cpi->stack_offset*BLOCK_SIZE*sizeof(*cpi->dct_token_eb_storage));
+
+  cpi->fr_partial = _ogg_calloc(cpi->super_total+1, sizeof(*cpi->fr_partial));
+  cpi->fr_partial_bits = _ogg_calloc(cpi->super_total+1, sizeof(*cpi->fr_partial_bits));
+  cpi->fr_full = _ogg_calloc(cpi->super_total+1, sizeof(*cpi->fr_full));
+  cpi->fr_full_bits = _ogg_calloc(cpi->super_total+1, sizeof(*cpi->fr_full_bits));
+  cpi->fr_block = _ogg_calloc(cpi->frag_total+1, sizeof(*cpi->fr_block));
+  cpi->fr_block_bits = _ogg_calloc(cpi->frag_total+1, sizeof(*cpi->fr_block_bits));
+
+#if defined(OC_COLLECT_METRICS)
+ {
+   cpi->frag_mbi = _ogg_calloc(cpi->frag_total+1, sizeof(*cpi->frag_mbi));
+   cpi->frag_sad = _ogg_calloc(cpi->frag_total+1, sizeof(*cpi->frag_sad));
+   cpi->frag_ssd = _ogg_calloc(cpi->frag_total+1, sizeof(*cpi->frag_ssd));
+   cpi->dct_token_frag_storage = _ogg_malloc(cpi->stack_offset*BLOCK_SIZE*sizeof(*cpi->dct_token_frag_storage));
+   cpi->dct_eob_fi_storage = _ogg_malloc(cpi->frag_total*BLOCK_SIZE*sizeof(*cpi->dct_eob_fi_storage));
+ }
+#endif
+
+  /* fill in superblock fragment pointers; hilbert order */
+  /* fill in macroblock superblock backpointers */
+  {
+    int row,col,frag,mb;
+    int fhilbertx[16] = {0,1,1,0,0,0,1,1,2,2,3,3,3,2,2,3};
+    int fhilberty[16] = {0,0,1,1,2,3,3,2,2,3,3,2,1,1,0,0};
+    int mhilbertx[4] = {0,0,1,1};
+    int mhilberty[4] = {0,1,1,0};
+    int offset = 0;
+    int plane;
+
+    for(plane=0;plane<3;plane++){
+
+      for(row=0;row<cpi->super_v[plane];row++){
+        for(col=0;col<cpi->super_h[plane];col++){
+          int superindex = row*cpi->super_h[plane] + col;
+          for(frag=0;frag<16;frag++){
+            /* translate to fragment index */
+            int frow = row*4 + fhilberty[frag];
+            int fcol = col*4 + fhilbertx[frag];
+            if(frow<cpi->frag_v[plane] && fcol<cpi->frag_h[plane]){
+              int fragindex = frow*cpi->frag_h[plane] + fcol + offset;
+              cpi->super[plane][superindex].f[frag] = fragindex;
+            }else
+              cpi->super[plane][superindex].f[frag] = cpi->frag_total; /* 'invalid' */
+          }
+        }
+      }
+      offset+=cpi->frag_n[plane];
+    }
+
+    /* Y */
+    for(row=0;row<cpi->super_v[0];row++){
+      for(col=0;col<cpi->super_h[0];col++){
+        int superindex = row*cpi->super_h[0] + col;
+        for(mb=0;mb<4;mb++){
+          /* translate to macroblock index */
+          int mrow = row*2 + mhilberty[mb];
+          int mcol = col*2 + mhilbertx[mb];
+          if(mrow<cpi->macro_v && mcol<cpi->macro_h){
+            int macroindex = mrow*cpi->macro_h + mcol;
+            cpi->super[0][superindex].m[mb] = macroindex;
+            cpi->macro[macroindex].ysb = superindex;
+          }else
+            cpi->super[0][superindex].m[mb] = cpi->macro_total;
+        }
+      }
+    }
+
+    /* U (assuming 4:2:0 for now) */
+    for(row=0;row<cpi->super_v[1];row++){
+      for(col=0;col<cpi->super_h[1];col++){
+        int superindex = row*cpi->super_h[1] + col;
+        for(mb=0;mb<16;mb++){
+          /* translate to macroblock index */
+          int mrow = row*4 + fhilberty[mb];
+          int mcol = col*4 + fhilbertx[mb];
+          if(mrow<cpi->macro_v && mcol<cpi->macro_h){
+            int macroindex = mrow*cpi->macro_h + mcol;
+            cpi->super[1][superindex].m[mb] = macroindex;
+            cpi->macro[macroindex].usb = superindex + cpi->super_n[0];
+          }else
+            cpi->super[1][superindex].m[mb] = cpi->macro_total;
+        }
+      }
+    }
+
+    /* V (assuming 4:2:0 for now) */
+    for(row=0;row<cpi->super_v[2];row++){
+      for(col=0;col<cpi->super_h[2];col++){
+        int superindex = row*cpi->super_h[2] + col;
+        for(mb=0;mb<16;mb++){
+          /* translate to macroblock index */
+          int mrow = row*4 + fhilberty[mb];
+          int mcol = col*4 + fhilbertx[mb];
+          if(mrow<cpi->macro_v && mcol<cpi->macro_h){
+            int macroindex = mrow*cpi->macro_h + mcol;
+            cpi->super[2][superindex].m[mb] = macroindex;
+            cpi->macro[macroindex].vsb = superindex + cpi->super_n[0] + cpi->super_n[1];
+          }else
+            cpi->super[2][superindex].m[mb] = cpi->macro_total;
+        }
+      }
+    }
+
+  }
+
+  /* fill in macroblock fragment pointers; raster (MV coding) order */
+  /* 4:2:0 only for now */
+  {
+    int row,col,frag;
+    int Hscanx[4][4] = { {0,1,1,0}, {1,0,0,1}, {0,0,1,1}, {0,0,1,1} };
+    int Hscany[4][4] = { {0,0,1,1}, {1,1,0,0}, {0,1,1,0}, {0,1,1,0} };
+
+    for(row=0;row<cpi->macro_v;row++){
+      int baserow = row*2;
+      for(col=0;col<cpi->macro_h;col++){
+        int basecol = col*2;
+        int macroindex = row*cpi->macro_h + col;
+        int hpos = (col&1) + (row&1)*2;
+
+        /* Y */
+        for(frag=0;frag<4;frag++){
+          int Hrow = baserow + Hscany[hpos][frag];
+          int Hcol = basecol + Hscanx[hpos][frag];
+          int Rrow = baserow + ((frag>>1)&1);
+          int Rcol = basecol + (frag&1);
+
+          cpi->macro[macroindex].Hyuv[0][frag] = cpi->frag_total; // default
+          cpi->macro[macroindex].Ryuv[0][frag] = cpi->frag_total; //default
+          if(Hrow<cpi->frag_v[0] && Hcol<cpi->frag_h[0]){
+            cpi->macro[macroindex].Hyuv[0][frag] = Hrow*cpi->frag_h[0] + Hcol;
+#if defined(OC_COLLECT_METRICS)
+            cpi->frag_mbi[Hrow*cpi->frag_h[0] + Hcol] = macroindex;
+#endif
+          }
+          if(Rrow<cpi->frag_v[0] && Rcol<cpi->frag_h[0])
+            cpi->macro[macroindex].Ryuv[0][frag] = Rrow*cpi->frag_h[0] + Rcol;
+        }
+
+        /* U */
+        cpi->macro[macroindex].Ryuv[1][0] = cpi->frag_total;
+        cpi->macro[macroindex].Ryuv[1][1] = cpi->frag_total;
+        cpi->macro[macroindex].Ryuv[1][2] = cpi->frag_total;
+        cpi->macro[macroindex].Ryuv[1][3] = cpi->frag_total;
+        cpi->macro[macroindex].Hyuv[1][0] = cpi->frag_total;
+        cpi->macro[macroindex].Hyuv[1][1] = cpi->frag_total;
+        cpi->macro[macroindex].Hyuv[1][2] = cpi->frag_total;
+        cpi->macro[macroindex].Hyuv[1][3] = cpi->frag_total;
+        if(row<cpi->frag_v[1] && col<cpi->frag_h[1]){
+          cpi->macro[macroindex].Hyuv[1][0] = cpi->frag_n[0] + macroindex;
+          cpi->macro[macroindex].Ryuv[1][0] = cpi->frag_n[0] + macroindex;
+#if defined(OC_COLLECT_METRICS)
+          cpi->frag_mbi[cpi->frag_n[0] + macroindex] = macroindex;
+#endif
+        }
+
+        /* V */
+        cpi->macro[macroindex].Ryuv[2][0] = cpi->frag_total;
+        cpi->macro[macroindex].Ryuv[2][1] = cpi->frag_total;
+        cpi->macro[macroindex].Ryuv[2][2] = cpi->frag_total;
+        cpi->macro[macroindex].Ryuv[2][3] = cpi->frag_total;
+        cpi->macro[macroindex].Hyuv[2][0] = cpi->frag_total;
+        cpi->macro[macroindex].Hyuv[2][1] = cpi->frag_total;
+        cpi->macro[macroindex].Hyuv[2][2] = cpi->frag_total;
+        cpi->macro[macroindex].Hyuv[2][3] = cpi->frag_total;
+        if(row<cpi->frag_v[2] && col<cpi->frag_h[2]){
+          cpi->macro[macroindex].Hyuv[2][0] = cpi->frag_n[0] + cpi->frag_n[1] + macroindex;
+          cpi->macro[macroindex].Ryuv[2][0] = cpi->frag_n[0] + cpi->frag_n[1] + macroindex;
+#if defined(OC_COLLECT_METRICS)
+          cpi->frag_mbi[cpi->frag_n[0] + cpi->frag_n[1] + macroindex] = macroindex;
+#endif
+        }
+      }
+    }
+  }
+
+  /* fill in macroblock neighbor information for MC analysis */
+  {
+    int row,col;
+
+    for(row=0;row<cpi->macro_v;row++){
+      for(col=0;col<cpi->macro_h;col++){
+        int macroindex = row*cpi->macro_h + col;
+        int count=0;
+
+        /* cneighbors are of four possible already-filled-in neighbors
+           from the eight-neighbor square for doing ME. The
+           macroblocks are scanned in Hilbert order and the corner
+           cases here are annoying, so we precompute. */
+        if(row&1){
+          if(col&1){
+            /* 2 */
+            cpi->macro[macroindex].cneighbors[count++]=macroindex-1;
+            cpi->macro[macroindex].cneighbors[count++]=macroindex-cpi->macro_h-1;
+          }else{
+            /* 1 */
+            if(col){
+              cpi->macro[macroindex].cneighbors[count++]=macroindex-1;
+              cpi->macro[macroindex].cneighbors[count++]=macroindex-cpi->macro_h-1;
+            }
+            cpi->macro[macroindex].cneighbors[count++]=macroindex-cpi->macro_h;
+          }
+        }else{
+          if(col&1){
+            /* 3; Could have up to six, fill in at most 4 */
+            if(row && col+1<cpi->macro_h)
+              cpi->macro[macroindex].cneighbors[count++]=macroindex-cpi->macro_h+1;
+            if(row)
+              cpi->macro[macroindex].cneighbors[count++]=macroindex-cpi->macro_h;
+            if(col && row)
+              cpi->macro[macroindex].cneighbors[count++]=macroindex-cpi->macro_h-1;
+            if(col)
+              cpi->macro[macroindex].cneighbors[count++]=macroindex-1;
+            if(col && row+1<cpi->macro_v && count<4)
+              cpi->macro[macroindex].cneighbors[count++]=macroindex+cpi->macro_h-1;
+            if(row+1<cpi->macro_v && count<4)
+              cpi->macro[macroindex].cneighbors[count++]=macroindex+cpi->macro_h;
+          }else{
+            /* 0; Could have up to five, fill in at most 4 */
+            if(row && col+1<cpi->macro_h)
+              cpi->macro[macroindex].cneighbors[count++]=macroindex-cpi->macro_h+1;
+            if(row)
+              cpi->macro[macroindex].cneighbors[count++]=macroindex-cpi->macro_h;
+            if(col && row)
+              cpi->macro[macroindex].cneighbors[count++]=macroindex-cpi->macro_h-1;
+            if(col)
+              cpi->macro[macroindex].cneighbors[count++]=macroindex-1;
+            if(col && row+1<cpi->macro_v && count<4)
+              cpi->macro[macroindex].cneighbors[count++]=macroindex+cpi->macro_h-1;
+          }
+        }
+        cpi->macro[macroindex].ncneighbors=count;
+
+        /* pneighbors are of the four possible direct neighbors (plus pattern), not the same as cneighbors */
+        count=0;
+        if(col)
+          cpi->macro[macroindex].pneighbors[count++]=macroindex-1;
+        if(row)
+          cpi->macro[macroindex].pneighbors[count++]=macroindex-cpi->macro_h;
+        if(col+1<cpi->macro_h)
+          cpi->macro[macroindex].pneighbors[count++]=macroindex+1;
+        if(row+1<cpi->macro_v)
+          cpi->macro[macroindex].pneighbors[count++]=macroindex+cpi->macro_h;
+        cpi->macro[macroindex].npneighbors=count;
+      }
+    }
+  }
+
+  /* fill in 'invalid' macroblock */
+  {
+    int p,f;
+    for(p=0;p<3;p++)
+      for(f=0;f<4;f++){
+        cpi->macro[cpi->macro_total].Ryuv[p][f] = cpi->frag_total;
+        cpi->macro[cpi->macro_total].Hyuv[p][f] = cpi->frag_total;
+      }
+    cpi->macro[cpi->macro_total].ncneighbors=0;
+    cpi->macro[cpi->macro_total].npneighbors=0;
+#if defined(OC_COLLECT_METRICS)
+    cpi->frag_mbi[cpi->frag_total] = cpi->macro_total;
+#endif
+  }
+
+  /* allocate frames */
+  cpi->frame = _ogg_calloc(cpi->frame_size,sizeof(*cpi->frame));
+  cpi->lastrecon = _ogg_calloc(cpi->frame_size,sizeof(*cpi->lastrecon));
+  cpi->golden = _ogg_calloc(cpi->frame_size,sizeof(*cpi->golden));
+  cpi->recon = _ogg_calloc(cpi->frame_size,sizeof(*cpi->recon));
+
+  /* Re-initialise the pixel index table. */
+  {
+    ogg_uint32_t plane,row,col;
+    ogg_uint32_t *bp = cpi->frag_buffer_index;
+
+    for(plane=0;plane<3;plane++){
+      ogg_uint32_t offset = cpi->offset[plane];
+      for(row=0;row<cpi->frag_v[plane];row++){
+        for(col=0;col<cpi->frag_h[plane];col++,bp++){
+          *bp = offset+col*8;
+        }
+        offset += cpi->stride[plane]*8;
+      }
+    }
+  }
+}
+
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/huffenc.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/huffenc.c
new file mode 100644
index 0000000..f1f553b
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/huffenc.c
@@ -0,0 +1,911 @@
+#include <stdlib.h>
+#include <string.h>
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+#include <vtkoggtheora/include/ogg/ogg.h>
+#include "huffenc.h"
+
+
+
+/*The default Huffman codes used for VP3.1.*/
+const th_huff_code TH_VP31_HUFF_CODES[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS]={
+  {
+    {0x002D, 6},{0x0026, 7},{0x0166, 9},{0x004E, 8},
+    {0x02CE,10},{0x059E,11},{0x027D,11},{0x0008, 5},
+    {0x04F9,12},{0x000F, 4},{0x000E, 4},{0x001B, 5},
+    {0x0006, 4},{0x0008, 4},{0x0005, 4},{0x001A, 5},
+    {0x0015, 5},{0x0007, 4},{0x000C, 4},{0x0001, 3},
+    {0x0000, 3},{0x0009, 4},{0x0017, 5},{0x0029, 6},
+    {0x0028, 6},{0x00B2, 8},{0x04F8,12},{0x059F,11},
+    {0x009E, 9},{0x013F,10},{0x0012, 6},{0x0058, 7}
+  },
+  {
+    {0x0010, 5},{0x0047, 7},{0x01FF, 9},{0x008C, 8},
+    {0x03FC,10},{0x046A,11},{0x0469,11},{0x0022, 6},
+    {0x11A1,13},{0x000E, 4},{0x000D, 4},{0x0004, 4},
+    {0x0005, 4},{0x0009, 4},{0x0006, 4},{0x001E, 5},
+    {0x0016, 5},{0x0007, 4},{0x000C, 4},{0x0001, 3},
+    {0x0000, 3},{0x000A, 4},{0x0017, 5},{0x007D, 7},
+    {0x007E, 7},{0x011B, 9},{0x08D1,12},{0x03FD,10},
+    {0x046B,11},{0x11A0,13},{0x007C, 7},{0x00FE, 8}
+  },
+  {
+    {0x0016, 5},{0x0020, 6},{0x0086, 8},{0x0087, 8},
+    {0x0367,10},{0x06CC,11},{0x06CB,11},{0x006E, 7},
+    {0x366D,14},{0x000F, 4},{0x000E, 4},{0x0004, 4},
+    {0x0005, 4},{0x000A, 4},{0x0006, 4},{0x001A, 5},
+    {0x0011, 5},{0x0007, 4},{0x000C, 4},{0x0001, 3},
+    {0x0000, 3},{0x0009, 4},{0x0017, 5},{0x006F, 7},
+    {0x006D, 7},{0x0364,10},{0x0D9A,12},{0x06CA,11},
+    {0x1B37,13},{0x366C,14},{0x0042, 7},{0x00D8, 8}
+  },
+  {
+    {0x0000, 4},{0x002D, 6},{0x00F7, 8},{0x0058, 7},
+    {0x0167, 9},{0x02CB,10},{0x02CA,10},{0x000E, 6},
+    {0x1661,13},{0x0003, 3},{0x0002, 3},{0x0008, 4},
+    {0x0009, 4},{0x000D, 4},{0x0002, 4},{0x001F, 5},
+    {0x0017, 5},{0x0001, 4},{0x000C, 4},{0x000E, 4},
+    {0x000A, 4},{0x0006, 5},{0x0078, 7},{0x000F, 6},
+    {0x007A, 7},{0x0164, 9},{0x0599,11},{0x02CD,10},
+    {0x0B31,12},{0x1660,13},{0x0079, 7},{0x00F6, 8}
+  },
+  {
+    {0x0003, 4},{0x003C, 6},{0x000F, 7},{0x007A, 7},
+    {0x001D, 8},{0x0020, 9},{0x0072,10},{0x0006, 6},
+    {0x0399,13},{0x0004, 3},{0x0005, 3},{0x0005, 4},
+    {0x0006, 4},{0x000E, 4},{0x0004, 4},{0x0000, 4},
+    {0x0019, 5},{0x0002, 4},{0x000D, 4},{0x0007, 4},
+    {0x001F, 5},{0x0030, 6},{0x0011, 8},{0x0031, 6},
+    {0x0005, 6},{0x0021, 9},{0x00E7,11},{0x0038, 9},
+    {0x01CD,12},{0x0398,13},{0x007B, 7},{0x0009, 7}
+  },
+  {
+    {0x0009, 4},{0x0002, 5},{0x0074, 7},{0x0007, 6},
+    {0x00EC, 8},{0x00D1, 9},{0x01A6,10},{0x0006, 6},
+    {0x0D21,13},{0x0005, 3},{0x0006, 3},{0x0008, 4},
+    {0x0007, 4},{0x000F, 4},{0x0004, 4},{0x0000, 4},
+    {0x001C, 5},{0x0002, 4},{0x0005, 4},{0x0003, 4},
+    {0x000C, 5},{0x0035, 7},{0x01A7,10},{0x001B, 6},
+    {0x0077, 7},{0x01A5,10},{0x0349,11},{0x00D0, 9},
+    {0x0691,12},{0x0D20,13},{0x0075, 7},{0x00ED, 8}
+  },
+  {
+    {0x000A, 4},{0x000C, 5},{0x0012, 6},{0x001B, 6},
+    {0x00B7, 8},{0x016C, 9},{0x0099, 9},{0x005A, 7},
+    {0x16D8,13},{0x0007, 3},{0x0006, 3},{0x0009, 4},
+    {0x0008, 4},{0x0000, 3},{0x0005, 4},{0x0017, 5},
+    {0x000E, 5},{0x0002, 4},{0x0003, 4},{0x000F, 5},
+    {0x001A, 6},{0x004D, 8},{0x2DB3,14},{0x002C, 6},
+    {0x0011, 6},{0x02DA,10},{0x05B7,11},{0x0098, 9},
+    {0x0B6D,12},{0x2DB2,14},{0x0010, 6},{0x0027, 7}
+  },
+  {
+    {0x000D, 4},{0x000F, 5},{0x001D, 6},{0x0008, 5},
+    {0x0051, 7},{0x0056, 8},{0x00AF, 9},{0x002A, 7},
+    {0x148A,13},{0x0007, 3},{0x0000, 2},{0x0008, 4},
+    {0x0009, 4},{0x000C, 4},{0x0006, 4},{0x0017, 5},
+    {0x000B, 5},{0x0016, 5},{0x0015, 5},{0x0009, 5},
+    {0x0050, 7},{0x00AE, 9},{0x2917,14},{0x001C, 6},
+    {0x0014, 6},{0x0290,10},{0x0523,11},{0x0149, 9},
+    {0x0A44,12},{0x2916,14},{0x0053, 7},{0x00A5, 8}
+  },
+  {
+    {0x0001, 4},{0x001D, 6},{0x00F5, 8},{0x00F4, 8},
+    {0x024D,10},{0x0499,11},{0x0498,11},{0x0001, 5},
+    {0x0021, 6},{0x0006, 3},{0x0005, 3},{0x0006, 4},
+    {0x0005, 4},{0x0002, 4},{0x0007, 5},{0x0025, 6},
+    {0x007B, 7},{0x001C, 6},{0x0020, 6},{0x000D, 6},
+    {0x0048, 7},{0x0092, 8},{0x0127, 9},{0x000E, 4},
+    {0x0004, 4},{0x0011, 5},{0x000C, 6},{0x003C, 6},
+    {0x000F, 5},{0x0000, 5},{0x001F, 5},{0x0013, 5}
+  },
+  {
+    {0x0005, 4},{0x003C, 6},{0x0040, 7},{0x000D, 7},
+    {0x0031, 9},{0x0061,10},{0x0060,10},{0x0002, 5},
+    {0x00F5, 8},{0x0006, 3},{0x0005, 3},{0x0007, 4},
+    {0x0006, 4},{0x0002, 4},{0x0009, 5},{0x0025, 6},
+    {0x0007, 6},{0x0021, 6},{0x0024, 6},{0x0010, 6},
+    {0x0041, 7},{0x00F4, 8},{0x0019, 8},{0x000E, 4},
+    {0x0003, 4},{0x0011, 5},{0x0011, 6},{0x003F, 6},
+    {0x003E, 6},{0x007B, 7},{0x0000, 4},{0x0013, 5}
+  },
+  {
+    {0x000A, 4},{0x0007, 5},{0x0001, 6},{0x0009, 6},
+    {0x0131, 9},{0x0261,10},{0x0260,10},{0x0015, 6},
+    {0x0001, 7},{0x0007, 3},{0x0006, 3},{0x0008, 4},
+    {0x0007, 4},{0x0006, 4},{0x0012, 5},{0x002F, 6},
+    {0x0014, 6},{0x0027, 6},{0x002D, 6},{0x0016, 6},
+    {0x004D, 7},{0x0099, 8},{0x0000, 7},{0x0004, 4},
+    {0x0001, 4},{0x0005, 5},{0x0017, 6},{0x002E, 6},
+    {0x002C, 6},{0x0008, 6},{0x0006, 5},{0x0001, 5}
+  },
+  {
+    {0x0000, 3},{0x000E, 5},{0x0017, 6},{0x002A, 6},
+    {0x0010, 7},{0x00F9,10},{0x00F8,10},{0x001E, 7},
+    {0x003F, 8},{0x0007, 3},{0x0006, 3},{0x0009, 4},
+    {0x0008, 4},{0x0006, 4},{0x000F, 5},{0x0005, 5},
+    {0x0016, 6},{0x0029, 6},{0x002B, 6},{0x0015, 6},
+    {0x0050, 7},{0x0011, 7},{0x007D, 9},{0x0004, 4},
+    {0x0017, 5},{0x0006, 5},{0x0014, 6},{0x002C, 6},
+    {0x002D, 6},{0x000E, 6},{0x0009, 6},{0x0051, 7}
+  },
+  {
+    {0x0002, 3},{0x0018, 5},{0x002F, 6},{0x000D, 5},
+    {0x0053, 7},{0x0295,10},{0x0294,10},{0x00A4, 8},
+    {0x007C, 8},{0x0000, 2},{0x0007, 3},{0x0009, 4},
+    {0x0008, 4},{0x001B, 5},{0x000C, 5},{0x0028, 6},
+    {0x006A, 7},{0x001E, 6},{0x001D, 6},{0x0069, 7},
+    {0x00D7, 8},{0x007D, 8},{0x014B, 9},{0x0019, 5},
+    {0x0016, 5},{0x002E, 6},{0x001C, 6},{0x002B, 6},
+    {0x002A, 6},{0x0068, 7},{0x003F, 7},{0x00D6, 8}
+  },
+  {
+    {0x0002, 3},{0x001B, 5},{0x000C, 5},{0x0018, 5},
+    {0x0029, 6},{0x007F, 8},{0x02F0,10},{0x0198, 9},
+    {0x0179, 9},{0x0000, 2},{0x0007, 3},{0x0009, 4},
+    {0x0008, 4},{0x001A, 5},{0x000D, 5},{0x002A, 6},
+    {0x0064, 7},{0x001E, 6},{0x0067, 7},{0x005F, 7},
+    {0x00CD, 8},{0x007E, 8},{0x02F1,10},{0x0016, 5},
+    {0x000E, 5},{0x002E, 6},{0x0065, 7},{0x002B, 6},
+    {0x0028, 6},{0x003E, 7},{0x00BD, 8},{0x0199, 9}
+  },
+  {
+    {0x0002, 3},{0x0007, 4},{0x0016, 5},{0x0006, 4},
+    {0x0036, 6},{0x005C, 7},{0x015D, 9},{0x015C, 9},
+    {0x02BF,10},{0x0000, 2},{0x0007, 3},{0x0009, 4},
+    {0x0008, 4},{0x0018, 5},{0x0034, 6},{0x002A, 6},
+    {0x005E, 7},{0x006A, 7},{0x0064, 7},{0x005D, 7},
+    {0x00CB, 8},{0x00AD, 8},{0x02BE,10},{0x0014, 5},
+    {0x0033, 6},{0x006E, 7},{0x005F, 7},{0x006F, 7},
+    {0x006B, 7},{0x00CA, 8},{0x00AC, 8},{0x015E, 9}
+  },
+  {
+    {0x000F, 4},{0x001D, 5},{0x0018, 5},{0x000B, 4},
+    {0x0019, 5},{0x0029, 6},{0x00D6, 8},{0x0551,11},
+    {0x0AA1,12},{0x0001, 2},{0x0000, 2},{0x0009, 4},
+    {0x0008, 4},{0x001B, 5},{0x0038, 6},{0x0028, 6},
+    {0x0057, 7},{0x006A, 7},{0x0068, 7},{0x0056, 7},
+    {0x00E5, 8},{0x0155, 9},{0x0AA0,12},{0x0073, 7},
+    {0x0069, 7},{0x00D7, 8},{0x00AB, 8},{0x00E4, 8},
+    {0x00A9, 8},{0x0151, 9},{0x0150, 9},{0x02A9,10}
+  },
+  {
+    {0x0008, 5},{0x0025, 7},{0x017A, 9},{0x02F7,10},
+    {0x0BDB,12},{0x17B4,13},{0x2F6B,14},{0x001D, 5},
+    {0x2F6A,14},{0x0008, 4},{0x0007, 4},{0x0001, 4},
+    {0x0002, 4},{0x000A, 4},{0x0006, 4},{0x0000, 4},
+    {0x001C, 5},{0x0009, 4},{0x000D, 4},{0x000F, 4},
+    {0x000C, 4},{0x0003, 4},{0x000A, 5},{0x0016, 5},
+    {0x0013, 6},{0x005D, 7},{0x0024, 7},{0x00BC, 8},
+    {0x005C, 7},{0x05EC,11},{0x000B, 5},{0x005F, 7}
+  },
+  {
+    {0x000F, 5},{0x0010, 6},{0x004B, 8},{0x00C6, 8},
+    {0x031D,10},{0x0C71,12},{0x0C70,12},{0x0001, 4},
+    {0x0C73,12},{0x0008, 4},{0x0009, 4},{0x0002, 4},
+    {0x0003, 4},{0x000B, 4},{0x0006, 4},{0x0000, 4},
+    {0x001C, 5},{0x0005, 4},{0x000D, 4},{0x000F, 4},
+    {0x000A, 4},{0x0019, 5},{0x0013, 6},{0x001D, 5},
+    {0x0030, 6},{0x0062, 7},{0x0024, 7},{0x004A, 8},
+    {0x018F, 9},{0x0C72,12},{0x000E, 5},{0x0011, 6}
+  },
+  {
+    {0x001B, 5},{0x0003, 6},{0x008D, 8},{0x0040, 7},
+    {0x0239,10},{0x0471,11},{0x08E0,12},{0x0003, 4},
+    {0x11C3,13},{0x000A, 4},{0x0009, 4},{0x0004, 4},
+    {0x0005, 4},{0x000E, 4},{0x0007, 4},{0x0001, 4},
+    {0x001E, 5},{0x0006, 4},{0x000C, 4},{0x000B, 4},
+    {0x0002, 4},{0x0000, 5},{0x0041, 7},{0x001F, 5},
+    {0x0022, 6},{0x0002, 6},{0x008F, 8},{0x008C, 8},
+    {0x011D, 9},{0x11C2,13},{0x001A, 5},{0x0021, 6}
+  },
+  {
+    {0x001F, 5},{0x0003, 6},{0x0003, 7},{0x0043, 7},
+    {0x000B, 9},{0x0015,10},{0x0051,12},{0x0003, 4},
+    {0x0050,12},{0x000D, 4},{0x000C, 4},{0x0004, 4},
+    {0x0006, 4},{0x000E, 4},{0x000A, 4},{0x0001, 4},
+    {0x001E, 5},{0x0005, 4},{0x0009, 4},{0x0007, 4},
+    {0x0011, 5},{0x0002, 6},{0x0004, 8},{0x0002, 4},
+    {0x002D, 6},{0x0020, 6},{0x0042, 7},{0x0001, 7},
+    {0x0000, 7},{0x0029,11},{0x0017, 5},{0x002C, 6}
+  },
+  {
+    {0x0003, 4},{0x001F, 6},{0x003A, 7},{0x005D, 7},
+    {0x0173, 9},{0x02E4,10},{0x172D,13},{0x0004, 4},
+    {0x172C,13},{0x000F, 4},{0x000E, 4},{0x0009, 4},
+    {0x0008, 4},{0x000C, 4},{0x000A, 4},{0x0001, 4},
+    {0x0016, 5},{0x0002, 4},{0x0005, 4},{0x001A, 5},
+    {0x002F, 6},{0x0038, 7},{0x05CA,11},{0x0006, 4},
+    {0x0037, 6},{0x001E, 6},{0x003B, 7},{0x0039, 7},
+    {0x00B8, 8},{0x0B97,12},{0x0000, 4},{0x0036, 6}
+  },
+  {
+    {0x0006, 4},{0x0037, 6},{0x005D, 7},{0x000C, 6},
+    {0x00B9, 8},{0x02E3,10},{0x05C4,11},{0x0004, 4},
+    {0x1715,13},{0x0000, 3},{0x000F, 4},{0x0008, 4},
+    {0x0007, 4},{0x000C, 4},{0x0009, 4},{0x001D, 5},
+    {0x0016, 5},{0x001C, 5},{0x001A, 5},{0x000B, 5},
+    {0x005E, 7},{0x0170, 9},{0x1714,13},{0x000A, 4},
+    {0x000A, 5},{0x0036, 6},{0x005F, 7},{0x001B, 7},
+    {0x001A, 7},{0x0B8B,12},{0x0002, 4},{0x0007, 5}
+  },
+  {
+    {0x000C, 4},{0x000B, 5},{0x0079, 7},{0x0022, 6},
+    {0x00F0, 8},{0x0119, 9},{0x0230,10},{0x001D, 5},
+    {0x08C4,12},{0x0001, 3},{0x0000, 3},{0x000A, 4},
+    {0x0009, 4},{0x000B, 4},{0x0007, 4},{0x001C, 5},
+    {0x003D, 6},{0x000D, 5},{0x0008, 5},{0x0015, 6},
+    {0x008D, 8},{0x118B,13},{0x118A,13},{0x000D, 4},
+    {0x0010, 5},{0x0009, 5},{0x0014, 6},{0x0047, 7},
+    {0x00F1, 8},{0x0463,11},{0x001F, 5},{0x000C, 5}
+  },
+  {
+    {0x0000, 3},{0x001A, 5},{0x0033, 6},{0x000C, 5},
+    {0x0046, 7},{0x01E3, 9},{0x03C5,10},{0x0017, 5},
+    {0x1E21,13},{0x0002, 3},{0x0001, 3},{0x0009, 4},
+    {0x000A, 4},{0x0007, 4},{0x001B, 5},{0x003D, 6},
+    {0x001B, 6},{0x0022, 6},{0x0079, 7},{0x00F0, 8},
+    {0x1E20,13},{0x1E23,13},{0x1E22,13},{0x000E, 4},
+    {0x0016, 5},{0x0018, 5},{0x0032, 6},{0x001A, 6},
+    {0x0047, 7},{0x0789,11},{0x001F, 5},{0x0010, 5}
+  },
+  {
+    {0x001D, 5},{0x0061, 7},{0x004E, 8},{0x009E, 9},
+    {0x027C,11},{0x09F5,13},{0x09F4,13},{0x0003, 4},
+    {0x0060, 7},{0x0000, 3},{0x000F, 4},{0x000B, 4},
+    {0x000A, 4},{0x0009, 4},{0x0005, 4},{0x000D, 5},
+    {0x0031, 6},{0x0008, 5},{0x0038, 6},{0x0012, 6},
+    {0x0026, 7},{0x013F,10},{0x04FB,12},{0x000D, 4},
+    {0x0002, 4},{0x000C, 5},{0x0039, 6},{0x001C, 6},
+    {0x000F, 5},{0x001D, 6},{0x0008, 4},{0x0019, 5}
+  },
+  {
+    {0x0007, 4},{0x0019, 6},{0x00AB, 8},{0x00AA, 8},
+    {0x0119,10},{0x0461,12},{0x0460,12},{0x001B, 5},
+    {0x0047, 8},{0x0001, 3},{0x0000, 3},{0x000C, 4},
+    {0x000B, 4},{0x0009, 4},{0x0005, 4},{0x000D, 5},
+    {0x0035, 6},{0x003D, 6},{0x003C, 6},{0x0018, 6},
+    {0x0022, 7},{0x008D, 9},{0x0231,11},{0x000E, 4},
+    {0x001F, 5},{0x0009, 5},{0x002B, 6},{0x0010, 6},
+    {0x0034, 6},{0x0054, 7},{0x0008, 4},{0x0014, 5}
+  },
+  {
+    {0x000C, 4},{0x0005, 5},{0x0008, 6},{0x005B, 7},
+    {0x004D, 9},{0x0131,11},{0x0261,12},{0x001A, 5},
+    {0x0012, 7},{0x0000, 3},{0x000F, 4},{0x000A, 4},
+    {0x0009, 4},{0x0006, 4},{0x001B, 5},{0x0006, 5},
+    {0x001C, 6},{0x002C, 6},{0x0015, 6},{0x005A, 7},
+    {0x0027, 8},{0x0099,10},{0x0260,12},{0x000E, 4},
+    {0x0004, 4},{0x000F, 5},{0x0007, 5},{0x001D, 6},
+    {0x000B, 5},{0x0014, 6},{0x0008, 4},{0x0017, 5}
+  },
+  {
+    {0x000F, 4},{0x0013, 5},{0x0075, 7},{0x0024, 6},
+    {0x0095, 8},{0x0251,10},{0x04A0,11},{0x0010, 5},
+    {0x00C8, 8},{0x0002, 3},{0x0001, 3},{0x0001, 4},
+    {0x0000, 4},{0x001A, 5},{0x0011, 5},{0x002C, 6},
+    {0x0065, 7},{0x0074, 7},{0x004B, 7},{0x00C9, 8},
+    {0x0129, 9},{0x0943,12},{0x0942,12},{0x0003, 3},
+    {0x000A, 4},{0x001C, 5},{0x0018, 5},{0x0033, 6},
+    {0x0017, 5},{0x002D, 6},{0x001B, 5},{0x003B, 6}
+  },
+  {
+    {0x0003, 3},{0x001A, 5},{0x002D, 6},{0x0038, 6},
+    {0x0028, 7},{0x0395,10},{0x0E51,12},{0x0037, 6},
+    {0x00E4, 8},{0x0001, 3},{0x0000, 3},{0x001F, 5},
+    {0x001E, 5},{0x0017, 5},{0x003A, 6},{0x0073, 7},
+    {0x002A, 7},{0x002B, 7},{0x0029, 7},{0x01CB, 9},
+    {0x0729,11},{0x1CA1,13},{0x1CA0,13},{0x0004, 3},
+    {0x000A, 4},{0x0004, 4},{0x0018, 5},{0x0036, 6},
+    {0x000B, 5},{0x002C, 6},{0x0019, 5},{0x003B, 6}
+  },
+  {
+    {0x0004, 3},{0x0004, 4},{0x003F, 6},{0x0017, 5},
+    {0x0075, 7},{0x01F5, 9},{0x07D1,11},{0x0017, 6},
+    {0x01F6, 9},{0x0001, 3},{0x0000, 3},{0x001B, 5},
+    {0x001A, 5},{0x000A, 5},{0x0032, 6},{0x0074, 7},
+    {0x00F8, 8},{0x00F9, 8},{0x01F7, 9},{0x03E9,10},
+    {0x0FA0,12},{0x1F43,13},{0x1F42,13},{0x0003, 3},
+    {0x000A, 4},{0x001E, 5},{0x001C, 5},{0x003B, 6},
+    {0x0018, 5},{0x0016, 6},{0x0016, 5},{0x0033, 6}
+  },
+  {
+    {0x0004, 3},{0x0007, 4},{0x0018, 5},{0x001E, 5},
+    {0x0036, 6},{0x0031, 7},{0x0177, 9},{0x0077, 7},
+    {0x0176, 9},{0x0001, 3},{0x0000, 3},{0x001A, 5},
+    {0x0019, 5},{0x003A, 6},{0x0019, 6},{0x005C, 7},
+    {0x00BA, 8},{0x0061, 8},{0x00C1, 9},{0x0180,10},
+    {0x0302,11},{0x0607,12},{0x0606,12},{0x0002, 3},
+    {0x000A, 4},{0x001F, 5},{0x001C, 5},{0x0037, 6},
+    {0x0016, 5},{0x0076, 7},{0x000D, 5},{0x002F, 6}
+  },
+  {
+    {0x0000, 3},{0x000A, 4},{0x001A, 5},{0x000C, 4},
+    {0x001D, 5},{0x0039, 6},{0x0078, 7},{0x005E, 7},
+    {0x0393,11},{0x0002, 3},{0x0001, 3},{0x0016, 5},
+    {0x000F, 5},{0x002E, 6},{0x005F, 7},{0x0073, 8},
+    {0x00E5, 9},{0x01C8,10},{0x0E4A,13},{0x1C97,14},
+    {0x1C96,14},{0x0E49,13},{0x0E48,13},{0x0004, 3},
+    {0x0006, 4},{0x001F, 5},{0x001B, 5},{0x001D, 6},
+    {0x0038, 6},{0x0038, 7},{0x003D, 6},{0x0079, 7}
+  },
+  {
+    {0x000B, 5},{0x002B, 7},{0x0054, 8},{0x01B7, 9},
+    {0x06D9,11},{0x0DB1,12},{0x0DB0,12},{0x0002, 4},
+    {0x00AB, 9},{0x0009, 4},{0x000A, 4},{0x0007, 4},
+    {0x0008, 4},{0x000F, 4},{0x000C, 4},{0x0003, 4},
+    {0x001D, 5},{0x0004, 4},{0x000B, 4},{0x0006, 4},
+    {0x001A, 5},{0x0003, 6},{0x00AA, 9},{0x0001, 4},
+    {0x0000, 5},{0x0014, 6},{0x006C, 7},{0x00DA, 8},
+    {0x0002, 6},{0x036D,10},{0x001C, 5},{0x0037, 6}
+  },
+  {
+    {0x001D, 5},{0x0004, 6},{0x00B6, 8},{0x006A, 8},
+    {0x05B9,11},{0x16E1,13},{0x16E0,13},{0x0007, 4},
+    {0x016F, 9},{0x000C, 4},{0x000D, 4},{0x0009, 4},
+    {0x0008, 4},{0x000F, 4},{0x000A, 4},{0x0003, 4},
+    {0x0017, 5},{0x0002, 4},{0x0004, 4},{0x001C, 5},
+    {0x002C, 6},{0x006B, 8},{0x0B71,12},{0x0005, 4},
+    {0x0003, 5},{0x001B, 6},{0x005A, 7},{0x0034, 7},
+    {0x0005, 6},{0x02DD,10},{0x0000, 4},{0x000C, 5}
+  },
+  {
+    {0x0003, 4},{0x007F, 7},{0x00A1, 8},{0x00A0, 8},
+    {0x020C,10},{0x0834,12},{0x106B,13},{0x0007, 4},
+    {0x0082, 8},{0x000E, 4},{0x000D, 4},{0x000B, 4},
+    {0x000C, 4},{0x0000, 3},{0x0009, 4},{0x0002, 4},
+    {0x0011, 5},{0x001E, 5},{0x0015, 5},{0x003E, 6},
+    {0x0040, 7},{0x041B,11},{0x106A,13},{0x0006, 4},
+    {0x000A, 5},{0x0029, 6},{0x007E, 7},{0x0051, 7},
+    {0x0021, 6},{0x0107, 9},{0x0004, 4},{0x000B, 5}
+  },
+  {
+    {0x0007, 4},{0x001B, 6},{0x00F6, 8},{0x00E9, 8},
+    {0x03A1,10},{0x0740,11},{0x0E82,12},{0x001F, 5},
+    {0x01EF, 9},{0x0001, 3},{0x0002, 3},{0x000B, 4},
+    {0x000C, 4},{0x000D, 4},{0x0008, 4},{0x001C, 5},
+    {0x0003, 5},{0x0012, 5},{0x0002, 5},{0x0075, 7},
+    {0x01D1, 9},{0x1D07,13},{0x1D06,13},{0x000A, 4},
+    {0x0013, 5},{0x003B, 6},{0x001A, 6},{0x007A, 7},
+    {0x003C, 6},{0x01EE, 9},{0x0000, 4},{0x000C, 5}
+  },
+  {
+    {0x000D, 4},{0x003D, 6},{0x0042, 7},{0x0037, 7},
+    {0x00D9, 9},{0x0362,11},{0x06C6,12},{0x001F, 5},
+    {0x0086, 8},{0x0001, 3},{0x0002, 3},{0x000C, 4},
+    {0x000B, 4},{0x000A, 4},{0x0001, 4},{0x000F, 5},
+    {0x0025, 6},{0x003C, 6},{0x001A, 6},{0x0087, 8},
+    {0x01B0,10},{0x0D8F,13},{0x0D8E,13},{0x000E, 4},
+    {0x0013, 5},{0x000C, 5},{0x0024, 6},{0x0020, 6},
+    {0x0011, 5},{0x006D, 8},{0x0000, 4},{0x000E, 5}
+  },
+  {
+    {0x0000, 3},{0x0012, 5},{0x0076, 7},{0x0077, 7},
+    {0x014D, 9},{0x0533,11},{0x14C9,13},{0x0013, 5},
+    {0x00A5, 8},{0x0002, 3},{0x0003, 3},{0x000B, 4},
+    {0x000C, 4},{0x0008, 4},{0x001A, 5},{0x002B, 6},
+    {0x0075, 7},{0x0074, 7},{0x00A7, 8},{0x0298,10},
+    {0x14C8,13},{0x14CB,13},{0x14CA,13},{0x000F, 4},
+    {0x001C, 5},{0x0007, 5},{0x002A, 6},{0x0028, 6},
+    {0x001B, 5},{0x00A4, 8},{0x0002, 4},{0x0006, 5}
+  },
+  {
+    {0x0002, 3},{0x001A, 5},{0x002B, 6},{0x003A, 6},
+    {0x00ED, 8},{0x0283,10},{0x0A0A,12},{0x0004, 5},
+    {0x00A1, 8},{0x0004, 3},{0x0003, 3},{0x000B, 4},
+    {0x000C, 4},{0x001F, 5},{0x0006, 5},{0x0077, 7},
+    {0x00A3, 8},{0x00A2, 8},{0x0140, 9},{0x1417,13},
+    {0x1416,13},{0x0A09,12},{0x0A08,12},{0x0000, 3},
+    {0x001E, 5},{0x0007, 5},{0x002A, 6},{0x0029, 6},
+    {0x001C, 5},{0x00EC, 8},{0x001B, 5},{0x0005, 5}
+  },
+  {
+    {0x0002, 3},{0x0002, 4},{0x0018, 5},{0x001D, 5},
+    {0x0035, 6},{0x00E4, 8},{0x01CF,11},{0x001D, 7},
+    {0x0072, 9},{0x0004, 3},{0x0005, 3},{0x0006, 4},
+    {0x0007, 4},{0x0006, 5},{0x0073, 7},{0x0038, 8},
+    {0x01CE,11},{0x039B,12},{0x0398,12},{0x0733,13},
+    {0x0732,13},{0x0735,13},{0x0734,13},{0x0000, 3},
+    {0x001F, 5},{0x001B, 5},{0x0034, 6},{0x000F, 6},
+    {0x001E, 5},{0x00E5, 8},{0x0019, 5},{0x0038, 6}
+  },
+  {
+    {0x0016, 5},{0x0050, 7},{0x0172, 9},{0x02E7,10},
+    {0x1732,13},{0x2E67,14},{0x2E66,14},{0x0006, 4},
+    {0x0051, 7},{0x0001, 3},{0x0000, 3},{0x000D, 4},
+    {0x000C, 4},{0x0009, 4},{0x001C, 5},{0x0009, 5},
+    {0x001C, 6},{0x001D, 6},{0x005D, 7},{0x00B8, 8},
+    {0x05CD,11},{0x1731,13},{0x1730,13},{0x000F, 4},
+    {0x0005, 4},{0x000F, 5},{0x0008, 5},{0x0029, 6},
+    {0x001D, 5},{0x002F, 6},{0x0008, 4},{0x0015, 5}
+  },
+  {
+    {0x0009, 4},{0x0021, 6},{0x0040, 7},{0x00AD, 8},
+    {0x02B0,10},{0x1589,13},{0x1588,13},{0x001C, 5},
+    {0x005F, 7},{0x0000, 3},{0x000F, 4},{0x000D, 4},
+    {0x000C, 4},{0x0006, 4},{0x0011, 5},{0x002A, 6},
+    {0x0057, 7},{0x005E, 7},{0x0041, 7},{0x0159, 9},
+    {0x0563,11},{0x158B,13},{0x158A,13},{0x0001, 3},
+    {0x0005, 4},{0x0014, 5},{0x003B, 6},{0x002E, 6},
+    {0x0004, 4},{0x003A, 6},{0x0007, 4},{0x0016, 5}
+  },
+  {
+    {0x000E, 4},{0x0007, 5},{0x0046, 7},{0x0045, 7},
+    {0x0064, 9},{0x032A,12},{0x0657,13},{0x0018, 5},
+    {0x000D, 6},{0x0000, 3},{0x000F, 4},{0x000A, 4},
+    {0x000B, 4},{0x001A, 5},{0x0036, 6},{0x0047, 7},
+    {0x0044, 7},{0x0018, 7},{0x0033, 8},{0x00CB,10},
+    {0x0656,13},{0x0329,12},{0x0328,12},{0x0002, 3},
+    {0x0006, 4},{0x0019, 5},{0x000E, 5},{0x0037, 6},
+    {0x0009, 4},{0x000F, 5},{0x0002, 4},{0x0010, 5}
+  },
+  {
+    {0x0003, 3},{0x0018, 5},{0x0023, 6},{0x0077, 7},
+    {0x0194, 9},{0x1956,13},{0x32AF,14},{0x003A, 6},
+    {0x0076, 7},{0x0002, 3},{0x0001, 3},{0x001F, 5},
+    {0x001E, 5},{0x0014, 5},{0x0022, 6},{0x0064, 7},
+    {0x0197, 9},{0x0196, 9},{0x032B,10},{0x0654,11},
+    {0x32AE,14},{0x1955,13},{0x1954,13},{0x0000, 3},
+    {0x0009, 4},{0x001C, 5},{0x0015, 5},{0x0010, 5},
+    {0x000D, 4},{0x0017, 5},{0x0016, 5},{0x0033, 6}
+  },
+  {
+    {0x0005, 3},{0x0006, 4},{0x003E, 6},{0x0010, 5},
+    {0x0048, 7},{0x093F,12},{0x24FA,14},{0x0032, 6},
+    {0x0067, 7},{0x0002, 3},{0x0001, 3},{0x001B, 5},
+    {0x001E, 5},{0x0034, 6},{0x0066, 7},{0x0092, 8},
+    {0x0126, 9},{0x024E,10},{0x049E,11},{0x49F7,15},
+    {0x49F6,15},{0x24F9,14},{0x24F8,14},{0x0000, 3},
+    {0x0007, 4},{0x0018, 5},{0x0011, 5},{0x003F, 6},
+    {0x000E, 4},{0x0013, 5},{0x0035, 6},{0x0025, 6}
+  },
+  {
+    {0x0005, 3},{0x0008, 4},{0x0012, 5},{0x001C, 5},
+    {0x001C, 6},{0x00EA, 9},{0x1D75,14},{0x001E, 6},
+    {0x0066, 7},{0x0001, 3},{0x0002, 3},{0x001B, 5},
+    {0x001A, 5},{0x001F, 6},{0x003B, 7},{0x0074, 8},
+    {0x01D6,10},{0x03AF,11},{0x1D74,14},{0x1D77,14},
+    {0x1D76,14},{0x0EB9,13},{0x0EB8,13},{0x000F, 4},
+    {0x0006, 4},{0x0013, 5},{0x003B, 6},{0x003A, 6},
+    {0x0000, 3},{0x0018, 5},{0x0032, 6},{0x0067, 7}
+  },
+  {
+    {0x0004, 3},{0x000A, 4},{0x001B, 5},{0x000C, 4},
+    {0x000D, 5},{0x00E6, 8},{0x0684,11},{0x0072, 7},
+    {0x00E7, 8},{0x0002, 3},{0x0001, 3},{0x0017, 5},
+    {0x0016, 5},{0x0018, 6},{0x00D1, 8},{0x01A0, 9},
+    {0x0686,11},{0x0D0F,12},{0x0D0A,12},{0x1A17,13},
+    {0x1A16,13},{0x1A1D,13},{0x1A1C,13},{0x000F, 4},
+    {0x001D, 5},{0x000E, 5},{0x0035, 6},{0x0038, 6},
+    {0x0000, 3},{0x000F, 5},{0x0019, 6},{0x0069, 7}
+  },
+  {
+    {0x0003, 3},{0x000C, 4},{0x001B, 5},{0x0000, 3},
+    {0x0003, 4},{0x002E, 6},{0x0051, 9},{0x00BC, 8},
+    {0x0053, 9},{0x0004, 3},{0x0002, 3},{0x0016, 5},
+    {0x0015, 5},{0x0015, 7},{0x0050, 9},{0x00A4,10},
+    {0x0294,12},{0x052B,13},{0x052A,13},{0x052D,13},
+    {0x052C,13},{0x052F,13},{0x052E,13},{0x000E, 4},
+    {0x001A, 5},{0x0004, 5},{0x0028, 6},{0x0029, 6},
+    {0x000F, 4},{0x000B, 6},{0x005F, 7},{0x00BD, 8}
+  },
+  {
+    {0x0003, 4},{0x0009, 6},{0x00D0, 8},{0x01A3, 9},
+    {0x0344,10},{0x0D14,12},{0x1A2B,13},{0x0004, 4},
+    {0x0015, 7},{0x0000, 3},{0x000F, 4},{0x000B, 4},
+    {0x000C, 4},{0x000E, 4},{0x0009, 4},{0x001B, 5},
+    {0x000A, 5},{0x0014, 5},{0x000D, 5},{0x002A, 6},
+    {0x0014, 7},{0x068B,11},{0x1A2A,13},{0x0008, 4},
+    {0x000B, 5},{0x002B, 6},{0x000B, 6},{0x0069, 7},
+    {0x0035, 6},{0x0008, 6},{0x0007, 4},{0x000C, 5}
+  },
+  {
+    {0x000A, 4},{0x003C, 6},{0x0032, 7},{0x0030, 7},
+    {0x00C5, 9},{0x0621,12},{0x0620,12},{0x001F, 5},
+    {0x0033, 7},{0x0001, 3},{0x0000, 3},{0x000E, 4},
+    {0x000D, 4},{0x000C, 4},{0x0004, 4},{0x000D, 5},
+    {0x0026, 6},{0x0027, 6},{0x0014, 6},{0x0063, 8},
+    {0x0189,10},{0x0623,12},{0x0622,12},{0x000B, 4},
+    {0x0012, 5},{0x003D, 6},{0x0022, 6},{0x0015, 6},
+    {0x000B, 5},{0x0023, 6},{0x0007, 4},{0x0010, 5}
+  },
+  {
+    {0x000F, 4},{0x000C, 5},{0x0043, 7},{0x0010, 6},
+    {0x0044, 8},{0x0114,10},{0x0455,12},{0x0018, 5},
+    {0x0023, 7},{0x0001, 3},{0x0000, 3},{0x000E, 4},
+    {0x000D, 4},{0x0009, 4},{0x0019, 5},{0x0009, 5},
+    {0x0017, 6},{0x0016, 6},{0x0042, 7},{0x008B, 9},
+    {0x0454,12},{0x0457,12},{0x0456,12},{0x000B, 4},
+    {0x0015, 5},{0x000A, 5},{0x0029, 6},{0x0020, 6},
+    {0x000D, 5},{0x0028, 6},{0x0007, 4},{0x0011, 5}
+  },
+  {
+    {0x0001, 3},{0x001A, 5},{0x0029, 6},{0x002A, 6},
+    {0x00A0, 8},{0x0285,10},{0x1425,13},{0x0002, 5},
+    {0x0000, 7},{0x0002, 3},{0x0003, 3},{0x000C, 4},
+    {0x000B, 4},{0x0008, 4},{0x0012, 5},{0x0001, 6},
+    {0x0051, 7},{0x0001, 7},{0x0143, 9},{0x0508,11},
+    {0x1424,13},{0x1427,13},{0x1426,13},{0x000F, 4},
+    {0x001C, 5},{0x0003, 5},{0x0037, 6},{0x002B, 6},
+    {0x0013, 5},{0x0036, 6},{0x001D, 5},{0x0001, 5}
+  },
+  {
+    {0x0004, 3},{0x001F, 5},{0x003D, 6},{0x0006, 5},
+    {0x0016, 7},{0x0053, 9},{0x014A,11},{0x0034, 6},
+    {0x002A, 8},{0x0002, 3},{0x0003, 3},{0x000B, 4},
+    {0x000C, 4},{0x001C, 5},{0x0037, 6},{0x0017, 7},
+    {0x002B, 8},{0x0028, 8},{0x00A4,10},{0x052D,13},
+    {0x052C,13},{0x052F,13},{0x052E,13},{0x0000, 3},
+    {0x001D, 5},{0x0007, 5},{0x0004, 5},{0x0035, 6},
+    {0x0014, 5},{0x0036, 6},{0x0015, 5},{0x003C, 6}
+  },
+  {
+    {0x0004, 3},{0x000A, 4},{0x0007, 5},{0x001D, 5},
+    {0x0009, 6},{0x01F3, 9},{0x07C7,11},{0x0008, 6},
+    {0x01F0, 9},{0x0003, 3},{0x0002, 3},{0x000D, 4},
+    {0x000C, 4},{0x0017, 5},{0x007D, 7},{0x01F2, 9},
+    {0x07C6,11},{0x07C5,11},{0x1F12,13},{0x3E27,14},
+    {0x3E26,14},{0x1F11,13},{0x1F10,13},{0x0000, 3},
+    {0x001E, 5},{0x0006, 5},{0x0039, 6},{0x0038, 6},
+    {0x003F, 6},{0x002C, 6},{0x0005, 5},{0x002D, 6}
+  },
+  {
+    {0x0002, 3},{0x0007, 4},{0x0018, 5},{0x0003, 4},
+    {0x0005, 5},{0x0035, 7},{0x004F, 9},{0x0012, 7},
+    {0x04E5,13},{0x0005, 3},{0x0004, 3},{0x000D, 4},
+    {0x000E, 4},{0x0033, 6},{0x0026, 8},{0x009D,10},
+    {0x04E4,13},{0x04E7,13},{0x04E6,13},{0x04E1,13},
+    {0x04E0,13},{0x04E3,13},{0x04E2,13},{0x0000, 3},
+    {0x001F, 5},{0x000C, 5},{0x003D, 6},{0x003C, 6},
+    {0x0032, 6},{0x0034, 7},{0x001B, 6},{0x0008, 6}
+  },
+  {
+    {0x0000, 3},{0x0004, 4},{0x001C, 5},{0x000F, 4},
+    {0x0002, 4},{0x0007, 5},{0x0075, 7},{0x00E8, 8},
+    {0x1D2A,13},{0x0005, 3},{0x0004, 3},{0x000D, 4},
+    {0x000C, 4},{0x0077, 7},{0x0E96,12},{0x3A57,14},
+    {0x3A56,14},{0x3A5D,14},{0x3A5C,14},{0x3A5F,14},
+    {0x3A5E,14},{0x1D29,13},{0x1D28,13},{0x0003, 3},
+    {0x0006, 5},{0x000A, 5},{0x002C, 7},{0x0017, 6},
+    {0x0076, 7},{0x01D3, 9},{0x03A4,10},{0x002D, 7}
+  },
+  {
+    {0x000A, 4},{0x0024, 6},{0x00BF, 8},{0x0085, 8},
+    {0x0211,10},{0x0842,12},{0x1087,13},{0x0018, 5},
+    {0x0020, 6},{0x0001, 3},{0x0002, 3},{0x000E, 4},
+    {0x000D, 4},{0x0007, 4},{0x0013, 5},{0x0025, 6},
+    {0x005E, 7},{0x0043, 7},{0x00BE, 8},{0x0109, 9},
+    {0x1086,13},{0x0841,12},{0x0840,12},{0x000F, 4},
+    {0x0001, 4},{0x0011, 5},{0x0000, 5},{0x002E, 6},
+    {0x0019, 5},{0x0001, 5},{0x0006, 4},{0x0016, 5}
+  },
+  {
+    {0x0002, 3},{0x000F, 5},{0x006F, 7},{0x0061, 7},
+    {0x0374,10},{0x1BA8,13},{0x3753,14},{0x0012, 5},
+    {0x0036, 6},{0x0000, 3},{0x0001, 3},{0x000A, 4},
+    {0x000B, 4},{0x001A, 5},{0x0031, 6},{0x0060, 7},
+    {0x00DC, 8},{0x01BB, 9},{0x06EB,11},{0x1BAB,13},
+    {0x3752,14},{0x3755,14},{0x3754,14},{0x000E, 4},
+    {0x0006, 4},{0x0013, 5},{0x000E, 5},{0x003E, 6},
+    {0x0008, 4},{0x001E, 5},{0x0019, 5},{0x003F, 6}
+  },
+  {
+    {0x0003, 3},{0x001C, 5},{0x0025, 6},{0x0024, 6},
+    {0x01DA, 9},{0x1DBD,13},{0x3B7C,14},{0x003C, 6},
+    {0x003D, 6},{0x0000, 3},{0x0001, 3},{0x000B, 4},
+    {0x000A, 4},{0x000B, 5},{0x0077, 7},{0x00EC, 8},
+    {0x03B6,10},{0x076E,11},{0x1DBF,13},{0x76FB,15},
+    {0x76FA,15},{0x3B79,14},{0x3B78,14},{0x000D, 4},
+    {0x001F, 5},{0x0013, 5},{0x000A, 5},{0x0008, 5},
+    {0x000C, 4},{0x0008, 4},{0x0009, 5},{0x003A, 6}
+  },
+  {
+    {0x0005, 3},{0x0003, 4},{0x0004, 5},{0x0010, 5},
+    {0x008F, 8},{0x0475,11},{0x11D1,13},{0x0079, 7},
+    {0x0027, 6},{0x0002, 3},{0x0003, 3},{0x0001, 4},
+    {0x0000, 4},{0x0026, 6},{0x0046, 7},{0x011C, 9},
+    {0x0477,11},{0x08ED,12},{0x11D0,13},{0x11D3,13},
+    {0x11D2,13},{0x11D9,13},{0x11D8,13},{0x000D, 4},
+    {0x001F, 5},{0x0012, 5},{0x0005, 5},{0x003D, 6},
+    {0x000C, 4},{0x000E, 4},{0x0022, 6},{0x0078, 7}
+  },
+  {
+    {0x0005, 3},{0x000C, 4},{0x001B, 5},{0x0000, 4},
+    {0x0006, 6},{0x03E2,10},{0x3E3D,14},{0x000F, 7},
+    {0x0034, 6},{0x0003, 3},{0x0002, 3},{0x001E, 5},
+    {0x001D, 5},{0x007D, 7},{0x01F0, 9},{0x07C6,11},
+    {0x3E3C,14},{0x3E3F,14},{0x3E3E,14},{0x3E39,14},
+    {0x3E38,14},{0x3E3B,14},{0x3E3A,14},{0x0008, 4},
+    {0x001C, 5},{0x0002, 5},{0x003F, 6},{0x0035, 6},
+    {0x0009, 4},{0x0001, 3},{0x000E, 7},{0x00F9, 8}
+  },
+  {
+    {0x0004, 3},{0x000B, 4},{0x0001, 4},{0x000A, 4},
+    {0x001E, 6},{0x00E0, 9},{0x0E1E,13},{0x0071, 8},
+    {0x0039, 7},{0x0007, 3},{0x0006, 3},{0x000D, 5},
+    {0x000C, 5},{0x0020, 7},{0x01C2,10},{0x1C3F,14},
+    {0x1C3E,14},{0x0E19,13},{0x0E18,13},{0x0E1B,13},
+    {0x0E1A,13},{0x0E1D,13},{0x0E1C,13},{0x0000, 4},
+    {0x0009, 5},{0x001D, 6},{0x001F, 6},{0x0011, 6},
+    {0x0005, 4},{0x0001, 3},{0x0043, 8},{0x0042, 8}
+  },
+  {
+    {0x0004, 3},{0x000D, 4},{0x0007, 4},{0x0002, 3},
+    {0x0014, 5},{0x016C, 9},{0x16D1,13},{0x02DF,10},
+    {0x016E, 9},{0x0000, 2},{0x0007, 3},{0x002C, 6},
+    {0x002B, 6},{0x02DE,10},{0x16D0,13},{0x16D3,13},
+    {0x16D2,13},{0x2DB5,14},{0x2DB4,14},{0x2DB7,14},
+    {0x2DB6,14},{0x16D9,13},{0x16D8,13},{0x000C, 5},
+    {0x002A, 6},{0x005A, 7},{0x001B, 6},{0x001A, 6},
+    {0x0017, 5},{0x000C, 4},{0x05B7,11},{0x05B5,11}
+  },
+  {
+    {0x0002, 2},{0x000F, 4},{0x001C, 5},{0x000C, 4},
+    {0x003B, 6},{0x01AC, 9},{0x1AD8,13},{0x35B3,14},
+    {0x35B2,14},{0x0001, 2},{0x0000, 2},{0x0069, 7},
+    {0x0068, 7},{0x35BD,14},{0x35BC,14},{0x35BF,14},
+    {0x35BE,14},{0x35B9,14},{0x35B8,14},{0x35BB,14},
+    {0x35BA,14},{0x35B5,14},{0x35B4,14},{0x01A9, 9},
+    {0x01A8, 9},{0x035A,10},{0x00D7, 8},{0x00D5, 8},
+    {0x003A, 6},{0x001B, 5},{0x35B7,14},{0x35B6,14}
+  },
+  {
+    {0x0000, 3},{0x0010, 5},{0x0072, 7},{0x0071, 7},
+    {0x0154, 9},{0x0AAB,12},{0x0AA8,12},{0x0014, 5},
+    {0x0070, 7},{0x0002, 3},{0x0003, 3},{0x000C, 4},
+    {0x000B, 4},{0x0003, 4},{0x0011, 5},{0x0073, 7},
+    {0x0054, 7},{0x00AB, 8},{0x02AB,10},{0x1553,13},
+    {0x1552,13},{0x1555,13},{0x1554,13},{0x000D, 4},
+    {0x001E, 5},{0x0012, 5},{0x003E, 6},{0x002B, 6},
+    {0x0002, 4},{0x003F, 6},{0x001D, 5},{0x0013, 5}
+  },
+  {
+    {0x0003, 3},{0x001F, 5},{0x0029, 6},{0x003D, 6},
+    {0x000C, 7},{0x0069,10},{0x0345,13},{0x0002, 5},
+    {0x0028, 6},{0x0002, 3},{0x0001, 3},{0x000E, 4},
+    {0x000C, 4},{0x0015, 5},{0x0007, 6},{0x001B, 8},
+    {0x006B,10},{0x006A,10},{0x0344,13},{0x0347,13},
+    {0x0346,13},{0x01A1,12},{0x01A0,12},{0x000B, 4},
+    {0x001A, 5},{0x0012, 5},{0x0000, 5},{0x003C, 6},
+    {0x0008, 4},{0x001B, 5},{0x0013, 5},{0x0001, 5}
+  },
+  {
+    {0x0004, 3},{0x0004, 4},{0x003F, 6},{0x0014, 5},
+    {0x0056, 7},{0x015C, 9},{0x15D5,13},{0x003C, 6},
+    {0x002A, 6},{0x0000, 3},{0x0001, 3},{0x000E, 4},
+    {0x000D, 4},{0x000C, 5},{0x00AF, 8},{0x02BB,10},
+    {0x15D4,13},{0x15D7,13},{0x15D6,13},{0x15D1,13},
+    {0x15D0,13},{0x15D3,13},{0x15D2,13},{0x000B, 4},
+    {0x0019, 5},{0x000D, 5},{0x003E, 6},{0x0031, 6},
+    {0x0007, 4},{0x0005, 4},{0x003D, 6},{0x0030, 6}
+  },
+  {
+    {0x0005, 3},{0x0008, 4},{0x001A, 5},{0x0000, 4},
+    {0x0036, 6},{0x0011, 8},{0x0106,12},{0x000A, 7},
+    {0x006E, 7},{0x0002, 3},{0x0003, 3},{0x0003, 4},
+    {0x0002, 4},{0x006F, 7},{0x0021, 9},{0x020F,13},
+    {0x020E,13},{0x0101,12},{0x0100,12},{0x0103,12},
+    {0x0102,12},{0x0105,12},{0x0104,12},{0x000C, 4},
+    {0x001E, 5},{0x0003, 5},{0x003E, 6},{0x003F, 6},
+    {0x0009, 4},{0x000E, 4},{0x000B, 7},{0x0009, 7}
+  },
+  {
+    {0x0002, 3},{0x000E, 4},{0x001E, 5},{0x000C, 4},
+    {0x001F, 5},{0x006E, 7},{0x00AD,10},{0x00AF,10},
+    {0x0014, 7},{0x0004, 3},{0x0003, 3},{0x001A, 5},
+    {0x0017, 5},{0x002A, 8},{0x0576,13},{0x0AEF,14},
+    {0x0AEE,14},{0x0571,13},{0x0570,13},{0x0573,13},
+    {0x0572,13},{0x0575,13},{0x0574,13},{0x0003, 4},
+    {0x0016, 5},{0x0004, 5},{0x0036, 6},{0x000B, 6},
+    {0x000A, 4},{0x0000, 3},{0x006F, 7},{0x00AC,10}
+  },
+  {
+    {0x0004, 3},{0x0005, 4},{0x0003, 3},{0x0001, 3},
+    {0x0004, 4},{0x002F, 6},{0x0526,11},{0x1495,13},
+    {0x00A6, 8},{0x0007, 3},{0x0006, 3},{0x002D, 6},
+    {0x002C, 6},{0x1494,13},{0x1497,13},{0x1496,13},
+    {0x1491,13},{0x1490,13},{0x1493,13},{0x1492,13},
+    {0x293D,14},{0x293C,14},{0x293F,14},{0x0000, 3},
+    {0x0028, 6},{0x00A5, 8},{0x0148, 9},{0x00A7, 8},
+    {0x002E, 6},{0x0015, 5},{0x0A4E,12},{0x293E,14}
+  },
+  {
+    {0x0004, 3},{0x0005, 4},{0x0003, 3},{0x0001, 3},
+    {0x0004, 4},{0x002F, 6},{0x0526,11},{0x1495,13},
+    {0x00A6, 8},{0x0007, 3},{0x0006, 3},{0x002D, 6},
+    {0x002C, 6},{0x1494,13},{0x1497,13},{0x1496,13},
+    {0x1491,13},{0x1490,13},{0x1493,13},{0x1492,13},
+    {0x293D,14},{0x293C,14},{0x293F,14},{0x0000, 3},
+    {0x0028, 6},{0x00A5, 8},{0x0148, 9},{0x00A7, 8},
+    {0x002E, 6},{0x0015, 5},{0x0A4E,12},{0x293E,14}
+  },
+  {
+    {0x0004, 3},{0x0005, 4},{0x0003, 3},{0x0001, 3},
+    {0x0004, 4},{0x002F, 6},{0x0526,11},{0x1495,13},
+    {0x00A6, 8},{0x0007, 3},{0x0006, 3},{0x002D, 6},
+    {0x002C, 6},{0x1494,13},{0x1497,13},{0x1496,13},
+    {0x1491,13},{0x1490,13},{0x1493,13},{0x1492,13},
+    {0x293D,14},{0x293C,14},{0x293F,14},{0x0000, 3},
+    {0x0028, 6},{0x00A5, 8},{0x0148, 9},{0x00A7, 8},
+    {0x002E, 6},{0x0015, 5},{0x0A4E,12},{0x293E,14}
+  },
+  {
+    {0x0003, 3},{0x0011, 5},{0x0020, 6},{0x0074, 7},
+    {0x010D, 9},{0x0863,12},{0x0860,12},{0x000A, 5},
+    {0x0075, 7},{0x0001, 3},{0x0000, 3},{0x000B, 4},
+    {0x000A, 4},{0x0018, 5},{0x0038, 6},{0x0042, 7},
+    {0x010F, 9},{0x010E, 9},{0x0219,10},{0x10C3,13},
+    {0x10C2,13},{0x10C5,13},{0x10C4,13},{0x000F, 4},
+    {0x0004, 4},{0x0019, 5},{0x000B, 5},{0x0039, 6},
+    {0x0009, 4},{0x001B, 5},{0x001A, 5},{0x003B, 6}
+  },
+  {
+    {0x0005, 3},{0x0001, 4},{0x003E, 6},{0x0001, 5},
+    {0x00E2, 8},{0x1C6F,13},{0x38D9,14},{0x0039, 6},
+    {0x001F, 6},{0x0002, 3},{0x0001, 3},{0x0009, 4},
+    {0x0008, 4},{0x0000, 5},{0x0070, 7},{0x01C7, 9},
+    {0x038C,10},{0x071A,11},{0x38D8,14},{0x38DB,14},
+    {0x38DA,14},{0x38DD,14},{0x38DC,14},{0x000D, 4},
+    {0x001D, 5},{0x000E, 5},{0x003F, 6},{0x003C, 6},
+    {0x000C, 4},{0x0006, 4},{0x003D, 6},{0x001E, 6}
+  },
+  {
+    {0x0006, 3},{0x000B, 4},{0x0011, 5},{0x001E, 5},
+    {0x0074, 7},{0x03AA,10},{0x1D5C,13},{0x0001, 6},
+    {0x0021, 6},{0x0001, 3},{0x0002, 3},{0x0007, 4},
+    {0x0006, 4},{0x003E, 6},{0x00EB, 8},{0x01D4, 9},
+    {0x0EAF,12},{0x3ABB,14},{0x3ABA,14},{0x1D59,13},
+    {0x1D58,13},{0x1D5B,13},{0x1D5A,13},{0x000A, 4},
+    {0x001C, 5},{0x0001, 5},{0x003F, 6},{0x003B, 6},
+    {0x0001, 4},{0x0009, 4},{0x0020, 6},{0x0000, 6}
+  },
+  {
+    {0x0004, 3},{0x000A, 4},{0x0017, 5},{0x0004, 4},
+    {0x0016, 6},{0x016A, 9},{0x16B1,13},{0x0017, 7},
+    {0x005B, 7},{0x0006, 3},{0x0007, 3},{0x0001, 4},
+    {0x0000, 4},{0x000A, 6},{0x02D7,10},{0x0B5A,12},
+    {0x16B0,13},{0x16B3,13},{0x16B2,13},{0x2D6D,14},
+    {0x2D6C,14},{0x2D6F,14},{0x2D6E,14},{0x0006, 4},
+    {0x000A, 5},{0x0004, 5},{0x002C, 6},{0x0017, 6},
+    {0x0003, 4},{0x0007, 4},{0x0016, 7},{0x00B4, 8}
+  },
+  {
+    {0x0005, 3},{0x000D, 4},{0x0005, 4},{0x0009, 4},
+    {0x0033, 6},{0x0193, 9},{0x192C,13},{0x0061, 8},
+    {0x0031, 7},{0x0000, 2},{0x0007, 3},{0x0010, 5},
+    {0x0011, 5},{0x00C8, 8},{0x192F,13},{0x325B,14},
+    {0x325A,14},{0x1929,13},{0x1928,13},{0x192B,13},
+    {0x192A,13},{0x325D,14},{0x325C,14},{0x0018, 5},
+    {0x001A, 6},{0x001B, 6},{0x0065, 7},{0x0019, 6},
+    {0x0004, 4},{0x0007, 4},{0x0060, 8},{0x0324,10}
+  },
+  {
+    {0x0006, 3},{0x0000, 3},{0x0002, 4},{0x000F, 4},
+    {0x0039, 6},{0x01D9, 9},{0x1D82,13},{0x0761,11},
+    {0x03BE,10},{0x0001, 2},{0x0002, 2},{0x000F, 6},
+    {0x000E, 6},{0x0762,11},{0x3B07,14},{0x3B06,14},
+    {0x3B1D,14},{0x3B1C,14},{0x3B1F,14},{0x3B1E,14},
+    {0x3B19,14},{0x3B18,14},{0x3B1B,14},{0x0038, 6},
+    {0x01DE, 9},{0x00ED, 8},{0x03BF,10},{0x00EE, 8},
+    {0x003A, 6},{0x0006, 5},{0x0EC0,12},{0x3B1A,14}
+  },
+  {
+    {0x0000, 2},{0x0002, 3},{0x000F, 5},{0x0006, 4},
+    {0x001C, 6},{0x01D0,10},{0x0E8C,13},{0x1D1B,14},
+    {0x1D1A,14},{0x0003, 2},{0x0002, 2},{0x00EA, 9},
+    {0x00E9, 9},{0x0E89,13},{0x0E88,13},{0x0E8B,13},
+    {0x0E8A,13},{0x1D65,14},{0x1D64,14},{0x1D67,14},
+    {0x1D66,14},{0x1D61,14},{0x1D60,14},{0x03AD,11},
+    {0x1D63,14},{0x1D62,14},{0x1D1D,14},{0x1D1C,14},
+    {0x003B, 7},{0x01D7,10},{0x1D1F,14},{0x1D1E,14}
+  },
+  {
+    {0x0002, 2},{0x000F, 4},{0x001C, 5},{0x000C, 4},
+    {0x003B, 6},{0x01AC, 9},{0x1AD8,13},{0x35B3,14},
+    {0x35B2,14},{0x0001, 2},{0x0000, 2},{0x0069, 7},
+    {0x0068, 7},{0x35BD,14},{0x35BC,14},{0x35BF,14},
+    {0x35BE,14},{0x35B9,14},{0x35B8,14},{0x35BB,14},
+    {0x35BA,14},{0x35B5,14},{0x35B4,14},{0x01A9, 9},
+    {0x01A8, 9},{0x035A,10},{0x00D7, 8},{0x00D5, 8},
+    {0x003A, 6},{0x001B, 5},{0x35B7,14},{0x35B6,14}
+  }
+};
+
+
+
+/*A description of a Huffman code value used when encoding the tree.*/
+typedef struct{
+  /*The bit pattern, left-shifted so that the MSB of all patterns is
+     aligned.*/
+  ogg_uint32_t pattern;
+  /*The amount the bit pattern was shifted.*/
+  int          shift;
+  /*The token this bit pattern represents.*/
+  int          token;
+}oc_huff_entry;
+
+
+
+/*Compares two oc_huff_entry structures by their bit patterns.
+  _c1: The first entry to compare.
+  _c2: The second entry to compare.
+  Return: <0 if _c1<_c2, >0 if _c1>_c2.*/
+static int huff_entry_cmp(const void *_c1,const void *_c2){
+  ogg_uint32_t b1;
+  ogg_uint32_t b2;
+  b1=((const oc_huff_entry *)_c1)->pattern;
+  b2=((const oc_huff_entry *)_c2)->pattern;
+  return b1<b2?-1:b1>b2?1:0;
+}
+
+/*Encodes a description of the given Huffman tables.
+  Although the codes are stored in the encoder as flat arrays, in the bit
+   stream and in the decoder they are structured as a tree.
+  This function recovers the tree structure from the flat array and then
+   writes it out.
+  Note that the codes MUST form a Huffman code, and not merely a prefix-free
+   code, since the binary tree is assumed to be full.
+  _opb:   The buffer to store the tree in.
+  _codes: The Huffman tables to pack.
+  Return: 0 on success, or a negative value if one of the given Huffman tables
+   does not form a full, prefix-free code.*/
+int oc_huff_codes_pack(oggpack_buffer *_opb,
+ const th_huff_code _codes[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS]){
+  int i;
+  for(i=0;i<TH_NHUFFMAN_TABLES;i++){
+    oc_huff_entry entries[TH_NDCT_TOKENS];
+    int           bpos;
+    int           maxlen;
+    int           mask;
+    int           j;
+    /*First, find the maximum code length so we can align all the bit
+       patterns.*/
+    maxlen=_codes[i][0].nbits;
+    for(j=1;j<TH_NDCT_TOKENS;j++){
+      maxlen=OC_MAXI(_codes[i][j].nbits,maxlen);
+    }
+    mask=(1<<maxlen)-1;
+    /*Copy over the codes into our temporary workspace.
+      The bit patterns are aligned, and the original entry each code is from
+       is stored as well.*/
+    for(j=0;j<TH_NDCT_TOKENS;j++){
+      entries[j].shift=maxlen-_codes[i][j].nbits;
+      entries[j].pattern=_codes[i][j].pattern<<entries[j].shift&mask;
+      entries[j].token=j;
+    }
+    /*Sort the codes into ascending order.
+      This is the order the leaves of the tree will be traversed.*/
+    qsort(entries,TH_NDCT_TOKENS,sizeof(entries[0]),huff_entry_cmp);
+    /*For each leaf of the tree:*/
+    bpos=maxlen;
+    for(j=0;j<TH_NDCT_TOKENS;j++){
+      int bit;
+      /*If this code has any bits at all.*/
+      if(entries[j].shift<maxlen){
+        /*Descend into the tree, writing a bit for each branch.*/
+        for(;bpos>entries[j].shift;bpos--)oggpackB_write(_opb,0,1);
+        /*Mark this as a leaf node, and write its value.*/
+        oggpackB_write(_opb,1,1);
+        oggpackB_write(_opb,entries[j].token,5);
+        /*For each 1 branch we've descended, back up the tree until we reach a
+           0 branch.*/
+        bit=1<<bpos;
+        for(;entries[j].pattern&bit;bpos++)bit<<=1;
+        /*Validate the code.*/
+        if(j+1<TH_NDCT_TOKENS){
+          mask=~(bit-1)<<1;
+          /*The next entry should have a 1 bit where we had a 0, and should
+             match our code above that bit.
+            This verifies both fullness and prefix-freeness simultaneously.*/
+          if(!(entries[j+1].pattern&bit)||
+           (entries[j].pattern&mask)!=(entries[j+1].pattern&mask)){
+            return TH_EINVAL;
+          }
+        }
+        /*If there are no more codes, we should have ascended back to the top
+           of the tree.*/
+        else if(bpos<maxlen)return TH_EINVAL;
+      }
+    }
+  }
+  return 0;
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/huffenc.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/huffenc.h
new file mode 100644
index 0000000..38b8825
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/huffenc.h
@@ -0,0 +1,19 @@
+#if !defined(_huffenc_H)
+# define _huffenc_H (1)
+# include "../dec/huffman.h"
+
+
+
+typedef th_huff_code                  th_huff_table[TH_NDCT_TOKENS];
+
+
+
+extern const th_huff_code
+ TH_VP31_HUFF_CODES[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS];
+
+
+
+int oc_huff_codes_pack(oggpack_buffer *_opb,
+ const th_huff_code _codes[TH_NHUFFMAN_TABLES][TH_NDCT_TOKENS]);
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/hufftables.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/hufftables.h
new file mode 100644
index 0000000..eb4be22
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/hufftables.h
@@ -0,0 +1,1034 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: hufftables.h 13884 2007-09-22 08:38:10Z giles $
+
+ ********************************************************************/
+
+#include "../dec/huffman.h"
+#include "codec_internal.h"
+
+const unsigned char ExtraBitLengths_VP31[MAX_ENTROPY_TOKENS] = {
+  0, 0, 0, 2, 3, 4, 12,3, 6,                 /* EOB and Zero-run tokens. */
+  0, 0, 0, 0,                                /* Very low value tokens. */
+  1, 1, 1, 1, 2, 3, 4, 5, 6, 10,             /* Other value tokens */
+  1, 1, 1, 1, 1, 3, 4,                       /* Category 1 runs. */
+  2, 3,                                      /* Category 2 runs. */
+};
+
+#define NEW_FREQS 0 /* dbm - test new frequency tables */
+
+#if NEW_FREQS
+/* New baseline frequency tables for encoder version >= 2 */
+const ogg_uint32_t FrequencyCounts_VP3[NUM_HUFF_TABLES][MAX_ENTROPY_TOKENS] = {
+  /* DC Intra bias  */
+  {  272,    84,    31,    36,    10,    2,    1,    92,    1,
+     701,   872,   410,   478,
+     630,   502,   417,   356,   582,   824,   985,   965,   697,   606,
+     125,   119,    40,    3,    9,    15,    10,
+     73,    37,
+  },
+  {  311,   107,    41,    51,    18,    4,    2,   120,    1,
+     824,  1037,   468,   541,
+     714,   555,   451,   374,   595,   819,   929,   817,   474,   220,
+     172,   142,    27,    4,    9,    10,    2,
+     98,    48,
+  },
+  {  353,   125,    49,    66,    24,    6,    2,   124,    1,
+     926,  1172,   512,   594,
+     766,   581,   458,   379,   590,   789,   849,   665,   306,    80,
+     204,   147,    25,    5,    12,    9,    2,
+     108,    54,
+  },
+  {  392,   141,    57,    75,    31,    7,    4,   138,    1,
+     1050,  1321,   559,   649,
+     806,   594,   460,   372,   568,   727,   710,   475,   155,    19,
+     251,   174,    27,    7,    16,    8,    2,
+     126,    62,
+  },
+  {  455,   168,    66,    87,    39,    10,    6,   124,    2,
+     1143,  1455,   592,   692,
+     824,   596,   453,   361,   542,   657,   592,   329,    78,    5,
+     269,   184,    27,    9,    19,    7,    2,
+     127,    66,
+  },
+  {  544,   201,    80,   102,    45,    11,    6,    99,    1,
+     1236,  1587,   610,   720,
+     833,   590,   444,   348,   506,   588,   487,   226,    39,    2,
+     253,   178,    27,    10,    20,    7,    2,
+     118,    65,
+  },
+  {  649,   241,    98,   121,    54,    14,    8,    84,    1,
+     1349,  1719,   634,   763,
+     847,   583,   428,   323,   456,   492,   349,   120,    13,    1,
+     231,   170,    24,    8,    19,    7,    1,
+     109,    67,
+  },
+  {  824,   304,   129,   158,    66,    19,    10,    44,    2,
+     1476,  1925,   644,   794,
+     838,   559,   396,   289,   392,   384,   223,    53,    3,    1,
+     159,   121,    17,    6,    16,    6,    2,
+     69,    53,
+  },
+
+  /* DC Inter Bias */
+  {  534,   174,    71,    68,    10,    1,    1,    68,   119,
+     1674,  1526,   560,   536,
+     539,   331,   229,   168,   233,   262,   231,   149,    71,    51,
+     629,   530,   284,   126,   182,   208,   184,
+     148,    87,
+  },
+  {  594,   195,    77,    71,    9,    1,    1,    47,    89,
+     1723,  1592,   595,   570,
+     574,   351,   241,   176,   243,   271,   234,   144,    65,    37,
+     534,   449,   240,   117,   167,   277,   153,
+     96,    54,
+  },
+  {  642,   213,    88,    83,    12,    1,    1,    40,    80,
+     1751,  1630,   621,   600,
+     598,   367,   250,   183,   251,   276,   235,   143,    62,    28,
+     485,   397,   212,   110,   161,   193,   141,
+     84,    48,
+  },
+  {  693,   258,   114,   131,    27,    3,    1,    44,    79,
+     1794,  1644,   550,   533,
+     518,   314,   213,   154,   209,   223,   174,    97,    40,    14,
+     584,   463,   236,   138,   196,   249,   143,
+     94,    54,
+  },
+  {  758,   303,   144,   189,    53,    8,    1,    37,    69,
+     1842,  1732,   513,   504,
+     478,   287,   191,   137,   182,   186,   137,    72,    31,    6,
+     589,   469,   199,   128,   177,   264,   161,
+     89,    49,
+  },
+  {  817,   344,   170,   243,    84,    18,    2,    30,    65,
+     1836,  1733,   518,   511,
+     477,   281,   185,   130,   169,   166,   117,    59,    25,    3,
+     572,   450,   185,   121,   173,   232,   146,
+     80,    43,
+  },
+  {  865,   389,   204,   322,   139,    42,    9,    26,    51,
+     1848,  1766,   531,   522,
+     477,   275,   177,   122,   153,   144,    97,    50,    16,    1,
+     485,   378,   167,   115,   164,   203,   128,
+     74,    42,
+  },
+  {  961,   447,   243,   407,   196,    74,    26,    12,    34,
+     2003,  1942,   571,   565,
+     494,   278,   173,   116,   141,   129,    85,    44,    8,    1,
+     285,   223,   101,    66,   104,   120,    74,
+     35,    22,
+  },
+
+  /* AC INTRA Tables  */
+  /* AC Intra bias group 1 tables */
+  {  245,    68,    25,    28,    5,    1,    1,   359,    4,
+     910,   904,   570,   571,
+     766,   620,   478,   375,   554,   684,   652,   441,   182,    30,
+     535,   206,   118,    77,    69,    90,    16,
+     299,   100,
+  },
+  {  302,    86,    32,    36,    8,    1,    1,   362,    3,
+     974,   968,   599,   599,
+     774,   635,   469,   365,   528,   628,   557,   337,   118,    14,
+     577,   219,   136,    82,    69,    65,    13,
+     317,   112,
+  },
+  {  348,   102,    39,    44,    9,    2,    1,   363,    3,
+     1062,  1055,   607,   609,
+     787,   626,   457,   348,   494,   550,   452,   233,    60,    2,
+     636,   244,   159,    92,    74,    68,    12,
+     327,   119,
+  },
+  {  400,   121,    47,    51,    11,    2,    1,   366,    3,
+     1109,  1102,   620,   622,
+     786,   624,   450,   331,   459,   490,   366,   163,    29,    1,
+     673,   257,   175,    98,    77,    63,    14,
+     344,   131,
+  },
+  {  470,   151,    59,    67,    15,    3,    1,   354,    4,
+     1198,  1189,   640,   643,
+     769,   603,   410,   294,   386,   381,   240,    78,    5,    1,
+     746,   282,   205,   113,    87,    64,    15,
+     368,   145,
+  },
+  {  553,   189,    77,    94,    24,    6,    1,   347,    4,
+     1244,  1232,   650,   653,
+     739,   551,   360,   249,   303,   261,   129,    24,    1,    1,
+     828,   313,   245,   135,   108,    77,    17,
+     403,   169,
+  },
+  {  701,   253,   109,   140,    42,    12,    2,   350,    6,
+     1210,  1197,   652,   647,
+     673,   495,   299,   189,   211,   151,    50,    2,    1,    1,
+     892,   336,   284,   162,   134,   101,    25,
+     455,   205,
+  },
+  {  924,   390,   180,   248,    85,    31,    13,   286,    14,
+     1242,  1206,   601,   577,
+     519,   342,   175,   100,    85,    36,    1,    1,    1,    1,
+     1031,   348,   346,   204,   166,   131,    34,
+     473,   197,
+  },
+  /* AC Inter bias group 1 tables */
+  {  459,   128,    50,    48,    8,    1,    1,   224,    69,
+     1285,  1227,   587,   565,
+     573,   406,   261,   180,   228,   213,   130,    47,    11,    3,
+     1069,   540,   309,   231,   147,   279,   157,
+     383,   165,
+  },
+  {  524,   155,    62,    64,    14,    2,    1,   209,    63,
+     1345,  1288,   523,   507,
+     515,   358,   225,   153,   183,   160,    87,    29,    7,    2,
+     1151,   591,   365,   282,   179,   308,   133,
+     344,   157,
+  },
+  {  588,   181,    75,    81,    19,    3,    1,   204,    68,
+     1344,  1288,   517,   503,
+     505,   346,   216,   141,   169,   139,    71,    21,    5,    1,
+     1146,   584,   366,   286,   170,   298,   153,
+     342,   157,
+  },
+  {  634,   196,    82,    89,    22,    4,    1,   194,    60,
+     1356,  1312,   515,   502,
+     489,   331,   199,   127,   145,   111,    51,    14,    3,    1,
+     1156,   589,   393,   300,   182,   285,   144,
+     340,   159,
+  },
+  {  715,   231,    98,   113,    31,    7,    1,   181,    57,
+     1345,  1303,   498,   490,
+     448,   291,   166,   101,   106,    75,    30,    9,    1,    1,
+     1175,   584,   416,   321,   209,   333,   164,
+     330,   159,
+  },
+  {  825,   283,   125,   149,    44,    11,    2,   160,    59,
+     1343,  1308,   476,   469,
+     405,   247,   131,    75,    76,    47,    18,    5,    1,    1,
+     1192,   579,   432,   332,   217,   327,   176,
+     320,   154,
+  },
+  {  961,   361,   170,   215,    70,    20,    5,   161,    55,
+     1250,  1218,   463,   460,
+     354,   204,   101,    52,    48,    28,    11,    1,    1,    1,
+     1172,   570,   449,   350,   222,   332,   169,
+     338,   174,
+  },
+  {  1139,   506,   266,   387,   156,    57,    26,   114,    48,
+     1192,  1170,   366,   366,
+     226,   113,    47,    22,    22,    12,    1,    1,    1,    1,
+     1222,   551,   462,   391,   220,   322,   156,
+     290,   136,
+  },
+
+  /* AC Intra bias group 2 tables */
+  {  245,    49,    15,    11,    1,    1,    1,   332,    38,
+     1163,  1162,   685,   683,
+     813,   623,   437,   318,   421,   424,   288,   109,    14,    1,
+     729,   303,   179,   112,    87,   199,    46,
+     364,   135,
+  },
+  {  305,    67,    22,    17,    2,    1,    1,   329,    39,
+     1250,  1245,   706,   705,
+     801,   584,   385,   267,   330,   296,   165,    40,    3,    1,
+     798,   340,   206,   131,   108,   258,    52,
+     382,   154,
+  },
+  {  356,    82,    28,    23,    3,    1,    1,   312,    42,
+     1340,  1334,   701,   703,
+     770,   545,   346,   227,   269,   223,   100,    17,    1,    1,
+     846,   359,   222,   142,   120,   284,    55,
+     379,   157,
+  },
+  {  402,    95,    33,    30,    4,    1,    1,   300,    43,
+     1379,  1371,   710,   714,
+     724,   486,   289,   182,   202,   144,    47,    5,    1,    1,
+     908,   394,   250,   161,   141,   350,    60,
+     391,   171,
+  },
+  {  499,   122,    44,    42,    7,    1,    1,   267,    45,
+     1439,  1436,   690,   694,
+     628,   385,   213,   122,   117,    62,    14,    1,    1,    1,
+     992,   441,   288,   187,   167,   446,    82,
+     378,   176,
+  },
+  {  641,   168,    62,    60,    12,    1,    1,   247,    49,
+     1435,  1436,   662,   669,
+     527,   298,   142,    71,    55,    22,    3,    1,    1,    1,
+     1036,   470,   319,   208,   193,   548,   106,
+     362,   184,
+  },
+  {  860,   274,   111,   113,    23,    4,    1,   229,    59,
+     1331,  1323,   629,   645,
+     419,   192,    72,    30,    19,    6,    1,    1,    1,    1,
+     1022,   478,   339,   225,   213,   690,   142,
+     342,   198,
+  },
+  {  1059,   437,   218,   285,    84,    17,    2,   152,    44,
+     1284,  1313,   530,   561,
+     212,    66,    17,    6,    3,    1,    1,    1,    1,    1,
+     1034,   485,   346,   226,   207,   819,   185,
+     248,   145,
+  },
+  /* AC Inter bias group 2 tables */
+  {  407,    93,    31,    24,    2,    1,    1,   232,   108,
+     1365,  1349,   581,   578,
+     498,   305,   170,   100,   103,    67,    24,    5,    1,    1,
+     1175,   604,   393,   268,   209,   506,   217,
+     379,   193,
+  },
+  {  521,   129,    46,    39,    4,    1,    1,   199,   116,
+     1419,  1403,   543,   540,
+     446,   263,   138,    78,    75,    44,    13,    2,    1,    1,
+     1201,   605,   392,   267,   214,   533,   252,
+     334,   167,
+  },
+  {  575,   144,    52,    46,    6,    1,    1,   193,   124,
+     1394,  1384,   528,   528,
+     406,   227,   112,    59,    54,    28,    7,    1,    1,    1,
+     1210,   621,   412,   284,   235,   604,   265,
+     320,   167,
+  },
+  {  673,   174,    64,    59,    9,    1,    1,   177,   128,
+     1392,  1385,   499,   499,
+     352,   183,    85,    42,    35,    16,    3,    1,    1,    1,
+     1210,   626,   418,   289,   246,   675,   297,
+     292,   158,
+  },
+  {  804,   225,    85,    77,    12,    1,    1,   150,   129,
+     1387,  1384,   455,   455,
+     277,   129,    53,    23,    17,    7,    1,    1,    1,    1,
+     1212,   635,   433,   306,   268,   760,   313,
+     249,   137,
+  },
+  {  975,   305,   123,   117,    20,    2,    1,   135,   140,
+     1312,  1310,   401,   399,
+     201,    80,    28,    11,    8,    2,    1,    1,    1,    1,
+     1162,   623,   439,   314,   283,   906,   368,
+     203,   121,
+  },
+  {  1205,   452,   208,   231,    50,    6,    1,   123,   149,
+     1161,  1164,   370,   370,
+     137,    45,    14,    4,    2,    1,    1,    1,    1,    1,
+     1047,   562,   413,   300,   277,  1020,   404,
+     168,   105,
+  },
+  {  1297,   662,   389,   574,   200,    39,    4,    55,   120,
+     1069,  1076,   273,   265,
+     66,    14,    2,    1,    1,    1,    1,    1,    1,    1,
+     930,   475,   345,   249,   236,  1124,   376,
+     91,    56,
+  },
+
+  /* AC Intra bias group 3 tables */
+  {  278,    55,    17,    12,    1,    1,    1,   288,    71,
+     1315,  1304,   725,   724,
+     733,   506,   307,   195,   225,   175,    77,    12,    1,    1,
+     904,   414,   246,   170,   126,   290,   205,
+     423,   185,
+  },
+  {  382,    80,    26,    21,    2,    1,    1,   239,    64,
+     1442,  1429,   706,   701,
+     664,   420,   239,   146,   152,   105,    34,    2,    1,    1,
+     975,   440,   263,   185,   140,   332,   229,
+     397,   169,
+  },
+  {  451,    97,    32,    27,    4,    1,    1,   223,    75,
+     1462,  1454,   682,   680,
+     574,   343,   179,   101,    98,    54,    9,    1,    1,    1,
+     1031,   482,   293,   210,   163,   400,   297,
+     384,   181,
+  },
+  {  551,   128,    43,    37,    5,    1,    1,   201,    78,
+     1497,  1487,   642,   651,
+     493,   269,   133,    70,    60,    24,    2,    1,    1,    1,
+     1065,   504,   312,   228,   178,   451,   352,
+     351,   174,
+  },
+  {  693,   179,    63,    54,    8,    1,    1,   169,    78,
+     1502,  1497,   580,   591,
+     375,   186,    77,    35,    21,    4,    1,    1,    1,    1,
+     1099,   533,   341,   253,   206,   542,   432,
+     306,   164,
+  },
+  {  867,   263,   105,    96,    16,    2,    1,   152,    81,
+     1435,  1439,   521,   525,
+     270,   107,    32,    8,    3,    1,    1,    1,    1,    1,
+     1085,   537,   361,   277,   223,   616,   549,
+     258,   156,
+  },
+  {  1022,   385,   182,   207,    46,    7,    1,   158,    88,
+     1290,  1318,   501,   502,
+     184,    38,    6,    1,    1,    1,    1,    1,    1,    1,
+     1023,   480,   345,   301,   232,   665,   661,
+     210,   133,
+  },
+  {  1184,   555,   307,   457,   185,    44,    6,   115,    41,
+     1236,  1253,   329,   340,
+     32,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+     1017,   385,   316,   370,   246,   672,   788,
+     85,    23,
+  },
+  /* AC Inter bias group 3 tables */
+  {  502,   106,    33,    22,    1,    1,    1,   151,   132,
+     1446,  1451,   502,   499,
+     343,   181,    84,    42,    36,    16,    3,    1,    1,    1,
+     1211,   661,   429,   312,   242,   637,   498,
+     288,   156,
+  },
+  {  651,   147,    48,    35,    3,    1,    1,   145,   140,
+     1419,  1420,   469,   466,
+     281,   132,    56,    25,    18,    6,    1,    1,    1,    1,
+     1175,   656,   435,   328,   260,   715,   556,
+     252,   147,
+  },
+  {  749,   179,    59,    43,    4,    1,    1,   123,   135,
+     1423,  1431,   413,   409,
+     221,    95,    36,    15,    9,    2,    1,    1,    1,    1,
+     1159,   658,   444,   340,   272,   782,   656,
+     205,   124,
+  },
+  {  902,   243,    86,    67,    7,    1,    1,   114,   141,
+     1385,  1385,   387,   383,
+     178,    67,    22,    7,    4,    1,    1,    1,    1,    1,
+     1096,   632,   434,   339,   277,   813,   735,
+     171,   109,
+  },
+  {  1081,   337,   133,   112,    15,    1,    1,    92,   137,
+     1350,  1349,   311,   309,
+     115,    34,    8,    2,    1,    1,    1,    1,    1,    1,
+     1016,   595,   418,   342,   283,   870,   883,
+     114,    78,
+  },
+  {  1253,   467,   210,   205,    34,    3,    1,    80,   130,
+     1318,  1313,   258,   260,
+     68,    12,    2,    1,    1,    1,    1,    1,    1,    1,
+     874,   516,   378,   330,   273,   877,  1000,
+     72,    53,
+  },
+  {  1362,   626,   333,   423,   100,    10,    1,    73,   106,
+     1311,  1313,   241,   231,
+     31,    3,    1,    1,    1,    1,    1,    1,    1,    1,
+     620,   368,   286,   302,   245,   814,  1127,
+     34,    28,
+  },
+  {  1203,   743,   460,   774,   284,    36,    1,    13,    25,
+     1956,  1961,   103,   106,
+     3,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+     248,   131,   149,   272,   165,   535,   813,
+     3,    3,
+  },
+
+  /* AC Intra bias group 4 tables */
+  {  599,   150,    55,    50,    9,    1,    1,   181,    19,
+     1487,  1487,   625,   625,
+     473,   271,   138,    74,    71,    42,    11,    1,    1,    1,
+     1187,   591,   356,   239,   170,   351,   137,
+     395,   194,
+  },
+  {  758,   209,    79,    74,    15,    2,    1,   147,    25,
+     1514,  1514,   521,   520,
+     334,   165,    74,    36,    30,    11,    1,    1,    1,    1,
+     1252,   644,   409,   279,   211,   472,   203,
+     318,   171,
+  },
+  {  852,   252,   100,    98,    20,    3,    1,   130,    26,
+     1493,  1498,   481,   473,
+     268,   123,    51,    23,    15,    3,    1,    1,    1,    1,
+     1256,   652,   426,   294,   231,   543,   242,
+     278,   156,
+  },
+  {  971,   309,   130,   136,    30,    5,    1,   113,    28,
+     1458,  1467,   443,   435,
+     215,    90,    31,    12,    5,    1,    1,    1,    1,    1,
+     1232,   643,   426,   303,   243,   590,   300,
+     235,   136,
+  },
+  {  1100,   399,   180,   206,    53,    9,    1,   101,    29,
+     1419,  1425,   375,   374,
+     158,    47,    10,    1,    1,    1,    1,    1,    1,    1,
+     1193,   609,   426,   319,   256,   643,   383,
+     166,   103,
+  },
+  {  1195,   505,   249,   326,    98,    20,    3,   102,    25,
+     1370,  1356,   355,   347,
+     104,    11,    1,    1,    1,    1,    1,    1,    1,    1,
+     1100,   568,   381,   330,   261,   642,   466,
+     105,    69,
+  },
+  {  1176,   608,   345,   559,   244,    57,    6,   110,    9,
+     1370,  1332,   372,   367,
+     29,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+     859,   427,   269,   359,   375,   608,   451,
+     35,    20,
+  },
+  {  1140,   613,   391,   797,   458,   180,    37,    2,    1,
+     2037,  1697,    95,    31,
+     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+     360,    49,    23,   198,  1001,   719,   160,
+     1,    1,
+  },
+  /* AC Inter bias group 4 tables */
+  {  931,   272,   105,    96,    16,    1,    1,    91,    52,
+     1481,  1489,   347,   349,
+     174,    74,    28,    12,    8,    3,    1,    1,    1,    1,
+     1247,   719,   490,   356,   279,   706,   363,
+     187,   110,
+  },
+  {  1095,   358,   148,   143,    25,    3,    1,    74,    61,
+     1439,  1457,   304,   302,
+     127,    46,    15,    5,    3,    1,    1,    1,    1,    1,
+     1138,   664,   469,   347,   282,   768,   487,
+     139,    87,
+  },
+  {  1192,   423,   188,   189,    36,    4,    1,    64,    61,
+     1457,  1475,   284,   282,
+     106,    35,    10,    3,    1,    1,    1,    1,    1,    1,
+     1078,   624,   440,   329,   264,   744,   507,
+     117,    73,
+  },
+  {  1275,   496,   231,   258,    52,    6,    1,    53,    55,
+     1458,  1470,   248,   245,
+     77,    20,    5,    1,    1,    1,    1,    1,    1,    1,
+     984,   576,   414,   323,   260,   771,   569,
+     84,    54,
+  },
+  {  1377,   603,   302,   367,    87,    11,    1,    37,    52,
+     1522,  1532,   207,   204,
+     47,    8,    1,    1,    1,    1,    1,    1,    1,    1,
+     840,   493,   366,   291,   231,   690,   636,
+     52,    32,
+  },
+  {  1409,   708,   385,   529,   148,    24,    1,    23,    37,
+     1672,  1670,   163,   162,
+     22,    2,    1,    1,    1,    1,    1,    1,    1,    1,
+     647,   364,   291,   262,   210,   574,   643,
+     26,    14,
+  },
+  {  1348,   778,   481,   755,   245,    53,    4,    13,    19,
+     2114,  2089,   141,   139,
+     7,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+     302,   183,   162,   181,   182,   344,   437,
+     8,    3,
+  },
+  {  1560,   769,   410,   664,   243,    58,    1,    1,    1,
+     3017,  2788,    17,    24,
+     3,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+     34,    16,    8,    55,   134,   105,    86,
+     1,    1,
+  },
+};
+
+#else /* Frequency tables for encoder version < 2 */
+
+const ogg_uint32_t FrequencyCounts_VP3[NUM_HUFF_TABLES][MAX_ENTROPY_TOKENS] = {
+  /* DC Intra bias */
+  {  198,    62,    22,    31,    14,     6,     6,   205,     3,
+     843,   843,   415,   516,
+     660,   509,   412,   347,   560,   779,   941,   930,   661,   377,
+     170,   155,    39,     2,     9,    15,    11,
+     128,    86,
+  },
+  {  299,    92,    34,    39,    15,     6,     6,   132,     1,
+     851,   851,   484,   485,
+     666,   514,   416,   351,   567,   788,   953,   943,   670,   383,
+     117,   119,    26,     4,    17,     7,     1,
+      93,    56,
+  },
+  {  367,   115,   42,   47,   16,    6,    6,   105,    1,
+     896,   896,   492,   493,
+     667,   510,   408,   342,   547,   760,   932,   927,   656,   379,
+     114,   103,   10,    3,    6,    2,    1,
+     88,   49,
+  },
+  {  462,   158,   63,   76,   28,    9,    8,   145,    1,
+     1140,  1140,   573,   574,
+     754,   562,   435,   357,   555,   742,   793,   588,   274,   81,
+     154,   117,   13,    6,   12,    2,    1,
+     104,   62,
+  },
+  {  558,   196,   81,   99,   36,   11,    9,   135,    1,
+     1300,  1301,   606,   607,
+     779,   560,   429,   349,   536,   680,   644,   405,   153,   30,
+     171,   120,   12,    5,   14,    3,    1,
+     104,   53,
+  },
+  {  635,   233,   100,   122,   46,   14,   12,   113,    1,
+     1414,  1415,   631,   631,
+     785,   555,   432,   335,   513,   611,   521,   284,   89,   13,
+     170,   113,   10,    5,   14,    3,    1,
+     102,   62,
+  },
+  {  720,   276,   119,   154,   62,   20,   16,   101,    1,
+     1583,  1583,   661,   661,
+     794,   556,   407,   318,   447,   472,   343,   153,   35,    1,
+     172,   115,   11,    7,   14,    3,    1,
+     112,   70,
+  },
+  {  853,   326,   144,   184,   80,   27,   19,   52,    1,
+     1739,  1740,   684,   685,
+     800,   540,   381,   277,   364,   352,   218,   78,   13,    1,
+     139,   109,    9,    6,   20,    2,    1,
+     94,   50,
+  },
+
+  /* DC Inter Bias */
+  {  490,   154,   57,   53,   10,    2,    1,   238,   160,
+     1391,  1390,   579,   578,
+     491,   273,   172,   118,   152,   156,   127,   79,   41,   39,
+     712,   547,   316,   125,   183,   306,   237,
+     451,   358,
+  },
+  {  566,   184,   70,   65,   11,    2,    1,   235,   51,
+     1414,  1414,   599,   598,
+     510,   285,   180,   124,   157,   161,   131,   82,   42,   40,
+     738,   551,   322,   138,   195,   188,   93,
+     473,   365,
+  },
+  {  711,   261,   111,   126,   27,    4,    1,   137,   52,
+     1506,  1505,   645,   645,
+     567,   316,   199,   136,   172,   175,   142,   88,   45,   48,
+     548,   449,   255,   145,   184,   174,   121,
+     260,   227,
+  },
+  {  823,   319,   144,   175,   43,    7,    1,   53,   42,
+     1648,  1648,   653,   652,
+     583,   329,   205,   139,   175,   176,   139,   84,   44,   34,
+     467,   389,   211,   137,   181,   186,   107,
+     106,   85,
+  },
+  {  948,   411,   201,   276,   85,   16,    2,   39,   33,
+     1778,  1777,   584,   583,
+     489,   265,   162,   111,   140,   140,   108,   64,   38,   23,
+     428,   356,   201,   139,   186,   165,   94,
+     78,   63,
+  },
+  {  1002,   470,   248,   386,   153,   39,    6,   23,   23,
+     1866,  1866,   573,   573,
+     467,   249,   155,   103,   130,   128,   94,   60,   38,   14,
+     323,   263,   159,   111,   156,   153,   74,
+     46,   34,
+  },
+  {  1020,   518,   291,   504,   242,   78,   18,   14,   14,
+     1980,  1979,   527,   526,
+     408,   219,   132,   87,   110,   104,   79,   55,   31,    7,
+     265,   213,   129,   91,   131,   111,   50,
+     31,   20,
+  },
+  {  1018,   544,   320,   591,   338,   139,   47,    5,    2,
+     2123,  2123,   548,   547,
+     414,   212,   126,   83,   101,   96,   79,   60,   23,    1,
+     120,   97,   55,   39,   60,   38,   15,
+     11,    8,
+  },
+
+  /* AC INTRA Tables  */
+  /* AC Intra bias group 1 tables */
+  {  242,   62,   22,   20,    4,    1,    1,   438,    1,
+     593,   593,   489,   490,
+     657,   580,   471,   374,   599,   783,   869,   770,   491,   279,
+     358,   144,   82,   54,   49,   70,    5,
+     289,   107,
+  },
+  {  317,   95,   38,   41,    8,    1,    1,   479,    1,
+     653,   654,   500,   501,
+     682,   611,   473,   376,   582,   762,   806,   656,   358,   155,
+     419,   162,   86,   58,   36,   34,    1,
+     315,   126,
+  },
+  {  382,   121,   49,   59,   15,    3,    1,   496,    1,
+     674,   674,   553,   554,
+     755,   636,   487,   391,   576,   718,   701,   488,   221,   72,
+     448,   161,   107,   56,   37,   29,    1,
+     362,   156,
+  },
+  {  415,   138,   57,   73,   21,    5,    1,   528,    1,
+     742,   741,   562,   563,
+     753,   669,   492,   388,   563,   664,   589,   340,   129,   26,
+     496,   184,   139,   71,   48,   33,    2,
+     387,   166,
+  },
+  {  496,   170,   73,   94,   31,    8,    2,   513,    1,
+     855,   855,   604,   604,
+     769,   662,   477,   356,   486,   526,   381,   183,   51,    5,
+     590,   214,   160,   85,   60,   39,    3,
+     427,   203,
+  },
+  {  589,   207,   89,   116,   40,   13,    3,   491,    1,
+     919,   919,   631,   631,
+     769,   633,   432,   308,   408,   378,   247,   94,   17,    1,
+     659,   247,   201,   105,   73,   51,    3,
+     466,   242,
+  },
+  {  727,   266,   115,   151,   49,   17,    6,   439,    1,
+     977,   977,   642,   642,
+     718,   572,   379,   243,   285,   251,   133,   40,    1,    1,
+     756,   287,   253,   126,   94,   66,    4,
+     492,   280,
+  },
+  {  940,   392,   180,   247,   82,   30,   14,   343,    1,
+     1064,  1064,   615,   616,
+     596,   414,   235,   146,   149,   108,   41,    1,    1,    1,
+     882,   314,   346,   172,   125,   83,    6,
+     489,   291,
+  },
+  /* AC Inter bias group 1 tables */
+  {  440,   102,   33,   23,    2,    1,    1,   465,   85,
+     852,   852,   744,   743,
+     701,   496,   297,   193,   225,   200,   129,   58,   18,    2,
+     798,   450,   269,   202,   145,   308,   154,
+     646,   389,
+  },
+  {  592,   151,   53,   43,    6,    1,    1,   409,   34,
+     875,   875,   748,   747,
+     723,   510,   305,   196,   229,   201,   130,   59,   18,    2,
+     800,   436,   253,   185,   115,   194,   88,
+     642,   368,
+  },
+  {  759,   222,   86,   85,   17,    2,    1,   376,   46,
+     888,   888,   689,   688,
+     578,   408,   228,   143,   165,   141,   84,   35,    7,    1,
+     878,   488,   321,   244,   147,   266,   124,
+     612,   367,
+  },
+  {  912,   298,   122,   133,   34,    7,    1,   261,   44,
+     1092,  1091,   496,   496,
+     409,   269,   150,   95,   106,   87,   49,   16,    1,    1,
+     1102,   602,   428,   335,   193,   323,   157,
+     423,   253,
+  },
+  {  1072,   400,   180,   210,   60,   16,    3,   210,   40,
+     1063,  1063,   451,   451,
+     345,   221,   121,   73,   79,   64,   31,    6,    1,    1,
+     1105,   608,   462,   358,   202,   330,   155,
+     377,   228,
+  },
+  {  1164,   503,   254,   330,   109,   34,    9,   167,   35,
+     1038,  1037,   390,   390,
+     278,   170,   89,   54,   56,   40,   13,    1,    1,    1,
+     1110,   607,   492,   401,   218,   343,   141,
+     323,   192,
+  },
+  {  1173,   583,   321,   486,   196,   68,   23,   124,   23,
+     1037,  1037,   347,   346,
+     232,   139,   69,   40,   37,   20,    2,    1,    1,    1,
+     1128,   584,   506,   410,   199,   301,   113,
+     283,   159,
+  },
+  {  1023,   591,   366,   699,   441,   228,   113,   79,    5,
+     1056,  1056,   291,   291,
+     173,   96,   38,   19,    8,    1,    1,    1,    1,    1,
+     1187,   527,   498,   409,   147,   210,   56,
+     263,   117,
+  },
+
+  /* AC Intra bias group 2 tables */
+  {  311,   74,   27,   27,    5,    1,    1,   470,   24,
+     665,   667,   637,   638,
+     806,   687,   524,   402,   585,   679,   609,   364,   127,   20,
+     448,   210,   131,   76,   52,   111,   19,
+     393,   195,
+  },
+  {  416,   104,   39,   38,    8,    1,    1,   545,   33,
+     730,   731,   692,   692,
+     866,   705,   501,   365,   495,   512,   387,   168,   39,    2,
+     517,   240,   154,   86,   64,   127,   19,
+     461,   247,
+  },
+  {  474,   117,   43,   42,    9,    1,    1,   560,   40,
+     783,   783,   759,   760,
+     883,   698,   466,   318,   404,   377,   215,   66,    7,    1,
+     559,   259,   176,   110,   87,   170,   22,
+     520,   278,
+  },
+  {  582,   149,   53,   53,   12,    2,    1,   473,   39,
+     992,   993,   712,   713,
+     792,   593,   373,   257,   299,   237,   114,   25,    1,    1,
+     710,   329,   221,   143,   116,   226,   26,
+     490,   259,
+  },
+  {  744,   210,   78,   77,   16,    2,    1,   417,   37,
+     1034,  1035,   728,   728,
+     718,   509,   296,   175,   184,   122,   42,    3,    1,    1,
+     791,   363,   255,   168,   145,   311,   35,
+     492,   272,
+  },
+  {  913,   291,   121,   128,   28,    4,    1,   334,   40,
+     1083,  1084,   711,   712,
+     624,   378,   191,   107,   95,   50,    7,    1,    1,    1,
+     876,   414,   288,   180,   164,   382,   39,
+     469,   275,
+  },
+  {  1065,   405,   184,   216,   53,    8,    1,   236,   36,
+     1134,  1134,   685,   686,
+     465,   253,   113,   48,   41,    9,    1,    1,    1,    1,
+     965,   451,   309,   179,   166,   429,   53,
+     414,   249,
+  },
+  {  1148,   548,   301,   438,   160,   42,    6,   84,   17,
+     1222,  1223,   574,   575,
+     272,   111,   23,    6,    2,    1,    1,    1,    1,    1,
+     1060,   502,   328,   159,   144,   501,   54,
+     302,   183,
+  },
+  /* AC Inter bias group 2 tables */
+  {  403,   80,   24,   17,    1,    1,    1,   480,   90,
+     899,   899,   820,   819,
+     667,   413,   228,   133,   139,   98,   42,   10,    1,    1,
+     865,   470,   316,   222,   171,   419,   213,
+     645,   400,
+  },
+  {  698,   169,   59,   49,    6,    1,    1,   414,   101,
+     894,   893,   761,   761,
+     561,   338,   171,   96,   97,   64,   26,    6,    1,    1,
+     896,   494,   343,   239,   192,   493,   215,
+     583,   366,
+  },
+  {  914,   255,   94,   80,   10,    1,    1,   345,   128,
+     935,   935,   670,   671,
+     415,   222,   105,   55,   51,   30,   10,    1,    1,    1,
+     954,   530,   377,   274,   232,   641,   295,
+     456,   298,
+  },
+  {  1103,   359,   146,   135,   20,    1,    1,   235,   119,
+     1042,  1042,   508,   507,
+     293,   146,   65,   33,   30,   16,    4,    1,    1,    1,
+     1031,   561,   407,   296,   265,   813,   317,
+     301,   192,
+  },
+  {  1255,   504,   238,   265,   51,    5,    1,   185,   113,
+     1013,  1013,   437,   438,
+     212,   92,   41,   18,   15,    6,    1,    1,    1,    1,
+     976,   530,   386,   276,   260,   927,   357,
+     224,   148,
+  },
+  {  1292,   610,   332,   460,   127,   16,    1,   136,   99,
+     1014,  1015,   384,   384,
+     153,   65,   25,   11,    6,    1,    1,    1,    1,    1,
+     942,   487,   343,   241,   238,   970,   358,
+     174,   103,
+  },
+  {  1219,   655,   407,   700,   280,   55,    2,   100,   60,
+     1029,  1029,   337,   336,
+     119,   43,   11,    3,    2,    1,    1,    1,    1,    1,
+     894,   448,   305,   199,   213,  1005,   320,
+     136,   77,
+  },
+  {  1099,   675,   435,   971,   581,   168,   12,   37,   16,
+     1181,  1081,   319,   318,
+     66,   11,    6,    1,    1,    1,    1,    1,    1,    1,
+     914,   370,   235,   138,   145,   949,   128,
+     94,   41,
+  },
+
+  /* AC Intra bias group 3 tables */
+  {  486,   112,   39,   34,    6,    1,    1,   541,   67,
+     819,   818,   762,   763,
+     813,   643,   403,   280,   332,   295,   164,   53,    6,    1,
+     632,   294,   180,   131,   105,   208,   109,
+     594,   295,
+  },
+  {  723,   191,   69,   65,   12,    1,    1,   445,   79,
+     865,   865,   816,   816,
+     750,   515,   290,   172,   184,   122,   46,    5,    1,    1,
+     740,   340,   213,   165,   129,   270,   168,
+     603,   326,
+  },
+  {  884,   264,   102,   103,   21,    3,    1,   382,   68,
+     897,   897,   836,   836,
+     684,   427,   227,   119,   119,   70,   16,    1,    1,    1,
+     771,   367,   234,   184,   143,   272,   178,
+     555,   326,
+  },
+  {  1028,   347,   153,   161,   36,    8,    1,   251,   44,
+     1083,  1084,   735,   735,
+     541,   289,   144,   77,   57,   23,    3,    1,    1,    1,
+     926,   422,   270,   215,   176,   301,   183,
+     443,   248,
+  },
+  {  1155,   465,   224,   264,   71,   14,    3,   174,   27,
+     1110,  1111,   730,   731,
+     429,   206,   79,   30,   19,    4,    1,    1,    1,    1,
+     929,   443,   279,   225,   194,   298,   196,
+     354,   223,
+  },
+  {  1191,   576,   296,   415,   144,   36,    8,   114,   16,
+     1162,  1162,   749,   749,
+     338,   108,   29,    8,    5,    1,    1,    1,    1,    1,
+     947,   458,   273,   207,   194,   248,   145,
+     258,   152,
+  },
+  {  1169,   619,   366,   603,   247,   92,   23,   46,    1,
+     1236,  1236,   774,   775,
+     191,   35,   14,    1,    1,    1,    1,    1,    1,    1,
+     913,   449,   260,   214,   194,   180,   82,
+     174,   98,
+  },
+  {  1006,   537,   381,   897,   504,   266,   101,   39,    1,
+     1307,  1307,   668,   667,
+     116,    3,    1,    1,    1,    1,    1,    1,    1,    1,
+     1175,   261,   295,   70,   164,   107,   31,
+     10,   76,
+  },
+  /* AC Inter bias group 3 tables */
+  {  652,   156,   53,   43,    5,    1,    1,   368,   128,
+     983,   984,   825,   825,
+     583,   331,   163,   88,   84,   48,   15,    1,    1,    1,
+     870,   480,   316,   228,   179,   421,   244,
+     562,   349,
+  },
+  {  988,   280,   104,   87,   12,    1,    1,   282,   194,
+     980,   981,   738,   739,
+     395,   189,   80,   37,   31,   12,    2,    1,    1,    1,
+     862,   489,   333,   262,   214,   600,   446,
+     390,   260,
+  },
+  {  1176,   399,   165,   154,   24,    2,    1,   218,   224,
+     1017,  1018,   651,   651,
+     280,   111,   42,   16,    9,    3,    1,    1,    1,    1,
+     787,   469,   324,   269,   229,   686,   603,
+     267,   194,
+  },
+  {  1319,   530,   255,   268,   47,    4,    1,   113,   183,
+     1149,  1150,   461,   461,
+     173,   58,   17,    5,    3,    1,    1,    1,    1,    1,
+     768,   450,   305,   261,   221,   716,   835,
+     136,   97,
+  },
+  {  1362,   669,   355,   465,   104,    9,    1,   76,   153,
+     1253,  1253,   398,   397,
+     102,   21,    5,    1,    1,    1,    1,    1,    1,    1,
+     596,   371,   238,   228,   196,   660,   954,
+     68,   53,
+  },
+  {  1354,   741,   446,   702,   174,   15,    1,   38,   87,
+     1498,  1498,   294,   294,
+     43,    7,    1,    1,    1,    1,    1,    1,    1,    1,
+     381,   283,   165,   181,   155,   544,  1039,
+     25,   21,
+  },
+  {  1262,   885,   546,   947,   263,   18,    1,   18,   27,
+     1908,  1908,   163,   162,
+     14,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+     195,   152,   83,   125,   109,   361,   827,
+     7,    5,
+  },
+  {  2539,   951,   369,   554,   212,   18,    1,    1,    1,
+     2290,  2289,   64,   64,
+     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+     18,   18,    9,   55,   36,   184,   323,
+     1,    1,
+  },
+
+
+  /* AC Intra bias group 4 tables */
+  {  921,   264,   101,   100,   19,    2,    1,   331,   98,
+     1015,  1016,   799,   799,
+     512,   269,   119,   60,   50,   17,    1,    1,    1,    1,
+     841,   442,   307,   222,   182,   493,   256,
+     438,   310,
+  },
+  {  1147,   412,   184,   206,   50,    6,    1,   242,   141,
+     977,   976,   808,   807,
+     377,   135,   40,   10,    7,    1,    1,    1,    1,    1,
+     788,   402,   308,   223,   205,   584,   406,
+     316,   227,
+  },
+  {  1243,   504,   238,   310,   79,   11,    1,   184,   150,
+     983,   984,   814,   813,
+     285,   56,   10,    1,    1,    1,    1,    1,    1,    1,
+     713,   377,   287,   217,   180,   615,   558,
+     208,   164,
+  },
+  {  1266,   606,   329,   484,   161,   27,    1,   79,   92,
+     1187,  1188,   589,   588,
+     103,   10,    1,    1,    1,    1,    1,    1,    1,    1,
+     680,   371,   278,   221,   244,   614,   728,
+     80,   62,
+  },
+  {  1126,   828,   435,   705,   443,   90,    8,   10,   55,
+     1220,  1219,   350,   350,
+     28,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+     602,   330,   222,   168,   158,   612,   919,
+     104,    5,
+  },
+  {  1210,   506,  1014,   926,   474,   240,    4,    1,    44,
+     1801,  1801,   171,   171,
+     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+     900,   132,    36,    11,    47,   191,   316,
+     2,    1,
+  },
+  {  1210,   506,  1014,   926,   474,   240,    4,    1,    44,
+     1801,  1801,   171,   171,
+     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+     900,   132,    36,    11,    47,   191,   316,
+     2,    1,
+  },
+  {  1210,   506,  1014,   926,   474,   240,    4,    1,    44,
+     1801,  1801,   171,   171,
+     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+     900,   132,    36,    11,    47,   191,   316,
+     2,    1,
+  },
+  /* AC Inter bias group 4 tables */
+  {  1064,   325,   129,   117,    20,    2,    1,   266,   121,
+     1000,  1000,   706,   706,
+     348,   162,    67,    32,    25,    11,    1,    1,    1,    1,
+     876,   513,   363,   274,   225,   627,   384,
+     370,   251,
+  },
+  {  1311,   517,   238,   254,    45,    3,    1,   188,   160,
+     1070,  1070,   635,   635,
+     239,    85,    30,    11,    6,    1,    1,    1,    1,    1,
+     744,   420,   313,   239,   206,   649,   541,
+     221,   155,
+  },
+  {  1394,   632,   322,   385,    78,    7,    1,   134,   152,
+     1163,  1164,   607,   607,
+     185,    51,    12,    3,    1,    1,    1,    1,    1,    1,
+     631,   331,   275,   203,   182,   604,   620,
+     146,    98,
+  },
+  {  1410,   727,   407,   546,   146,    19,    1,    67,    88,
+     1485,  1486,   419,   418,
+     103,    18,    3,    1,    1,    1,    1,    1,    1,    1,
+     555,   261,   234,   164,   148,   522,   654,
+      67,    39,
+  },
+  {  1423,   822,   492,   719,   216,    22,    1,    28,    59,
+     1793,  1793,   323,   324,
+     37,    2,    1,    1,    1,    1,    1,    1,    1,    1,
+     376,   138,   158,   102,   119,   400,   604,
+     28,    9,
+  },
+  {  1585,   923,   563,   918,   207,    25,    1,    5,    20,
+     2229,  2230,   172,   172,
+     7,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+     191,    40,    56,    22,    65,   243,   312,
+     2,    1,
+  },
+  {  2225,  1100,   408,   608,   133,    8,    1,    1,    1,
+     2658,  2658,    25,    24,
+     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+     8,    1,    1,    1,    1,   125,    16,
+     1,    1,
+  },
+  {  2539,   951,   369,   554,   212,    18,    1,    1,    1,
+     2290,  2289,    64,    64,
+     1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+     18,    18,    9,    55,    36,   184,   323,
+     1,    1,
+  },
+};
+
+#endif /* NEW_FREQS */
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/mathops.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/mathops.c
new file mode 100644
index 0000000..97f0146
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/mathops.c
@@ -0,0 +1,296 @@
+#include "mathops.h"
+#include <limits.h>
+
+/*The fastest fallback strategy for platforms with fast multiplication appears
+   to be based on de Bruijn sequences~\cite{LP98}.
+  Tests confirmed this to be true even on an ARM11, where it is actually faster
+   than using the native clz instruction.
+  Define OC_ILOG_NODEBRUIJN to use a simpler fallback on platforms where
+   multiplication or table lookups are too expensive.
+
+  @UNPUBLISHED{LP98,
+    author="Charles E. Leiserson and Harald Prokop",
+    title="Using de {Bruijn} Sequences to Index a 1 in a Computer Word",
+    month=Jun,
+    year=1998,
+    note="\url{http://supertech.csail.mit.edu/papers/debruijn.pdf}"
+  }*/
+#if !defined(OC_ILOG_NODEBRUIJN)&& \
+ !defined(OC_CLZ32)||!defined(OC_CLZ64)&&LONG_MAX<9223372036854775807LL
+static const unsigned char OC_DEBRUIJN_IDX32[32]={
+   0, 1,28, 2,29,14,24, 3,30,22,20,15,25,17, 4, 8,
+  31,27,13,23,21,19,16, 7,26,12,18, 6,11, 5,10, 9
+};
+#endif
+
+int oc_ilog32(ogg_uint32_t _v){
+#if defined(OC_CLZ32)
+  return (OC_CLZ32_OFFS-OC_CLZ32(_v))&-!!_v;
+#else
+/*On a Pentium M, this branchless version tested as the fastest version without
+   multiplications on 1,000,000,000 random 32-bit integers, edging out a
+   similar version with branches, and a 256-entry LUT version.*/
+# if defined(OC_ILOG_NODEBRUIJN)
+  int ret;
+  int m;
+  ret=_v>0;
+  m=(_v>0xFFFFU)<<4;
+  _v>>=m;
+  ret|=m;
+  m=(_v>0xFFU)<<3;
+  _v>>=m;
+  ret|=m;
+  m=(_v>0xFU)<<2;
+  _v>>=m;
+  ret|=m;
+  m=(_v>3)<<1;
+  _v>>=m;
+  ret|=m;
+  ret+=_v>1;
+  return ret;
+/*This de Bruijn sequence version is faster if you have a fast multiplier.*/
+# else
+  int ret;
+  ret=_v>0;
+  _v|=_v>>1;
+  _v|=_v>>2;
+  _v|=_v>>4;
+  _v|=_v>>8;
+  _v|=_v>>16;
+  _v=(_v>>1)+1;
+  ret+=OC_DEBRUIJN_IDX32[_v*0x77CB531U>>27&0x1F];
+  return ret;
+# endif
+#endif
+}
+
+int oc_ilog64(ogg_int64_t _v){
+#if defined(OC_CLZ64)
+  return (OC_CLZ64_OFFS-OC_CLZ64(_v))&-!!_v;
+#else
+# if defined(OC_ILOG_NODEBRUIJN)
+  ogg_uint32_t v;
+  int          ret;
+  int          m;
+  ret=_v>0;
+  m=(_v>0xFFFFFFFFU)<<5;
+  v=(ogg_uint32_t)(_v>>m);
+  ret|=m;
+  m=(v>0xFFFFU)<<4;
+  v>>=m;
+  ret|=m;
+  m=(v>0xFFU)<<3;
+  v>>=m;
+  ret|=m;
+  m=(v>0xFU)<<2;
+  v>>=m;
+  ret|=m;
+  m=(v>3)<<1;
+  v>>=m;
+  ret|=m;
+  ret+=v>1;
+  return ret;
+# else
+/*If we don't have a 64-bit word, split it into two 32-bit halves.*/
+#  if LONG_MAX<9223372036854775807LL
+  ogg_uint32_t v;
+  int          ret;
+  int          m;
+  ret=_v>0;
+  m=(_v>0xFFFFFFFFU)<<5;
+  v=(ogg_uint32_t)(_v>>m);
+  ret|=m;
+  v|=v>>1;
+  v|=v>>2;
+  v|=v>>4;
+  v|=v>>8;
+  v|=v>>16;
+  v=(v>>1)+1;
+  ret+=OC_DEBRUIJN_IDX32[v*0x77CB531U>>27&0x1F];
+  return ret;
+/*Otherwise do it in one 64-bit operation.*/
+#  else
+  static const unsigned char OC_DEBRUIJN_IDX64[64]={
+     0, 1, 2, 7, 3,13, 8,19, 4,25,14,28, 9,34,20,40,
+     5,17,26,38,15,46,29,48,10,31,35,54,21,50,41,57,
+    63, 6,12,18,24,27,33,39,16,37,45,47,30,53,49,56,
+    62,11,23,32,36,44,52,55,61,22,43,51,60,42,59,58
+  };
+  int ret;
+  ret=_v>0;
+  _v|=_v>>1;
+  _v|=_v>>2;
+  _v|=_v>>4;
+  _v|=_v>>8;
+  _v|=_v>>16;
+  _v|=_v>>32;
+  _v=(_v>>1)+1;
+  ret+=OC_DEBRUIJN_IDX64[_v*0x218A392CD3D5DBF>>58&0x3F];
+  return ret;
+#  endif
+# endif
+#endif
+}
+
+/*round(2**(62+i)*atanh(2**(-(i+1)))/log(2))*/
+static const ogg_int64_t OC_ATANH_LOG2[32]={
+  0x32B803473F7AD0F4LL,0x2F2A71BD4E25E916LL,0x2E68B244BB93BA06LL,
+  0x2E39FB9198CE62E4LL,0x2E2E683F68565C8FLL,0x2E2B850BE2077FC1LL,
+  0x2E2ACC58FE7B78DBLL,0x2E2A9E2DE52FD5F2LL,0x2E2A92A338D53EECLL,
+  0x2E2A8FC08F5E19B6LL,0x2E2A8F07E51A485ELL,0x2E2A8ED9BA8AF388LL,
+  0x2E2A8ECE2FE7384ALL,0x2E2A8ECB4D3E4B1ALL,0x2E2A8ECA94940FE8LL,
+  0x2E2A8ECA6669811DLL,0x2E2A8ECA5ADEDD6ALL,0x2E2A8ECA57FC347ELL,
+  0x2E2A8ECA57438A43LL,0x2E2A8ECA57155FB4LL,0x2E2A8ECA5709D510LL,
+  0x2E2A8ECA5706F267LL,0x2E2A8ECA570639BDLL,0x2E2A8ECA57060B92LL,
+  0x2E2A8ECA57060008LL,0x2E2A8ECA5705FD25LL,0x2E2A8ECA5705FC6CLL,
+  0x2E2A8ECA5705FC3ELL,0x2E2A8ECA5705FC33LL,0x2E2A8ECA5705FC30LL,
+  0x2E2A8ECA5705FC2FLL,0x2E2A8ECA5705FC2FLL
+};
+
+/*Computes the binary exponential of _log2, a log base 2 in Q57 format.*/
+ogg_int64_t oc_bexp64(ogg_int64_t _z){
+  ogg_int64_t w;
+  ogg_int64_t z;
+  int         ipart;
+  ipart=(int)(_z>>57);
+  if(ipart<0)return 0;
+  if(ipart>=63)return 0x7FFFFFFFFFFFFFFFLL;
+  z=_z-OC_Q57(ipart);
+  if(z){
+    ogg_int64_t mask;
+    long        wlo;
+    int         i;
+    /*C doesn't give us 64x64->128 muls, so we use CORDIC.
+      This is not particularly fast, but it's not being used in time-critical
+       code; it is very accurate.*/
+    /*z is the fractional part of the log in Q62 format.
+      We need 1 bit of headroom since the magnitude can get larger than 1
+       during the iteration, and a sign bit.*/
+    z<<=5;
+    /*w is the exponential in Q61 format (since it also needs headroom and can
+       get as large as 2.0); we could get another bit if we dropped the sign,
+       but we'll recover that bit later anyway.
+      Ideally this should start out as
+        \lim_{n->\infty} 2^{61}/\product_{i=1}^n \sqrt{1-2^{-2i}}
+       but in order to guarantee convergence we have to repeat iterations 4,
+        13 (=3*4+1), and 40 (=3*13+1, etc.), so it winds up somewhat larger.*/
+    w=0x26A3D0E401DD846DLL;
+    for(i=0;;i++){
+      mask=-(z<0);
+      w+=(w>>i+1)+mask^mask;
+      z-=OC_ATANH_LOG2[i]+mask^mask;
+      /*Repeat iteration 4.*/
+      if(i>=3)break;
+      z<<=1;
+    }
+    for(;;i++){
+      mask=-(z<0);
+      w+=(w>>i+1)+mask^mask;
+      z-=OC_ATANH_LOG2[i]+mask^mask;
+      /*Repeat iteration 13.*/
+      if(i>=12)break;
+      z<<=1;
+    }
+    for(;i<32;i++){
+      mask=-(z<0);
+      w+=(w>>i+1)+mask^mask;
+      z=z-(OC_ATANH_LOG2[i]+mask^mask)<<1;
+    }
+    wlo=0;
+    /*Skip the remaining iterations unless we really require that much
+       precision.
+      We could have bailed out earlier for smaller iparts, but that would
+       require initializing w from a table, as the limit doesn't converge to
+       61-bit precision until n=30.*/
+    if(ipart>30){
+      /*For these iterations, we just update the low bits, as the high bits
+         can't possibly be affected.
+        OC_ATANH_LOG2 has also converged (it actually did so one iteration
+         earlier, but that's no reason for an extra special case).*/
+      for(;;i++){
+        mask=-(z<0);
+        wlo+=(w>>i)+mask^mask;
+        z-=OC_ATANH_LOG2[31]+mask^mask;
+        /*Repeat iteration 40.*/
+        if(i>=39)break;
+        z<<=1;
+      }
+      for(;i<61;i++){
+        mask=-(z<0);
+        wlo+=(w>>i)+mask^mask;
+        z=z-(OC_ATANH_LOG2[31]+mask^mask)<<1;
+      }
+    }
+    w=(w<<1)+wlo;
+  }
+  else w=(ogg_int64_t)1<<62;
+  if(ipart<62)w=(w>>61-ipart)+1>>1;
+  return w;
+}
+
+/*Computes the binary logarithm of _w, returned in Q57 format.*/
+ogg_int64_t oc_blog64(ogg_int64_t _w){
+  ogg_int64_t z;
+  int         ipart;
+  if(_w<=0)return -1;
+  ipart=OC_ILOGNZ_64(_w)-1;
+  if(ipart>61)_w>>=ipart-61;
+  else _w<<=61-ipart;
+  z=0;
+  if(_w&_w-1){
+    ogg_int64_t x;
+    ogg_int64_t y;
+    ogg_int64_t u;
+    ogg_int64_t mask;
+    int         i;
+    /*C doesn't give us 64x64->128 muls, so we use CORDIC.
+      This is not particularly fast, but it's not being used in time-critical
+       code; it is very accurate.*/
+    /*z is the fractional part of the log in Q61 format.*/
+    /*x and y are the cosh() and sinh(), respectively, in Q61 format.
+      We are computing z=2*atanh(y/x)=2*atanh((_w-1)/(_w+1)).*/
+    x=_w+((ogg_int64_t)1<<61);
+    y=_w-((ogg_int64_t)1<<61);
+    for(i=0;i<4;i++){
+      mask=-(y<0);
+      z+=(OC_ATANH_LOG2[i]>>i)+mask^mask;
+      u=x>>i+1;
+      x-=(y>>i+1)+mask^mask;
+      y-=u+mask^mask;
+    }
+    /*Repeat iteration 4.*/
+    for(i--;i<13;i++){
+      mask=-(y<0);
+      z+=(OC_ATANH_LOG2[i]>>i)+mask^mask;
+      u=x>>i+1;
+      x-=(y>>i+1)+mask^mask;
+      y-=u+mask^mask;
+    }
+    /*Repeat iteration 13.*/
+    for(i--;i<32;i++){
+      mask=-(y<0);
+      z+=(OC_ATANH_LOG2[i]>>i)+mask^mask;
+      u=x>>i+1;
+      x-=(y>>i+1)+mask^mask;
+      y-=u+mask^mask;
+    }
+    /*OC_ATANH_LOG2 has converged.*/
+    for(;i<40;i++){
+      mask=-(y<0);
+      z+=(OC_ATANH_LOG2[31]>>i)+mask^mask;
+      u=x>>i+1;
+      x-=(y>>i+1)+mask^mask;
+      y-=u+mask^mask;
+    }
+    /*Repeat iteration 40.*/
+    for(i--;i<62;i++){
+      mask=-(y<0);
+      z+=(OC_ATANH_LOG2[31]>>i)+mask^mask;
+      u=x>>i+1;
+      x-=(y>>i+1)+mask^mask;
+      y-=u+mask^mask;
+    }
+    z=z+8>>4;
+  }
+  return OC_Q57(ipart)+z;
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/mathops.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/mathops.h
new file mode 100644
index 0000000..d3f7479
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/mathops.h
@@ -0,0 +1,142 @@
+#if !defined(_mathops_H)
+# define _mathops_H (1)
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+# include <vtkoggtheora/include/ogg/ogg.h>
+
+# ifdef __GNUC_PREREQ
+#  if __GNUC_PREREQ(3,4)
+#   include <limits.h>
+/*Note the casts to (int) below: this prevents OC_CLZ{32|64}_OFFS from
+   "upgrading" the type of an entire expression to an (unsigned) size_t.*/
+#   if INT_MAX>=2147483647
+#    define OC_CLZ32_OFFS ((int)sizeof(unsigned)*CHAR_BIT)
+#    define OC_CLZ32(_x) (__builtin_clz(_x))
+#   elif LONG_MAX>=2147483647L
+#    define OC_CLZ32_OFFS ((int)sizeof(unsigned long)*CHAR_BIT)
+#    define OC_CLZ32(_x) (__builtin_clzl(_x))
+#   endif
+#   if INT_MAX>=9223372036854775807LL
+#    define OC_CLZ64_OFFS ((int)sizeof(unsigned)*CHAR_BIT)
+#    define OC_CLZ64(_x) (__builtin_clz(_x))
+#   elif LONG_MAX>=9223372036854775807LL
+#    define OC_CLZ64_OFFS ((int)sizeof(unsigned long)*CHAR_BIT)
+#    define OC_CLZ64(_x) (__builtin_clzl(_x))
+#   elif LLONG_MAX>=9223372036854775807LL|| \
+     __LONG_LONG_MAX__>=9223372036854775807LL
+#    define OC_CLZ64_OFFS ((int)sizeof(unsigned long long)*CHAR_BIT)
+#    define OC_CLZ64(_x) (__builtin_clzll(_x))
+#   endif
+#  endif
+# endif
+
+
+
+/**
+ * oc_ilog32 - Integer binary logarithm of a 32-bit value.
+ * @_v: A 32-bit value.
+ * Returns floor(log2(_v))+1, or 0 if _v==0.
+ * This is the number of bits that would be required to represent _v in two's
+ *  complement notation with all of the leading zeros stripped.
+ * The OC_ILOG_32() or OC_ILOGNZ_32() macros may be able to use a builtin
+ *  function instead, which should be faster.
+ */
+int oc_ilog32(ogg_uint32_t _v);
+/**
+ * oc_ilog64 - Integer binary logarithm of a 64-bit value.
+ * @_v: A 64-bit value.
+ * Returns floor(log2(_v))+1, or 0 if _v==0.
+ * This is the number of bits that would be required to represent _v in two's
+ *  complement notation with all of the leading zeros stripped.
+ * The OC_ILOG_64() or OC_ILOGNZ_64() macros may be able to use a builtin
+ *  function instead, which should be faster.
+ */
+int oc_ilog64(ogg_int64_t _v);
+
+
+# if defined(OC_CLZ32)
+/**
+ * OC_ILOGNZ_32 - Integer binary logarithm of a non-zero 32-bit value.
+ * @_v: A non-zero 32-bit value.
+ * Returns floor(log2(_v))+1.
+ * This is the number of bits that would be required to represent _v in two's
+ *  complement notation with all of the leading zeros stripped.
+ * If _v is zero, the return value is undefined; use OC_ILOG_32() instead.
+ */
+#  define OC_ILOGNZ_32(_v) (OC_CLZ32_OFFS-OC_CLZ32(_v))
+/**
+ * OC_ILOG_32 - Integer binary logarithm of a 32-bit value.
+ * @_v: A 32-bit value.
+ * Returns floor(log2(_v))+1, or 0 if _v==0.
+ * This is the number of bits that would be required to represent _v in two's
+ *  complement notation with all of the leading zeros stripped.
+ */
+#  define OC_ILOG_32(_v)   (OC_ILOGNZ_32(_v)&-!!(_v))
+# else
+#  define OC_ILOGNZ_32(_v) (oc_ilog32(_v))
+#  define OC_ILOG_32(_v)   (oc_ilog32(_v))
+# endif
+
+# if defined(CLZ64)
+/**
+ * OC_ILOGNZ_64 - Integer binary logarithm of a non-zero 64-bit value.
+ * @_v: A non-zero 64-bit value.
+ * Returns floor(log2(_v))+1.
+ * This is the number of bits that would be required to represent _v in two's
+ *  complement notation with all of the leading zeros stripped.
+ * If _v is zero, the return value is undefined; use OC_ILOG_64() instead.
+ */
+#  define OC_ILOGNZ_64(_v) (CLZ64_OFFS-CLZ64(_v))
+/**
+ * OC_ILOG_64 - Integer binary logarithm of a 64-bit value.
+ * @_v: A 64-bit value.
+ * Returns floor(log2(_v))+1, or 0 if _v==0.
+ * This is the number of bits that would be required to represent _v in two's
+ *  complement notation with all of the leading zeros stripped.
+ */
+#  define OC_ILOG_64(_v)   (OC_ILOGNZ_64(_v)&-!!(_v))
+# else
+#  define OC_ILOGNZ_64(_v) (oc_ilog64(_v))
+#  define OC_ILOG_64(_v)   (oc_ilog64(_v))
+# endif
+
+# define OC_STATIC_ILOG0(_v) (!!(_v))
+# define OC_STATIC_ILOG1(_v) (((_v)&0x2)?2:OC_STATIC_ILOG0(_v))
+# define OC_STATIC_ILOG2(_v) \
+ (((_v)&0xC)?2+OC_STATIC_ILOG1((_v)>>2):OC_STATIC_ILOG1(_v))
+# define OC_STATIC_ILOG3(_v) \
+ (((_v)&0xF0)?4+OC_STATIC_ILOG2((_v)>>4):OC_STATIC_ILOG2(_v))
+# define OC_STATIC_ILOG4(_v) \
+ (((_v)&0xFF00)?8+OC_STATIC_ILOG3((_v)>>8):OC_STATIC_ILOG3(_v))
+# define OC_STATIC_ILOG5(_v) \
+ (((_v)&0xFFFF0000)?16+OC_STATIC_ILOG4((_v)>>16):OC_STATIC_ILOG4(_v))
+# define OC_STATIC_ILOG6(_v) \
+ (((_v)&0xFFFFFFFF00000000ULL)?32+OC_STATIC_ILOG5((_v)>>32):OC_STATIC_ILOG5(_v))
+/**
+ * OC_STATIC_ILOG_32 - The integer logarithm of an (unsigned, 32-bit) constant.
+ * @_v: A non-negative 32-bit constant.
+ * Returns floor(log2(_v))+1, or 0 if _v==0.
+ * This is the number of bits that would be required to represent _v in two's
+ *  complement notation with all of the leading zeros stripped.
+ * This macro is suitable for evaluation at compile time, but it should not be
+ *  used on values that can change at runtime, as it operates via exhaustive
+ *  search.
+ */
+# define OC_STATIC_ILOG_32(_v) (OC_STATIC_ILOG5((ogg_uint32_t)(_v)))
+/**
+ * OC_STATIC_ILOG_64 - The integer logarithm of an (unsigned, 64-bit) constant.
+ * @_v: A non-negative 64-bit constant.
+ * Returns floor(log2(_v))+1, or 0 if _v==0.
+ * This is the number of bits that would be required to represent _v in two's
+ *  complement notation with all of the leading zeros stripped.
+ * This macro is suitable for evaluation at compile time, but it should not be
+ *  used on values that can change at runtime, as it operates via exhaustive
+ *  search.
+ */
+# define OC_STATIC_ILOG_64(_v) (OC_STATIC_ILOG6((ogg_int64_t)(_v)))
+
+#define OC_Q57(_v) ((ogg_int64_t)(_v)<<57)
+
+ogg_int64_t oc_bexp64(ogg_int64_t _z);
+ogg_int64_t oc_blog64(ogg_int64_t _w);
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/mcenc.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/mcenc.c
new file mode 100644
index 0000000..e29cc30
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/mcenc.c
@@ -0,0 +1,757 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2008                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id$
+
+ ********************************************************************/
+
+#include <stdlib.h>
+#include <limits.h>
+#include <string.h>
+#include "codec_internal.h"
+
+/*The maximum Y plane SAD value for accepting the median predictor.*/
+#define OC_YSAD_THRESH1            (256)
+/*The amount to right shift the minimum error by when inflating it for
+   computing the second maximum Y plane SAD threshold.*/
+#define OC_YSAD_THRESH2_SCALE_BITS (4)
+/*The amount to add to the second maximum Y plane threshold when inflating
+   it.*/
+#define OC_YSAD_THRESH2_OFFSET     (64)
+
+/*The vector offsets in the X direction for each search site in the square
+   pattern.*/
+static const int OC_SQUARE_DX[9]={-1,0,1,-1,0,1,-1,0,1};
+/*The vector offsets in the Y direction for each search site in the square
+   pattern.*/
+static const int OC_SQUARE_DY[9]={-1,-1,-1,0,0,0,1,1,1};
+/*The number of sites to search for each boundary condition in the square
+   pattern.
+  Bit flags for the boundary conditions are as follows:
+  1: -16==dx
+  2:      dx==15(.5)
+  4: -16==dy
+  8:      dy==15(.5)*/
+static const int OC_SQUARE_NSITES[11]={8,5,5,0,5,3,3,0,5,3,3};
+/*The list of sites to search for each boundary condition in the square
+   pattern.*/
+static const int OC_SQUARE_SITES[11][8]={
+  /* -15.5<dx<31,       -15.5<dy<15(.5)*/
+  {0,1,2,3,5,6,7,8},
+  /*-15.5==dx,          -15.5<dy<15(.5)*/
+  {1,2,5,7,8},
+  /*     dx==15(.5),    -15.5<dy<15(.5)*/
+  {0,1,3,6,7},
+  /*-15.5==dx==15(.5),  -15.5<dy<15(.5)*/
+  {-1},
+  /* -15.5<dx<15(.5),  -15.5==dy*/
+  {3,5,6,7,8},
+  /*-15.5==dx,         -15.5==dy*/
+  {5,7,8},
+  /*     dx==15(.5),   -15.5==dy*/
+  {3,6,7},
+  /*-15.5==dx==15(.5), -15.5==dy*/
+  {-1},
+  /*-15.5dx<15(.5),           dy==15(.5)*/
+  {0,1,2,3,5},
+  /*-15.5==dx,                dy==15(.5)*/
+  {1,2,5},
+  /*       dx==15(.5),        dy==15(.5)*/
+  {0,1,3}
+};
+
+
+static void oc_mcenc_find_candidates(CP_INSTANCE *cpi,mc_state *_mcenc,
+ int _mbi,int _goldenp){
+  macroblock_t *nemb;
+  macroblock_t *emb;
+  ogg_int32_t   mvapw1;
+  ogg_int32_t   mvapw2;
+  int           a[3][2];
+  int           ncandidates;
+  int           i;
+  emb=cpi->macro+_mbi;
+  if(emb->ncneighbors>0){
+    /*Fill in the first part of set A: the last motion vectors used and the
+       vectors from adjacent blocks.*/
+    /*Skip a position to store the median predictor in.*/
+    ncandidates=1;
+    for(i=0;i<emb->ncneighbors;i++){
+      nemb=cpi->macro+emb->cneighbors[i];
+      _mcenc->candidates[ncandidates][0]=nemb->analysis_mv[0][_goldenp][0];
+      _mcenc->candidates[ncandidates][1]=nemb->analysis_mv[0][_goldenp][1];
+      ncandidates++;
+    }
+    /*Add a few additional vectors to set A: the vector used in the
+       previous frame and the (0,0) vector.*/
+    _mcenc->candidates[ncandidates][0]=emb->analysis_mv[1][_goldenp][0];
+    _mcenc->candidates[ncandidates][1]=emb->analysis_mv[1][_goldenp][1];
+    ncandidates++;
+    _mcenc->candidates[ncandidates][0]=0;
+    _mcenc->candidates[ncandidates][1]=0;
+    ncandidates++;
+    /*Use the first three vectors of set A to find our best predictor: their
+       median.*/
+    memcpy(a,_mcenc->candidates+1,sizeof(a));
+    OC_SORT2I(a[0][0],a[1][0]);
+    OC_SORT2I(a[0][1],a[1][1]);
+    OC_SORT2I(a[1][0],a[2][0]);
+    OC_SORT2I(a[1][1],a[2][1]);
+    OC_SORT2I(a[0][0],a[1][0]);
+    OC_SORT2I(a[0][1],a[1][1]);
+    _mcenc->candidates[0][0]=a[1][0];
+    _mcenc->candidates[0][1]=a[1][1];
+  }
+  else{
+    /*The upper-left most macro block has no neighbors at all
+      We just use 0,0 as the median predictor and its previous motion vector
+      for set A.*/
+    _mcenc->candidates[0][0]=0;
+    _mcenc->candidates[0][1]=1;
+    _mcenc->candidates[1][0]=emb->analysis_mv[1][_goldenp][0];
+    _mcenc->candidates[1][1]=emb->analysis_mv[1][_goldenp][1];
+    ncandidates=2;
+  }
+  /*Fill in set B: accelerated predictors for this and adjacent macro
+     blocks.*/
+  _mcenc->setb0=ncandidates;
+  mvapw1=_mcenc->mvapw1[_goldenp];
+  mvapw2=_mcenc->mvapw2[_goldenp];
+  /*The first time through the loop use the current macro block.*/
+  nemb=emb;
+  for(i=0;;i++){
+    _mcenc->candidates[ncandidates][0]=OC_CLAMPI(-31,
+     OC_DIV_POW2_RE(nemb->analysis_mv[1][_goldenp][0]*mvapw1
+     -nemb->analysis_mv[2][_goldenp][0]*mvapw2,16),31);
+    _mcenc->candidates[ncandidates][1]=OC_CLAMPI(-31,
+     OC_DIV_POW2_RE(nemb->analysis_mv[1][_goldenp][1]*mvapw1
+     -nemb->analysis_mv[2][_goldenp][1]*mvapw2,16),31);
+    ncandidates++;
+    if(i>=emb->npneighbors)break;
+    nemb=cpi->macro+emb->pneighbors[i];
+  }
+  /*Truncate to full-pel positions.*/
+  for(i=0;i<ncandidates;i++){
+    _mcenc->candidates[i][0]=OC_DIV2(_mcenc->candidates[i][0]);
+    _mcenc->candidates[i][1]=OC_DIV2(_mcenc->candidates[i][1]);
+  }
+  _mcenc->ncandidates=ncandidates;
+}
+
+#if 0
+static int oc_sad16_halfpel(CP_INSTANCE *cpi,int mbi,
+ int _mvoffset0,int _mvoffset1,int _goldenp,int _best_err){
+  macroblock_t *mb;
+  int           err;
+  int           bi;
+  mb=cpi->macro+mbi;
+  err=0;
+  for(bi=0;bi<4;bi++){
+    const unsigned char *cur;
+    const unsigned char *ref;
+    ogg_uint32_t         base_offset;
+    int                  fi;
+    fi=mb->Ryuv[0][bi];
+    base_offset=cpi->frag_buffer_index[fi];
+    cur=cpi->frame+base_offset;
+    ref=(_goldenp?cpi->golden:cpi->lastrecon)+base_offset;
+    err+=oc_enc_frag_sad2_thresh(cpi,cur,
+     ref+_mvoffset0,ref+_mvoffset1,cpi->stride[0],_best_err-err);
+  }
+  return err;
+}
+#endif
+
+static int oc_satd16_halfpel(CP_INSTANCE *cpi,int mbi,
+ int _mvoffset0,int _mvoffset1,int _goldenp,int _best_err){
+  macroblock_t *mb;
+  int           err;
+  int           bi;
+  mb=cpi->macro+mbi;
+  err=0;
+  for(bi=0;bi<4;bi++){
+    const unsigned char *cur;
+    const unsigned char *ref;
+    ogg_uint32_t         base_offset;
+    int                  fi;
+    fi=mb->Ryuv[0][bi];
+    base_offset=cpi->frag_buffer_index[fi];
+    cur=cpi->frame+base_offset;
+    ref=(_goldenp?cpi->golden:cpi->lastrecon)+base_offset;
+    err+=oc_enc_frag_satd2_thresh(cpi,cur,
+     ref+_mvoffset0,ref+_mvoffset1,cpi->stride[0],_best_err-err);
+  }
+  return err;
+}
+
+static int oc_mcenc_ysad_check_mbcandidate_fullpel(CP_INSTANCE *cpi,
+ int _mbi,int _dx,int _dy,int _goldenp,int _block_err[4]){
+  int           stride;
+  int           mvoffset;
+  int           err;
+  int           bi;
+  macroblock_t *mb;
+  mb=cpi->macro+_mbi;
+  /*TODO: customize error function for speed/(quality+size) tradeoff.*/
+  stride=cpi->stride[0];
+  mvoffset=_dx+_dy*stride;
+  err=0;
+  for(bi=0;bi<4;bi++){
+    const unsigned char *cur;
+    const unsigned char *ref;
+    ogg_uint32_t         base_offset;
+    int                  fi;
+    fi=mb->Ryuv[0][bi];
+    base_offset=cpi->frag_buffer_index[fi];
+    cur=cpi->frame+base_offset;
+    ref=(_goldenp?cpi->golden:cpi->lastrecon)+base_offset;
+    _block_err[bi]=oc_enc_frag_sad(cpi,cur,ref+mvoffset,stride);
+    err+=_block_err[bi];
+  }
+  return err;
+}
+
+static int oc_mcenc_ysatd_check_mbcandidate_fullpel(CP_INSTANCE *cpi,
+ int _mbi,int _dx,int _dy,int _goldenp){
+  int           stride;
+  int           mvoffset;
+  int           err;
+  int           bi;
+  macroblock_t *mb;
+  mb=cpi->macro+_mbi;
+  stride=cpi->stride[0];
+  mvoffset=_dx+_dy*stride;
+  err=0;
+  for(bi=0;bi<4;bi++){
+    const unsigned char *cur;
+    const unsigned char *ref;
+    ogg_uint32_t         base_offset;
+    int                  fi;
+    fi=mb->Ryuv[0][bi];
+    base_offset=cpi->frag_buffer_index[fi];
+    cur=cpi->frame+base_offset;
+    ref=(_goldenp?cpi->golden:cpi->lastrecon)+base_offset;
+    err+=oc_enc_frag_satd_thresh(cpi,cur,ref+mvoffset,stride,0xFF000);
+  }
+  return err;
+}
+
+static int oc_mcenc_ysatd_check_bcandidate_fullpel(CP_INSTANCE *cpi,
+ int _mbi,int _bi,int _dx,int _dy,int _goldenp){
+  macroblock_t        *mb;
+  const unsigned char *cur;
+  const unsigned char *ref;
+  ogg_uint32_t         base_offset;
+  int                  stride;
+  int                  mvoffset;
+  int                  fi;
+  mb=cpi->macro+_mbi;
+  stride=cpi->stride[0];
+  mvoffset=_dx+_dy*stride;
+  fi=mb->Ryuv[0][_bi];
+  base_offset=cpi->frag_buffer_index[fi];
+  cur=cpi->frame+base_offset;
+  ref=(_goldenp?cpi->golden:cpi->lastrecon)+base_offset;
+  return oc_enc_frag_satd_thresh(cpi,cur,ref+mvoffset,stride,0xFF000);
+}
+
+#if 0
+static int oc_mcenc_ysad_halfpel_mbrefine(CP_INSTANCE *cpi,int _mbi,
+ int _vec[2],int _best_err,int _goldenp){
+  int offset_y[9];
+  int stride;
+  int mvoffset_base;
+  int best_site;
+  int sitei;
+  int err;
+  stride=cpi->stride[0];
+  mvoffset_base=_vec[0]+_vec[1]*stride;
+  offset_y[0]=offset_y[1]=offset_y[2]=-stride;
+  offset_y[3]=offset_y[5]=0;
+  offset_y[6]=offset_y[7]=offset_y[8]=stride;
+  best_site=4;
+  for(sitei=0;sitei<8;sitei++){
+    int site;
+    int xmask;
+    int ymask;
+    int dx;
+    int dy;
+    int mvoffset0;
+    int mvoffset1;
+    site=OC_SQUARE_SITES[0][sitei];
+    dx=OC_SQUARE_DX[site];
+    dy=OC_SQUARE_DY[site];
+    /*The following code SHOULD be equivalent to
+        oc_state_get_mv_offsets(&_mcenc->enc.state,&mvoffset0,&mvoffset1,
+         (_vec[0]<<1)+dx,(_vec[1]<<1)+dy,ref_ystride,0);
+      However, it should also be much faster, as it involves no multiplies and
+       doesn't have to handle chroma vectors.*/
+    xmask=OC_SIGNMASK(((_vec[0]<<1)+dx)^dx);
+    ymask=OC_SIGNMASK(((_vec[1]<<1)+dy)^dy);
+    mvoffset0=mvoffset_base+(dx&xmask)+(offset_y[site]&ymask);
+    mvoffset1=mvoffset_base+(dx&~xmask)+(offset_y[site]&~ymask);
+    err=oc_sad16_halfpel(cpi,_mbi,mvoffset0,mvoffset1,_goldenp,_best_err);
+    if(err<_best_err){
+      _best_err=err;
+      best_site=site;
+    }
+  }
+  _vec[0]=(_vec[0]<<1)+OC_SQUARE_DX[best_site];
+  _vec[1]=(_vec[1]<<1)+OC_SQUARE_DY[best_site];
+  return _best_err;
+}
+#endif
+
+static int oc_mcenc_ysatd_halfpel_mbrefine(CP_INSTANCE *cpi,int _mbi,
+ int _vec[2],int _best_err,int _goldenp){
+  int offset_y[9];
+  int stride;
+  int mvoffset_base;
+  int best_site;
+  int sitei;
+  int err;
+  stride=cpi->stride[0];
+  mvoffset_base=_vec[0]+_vec[1]*stride;
+  offset_y[0]=offset_y[1]=offset_y[2]=-stride;
+  offset_y[3]=offset_y[5]=0;
+  offset_y[6]=offset_y[7]=offset_y[8]=stride;
+  best_site=4;
+  for(sitei=0;sitei<8;sitei++){
+    int site;
+    int xmask;
+    int ymask;
+    int dx;
+    int dy;
+    int mvoffset0;
+    int mvoffset1;
+    site=OC_SQUARE_SITES[0][sitei];
+    dx=OC_SQUARE_DX[site];
+    dy=OC_SQUARE_DY[site];
+    /*The following code SHOULD be equivalent to
+        oc_state_get_mv_offsets(&_mcenc->enc.state,&mvoffset0,&mvoffset1,
+         (_vec[0]<<1)+dx,(_vec[1]<<1)+dy,ref_ystride,0);
+      However, it should also be much faster, as it involves no multiplies and
+       doesn't have to handle chroma vectors.*/
+    xmask=OC_SIGNMASK(((_vec[0]<<1)+dx)^dx);
+    ymask=OC_SIGNMASK(((_vec[1]<<1)+dy)^dy);
+    mvoffset0=mvoffset_base+(dx&xmask)+(offset_y[site]&ymask);
+    mvoffset1=mvoffset_base+(dx&~xmask)+(offset_y[site]&~ymask);
+    err=oc_satd16_halfpel(cpi,_mbi,mvoffset0,mvoffset1,_goldenp,_best_err);
+    if(err<_best_err){
+      _best_err=err;
+      best_site=site;
+    }
+  }
+  _vec[0]=(_vec[0]<<1)+OC_SQUARE_DX[best_site];
+  _vec[1]=(_vec[1]<<1)+OC_SQUARE_DY[best_site];
+  return _best_err;
+}
+
+#if 0
+static int oc_mcenc_ysad_halfpel_brefine(CP_INSTANCE *cpi,int _mbi,
+ int _bi,int _vec[2],int _best_err,int _goldenp){
+  macroblock_t *mb;
+  int           offset_y[9];
+  int           stride;
+  int           mvoffset_base;
+  int           best_site;
+  int           sitei;
+  int           err;
+  int           fi;
+  mb=cpi->macro+_mbi;
+  stride=cpi->stride[0];
+  fi=mb->Ryuv[0][_bi];
+  mvoffset_base=_vec[0]+_vec[1]*stride;
+  offset_y[0]=offset_y[1]=offset_y[2]=-stride;
+  offset_y[3]=offset_y[5]=0;
+  offset_y[6]=offset_y[7]=offset_y[8]=stride;
+  best_site=4;
+  for(sitei=0;sitei<8;sitei++){
+    ogg_uint32_t         base_offset;
+    const unsigned char *cur;
+    const unsigned char *ref;
+    int                  site;
+    int                  xmask;
+    int                  ymask;
+    int                  dx;
+    int                  dy;
+    int                  mvoffset0;
+    int                  mvoffset1;
+    base_offset=cpi->frag_buffer_index[fi];
+    cur=cpi->frame+base_offset;
+    ref=(_goldenp?cpi->golden:cpi->lastrecon)+base_offset;
+    site=OC_SQUARE_SITES[0][sitei];
+    dx=OC_SQUARE_DX[site];
+    dy=OC_SQUARE_DY[site];
+    /*The following code SHOULD be equivalent to
+        oc_state_get_mv_offsets(&_mcenc->enc.state,&mvoffset0,&mvoffset1,
+         (_vec[0]<<1)+dx,(_vec[1]<<1)+dy,ref_ystride,0);
+      However, it should also be much faster, as it involves no multiplies and
+       doesn't have to handle chroma vectors.*/
+    xmask=OC_SIGNMASK(((_vec[0]<<1)+dx)^dx);
+    ymask=OC_SIGNMASK(((_vec[1]<<1)+dy)^dy);
+    mvoffset0=mvoffset_base+(dx&xmask)+(offset_y[site]&ymask);
+    mvoffset1=mvoffset_base+(dx&~xmask)+(offset_y[site]&~ymask);
+    err=oc_enc_frag_sad2_thresh(cpi,cur,
+     ref+mvoffset0,ref+mvoffset1,stride,_best_err);
+    if(err<_best_err){
+      _best_err=err;
+      best_site=site;
+    }
+  }
+  _vec[0]=(_vec[0]<<1)+OC_SQUARE_DX[best_site];
+  _vec[1]=(_vec[1]<<1)+OC_SQUARE_DY[best_site];
+  return _best_err;
+}
+#endif
+
+static int oc_mcenc_ysatd_halfpel_brefine(CP_INSTANCE *cpi,int _mbi,
+ int _bi,int _vec[2],int _best_err,int _goldenp){
+  macroblock_t *mb;
+  int           offset_y[9];
+  int           stride;
+  int           mvoffset_base;
+  int           best_site;
+  int           sitei;
+  int           err;
+  int           fi;
+  mb=cpi->macro+_mbi;
+  stride=cpi->stride[0];
+  fi=mb->Ryuv[0][_bi];
+  mvoffset_base=_vec[0]+_vec[1]*stride;
+  offset_y[0]=offset_y[1]=offset_y[2]=-stride;
+  offset_y[3]=offset_y[5]=0;
+  offset_y[6]=offset_y[7]=offset_y[8]=stride;
+  best_site=4;
+  for(sitei=0;sitei<8;sitei++){
+    ogg_uint32_t         base_offset;
+    const unsigned char *cur;
+    const unsigned char *ref;
+    int                  site;
+    int                  xmask;
+    int                  ymask;
+    int                  dx;
+    int                  dy;
+    int                  mvoffset0;
+    int                  mvoffset1;
+    base_offset=cpi->frag_buffer_index[fi];
+    cur=cpi->frame+base_offset;
+    ref=(_goldenp?cpi->golden:cpi->lastrecon)+base_offset;
+    site=OC_SQUARE_SITES[0][sitei];
+    dx=OC_SQUARE_DX[site];
+    dy=OC_SQUARE_DY[site];
+    /*The following code SHOULD be equivalent to
+        oc_state_get_mv_offsets(&_mcenc->enc.state,&mvoffset0,&mvoffset1,
+         (_vec[0]<<1)+dx,(_vec[1]<<1)+dy,ref_ystride,0);
+      However, it should also be much faster, as it involves no multiplies and
+       doesn't have to handle chroma vectors.*/
+    xmask=OC_SIGNMASK(((_vec[0]<<1)+dx)^dx);
+    ymask=OC_SIGNMASK(((_vec[1]<<1)+dy)^dy);
+    mvoffset0=mvoffset_base+(dx&xmask)+(offset_y[site]&ymask);
+    mvoffset1=mvoffset_base+(dx&~xmask)+(offset_y[site]&~ymask);
+    err=oc_enc_frag_satd2_thresh(cpi,cur,
+     ref+mvoffset0,ref+mvoffset1,stride,_best_err);
+    if(err<_best_err){
+      _best_err=err;
+      best_site=site;
+    }
+  }
+  _vec[0]=(_vec[0]<<1)+OC_SQUARE_DX[best_site];
+  _vec[1]=(_vec[1]<<1)+OC_SQUARE_DY[best_site];
+  return _best_err;
+}
+
+/*Perform a motion vector search for this macro block against a single
+   reference frame.
+  As a bonus, individual block motion vectors are computed as well, as much of
+   the work can be shared.
+  The actual motion vector is stored in the appropriate place in the
+   oc_mb_enc_info structure.
+  _mcenc:    The motion compensation context.
+  _mbi:      The macro block index.
+  _frame:    The frame to search, either OC_FRAME_PREV or OC_FRAME_GOLD.
+  _bmvs:     Returns the individual block motion vectors.*/
+void oc_mcenc_search(CP_INSTANCE *cpi,mc_state *_mcenc,int _mbi,
+ int _goldenp,oc_mv _bmvs[4],int *_best_err,int _best_block_err[4]){
+  /*Note: Traditionally this search is done using a rate-distortion objective
+     function of the form D+lambda*R.
+    However, xiphmont tested this and found it produced a small degredation,
+     while requiring extra computation.
+    This is most likely due to Theora's peculiar MV encoding scheme: MVs are
+     not coded relative to a predictor, and the only truly cheap way to use a
+     MV is in the LAST or LAST2 MB modes, which are not being considered here.
+    Therefore if we use the MV found here, it's only because both LAST and
+     LAST2 performed poorly, and therefore the MB is not likely to be uniform
+     or suffer from the aperture problem.
+    Furthermore we would like to re-use the MV found here for as many MBs as
+     possible, so picking a slightly sub-optimal vector to save a bit or two
+     may cause increased degredation in many blocks to come.
+    We could artificially reduce lambda to compensate, but it's faster to just
+     disable it entirely, and use D (the distortion) as the sole criterion.*/
+  macroblock_t *mb;
+  ogg_int32_t   hit_cache[31];
+  ogg_int32_t   hitbit;
+  int           block_err[4];
+  int           best_vec[2];
+  int           best_err;
+  int           best_block_vec[4][2];
+  int           candx;
+  int           candy;
+  int           bi;
+  mb=cpi->macro+_mbi;
+  /*Find some candidate motion vectors.*/
+  oc_mcenc_find_candidates(cpi,_mcenc,_mbi,_goldenp);
+  /*Clear the cache of locations we've examined.*/
+  memset(hit_cache,0,sizeof(hit_cache));
+  /*Start with the median predictor.*/
+  candx=_mcenc->candidates[0][0];
+  candy=_mcenc->candidates[0][1];
+  hit_cache[candy+15]|=(ogg_int32_t)1<<candx+15;
+  /*TODO: customize error function for speed/(quality+size) tradeoff.*/
+  best_err=oc_mcenc_ysad_check_mbcandidate_fullpel(cpi,
+   _mbi,candx,candy,_goldenp,block_err);
+  best_vec[0]=candx;
+  best_vec[1]=candy;
+  if(_bmvs){
+    for(bi=0;bi<4;bi++){
+      _best_block_err[bi]=block_err[bi];
+      best_block_vec[bi][0]=candx;
+      best_block_vec[bi][1]=candy;
+    }
+  }
+  /*If this predictor fails, move on to set A.*/
+  if(best_err>OC_YSAD_THRESH1){
+    int err;
+    int ci;
+    int ncs;
+    int t2;
+    /*Compute the early termination threshold for set A.*/
+    t2=mb->aerror;
+    ncs=OC_MINI(3,mb->ncneighbors);
+    for(ci=0;ci<ncs;ci++)t2=OC_MAXI(t2,cpi->macro[mb->cneighbors[ci]].aerror);
+    t2+=(t2>>OC_YSAD_THRESH2_SCALE_BITS)+OC_YSAD_THRESH2_OFFSET;
+    /*Examine the candidates in set A.*/
+    for(ci=1;ci<_mcenc->setb0;ci++){
+      candx=_mcenc->candidates[ci][0];
+      candy=_mcenc->candidates[ci][1];
+      /*If we've already examined this vector, then we would be using it if it
+         was better than what we are using.*/
+      hitbit=(ogg_int32_t)1<<candx+15;
+      if(hit_cache[candy+15]&hitbit)continue;
+      hit_cache[candy+15]|=hitbit;
+      err=oc_mcenc_ysad_check_mbcandidate_fullpel(cpi,
+       _mbi,candx,candy,_goldenp,block_err);
+      if(err<best_err){
+        best_err=err;
+        best_vec[0]=candx;
+        best_vec[1]=candy;
+      }
+      if(_bmvs){
+        for(bi=0;bi<4;bi++)if(block_err[bi]<_best_block_err[bi]){
+          _best_block_err[bi]=block_err[bi];
+          best_block_vec[bi][0]=candx;
+          best_block_vec[bi][1]=candy;
+        }
+      }
+    }
+    if(best_err>t2){
+      /*Examine the candidates in set B.*/
+      for(;ci<_mcenc->ncandidates;ci++){
+        candx=_mcenc->candidates[ci][0];
+        candy=_mcenc->candidates[ci][1];
+        hitbit=(ogg_int32_t)1<<candx+15;
+        if(hit_cache[candy+15]&hitbit)continue;
+        hit_cache[candy+15]|=hitbit;
+        err=oc_mcenc_ysad_check_mbcandidate_fullpel(cpi,
+         _mbi,candx,candy,_goldenp,block_err);
+        if(err<best_err){
+          best_err=err;
+          best_vec[0]=candx;
+          best_vec[1]=candy;
+        }
+        if(_bmvs){
+          for(bi=0;bi<4;bi++)if(block_err[bi]<_best_block_err[bi]){
+            _best_block_err[bi]=block_err[bi];
+            best_block_vec[bi][0]=candx;
+            best_block_vec[bi][1]=candy;
+          }
+        }
+      }
+      /*Use the same threshold for set B as in set A.*/
+      if(best_err>t2){
+        int best_site;
+        int nsites;
+        int sitei;
+        int site;
+        int b;
+        /*Square pattern search.*/
+        for(;;){
+          best_site=4;
+          /*Compose the bit flags for boundary conditions.*/
+          b=OC_DIV16(-best_vec[0]+1)|OC_DIV16(best_vec[0]+1)<<1|
+           OC_DIV16(-best_vec[1]+1)<<2|OC_DIV16(best_vec[1]+1)<<3;
+          nsites=OC_SQUARE_NSITES[b];
+          for(sitei=0;sitei<nsites;sitei++){
+            site=OC_SQUARE_SITES[b][sitei];
+            candx=best_vec[0]+OC_SQUARE_DX[site];
+            candy=best_vec[1]+OC_SQUARE_DY[site];
+            hitbit=(ogg_int32_t)1<<candx+15;
+            if(hit_cache[candy+15]&hitbit)continue;
+            hit_cache[candy+15]|=hitbit;
+            err=oc_mcenc_ysad_check_mbcandidate_fullpel(cpi,
+             _mbi,candx,candy,_goldenp,block_err);
+            if(err<best_err){
+              best_err=err;
+              best_site=site;
+            }
+            if(_bmvs){
+              for(bi=0;bi<4;bi++)if(block_err[bi]<_best_block_err[bi]){
+                _best_block_err[bi]=block_err[bi];
+                best_block_vec[bi][0]=candx;
+                best_block_vec[bi][1]=candy;
+              }
+            }
+          }
+          if(best_site==4)break;
+          best_vec[0]+=OC_SQUARE_DX[best_site];
+          best_vec[1]+=OC_SQUARE_DY[best_site];
+        }
+        /*Final 4-MV search.*/
+        /*Simply use 1/4 of the macro block set A and B threshold as the
+           individual block threshold.*/
+        if(_bmvs){
+          t2>>=2;
+          for(bi=0;bi<4;bi++){
+            if(_best_block_err[bi]>t2){
+              /*Square pattern search.
+                We do this in a slightly interesting manner.
+                We continue to check the SAD of all four blocks in the
+                 macro block.
+                This gives us two things:
+                 1) We can continue to use the hit_cache to avoid duplicate
+                     checks.
+                    Otherwise we could continue to read it, but not write to it
+                     without saving and restoring it for each block.
+                    Note that we could still eliminate a large number of
+                     duplicate checks by taking into account the site we came
+                     from when choosing the site list.
+                    We can still do that to avoid extra hit_cache queries, and
+                     it might even be a speed win.
+                 2) It gives us a slightly better chance of escaping local
+                     minima.
+                    We would not be here if we weren't doing a fairly bad job
+                     in finding a good vector, and checking these vectors can
+                     save us from 100 to several thousand points off our SAD 1
+                     in 15 times.
+                TODO: Is this a good idea?
+                Who knows.
+                It needs more testing.*/
+              for(;;){
+                int bestx;
+                int besty;
+                int bj;
+                bestx=best_block_vec[bi][0];
+                besty=best_block_vec[bi][1];
+                /*Compose the bit flags for boundary conditions.*/
+                b=OC_DIV16(-bestx+1)|OC_DIV16(bestx+1)<<1|
+                 OC_DIV16(-besty+1)<<2|OC_DIV16(besty+1)<<3;
+                nsites=OC_SQUARE_NSITES[b];
+                for(sitei=0;sitei<nsites;sitei++){
+                  site=OC_SQUARE_SITES[b][sitei];
+                  candx=bestx+OC_SQUARE_DX[site];
+                  candy=besty+OC_SQUARE_DY[site];
+                  hitbit=(ogg_int32_t)1<<candx+15;
+                  if(hit_cache[candy+15]&hitbit)continue;
+                  hit_cache[candy+15]|=hitbit;
+                  err=oc_mcenc_ysad_check_mbcandidate_fullpel(cpi,
+                   _mbi,candx,candy,_goldenp,block_err);
+                  if(err<best_err){
+                    best_err=err;
+                    best_vec[0]=candx;
+                    best_vec[1]=candy;
+                  }
+                  for(bj=0;bj<4;bj++)if(block_err[bj]<_best_block_err[bj]){
+                    _best_block_err[bj]=block_err[bj];
+                    best_block_vec[bj][0]=candx;
+                    best_block_vec[bj][1]=candy;
+                  }
+                }
+                if(best_block_vec[bi][0]==bestx&&best_block_vec[bi][1]==besty){
+                  break;
+                }
+              }
+            }
+          }
+        }
+      }
+    }
+  }
+  if(!_goldenp)mb->aerror=best_err;
+  else mb->gerror=best_err;
+  candx=best_vec[0];
+  candy=best_vec[1];
+  *_best_err=oc_mcenc_ysatd_check_mbcandidate_fullpel(cpi,
+   _mbi,candx,candy,_goldenp);
+  mb->analysis_mv[0][_goldenp][0]=(signed char)(candx<<1);
+  mb->analysis_mv[0][_goldenp][1]=(signed char)(candy<<1);
+  if(_bmvs!=NULL){
+    for(bi=0;bi<4;bi++){
+      candx=best_block_vec[bi][0];
+      candy=best_block_vec[bi][1];
+      _best_block_err[bi]=oc_mcenc_ysatd_check_bcandidate_fullpel(cpi,
+       _mbi,bi,candx,candy,_goldenp);
+      _bmvs[bi][0]=(signed char)(candx<<1);
+      _bmvs[bi][1]=(signed char)(candy<<1);
+    }
+  }
+}
+
+void oc_mcenc_refine1mv(CP_INSTANCE *cpi,int _mbi,int _goldenp,int _err){
+  macroblock_t *mb;
+  int           vec[2];
+  mb=cpi->macro+_mbi;
+  vec[0]=OC_DIV2(mb->analysis_mv[0][_goldenp][0]);
+  vec[1]=OC_DIV2(mb->analysis_mv[0][_goldenp][1]);
+  _err=oc_mcenc_ysatd_halfpel_mbrefine(cpi,_mbi,vec,_err,_goldenp);
+  mb->analysis_mv[0][_goldenp][0]=(signed char)vec[0];
+  mb->analysis_mv[0][_goldenp][1]=(signed char)vec[1];
+  if(!_goldenp)mb->asatd=_err;
+  else mb->gsatd=_err;
+}
+
+void oc_mcenc_refine4mv(CP_INSTANCE *cpi,int _mbi,int _err[4]){
+  macroblock_t *mb;
+  int           bi;
+  mb=cpi->macro+_mbi;
+  for(bi=0;bi<4;bi++){
+    int vec[2];
+    vec[0]=OC_DIV2(mb->block_mv[bi][0]);
+    vec[1]=OC_DIV2(mb->block_mv[bi][1]);
+    oc_mcenc_ysatd_halfpel_brefine(cpi,_mbi,bi,vec,_err[bi],0);
+    mb->ref_mv[bi][0]=(signed char)vec[0];
+    mb->ref_mv[bi][1]=(signed char)vec[1];
+  }
+}
+
+void oc_mcenc_start(CP_INSTANCE *cpi,mc_state *_mcenc){
+  ogg_int64_t nframes;
+  /*Set up the accelerated MV weights for previous frame prediction.*/
+  _mcenc->mvapw1[OC_FRAME_PREV]=(ogg_int32_t)1<<17;
+  _mcenc->mvapw2[OC_FRAME_PREV]=(ogg_int32_t)1<<16;
+  /*Set up the accelerated MV weights for golden frame prediction.*/
+  nframes=cpi->LastKeyFrame;
+  _mcenc->mvapw1[OC_FRAME_GOLD]=(ogg_int32_t)(
+   nframes!=1?(nframes<<17)/(nframes-1):0);
+  _mcenc->mvapw2[OC_FRAME_GOLD]=(ogg_int32_t)(
+   nframes!=2?(nframes<<16)/(nframes-2):0);
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/mode.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/mode.c
new file mode 100644
index 0000000..2564010
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/mode.c
@@ -0,0 +1,1497 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2008                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function: mode selection code
+  last mod: $Id$
+
+ ********************************************************************/
+
+#include <string.h>
+#include "codec_internal.h"
+#include "modedec.h"
+#include "encoder_lookup.h"
+
+/*Mode decision is done by exhaustively examining all potential choices.
+  Obviously, doing the motion compensation, fDCT, tokenization, and then
+   counting the bits each token uses is computationally expensive.
+  Theora's EOB runs can also split the cost of these tokens across multiple
+   fragments, and naturally we don't know what the optimal choice of Huffman
+   codes will be until we know all the tokens we're going to encode in all the
+   fragments.
+  So we use a simple approach to estimating the bit cost of each mode based
+   upon the SAD value of the residual.
+  The mathematics behind the technique are outlined by Kim \cite{Kim03}, but
+   the process is very simple.
+  For each quality index and SAD value, we have a table containing the average
+   number of bits needed to code a fragment.
+  The SAD values are placed into a small number of bins (currently 24).
+  TODO: The remaining portion is no longer current.
+  The bit counts are obtained by examining actual encoded frames, with optimal
+   Huffman codes selected and EOB bits appropriately divided among all the
+   blocks they involve.
+  A separate QIxSAD table is kept for each mode and color plane.
+  It may be possible to combine many of these, but only experimentation
+   will tell which ones truly represent the same distribution.
+
+  @ARTICLE{Kim03,
+    author="Hyun Mun Kim",
+    title="Adaptive Rate Control Using Nonlinear Regression",
+    journal="IEEE Transactions on Circuits and Systems for Video
+    Technology",
+    volume=13,
+    number=5,
+    pages="432--439",
+    month="May",
+    year=2003
+  }*/
+
+/*Pointers to the list of bit lengths for the VLC codes used for each mode
+   scheme.
+  Schemes 0-6 use the same VLC, while scheme 7 uses a FLC.*/
+static const unsigned char *OC_MODE_SCHEME_BITS[8]={
+  ModeBitLengths,
+  ModeBitLengths,
+  ModeBitLengths,
+  ModeBitLengths,
+  ModeBitLengths,
+  ModeBitLengths,
+  ModeBitLengths,
+  ModeBitLengthsD,
+};
+
+/*Initialize the mode scheme chooser.
+  This need only be called once per encoder.
+  This is probably the best place to describe the various schemes Theora uses
+   to encode macro block modes.
+  There are 8 possible schemes.
+  Schemes 0-6 use a highly unbalanced Huffman code to code each of the modes.
+  The same set of Huffman codes is used for each of these 7 schemes, but the
+   mode assigned to each code varies.
+  Schemes 1-6 have a fixed mapping from Huffman code to MB mode, while scheme 0
+   writes a custom mapping to the bitstream before all the modes.
+  Finally, scheme 7 just encodes each mode directly in 3 bits.*/
+void oc_mode_scheme_chooser_init(oc_mode_scheme_chooser *_chooser){
+  int si;
+  _chooser->mode_ranks[0]=_chooser->scheme0_ranks;
+  for(si=1;si<8;si++)_chooser->mode_ranks[si]=ModeSchemes[si-1];
+}
+
+/*Reset the mode scheme chooser.
+  This needs to be called once for each frame, including the first.*/
+static void oc_mode_scheme_chooser_reset(oc_mode_scheme_chooser *_chooser){
+  int si;
+  memset(_chooser->mode_counts,0,OC_NMODES*sizeof(*_chooser->mode_counts));
+  /*Scheme 0 starts with 24 bits to store the mode list in.*/
+  _chooser->scheme_bits[0]=24;
+  memset(_chooser->scheme_bits+1,0,7*sizeof(*_chooser->scheme_bits));
+  for(si=0;si<8;si++){
+    /*Scheme 7 should always start first, and scheme 0 should always start
+       last.*/
+    _chooser->scheme_list[si]=7-si;
+    _chooser->scheme0_list[si]=_chooser->scheme0_ranks[si]=si;
+  }
+}
+
+/*This is the real purpose of this data structure: not actually selecting a
+   mode scheme, but estimating the cost of coding a given mode given all the
+   modes selected so far.
+  This is done via opportunity cost: the cost is defined as the number of bits
+   required to encode all the modes selected so far including the current one
+   using the best possible scheme, minus the number of bits required to encode
+   all the modes selected so far not including the current one using the best
+   possible scheme.
+  The computational expense of doing this probably makes it overkill.
+  Just be happy we take a greedy approach instead of trying to solve the
+   global mode-selection problem (which is NP-hard).
+  _mode: The mode to determine the cost of.
+  Return: The number of bits required to code this mode.*/
+static int oc_mode_scheme_chooser_cost(oc_mode_scheme_chooser *_chooser,
+ int _mode){
+  int scheme0;
+  int scheme1;
+  int best_bits;
+  int mode_bits;
+  int si;
+  int scheme_bits;
+  scheme0=_chooser->scheme_list[0];
+  scheme1=_chooser->scheme_list[1];
+  best_bits=_chooser->scheme_bits[scheme0];
+  mode_bits=OC_MODE_SCHEME_BITS[scheme0][_chooser->mode_ranks[scheme0][_mode]];
+  /*Typical case: If the difference between the best scheme and the next best
+     is greater than 6 bits, then adding just one mode cannot change which
+     scheme we use.*/
+  if(_chooser->scheme_bits[scheme1]-best_bits>6)return mode_bits;
+  /*Otherwise, check to see if adding this mode selects a different scheme as
+     the best.*/
+  si=1;
+  best_bits+=mode_bits;
+  do{
+    /*For any scheme except 0, we can just use the bit cost of the mode's rank
+       in that scheme.*/
+    if(scheme1!=0){
+      scheme_bits=_chooser->scheme_bits[scheme1]+
+       OC_MODE_SCHEME_BITS[scheme1][_chooser->mode_ranks[scheme1][_mode]];
+    }
+    else{
+      int ri;
+      /*For scheme 0, incrementing the mode count could potentially change the
+         mode's rank.
+        Find the index where the mode would be moved to in the optimal list,
+         and use its bit cost instead of the one for the mode's current
+         position in the list.*/
+      /*We don't recompute scheme bits; this is computing opportunity cost, not
+         an update.*/
+      for(ri=_chooser->scheme0_ranks[_mode];ri>0&&
+       _chooser->mode_counts[_mode]>=
+       _chooser->mode_counts[_chooser->scheme0_list[ri-1]];ri--);
+      scheme_bits=_chooser->scheme_bits[0]+ModeBitLengths[ri];
+    }
+    if(scheme_bits<best_bits)best_bits=scheme_bits;
+    if(++si>=8)break;
+    scheme1=_chooser->scheme_list[si];
+  }
+  while(_chooser->scheme_bits[scheme1]-_chooser->scheme_bits[scheme0]<=6);
+  return best_bits-_chooser->scheme_bits[scheme0];
+}
+
+/*Incrementally update the mode counts and per-scheme bit counts and re-order
+   the scheme lists once a mode has been selected.
+  _mode: The mode that was chosen.*/
+static void oc_mode_scheme_chooser_update(oc_mode_scheme_chooser *_chooser,
+ int _mode){
+  int ri;
+  int si;
+  _chooser->mode_counts[_mode]++;
+  /*Re-order the scheme0 mode list if necessary.*/
+  for(ri=_chooser->scheme0_ranks[_mode];ri>0;ri--){
+    int pmode;
+    pmode=_chooser->scheme0_list[ri-1];
+    if(_chooser->mode_counts[pmode]>=_chooser->mode_counts[_mode])break;
+    /*Reorder the mode ranking.*/
+    _chooser->scheme0_ranks[pmode]++;
+    _chooser->scheme0_list[ri]=pmode;
+  }
+  _chooser->scheme0_ranks[_mode]=ri;
+  _chooser->scheme0_list[ri]=_mode;
+  /*Now add the bit cost for the mode to each scheme.*/
+  for(si=0;si<8;si++){
+    _chooser->scheme_bits[si]+=
+     OC_MODE_SCHEME_BITS[si][_chooser->mode_ranks[si][_mode]];
+  }
+  /*Finally, re-order the list of schemes.*/
+  for(si=1;si<8;si++){
+    int sj;
+    int scheme0;
+    int bits0;
+    sj=si;
+    scheme0=_chooser->scheme_list[si];
+    bits0=_chooser->scheme_bits[scheme0];
+    do{
+      int scheme1;
+      scheme1=_chooser->scheme_list[sj-1];
+      if(bits0>=_chooser->scheme_bits[scheme1])break;
+      _chooser->scheme_list[sj]=scheme1;
+    }
+    while(--sj>0);
+    _chooser->scheme_list[sj]=scheme0;
+  }
+}
+
+typedef struct oc_mode_choice oc_mode_choice;
+
+struct oc_mode_choice{
+  unsigned cost;
+  unsigned ssd;
+  unsigned rate;
+  unsigned overhead;
+};
+
+static void oc_mode_dct_cost_accum(oc_mode_choice *_mode,
+ int _qi,int _pli,int _qti,int _sad){
+  int      bin;
+  int      dx;
+  int      y0;
+  int      z0;
+  int      dy;
+  int      dz;
+  unsigned rmse;
+  bin=OC_MINI(_sad>>OC_SAD_SHIFT,OC_SAD_BINS-2);
+  dx=_sad-(bin<<OC_SAD_SHIFT);
+  y0=OC_MODE_RD[_qi][_pli][_qti][bin].rate;
+  z0=OC_MODE_RD[_qi][_pli][_qti][bin].rmse;
+  dy=OC_MODE_RD[_qi][_pli][_qti][bin+1].rate-y0;
+  dz=OC_MODE_RD[_qi][_pli][_qti][bin+1].rmse-z0;
+  _mode->rate+=OC_MAXI(y0+(dy*dx>>OC_SAD_SHIFT),0);
+  rmse=OC_MAXI(z0+(dz*dx>>OC_SAD_SHIFT),0);
+  _mode->ssd+=rmse*rmse>>2*OC_RMSE_SCALE-OC_BIT_SCALE;
+}
+
+static void oc_mode_set_cost(oc_mode_choice *_mode,int _lambda){
+ _mode->cost=_mode->ssd+(_mode->rate+_mode->overhead)*_lambda;
+}
+
+
+static const signed char OC_MVMAP[2][64]={
+  {     -15,-15,-14, -14,-13,-13,-12, -12,-11,-11,-10, -10, -9, -9, -8,
+     -8, -7, -7, -6,  -6, -5, -5, -4,  -4, -3, -3, -2,  -2, -1, -1,  0,
+      0,  0,  1,  1,   2,  2,  3,  3,   4,  4,  5,  5,   6,  6,  7,  7,
+      8,  8,  9,  9,  10, 10, 11, 11,  12, 12, 13, 13,  14, 14, 15, 15 },
+  {      -7, -7, -7,  -7, -6, -6, -6,  -6, -5, -5, -5,  -5, -4, -4, -4,
+     -4, -3, -3, -3,  -3, -2, -2, -2,  -2, -1, -1, -1,  -1,  0,  0,  0,
+      0,  0,  0,  0,   1,  1,  1,  1,   2,  2,  2,  2,   3,  3,  3,  3,
+      4,  4,  4,  4,   5,  5,  5,  5,   6,  6,  6,  6,   7,  7,  7,  7 }
+};
+
+static const signed char OC_MVMAP2[2][63]={
+  {   -1, 0,-1,  0,-1, 0,-1,  0,-1, 0,-1,  0,-1, 0,-1,
+    0,-1, 0,-1,  0,-1, 0,-1,  0,-1, 0,-1,  0,-1, 0,-1,
+    0, 1, 0, 1,  0, 1, 0, 1,  0, 1, 0, 1,  0, 1, 0, 1,
+    0, 1, 0, 1,  0, 1, 0, 1,  0, 1, 0, 1,  0, 1, 0, 1 },
+  {   -1,-1,-1,  0,-1,-1,-1,  0,-1,-1,-1,  0,-1,-1,-1,
+    0,-1,-1,-1,  0,-1,-1,-1,  0,-1,-1,-1,  0,-1,-1,-1,
+    0, 1, 1, 1,  0, 1, 1, 1,  0, 1, 1, 1,  0, 1, 1, 1,
+    0, 1, 1, 1,  0, 1, 1, 1,  0, 1, 1, 1,  0, 1, 1, 1 }
+};
+
+int oc_get_mv_offsets(int _offsets[2],int _dx,int _dy,
+ int _ystride,int _pli,int _pf){
+  int qpx;
+  int qpy;
+  int mx;
+  int my;
+  int mx2;
+  int my2;
+  int offs;
+  qpy=!(_pf&2)&&_pli;
+  my=OC_MVMAP[qpy][_dy+31];
+  my2=OC_MVMAP2[qpy][_dy+31];
+  qpx=!(_pf&1)&&_pli;
+  mx=OC_MVMAP[qpx][_dx+31];
+  mx2=OC_MVMAP2[qpx][_dx+31];
+  offs=my*_ystride+mx;
+  if(mx2||my2){
+    _offsets[1]=offs+my2*_ystride+mx2;
+    _offsets[0]=offs;
+    return 2;
+  }
+  _offsets[0]=offs;
+  return 1;
+}
+
+static int BIntraSAD(CP_INSTANCE *cpi, int fi, int plane){
+  int satd;
+  satd=oc_enc_frag_intra_satd(cpi,
+   cpi->frame+cpi->frag_buffer_index[fi],cpi->stride[plane]);
+  if(plane)satd<<=2;
+  return satd;
+}
+
+static int BInterSAD(CP_INSTANCE *cpi,int _fi,int _dx,int _dy,
+ int _pli,int _goldenp){
+  unsigned char *b;
+  unsigned char *r;
+  int            offs[2];
+  int            stride;
+  int            sad;
+  b=cpi->frame+cpi->frag_buffer_index[_fi];
+  r=(_goldenp?cpi->golden:cpi->lastrecon)+cpi->frag_buffer_index[_fi];
+  stride=cpi->stride[_pli];
+  sad=0;
+  if(oc_get_mv_offsets(offs,_dx,_dy,
+   cpi->stride[_pli],_pli,cpi->info.pixelformat)>1){
+    sad=oc_enc_frag_satd2_thresh(cpi,b,r+offs[0],r+offs[1],stride,0xFF000);
+  }
+  else sad=oc_enc_frag_satd_thresh(cpi,b,r+offs[0],stride,0xFF000);
+  /*TODO: <<2? Really? Why?*/
+  if(_pli)return sad<<2;
+  else return sad;
+}
+
+static void oc_cost_intra(CP_INSTANCE *cpi,oc_mode_choice *_mode,
+ int _mbi,int _qi){
+  macroblock_t *mb;
+  int           pli;
+  int           bi;
+  mb=cpi->macro+_mbi;
+  _mode->rate=_mode->ssd=0;
+  for(pli=0;pli<3;pli++){
+    for(bi=0;bi<4;bi++){
+      int fi;
+      fi=mb->Ryuv[pli][bi];
+      if(fi<cpi->frag_total){
+        oc_mode_dct_cost_accum(_mode,_qi,pli,0,BIntraSAD(cpi,fi,pli));
+      }
+    }
+  }
+  _mode->overhead=
+   oc_mode_scheme_chooser_cost(&cpi->chooser,CODE_INTRA)<<OC_BIT_SCALE;
+  oc_mode_set_cost(_mode,cpi->lambda);
+}
+
+static void oc_cost_inter(CP_INSTANCE *cpi,oc_mode_choice *_mode,int _mbi,
+ int _modei,const signed char *_mv,int _qi){
+  macroblock_t *mb;
+  int           goldenp;
+  int           pli;
+  int           bi;
+  int           dx;
+  int           dy;
+  goldenp=OC_FRAME_FOR_MODE[_modei]==OC_FRAME_GOLD;
+  mb=cpi->macro+_mbi;
+  _mode->rate=_mode->ssd=0;
+  dx=_mv[0];
+  dy=_mv[1];
+  for(pli=0;pli<3;pli++){
+    for(bi=0;bi<4;bi++){
+      int fi;
+      fi=mb->Ryuv[pli][bi];
+      if(fi<cpi->frag_total){
+        oc_mode_dct_cost_accum(_mode,_qi,pli,1,
+         BInterSAD(cpi,fi,dx,dy,pli,goldenp));
+      }
+    }
+  }
+  _mode->overhead=
+   oc_mode_scheme_chooser_cost(&cpi->chooser,_modei)<<OC_BIT_SCALE;
+  oc_mode_set_cost(_mode,cpi->lambda);
+}
+
+static void oc_cost_inter_nomv(CP_INSTANCE *cpi,oc_mode_choice *_mode,int _mbi,
+ int _modei,int _qi){
+  const unsigned char *ref;
+  macroblock_t        *mb;
+  int                  pli;
+  int                  bi;
+  ref=_modei==CODE_INTER_NO_MV?cpi->lastrecon:cpi->golden;
+  mb=cpi->macro+_mbi;
+  _mode->rate=_mode->ssd=0;
+  for(pli=0;pli<3;pli++){
+    int stride;
+    stride=cpi->stride[pli];
+    for(bi=0;bi<4;bi++){
+      int fi;
+      fi=mb->Ryuv[pli][bi];
+      if(fi<cpi->frag_total){
+        int offs;
+        int sad;
+        offs=cpi->frag_buffer_index[fi];
+        sad=oc_enc_frag_satd_thresh(cpi,
+         cpi->frame+offs,ref+offs,stride,0xFF000);
+        if(pli)sad<<=2;
+        oc_mode_dct_cost_accum(_mode,_qi,pli,1,sad);
+      }
+    }
+  }
+  _mode->overhead=
+   oc_mode_scheme_chooser_cost(&cpi->chooser,_modei)<<OC_BIT_SCALE;
+  oc_mode_set_cost(_mode,cpi->lambda);
+}
+
+static int oc_cost_inter1mv(CP_INSTANCE *cpi,oc_mode_choice *_mode,int _mbi,
+ int _modei,const signed char *_mv,int _qi){
+  int bits0;
+  oc_cost_inter(cpi,_mode,_mbi,_modei,_mv,_qi);
+  bits0=MvBits[_mv[0]+MAX_MV_EXTENT]+MvBits[_mv[1]+MAX_MV_EXTENT];
+  _mode->overhead+=OC_MINI(cpi->MVBits_0+bits0,cpi->MVBits_1+12)
+   -OC_MINI(cpi->MVBits_0,cpi->MVBits_1)<<OC_BIT_SCALE;
+  oc_mode_set_cost(_mode,cpi->lambda);
+  return bits0;
+}
+
+static int oc_cost_inter4mv(CP_INSTANCE *cpi,oc_mode_choice *_mode,int _mbi,
+ oc_mv _mv[4],int _qi){
+  macroblock_t *mb;
+  int           pli;
+  int           bi;
+  int           bits0;
+  mb=cpi->macro+_mbi;
+  memcpy(mb->mv,_mv,sizeof(mb->mv));
+  _mode->rate=_mode->ssd=0;
+  bits0=0;
+  for(bi=0;bi<4;bi++){
+    int fi;
+    fi=mb->Ryuv[0][bi];
+    if(fi<cpi->frag_total){
+      int dx;
+      int dy;
+      dx=_mv[bi][0];
+      dy=_mv[bi][1];
+      bits0+=MvBits[dx+MAX_MV_EXTENT]+MvBits[dy+MAX_MV_EXTENT];
+      oc_mode_dct_cost_accum(_mode,_qi,0,1,
+       BInterSAD(cpi,fi,dx,dy,0,0));
+    }
+  }
+  (*OC_SET_CHROMA_MVS_TABLE[cpi->info.pixelformat])(mb->cbmvs,
+   (const oc_mv *)_mv);
+  for(pli=1;pli<3;pli++){
+    for(bi=0;bi<4;bi++){
+      int fi;
+      fi=mb->Ryuv[pli][bi];
+      if(fi<cpi->frag_total){
+        int dx;
+        int dy;
+        dx=mb->cbmvs[bi][0];
+        dy=mb->cbmvs[bi][1];
+        oc_mode_dct_cost_accum(_mode,_qi,pli,1,
+         BInterSAD(cpi,fi,dx,dy,pli,0));
+      }
+    }
+  }
+  _mode->overhead=oc_mode_scheme_chooser_cost(&cpi->chooser,CODE_INTER_FOURMV)
+   +OC_MINI(cpi->MVBits_0+bits0,cpi->MVBits_1+48)
+   -OC_MINI(cpi->MVBits_0,cpi->MVBits_1)<<OC_BIT_SCALE;
+  oc_mode_set_cost(_mode,cpi->lambda);
+  return bits0;
+}
+
+#include "quant_lookup.h"
+
+static void uncode_frag(CP_INSTANCE *cpi, int fi, int plane){
+  int bi;
+  int stride;
+  bi=cpi->frag_buffer_index[fi];
+  stride=cpi->stride[plane];
+  cpi->frag_coded[fi]=0;
+  oc_enc_frag_copy(cpi,cpi->recon+bi,cpi->lastrecon+bi,stride);
+}
+
+typedef struct{
+  int uncoded_ac_ssd;
+  int coded_ac_ssd;
+  int ac_cost;
+  int dc_flag;
+} rd_metric_t;
+
+typedef struct{
+  int plane;
+  int qi;
+  ogg_int16_t re_q[2][3][64];
+  oc_iquant *iq[2];
+  quant_tables *qq[2];
+  int xqp;
+  int yqp;
+  int ssdmul;
+} plane_state_t;
+
+static void ps_setup_frame(CP_INSTANCE *cpi, plane_state_t *ps){
+  int i,j,k;
+  int qi = cpi->BaseQ; /* temporary */;
+
+  ps->qi = qi;
+  for(i=0;i<2;i++)
+    for(j=0;j<3;j++)
+      for(k=0;k<64;k++)
+        ps->re_q[i][j][k]=cpi->quant_tables[i][j][k][qi];
+}
+
+static void ps_setup_plane(CP_INSTANCE *cpi, plane_state_t *ps, int plane){
+  ps->plane = plane;
+  ps->iq[0] = cpi->iquant_tables[0][plane][ps->qi];
+  ps->iq[1] = cpi->iquant_tables[1][plane][ps->qi];
+  ps->qq[0] = &(cpi->quant_tables[0][plane]);
+  ps->qq[1] = &(cpi->quant_tables[1][plane]);
+  ps->xqp = (plane && cpi->info.pixelformat != OC_PF_444);
+  ps->yqp = (plane && cpi->info.pixelformat == OC_PF_420);
+  ps->ssdmul = (ps->xqp+1)*(ps->yqp+1);
+}
+
+/* coding overhead is unscaled */
+#include<stdio.h>
+static int TQB (CP_INSTANCE *cpi,plane_state_t *ps,int mode,int fi,
+ int _dx,int _dy,int coding_overhead,rd_metric_t *mo,long *rho_count,
+ token_checkpoint_t **stack){
+  const int keyframe = (cpi->FrameType == KEY_FRAME);
+  const oc_iquant *iq = ps->iq[mode != CODE_INTRA];
+  ogg_int16_t buffer[64]OC_ALIGN16;
+  ogg_int16_t data[64]OC_ALIGN16;
+  const int bi = cpi->frag_buffer_index[fi];
+  const int stride = cpi->stride[ps->plane];
+  const unsigned char *frame_ptr = &cpi->frame[bi];
+  unsigned char *lastrecon = ((mode == CODE_USING_GOLDEN ||
+                               mode == CODE_GOLDEN_MV) ?
+                              cpi->golden : cpi->lastrecon)+bi;
+  unsigned char *thisrecon = cpi->recon+bi;
+  int nonzero=0;
+  const ogg_int16_t *dequant = ps->re_q[mode != CODE_INTRA][ps->plane];
+  int uncoded_ssd=0,coded_ssd=0;
+  int uncoded_dc=0,coded_dc=0,dc_flag=0;
+  int lambda = cpi->lambda;
+  token_checkpoint_t *checkpoint=*stack;
+  int mv_offs[2];
+  int nmv_offs;
+  int cost;
+  int ci;
+  int pi;
+
+  cpi->frag_coded[fi]=1;
+
+  /* by way of explanation: although the f_array coding overhead
+     determination is accurate, it is greedy using very coarse-grained
+     local information.  Allowing it to mildly discourage coding turns
+     out to be beneficial, but it's not clear that allowing it to
+     encourage coding through negative coding overhead deltas is
+     useful.  For that reason, we disallow negative
+     coding_overheads */
+  if(coding_overhead<0)coding_overhead = 0;
+
+  /* motion comp */
+  switch(mode){
+    case CODE_INTRA:{
+      nmv_offs=0;
+      oc_enc_frag_sub_128(cpi,data,frame_ptr,stride);
+    }break;
+    case CODE_USING_GOLDEN:
+    case CODE_INTER_NO_MV:{
+      nmv_offs=1;
+      mv_offs[0]=0;
+      oc_enc_frag_sub(cpi,data,frame_ptr,lastrecon,stride);
+    }break;
+    default:{
+      nmv_offs=oc_get_mv_offsets(mv_offs,_dx,_dy,
+       stride,ps->plane,cpi->info.pixelformat);
+      if(nmv_offs>1){
+        oc_enc_frag_copy2(cpi,thisrecon,
+         lastrecon+mv_offs[0],lastrecon+mv_offs[1],stride);
+        oc_enc_frag_sub(cpi,data,frame_ptr,thisrecon,stride);
+      }
+      else oc_enc_frag_sub(cpi,data,frame_ptr,lastrecon+mv_offs[0],stride);
+    }break;
+  }
+
+#if defined(OC_COLLECT_METRICS)
+  int sad=0;
+  if(mode==CODE_INTRA)sad=BIntraSAD(cpi,fi,ps->plane);
+  else{
+    sad=BInterSAD(cpi,fi,_dx,_dy,ps->plane,
+     OC_FRAME_FOR_MODE[mode]==OC_FRAME_GOLD);
+  }
+  cpi->frag_sad[fi]=sad;
+#endif
+
+  if(!keyframe){
+    if(mode==CODE_INTER_NO_MV){
+      for(pi=0;pi<64;pi++){
+        uncoded_ssd += data[pi]*data[pi];
+        uncoded_dc += data[pi];
+      }
+    }else{
+      oc_enc_frag_sub(cpi,buffer,frame_ptr,cpi->lastrecon+bi,stride);
+      for(pi=0;pi<64;pi++){
+        uncoded_ssd += buffer[pi]*buffer[pi];
+        uncoded_dc += buffer[pi];
+      }
+    }
+    uncoded_ssd <<= 4; /* scale to match DCT domain */
+  }
+
+  /* transform */
+  oc_enc_fdct8x8(cpi,buffer,data);
+
+  /* collect rho metrics, quantize */
+  {
+    int          zzi;
+#if 0
+    quant_tables *qq = ps->qq[mode != CODE_INTRA];
+#endif
+    for(zzi=0;zzi<64;zzi++){
+      int v;
+      int val;
+      int d;
+      ci=dezigzag_index[zzi];
+      v=buffer[ci];
+      d=dequant[zzi];
+      /* rho-domain distribution */
+      val=v<<1;
+      v=abs(val);
+#if 0
+      {
+        ogg_int16_t *qqq = (*qq)[zzi];
+        int pos;
+        for(pos=64;pos>0;pos--)if(v<qqq[pos-1])break;
+        rho_count[pos]++;
+      }
+#endif
+      if(v>=d){
+        int s;
+        s=OC_SIGNMASK(val);
+        /*The bias added here rounds ties away from zero, since token
+           optimization can only decrease the magnitude of the quantized
+           value.*/
+        val+=(d+s)^s;
+        /*Note the arithmetic right shift is not guaranteed by ANSI C.
+          Hopefully no one still uses ones-complement architectures.*/
+        val=((iq[zzi].m*(ogg_int32_t)val>>16)+val>>iq[zzi].l)-s;
+        data[zzi]=OC_CLAMPI(-580,val,580);
+        nonzero=zzi;
+      }
+      else data[zzi]=0;
+    }
+  }
+  cpi->frag_dc[fi] = data[0];
+
+  /* tokenize */
+  cost = dct_tokenize_AC(cpi, fi, data, dequant, buffer, fi>=cpi->frag_n[0], stack,mode==CODE_INTRA?3:0);
+
+  /*Reconstruct.*/
+  oc_enc_dequant_idct8x8(cpi,buffer,data,
+   nonzero+1,nonzero+1,dequant[0],(ogg_uint16_t *)dequant);
+  if(mode==CODE_INTRA)oc_enc_frag_recon_intra(cpi,thisrecon,stride,buffer);
+  else{
+    oc_enc_frag_recon_inter(cpi,thisrecon,
+     nmv_offs==1?lastrecon+mv_offs[0]:thisrecon,stride,buffer);
+  }
+
+#if defined(OC_COLLECT_METRICS)
+  {
+#else
+  if(!keyframe){
+#endif
+    /* in retrospect, should we have skipped this block? */
+    oc_enc_frag_sub(cpi,buffer,frame_ptr,thisrecon,stride);
+    for(pi=0;pi<64;pi++){
+      coded_ssd+=buffer[pi]*buffer[pi];
+      coded_dc+=buffer[pi];
+    }
+    coded_ssd <<= 4; /* scale to match DCT domain */
+    /* We actually only want the AC contribution to the SSDs */
+    uncoded_ssd -= ((uncoded_dc*uncoded_dc)>>2);
+    coded_ssd -= ((coded_dc*coded_dc)>>2);
+#if defined(OC_COLLECT_METRICS)
+    cpi->frag_ssd[fi]=coded_ssd;
+  }
+  if(!keyframe){
+#endif
+    /* for undersampled planes */
+    /*coded_ssd*=ps->ssdmul;*/
+    /*uncoded_ssd*=ps->ssdmul;*/
+    mo->uncoded_ac_ssd+=uncoded_ssd;
+
+    /* DC is a special case; if there's more than a full-quantizer
+       improvement in the effective DC component, always force-code
+       the block */
+    if( abs(uncoded_dc)-abs(coded_dc) > (dequant[0]<<1)){
+      mo->dc_flag = dc_flag = 1;
+    }
+
+    if(!dc_flag && uncoded_ssd <= coded_ssd+(coding_overhead+cost)*lambda){
+      /* Hm, not worth it.  roll back */
+      tokenlog_rollback(cpi, checkpoint, (*stack)-checkpoint);
+      *stack = checkpoint;
+      uncode_frag(cpi,fi,ps->plane);
+
+      mo->coded_ac_ssd+=uncoded_ssd;
+      //fprintf(stderr,"skip(%d:%d)",coding_overhead,cost);
+
+      return 0;
+    }else{
+
+      //fprintf(stderr,"*****(%d:%d)",coding_overhead,cost);
+
+      mo->coded_ac_ssd+=coded_ssd;
+      mo->ac_cost+=cost;
+
+    }
+  }
+
+  //for(i=0;i<64;i++)
+  //if(data[i]!=0)cpi->rho_postop++;
+
+  return 1;
+}
+
+static int macroblock_phase_Y[4][4] = {{0,1,3,2},{0,2,3,1},{0,2,3,1},{3,2,0,1}};
+
+/* mode_overhead is scaled by << OC_BIT_SCALE */
+static int TQMB_Y(CP_INSTANCE *cpi,macroblock_t *mb,int mb_phase,
+ plane_state_t *ps,long *rc,int mode_overhead,int *mb_mv_bits_0,fr_state_t *fr){
+
+  int full_checkpoint = cpi->fr_full_count;
+  int partial_checkpoint = cpi->fr_partial_count;
+  int block_checkpoint = cpi->fr_block_count;
+  fr_state_t fr_checkpoint = *fr;
+  unsigned char *cp=cpi->frag_coded;
+  int mode = mb->mode;
+  int coded = 0;
+  int i;
+  token_checkpoint_t stack[64*5]; /* worst case token usage for 4 fragments*/
+  token_checkpoint_t *stackptr = stack;
+  //int rho_check = cpi->rho_postop;
+
+  rd_metric_t mo;
+  memset(&mo,0,sizeof(mo));
+
+  for(i=0;i<4;i++){
+    /* Blocks must be handled in Hilbert order which is defined by MB
+       position within the SB.  And, of course, the MVs have to be in
+       raster order just to make it more difficult. */
+    int bi = macroblock_phase_Y[mb_phase][i];
+    int fi = mb->Ryuv[0][bi];
+
+    if(TQB(cpi,ps,mode,fi,mb->mv[bi][0],mb->mv[bi][1],
+     fr_cost1(fr),&mo,rc,&stackptr)){
+      fr_codeblock(cpi,fr);
+      coded++;
+    }
+    else fr_skipblock(cpi,fr);
+  }
+
+
+  if(cpi->FrameType != KEY_FRAME){
+    int bi;
+    if(coded && !mo.dc_flag){
+      /* block by block, still coding the MB.  Now consider the
+         macroblock coding cost as a whole (mode and MV) */
+      int codecost = mo.ac_cost+fr_cost4(&fr_checkpoint,fr)+(mode_overhead>>OC_BIT_SCALE);
+      if(mo.uncoded_ac_ssd <= mo.coded_ac_ssd+cpi->lambda*codecost){
+
+        /* taking macroblock overhead into account, it is not worth coding this MB */
+        tokenlog_rollback(cpi, stack, stackptr-stack);
+        memcpy(fr,&fr_checkpoint,sizeof(fr_checkpoint));
+        cpi->fr_full_count = full_checkpoint;
+        cpi->fr_partial_count = partial_checkpoint;
+        cpi->fr_block_count = block_checkpoint;
+        /*cpi->rho_postop = rho_check;*/
+
+        for(i=0;i<4;i++){
+          int fi = mb->Ryuv[0][i];
+          if(cp[fi])
+            uncode_frag(cpi,fi,0);
+          fr_skipblock(cpi,fr);
+        }
+        coded=0;
+
+      }
+    }
+
+    if(coded==0){
+      mb->mode = CODE_INTER_NO_MV; /* No luma blocks coded, mode is forced */
+      mb->coded = 0;
+      memset(mb->mv,0,sizeof(mb->mv));
+      memset(mb->cbmvs,0,sizeof(mb->cbmvs));
+      return 0;
+    }
+    /*Assume that a 1mv with a single coded block is always cheaper than a 4mv
+       with a single coded block.
+      This may not be strictly true: a 4MV computes chroma MVs using (0,0) for
+       skipped blocks, while a 1MV does not.*/
+    else if(coded==1&&mode==CODE_INTER_FOURMV){
+      int dx;
+      int dy;
+      mode=mb->mode=CODE_INTER_PLUS_MV;
+      for(bi=0;!cp[mb->Ryuv[0][bi]];bi++);
+      dx=mb->mv[bi][0];
+      dy=mb->mv[bi][1];
+      mb->cbmvs[0][0]=mb->cbmvs[1][0]=mb->cbmvs[2][0]=mb->cbmvs[3][0]=
+       mb->mv[0][0]=mb->mv[1][0]=mb->mv[2][0]=mb->mv[3][0]=(signed char)dx;
+      mb->cbmvs[0][1]=mb->cbmvs[1][1]=mb->cbmvs[2][1]=mb->cbmvs[3][1]=
+       mb->mv[0][1]=mb->mv[1][1]=mb->mv[2][1]=mb->mv[3][1]=(signed char)dy;
+      *mb_mv_bits_0=MvBits[dx+MAX_MV_EXTENT]+MvBits[dy+MAX_MV_EXTENT];
+    }
+    mb->coded=0;
+    for(bi=0;bi<4;bi++)mb->coded|=cp[mb->Ryuv[0][bi]]<<bi;
+  }
+
+  /* Commit tokenization */
+  tokenlog_commit(cpi, stack, stackptr-stack);
+
+  return coded;
+}
+
+static const unsigned char OC_MACROBLOCK_PHASE[16]={
+  0,1,3,2,0,2,3,1,0,2,3,1,3,2,0,1
+};
+
+static int TQSB_UV ( CP_INSTANCE *cpi, superblock_t *sb, plane_state_t *ps, long *rc, fr_state_t *fr){
+  int pf = cpi->info.pixelformat;
+  int i;
+  int coded = 0;
+  rd_metric_t mo;
+  token_checkpoint_t stack[64*2]; /* worst case token usage for 1 fragment*/
+  memset(&mo,0,sizeof(mo));
+
+  for(i=0;i<16;i++){
+    int fi = sb->f[i];
+
+    if(fi<cpi->frag_total){
+      token_checkpoint_t *stackptr;
+      macroblock_t       *mb;
+      int                 bi;
+      stackptr = stack;
+      mb=cpi->macro+sb->m[i];
+      bi=OC_MACROBLOCK_PHASE[i]&pf;
+      if(TQB(cpi,ps,mb->mode,fi,mb->cbmvs[bi][0],mb->cbmvs[bi][1],
+       fr_cost1(fr),&mo,rc,&stackptr)){
+        fr_codeblock(cpi,fr);
+        tokenlog_commit(cpi, stack, stackptr-stack);
+        coded++;
+      }else{
+        fr_skipblock(cpi,fr);
+      }
+    }
+  }
+
+  return coded;
+}
+
+int PickModes(CP_INSTANCE *cpi, int recode){
+  int qi;
+  superblock_t *sb;
+  superblock_t *sb_end;
+  int i,j;
+  ogg_uint32_t interbits;
+  ogg_uint32_t intrabits;
+  mc_state mcenc;
+  oc_mv last_mv;
+  oc_mv prior_mv;
+  long rho_count[65];
+  plane_state_t ps;
+  fr_state_t fr;
+  interbits=intrabits=0;
+  last_mv[0]=last_mv[1]=prior_mv[0]=prior_mv[1]=0;
+  oc_mode_scheme_chooser_reset(&cpi->chooser);
+  ps_setup_frame(cpi,&ps);
+  ps_setup_plane(cpi,&ps,0);
+  fr_clear(cpi,&fr);
+  cpi->fr_full_count=0;
+  cpi->fr_partial_count=0;
+  cpi->fr_block_count=0;
+
+  //cpi->rho_postop=0;
+
+  memset(rho_count,0,sizeof(rho_count));
+  cpi->MVBits_0 = 0;
+  cpi->MVBits_1 = 0;
+
+  if(!recode)
+    oc_mcenc_start(cpi, &mcenc);
+
+  dct_tokenize_init(cpi);
+
+  /* Choose mvs, modes; must be done in Hilbert order */
+  /* quantize and code Luma */
+  qi=cpi->BaseQ;
+  sb = cpi->super[0];
+  sb_end = sb + cpi->super_n[0];
+  for(; sb<sb_end; sb++){
+
+    for(j = 0; j<4; j++){ /* mode addressing is through Y plane, always 4 MB per SB */
+      macroblock_t *mb;
+      int           mbi;
+      mbi=sb->m[j];
+      if(mbi>=cpi->macro_total)continue;
+      mb=cpi->macro+mbi;
+      if(!recode){
+        /*Motion estimation:
+          We always do a basic 1MV search for all macroblocks, coded or not,
+           keyframe or not.*/
+        /*Move the motion vector predictors back a frame.*/
+        memmove(mb->analysis_mv+1,mb->analysis_mv,2*sizeof(mb->analysis_mv[0]));
+        /*Search the last frame.*/
+        oc_mcenc_search(cpi,&mcenc,mbi,0,
+         mb->block_mv,&mb->asatd,mb->block_satd);
+        /*Search the golden frame.*/
+        oc_mcenc_search(cpi,&mcenc,mbi,1,NULL,&mb->gsatd,NULL);
+      }
+      if(cpi->FrameType==KEY_FRAME){
+        mb->mode=CODE_INTRA;
+        /* Transform, quantize, collect rho metrics */
+        TQMB_Y(cpi,mb,j,&ps,rho_count,0,NULL,&fr);
+      }
+      else{
+        oc_mode_choice modes[8];
+        int            mb_mv_bits_0;
+        int            mb_gmv_bits_0;
+        int            mb_4mv_bits_0;
+        int            mb_4mv_bits_1;
+        int            inter_mv_pref;
+        int            mode;
+        /*Find the block choice with the lowest estimated coding cost.
+          If a Cb or Cr block is coded but no Y' block from a macro block then
+           the mode MUST be CODE_INTER_NO_MV.
+          This is the default state to which the mode data structure is
+           initialised in encoder and decoder at the start of each frame.*/
+        /*Block coding cost is estimated from correlated SATD metrics.*/
+        /*At this point, all blocks that are in frame are still marked coded.*/
+        if(!recode){
+          memcpy(mb->unref_mv,mb->analysis_mv[0],sizeof(mb->unref_mv));
+          mb->refined=0;
+        }
+        oc_cost_inter_nomv(cpi,modes+CODE_INTER_NO_MV,mbi,CODE_INTER_NO_MV,qi);
+        oc_cost_intra(cpi,modes+CODE_INTRA,mbi,qi);
+        intrabits+=modes[CODE_INTRA].rate;
+        mb_mv_bits_0=oc_cost_inter1mv(cpi,modes+CODE_INTER_PLUS_MV,mbi,
+         CODE_INTER_PLUS_MV,mb->unref_mv[0],qi);
+        oc_cost_inter(cpi,modes+CODE_INTER_LAST_MV,mbi,
+         CODE_INTER_LAST_MV,last_mv,qi);
+        oc_cost_inter(cpi,modes+CODE_INTER_PRIOR_LAST,mbi,
+         CODE_INTER_PRIOR_LAST,prior_mv,qi);
+        oc_cost_inter_nomv(cpi,modes+CODE_USING_GOLDEN,mbi,
+         CODE_USING_GOLDEN,qi);
+        mb_gmv_bits_0=oc_cost_inter1mv(cpi,modes+CODE_GOLDEN_MV,mbi,
+         CODE_GOLDEN_MV,mb->unref_mv[1],qi);
+        mb_4mv_bits_0=oc_cost_inter4mv(cpi,modes+CODE_INTER_FOURMV,mbi,
+         mb->block_mv,qi);
+        mb_4mv_bits_1=48;
+        /*The explicit MV modes (2,6,7) have not yet gone through halfpel
+           refinement.
+          We choose the explicit MV mode that's already furthest ahead on bits
+           and refine only that one.
+          We have to be careful to remember which ones we've refined so that
+           we don't refine it again if we re-encode this frame.*/
+        inter_mv_pref=cpi->lambda*3<<OC_BIT_SCALE;
+        if(modes[CODE_INTER_FOURMV].cost<modes[CODE_INTER_PLUS_MV].cost&&
+         modes[CODE_INTER_FOURMV].cost<modes[CODE_GOLDEN_MV].cost){
+          if(!(mb->refined&0x80)){
+            oc_mcenc_refine4mv(cpi, mbi, mb->block_satd);
+            mb->refined|=0x80;
+          }
+          mb_4mv_bits_0=oc_cost_inter4mv(cpi,modes+CODE_INTER_FOURMV,mbi,
+           mb->ref_mv,qi);
+        }
+        else if(modes[CODE_GOLDEN_MV].cost+inter_mv_pref<
+         modes[CODE_INTER_PLUS_MV].cost){
+          if(!(mb->refined&0x40)){
+            oc_mcenc_refine1mv(cpi,mbi,1,mb->gsatd);
+            mb->refined|=0x40;
+          }
+          mb_gmv_bits_0=oc_cost_inter1mv(cpi,modes+CODE_GOLDEN_MV,mbi,
+           CODE_GOLDEN_MV,mb->analysis_mv[0][1],qi);
+        }
+        if(!(mb->refined&0x04)){
+          oc_mcenc_refine1mv(cpi,mbi,0,mb->asatd);
+          mb->refined|=0x04;
+        }
+        mb_mv_bits_0=oc_cost_inter1mv(cpi,modes+CODE_INTER_PLUS_MV,mbi,
+         CODE_INTER_PLUS_MV,mb->analysis_mv[0][0],qi);
+        /*Finally, pick the mode with the cheapest estimated bit cost.*/
+        /*We prefer CODE_INTER_PLUS_MV, but not over LAST and LAST2.*/
+        mode=0;
+        if(modes[1].cost<modes[0].cost)mode=1;
+        if(modes[3].cost<modes[mode].cost)mode=3;
+        if(modes[4].cost<modes[mode].cost)mode=4;
+        if(modes[5].cost<modes[mode].cost)mode=5;
+        if(modes[6].cost<modes[mode].cost)mode=6;
+        if(modes[7].cost<modes[mode].cost)mode=7;
+        if(mode==CODE_INTER_LAST_MV||mode==CODE_INTER_PRIOR_LAST){
+          inter_mv_pref=0;
+        }
+        if(modes[2].cost<modes[mode].cost+inter_mv_pref)mode=2;
+        /*If we picked something other than 4MV, propagate the MV to the
+           blocks.*/
+        if(mode!=CODE_INTER_FOURMV){
+          int dx;
+          int dy;
+          switch(mode){
+            case CODE_INTER_PLUS_MV:{
+              dx=mb->analysis_mv[0][0][0];
+              dy=mb->analysis_mv[0][0][1];
+            }break;
+            case CODE_INTER_LAST_MV:{
+              dx=last_mv[0];
+              dy=last_mv[1];
+            }break;
+            case CODE_INTER_PRIOR_LAST:{
+              dx=prior_mv[0];
+              dy=prior_mv[1];
+            }break;
+            case CODE_GOLDEN_MV:{
+              dx=mb->analysis_mv[0][1][0];
+              dy=mb->analysis_mv[0][1][1];
+            }break;
+            default:dx=dy=0;break;
+          }
+          mb->cbmvs[0][0]=mb->cbmvs[1][0]=mb->cbmvs[2][0]=mb->cbmvs[3][0]=
+           mb->mv[0][0]=mb->mv[1][0]=mb->mv[2][0]=mb->mv[3][0]=(signed char)dx;
+          mb->cbmvs[0][1]=mb->cbmvs[1][1]=mb->cbmvs[2][1]=mb->cbmvs[3][1]=
+           mb->mv[0][1]=mb->mv[1][1]=mb->mv[2][1]=mb->mv[3][1]=(signed char)dy;
+        }
+        mb->mode=mode;
+        /* Transform, quantize, collect rho metrics */
+        if(TQMB_Y(cpi,mb,j,&ps,rho_count,modes[mode].overhead,&mb_mv_bits_0,&fr)){
+          switch(mb->mode){
+            case CODE_INTER_PLUS_MV:{
+              prior_mv[0]=last_mv[0];
+              prior_mv[1]=last_mv[1];
+              /*mb->mv[0] is not the same as analysis_mv[0][0] if we're
+                 backing out from a 4MV.*/
+              last_mv[0]=mb->mv[0][0];
+              last_mv[1]=mb->mv[0][1];
+              cpi->MVBits_0+=mb_mv_bits_0;
+              cpi->MVBits_1+=12;
+            }break;
+            case CODE_INTER_PRIOR_LAST:{
+              oc_mv temp;
+              temp[0]=prior_mv[0];
+              temp[1]=prior_mv[1];
+              prior_mv[0]=last_mv[0];
+              prior_mv[1]=last_mv[1];
+              last_mv[0]=temp[0];
+              last_mv[1]=temp[1];
+            }break;
+            case CODE_GOLDEN_MV:{
+              cpi->MVBits_0 += mb_gmv_bits_0;
+              cpi->MVBits_1 += 12;
+            }break;
+            case CODE_INTER_FOURMV:{
+              int bi;
+              prior_mv[0]=last_mv[0];
+              prior_mv[1]=last_mv[1];
+              for(bi=0;bi<4;bi++){
+                if(mb->coded&(1<<bi)){
+                  cpi->MVBits_0+=MvBits[mb->mv[bi][0]+MAX_MV_EXTENT]
+                   +MvBits[mb->mv[bi][1]+MAX_MV_EXTENT];
+                  cpi->MVBits_1+=12;
+                  last_mv[0]=mb->mv[bi][0];
+                  last_mv[1]=mb->mv[bi][1];
+                }
+                /*Replace the block MVs for not-coded blocks with (0,0).*/
+                else mb->mv[bi][0]=mb->mv[bi][1]=0;
+              }
+              if(mb->coded!=0xF){
+                (*OC_SET_CHROMA_MVS_TABLE[cpi->info.pixelformat])(mb->cbmvs,
+                 (const oc_mv *)mb->mv);
+              }
+            }break;
+            default:break;
+          }
+          oc_mode_scheme_chooser_update(&cpi->chooser,mb->mode);
+          interbits+=modes[mb->mode].rate+modes[mb->mode].overhead;
+        }
+      }
+    }
+    fr_finishsb(cpi,&fr);
+  }
+
+  dct_tokenize_mark_ac_chroma(cpi);
+
+  /* code chroma U */
+  sb = cpi->super[1];
+  sb_end = sb + cpi->super_n[1];
+  ps_setup_plane(cpi,&ps,1);
+  for(; sb<sb_end; sb++){
+    TQSB_UV(cpi, sb, &ps, rho_count, &fr);
+    fr_finishsb(cpi,&fr);
+  }
+
+  /* code chroma V */
+  sb = cpi->super[2];
+  sb_end = sb + cpi->super_n[2];
+  ps_setup_plane(cpi,&ps,2);
+  for(; sb<sb_end; sb++){
+    TQSB_UV(cpi, sb, &ps, rho_count, &fr);
+    fr_finishsb(cpi,&fr);
+  }
+
+  for(i=1;i<65;i++)
+  rho_count[i]+=rho_count[i-1];
+
+  memcpy(cpi->rho_count,rho_count,sizeof(rho_count));
+  if(cpi->FrameType != KEY_FRAME){
+
+    if(interbits>intrabits) return 1; /* short circuit */
+
+    /* finish adding flagging overhead costs to inter bit counts */
+
+    if(cpi->MVBits_0 < cpi->MVBits_1)
+      interbits += (cpi->MVBits_0 << OC_BIT_SCALE);
+    else
+      interbits += (cpi->MVBits_1 << OC_BIT_SCALE);
+
+    interbits += (cpi->chooser.scheme_bits[cpi->chooser.scheme_list[0]] << OC_BIT_SCALE);
+
+    if(interbits>intrabits) return 1; /* short circuit */
+
+    /* The easiest way to count the bits needed for coded/not coded fragments is
+       to code them. */
+    {
+      ogg_uint32_t bits = oggpackB_bits(cpi->oggbuffer);
+      fr_write(cpi,&fr);
+      interbits += ((oggpackB_bits(cpi->oggbuffer) - bits) << OC_BIT_SCALE);
+    }
+
+    if(interbits>intrabits) return 1;
+
+  }
+  return 0;
+}
+
+#if defined(OC_COLLECT_METRICS)
+# include <stdio.h>
+# include <math.h>
+
+# define OC_ZWEIGHT   (0.25)
+# define OC_BIN(_sad) (OC_MINI((_sad)>>OC_SAD_SHIFT,OC_SAD_BINS-1))
+
+static void oc_mode_metrics_add(oc_mode_metrics *_metrics,
+ double _w,int _sad,int _rate,double _rmse){
+  double rate;
+  /*Accumulate statistics without the scaling; this lets us change the scale
+     factor yet still use old data.*/
+  rate=ldexp(_rate,-OC_BIT_SCALE);
+  if(_metrics->fragw>0){
+    double dsad;
+    double drate;
+    double drmse;
+    double w;
+    dsad=_sad-_metrics->sad/_metrics->fragw;
+    drate=rate-_metrics->rate/_metrics->fragw;
+    drmse=_rmse-_metrics->rmse/_metrics->fragw;
+    w=_metrics->fragw*_w/(_metrics->fragw+_w);
+    _metrics->sad2+=dsad*dsad*w;
+    _metrics->sadrate+=dsad*drate*w;
+    _metrics->rate2+=drate*drate*w;
+    _metrics->sadrmse+=dsad*drmse*w;
+    _metrics->rmse2+=drmse*drmse*w;
+  }
+  _metrics->fragw+=_w;
+  _metrics->sad+=_sad*_w;
+  _metrics->rate+=rate*_w;
+  _metrics->rmse+=_rmse*_w;
+}
+
+static void oc_mode_metrics_merge(oc_mode_metrics *_dst,
+ const oc_mode_metrics *_src,int _n){
+  int i;
+  /*Find a non-empty set of metrics.*/
+  for(i=0;i<_n&&_src[i].fragw<=0;i++);
+  if(i>=_n){
+    memset(_dst,0,sizeof(*_dst));
+    return;
+  }
+  memcpy(_dst,_src+i,sizeof(*_dst));
+  /*And iterate over the remaining non-empty sets of metrics.*/
+  for(i++;i<_n;i++)if(_src[i].fragw>0){
+    double wa;
+    double wb;
+    double dsad;
+    double drate;
+    double drmse;
+    double w;
+    wa=_dst->fragw;
+    wb=_src[i].fragw;
+    dsad=_src[i].sad/wb-_dst->sad/wa;
+    drate=_src[i].rate/wb-_dst->rate/wa;
+    drmse=_src[i].rmse/wb-_dst->rmse/wa;
+    w=wa*wb/(wa+wb);
+    _dst->fragw+=_src[i].fragw;
+    _dst->sad+=_src[i].sad;
+    _dst->rate+=_src[i].rate;
+    _dst->rmse+=_src[i].rmse;
+    _dst->sad2+=_src[i].sad2+dsad*dsad*w;
+    _dst->sadrate+=_src[i].sadrate+dsad*drate*w;
+    _dst->rate2+=_src[i].rate2+drate*drate*w;
+    _dst->sadrmse+=_src[i].sadrmse+dsad*drmse*w;
+    _dst->rmse2+=_src[i].rmse2+drmse*drmse*w;
+  }
+}
+
+static void oc_enc_mode_metrics_update(CP_INSTANCE *cpi,int _qi){
+  int pli;
+  int qti;
+  oc_enc_restore_fpu(cpi);
+  /*Compile collected SAD/rate/RMSE metrics into a form that's immediately
+     useful for mode decision.*/
+  /*Convert raw collected data into cleaned up sample points.*/
+  for(pli=0;pli<3;pli++){
+    for(qti=0;qti<2;qti++){
+      double fragw;
+      int    bin0;
+      int    bin1;
+      int    bin;
+      fragw=0;
+      bin0=bin1=0;
+      for(bin=0;bin<OC_SAD_BINS;bin++){
+        oc_mode_metrics metrics;
+        OC_MODE_RD[_qi][pli][qti][bin].rate=0;
+        OC_MODE_RD[_qi][pli][qti][bin].rmse=0;
+        /*Find some points on either side of the current bin.*/
+        while((bin1<bin+1||fragw<OC_ZWEIGHT)&&bin1<OC_SAD_BINS-1){
+          fragw+=OC_MODE_METRICS[_qi][pli][qti][bin1++].fragw;
+        }
+        while(bin0+1<bin&&bin0+1<bin1&&
+         fragw-OC_MODE_METRICS[_qi][pli][qti][bin0].fragw>=OC_ZWEIGHT){
+          fragw-=OC_MODE_METRICS[_qi][pli][qti][bin0++].fragw;
+        }
+        /*Merge statistics and fit lines.*/
+        oc_mode_metrics_merge(&metrics,
+         OC_MODE_METRICS[_qi][pli][qti]+bin0,bin1-bin0);
+        if(metrics.fragw>0&&metrics.sad2>0){
+          double a;
+          double b;
+          double msad;
+          double mrate;
+          double mrmse;
+          double rate;
+          double rmse;
+          msad=metrics.sad/metrics.fragw;
+          mrate=metrics.rate/metrics.fragw;
+          mrmse=metrics.rmse/metrics.fragw;
+          /*Compute the points on these lines corresponding to the actual bin
+             value.*/
+          b=metrics.sadrate/metrics.sad2;
+          a=mrate-b*msad;
+          rate=ldexp(a+b*(bin<<OC_SAD_SHIFT),OC_BIT_SCALE);
+          OC_MODE_RD[_qi][pli][qti][bin].rate=
+           (ogg_int16_t)OC_CLAMPI(-32768,(int)(rate+0.5),32767);
+          b=metrics.sadrmse/metrics.sad2;
+          a=mrmse-b*msad;
+          rmse=ldexp(a+b*(bin<<OC_SAD_SHIFT),OC_RMSE_SCALE);
+          OC_MODE_RD[_qi][pli][qti][bin].rmse=
+           (ogg_int16_t)OC_CLAMPI(-32768,(int)(rmse+0.5),32767);
+        }
+      }
+    }
+  }
+}
+
+static int parse_eob_run(int token, int eb){
+  switch(token){
+  case DCT_EOB_TOKEN:
+    return 1;
+  case DCT_EOB_PAIR_TOKEN:
+    return 2;
+  case DCT_EOB_TRIPLE_TOKEN:
+    return 3;
+  case DCT_REPEAT_RUN_TOKEN:
+    return eb+4;
+  case DCT_REPEAT_RUN2_TOKEN:
+    return eb+8;
+  case DCT_REPEAT_RUN3_TOKEN:
+    return eb+16;
+  case DCT_REPEAT_RUN4_TOKEN:
+    return eb;
+  default:
+    return 0;
+  }
+}
+
+
+static void ModeMetricsGroup(CP_INSTANCE *cpi, int group, int huffY, int huffC, int eobcounts[64], int *actual_bits){
+  int ti=0;
+  int *stack = cpi->dct_eob_fi_stack[group];
+  int *tfi = cpi->dct_token_frag[group];
+  int ty = cpi->dct_token_ycount[group];
+  int tn = cpi->dct_token_count[group];
+
+  for(ti=0;ti<tn;ti++){
+    int token = cpi->dct_token[group][ti];
+    int bits = cpi->huff_codes[(ti<ty ? huffY : huffC)][token].nbits + OC_DCT_TOKEN_EXTRA_BITS[token];
+
+    if(token>DCT_REPEAT_RUN4_TOKEN){
+      /* not an EOB run; this token belongs to a single fragment */
+      int fi = tfi[ti];
+      actual_bits[fi] += (bits<<OC_BIT_SCALE);
+    }else{
+
+      int run = parse_eob_run(token, cpi->dct_token_eb[group][ti]);
+      int fi = stack[eobcounts[group]];
+      actual_bits[fi]+=(bits<<OC_BIT_SCALE);
+
+      if(ti+1<tn){
+        /* tokens follow EOB so it must be entirely ensconced within this plane/group */
+        eobcounts[group]+=run;
+      }else{
+        /* EOB is the last token in this plane/group, so it may span into the next plane/group */
+        int n = cpi->dct_eob_fi_count[group];
+        while(run){
+          int rem = n - eobcounts[group];
+          if(rem>run)rem=run;
+
+          eobcounts[group]+=rem;
+          run -= rem;
+          if(run){
+            group++;
+            n = cpi->dct_eob_fi_count[group];
+            stack = cpi->dct_eob_fi_stack[group];
+          }
+        }
+      }
+    }
+  }
+}
+
+void ModeMetrics(CP_INSTANCE *cpi){
+  double fragw;
+  int interp = (cpi->FrameType!=KEY_FRAME);
+  int huff[4];
+  int fi,gi;
+  int y = cpi->frag_n[0];
+  int u = y + cpi->frag_n[1];
+  int v = cpi->frag_total;
+  unsigned char *cp = cpi->frag_coded;
+  int *sp = cpi->frag_sad;
+  int *mp = cpi->frag_mbi;
+  int eobcounts[64];
+  int qi = cpi->BaseQ; /* temporary */
+  int actual_bits[cpi->frag_total];
+  oc_enc_restore_fpu(cpi);
+  /*Weight the fragments by the inverse frame size; this prevents HD content
+     from dominating the statistics.*/
+  fragw=1.0/cpi->frag_n[0];
+  memset(actual_bits,0,sizeof(actual_bits));
+  memset(eobcounts,0,sizeof(eobcounts));
+  huff[0] = cpi->huffchoice[interp][0][0];
+  huff[1] = cpi->huffchoice[interp][0][1];
+  huff[2] = cpi->huffchoice[interp][1][0];
+  huff[3] = cpi->huffchoice[interp][1][1];
+
+  memset(cpi->dist_dist,0,sizeof(cpi->dist_dist));
+  memset(cpi->dist_bits,0,sizeof(cpi->dist_bits));
+
+  if(!oc_has_mode_metrics){
+    FILE *fmetrics;
+    int   qi;
+    memset(OC_MODE_METRICS,0,sizeof(OC_MODE_METRICS));
+    fmetrics=fopen("modedec.stats","rb");
+    if(fmetrics!=NULL){
+      fread(OC_MODE_METRICS,sizeof(OC_MODE_METRICS),1,fmetrics);
+      fclose(fmetrics);
+    }
+    for(qi=0;qi<64;qi++)oc_enc_mode_metrics_update(cpi,qi);
+    oc_has_mode_metrics=1;
+  }
+
+  /* count bits for tokens */
+  ModeMetricsGroup(cpi, 0, huff[0], huff[1], eobcounts, actual_bits);
+  for(gi=1;gi<=AC_TABLE_2_THRESH;gi++)
+    ModeMetricsGroup(cpi, gi,  huff[2], huff[3], eobcounts, actual_bits);
+  for(;gi<=AC_TABLE_3_THRESH;gi++)
+    ModeMetricsGroup(cpi, gi, huff[2]+AC_HUFF_CHOICES, huff[3]+AC_HUFF_CHOICES, eobcounts, actual_bits);
+  for(;gi<=AC_TABLE_4_THRESH;gi++)
+    ModeMetricsGroup(cpi, gi, huff[2]+AC_HUFF_CHOICES*2, huff[3]+AC_HUFF_CHOICES*2, eobcounts, actual_bits);
+  for(;gi<BLOCK_SIZE;gi++)
+    ModeMetricsGroup(cpi, gi, huff[2]+AC_HUFF_CHOICES*3, huff[3]+AC_HUFF_CHOICES*3, eobcounts, actual_bits);
+
+  /* accumulate */
+  for(fi=0;fi<v;fi++)if(cp[fi]){
+    int mbi = mp[fi];
+    macroblock_t *mb = &cpi->macro[mbi];
+    int mode = mb->mode;
+    int plane = (fi<y ? 0 : (fi<u ? 1 : 2));
+    int bin = OC_BIN(sp[fi]);
+    oc_mode_metrics_add(OC_MODE_METRICS[qi][plane][mode!=CODE_INTRA]+bin,
+     fragw,sp[fi],actual_bits[fi],sqrt(cpi->frag_ssd[fi]));
+  }
+  /* update global SAD/rate estimation matrix */
+  oc_enc_mode_metrics_update(cpi,qi);
+}
+
+void oc_enc_mode_metrics_dump(CP_INSTANCE *cpi){
+  FILE *fmetrics;
+  int   qi;
+  /*Generate sample points for complete list of QI values.*/
+  for(qi=0;qi<64;qi++)oc_enc_mode_metrics_update(cpi,qi);
+  fmetrics=fopen("modedec.stats","wb");
+  if(fmetrics!=NULL){
+    fwrite(OC_MODE_METRICS,sizeof(OC_MODE_METRICS),1,fmetrics);
+    fclose(fmetrics);
+  }
+  fprintf(stdout,
+   "/*File generated by libtheora with OC_COLLECT_METRICS"
+   " defined at compile time.*/\n"
+   "#if !defined(_modedec_H)\n"
+   "# define _modedec_H (1)\n"
+   "\n"
+   "\n"
+   "\n"
+   "# if defined(OC_COLLECT_METRICS)\n"
+   "typedef struct oc_mode_metrics oc_mode_metrics;\n"
+   "# endif\n"
+   "typedef struct oc_mode_rd      oc_mode_rd;\n"
+   "\n"
+   "\n"
+   "\n"
+   "/*The number of extra bits of precision at which to store rate"
+   " metrics.*/\n"
+   "# define OC_BIT_SCALE  (%i)\n"
+   "/*The number of extra bits of precision at which to store RMSE metrics.\n"
+   "  This must be at least half OC_BIT_SCALE (rounded up).*/\n"
+   "# define OC_RMSE_SCALE (%i)\n"
+   "/*The number of bins to partition statistics into.*/\n"
+   "# define OC_SAD_BINS   (%i)\n"
+   "/*The number of bits of precision to drop"
+   " from SAD scores to assign them to a\n"
+   "   bin.*/\n"
+   "# define OC_SAD_SHIFT  (%i)\n"
+   "\n"
+   "\n"
+   "\n"
+   "# if defined(OC_COLLECT_METRICS)\n"
+   "struct oc_mode_metrics{\n"
+   "  double fragw;\n"
+   "  double sad;\n"
+   "  double rate;\n"
+   "  double rmse;\n"
+   "  double sad2;\n"
+   "  double sadrate;\n"
+   "  double rate2;\n"
+   "  double sadrmse;\n"
+   "  double rmse2;\n"
+   "};\n"
+   "\n"
+   "\n"
+   "int             oc_has_mode_metrics;\n"
+   "oc_mode_metrics OC_MODE_METRICS[64][3][2][OC_SAD_BINS];\n"
+   "# endif\n"
+   "\n"
+   "\n"
+   "\n"
+   "struct oc_mode_rd{\n"
+   "  ogg_int16_t rate;\n"
+   "  ogg_int16_t rmse;\n"
+   "};\n"
+   "\n"
+   "\n"
+   "# if !defined(OC_COLLECT_METRICS)\n"
+   "static const\n"
+   "# endif\n"
+   "oc_mode_rd OC_MODE_RD[64][3][2][OC_SAD_BINS]={\n",
+   OC_BIT_SCALE,OC_RMSE_SCALE,OC_SAD_BINS,OC_SAD_SHIFT);
+  for(qi=0;qi<64;qi++){
+    int pli;
+    fprintf(stdout,"  {\n");
+    for(pli=0;pli<3;pli++){
+      int qti;
+      fprintf(stdout,"    {\n");
+      for(qti=0;qti<2;qti++){
+        int bin;
+        static const char *pl_names[3]={"Y'","Cb","Cr"};
+        static const char *qti_names[2]={"INTRA","INTER"};
+        fprintf(stdout,"      /*%s  qi=%i  %s*/\n",
+         pl_names[pli],qi,qti_names[qti]);
+        fprintf(stdout,"      {\n");
+        fprintf(stdout,"        ");
+        for(bin=0;bin<OC_SAD_BINS;bin++){
+          if(bin&&!(bin&0x3))fprintf(stdout,"\n        ");
+          fprintf(stdout,"{%5i,%5i}",
+           OC_MODE_RD[qi][pli][qti][bin].rate,
+           OC_MODE_RD[qi][pli][qti][bin].rmse);
+          if(bin+1<OC_SAD_BINS)fprintf(stdout,",");
+        }
+        fprintf(stdout,"\n      }");
+        if(qti<1)fprintf(stdout,",");
+        fprintf(stdout,"\n");
+      }
+      fprintf(stdout,"    }");
+      if(pli<2)fprintf(stdout,",");
+      fprintf(stdout,"\n");
+    }
+    fprintf(stdout,"  }");
+    if(qi<63)fprintf(stdout,",");
+    fprintf(stdout,"\n");
+  }
+  fprintf(stdout,
+   "};\n"
+   "\n"
+   "#endif\n");
+}
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/modedec.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/modedec.h
new file mode 100644
index 0000000..cf0866a
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/modedec.h
@@ -0,0 +1,4027 @@
+//*File generated by libtheora with OC_COLLECT_METRICS defined at compile time.*/
+#if !defined(_modedec_H)
+# define _modedec_H (1)
+
+
+
+# if defined(OC_COLLECT_METRICS)
+typedef struct oc_mode_metrics oc_mode_metrics;
+# endif
+typedef struct oc_mode_rd      oc_mode_rd;
+
+
+
+/*The number of extra bits of precision at which to store rate metrics.*/
+# define OC_BIT_SCALE  (6)
+/*The number of extra bits of precision at which to store RMSE metrics.
+  This must be at least half OC_BIT_SCALE (rounded up).*/
+# define OC_RMSE_SCALE (5)
+/*The number of bins to partition statistics into.*/
+# define OC_SAD_BINS   (24)
+/*The number of bits of precision to drop from SAD scores to assign them to a
+   bin.*/
+# define OC_SAD_SHIFT  (9)
+
+
+
+# if defined(OC_COLLECT_METRICS)
+struct oc_mode_metrics{
+  double fragw;
+  double sad;
+  double rate;
+  double rmse;
+  double sad2;
+  double sadrate;
+  double rate2;
+  double sadrmse;
+  double rmse2;
+};
+
+
+int             oc_has_mode_metrics;
+oc_mode_metrics OC_MODE_METRICS[64][3][2][OC_SAD_BINS];
+# endif
+
+
+
+struct oc_mode_rd{
+  ogg_int16_t rate;
+  ogg_int16_t rmse;
+};
+
+
+# if !defined(OC_COLLECT_METRICS)
+static const
+# endif
+oc_mode_rd OC_MODE_RD[64][3][2][OC_SAD_BINS]={
+  {
+    {
+      /*Y'  qi=0  INTRA*/
+      {
+        {  172,  -63},{  218, 1603},{  265, 3547},{  333, 5324},
+        {  424, 6541},{  520, 7452},{  615, 8306},{  706, 9139},
+        {  796, 9953},{  891,10771},{  989,11586},{ 1096,12392},
+        { 1205,13151},{ 1304,13829},{ 1388,14586},{ 1475,15372},
+        { 1566,16084},{ 1654,16833},{ 1746,17548},{ 1838,18221},
+        { 1927,18914},{ 2017,19622},{ 2102,20326},{ 2170,21128}
+      },
+      /*Y'  qi=0  INTER*/
+      {
+        {  136, -147},{   93, 1359},{  122, 2917},{  149, 4559},
+        {  165, 6181},{  177, 7697},{  190, 9078},{  204,10362},
+        {  220,11653},{  240,12884},{  268,14050},{  301,15223},
+        {  336,16392},{  370,17564},{  404,18716},{  443,19858},
+        {  482,20992},{  526,22096},{  586,23182},{  653,24238},
+        {  725,25263},{  797,26287},{  874,27271},{  959,28217}
+      }
+    },
+    {
+      /*Cb  qi=0  INTRA*/
+      {
+        {    9,    2},{   67,  365},{  111,  742},{  129, 1183},
+        {  142, 1661},{  157, 2165},{  169, 2686},{  173, 3205},
+        {  181, 3685},{  190, 4166},{  196, 4618},{  202, 5034},
+        {  209, 5470},{  217, 5883},{  224, 6272},{  237, 6630},
+        {  253, 6962},{  260, 7315},{  275, 7663},{  287, 8010},
+        {  294, 8367},{  308, 8640},{  328, 8931},{  367, 9355}
+      },
+      /*Cb  qi=0  INTER*/
+      {
+        {  129,  -50},{  123,  303},{  117,  654},{  114, 1025},
+        {  113, 1434},{  112, 1854},{  117, 2271},{  122, 2682},
+        {  126, 3101},{  129, 3532},{  132, 3962},{  134, 4383},
+        {  136, 4802},{  139, 5188},{  142, 5544},{  145, 5904},
+        {  145, 6270},{  146, 6638},{  148, 6998},{  149, 7345},
+        {  150, 7697},{  153, 8045},{  154, 8401},{  153, 8788}
+      }
+    },
+    {
+      /*Cr  qi=0  INTRA*/
+      {
+        {    5,    4},{   58,  373},{  102,  762},{  127, 1227},
+        {  139, 1710},{  147, 2210},{  156, 2712},{  165, 3178},
+        {  174, 3642},{  183, 4103},{  198, 4561},{  209, 4989},
+        {  217, 5373},{  225, 5788},{  235, 6194},{  245, 6587},
+        {  253, 7005},{  268, 7368},{  287, 7714},{  298, 8043},
+        {  304, 8410},{  318, 8695},{  327, 8926},{  342, 9294}
+      },
+      /*Cr  qi=0  INTER*/
+      {
+        {   88,   18},{   98,  337},{  108,  648},{  119, 1017},
+        {  117, 1432},{  117, 1842},{  121, 2250},{  125, 2663},
+        {  127, 3082},{  129, 3503},{  131, 3920},{  131, 4345},
+        {  134, 4757},{  137, 5155},{  138, 5551},{  137, 5941},
+        {  138, 6336},{  140, 6715},{  143, 7100},{  146, 7467},
+        {  150, 7805},{  153, 8150},{  157, 8499},{  159, 8860}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=1  INTRA*/
+      {
+        {  180,  -58},{  226, 1601},{  279, 3502},{  358, 5179},
+        {  463, 6309},{  571, 7184},{  674, 8016},{  776, 8821},
+        {  878, 9601},{  985,10382},{ 1096,11169},{ 1216,11930},
+        { 1333,12652},{ 1437,13332},{ 1535,14052},{ 1636,14795},
+        { 1736,15477},{ 1833,16184},{ 1930,16870},{ 2030,17514},
+        { 2130,18188},{ 2228,18859},{ 2326,19535},{ 2417,20310}
+      },
+      /*Y'  qi=1  INTER*/
+      {
+        {  146,  -73},{   98, 1355},{  128, 2908},{  156, 4550},
+        {  173, 6168},{  188, 7635},{  203, 8959},{  221,10217},
+        {  242,11464},{  269,12679},{  304,13838},{  344,14978},
+        {  388,16124},{  435,17267},{  479,18403},{  529,19526},
+        {  583,20640},{  645,21716},{  723,22748},{  807,23762},
+        {  892,24739},{  980,25687},{ 1074,26614},{ 1179,27501}
+      }
+    },
+    {
+      /*Cb  qi=1  INTRA*/
+      {
+        {    9,    2},{   70,  365},{  120,  742},{  143, 1183},
+        {  153, 1663},{  163, 2167},{  173, 2690},{  180, 3208},
+        {  188, 3686},{  200, 4164},{  207, 4612},{  214, 5008},
+        {  228, 5426},{  239, 5823},{  245, 6192},{  257, 6527},
+        {  273, 6841},{  282, 7178},{  299, 7512},{  315, 7837},
+        {  324, 8190},{  344, 8438},{  369, 8685},{  410, 9117}
+      },
+      /*Cb  qi=1  INTER*/
+      {
+        {   86,  -49},{   98,  303},{  108,  655},{  116, 1027},
+        {  113, 1433},{  114, 1848},{  120, 2263},{  126, 2679},
+        {  130, 3103},{  132, 3529},{  134, 3956},{  137, 4378},
+        {  139, 4770},{  142, 5146},{  145, 5518},{  145, 5878},
+        {  147, 6239},{  150, 6591},{  153, 6941},{  153, 7298},
+        {  155, 7648},{  158, 7991},{  161, 8340},{  167, 8699}
+      }
+    },
+    {
+      /*Cr  qi=1  INTRA*/
+      {
+        {    5,    4},{   63,  373},{  111,  762},{  136, 1227},
+        {  149, 1711},{  159, 2211},{  167, 2715},{  177, 3180},
+        {  187, 3639},{  198, 4062},{  216, 4473},{  228, 4910},
+        {  234, 5316},{  244, 5723},{  256, 6115},{  268, 6484},
+        {  282, 6876},{  300, 7212},{  316, 7532},{  327, 7840},
+        {  335, 8183},{  352, 8432},{  362, 8632},{  372, 8949}
+      },
+      /*Cr  qi=1  INTER*/
+      {
+        {  139,    9},{  120,  326},{  112,  649},{  116, 1028},
+        {  117, 1441},{  120, 1842},{  124, 2245},{  127, 2663},
+        {  129, 3087},{  130, 3513},{  132, 3932},{  134, 4344},
+        {  137, 4748},{  139, 5144},{  141, 5536},{  143, 5921},
+        {  143, 6297},{  145, 6665},{  148, 7030},{  152, 7392},
+        {  155, 7729},{  157, 8067},{  160, 8410},{  164, 8739}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=2  INTRA*/
+      {
+        {  186,  -63},{  235, 1599},{  293, 3459},{  382, 5040},
+        {  502, 6099},{  622, 6939},{  738, 7732},{  855, 8498},
+        {  969, 9249},{ 1088,10000},{ 1214,10745},{ 1344,11462},
+        { 1472,12147},{ 1589,12822},{ 1699,13505},{ 1813,14184},
+        { 1925,14844},{ 2032,15535},{ 2140,16201},{ 2249,16824},
+        { 2355,17461},{ 2460,18093},{ 2570,18726},{ 2665,19470}
+      },
+      /*Y'  qi=2  INTER*/
+      {
+        {  114,  -52},{  100, 1348},{  133, 2895},{  163, 4538},
+        {  182, 6128},{  200, 7525},{  217, 8799},{  239,10033},
+        {  267,11258},{  302,12447},{  347,13598},{  397,14723},
+        {  451,15836},{  505,16967},{  566,18081},{  636,19149},
+        {  711,20211},{  796,21263},{  892,22248},{  991,23201},
+        { 1091,24136},{ 1204,25012},{ 1323,25848},{ 1442,26670}
+      }
+    },
+    {
+      /*Cb  qi=2  INTRA*/
+      {
+        {    9,    2},{   75,  366},{  127,  742},{  147, 1184},
+        {  158, 1665},{  171, 2171},{  182, 2693},{  188, 3210},
+        {  198, 3673},{  210, 4109},{  219, 4538},{  228, 4954},
+        {  240, 5368},{  252, 5743},{  263, 6092},{  278, 6416},
+        {  294, 6721},{  308, 7038},{  325, 7358},{  333, 7686},
+        {  344, 8014},{  371, 8220},{  404, 8422},{  441, 8683}
+      },
+      /*Cb  qi=2  INTER*/
+      {
+        {  141, -126},{  130,  236},{  120,  594},{  113,  979},
+        {  115, 1411},{  116, 1837},{  122, 2252},{  128, 2668},
+        {  132, 3094},{  135, 3523},{  136, 3946},{  138, 4358},
+        {  141, 4753},{  145, 5135},{  147, 5496},{  148, 5850},
+        {  150, 6214},{  154, 6561},{  158, 6889},{  161, 7227},
+        {  164, 7563},{  166, 7894},{  169, 8237},{  175, 8573}
+      }
+    },
+    {
+      /*Cr  qi=2  INTRA*/
+      {
+        {    5,    4},{   66,  373},{  114,  762},{  139, 1228},
+        {  154, 1714},{  165, 2216},{  172, 2720},{  183, 3187},
+        {  195, 3637},{  205, 4047},{  222, 4443},{  239, 4857},
+        {  249, 5249},{  262, 5642},{  278, 6031},{  290, 6378},
+        {  307, 6742},{  323, 7071},{  342, 7359},{  355, 7644},
+        {  363, 7972},{  383, 8186},{  399, 8373},{  428, 8675}
+      },
+      /*Cr  qi=2  INTER*/
+      {
+        {  109,   -7},{  109,  326},{  114,  640},{  119, 1017},
+        {  120, 1423},{  122, 1830},{  126, 2243},{  128, 2663},
+        {  130, 3089},{  132, 3514},{  134, 3931},{  137, 4345},
+        {  138, 4748},{  140, 5138},{  143, 5521},{  145, 5895},
+        {  148, 6262},{  151, 6624},{  155, 6988},{  158, 7343},
+        {  162, 7670},{  169, 7987},{  171, 8300},{  174, 8630}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=3  INTRA*/
+      {
+        {  191,  -64},{  242, 1597},{  305, 3413},{  407, 4918},
+        {  541, 5923},{  672, 6731},{  797, 7504},{  924, 8251},
+        { 1047, 8986},{ 1175, 9717},{ 1311,10437},{ 1453,11125},
+        { 1590,11786},{ 1718,12431},{ 1838,13095},{ 1958,13784},
+        { 2078,14411},{ 2196,15059},{ 2309,15712},{ 2424,16311},
+        { 2538,16930},{ 2651,17541},{ 2766,18161},{ 2869,18889}
+      },
+      /*Y'  qi=3  INTER*/
+      {
+        {  147,  -56},{  103, 1351},{  138, 2897},{  169, 4523},
+        {  191, 6071},{  212, 7429},{  234, 8690},{  261, 9919},
+        {  296,11128},{  338,12302},{  392,13431},{  454,14530},
+        {  522,15620},{  593,16713},{  664,17804},{  745,18866},
+        {  844,19878},{  943,20872},{ 1050,21826},{ 1163,22748},
+        { 1280,23627},{ 1406,24454},{ 1535,25254},{ 1671,26041}
+      }
+    },
+    {
+      /*Cb  qi=3  INTRA*/
+      {
+        {   11,    2},{   78,  366},{  131,  743},{  152, 1186},
+        {  164, 1668},{  177, 2173},{  186, 2694},{  192, 3207},
+        {  205, 3664},{  220, 4088},{  232, 4508},{  242, 4919},
+        {  253, 5313},{  269, 5663},{  287, 5992},{  301, 6308},
+        {  317, 6588},{  332, 6894},{  350, 7204},{  364, 7506},
+        {  375, 7818},{  403, 8020},{  439, 8208},{  483, 8456}
+      },
+      /*Cb  qi=3  INTER*/
+      {
+        {  121,  -62},{  119,  286},{  116,  631},{  112, 1004},
+        {  112, 1427},{  118, 1851},{  125, 2268},{  131, 2687},
+        {  134, 3111},{  137, 3536},{  140, 3950},{  143, 4354},
+        {  146, 4746},{  150, 5117},{  152, 5493},{  155, 5843},
+        {  158, 6173},{  161, 6509},{  164, 6834},{  167, 7165},
+        {  171, 7499},{  175, 7831},{  178, 8153},{  179, 8462}
+      }
+    },
+    {
+      /*Cr  qi=3  INTRA*/
+      {
+        {    5,    4},{   71,  374},{  121,  764},{  145, 1230},
+        {  158, 1717},{  169, 2221},{  178, 2723},{  188, 3189},
+        {  200, 3634},{  211, 4035},{  230, 4419},{  248, 4823},
+        {  262, 5199},{  279, 5563},{  292, 5946},{  306, 6291},
+        {  330, 6623},{  352, 6924},{  376, 7223},{  389, 7488},
+        {  393, 7763},{  411, 7973},{  432, 8158},{  457, 8455}
+      },
+      /*Cr  qi=3  INTER*/
+      {
+        {   96,   17},{  107,  333},{  111,  656},{  117, 1031},
+        {  120, 1440},{  123, 1848},{  128, 2257},{  131, 2679},
+        {  132, 3107},{  134, 3529},{  137, 3939},{  140, 4340},
+        {  142, 4738},{  145, 5130},{  148, 5500},{  150, 5854},
+        {  154, 6212},{  159, 6569},{  164, 6924},{  170, 7258},
+        {  174, 7567},{  178, 7883},{  183, 8190},{  196, 8493}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=4  INTRA*/
+      {
+        {  192,  -64},{  245, 1594},{  314, 3374},{  428, 4815},
+        {  574, 5781},{  715, 6566},{  852, 7311},{  992, 8028},
+        { 1128, 8727},{ 1268, 9429},{ 1411,10136},{ 1561,10799},
+        { 1711,11419},{ 1849,12044},{ 1977,12684},{ 2103,13333},
+        { 2232,13939},{ 2360,14569},{ 2485,15194},{ 2606,15774},
+        { 2723,16370},{ 2844,16938},{ 2964,17526},{ 3073,18257}
+      },
+      /*Y'  qi=4  INTER*/
+      {
+        {  132,  -95},{  100, 1357},{  140, 2894},{  173, 4496},
+        {  196, 5989},{  219, 7318},{  246, 8578},{  279, 9789},
+        {  320,10973},{  374,12128},{  440,13231},{  514,14309},
+        {  596,15382},{  679,16465},{  769,17527},{  872,18543},
+        {  978,19537},{ 1092,20482},{ 1216,21384},{ 1343,22259},
+        { 1478,23075},{ 1623,23822},{ 1775,24492},{ 1939,25083}
+      }
+    },
+    {
+      /*Cb  qi=4  INTRA*/
+      {
+        {   10,    2},{   80,  366},{  136,  743},{  158, 1186},
+        {  169, 1670},{  181, 2176},{  193, 2696},{  200, 3206},
+        {  212, 3659},{  228, 4080},{  239, 4490},{  254, 4891},
+        {  271, 5271},{  284, 5605},{  301, 5919},{  318, 6225},
+        {  337, 6510},{  358, 6799},{  384, 7069},{  395, 7356},
+        {  409, 7640},{  439, 7840},{  471, 8023},{  521, 8202}
+      },
+      /*Cb  qi=4  INTER*/
+      {
+        {  126,  -54},{  121,  305},{  117,  662},{  112, 1042},
+        {  110, 1447},{  117, 1859},{  125, 2275},{  130, 2696},
+        {  134, 3121},{  137, 3540},{  140, 3956},{  143, 4352},
+        {  147, 4732},{  150, 5096},{  154, 5444},{  159, 5783},
+        {  163, 6120},{  165, 6452},{  169, 6781},{  174, 7106},
+        {  177, 7426},{  182, 7748},{  189, 8069},{  187, 8390}
+      }
+    },
+    {
+      /*Cr  qi=4  INTRA*/
+      {
+        {    5,    4},{   76,  374},{  128,  764},{  150, 1230},
+        {  162, 1718},{  173, 2223},{  183, 2727},{  195, 3191},
+        {  208, 3629},{  219, 4019},{  240, 4385},{  263, 4773},
+        {  279, 5145},{  293, 5503},{  305, 5869},{  320, 6195},
+        {  346, 6506},{  370, 6792},{  396, 7055},{  418, 7299},
+        {  428, 7591},{  443, 7811},{  461, 7996},{  494, 8275}
+      },
+      /*Cr  qi=4  INTER*/
+      {
+        {  110,   25},{  110,  339},{  115,  661},{  115, 1040},
+        {  117, 1453},{  121, 1863},{  125, 2274},{  129, 2695},
+        {  131, 3115},{  133, 3531},{  136, 3942},{  139, 4343},
+        {  143, 4729},{  146, 5105},{  149, 5470},{  154, 5828},
+        {  157, 6183},{  161, 6520},{  167, 6854},{  176, 7181},
+        {  184, 7488},{  189, 7791},{  194, 8091},{  198, 8385}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=5  INTRA*/
+      {
+        {  195,  -61},{  247, 1591},{  319, 3349},{  443, 4760},
+        {  600, 5698},{  751, 6454},{  901, 7161},{ 1051, 7851},
+        { 1197, 8526},{ 1349, 9190},{ 1503, 9860},{ 1661,10491},
+        { 1820,11089},{ 1970,11684},{ 2106,12296},{ 2241,12910},
+        { 2381,13489},{ 2518,14102},{ 2651,14694},{ 2779,15243},
+        { 2903,15804},{ 3033,16352},{ 3164,16905},{ 3279,17578}
+      },
+      /*Y'  qi=5  INTER*/
+      {
+        {  134,  -96},{  101, 1355},{  141, 2890},{  176, 4464},
+        {  204, 5918},{  232, 7225},{  263, 8463},{  304, 9661},
+        {  357,10829},{  425,11946},{  506,13015},{  597,14074},
+        {  690,15134},{  791,16186},{  902,17203},{ 1020,18179},
+        { 1143,19128},{ 1277,20023},{ 1419,20864},{ 1565,21660},
+        { 1721,22387},{ 1886,23034},{ 2060,23581},{ 2246,24016}
+      }
+    },
+    {
+      /*Cb  qi=5  INTRA*/
+      {
+        {   10,    2},{   82,  366},{  138,  743},{  159, 1187},
+        {  170, 1670},{  182, 2176},{  194, 2696},{  202, 3204},
+        {  214, 3654},{  232, 4063},{  244, 4461},{  259, 4852},
+        {  280, 5222},{  298, 5537},{  315, 5819},{  334, 6104},
+        {  358, 6389},{  381, 6667},{  410, 6915},{  427, 7190},
+        {  439, 7468},{  465, 7673},{  504, 7867},{  560, 8096}
+      },
+      /*Cb  qi=5  INTER*/
+      {
+        {  117,  -83},{  115,  289},{  114,  658},{  111, 1042},
+        {  110, 1446},{  116, 1859},{  124, 2276},{  130, 2698},
+        {  135, 3119},{  138, 3539},{  141, 3945},{  144, 4332},
+        {  148, 4703},{  153, 5066},{  158, 5416},{  161, 5746},
+        {  164, 6072},{  168, 6394},{  173, 6716},{  181, 7039},
+        {  190, 7344},{  195, 7652},{  198, 7975},{  200, 8302}
+      }
+    },
+    {
+      /*Cr  qi=5  INTRA*/
+      {
+        {    6,    4},{   77,  374},{  130,  764},{  152, 1231},
+        {  163, 1719},{  175, 2224},{  186, 2725},{  197, 3186},
+        {  211, 3622},{  222, 4010},{  245, 4368},{  270, 4742},
+        {  286, 5102},{  306, 5436},{  320, 5785},{  334, 6101},
+        {  363, 6386},{  389, 6662},{  413, 6914},{  439, 7148},
+        {  461, 7419},{  478, 7627},{  495, 7800},{  531, 8092}
+      },
+      /*Cr  qi=5  INTER*/
+      {
+        {  121,   19},{  112,  336},{  111,  657},{  114, 1037},
+        {  115, 1451},{  120, 1861},{  125, 2272},{  128, 2692},
+        {  131, 3112},{  133, 3526},{  136, 3933},{  140, 4329},
+        {  143, 4707},{  147, 5072},{  151, 5432},{  157, 5789},
+        {  162, 6128},{  167, 6459},{  175, 6800},{  183, 7115},
+        {  191, 7402},{  199, 7692},{  207, 7984},{  216, 8259}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=6  INTRA*/
+      {
+        {  195,  -62},{  255, 1587},{  337, 3305},{  476, 4655},
+        {  647, 5547},{  812, 6263},{  976, 6937},{ 1139, 7601},
+        { 1295, 8257},{ 1455, 8903},{ 1622, 9551},{ 1794,10157},
+        { 1963,10732},{ 2123,11297},{ 2269,11892},{ 2412,12506},
+        { 2558,13078},{ 2706,13650},{ 2850,14213},{ 2985,14755},
+        { 3118,15295},{ 3256,15813},{ 3395,16340},{ 3519,17010}
+      },
+      /*Y'  qi=6  INTER*/
+      {
+        {  155, -118},{  107, 1348},{  147, 2882},{  185, 4440},
+        {  217, 5866},{  250, 7139},{  287, 8355},{  338, 9537},
+        {  405,10677},{  488,11763},{  587,12810},{  693,13850},
+        {  804,14888},{  924,15904},{ 1051,16883},{ 1185,17824},
+        { 1327,18720},{ 1478,19567},{ 1637,20351},{ 1807,21058},
+        { 1984,21690},{ 2171,22235},{ 2367,22697},{ 2568,23093}
+      }
+    },
+    {
+      /*Cb  qi=6  INTRA*/
+      {
+        {   11,    2},{   85,  366},{  142,  743},{  163, 1187},
+        {  176, 1669},{  189, 2174},{  200, 2691},{  208, 3192},
+        {  222, 3634},{  242, 4036},{  256, 4424},{  274, 4795},
+        {  296, 5134},{  314, 5423},{  337, 5693},{  359, 5975},
+        {  383, 6243},{  411, 6488},{  442, 6706},{  462, 6983},
+        {  483, 7250},{  512, 7449},{  549, 7636},{  605, 7799}
+      },
+      /*Cb  qi=6  INTER*/
+      {
+        {  106,   -3},{  111,  332},{  117,  668},{  113, 1039},
+        {  114, 1442},{  120, 1856},{  128, 2272},{  134, 2691},
+        {  138, 3111},{  142, 3528},{  145, 3926},{  149, 4308},
+        {  155, 4677},{  159, 5029},{  164, 5367},{  168, 5692},
+        {  173, 6010},{  179, 6326},{  186, 6642},{  191, 6964},
+        {  201, 7275},{  210, 7581},{  216, 7898},{  224, 8221}
+      }
+    },
+    {
+      /*Cr  qi=6  INTRA*/
+      {
+        {    7,    4},{   79,  374},{  133,  764},{  156, 1232},
+        {  168, 1722},{  180, 2227},{  193, 2729},{  206, 3189},
+        {  220, 3615},{  231, 3988},{  255, 4338},{  282, 4701},
+        {  300, 5039},{  323, 5340},{  343, 5665},{  363, 5968},
+        {  396, 6231},{  422, 6494},{  448, 6724},{  477, 6936},
+        {  496, 7206},{  517, 7409},{  533, 7591},{  555, 7913}
+      },
+      /*Cr  qi=6  INTER*/
+      {
+        {  100,   31},{  109,  342},{  115,  660},{  116, 1039},
+        {  118, 1448},{  123, 1858},{  128, 2274},{  131, 2692},
+        {  134, 3109},{  136, 3523},{  139, 3926},{  143, 4312},
+        {  148, 4681},{  154, 5040},{  157, 5391},{  163, 5737},
+        {  171, 6069},{  178, 6396},{  185, 6720},{  195, 7027},
+        {  205, 7320},{  214, 7610},{  227, 7896},{  249, 8152}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=7  INTRA*/
+      {
+        {  195,  -62},{  258, 1583},{  344, 3282},{  493, 4607},
+        {  674, 5472},{  849, 6160},{ 1025, 6812},{ 1196, 7460},
+        { 1360, 8101},{ 1528, 8730},{ 1700, 9356},{ 1879, 9940},
+        { 2057,10499},{ 2225,11041},{ 2383,11606},{ 2536,12196},
+        { 2691,12742},{ 2848,13295},{ 2999,13847},{ 3140,14366},
+        { 3279,14887},{ 3421,15386},{ 3569,15879},{ 3712,16474}
+      },
+      /*Y'  qi=7  INTER*/
+      {
+        {  152, -129},{  108, 1347},{  149, 2880},{  189, 4422},
+        {  225, 5823},{  262, 7073},{  306, 8274},{  367, 9438},
+        {  446,10551},{  544,11615},{  658,12639},{  775,13657},
+        {  900,14670},{ 1039,15647},{ 1183,16590},{ 1331,17495},
+        { 1488,18347},{ 1654,19138},{ 1831,19864},{ 2017,20508},
+        { 2212,21055},{ 2413,21536},{ 2621,21925},{ 2816,22241}
+      }
+    },
+    {
+      /*Cb  qi=7  INTRA*/
+      {
+        {   11,    2},{   84,  366},{  142,  744},{  164, 1187},
+        {  176, 1669},{  190, 2174},{  203, 2685},{  211, 3177},
+        {  225, 3621},{  243, 4022},{  261, 4396},{  282, 4755},
+        {  306, 5085},{  326, 5361},{  350, 5609},{  373, 5886},
+        {  401, 6149},{  432, 6382},{  467, 6582},{  494, 6836},
+        {  519, 7096},{  544, 7299},{  585, 7473},{  649, 7631}
+      },
+      /*Cb  qi=7  INTER*/
+      {
+        {  127,   25},{  118,  340},{  112,  666},{  110, 1040},
+        {  112, 1443},{  120, 1856},{  128, 2272},{  134, 2693},
+        {  138, 3115},{  142, 3527},{  146, 3923},{  150, 4300},
+        {  155, 4661},{  160, 5005},{  166, 5335},{  171, 5654},
+        {  177, 5966},{  183, 6284},{  191, 6595},{  200, 6899},
+        {  208, 7205},{  215, 7523},{  222, 7835},{  235, 8121}
+      }
+    },
+    {
+      /*Cr  qi=7  INTRA*/
+      {
+        {    6,    4},{   79,  374},{  134,  764},{  157, 1232},
+        {  169, 1722},{  181, 2226},{  194, 2728},{  208, 3187},
+        {  223, 3603},{  236, 3961},{  262, 4303},{  287, 4666},
+        {  307, 4995},{  334, 5282},{  356, 5584},{  381, 5861},
+        {  417, 6120},{  445, 6378},{  475, 6575},{  508, 6775},
+        {  525, 7062},{  543, 7278},{  563, 7464},{  589, 7756}
+      },
+      /*Cr  qi=7  INTER*/
+      {
+        {   95,   24},{  110,  344},{  115,  664},{  115, 1037},
+        {  117, 1448},{  123, 1859},{  128, 2275},{  131, 2692},
+        {  133, 3106},{  136, 3514},{  140, 3914},{  145, 4300},
+        {  150, 4664},{  153, 5019},{  159, 5362},{  166, 5698},
+        {  174, 6029},{  183, 6347},{  192, 6658},{  201, 6965},
+        {  211, 7258},{  224, 7537},{  236, 7813},{  248, 8078}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=8  INTRA*/
+      {
+        {  202,  -62},{  263, 1579},{  357, 3241},{  521, 4514},
+        {  716, 5338},{  906, 5995},{ 1096, 6622},{ 1280, 7252},
+        { 1455, 7877},{ 1631, 8495},{ 1813, 9102},{ 2001, 9668},
+        { 2190,10201},{ 2369,10718},{ 2535,11268},{ 2700,11835},
+        { 2866,12361},{ 3028,12883},{ 3186,13411},{ 3337,13913},
+        { 3481,14398},{ 3632,14869},{ 3787,15334},{ 3929,15913}
+      },
+      /*Y'  qi=8  INTER*/
+      {
+        {  154, -112},{  111, 1348},{  153, 2875},{  197, 4392},
+        {  237, 5760},{  279, 6990},{  333, 8171},{  407, 9316},
+        {  504,10404},{  620,11437},{  749,12441},{  885,13438},
+        { 1030,14416},{ 1185,15361},{ 1348,16259},{ 1517,17111},
+        { 1693,17906},{ 1881,18625},{ 2080,19269},{ 2288,19822},
+        { 2505,20266},{ 2731,20604},{ 2960,20837},{ 3186,20985}
+      }
+    },
+    {
+      /*Cb  qi=8  INTRA*/
+      {
+        {   11,    2},{   89,  366},{  149,  744},{  170, 1188},
+        {  183, 1670},{  198, 2174},{  212, 2683},{  222, 3172},
+        {  236, 3608},{  255, 3998},{  274, 4361},{  297, 4701},
+        {  321, 5016},{  349, 5283},{  378, 5520},{  402, 5782},
+        {  434, 6024},{  469, 6246},{  506, 6441},{  539, 6686},
+        {  565, 6933},{  590, 7116},{  629, 7281},{  700, 7370}
+      },
+      /*Cb  qi=8  INTER*/
+      {
+        {  105,   -1},{  111,  332},{  114,  667},{  111, 1044},
+        {  114, 1444},{  121, 1854},{  129, 2272},{  136, 2692},
+        {  141, 3109},{  145, 3516},{  150, 3907},{  154, 4281},
+        {  160, 4633},{  166, 4966},{  172, 5286},{  179, 5604},
+        {  184, 5918},{  191, 6225},{  200, 6531},{  213, 6833},
+        {  225, 7134},{  233, 7441},{  246, 7743},{  255, 8048}
+      }
+    },
+    {
+      /*Cr  qi=8  INTRA*/
+      {
+        {    6,    4},{   82,  374},{  140,  765},{  165, 1233},
+        {  178, 1723},{  189, 2227},{  201, 2727},{  215, 3180},
+        {  233, 3587},{  251, 3933},{  277, 4269},{  303, 4622},
+        {  324, 4932},{  354, 5201},{  380, 5490},{  410, 5751},
+        {  449, 5994},{  477, 6241},{  510, 6435},{  543, 6641},
+        {  563, 6909},{  587, 7106},{  612, 7289},{  653, 7563}
+      },
+      /*Cr  qi=8  INTER*/
+      {
+        {  108,   12},{  109,  332},{  112,  659},{  116, 1040},
+        {  119, 1445},{  124, 1857},{  130, 2274},{  133, 2692},
+        {  135, 3107},{  138, 3512},{  143, 3902},{  147, 4281},
+        {  153, 4641},{  160, 4985},{  167, 5326},{  175, 5660},
+        {  184, 5981},{  194, 6283},{  204, 6586},{  217, 6884},
+        {  230, 7168},{  241, 7452},{  257, 7723},{  263, 7987}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=9  INTRA*/
+      {
+        {  202,  -61},{  265, 1574},{  366, 3211},{  542, 4451},
+        {  750, 5241},{  954, 5870},{ 1157, 6482},{ 1354, 7089},
+        { 1539, 7692},{ 1726, 8292},{ 1921, 8872},{ 2119, 9416},
+        { 2316, 9924},{ 2505,10409},{ 2681,10938},{ 2854,11483},
+        { 3029,11982},{ 3204,12489},{ 3369,12999},{ 3526,13466},
+        { 3677,13926},{ 3839,14359},{ 4002,14798},{ 4149,15376}
+      },
+      /*Y'  qi=9  INTER*/
+      {
+        {  149, -122},{  112, 1350},{  155, 2869},{  203, 4369},
+        {  249, 5707},{  298, 6914},{  362, 8081},{  452, 9202},
+        {  566,10263},{  703,11262},{  851,12236},{ 1004,13206},
+        { 1166,14153},{ 1339,15058},{ 1516,15916},{ 1703,16713},
+        { 1903,17437},{ 2110,18100},{ 2328,18668},{ 2559,19128},
+        { 2795,19487},{ 3038,19759},{ 3280,19974},{ 3523,20082}
+      }
+    },
+    {
+      /*Cb  qi=9  INTRA*/
+      {
+        {   11,    2},{   90,  366},{  150,  744},{  172, 1189},
+        {  184, 1670},{  199, 2172},{  215, 2679},{  226, 3164},
+        {  241, 3594},{  263, 3971},{  283, 4324},{  307, 4654},
+        {  335, 4948},{  367, 5195},{  401, 5419},{  426, 5676},
+        {  457, 5908},{  498, 6104},{  539, 6299},{  566, 6555},
+        {  597, 6797},{  627, 6970},{  669, 7125},{  728, 7283}
+      },
+      /*Cb  qi=9  INTER*/
+      {
+        {   85,  -46},{  106,  314},{  119,  666},{  113, 1040},
+        {  114, 1444},{  121, 1856},{  129, 2270},{  136, 2688},
+        {  142, 3104},{  146, 3507},{  150, 3888},{  157, 4253},
+        {  164, 4600},{  171, 4931},{  177, 5249},{  185, 5561},
+        {  193, 5868},{  203, 6171},{  214, 6475},{  225, 6771},
+        {  239, 7068},{  252, 7368},{  263, 7665},{  279, 7962}
+      }
+    },
+    {
+      /*Cr  qi=9  INTRA*/
+      {
+        {    7,    4},{   84,  375},{  142,  765},{  167, 1234},
+        {  179, 1723},{  190, 2226},{  203, 2725},{  218, 3173},
+        {  238, 3571},{  257, 3910},{  288, 4231},{  317, 4564},
+        {  337, 4866},{  370, 5125},{  403, 5393},{  433, 5642},
+        {  475, 5866},{  509, 6100},{  539, 6298},{  575, 6487},
+        {  598, 6754},{  621, 6972},{  649, 7145},{  701, 7424}
+      },
+      /*Cr  qi=9  INTER*/
+      {
+        {  101,    8},{  107,  332},{  112,  661},{  115, 1041},
+        {  118, 1447},{  124, 1858},{  130, 2273},{  133, 2690},
+        {  136, 3103},{  139, 3505},{  143, 3891},{  149, 4255},
+        {  156, 4608},{  163, 4954},{  170, 5287},{  179, 5614},
+        {  192, 5924},{  206, 6222},{  218, 6518},{  232, 6816},
+        {  245, 7097},{  261, 7357},{  277, 7627},{  292, 7894}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=10  INTRA*/
+      {
+        {  211,  -60},{  276, 1567},{  389, 3154},{  582, 4321},
+        {  807, 5059},{ 1028, 5665},{ 1246, 6262},{ 1453, 6863},
+        { 1647, 7465},{ 1847, 8054},{ 2051, 8619},{ 2260, 9143},
+        { 2468, 9638},{ 2664,10121},{ 2851,10632},{ 3038,11142},
+        { 3221,11626},{ 3403,12114},{ 3578,12597},{ 3743,13052},
+        { 3898,13494},{ 4061,13913},{ 4233,14311},{ 4398,14832}
+      },
+      /*Y'  qi=10  INTER*/
+      {
+        {  154,  -91},{  118, 1343},{  164, 2856},{  218, 4328},
+        {  271, 5636},{  329, 6826},{  407, 7972},{  515, 9068},
+        {  654,10092},{  810,11068},{  974,12028},{ 1150,12966},
+        { 1334,13880},{ 1522,14752},{ 1722,15561},{ 1930,16300},
+        { 2151,16969},{ 2385,17544},{ 2624,18031},{ 2874,18417},
+        { 3134,18699},{ 3390,18914},{ 3649,19031},{ 3901,19135}
+      }
+    },
+    {
+      /*Cb  qi=10  INTRA*/
+      {
+        {   11,    2},{   93,  367},{  157,  745},{  181, 1190},
+        {  192, 1672},{  207, 2173},{  223, 2675},{  235, 3152},
+        {  251, 3574},{  277, 3934},{  303, 4264},{  331, 4574},
+        {  365, 4844},{  399, 5073},{  433, 5289},{  464, 5539},
+        {  499, 5759},{  542, 5931},{  585, 6126},{  610, 6389},
+        {  642, 6628},{  678, 6799},{  726, 6954},{  805, 7071}
+      },
+      /*Cb  qi=10  INTER*/
+      {
+        {  119,  -59},{  117,  269},{  115,  608},{  116, 1014},
+        {  118, 1437},{  127, 1851},{  135, 2263},{  143, 2676},
+        {  149, 3086},{  153, 3482},{  158, 3856},{  165, 4215},
+        {  173, 4557},{  182, 4882},{  190, 5191},{  199, 5495},
+        {  209, 5800},{  221, 6099},{  234, 6396},{  248, 6690},
+        {  265, 6978},{  283, 7270},{  297, 7575},{  313, 7874}
+      }
+    },
+    {
+      /*Cr  qi=10  INTRA*/
+      {
+        {    7,    4},{   87,  377},{  147,  768},{  173, 1236},
+        {  187, 1726},{  198, 2230},{  212, 2725},{  230, 3165},
+        {  251, 3545},{  275, 3865},{  307, 4163},{  340, 4477},
+        {  367, 4758},{  403, 5010},{  436, 5277},{  470, 5513},
+        {  513, 5723},{  550, 5945},{  586, 6137},{  622, 6318},
+        {  648, 6579},{  674, 6780},{  702, 6944},{  729, 7237}
+      },
+      /*Cr  qi=10  INTER*/
+      {
+        {  109,   19},{  114,  326},{  118,  646},{  120, 1035},
+        {  123, 1442},{  129, 1853},{  134, 2268},{  139, 2685},
+        {  141, 3094},{  145, 3489},{  151, 3869},{  157, 4230},
+        {  165, 4572},{  174, 4904},{  184, 5229},{  195, 5542},
+        {  209, 5845},{  224, 6140},{  240, 6428},{  257, 6709},
+        {  274, 6982},{  290, 7254},{  305, 7523},{  321, 7785}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=11  INTRA*/
+      {
+        {  216,  -62},{  278, 1563},{  399, 3133},{  605, 4265},
+        {  843, 4969},{ 1078, 5554},{ 1309, 6137},{ 1529, 6718},
+        { 1735, 7304},{ 1946, 7872},{ 2162, 8411},{ 2379, 8919},
+        { 2597, 9388},{ 2806, 9841},{ 3005,10329},{ 3199,10821},
+        { 3391,11282},{ 3578,11758},{ 3760,12221},{ 3934,12634},
+        { 4089,13051},{ 4253,13447},{ 4430,13818},{ 4598,14334}
+      },
+      /*Y'  qi=11  INTER*/
+      {
+        {  153,  -95},{  119, 1342},{  167, 2852},{  226, 4307},
+        {  286, 5589},{  353, 6756},{  447, 7881},{  576, 8947},
+        {  734, 9940},{  908,10890},{ 1092,11824},{ 1286,12735},
+        { 1488,13608},{ 1698,14431},{ 1917,15188},{ 2150,15866},
+        { 2393,16462},{ 2643,16965},{ 2909,17368},{ 3185,17655},
+        { 3461,17845},{ 3731,17991},{ 3991,18093},{ 4242,18199}
+      }
+    },
+    {
+      /*Cb  qi=11  INTRA*/
+      {
+        {   12,    2},{   94,  367},{  158,  745},{  182, 1191},
+        {  194, 1673},{  209, 2173},{  225, 2670},{  239, 3138},
+        {  257, 3553},{  285, 3907},{  314, 4228},{  345, 4525},
+        {  382, 4780},{  420, 5001},{  457, 5206},{  486, 5454},
+        {  520, 5672},{  570, 5837},{  612, 6036},{  640, 6292},
+        {  682, 6499},{  719, 6665},{  763, 6827},{  828, 6982}
+      },
+      /*Cb  qi=11  INTER*/
+      {
+        {   98,  -50},{  111,  274},{  116,  608},{  115, 1015},
+        {  119, 1438},{  127, 1850},{  135, 2262},{  143, 2673},
+        {  150, 3077},{  155, 3468},{  161, 3838},{  168, 4190},
+        {  177, 4524},{  187, 4846},{  197, 5154},{  208, 5456},
+        {  219, 5751},{  233, 6043},{  248, 6336},{  264, 6626},
+        {  282, 6918},{  301, 7210},{  325, 7492},{  344, 7781}
+      }
+    },
+    {
+      /*Cr  qi=11  INTRA*/
+      {
+        {    7,    4},{   88,  377},{  148,  768},{  174, 1237},
+        {  188, 1727},{  200, 2229},{  215, 2722},{  233, 3153},
+        {  256, 3527},{  281, 3839},{  316, 4124},{  355, 4410},
+        {  382, 4684},{  419, 4947},{  458, 5194},{  495, 5407},
+        {  539, 5611},{  576, 5833},{  615, 6028},{  655, 6195},
+        {  687, 6432},{  717, 6634},{  740, 6813},{  771, 7114}
+      },
+      /*Cr  qi=11  INTER*/
+      {
+        {  101,   10},{  110,  322},{  118,  647},{  120, 1035},
+        {  123, 1442},{  129, 1853},{  134, 2266},{  138, 2681},
+        {  142, 3087},{  146, 3477},{  152, 3852},{  161, 4209},
+        {  169, 4550},{  178, 4878},{  189, 5193},{  203, 5499},
+        {  220, 5797},{  236, 6090},{  253, 6378},{  274, 6648},
+        {  293, 6915},{  310, 7190},{  333, 7445},{  359, 7698}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=12  INTRA*/
+      {
+        {  219,  -60},{  289, 1553},{  423, 3075},{  646, 4142},
+        {  901, 4805},{ 1151, 5375},{ 1393, 5949},{ 1625, 6529},
+        { 1842, 7107},{ 2065, 7669},{ 2291, 8201},{ 2516, 8694},
+        { 2740, 9156},{ 2957, 9602},{ 3164,10078},{ 3365,10563},
+        { 3563,11006},{ 3757,11456},{ 3944,11910},{ 4118,12322},
+        { 4275,12736},{ 4442,13112},{ 4625,13472},{ 4793,13992}
+      },
+      /*Y'  qi=12  INTER*/
+      {
+        {  147,  -51},{  125, 1342},{  177, 2838},{  240, 4266},
+        {  306, 5525},{  384, 6683},{  496, 7791},{  645, 8834},
+        {  823, 9805},{ 1016,10735},{ 1218,11647},{ 1427,12540},
+        { 1644,13390},{ 1871,14180},{ 2108,14902},{ 2358,15533},
+        { 2617,16070},{ 2889,16513},{ 3174,16848},{ 3467,17059},
+        { 3758,17206},{ 4034,17335},{ 4295,17431},{ 4544,17551}
+      }
+    },
+    {
+      /*Cb  qi=12  INTRA*/
+      {
+        {   12,    2},{   96,  367},{  159,  746},{  183, 1192},
+        {  198, 1673},{  215, 2171},{  234, 2662},{  249, 3116},
+        {  270, 3514},{  301, 3850},{  334, 4147},{  369, 4426},
+        {  410, 4680},{  447, 4905},{  485, 5106},{  522, 5341},
+        {  558, 5549},{  608, 5710},{  654, 5904},{  687, 6143},
+        {  733, 6345},{  782, 6502},{  825, 6658},{  890, 6833}
+      },
+      /*Cb  qi=12  INTER*/
+      {
+        {  122,   46},{  114,  328},{  113,  631},{  117, 1026},
+        {  124, 1443},{  133, 1856},{  143, 2268},{  151, 2677},
+        {  157, 3074},{  164, 3454},{  173, 3814},{  181, 4155},
+        {  192, 4480},{  203, 4793},{  214, 5095},{  227, 5390},
+        {  242, 5683},{  258, 5973},{  275, 6262},{  293, 6550},
+        {  316, 6839},{  340, 7127},{  366, 7406},{  390, 7698}
+      }
+    },
+    {
+      /*Cr  qi=12  INTRA*/
+      {
+        {    8,    4},{   92,  378},{  152,  770},{  178, 1238},
+        {  192, 1728},{  204, 2228},{  220, 2715},{  243, 3132},
+        {  267, 3492},{  293, 3795},{  335, 4067},{  379, 4327},
+        {  412, 4578},{  449, 4833},{  488, 5084},{  529, 5298},
+        {  579, 5484},{  619, 5686},{  656, 5886},{  697, 6070},
+        {  733, 6298},{  757, 6487},{  779, 6668},{  802, 6957}
+      },
+      /*Cr  qi=12  INTER*/
+      {
+        {  101,   45},{  112,  351},{  119,  665},{  122, 1044},
+        {  127, 1450},{  133, 1861},{  140, 2273},{  145, 2681},
+        {  150, 3082},{  156, 3464},{  163, 3828},{  172, 4176},
+        {  182, 4506},{  194, 4823},{  208, 5134},{  225, 5435},
+        {  242, 5728},{  259, 6015},{  281, 6293},{  305, 6561},
+        {  327, 6822},{  352, 7080},{  375, 7345},{  396, 7617}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=13  INTRA*/
+      {
+        {  220,  -58},{  290, 1551},{  428, 3059},{  657, 4111},
+        {  917, 4766},{ 1172, 5334},{ 1419, 5906},{ 1656, 6481},
+        { 1877, 7054},{ 2104, 7607},{ 2334, 8134},{ 2564, 8620},
+        { 2791, 9071},{ 3010, 9511},{ 3221, 9978},{ 3425,10450},
+        { 3625,10896},{ 3821,11350},{ 4011,11779},{ 4189,12178},
+        { 4349,12587},{ 4519,12957},{ 4702,13304},{ 4869,13828}
+      },
+      /*Y'  qi=13  INTER*/
+      {
+        {  158,  -46},{  126, 1342},{  179, 2835},{  244, 4255},
+        {  313, 5504},{  397, 6654},{  516, 7754},{  674, 8786},
+        {  861, 9745},{ 1061,10667},{ 1271,11568},{ 1489,12446},
+        { 1712,13280},{ 1944,14059},{ 2189,14760},{ 2450,15360},
+        { 2717,15880},{ 2998,16278},{ 3293,16571},{ 3591,16787},
+        { 3886,16908},{ 4162,17014},{ 4426,17124},{ 4684,17257}
+      }
+    },
+    {
+      /*Cb  qi=13  INTRA*/
+      {
+        {   12,    2},{   97,  367},{  160,  746},{  183, 1192},
+        {  198, 1673},{  216, 2170},{  235, 2659},{  251, 3110},
+        {  273, 3502},{  305, 3834},{  340, 4127},{  377, 4398},
+        {  418, 4648},{  459, 4863},{  499, 5058},{  534, 5301},
+        {  571, 5508},{  619, 5675},{  666, 5868},{  702, 6098},
+        {  749, 6301},{  794, 6459},{  835, 6617},{  889, 6808}
+      },
+      /*Cb  qi=13  INTER*/
+      {
+        {  125,   40},{  122,  323},{  117,  631},{  116, 1028},
+        {  123, 1443},{  133, 1855},{  143, 2265},{  151, 2671},
+        {  158, 3067},{  166, 3443},{  174, 3800},{  183, 4141},
+        {  195, 4464},{  207, 4772},{  219, 5072},{  231, 5369},
+        {  246, 5659},{  264, 5947},{  284, 6238},{  305, 6524},
+        {  329, 6806},{  356, 7089},{  384, 7370},{  420, 7654}
+      }
+    },
+    {
+      /*Cr  qi=13  INTRA*/
+      {
+        {    9,    4},{   92,  378},{  153,  770},{  179, 1238},
+        {  193, 1728},{  205, 2227},{  222, 2713},{  244, 3129},
+        {  270, 3481},{  298, 3775},{  340, 4045},{  385, 4302},
+        {  418, 4549},{  457, 4804},{  498, 5051},{  540, 5264},
+        {  590, 5451},{  634, 5649},{  673, 5836},{  714, 6013},
+        {  754, 6238},{  779, 6441},{  802, 6623},{  825, 6951}
+      },
+      /*Cr  qi=13  INTER*/
+      {
+        {  104,   42},{  112,  351},{  121,  665},{  123, 1044},
+        {  127, 1449},{  134, 1857},{  140, 2271},{  145, 2681},
+        {  150, 3079},{  156, 3460},{  164, 3820},{  172, 4161},
+        {  183, 4489},{  198, 4807},{  211, 5116},{  227, 5414},
+        {  247, 5705},{  267, 5988},{  293, 6262},{  319, 6527},
+        {  344, 6784},{  366, 7048},{  386, 7314},{  407, 7582}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=14  INTRA*/
+      {
+        {  223,  -58},{  296, 1546},{  445, 3027},{  688, 4036},
+        {  964, 4657},{ 1233, 5209},{ 1492, 5770},{ 1739, 6332},
+        { 1975, 6889},{ 2214, 7428},{ 2450, 7942},{ 2687, 8412},
+        { 2923, 8854},{ 3148, 9282},{ 3366, 9733},{ 3577,10194},
+        { 3780,10617},{ 3981,11049},{ 4180,11462},{ 4362,11843},
+        { 4523,12241},{ 4696,12592},{ 4884,12905},{ 5064,13397}
+      },
+      /*Y'  qi=14  INTER*/
+      {
+        {  160,  -56},{  127, 1345},{  184, 2829},{  253, 4229},
+        {  328, 5456},{  424, 6594},{  563, 7675},{  741, 8681},
+        {  945, 9617},{ 1162,10518},{ 1389,11395},{ 1625,12241},
+        { 1865,13044},{ 2115,13779},{ 2381,14425},{ 2662,14964},
+        { 2957,15398},{ 3262,15730},{ 3572,15966},{ 3878,16119},
+        { 4176,16208},{ 4454,16307},{ 4713,16404},{ 4957,16495}
+      }
+    },
+    {
+      /*Cb  qi=14  INTRA*/
+      {
+        {   12,    2},{  104,  367},{  170,  746},{  192, 1193},
+        {  207, 1674},{  226, 2166},{  246, 2647},{  266, 3086},
+        {  292, 3466},{  327, 3787},{  364, 4069},{  403, 4332},
+        {  449, 4572},{  493, 4792},{  533, 4985},{  570, 5211},
+        {  611, 5414},{  664, 5571},{  715, 5749},{  754, 5962},
+        {  801, 6166},{  845, 6335},{  890, 6485},{  956, 6676}
+      },
+      /*Cb  qi=14  INTER*/
+      {
+        {  113,   29},{  123,  351},{  123,  678},{  116, 1049},
+        {  123, 1450},{  134, 1860},{  145, 2269},{  153, 2675},
+        {  161, 3064},{  169, 3435},{  179, 3788},{  190, 4121},
+        {  201, 4438},{  213, 4746},{  229, 5042},{  245, 5332},
+        {  262, 5622},{  280, 5906},{  301, 6190},{  328, 6468},
+        {  358, 6747},{  390, 7024},{  424, 7293},{  471, 7544}
+      }
+    },
+    {
+      /*Cr  qi=14  INTRA*/
+      {
+        {    9,    4},{   97,  378},{  161,  770},{  188, 1239},
+        {  201, 1728},{  215, 2223},{  234, 2702},{  258, 3107},
+        {  287, 3448},{  316, 3738},{  363, 3990},{  415, 4225},
+        {  449, 4471},{  490, 4730},{  533, 4970},{  580, 5161},
+        {  633, 5339},{  679, 5532},{  724, 5707},{  763, 5884},
+        {  799, 6105},{  832, 6290},{  858, 6483},{  895, 6766}
+      },
+      /*Cr  qi=14  INTER*/
+      {
+        {  109,   26},{  112,  347},{  119,  673},{  122, 1052},
+        {  126, 1456},{  134, 1867},{  140, 2276},{  146, 2681},
+        {  152, 3076},{  158, 3452},{  167, 3808},{  178, 4144},
+        {  190, 4467},{  205, 4780},{  222, 5081},{  240, 5376},
+        {  261, 5663},{  285, 5943},{  314, 6206},{  342, 6461},
+        {  368, 6718},{  396, 6975},{  428, 7226},{  450, 7496}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=15  INTRA*/
+      {
+        {  226,  -57},{  299, 1544},{  459, 3001},{  715, 3958},
+        { 1000, 4550},{ 1277, 5097},{ 1548, 5655},{ 1808, 6212},
+        { 2056, 6756},{ 2303, 7287},{ 2547, 7787},{ 2796, 8234},
+        { 3038, 8664},{ 3268, 9082},{ 3493, 9518},{ 3715, 9963},
+        { 3924,10374},{ 4129,10784},{ 4333,11183},{ 4519,11557},
+        { 4686,11930},{ 4862,12255},{ 5054,12557},{ 5234,13032}
+      },
+      /*Y'  qi=15  INTER*/
+      {
+        {  154,  -48},{  127, 1344},{  188, 2822},{  263, 4200},
+        {  348, 5406},{  460, 6528},{  619, 7586},{  819, 8563},
+        { 1041, 9475},{ 1276,10357},{ 1519,11214},{ 1773,12029},
+        { 2033,12795},{ 2306,13483},{ 2598,14062},{ 2901,14552},
+        { 3214,14922},{ 3540,15165},{ 3864,15343},{ 4175,15468},
+        { 4471,15564},{ 4744,15643},{ 5003,15710},{ 5249,15824}
+      }
+    },
+    {
+      /*Cb  qi=15  INTRA*/
+      {
+        {   12,    2},{  104,  368},{  170,  747},{  193, 1193},
+        {  209, 1675},{  229, 2163},{  249, 2636},{  271, 3067},
+        {  300, 3439},{  338, 3752},{  376, 4028},{  419, 4281},
+        {  466, 4518},{  513, 4734},{  558, 4919},{  595, 5139},
+        {  638, 5337},{  694, 5492},{  745, 5675},{  785, 5896},
+        {  832, 6088},{  886, 6230},{  936, 6372},{  976, 6588}
+      },
+      /*Cb  qi=15  INTER*/
+      {
+        {  121,   33},{  119,  353},{  121,  680},{  118, 1049},
+        {  124, 1449},{  134, 1858},{  145, 2266},{  155, 2665},
+        {  163, 3050},{  173, 3414},{  184, 3762},{  196, 4092},
+        {  210, 4404},{  225, 4705},{  240, 4999},{  258, 5288},
+        {  279, 5570},{  302, 5854},{  327, 6131},{  359, 6400},
+        {  395, 6671},{  433, 6939},{  471, 7211},{  513, 7470}
+      }
+    },
+    {
+      /*Cr  qi=15  INTRA*/
+      {
+        {    9,    4},{   97,  378},{  162,  771},{  190, 1239},
+        {  204, 1728},{  217, 2221},{  237, 2694},{  263, 3092},
+        {  293, 3424},{  325, 3700},{  375, 3943},{  429, 4178},
+        {  468, 4415},{  514, 4658},{  558, 4899},{  605, 5089},
+        {  661, 5251},{  709, 5439},{  754, 5617},{  801, 5786},
+        {  837, 6002},{  865, 6194},{  898, 6373},{  945, 6631}
+      },
+      /*Cr  qi=15  INTER*/
+      {
+        {  106,   29},{  113,  349},{  118,  674},{  120, 1051},
+        {  126, 1455},{  134, 1865},{  141, 2272},{  148, 2673},
+        {  154, 3063},{  162, 3435},{  172, 3784},{  185, 4114},
+        {  198, 4435},{  214, 4741},{  233, 5038},{  254, 5329},
+        {  279, 5609},{  308, 5881},{  338, 6141},{  371, 6393},
+        {  402, 6644},{  432, 6902},{  461, 7161},{  496, 7408}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=16  INTRA*/
+      {
+        {  232,  -56},{  313, 1533},{  489, 2937},{  765, 3835},
+        { 1068, 4395},{ 1362, 4930},{ 1648, 5481},{ 1920, 6032},
+        { 2179, 6572},{ 2438, 7090},{ 2695, 7574},{ 2952, 8010},
+        { 3202, 8436},{ 3438, 8846},{ 3670, 9268},{ 3896, 9693},
+        { 4113,10081},{ 4327,10486},{ 4534,10874},{ 4723,11217},
+        { 4895,11581},{ 5074,11899},{ 5265,12170},{ 5445,12625}
+      },
+      /*Y'  qi=16  INTER*/
+      {
+        {  162,  -30},{  137, 1342},{  199, 2812},{  280, 4165},
+        {  377, 5351},{  507, 6457},{  689, 7493},{  911, 8445},
+        { 1155, 9337},{ 1410,10199},{ 1674,11030},{ 1949,11816},
+        { 2234,12539},{ 2533,13169},{ 2849,13692},{ 3179,14093},
+        { 3516,14389},{ 3857,14578},{ 4187,14712},{ 4497,14825},
+        { 4790,14903},{ 5063,14976},{ 5319,15031},{ 5554,15061}
+      }
+    },
+    {
+      /*Cb  qi=16  INTRA*/
+      {
+        {   12,    2},{  106,  368},{  177,  747},{  202, 1193},
+        {  218, 1673},{  241, 2156},{  264, 2615},{  290, 3025},
+        {  323, 3378},{  363, 3680},{  405, 3945},{  452, 4190},
+        {  504, 4423},{  552, 4635},{  597, 4811},{  639, 5016},
+        {  685, 5223},{  741, 5381},{  799, 5544},{  844, 5748},
+        {  896, 5933},{  951, 6073},{ 1000, 6210},{ 1063, 6406}
+      },
+      /*Cb  qi=16  INTER*/
+      {
+        {  128,   36},{  122,  358},{  120,  682},{  123, 1047},
+        {  131, 1448},{  142, 1856},{  152, 2259},{  163, 2652},
+        {  173, 3032},{  183, 3392},{  195, 3734},{  210, 4054},
+        {  226, 4359},{  241, 4656},{  260, 4945},{  282, 5230},
+        {  307, 5509},{  336, 5783},{  365, 6061},{  403, 6327},
+        {  445, 6597},{  489, 6861},{  541, 7111},{  599, 7351}
+      }
+    },
+    {
+      /*Cr  qi=16  INTRA*/
+      {
+        {    9,    4},{  103,  377},{  171,  769},{  199, 1238},
+        {  215, 1727},{  231, 2215},{  252, 2678},{  282, 3064},
+        {  315, 3380},{  351, 3643},{  405, 3870},{  462, 4086},
+        {  505, 4314},{  555, 4547},{  602, 4779},{  652, 4969},
+        {  712, 5128},{  764, 5301},{  808, 5474},{  856, 5632},
+        {  903, 5841},{  932, 6038},{  963, 6208},{ 1017, 6419}
+      },
+      /*Cr  qi=16  INTER*/
+      {
+        {  116,   29},{  119,  346},{  123,  675},{  126, 1054},
+        {  132, 1456},{  141, 1863},{  149, 2266},{  155, 2664},
+        {  161, 3048},{  170, 3413},{  181, 3757},{  195, 4081},
+        {  213, 4392},{  232, 4693},{  255, 4987},{  280, 5271},
+        {  310, 5539},{  342, 5801},{  377, 6057},{  414, 6307},
+        {  451, 6557},{  486, 6812},{  522, 7064},{  546, 7331}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=17  INTRA*/
+      {
+        {  233,  -55},{  316, 1530},{  499, 2918},{  787, 3793},
+        { 1101, 4337},{ 1405, 4866},{ 1700, 5409},{ 1982, 5949},
+        { 2251, 6477},{ 2517, 6988},{ 2781, 7461},{ 3045, 7883},
+        { 3301, 8297},{ 3542, 8696},{ 3776, 9105},{ 4006, 9518},
+        { 4226, 9896},{ 4443,10285},{ 4651,10660},{ 4842,11001},
+        { 5019,11341},{ 5196,11634},{ 5382,11912},{ 5561,12352}
+      },
+      /*Y'  qi=17  INTER*/
+      {
+        {  165,  -32},{  137, 1342},{  202, 2804},{  288, 4145},
+        {  394, 5319},{  539, 6410},{  738, 7427},{  977, 8359},
+        { 1236, 9232},{ 1505,10078},{ 1785,10891},{ 2075,11651},
+        { 2376,12344},{ 2696,12932},{ 3032,13397},{ 3378,13745},
+        { 3728,13983},{ 4078,14103},{ 4411,14175},{ 4714,14249},
+        { 4995,14284},{ 5260,14316},{ 5510,14338},{ 5739,14362}
+      }
+    },
+    {
+      /*Cb  qi=17  INTRA*/
+      {
+        {   13,    2},{  106,  368},{  177,  747},{  202, 1193},
+        {  219, 1671},{  240, 2149},{  266, 2603},{  294, 3007},
+        {  328, 3355},{  372, 3648},{  417, 3906},{  465, 4153},
+        {  519, 4380},{  572, 4578},{  619, 4758},{  660, 4971},
+        {  703, 5177},{  761, 5326},{  822, 5480},{  872, 5676},
+        {  929, 5850},{  981, 5994},{ 1029, 6134},{ 1102, 6293}
+      },
+      /*Cb  qi=17  INTER*/
+      {
+        {  125,   41},{  122,  359},{  123,  681},{  122, 1048},
+        {  130, 1447},{  143, 1855},{  154, 2258},{  164, 2648},
+        {  175, 3024},{  186, 3381},{  199, 3716},{  215, 4032},
+        {  232, 4336},{  251, 4632},{  272, 4919},{  296, 5199},
+        {  323, 5473},{  354, 5743},{  392, 6008},{  434, 6272},
+        {  480, 6538},{  532, 6788},{  588, 7031},{  647, 7270}
+      }
+    },
+    {
+      /*Cr  qi=17  INTRA*/
+      {
+        {   10,    4},{  103,  377},{  170,  769},{  197, 1235},
+        {  213, 1722},{  231, 2208},{  254, 2665},{  284, 3046},
+        {  321, 3359},{  357, 3621},{  412, 3845},{  472, 4054},
+        {  517, 4273},{  571, 4503},{  623, 4729},{  677, 4907},
+        {  736, 5059},{  782, 5235},{  831, 5407},{  887, 5563},
+        {  933, 5764},{  958, 5960},{  993, 6138},{ 1046, 6366}
+      },
+      /*Cr  qi=17  INTER*/
+      {
+        {  123,   35},{  121,  351},{  123,  677},{  126, 1053},
+        {  132, 1453},{  141, 1860},{  149, 2263},{  156, 2659},
+        {  163, 3042},{  171, 3404},{  184, 3742},{  201, 4063},
+        {  219, 4370},{  241, 4666},{  266, 4956},{  296, 5237},
+        {  329, 5501},{  367, 5755},{  408, 6004},{  449, 6253},
+        {  488, 6496},{  528, 6740},{  569, 6988},{  622, 7226}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=18  INTRA*/
+      {
+        {  238,  -52},{  327, 1520},{  530, 2862},{  842, 3685},
+        { 1175, 4203},{ 1496, 4717},{ 1805, 5250},{ 2102, 5779},
+        { 2386, 6290},{ 2665, 6786},{ 2940, 7252},{ 3216, 7659},
+        { 3486, 8051},{ 3736, 8442},{ 3979, 8836},{ 4218, 9226},
+        { 4448, 9582},{ 4677, 9959},{ 4898,10317},{ 5100,10629},
+        { 5285,10954},{ 5472,11246},{ 5669,11509},{ 5869,11928}
+      },
+      /*Y'  qi=18  INTER*/
+      {
+        {  153,    1},{  142, 1345},{  213, 2786},{  310, 4098},
+        {  434, 5252},{  607, 6320},{  836, 7303},{ 1103, 8203},
+        { 1386, 9050},{ 1682, 9865},{ 1986,10646},{ 2301,11365},
+        { 2632,11993},{ 2981,12511},{ 3346,12905},{ 3719,13173},
+        { 4089,13332},{ 4442,13453},{ 4770,13568},{ 5079,13650},
+        { 5368,13726},{ 5638,13791},{ 5896,13846},{ 6153,13905}
+      }
+    },
+    {
+      /*Cb  qi=18  INTRA*/
+      {
+        {   13,    2},{  109,  368},{  182,  748},{  210, 1194},
+        {  229, 1670},{  253, 2142},{  283, 2579},{  313, 2964},
+        {  351, 3296},{  401, 3574},{  450, 3819},{  502, 4058},
+        {  557, 4279},{  613, 4468},{  665, 4640},{  713, 4843},
+        {  762, 5046},{  819, 5207},{  882, 5363},{  934, 5553},
+        {  984, 5722},{ 1036, 5870},{ 1091, 6015},{ 1157, 6210}
+      },
+      /*Cb  qi=18  INTER*/
+      {
+        {  118,   18},{  125,  348},{  124,  675},{  125, 1048},
+        {  134, 1448},{  147, 1853},{  159, 2250},{  171, 2632},
+        {  183, 3000},{  196, 3349},{  212, 3676},{  230, 3987},
+        {  250, 4286},{  273, 4575},{  299, 4855},{  327, 5131},
+        {  358, 5404},{  396, 5669},{  443, 5927},{  495, 6185},
+        {  548, 6439},{  611, 6683},{  679, 6919},{  738, 7153}
+      }
+    },
+    {
+      /*Cr  qi=18  INTRA*/
+      {
+        {   10,    4},{  107,  378},{  177,  771},{  207, 1239},
+        {  225, 1726},{  244, 2203},{  269, 2642},{  304, 2999},
+        {  345, 3293},{  384, 3546},{  443, 3763},{  507, 3970},
+        {  558, 4187},{  615, 4402},{  665, 4620},{  723, 4798},
+        {  788, 4946},{  840, 5114},{  887, 5287},{  939, 5445},
+        {  990, 5643},{ 1022, 5827},{ 1060, 5985},{ 1119, 6156}
+      },
+      /*Cr  qi=18  INTER*/
+      {
+        {  124,   32},{  126,  349},{  128,  673},{  129, 1053},
+        {  136, 1453},{  145, 1855},{  154, 2254},{  162, 2645},
+        {  170, 3021},{  181, 3374},{  196, 3704},{  215, 4018},
+        {  237, 4321},{  263, 4612},{  293, 4891},{  327, 5166},
+        {  369, 5421},{  412, 5665},{  459, 5906},{  510, 6145},
+        {  556, 6387},{  598, 6631},{  644, 6874},{  701, 7114}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=19  INTRA*/
+      {
+        {  237,  -50},{  328, 1517},{  539, 2842},{  861, 3645},
+        { 1202, 4152},{ 1528, 4664},{ 1844, 5192},{ 2148, 5714},
+        { 2438, 6223},{ 2725, 6708},{ 3005, 7168},{ 3282, 7567},
+        { 3559, 7946},{ 3815, 8328},{ 4061, 8710},{ 4305, 9095},
+        { 4538, 9445},{ 4773, 9806},{ 4995,10149},{ 5197,10447},
+        { 5384,10763},{ 5574,11052},{ 5776,11301},{ 5989,11701}
+      },
+      /*Y'  qi=19  INTER*/
+      {
+        {  154,   -8},{  143, 1345},{  217, 2777},{  320, 4078},
+        {  455, 5221},{  643, 6274},{  889, 7241},{ 1171, 8125},
+        { 1470, 8956},{ 1778, 9756},{ 2094,10516},{ 2426,11207},
+        { 2774,11805},{ 3138,12287},{ 3519,12633},{ 3901,12868},
+        { 4276,13012},{ 4632,13119},{ 4964,13232},{ 5271,13321},
+        { 5558,13381},{ 5831,13433},{ 6084,13493},{ 6335,13585}
+      }
+    },
+    {
+      /*Cb  qi=19  INTRA*/
+      {
+        {   14,    2},{  110,  368},{  184,  748},{  211, 1194},
+        {  229, 1670},{  255, 2137},{  286, 2566},{  319, 2943},
+        {  360, 3269},{  410, 3544},{  461, 3785},{  515, 4024},
+        {  572, 4239},{  631, 4420},{  686, 4593},{  736, 4798},
+        {  787, 5000},{  848, 5156},{  913, 5303},{  961, 5491},
+        { 1012, 5655},{ 1062, 5798},{ 1115, 5940},{ 1165, 6131}
+      },
+      /*Cb  qi=19  INTER*/
+      {
+        {  121,   28},{  129,  349},{  130,  674},{  127, 1047},
+        {  135, 1447},{  147, 1850},{  160, 2245},{  173, 2624},
+        {  186, 2987},{  202, 3331},{  218, 3655},{  237, 3965},
+        {  260, 4260},{  284, 4546},{  312, 4825},{  343, 5097},
+        {  377, 5369},{  420, 5633},{  471, 5887},{  526, 6143},
+        {  587, 6392},{  652, 6626},{  722, 6857},{  803, 7064}
+      }
+    },
+    {
+      /*Cr  qi=19  INTRA*/
+      {
+        {   10,    4},{  108,  378},{  178,  771},{  208, 1238},
+        {  226, 1724},{  246, 2198},{  272, 2630},{  309, 2980},
+        {  352, 3268},{  394, 3517},{  453, 3735},{  516, 3946},
+        {  569, 4156},{  628, 4365},{  684, 4580},{  743, 4753},
+        {  811, 4891},{  868, 5053},{  913, 5232},{  963, 5394},
+        { 1011, 5593},{ 1046, 5775},{ 1089, 5928},{ 1147, 6126}
+      },
+      /*Cr  qi=19  INTER*/
+      {
+        {  116,   22},{  121,  344},{  126,  675},{  129, 1054},
+        {  135, 1453},{  146, 1854},{  155, 2249},{  164, 2636},
+        {  173, 3008},{  186, 3360},{  202, 3690},{  221, 4000},
+        {  246, 4296},{  276, 4581},{  308, 4859},{  342, 5130},
+        {  385, 5386},{  437, 5629},{  486, 5873},{  536, 6105},
+        {  588, 6337},{  633, 6586},{  683, 6829},{  731, 7071}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=20  INTRA*/
+      {
+        {  238,  -46},{  346, 1504},{  574, 2782},{  913, 3545},
+        { 1270, 4033},{ 1611, 4532},{ 1937, 5056},{ 2252, 5575},
+        { 2554, 6075},{ 2849, 6555},{ 3134, 7019},{ 3418, 7415},
+        { 3702, 7784},{ 3961, 8166},{ 4211, 8547},{ 4459, 8923},
+        { 4696, 9267},{ 4934, 9623},{ 5163, 9961},{ 5365,10254},
+        { 5553,10567},{ 5747,10850},{ 5952,11081},{ 6157,11446}
+      },
+      /*Y'  qi=20  INTER*/
+      {
+        {  174,   -4},{  154, 1343},{  231, 2769},{  339, 4055},
+        {  482, 5187},{  682, 6232},{  942, 7187},{ 1238, 8061},
+        { 1552, 8883},{ 1877, 9670},{ 2211,10413},{ 2560,11075},
+        { 2926,11635},{ 3312,12073},{ 3707,12374},{ 4101,12561},
+        { 4478,12685},{ 4835,12788},{ 5166,12893},{ 5473,12984},
+        { 5760,13070},{ 6027,13118},{ 6286,13155},{ 6537,13181}
+      }
+    },
+    {
+      /*Cb  qi=20  INTRA*/
+      {
+        {   14,    2},{  116,  369},{  193,  749},{  221, 1195},
+        {  241, 1667},{  270, 2125},{  304, 2538},{  342, 2898},
+        {  388, 3211},{  442, 3475},{  501, 3706},{  558, 3933},
+        {  615, 4146},{  676, 4326},{  735, 4494},{  786, 4697},
+        {  839, 4894},{  903, 5047},{  968, 5187},{ 1017, 5370},
+        { 1068, 5536},{ 1119, 5685},{ 1174, 5843},{ 1229, 6021}
+      },
+      /*Cb  qi=20  INTER*/
+      {
+        {  112,  -47},{  121,  279},{  130,  627},{  135, 1036},
+        {  145, 1443},{  158, 1843},{  172, 2228},{  185, 2604},
+        {  197, 2967},{  212, 3310},{  230, 3632},{  251, 3934},
+        {  274, 4227},{  298, 4515},{  329, 4790},{  365, 5059},
+        {  405, 5325},{  450, 5585},{  505, 5839},{  569, 6088},
+        {  636, 6330},{  706, 6566},{  778, 6791},{  861, 6988}
+      }
+    },
+    {
+      /*Cr  qi=20  INTRA*/
+      {
+        {   13,    5},{  114,  382},{  186,  776},{  217, 1241},
+        {  237, 1720},{  261, 2184},{  293, 2599},{  332, 2929},
+        {  379, 3205},{  427, 3446},{  488, 3661},{  551, 3869},
+        {  611, 4064},{  676, 4260},{  733, 4474},{  796, 4652},
+        {  865, 4785},{  923, 4935},{  975, 5112},{ 1028, 5275},
+        { 1081, 5459},{ 1121, 5645},{ 1159, 5809},{ 1209, 5986}
+      },
+      /*Cr  qi=20  INTER*/
+      {
+        {  121,  -76},{  128,  287},{  134,  657},{  137, 1050},
+        {  146, 1448},{  156, 1845},{  166, 2238},{  173, 2625},
+        {  183, 2995},{  197, 3339},{  213, 3665},{  235, 3972},
+        {  262, 4265},{  292, 4548},{  326, 4822},{  367, 5084},
+        {  416, 5335},{  470, 5576},{  523, 5816},{  572, 6058},
+        {  624, 6297},{  679, 6532},{  731, 6774},{  763, 7042}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=21  INTRA*/
+      {
+        {  237,  -44},{  351, 1498},{  598, 2744},{  961, 3472},
+        { 1338, 3941},{ 1701, 4422},{ 2052, 4923},{ 2388, 5418},
+        { 2709, 5897},{ 3020, 6358},{ 3322, 6800},{ 3621, 7175},
+        { 3916, 7517},{ 4189, 7870},{ 4447, 8230},{ 4702, 8585},
+        { 4950, 8904},{ 5201, 9230},{ 5435, 9534},{ 5638, 9809},
+        { 5833,10099},{ 6036,10352},{ 6246,10577},{ 6466,10934}
+      },
+      /*Y'  qi=21  INTER*/
+      {
+        {  176,  -12},{  156, 1344},{  241, 2750},{  368, 4008},
+        {  544, 5109},{  788, 6113},{ 1091, 7023},{ 1424, 7855},
+        { 1773, 8639},{ 2134, 9383},{ 2508,10068},{ 2898,10662},
+        { 3307,11127},{ 3734,11447},{ 4161,11651},{ 4567,11785},
+        { 4947,11882},{ 5301,11975},{ 5630,12064},{ 5938,12127},
+        { 6226,12185},{ 6496,12236},{ 6752,12268},{ 7005,12319}
+      }
+    },
+    {
+      /*Cb  qi=21  INTRA*/
+      {
+        {   14,    2},{  117,  369},{  194,  749},{  223, 1194},
+        {  245, 1662},{  277, 2109},{  315, 2508},{  359, 2854},
+        {  409, 3159},{  468, 3415},{  529, 3636},{  591, 3858},
+        {  654, 4063},{  721, 4232},{  785, 4396},{  839, 4597},
+        {  899, 4782},{  966, 4919},{ 1032, 5062},{ 1087, 5242},
+        { 1144, 5401},{ 1195, 5546},{ 1256, 5695},{ 1326, 5879}
+      },
+      /*Cb  qi=21  INTER*/
+      {
+        {   99,  -47},{  117,  279},{  131,  628},{  136, 1036},
+        {  146, 1442},{  160, 1838},{  175, 2218},{  190, 2585},
+        {  206, 2939},{  225, 3275},{  246, 3589},{  271, 3884},
+        {  300, 4168},{  332, 4449},{  371, 4719},{  416, 4978},
+        {  466, 5233},{  525, 5486},{  594, 5729},{  668, 5967},
+        {  747, 6196},{  831, 6412},{  915, 6622},{ 1007, 6824}
+      }
+    },
+    {
+      /*Cr  qi=21  INTRA*/
+      {
+        {   14,    5},{  115,  382},{  187,  776},{  220, 1240},
+        {  242, 1714},{  268, 2165},{  304, 2563},{  347, 2880},
+        {  401, 3144},{  452, 3382},{  516, 3596},{  588, 3792},
+        {  649, 3986},{  717, 4174},{  783, 4371},{  849, 4539},
+        {  923, 4661},{  991, 4805},{ 1046, 4977},{ 1104, 5132},
+        { 1161, 5319},{ 1200, 5499},{ 1230, 5671},{ 1279, 5866}
+      },
+      /*Cr  qi=21  INTER*/
+      {
+        {  120,  -74},{  126,  287},{  132,  657},{  138, 1050},
+        {  146, 1447},{  158, 1841},{  169, 2229},{  178, 2608},
+        {  191, 2969},{  207, 3307},{  228, 3623},{  256, 3919},
+        {  289, 4204},{  327, 4481},{  372, 4745},{  420, 4998},
+        {  477, 5237},{  542, 5468},{  610, 5694},{  672, 5924},
+        {  730, 6162},{  791, 6397},{  850, 6632},{  911, 6874}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=22  INTRA*/
+      {
+        {  238,  -42},{  353, 1495},{  607, 2723},{  979, 3433},
+        { 1364, 3893},{ 1735, 4369},{ 2095, 4863},{ 2439, 5351},
+        { 2769, 5823},{ 3090, 6274},{ 3398, 6709},{ 3702, 7071},
+        { 4004, 7395},{ 4281, 7734},{ 4546, 8080},{ 4810, 8425},
+        { 5060, 8736},{ 5313, 9050},{ 5554, 9334},{ 5763, 9596},
+        { 5961, 9882},{ 6165,10130},{ 6376,10341},{ 6592,10685}
+      },
+      /*Y'  qi=22  INTER*/
+      {
+        {  173,  -13},{  157, 1344},{  247, 2741},{  385, 3983},
+        {  580, 5068},{  846, 6052},{ 1167, 6942},{ 1518, 7754},
+        { 1886, 8517},{ 2267, 9239},{ 2661, 9895},{ 3075,10444},
+        { 3511,10854},{ 3958,11122},{ 4394,11285},{ 4803,11401},
+        { 5184,11500},{ 5538,11587},{ 5867,11669},{ 6176,11748},
+        { 6462,11803},{ 6730,11834},{ 6987,11870},{ 7217,11864}
+      }
+    },
+    {
+      /*Cb  qi=22  INTRA*/
+      {
+        {   15,    2},{  117,  369},{  194,  750},{  224, 1194},
+        {  247, 1660},{  280, 2104},{  320, 2500},{  366, 2844},
+        {  417, 3145},{  478, 3397},{  542, 3615},{  606, 3833},
+        {  671, 4032},{  739, 4198},{  803, 4362},{  862, 4554},
+        {  930, 4723},{  999, 4863},{ 1063, 5005},{ 1119, 5182},
+        { 1179, 5342},{ 1233, 5479},{ 1289, 5627},{ 1349, 5821}
+      },
+      /*Cb  qi=22  INTER*/
+      {
+        {  111,  -49},{  122,  279},{  129,  629},{  136, 1037},
+        {  147, 1442},{  161, 1837},{  177, 2215},{  193, 2577},
+        {  211, 2927},{  232, 3257},{  257, 3564},{  285, 3855},
+        {  316, 4140},{  350, 4416},{  395, 4680},{  447, 4936},
+        {  502, 5187},{  569, 5432},{  643, 5673},{  724, 5902},
+        {  812, 6125},{  899, 6338},{  983, 6541},{ 1068, 6732}
+      }
+    },
+    {
+      /*Cr  qi=22  INTRA*/
+      {
+        {   14,    5},{  115,  383},{  187,  776},{  220, 1240},
+        {  243, 1712},{  271, 2160},{  308, 2554},{  355, 2866},
+        {  411, 3122},{  464, 3356},{  530, 3571},{  603, 3768},
+        {  668, 3955},{  739, 4137},{  804, 4335},{  871, 4497},
+        {  951, 4609},{ 1024, 4744},{ 1078, 4916},{ 1136, 5073},
+        { 1190, 5258},{ 1228, 5443},{ 1268, 5608},{ 1333, 5773}
+      },
+      /*Cr  qi=22  INTER*/
+      {
+        {  133,  -80},{  131,  286},{  133,  659},{  138, 1052},
+        {  147, 1447},{  158, 1838},{  170, 2223},{  181, 2598},
+        {  195, 2955},{  214, 3289},{  237, 3601},{  266, 3897},
+        {  303, 4178},{  345, 4448},{  396, 4705},{  455, 4949},
+        {  519, 5188},{  586, 5420},{  656, 5638},{  722, 5862},
+        {  788, 6095},{  850, 6331},{  914, 6560},{  984, 6793}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=23  INTRA*/
+      {
+        {  253,  -36},{  377, 1480},{  654, 2660},{ 1055, 3323},
+        { 1465, 3760},{ 1855, 4222},{ 2231, 4715},{ 2589, 5204},
+        { 2926, 5675},{ 3254, 6131},{ 3569, 6569},{ 3878, 6931},
+        { 4185, 7250},{ 4466, 7586},{ 4731, 7939},{ 4999, 8276},
+        { 5254, 8578},{ 5510, 8890},{ 5751, 9167},{ 5960, 9411},
+        { 6159, 9688},{ 6361, 9943},{ 6574,10148},{ 6796,10475}
+      },
+      /*Y'  qi=23  INTER*/
+      {
+        {  180,    4},{  170, 1341},{  267, 2726},{  417, 3953},
+        {  631, 5022},{  920, 5989},{ 1262, 6861},{ 1629, 7664},
+        { 2010, 8421},{ 2405, 9132},{ 2816, 9767},{ 3250,10280},
+        { 3703,10646},{ 4164,10869},{ 4606,11013},{ 5018,11125},
+        { 5396,11218},{ 5747,11308},{ 6079,11402},{ 6387,11475},
+        { 6671,11523},{ 6944,11562},{ 7201,11593},{ 7461,11641}
+      }
+    },
+    {
+      /*Cb  qi=23  INTRA*/
+      {
+        {   15,    2},{  124,  369},{  206,  750},{  237, 1194},
+        {  263, 1655},{  299, 2086},{  344, 2463},{  396, 2789},
+        {  452, 3076},{  517, 3317},{  584, 3528},{  651, 3741},
+        {  718, 3936},{  789, 4096},{  859, 4259},{  917, 4457},
+        {  987, 4621},{ 1058, 4752},{ 1123, 4898},{ 1178, 5078},
+        { 1234, 5240},{ 1294, 5378},{ 1354, 5529},{ 1420, 5731}
+      },
+      /*Cb  qi=23  INTER*/
+      {
+        {  112,   31},{  129,  334},{  143,  655},{  149, 1043},
+        {  161, 1442},{  175, 1834},{  192, 2207},{  210, 2561},
+        {  230, 2902},{  254, 3226},{  280, 3531},{  311, 3821},
+        {  346, 4100},{  386, 4369},{  433, 4630},{  488, 4885},
+        {  554, 5132},{  630, 5373},{  715, 5600},{  802, 5824},
+        {  892, 6046},{  988, 6253},{ 1082, 6450},{ 1193, 6625}
+      }
+    },
+    {
+      /*Cr  qi=23  INTRA*/
+      {
+        {   15,    5},{  123,  385},{  199,  779},{  234, 1240},
+        {  261, 1705},{  293, 2136},{  335, 2511},{  386, 2807},
+        {  445, 3055},{  502, 3282},{  572, 3492},{  648, 3684},
+        {  717, 3865},{  788, 4041},{  858, 4225},{  932, 4378},
+        { 1014, 4492},{ 1081, 4636},{ 1134, 4814},{ 1196, 4969},
+        { 1252, 5145},{ 1292, 5331},{ 1333, 5503},{ 1397, 5678}
+      },
+      /*Cr  qi=23  INTER*/
+      {
+        {  125,   56},{  136,  363},{  144,  681},{  149, 1054},
+        {  160, 1448},{  173, 1837},{  185, 2214},{  197, 2583},
+        {  213, 2932},{  234, 3260},{  260, 3568},{  293, 3858},
+        {  334, 4135},{  384, 4397},{  439, 4650},{  503, 4892},
+        {  575, 5123},{  647, 5354},{  722, 5575},{  789, 5803},
+        {  856, 6034},{  929, 6255},{  996, 6480},{ 1055, 6709}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=24  INTRA*/
+      {
+        {  253,  -35},{  378, 1475},{  664, 2631},{ 1075, 3275},
+        { 1491, 3706},{ 1887, 4161},{ 2272, 4648},{ 2639, 5129},
+        { 2986, 5586},{ 3323, 6027},{ 3646, 6447},{ 3961, 6790},
+        { 4274, 7098},{ 4561, 7420},{ 4831, 7758},{ 5102, 8088},
+        { 5359, 8380},{ 5621, 8674},{ 5868, 8931},{ 6081, 9163},
+        { 6285, 9420},{ 6492, 9646},{ 6707, 9844},{ 6924,10173}
+      },
+      /*Y'  qi=24  INTER*/
+      {
+        {  181,   -8},{  170, 1343},{  273, 2711},{  435, 3924},
+        {  671, 4977},{  985, 5925},{ 1351, 6776},{ 1743, 7553},
+        { 2152, 8282},{ 2574, 8957},{ 3013, 9547},{ 3476,10000},
+        { 3957,10294},{ 4433,10470},{ 4879,10590},{ 5288,10697},
+        { 5669,10785},{ 6020,10862},{ 6348,10939},{ 6657,11004},
+        { 6940,11052},{ 7213,11094},{ 7471,11125},{ 7718,11154}
+      }
+    },
+    {
+      /*Cb  qi=24  INTRA*/
+      {
+        {   15,    2},{  125,  370},{  206,  751},{  238, 1194},
+        {  265, 1652},{  303, 2078},{  351, 2450},{  405, 2769},
+        {  464, 3052},{  532, 3288},{  602, 3495},{  669, 3705},
+        {  740, 3893},{  814, 4052},{  887, 4214},{  949, 4405},
+        { 1018, 4571},{ 1091, 4702},{ 1157, 4837},{ 1214, 5014},
+        { 1272, 5182},{ 1334, 5315},{ 1397, 5446},{ 1458, 5652}
+      },
+      /*Cb  qi=24  INTER*/
+      {
+        {  119,   22},{  130,  330},{  140,  655},{  148, 1043},
+        {  161, 1441},{  177, 1830},{  195, 2198},{  215, 2550},
+        {  238, 2887},{  264, 3205},{  293, 3505},{  326, 3792},
+        {  365, 4068},{  409, 4335},{  463, 4594},{  525, 4842},
+        {  597, 5083},{  682, 5314},{  773, 5540},{  869, 5760},
+        {  969, 5967},{ 1068, 6161},{ 1162, 6351},{ 1253, 6526}
+      }
+    },
+    {
+      /*Cr  qi=24  INTRA*/
+      {
+        {   16,    5},{  123,  386},{  199,  779},{  235, 1240},
+        {  263, 1702},{  297, 2128},{  342, 2494},{  395, 2788},
+        {  457, 3033},{  516, 3256},{  589, 3469},{  670, 3659},
+        {  739, 3836},{  812, 4004},{  884, 4181},{  959, 4332},
+        { 1043, 4439},{ 1117, 4575},{ 1174, 4750},{ 1231, 4907},
+        { 1293, 5074},{ 1338, 5252},{ 1378, 5430},{ 1447, 5581}
+      },
+      /*Cr  qi=24  INTER*/
+      {
+        {  125,   54},{  134,  362},{  142,  681},{  149, 1055},
+        {  160, 1447},{  174, 1832},{  188, 2207},{  201, 2571},
+        {  219, 2917},{  242, 3241},{  271, 3543},{  308, 3829},
+        {  353, 4102},{  409, 4361},{  472, 4605},{  544, 4837},
+        {  621, 5067},{  698, 5293},{  774, 5514},{  848, 5734},
+        {  920, 5960},{  994, 6186},{ 1075, 6396},{ 1159, 6607}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=25  INTRA*/
+      {
+        {  252,  -34},{  385, 1472},{  689, 2607},{ 1120, 3223},
+        { 1552, 3638},{ 1965, 4082},{ 2365, 4554},{ 2747, 5020},
+        { 3107, 5473},{ 3455, 5907},{ 3786, 6317},{ 4107, 6654},
+        { 4430, 6947},{ 4727, 7252},{ 5007, 7579},{ 5285, 7897},
+        { 5549, 8175},{ 5814, 8451},{ 6064, 8698},{ 6280, 8925},
+        { 6489, 9174},{ 6702, 9384},{ 6917, 9573},{ 7130, 9898}
+      },
+      /*Y'  qi=25  INTER*/
+      {
+        {  180,   -4},{  172, 1342},{  284, 2698},{  466, 3892},
+        {  730, 4924},{ 1073, 5846},{ 1465, 6670},{ 1880, 7424},
+        { 2310, 8130},{ 2755, 8780},{ 3224, 9326},{ 3719, 9714},
+        { 4222, 9951},{ 4704,10101},{ 5150,10210},{ 5562,10303},
+        { 5942,10388},{ 6295,10474},{ 6627,10547},{ 6932,10598},
+        { 7226,10648},{ 7499,10679},{ 7744,10685},{ 7988,10712}
+      }
+    },
+    {
+      /*Cb  qi=25  INTRA*/
+      {
+        {   16,    2},{  126,  370},{  207,  751},{  240, 1193},
+        {  269, 1647},{  309, 2066},{  360, 2429},{  419, 2740},
+        {  481, 3017},{  551, 3251},{  623, 3457},{  695, 3661},
+        {  768, 3847},{  845, 4005},{  922, 4160},{  984, 4345},
+        { 1056, 4508},{ 1136, 4632},{ 1201, 4768},{ 1253, 4941},
+        { 1316, 5099},{ 1376, 5243},{ 1440, 5383},{ 1518, 5588}
+      },
+      /*Cb  qi=25  INTER*/
+      {
+        {  106,   20},{  127,  330},{  141,  655},{  149, 1043},
+        {  162, 1440},{  178, 1826},{  198, 2192},{  221, 2538},
+        {  248, 2868},{  277, 3182},{  309, 3479},{  346, 3765},
+        {  390, 4036},{  445, 4296},{  505, 4549},{  576, 4792},
+        {  659, 5024},{  751, 5251},{  850, 5468},{  950, 5682},
+        { 1055, 5881},{ 1163, 6063},{ 1263, 6249},{ 1370, 6427}
+      }
+    },
+    {
+      /*Cr  qi=25  INTRA*/
+      {
+        {   16,    6},{  124,  386},{  201,  780},{  238, 1238},
+        {  267, 1695},{  304, 2111},{  353, 2468},{  411, 2753},
+        {  474, 2995},{  536, 3217},{  615, 3426},{  698, 3617},
+        {  767, 3790},{  841, 3955},{  918, 4126},{  999, 4268},
+        { 1082, 4375},{ 1154, 4514},{ 1213, 4687},{ 1275, 4831},
+        { 1337, 5000},{ 1379, 5182},{ 1422, 5353},{ 1489, 5502}
+      },
+      /*Cr  qi=25  INTER*/
+      {
+        {  135,   50},{  138,  361},{  143,  681},{  149, 1054},
+        {  161, 1445},{  176, 1828},{  191, 2199},{  206, 2560},
+        {  226, 2903},{  253, 3223},{  287, 3520},{  330, 3799},
+        {  383, 4062},{  445, 4315},{  518, 4556},{  598, 4783},
+        {  683, 5002},{  765, 5224},{  841, 5446},{  919, 5670},
+        { 1000, 5886},{ 1081, 6094},{ 1164, 6305},{ 1233, 6523}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=26  INTRA*/
+      {
+        {  258,  -31},{  400, 1459},{  722, 2551},{ 1169, 3138},
+        { 1615, 3542},{ 2039, 3983},{ 2450, 4461},{ 2843, 4928},
+        { 3216, 5372},{ 3573, 5801},{ 3910, 6212},{ 4235, 6548},
+        { 4561, 6836},{ 4859, 7132},{ 5141, 7450},{ 5422, 7763},
+        { 5690, 8035},{ 5958, 8307},{ 6208, 8548},{ 6426, 8763},
+        { 6637, 8999},{ 6854, 9211},{ 7072, 9398},{ 7298, 9718}
+      },
+      /*Y'  qi=26  INTER*/
+      {
+        {  178,    4},{  177, 1342},{  304, 2683},{  507, 3858},
+        {  799, 4872},{ 1167, 5777},{ 1579, 6592},{ 2013, 7342},
+        { 2463, 8039},{ 2932, 8668},{ 3429, 9170},{ 3952, 9500},
+        { 4471, 9695},{ 4958, 9825},{ 5404, 9930},{ 5816,10028},
+        { 6194,10113},{ 6545,10187},{ 6878,10268},{ 7193,10333},
+        { 7482,10365},{ 7753,10399},{ 8004,10427},{ 8244,10452}
+      }
+    },
+    {
+      /*Cb  qi=26  INTRA*/
+      {
+        {   17,    2},{  134,  370},{  222,  751},{  258, 1192},
+        {  290, 1638},{  334, 2041},{  391, 2388},{  456, 2686},
+        {  523, 2953},{  595, 3181},{  672, 3382},{  749, 3580},
+        {  828, 3763},{  904, 3921},{  980, 4076},{ 1050, 4257},
+        { 1121, 4425},{ 1199, 4551},{ 1268, 4678},{ 1329, 4855},
+        { 1391, 5012},{ 1452, 5149},{ 1514, 5292},{ 1584, 5469}
+      },
+      /*Cb  qi=26  INTER*/
+      {
+        {  133,   54},{  140,  366},{  144,  683},{  151, 1052},
+        {  166, 1444},{  185, 1827},{  208, 2185},{  234, 2523},
+        {  264, 2845},{  300, 3152},{  337, 3446},{  381, 3724},
+        {  434, 3989},{  492, 4246},{  560, 4494},{  643, 4729},
+        {  735, 4957},{  831, 5185},{  938, 5397},{ 1051, 5595},
+        { 1164, 5787},{ 1272, 5969},{ 1372, 6157},{ 1465, 6357}
+      }
+    },
+    {
+      /*Cr  qi=26  INTRA*/
+      {
+        {   16,    5},{  134,  384},{  217,  779},{  257, 1235},
+        {  291, 1682},{  333, 2078},{  387, 2417},{  448, 2694},
+        {  514, 2933},{  581, 3153},{  661, 3358},{  749, 3542},
+        {  825, 3713},{  902, 3879},{  981, 4048},{ 1064, 4183},
+        { 1146, 4294},{ 1220, 4429},{ 1283, 4589},{ 1347, 4738},
+        { 1408, 4915},{ 1456, 5089},{ 1497, 5270},{ 1555, 5473}
+      },
+      /*Cr  qi=26  INTER*/
+      {
+        {  129,   55},{  138,  367},{  143,  688},{  150, 1061},
+        {  165, 1451},{  182, 1830},{  199, 2194},{  217, 2547},
+        {  242, 2882},{  273, 3193},{  313, 3485},{  363, 3759},
+        {  423, 4018},{  495, 4261},{  579, 4492},{  668, 4714},
+        {  756, 4936},{  840, 5157},{  923, 5378},{ 1009, 5598},
+        { 1094, 5809},{ 1177, 6020},{ 1264, 6230},{ 1360, 6432}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=27  INTRA*/
+      {
+        {  258,  -32},{  403, 1460},{  736, 2556},{ 1195, 3138},
+        { 1656, 3527},{ 2097, 3946},{ 2524, 4400},{ 2933, 4849},
+        { 3318, 5281},{ 3685, 5701},{ 4034, 6100},{ 4369, 6424},
+        { 4700, 6697},{ 5003, 6982},{ 5293, 7287},{ 5580, 7583},
+        { 5851, 7847},{ 6125, 8107},{ 6381, 8335},{ 6601, 8542},
+        { 6812, 8767},{ 7031, 8964},{ 7251, 9143},{ 7460, 9436}
+      },
+      /*Y'  qi=27  INTER*/
+      {
+        {  174,    3},{  178, 1343},{  309, 2679},{  528, 3841},
+        {  842, 4835},{ 1234, 5715},{ 1668, 6506},{ 2125, 7231},
+        { 2600, 7901},{ 3099, 8488},{ 3628, 8935},{ 4175, 9209},
+        { 4704, 9366},{ 5193, 9480},{ 5640, 9581},{ 6049, 9669},
+        { 6428, 9746},{ 6780, 9819},{ 7111, 9881},{ 7420, 9936},
+        { 7714, 9980},{ 7987,10006},{ 8236,10015},{ 8487, 9990}
+      }
+    },
+    {
+      /*Cb  qi=27  INTRA*/
+      {
+        {   17,    2},{  135,  370},{  222,  752},{  258, 1192},
+        {  291, 1635},{  337, 2036},{  396, 2379},{  462, 2674},
+        {  530, 2937},{  605, 3163},{  682, 3361},{  762, 3552},
+        {  844, 3730},{  923, 3886},{ 1001, 4038},{ 1071, 4220},
+        { 1146, 4379},{ 1228, 4497},{ 1297, 4628},{ 1354, 4804},
+        { 1419, 4959},{ 1489, 5092},{ 1555, 5230},{ 1629, 5427}
+      },
+      /*Cb  qi=27  INTER*/
+      {
+        {  142,   56},{  141,  368},{  143,  683},{  151, 1052},
+        {  166, 1443},{  185, 1825},{  210, 2181},{  238, 2517},
+        {  270, 2838},{  307, 3141},{  348, 3429},{  395, 3704},
+        {  451, 3968},{  517, 4221},{  594, 4462},{  683, 4691},
+        {  778, 4916},{  882, 5135},{  996, 5338},{ 1114, 5528},
+        { 1228, 5719},{ 1335, 5903},{ 1444, 6078},{ 1552, 6260}
+      }
+    },
+    {
+      /*Cr  qi=27  INTRA*/
+      {
+        {   15,    5},{  133,  384},{  217,  778},{  257, 1235},
+        {  293, 1678},{  337, 2071},{  392, 2406},{  455, 2679},
+        {  523, 2915},{  594, 3127},{  678, 3328},{  765, 3510},
+        {  841, 3677},{  921, 3842},{ 1000, 4006},{ 1089, 4135},
+        { 1175, 4240},{ 1248, 4381},{ 1311, 4545},{ 1380, 4682},
+        { 1445, 4854},{ 1491, 5030},{ 1537, 5201},{ 1630, 5329}
+      },
+      /*Cr  qi=27  INTER*/
+      {
+        {  134,   53},{  139,  366},{  143,  688},{  151, 1060},
+        {  165, 1451},{  182, 1828},{  200, 2190},{  220, 2541},
+        {  245, 2874},{  279, 3183},{  323, 3469},{  379, 3740},
+        {  447, 3991},{  526, 4230},{  615, 4457},{  708, 4677},
+        {  803, 4892},{  896, 5105},{  983, 5317},{ 1063, 5536},
+        { 1149, 5753},{ 1240, 5957},{ 1334, 6155},{ 1436, 6345}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=28  INTRA*/
+      {
+        {  250,  -28},{  406, 1456},{  749, 2531},{ 1221, 3097},
+        { 1692, 3480},{ 2144, 3894},{ 2583, 4338},{ 3005, 4778},
+        { 3399, 5202},{ 3775, 5609},{ 4132, 5991},{ 4473, 6310},
+        { 4808, 6577},{ 5115, 6852},{ 5412, 7147},{ 5707, 7428},
+        { 5984, 7683},{ 6264, 7933},{ 6523, 8153},{ 6739, 8345},
+        { 6953, 8556},{ 7178, 8740},{ 7398, 8913},{ 7628, 9201}
+      },
+      /*Y'  qi=28  INTER*/
+      {
+        {  188,    9},{  179, 1341},{  319, 2665},{  554, 3815},
+        {  890, 4796},{ 1302, 5661},{ 1760, 6433},{ 2243, 7138},
+        { 2741, 7788},{ 3264, 8342},{ 3817, 8740},{ 4379, 8977},
+        { 4914, 9110},{ 5401, 9211},{ 5844, 9304},{ 6249, 9392},
+        { 6627, 9472},{ 6979, 9540},{ 7310, 9602},{ 7619, 9648},
+        { 7907, 9685},{ 8177, 9708},{ 8427, 9706},{ 8667, 9672}
+      }
+    },
+    {
+      /*Cb  qi=28  INTRA*/
+      {
+        {   18,    2},{  136,  370},{  224,  752},{  260, 1190},
+        {  295, 1630},{  344, 2024},{  407, 2360},{  476, 2651},
+        {  547, 2911},{  626, 3132},{  705, 3328},{  786, 3516},
+        {  874, 3689},{  952, 3845},{ 1031, 3997},{ 1111, 4173},
+        { 1188, 4330},{ 1265, 4450},{ 1335, 4580},{ 1399, 4745},
+        { 1469, 4892},{ 1537, 5027},{ 1603, 5166},{ 1658, 5359}
+      },
+      /*Cb  qi=28  INTER*/
+      {
+        {  129,   58},{  138,  367},{  143,  683},{  152, 1051},
+        {  168, 1441},{  188, 1819},{  214, 2172},{  245, 2504},
+        {  280, 2820},{  321, 3120},{  366, 3405},{  418, 3677},
+        {  482, 3935},{  555, 4181},{  637, 4421},{  729, 4651},
+        {  832, 4868},{  942, 5082},{ 1060, 5284},{ 1181, 5467},
+        { 1298, 5651},{ 1412, 5835},{ 1527, 6003},{ 1644, 6157}
+      }
+    },
+    {
+      /*Cr  qi=28  INTRA*/
+      {
+        {   17,    5},{  134,  384},{  217,  778},{  259, 1232},
+        {  297, 1672},{  344, 2057},{  403, 2387},{  467, 2658},
+        {  537, 2892},{  611, 3104},{  696, 3305},{  784, 3482},
+        {  865, 3638},{  950, 3796},{ 1035, 3961},{ 1122, 4093},
+        { 1210, 4192},{ 1288, 4326},{ 1355, 4481},{ 1427, 4613},
+        { 1489, 4791},{ 1534, 4970},{ 1585, 5132},{ 1675, 5267}
+      },
+      /*Cr  qi=28  INTER*/
+      {
+        {  132,   52},{  135,  365},{  141,  687},{  151, 1061},
+        {  167, 1449},{  185, 1823},{  204, 2181},{  226, 2528},
+        {  254, 2856},{  292, 3162},{  341, 3446},{  403, 3710},
+        {  479, 3958},{  565, 4193},{  658, 4416},{  757, 4630},
+        {  855, 4844},{  949, 5058},{ 1039, 5267},{ 1128, 5479},
+        { 1216, 5696},{ 1314, 5893},{ 1422, 6075},{ 1529, 6250}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=29  INTRA*/
+      {
+        {  256,  -19},{  440, 1432},{  823, 2441},{ 1332, 2962},
+        { 1823, 3333},{ 2290, 3743},{ 2744, 4191},{ 3179, 4635},
+        { 3581, 5067},{ 3964, 5474},{ 4330, 5853},{ 4674, 6173},
+        { 5012, 6435},{ 5323, 6703},{ 5626, 6990},{ 5926, 7263},
+        { 6200, 7506},{ 6482, 7745},{ 6745, 7958},{ 6964, 8149},
+        { 7177, 8350},{ 7401, 8529},{ 7623, 8694},{ 7865, 8975}
+      },
+      /*Y'  qi=29  INTER*/
+      {
+        {  193,   -3},{  195, 1340},{  350, 2649},{  615, 3772},
+        {  987, 4730},{ 1432, 5577},{ 1915, 6337},{ 2421, 7033},
+        { 2948, 7660},{ 3506, 8171},{ 4092, 8506},{ 4674, 8689},
+        { 5209, 8810},{ 5690, 8915},{ 6126, 9009},{ 6531, 9093},
+        { 6905, 9159},{ 7250, 9232},{ 7582, 9297},{ 7894, 9345},
+        { 8183, 9382},{ 8451, 9400},{ 8704, 9415},{ 8946, 9404}
+      }
+    },
+    {
+      /*Cb  qi=29  INTRA*/
+      {
+        {   18,    2},{  142,  371},{  235,  752},{  276, 1186},
+        {  315, 1612},{  372, 1987},{  444, 2305},{  520, 2578},
+        {  597, 2824},{  682, 3035},{  769, 3224},{  856, 3410},
+        {  948, 3581},{ 1033, 3730},{ 1117, 3883},{ 1196, 4059},
+        { 1276, 4212},{ 1357, 4332},{ 1419, 4467},{ 1481, 4636},
+        { 1561, 4780},{ 1629, 4919},{ 1689, 5071},{ 1748, 5260}
+      },
+      /*Cb  qi=29  INTER*/
+      {
+        {  146,   39},{  153,  353},{  156,  673},{  164, 1049},
+        {  181, 1437},{  203, 1810},{  230, 2155},{  264, 2480},
+        {  303, 2792},{  348, 3087},{  401, 3365},{  464, 3630},
+        {  537, 3883},{  621, 4125},{  714, 4357},{  817, 4578},
+        {  932, 4789},{ 1056, 4990},{ 1185, 5182},{ 1310, 5363},
+        { 1437, 5531},{ 1559, 5709},{ 1671, 5883},{ 1783, 6059}
+      }
+    },
+    {
+      /*Cr  qi=29  INTRA*/
+      {
+        {   19,    6},{  142,  385},{  228,  779},{  273, 1227},
+        {  317, 1650},{  373, 2011},{  440, 2322},{  512, 2584},
+        {  588, 2809},{  668, 3013},{  760, 3207},{  851, 3380},
+        {  936, 3533},{ 1030, 3687},{ 1118, 3853},{ 1203, 3986},
+        { 1292, 4081},{ 1369, 4215},{ 1438, 4373},{ 1510, 4510},
+        { 1569, 4695},{ 1619, 4871},{ 1675, 5031},{ 1775, 5166}
+      },
+      /*Cr  qi=29  INTER*/
+      {
+        {  143,    2},{  149,  356},{  155,  684},{  163, 1059},
+        {  179, 1445},{  198, 1812},{  218, 2166},{  243, 2507},
+        {  276, 2828},{  320, 3126},{  380, 3401},{  453, 3659},
+        {  541, 3897},{  639, 4123},{  742, 4341},{  848, 4552},
+        {  953, 4763},{ 1051, 4973},{ 1143, 5186},{ 1243, 5395},
+        { 1350, 5596},{ 1453, 5785},{ 1569, 5957},{ 1706, 6124}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=30  INTRA*/
+      {
+        {  253,  -16},{  448, 1426},{  855, 2407},{ 1388, 2904},
+        { 1899, 3262},{ 2386, 3661},{ 2864, 4094},{ 3323, 4518},
+        { 3747, 4929},{ 4147, 5313},{ 4530, 5669},{ 4889, 5966},
+        { 5235, 6209},{ 5556, 6456},{ 5869, 6717},{ 6178, 6971},
+        { 6464, 7204},{ 6756, 7428},{ 7023, 7622},{ 7247, 7789},
+        { 7472, 7974},{ 7704, 8141},{ 7930, 8299},{ 8183, 8558}
+      },
+      /*Y'  qi=30  INTER*/
+      {
+        {  189,   -4},{  197, 1340},{  370, 2631},{  669, 3731},
+        { 1081, 4662},{ 1564, 5480},{ 2087, 6209},{ 2633, 6870},
+        { 3209, 7445},{ 3821, 7868},{ 4445, 8110},{ 5032, 8243},
+        { 5559, 8348},{ 6032, 8446},{ 6463, 8534},{ 6858, 8610},
+        { 7222, 8671},{ 7566, 8730},{ 7891, 8790},{ 8196, 8839},
+        { 8483, 8875},{ 8752, 8881},{ 9009, 8882},{ 9238, 8898}
+      }
+    },
+    {
+      /*Cb  qi=30  INTRA*/
+      {
+        {   18,    2},{  143,  371},{  238,  752},{  279, 1183},
+        {  321, 1603},{  383, 1969},{  461, 2281},{  542, 2550},
+        {  623, 2788},{  712, 2992},{  803, 3174},{  899, 3353},
+        {  997, 3516},{ 1087, 3662},{ 1176, 3808},{ 1259, 3975},
+        { 1340, 4129},{ 1422, 4243},{ 1496, 4370},{ 1560, 4541},
+        { 1631, 4696},{ 1699, 4839},{ 1767, 4981},{ 1831, 5182}
+      },
+      /*Cb  qi=30  INTER*/
+      {
+        {  157,   37},{  158,  352},{  158,  673},{  166, 1049},
+        {  184, 1435},{  208, 1803},{  239, 2141},{  276, 2460},
+        {  322, 2766},{  373, 3057},{  434, 3330},{  507, 3587},
+        {  591, 3833},{  685, 4069},{  788, 4294},{  903, 4507},
+        { 1027, 4714},{ 1162, 4905},{ 1301, 5087},{ 1440, 5262},
+        { 1568, 5430},{ 1689, 5598},{ 1817, 5759},{ 1938, 5957}
+      }
+    },
+    {
+      /*Cr  qi=30  INTRA*/
+      {
+        {   19,    6},{  144,  385},{  230,  778},{  276, 1224},
+        {  323, 1641},{  386, 1992},{  459, 2296},{  534, 2554},
+        {  614, 2772},{  699, 2971},{  798, 3160},{  893, 3329},
+        {  982, 3476},{ 1083, 3624},{ 1176, 3782},{ 1264, 3908},
+        { 1354, 4002},{ 1432, 4135},{ 1505, 4282},{ 1582, 4410},
+        { 1648, 4591},{ 1695, 4771},{ 1756, 4922},{ 1850, 5020}
+      },
+      /*Cr  qi=30  INTER*/
+      {
+        {  141,    5},{  148,  354},{  155,  684},{  164, 1058},
+        {  181, 1441},{  202, 1804},{  225, 2154},{  252, 2491},
+        {  292, 2806},{  345, 3096},{  414, 3363},{  499, 3612},
+        {  596, 3844},{  705, 4066},{  819, 4279},{  933, 4480},
+        { 1043, 4687},{ 1147, 4899},{ 1246, 5108},{ 1354, 5308},
+        { 1472, 5496},{ 1592, 5676},{ 1726, 5831},{ 1859, 5990}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=31  INTRA*/
+      {
+        {  253,  -12},{  454, 1419},{  882, 2378},{ 1435, 2861},
+        { 1951, 3215},{ 2444, 3610},{ 2928, 4039},{ 3394, 4459},
+        { 3825, 4870},{ 4228, 5259},{ 4612, 5613},{ 4975, 5905},
+        { 5324, 6143},{ 5645, 6389},{ 5958, 6646},{ 6273, 6890},
+        { 6558, 7114},{ 6847, 7335},{ 7115, 7527},{ 7339, 7690},
+        { 7563, 7874},{ 7792, 8041},{ 8013, 8196},{ 8270, 8449}
+      },
+      /*Y'  qi=31  INTER*/
+      {
+        {  189,   -3},{  199, 1339},{  393, 2612},{  727, 3689},
+        { 1177, 4597},{ 1690, 5399},{ 2238, 6117},{ 2810, 6766},
+        { 3413, 7317},{ 4050, 7703},{ 4686, 7916},{ 5273, 8037},
+        { 5792, 8136},{ 6260, 8234},{ 6684, 8325},{ 7074, 8394},
+        { 7435, 8456},{ 7775, 8517},{ 8103, 8572},{ 8410, 8617},
+        { 8694, 8644},{ 8960, 8658},{ 9224, 8670},{ 9489, 8694}
+      }
+    },
+    {
+      /*Cb  qi=31  INTRA*/
+      {
+        {   19,    2},{  145,  371},{  240,  752},{  281, 1181},
+        {  326, 1595},{  392, 1954},{  472, 2257},{  556, 2517},
+        {  640, 2750},{  730, 2951},{  825, 3131},{  922, 3310},
+        { 1018, 3477},{ 1110, 3621},{ 1203, 3765},{ 1282, 3938},
+        { 1361, 4096},{ 1443, 4214},{ 1516, 4340},{ 1579, 4508},
+        { 1649, 4662},{ 1716, 4805},{ 1790, 4941},{ 1871, 5133}
+      },
+      /*Cb  qi=31  INTER*/
+      {
+        {  148,   37},{  152,  352},{  157,  674},{  167, 1048},
+        {  186, 1432},{  212, 1795},{  248, 2128},{  291, 2442},
+        {  341, 2742},{  404, 3025},{  474, 3292},{  555, 3546},
+        {  651, 3784},{  757, 4013},{  867, 4235},{  993, 4441},
+        { 1130, 4636},{ 1274, 4823},{ 1422, 4995},{ 1566, 5160},
+        { 1703, 5323},{ 1829, 5493},{ 1954, 5663},{ 2101, 5780}
+      }
+    },
+    {
+      /*Cr  qi=31  INTRA*/
+      {
+        {   19,    6},{  145,  386},{  232,  778},{  278, 1221},
+        {  328, 1631},{  396, 1972},{  472, 2268},{  547, 2521},
+        {  628, 2738},{  715, 2936},{  817, 3120},{  913, 3291},
+        { 1005, 3442},{ 1105, 3591},{ 1198, 3747},{ 1286, 3870},
+        { 1378, 3961},{ 1461, 4092},{ 1532, 4244},{ 1605, 4377},
+        { 1668, 4560},{ 1717, 4737},{ 1780, 4885},{ 1882, 4986}
+      },
+      /*Cr  qi=31  INTER*/
+      {
+        {  138,    6},{  148,  354},{  155,  684},{  165, 1057},
+        {  184, 1437},{  207, 1796},{  233, 2141},{  266, 2472},
+        {  312, 2780},{  372, 3065},{  451, 3327},{  549, 3567},
+        {  660, 3794},{  779, 4006},{  906, 4208},{ 1025, 4411},
+        { 1139, 4617},{ 1250, 4823},{ 1360, 5024},{ 1475, 5221},
+        { 1601, 5400},{ 1739, 5557},{ 1880, 5707},{ 2019, 5854}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=32  INTRA*/
+      {
+        {  250,  -10},{  458, 1417},{  901, 2366},{ 1469, 2839},
+        { 2000, 3182},{ 2507, 3559},{ 3007, 3966},{ 3487, 4369},
+        { 3932, 4765},{ 4348, 5136},{ 4742, 5472},{ 5113, 5743},
+        { 5471, 5971},{ 5798, 6206},{ 6118, 6451},{ 6437, 6686},
+        { 6729, 6903},{ 7024, 7119},{ 7295, 7300},{ 7521, 7455},
+        { 7744, 7627},{ 7976, 7778},{ 8202, 7925},{ 8472, 8175}
+      },
+      /*Y'  qi=32  INTER*/
+      {
+        {  192,   11},{  200, 1338},{  399, 2605},{  747, 3673},
+        { 1215, 4570},{ 1751, 5350},{ 2329, 6039},{ 2936, 6653},
+        { 3576, 7153},{ 4241, 7479},{ 4887, 7649},{ 5471, 7752},
+        { 5987, 7842},{ 6451, 7932},{ 6874, 8009},{ 7261, 8068},
+        { 7624, 8122},{ 7965, 8176},{ 8292, 8225},{ 8597, 8261},
+        { 8882, 8291},{ 9155, 8301},{ 9410, 8303},{ 9639, 8288}
+      }
+    },
+    {
+      /*Cb  qi=32  INTRA*/
+      {
+        {   19,    2},{  145,  371},{  239,  752},{  283, 1180},
+        {  329, 1593},{  398, 1950},{  483, 2252},{  569, 2511},
+        {  656, 2741},{  754, 2936},{  853, 3107},{  952, 3283},
+        { 1055, 3443},{ 1155, 3579},{ 1250, 3715},{ 1331, 3881},
+        { 1414, 4035},{ 1498, 4155},{ 1569, 4289},{ 1634, 4460},
+        { 1705, 4613},{ 1776, 4746},{ 1850, 4878},{ 1921, 5076}
+      },
+      /*Cb  qi=32  INTER*/
+      {
+        {  137,   30},{  147,  350},{  157,  674},{  168, 1048},
+        {  186, 1431},{  214, 1792},{  250, 2124},{  295, 2436},
+        {  350, 2733},{  413, 3013},{  487, 3279},{  575, 3529},
+        {  675, 3766},{  784, 3994},{  900, 4210},{ 1030, 4410},
+        { 1174, 4601},{ 1323, 4780},{ 1475, 4947},{ 1621, 5109},
+        { 1760, 5266},{ 1888, 5434},{ 2019, 5608},{ 2176, 5736}
+      }
+    },
+    {
+      /*Cr  qi=32  INTRA*/
+      {
+        {   19,    6},{  145,  386},{  232,  778},{  281, 1219},
+        {  333, 1627},{  402, 1968},{  482, 2263},{  562, 2514},
+        {  648, 2726},{  738, 2917},{  842, 3100},{  945, 3261},
+        { 1040, 3401},{ 1145, 3544},{ 1242, 3699},{ 1335, 3819},
+        { 1433, 3906},{ 1514, 4037},{ 1586, 4183},{ 1663, 4310},
+        { 1731, 4495},{ 1785, 4671},{ 1849, 4812},{ 1948, 4904}
+      },
+      /*Cr  qi=32  INTER*/
+      {
+        {  134,    6},{  146,  354},{  156,  683},{  165, 1057},
+        {  184, 1437},{  208, 1794},{  235, 2136},{  270, 2466},
+        {  318, 2773},{  383, 3054},{  466, 3313},{  569, 3551},
+        {  687, 3770},{  812, 3979},{  937, 4180},{ 1058, 4381},
+        { 1172, 4585},{ 1288, 4787},{ 1408, 4985},{ 1528, 5173},
+        { 1655, 5351},{ 1796, 5507},{ 1948, 5638},{ 2094, 5762}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=33  INTRA*/
+      {
+        {  251,   -3},{  482, 1400},{  956, 2310},{ 1547, 2757},
+        { 2093, 3091},{ 2618, 3466},{ 3134, 3876},{ 3627, 4282},
+        { 4082, 4675},{ 4507, 5046},{ 4908, 5383},{ 5283, 5659},
+        { 5640, 5883},{ 5971, 6103},{ 6296, 6342},{ 6615, 6576},
+        { 6909, 6783},{ 7206, 6990},{ 7476, 7167},{ 7700, 7318},
+        { 7924, 7482},{ 8156, 7632},{ 8390, 7783},{ 8661, 8018}
+      },
+      /*Y'  qi=33  INTER*/
+      {
+        {  203,   42},{  212, 1342},{  438, 2585},{  826, 3628},
+        { 1333, 4507},{ 1902, 5276},{ 2508, 5959},{ 3143, 6559},
+        { 3816, 7021},{ 4504, 7301},{ 5154, 7443},{ 5731, 7545},
+        { 6241, 7640},{ 6699, 7726},{ 7118, 7804},{ 7509, 7867},
+        { 7867, 7922},{ 8206, 7981},{ 8536, 8031},{ 8842, 8055},
+        { 9122, 8072},{ 9399, 8088},{ 9654, 8089},{ 9879, 8087}
+      }
+    },
+    {
+      /*Cb  qi=33  INTRA*/
+      {
+        {   22,    2},{  159,  372},{  260,  753},{  305, 1177},
+        {  357, 1577},{  434, 1917},{  523, 2204},{  614, 2451},
+        {  707, 2670},{  810, 2859},{  914, 3028},{ 1015, 3204},
+        { 1120, 3367},{ 1223, 3507},{ 1321, 3644},{ 1400, 3812},
+        { 1481, 3965},{ 1562, 4088},{ 1635, 4224},{ 1701, 4393},
+        { 1770, 4550},{ 1847, 4681},{ 1927, 4812},{ 2007, 5028}
+      },
+      /*Cb  qi=33  INTER*/
+      {
+        {  148,   39},{  157,  355},{  165,  678},{  177, 1050},
+        {  197, 1428},{  228, 1781},{  269, 2105},{  322, 2411},
+        {  384, 2703},{  456, 2977},{  543, 3235},{  642, 3479},
+        {  753, 3710},{  872, 3932},{ 1000, 4144},{ 1144, 4339},
+        { 1300, 4520},{ 1458, 4692},{ 1618, 4855},{ 1771, 5013},
+        { 1908, 5175},{ 2050, 5337},{ 2195, 5501},{ 2336, 5652}
+      }
+    },
+    {
+      /*Cr  qi=33  INTRA*/
+      {
+        {   23,    6},{  159,  388},{  251,  781},{  303, 1215},
+        {  363, 1607},{  440, 1930},{  525, 2208},{  609, 2447},
+        {  698, 2656},{  793, 2847},{  898, 3028},{ 1004, 3191},
+        { 1105, 3334},{ 1214, 3475},{ 1312, 3627},{ 1404, 3748},
+        { 1499, 3841},{ 1581, 3971},{ 1654, 4119},{ 1728, 4253},
+        { 1796, 4435},{ 1853, 4608},{ 1925, 4746},{ 2021, 4852}
+      },
+      /*Cr  qi=33  INTER*/
+      {
+        {  151,    6},{  152,  359},{  162,  686},{  173, 1058},
+        {  194, 1432},{  221, 1782},{  253, 2118},{  293, 2442},
+        {  351, 2741},{  428, 3014},{  524, 3266},{  641, 3495},
+        {  771, 3708},{  903, 3914},{ 1036, 4112},{ 1168, 4312},
+        { 1291, 4513},{ 1416, 4709},{ 1541, 4904},{ 1670, 5090},
+        { 1808, 5263},{ 1962, 5409},{ 2136, 5516},{ 2329, 5593}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=34  INTRA*/
+      {
+        {  249,    0},{  488, 1396},{  986, 2289},{ 1601, 2724},
+        { 2165, 3049},{ 2706, 3409},{ 3240, 3798},{ 3748, 4183},
+        { 4214, 4561},{ 4650, 4916},{ 5062, 5232},{ 5446, 5484},
+        { 5810, 5686},{ 6143, 5888},{ 6467, 6114},{ 6786, 6340},
+        { 7076, 6539},{ 7371, 6728},{ 7644, 6893},{ 7861, 7037},
+        { 8071, 7188},{ 8302, 7324},{ 8542, 7465},{ 8808, 7698}
+      },
+      /*Y'  qi=34  INTER*/
+      {
+        {  205,    9},{  214, 1338},{  464, 2567},{  895, 3586},
+        { 1446, 4434},{ 2058, 5171},{ 2711, 5819},{ 3401, 6368},
+        { 4128, 6753},{ 4846, 6963},{ 5495, 7075},{ 6064, 7158},
+        { 6568, 7237},{ 7021, 7308},{ 7433, 7365},{ 7816, 7412},
+        { 8173, 7454},{ 8507, 7484},{ 8827, 7504},{ 9135, 7516},
+        { 9410, 7514},{ 9670, 7500},{ 9914, 7484},{10130, 7453}
+      }
+    },
+    {
+      /*Cb  qi=34  INTRA*/
+      {
+        {   17,    2},{  157,  371},{  261,  752},{  306, 1174},
+        {  363, 1568},{  445, 1901},{  540, 2186},{  636, 2432},
+        {  734, 2649},{  843, 2833},{  951, 2994},{ 1059, 3162},
+        { 1169, 3320},{ 1272, 3456},{ 1372, 3588},{ 1457, 3751},
+        { 1542, 3902},{ 1628, 4026},{ 1701, 4161},{ 1770, 4323},
+        { 1847, 4473},{ 1915, 4604},{ 1989, 4743},{ 2079, 4962}
+      },
+      /*Cb  qi=34  INTER*/
+      {
+        {  141,   42},{  155,  356},{  165,  677},{  178, 1049},
+        {  200, 1426},{  235, 1775},{  281, 2093},{  340, 2393},
+        {  412, 2679},{  496, 2947},{  593, 3200},{  704, 3436},
+        {  826, 3660},{  955, 3873},{ 1092, 4075},{ 1247, 4259},
+        { 1417, 4424},{ 1586, 4583},{ 1748, 4738},{ 1907, 4891},
+        { 2063, 5037},{ 2212, 5187},{ 2356, 5362},{ 2511, 5551}
+      }
+    },
+    {
+      /*Cr  qi=34  INTRA*/
+      {
+        {   18,    5},{  157,  387},{  252,  780},{  304, 1210},
+        {  369, 1595},{  452, 1913},{  542, 2192},{  630, 2430},
+        {  725, 2633},{  826, 2820},{  937, 2997},{ 1047, 3156},
+        { 1153, 3287},{ 1267, 3420},{ 1367, 3569},{ 1462, 3690},
+        { 1559, 3782},{ 1643, 3911},{ 1718, 4052},{ 1793, 4182},
+        { 1864, 4364},{ 1923, 4528},{ 1992, 4664},{ 2092, 4771}
+      },
+      /*Cr  qi=34  INTER*/
+      {
+        {  139,    9},{  153,  358},{  164,  687},{  175, 1058},
+        {  198, 1430},{  227, 1776},{  262, 2108},{  309, 2426},
+        {  375, 2719},{  463, 2986},{  573, 3228},{  702, 3450},
+        {  840, 3656},{  982, 3853},{ 1129, 4042},{ 1268, 4235},
+        { 1396, 4431},{ 1533, 4617},{ 1670, 4804},{ 1815, 4972},
+        { 1980, 5111},{ 2151, 5235},{ 2335, 5328},{ 2519, 5413}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=35  INTRA*/
+      {
+        {  242,    4},{  497, 1386},{ 1017, 2259},{ 1653, 2679},
+        { 2235, 2992},{ 2795, 3342},{ 3347, 3720},{ 3871, 4093},
+        { 4355, 4460},{ 4805, 4799},{ 5229, 5094},{ 5625, 5323},
+        { 5997, 5512},{ 6337, 5712},{ 6671, 5931},{ 7003, 6144},
+        { 7305, 6337},{ 7614, 6525},{ 7898, 6682},{ 8129, 6817},
+        { 8360, 6965},{ 8601, 7095},{ 8851, 7222},{ 9128, 7438}
+      },
+      /*Y'  qi=35  INTER*/
+      {
+        {  204,    2},{  217, 1336},{  495, 2550},{  967, 3544},
+        { 1558, 4367},{ 2207, 5083},{ 2895, 5709},{ 3626, 6213},
+        { 4389, 6534},{ 5118, 6697},{ 5766, 6798},{ 6332, 6884},
+        { 6838, 6965},{ 7296, 7043},{ 7719, 7102},{ 8111, 7154},
+        { 8476, 7201},{ 8826, 7248},{ 9160, 7286},{ 9476, 7308},
+        { 9774, 7329},{10054, 7343},{10316, 7339},{10575, 7351}
+      }
+    },
+    {
+      /*Cb  qi=35  INTRA*/
+      {
+        {   23,    2},{  162,  372},{  263,  752},{  312, 1170},
+        {  373, 1557},{  462, 1883},{  563, 2158},{  667, 2396},
+        {  772, 2607},{  887, 2785},{  999, 2947},{ 1112, 3113},
+        { 1226, 3266},{ 1332, 3402},{ 1433, 3537},{ 1519, 3696},
+        { 1609, 3845},{ 1695, 3968},{ 1772, 4099},{ 1845, 4256},
+        { 1925, 4408},{ 1994, 4545},{ 2065, 4677},{ 2146, 4904}
+      },
+      /*Cb  qi=35  INTER*/
+      {
+        {  147,   34},{  157,  354},{  167,  678},{  179, 1048},
+        {  203, 1422},{  241, 1768},{  293, 2083},{  359, 2379},
+        {  440, 2659},{  535, 2921},{  645, 3167},{  768, 3399},
+        {  897, 3619},{ 1034, 3829},{ 1182, 4024},{ 1345, 4202},
+        { 1525, 4365},{ 1704, 4518},{ 1872, 4673},{ 2038, 4824},
+        { 2201, 4966},{ 2358, 5126},{ 2508, 5302},{ 2648, 5479}
+      }
+    },
+    {
+      /*Cr  qi=35  INTRA*/
+      {
+        {   25,    6},{  162,  389},{  255,  780},{  312, 1206},
+        {  382, 1583},{  470, 1894},{  565, 2166},{  657, 2399},
+        {  757, 2599},{  863, 2783},{  979, 2956},{ 1096, 3110},
+        { 1209, 3239},{ 1323, 3370},{ 1424, 3518},{ 1522, 3640},
+        { 1620, 3738},{ 1710, 3860},{ 1792, 3985},{ 1867, 4109},
+        { 1938, 4287},{ 2003, 4451},{ 2074, 4585},{ 2192, 4655}
+      },
+      /*Cr  qi=35  INTER*/
+      {
+        {  135,    8},{  154,  359},{  164,  687},{  176, 1056},
+        {  202, 1425},{  234, 1769},{  274, 2098},{  328, 2411},
+        {  404, 2698},{  504, 2958},{  628, 3194},{  769, 3409},
+        {  918, 3608},{ 1068, 3799},{ 1215, 3990},{ 1360, 4178},
+        { 1498, 4373},{ 1637, 4563},{ 1786, 4743},{ 1942, 4904},
+        { 2117, 5033},{ 2299, 5148},{ 2497, 5226},{ 2705, 5259}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=36  INTRA*/
+      {
+        {  235,   11},{  510, 1382},{ 1051, 2249},{ 1711, 2656},
+        { 2318, 2951},{ 2906, 3275},{ 3484, 3630},{ 4030, 3984},
+        { 4531, 4330},{ 4995, 4651},{ 5433, 4930},{ 5837, 5147},
+        { 6213, 5325},{ 6560, 5519},{ 6901, 5737},{ 7234, 5946},
+        { 7539, 6134},{ 7857, 6316},{ 8153, 6471},{ 8388, 6597},
+        { 8618, 6732},{ 8865, 6856},{ 9121, 6978},{ 9381, 7166}
+      },
+      /*Y'  qi=36  INTER*/
+      {
+        {  206,    6},{  219, 1335},{  520, 2535},{ 1028, 3510},
+        { 1661, 4306},{ 2354, 4990},{ 3089, 5579},{ 3862, 6036},
+        { 4652, 6305},{ 5389, 6436},{ 6032, 6527},{ 6597, 6606},
+        { 7102, 6680},{ 7564, 6752},{ 7990, 6809},{ 8386, 6856},
+        { 8762, 6900},{ 9118, 6941},{ 9456, 6975},{ 9772, 6995},
+        {10074, 7009},{10355, 7020},{10617, 7016},{10868, 7004}
+      }
+    },
+    {
+      /*Cb  qi=36  INTRA*/
+      {
+        {   22,    2},{  163,  372},{  265,  752},{  314, 1167},
+        {  379, 1551},{  471, 1873},{  577, 2144},{  684, 2375},
+        {  794, 2580},{  914, 2751},{ 1031, 2909},{ 1147, 3070},
+        { 1267, 3216},{ 1378, 3352},{ 1481, 3484},{ 1572, 3639},
+        { 1663, 3783},{ 1750, 3905},{ 1825, 4041},{ 1898, 4197},
+        { 1985, 4339},{ 2063, 4468},{ 2131, 4613},{ 2213, 4832}
+      },
+      /*Cb  qi=36  INTER*/
+      {
+        {  148,   34},{  159,  353},{  168,  678},{  181, 1047},
+        {  206, 1419},{  246, 1762},{  304, 2072},{  378, 2364},
+        {  466, 2640},{  571, 2898},{  691, 3139},{  821, 3366},
+        {  962, 3579},{ 1108, 3782},{ 1268, 3968},{ 1443, 4138},
+        { 1628, 4296},{ 1813, 4446},{ 1996, 4587},{ 2170, 4732},
+        { 2335, 4877},{ 2502, 5023},{ 2662, 5204},{ 2816, 5396}
+      }
+    },
+    {
+      /*Cr  qi=36  INTRA*/
+      {
+        {   24,    6},{  162,  388},{  256,  780},{  314, 1203},
+        {  389, 1575},{  480, 1883},{  578, 2151},{  675, 2377},
+        {  780, 2570},{  890, 2750},{ 1012, 2917},{ 1138, 3062},
+        { 1254, 3187},{ 1371, 3316},{ 1474, 3461},{ 1574, 3582},
+        { 1678, 3671},{ 1771, 3784},{ 1846, 3917},{ 1918, 4044},
+        { 1996, 4218},{ 2068, 4367},{ 2143, 4494},{ 2248, 4581}
+      },
+      /*Cr  qi=36  INTER*/
+      {
+        {  140,   10},{  157,  358},{  165,  686},{  178, 1055},
+        {  204, 1422},{  239, 1763},{  282, 2088},{  343, 2397},
+        {  429, 2679},{  541, 2934},{  675, 3164},{  825, 3371},
+        {  980, 3566},{ 1138, 3754},{ 1295, 3937},{ 1447, 4126},
+        { 1593, 4315},{ 1742, 4495},{ 1899, 4667},{ 2071, 4815},
+        { 2261, 4930},{ 2466, 5024},{ 2677, 5085},{ 2901, 5092}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=37  INTRA*/
+      {
+        {  236,   30},{  562, 1355},{ 1128, 2197},{ 1803, 2592},
+        { 2429, 2875},{ 3038, 3188},{ 3631, 3539},{ 4185, 3892},
+        { 4690, 4240},{ 5159, 4563},{ 5598, 4838},{ 6002, 5050},
+        { 6378, 5230},{ 6728, 5421},{ 7072, 5629},{ 7409, 5838},
+        { 7717, 6024},{ 8036, 6204},{ 8333, 6356},{ 8573, 6479},
+        { 8800, 6613},{ 9047, 6741},{ 9301, 6864},{ 9571, 7063}
+      },
+      /*Y'  qi=37  INTER*/
+      {
+        {  210,    5},{  222, 1332},{  548, 2519},{ 1091, 3477},
+        { 1756, 4260},{ 2475, 4935},{ 3235, 5511},{ 4034, 5937},
+        { 4839, 6173},{ 5573, 6290},{ 6212, 6379},{ 6772, 6459},
+        { 7276, 6531},{ 7737, 6599},{ 8163, 6655},{ 8566, 6701},
+        { 8944, 6745},{ 9299, 6784},{ 9636, 6814},{ 9953, 6836},
+        {10257, 6854},{10549, 6867},{10813, 6863},{11053, 6834}
+      }
+    },
+    {
+      /*Cb  qi=37  INTRA*/
+      {
+        {   27,    2},{  179,  373},{  291,  752},{  345, 1160},
+        {  416, 1532},{  515, 1843},{  627, 2103},{  739, 2327},
+        {  854, 2526},{  978, 2693},{ 1102, 2846},{ 1221, 3007},
+        { 1340, 3157},{ 1452, 3292},{ 1556, 3427},{ 1648, 3585},
+        { 1738, 3731},{ 1824, 3859},{ 1901, 3998},{ 1972, 4147},
+        { 2064, 4282},{ 2145, 4421},{ 2216, 4567},{ 2285, 4785}
+      },
+      /*Cb  qi=37  INTER*/
+      {
+        {  157,   33},{  162,  355},{  168,  679},{  182, 1045},
+        {  210, 1414},{  255, 1754},{  317, 2061},{  398, 2348},
+        {  496, 2619},{  611, 2872},{  740, 3108},{  880, 3331},
+        { 1027, 3542},{ 1182, 3738},{ 1349, 3920},{ 1534, 4085},
+        { 1732, 4234},{ 1924, 4377},{ 2105, 4527},{ 2285, 4673},
+        { 2464, 4806},{ 2635, 4956},{ 2797, 5133},{ 2980, 5305}
+      }
+    },
+    {
+      /*Cr  qi=37  INTRA*/
+      {
+        {   36,    7},{  180,  394},{  277,  785},{  341, 1199},
+        {  424, 1556},{  524, 1851},{  628, 2108},{  730, 2325},
+        {  842, 2513},{  957, 2689},{ 1084, 2853},{ 1212, 3001},
+        { 1330, 3129},{ 1449, 3255},{ 1553, 3398},{ 1650, 3522},
+        { 1752, 3622},{ 1848, 3735},{ 1924, 3863},{ 1994, 3995},
+        { 2072, 4168},{ 2145, 4323},{ 2215, 4454},{ 2324, 4538}
+      },
+      /*Cr  qi=37  INTER*/
+      {
+        {  149,    9},{  157,  359},{  166,  686},{  180, 1053},
+        {  208, 1417},{  246, 1755},{  295, 2077},{  362, 2381},
+        {  458, 2657},{  580, 2905},{  725, 3130},{  886, 3333},
+        { 1050, 3523},{ 1213, 3707},{ 1373, 3893},{ 1529, 4078},
+        { 1690, 4256},{ 1848, 4436},{ 2012, 4605},{ 2196, 4742},
+        { 2397, 4844},{ 2616, 4919},{ 2839, 4964},{ 3068, 4999}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=38  INTRA*/
+      {
+        {  236,   32},{  570, 1352},{ 1154, 2183},{ 1846, 2567},
+        { 2492, 2835},{ 3124, 3127},{ 3740, 3457},{ 4315, 3791},
+        { 4844, 4115},{ 5329, 4414},{ 5780, 4670},{ 6193, 4864},
+        { 6578, 5028},{ 6937, 5212},{ 7292, 5410},{ 7639, 5604},
+        { 7956, 5783},{ 8286, 5953},{ 8589, 6102},{ 8830, 6217},
+        { 9069, 6339},{ 9321, 6458},{ 9578, 6574},{ 9858, 6766}
+      },
+      /*Y'  qi=38  INTER*/
+      {
+        {  210,    7},{  226, 1331},{  589, 2497},{ 1187, 3424},
+        { 1908, 4173},{ 2682, 4812},{ 3496, 5341},{ 4347, 5698},
+        { 5176, 5876},{ 5911, 5973},{ 6546, 6054},{ 7109, 6130},
+        { 7619, 6200},{ 8085, 6256},{ 8519, 6308},{ 8927, 6352},
+        { 9307, 6387},{ 9672, 6424},{10024, 6455},{10352, 6479},
+        {10665, 6495},{10955, 6501},{11224, 6504},{11463, 6509}
+      }
+    },
+    {
+      /*Cb  qi=38  INTRA*/
+      {
+        {   29,    3},{  181,  373},{  292,  752},{  350, 1157},
+        {  429, 1525},{  537, 1831},{  654, 2087},{  772, 2304},
+        {  894, 2495},{ 1025, 2655},{ 1151, 2804},{ 1276, 2961},
+        { 1403, 3106},{ 1517, 3239},{ 1622, 3372},{ 1719, 3528},
+        { 1814, 3671},{ 1905, 3797},{ 1991, 3929},{ 2062, 4081},
+        { 2151, 4215},{ 2243, 4341},{ 2322, 4483},{ 2410, 4697}
+      },
+      /*Cb  qi=38  INTER*/
+      {
+        {  154,   38},{  163,  356},{  170,  678},{  185, 1045},
+        {  215, 1411},{  263, 1746},{  334, 2048},{  426, 2329},
+        {  538, 2592},{  666, 2838},{  809, 3068},{  961, 3283},
+        { 1120, 3486},{ 1289, 3675},{ 1470, 3849},{ 1670, 4004},
+        { 1877, 4148},{ 2082, 4284},{ 2279, 4419},{ 2466, 4553},
+        { 2650, 4695},{ 2836, 4851},{ 3021, 5011},{ 3207, 5170}
+      }
+    },
+    {
+      /*Cr  qi=38  INTRA*/
+      {
+        {   38,    7},{  182,  394},{  279,  785},{  348, 1195},
+        {  438, 1550},{  544, 1842},{  653, 2096},{  761, 2308},
+        {  878, 2487},{ 1000, 2656},{ 1134, 2815},{ 1270, 2955},
+        { 1396, 3076},{ 1519, 3199},{ 1625, 3339},{ 1725, 3460},
+        { 1831, 3557},{ 1927, 3670},{ 2005, 3792},{ 2080, 3919},
+        { 2167, 4082},{ 2242, 4227},{ 2309, 4364},{ 2415, 4447}
+      },
+      /*Cr  qi=38  INTER*/
+      {
+        {  149,    6},{  159,  359},{  166,  686},{  182, 1052},
+        {  213, 1414},{  255, 1748},{  309, 2064},{  387, 2363},
+        {  497, 2632},{  636, 2872},{  794, 3089},{  968, 3283},
+        { 1145, 3465},{ 1315, 3646},{ 1483, 3826},{ 1657, 4004},
+        { 1826, 4180},{ 1998, 4346},{ 2188, 4490},{ 2391, 4610},
+        { 2598, 4710},{ 2828, 4770},{ 3063, 4792},{ 3257, 4848}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=39  INTRA*/
+      {
+        {  234,   32},{  570, 1352},{ 1155, 2183},{ 1848, 2566},
+        { 2495, 2831},{ 3133, 3119},{ 3755, 3440},{ 4337, 3764},
+        { 4871, 4082},{ 5364, 4373},{ 5820, 4621},{ 6237, 4809},
+        { 6626, 4966},{ 6987, 5146},{ 7346, 5340},{ 7699, 5527},
+        { 8024, 5697},{ 8356, 5862},{ 8660, 6005},{ 8907, 6116},
+        { 9150, 6230},{ 9408, 6342},{ 9665, 6449},{ 9941, 6627}
+      },
+      /*Y'  qi=39  INTER*/
+      {
+        {  206,    9},{  225, 1331},{  589, 2497},{ 1187, 3424},
+        { 1909, 4172},{ 2688, 4807},{ 3514, 5326},{ 4376, 5666},
+        { 5208, 5831},{ 5944, 5921},{ 6579, 6000},{ 7142, 6075},
+        { 7653, 6140},{ 8120, 6197},{ 8556, 6247},{ 8965, 6288},
+        { 9347, 6324},{ 9711, 6355},{10063, 6384},{10398, 6411},
+        {10700, 6425},{10994, 6428},{11271, 6426},{11496, 6430}
+      }
+    },
+    {
+      /*Cb  qi=39  INTRA*/
+      {
+        {   29,    3},{  180,  373},{  292,  752},{  350, 1157},
+        {  429, 1524},{  537, 1829},{  655, 2084},{  775, 2300},
+        {  899, 2489},{ 1028, 2648},{ 1155, 2796},{ 1281, 2950},
+        { 1410, 3093},{ 1525, 3226},{ 1629, 3360},{ 1728, 3513},
+        { 1828, 3654},{ 1919, 3778},{ 2002, 3911},{ 2079, 4060},
+        { 2169, 4191},{ 2260, 4320},{ 2340, 4457},{ 2413, 4674}
+      },
+      /*Cb  qi=39  INTER*/
+      {
+        {  164,   35},{  165,  355},{  169,  678},{  185, 1044},
+        {  214, 1410},{  263, 1746},{  334, 2048},{  426, 2328},
+        {  538, 2592},{  668, 2838},{  810, 3068},{  960, 3285},
+        { 1118, 3487},{ 1288, 3676},{ 1470, 3850},{ 1667, 4007},
+        { 1875, 4148},{ 2081, 4283},{ 2275, 4424},{ 2466, 4561},
+        { 2652, 4698},{ 2832, 4853},{ 3015, 5008},{ 3186, 5172}
+      }
+    },
+    {
+      /*Cr  qi=39  INTRA*/
+      {
+        {   37,    7},{  182,  394},{  279,  785},{  348, 1195},
+        {  438, 1549},{  544, 1840},{  655, 2093},{  766, 2302},
+        {  883, 2481},{ 1005, 2650},{ 1138, 2809},{ 1272, 2949},
+        { 1397, 3070},{ 1522, 3190},{ 1632, 3327},{ 1734, 3451},
+        { 1843, 3549},{ 1938, 3659},{ 2017, 3775},{ 2095, 3895},
+        { 2179, 4058},{ 2256, 4208},{ 2331, 4335},{ 2441, 4401}
+      },
+      /*Cr  qi=39  INTER*/
+      {
+        {  146,    9},{  157,  360},{  168,  686},{  182, 1052},
+        {  212, 1413},{  254, 1747},{  309, 2064},{  388, 2363},
+        {  496, 2632},{  634, 2872},{  795, 3087},{  968, 3281},
+        { 1141, 3466},{ 1313, 3647},{ 1484, 3829},{ 1653, 4008},
+        { 1822, 4183},{ 1995, 4354},{ 2188, 4499},{ 2386, 4617},
+        { 2592, 4709},{ 2827, 4775},{ 3069, 4802},{ 3305, 4777}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=40  INTRA*/
+      {
+        {  226,   38},{  594, 1336},{ 1233, 2131},{ 1973, 2495},
+        { 2656, 2748},{ 3319, 3025},{ 3962, 3342},{ 4560, 3665},
+        { 5107, 3977},{ 5609, 4266},{ 6073, 4511},{ 6493, 4693},
+        { 6886, 4846},{ 7253, 5021},{ 7610, 5214},{ 7964, 5399},
+        { 8291, 5565},{ 8627, 5726},{ 8934, 5868},{ 9183, 5979},
+        { 9427, 6092},{ 9685, 6201},{ 9953, 6304},{10248, 6484}
+      },
+      /*Y'  qi=40  INTER*/
+      {
+        {  217,   -2},{  233, 1327},{  661, 2461},{ 1337, 3353},
+        { 2130, 4073},{ 2967, 4690},{ 3841, 5178},{ 4739, 5469},
+        { 5581, 5606},{ 6311, 5693},{ 6944, 5771},{ 7510, 5843},
+        { 8025, 5907},{ 8501, 5964},{ 8944, 6014},{ 9359, 6055},
+        { 9752, 6088},{10124, 6122},{10477, 6148},{10807, 6163},
+        {11117, 6175},{11411, 6185},{11686, 6188},{11943, 6192}
+      }
+    },
+    {
+      /*Cb  qi=40  INTRA*/
+      {
+        {   29,    2},{  183,  373},{  297,  751},{  362, 1148},
+        {  450, 1502},{  570, 1792},{  698, 2035},{  829, 2240},
+        {  961, 2422},{ 1097, 2579},{ 1226, 2727},{ 1356, 2883},
+        { 1489, 3027},{ 1606, 3163},{ 1711, 3303},{ 1807, 3459},
+        { 1907, 3600},{ 2005, 3724},{ 2088, 3858},{ 2163, 4007},
+        { 2257, 4127},{ 2347, 4251},{ 2426, 4396},{ 2514, 4608}
+      },
+      /*Cb  qi=40  INTER*/
+      {
+        {  155,   41},{  164,  358},{  172,  678},{  190, 1042},
+        {  226, 1401},{  286, 1728},{  373, 2020},{  487, 2289},
+        {  620, 2542},{  768, 2779},{  930, 3000},{ 1099, 3206},
+        { 1271, 3402},{ 1459, 3582},{ 1665, 3742},{ 1886, 3883},
+        { 2110, 4012},{ 2330, 4144},{ 2536, 4284},{ 2735, 4419},
+        { 2944, 4551},{ 3148, 4704},{ 3347, 4840},{ 3557, 4961}
+      }
+    },
+    {
+      /*Cr  qi=40  INTRA*/
+      {
+        {   37,    6},{  184,  394},{  283,  783},{  359, 1185},
+        {  461, 1523},{  580, 1798},{  699, 2036},{  819, 2237},
+        {  946, 2411},{ 1074, 2583},{ 1211, 2746},{ 1346, 2885},
+        { 1474, 3006},{ 1602, 3130},{ 1714, 3272},{ 1819, 3390},
+        { 1926, 3483},{ 2023, 3598},{ 2105, 3714},{ 2181, 3841},
+        { 2265, 4009},{ 2341, 4150},{ 2415, 4273},{ 2521, 4361}
+      },
+      /*Cr  qi=40  INTER*/
+      {
+        {  151,   10},{  160,  359},{  169,  686},{  186, 1049},
+        {  223, 1404},{  276, 1730},{  345, 2038},{  446, 2324},
+        {  579, 2581},{  740, 2809},{  920, 3014},{ 1108, 3201},
+        { 1299, 3378},{ 1485, 3556},{ 1663, 3737},{ 1848, 3910},
+        { 2041, 4076},{ 2237, 4231},{ 2448, 4358},{ 2676, 4452},
+        { 2912, 4519},{ 3154, 4562},{ 3406, 4570},{ 3671, 4526}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=41  INTRA*/
+      {
+        {  220,   40},{  608, 1331},{ 1268, 2118},{ 2027, 2472},
+        { 2731, 2711},{ 3421, 2968},{ 4089, 3261},{ 4710, 3558},
+        { 5280, 3842},{ 5800, 4103},{ 6277, 4326},{ 6709, 4490},
+        { 7111, 4632},{ 7488, 4797},{ 7858, 4979},{ 8226, 5151},
+        { 8570, 5308},{ 8922, 5458},{ 9244, 5585},{ 9501, 5682},
+        { 9751, 5786},{10022, 5892},{10298, 5991},{10596, 6153}
+      },
+      /*Y'  qi=41  INTER*/
+      {
+        {  219,    0},{  234, 1327},{  696, 2445},{ 1417, 3313},
+        { 2263, 4001},{ 3165, 4571},{ 4109, 4982},{ 5051, 5193},
+        { 5899, 5292},{ 6626, 5368},{ 7262, 5435},{ 7836, 5495},
+        { 8360, 5549},{ 8842, 5597},{ 9292, 5639},{ 9718, 5675},
+        {10119, 5705},{10499, 5732},{10865, 5753},{11204, 5770},
+        {11519, 5782},{11819, 5788},{12093, 5785},{12335, 5762}
+      }
+    },
+    {
+      /*Cb  qi=41  INTRA*/
+      {
+        {   30,    3},{  184,  373},{  299,  750},{  365, 1145},
+        {  458, 1495},{  583, 1782},{  717, 2020},{  852, 2218},
+        {  988, 2394},{ 1129, 2545},{ 1267, 2688},{ 1405, 2834},
+        { 1542, 2972},{ 1659, 3107},{ 1769, 3242},{ 1874, 3395},
+        { 1977, 3532},{ 2077, 3656},{ 2166, 3791},{ 2246, 3938},
+        { 2345, 4055},{ 2440, 4161},{ 2522, 4293},{ 2617, 4505}
+      },
+      /*Cb  qi=41  INTER*/
+      {
+        {  146,   41},{  161,  357},{  174,  678},{  190, 1041},
+        {  229, 1398},{  293, 1722},{  388, 2011},{  514, 2274},
+        {  660, 2522},{  819, 2754},{  986, 2972},{ 1161, 3174},
+        { 1348, 3360},{ 1549, 3531},{ 1767, 3684},{ 2002, 3817},
+        { 2237, 3945},{ 2470, 4066},{ 2695, 4187},{ 2913, 4315},
+        { 3129, 4450},{ 3349, 4574},{ 3581, 4689},{ 3807, 4801}
+      }
+    },
+    {
+      /*Cr  qi=41  INTRA*/
+      {
+        {   39,    7},{  185,  394},{  285,  783},{  364, 1181},
+        {  470, 1516},{  591, 1789},{  716, 2022},{  841, 2218},
+        {  973, 2386},{ 1107, 2551},{ 1250, 2707},{ 1392, 2842},
+        { 1527, 2956},{ 1654, 3079},{ 1771, 3217},{ 1887, 3327},
+        { 1995, 3418},{ 2094, 3525},{ 2187, 3631},{ 2270, 3753},
+        { 2351, 3917},{ 2428, 4055},{ 2508, 4171},{ 2614, 4242}
+      },
+      /*Cr  qi=41  INTER*/
+      {
+        {  146,    9},{  159,  360},{  171,  686},{  188, 1048},
+        {  226, 1401},{  283, 1724},{  360, 2028},{  471, 2310},
+        {  616, 2562},{  787, 2786},{  976, 2985},{ 1175, 3164},
+        { 1373, 3337},{ 1564, 3512},{ 1760, 3681},{ 1961, 3846},
+        { 2163, 4007},{ 2381, 4143},{ 2611, 4253},{ 2851, 4332},
+        { 3118, 4372},{ 3381, 4397},{ 3624, 4407},{ 3864, 4412}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=42  INTRA*/
+      {
+        {  258,   53},{  689, 1302},{ 1369, 2075},{ 2137, 2422},
+        { 2859, 2650},{ 3570, 2897},{ 4256, 3184},{ 4892, 3478},
+        { 5469, 3758},{ 5996, 4017},{ 6480, 4240},{ 6912, 4404},
+        { 7322, 4544},{ 7708, 4707},{ 8079, 4886},{ 8450, 5058},
+        { 8792, 5211},{ 9146, 5355},{ 9478, 5481},{ 9735, 5578},
+        { 9985, 5673},{10259, 5775},{10536, 5872},{10851, 6033}
+      },
+      /*Y'  qi=42  INTER*/
+      {
+        {  212,    3},{  236, 1325},{  712, 2436},{ 1458, 3294},
+        { 2324, 3974},{ 3239, 4539},{ 4195, 4939},{ 5141, 5141},
+        { 5991, 5239},{ 6719, 5314},{ 7356, 5381},{ 7930, 5443},
+        { 8456, 5498},{ 8944, 5547},{ 9396, 5586},{ 9819, 5617},
+        {10224, 5650},{10608, 5680},{10971, 5700},{11317, 5717},
+        {11640, 5726},{11942, 5728},{12217, 5731},{12468, 5725}
+      }
+    },
+    {
+      /*Cb  qi=42  INTRA*/
+      {
+        {   28,    3},{  194,  372},{  318,  747},{  395, 1133},
+        {  499, 1475},{  635, 1753},{  780, 1984},{  925, 2176},
+        { 1070, 2345},{ 1219, 2492},{ 1364, 2631},{ 1506, 2776},
+        { 1646, 2913},{ 1769, 3048},{ 1877, 3186},{ 1980, 3341},
+        { 2083, 3478},{ 2183, 3601},{ 2275, 3735},{ 2360, 3880},
+        { 2461, 3998},{ 2551, 4110},{ 2637, 4241},{ 2738, 4445}
+      },
+      /*Cb  qi=42  INTER*/
+      {
+        {  148,   34},{  161,  353},{  174,  677},{  191, 1040},
+        {  230, 1396},{  298, 1718},{  397, 2004},{  526, 2266},
+        {  676, 2513},{  840, 2743},{ 1015, 2957},{ 1199, 3156},
+        { 1392, 3339},{ 1599, 3507},{ 1822, 3658},{ 2063, 3788},
+        { 2306, 3908},{ 2538, 4035},{ 2765, 4160},{ 2990, 4279},
+        { 3212, 4407},{ 3443, 4532},{ 3685, 4637},{ 3903, 4746}
+      }
+    },
+    {
+      /*Cr  qi=42  INTRA*/
+      {
+        {   40,    7},{  196,  395},{  303,  781},{  394, 1168},
+        {  514, 1490},{  645, 1757},{  780, 1983},{  913, 2172},
+        { 1056, 2335},{ 1203, 2490},{ 1354, 2639},{ 1499, 2774},
+        { 1634, 2894},{ 1762, 3019},{ 1880, 3153},{ 1996, 3267},
+        { 2101, 3368},{ 2201, 3475},{ 2295, 3579},{ 2379, 3697},
+        { 2462, 3858},{ 2540, 4000},{ 2625, 4121},{ 2743, 4206}
+      },
+      /*Cr  qi=42  INTER*/
+      {
+        {  142,    7},{  162,  358},{  171,  686},{  188, 1047},
+        {  227, 1398},{  286, 1720},{  367, 2023},{  482, 2303},
+        {  633, 2552},{  813, 2772},{ 1010, 2967},{ 1215, 3144},
+        { 1415, 3316},{ 1612, 3488},{ 1815, 3658},{ 2020, 3819},
+        { 2233, 3972},{ 2458, 4106},{ 2688, 4214},{ 2937, 4286},
+        { 3196, 4330},{ 3462, 4349},{ 3723, 4350},{ 3958, 4352}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=43  INTRA*/
+      {
+        {  256,   55},{  695, 1296},{ 1396, 2053},{ 2187, 2394},
+        { 2931, 2613},{ 3655, 2854},{ 4350, 3137},{ 4993, 3425},
+        { 5574, 3700},{ 6101, 3953},{ 6590, 4174},{ 7025, 4335},
+        { 7428, 4471},{ 7812, 4627},{ 8183, 4799},{ 8556, 4966},
+        { 8902, 5117},{ 9258, 5258},{ 9589, 5381},{ 9848, 5478},
+        {10099, 5570},{10368, 5666},{10647, 5766},{10965, 5934}
+      },
+      /*Y'  qi=43  INTER*/
+      {
+        {  214,    2},{  245, 1321},{  781, 2405},{ 1591, 3238},
+        { 2506, 3906},{ 3461, 4455},{ 4455, 4815},{ 5416, 4982},
+        { 6257, 5075},{ 6979, 5151},{ 7613, 5217},{ 8186, 5279},
+        { 8712, 5333},{ 9200, 5380},{ 9657, 5418},{10086, 5449},
+        {10493, 5479},{10879, 5509},{11240, 5530},{11584, 5543},
+        {11909, 5552},{12209, 5555},{12485, 5556},{12717, 5549}
+      }
+    },
+    {
+      /*Cb  qi=43  INTRA*/
+      {
+        {   31,    3},{  198,  373},{  322,  746},{  403, 1125},
+        {  514, 1456},{  653, 1725},{  801, 1950},{  950, 2138},
+        { 1095, 2307},{ 1243, 2458},{ 1385, 2602},{ 1525, 2748},
+        { 1668, 2884},{ 1789, 3022},{ 1897, 3164},{ 2001, 3317},
+        { 2106, 3454},{ 2204, 3579},{ 2293, 3709},{ 2378, 3855},
+        { 2482, 3974},{ 2580, 4082},{ 2669, 4214},{ 2765, 4427}
+      },
+      /*Cb  qi=43  INTER*/
+      {
+        {  174,   33},{  172,  353},{  175,  677},{  197, 1037},
+        {  243, 1387},{  321, 1702},{  436, 1980},{  583, 2234},
+        {  750, 2473},{  930, 2697},{ 1119, 2906},{ 1315, 3099},
+        { 1525, 3275},{ 1749, 3434},{ 1990, 3574},{ 2240, 3701},
+        { 2488, 3822},{ 2733, 3941},{ 2979, 4054},{ 3211, 4171},
+        { 3439, 4295},{ 3680, 4417},{ 3926, 4518},{ 4173, 4645}
+      }
+    },
+    {
+      /*Cr  qi=43  INTRA*/
+      {
+        {   42,    7},{  199,  395},{  308,  780},{  404, 1159},
+        {  528, 1470},{  662, 1726},{  799, 1947},{  937, 2133},
+        { 1082, 2298},{ 1227, 2458},{ 1374, 2613},{ 1515, 2754},
+        { 1654, 2873},{ 1783, 2995},{ 1899, 3132},{ 2016, 3243},
+        { 2122, 3341},{ 2219, 3447},{ 2312, 3553},{ 2402, 3674},
+        { 2491, 3830},{ 2566, 3965},{ 2645, 4089},{ 2748, 4190}
+      },
+      /*Cr  qi=43  INTER*/
+      {
+        {  143,    9},{  161,  359},{  172,  685},{  194, 1044},
+        {  240, 1390},{  308, 1705},{  402, 2000},{  534, 2272},
+        {  703, 2513},{  901, 2725},{ 1114, 2913},{ 1332, 3084},
+        { 1547, 3253},{ 1756, 3422},{ 1970, 3588},{ 2186, 3749},
+        { 2414, 3893},{ 2658, 4008},{ 2905, 4102},{ 3172, 4164},
+        { 3445, 4190},{ 3721, 4193},{ 3984, 4182},{ 4236, 4159}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=44  INTRA*/
+      {
+        {  246,   58},{  719, 1291},{ 1460, 2040},{ 2282, 2374},
+        { 3049, 2582},{ 3792, 2805},{ 4505, 3066},{ 5168, 3336},
+        { 5771, 3589},{ 6319, 3821},{ 6824, 4027},{ 7270, 4177},
+        { 7690, 4300},{ 8087, 4447},{ 8472, 4613},{ 8861, 4772},
+        { 9222, 4912},{ 9593, 5041},{ 9934, 5155},{10202, 5245},
+        {10468, 5328},{10751, 5418},{11036, 5509},{11366, 5659}
+      },
+      /*Y'  qi=44  INTER*/
+      {
+        {  209,    5},{  247, 1320},{  824, 2388},{ 1683, 3196},
+        { 2649, 3835},{ 3667, 4338},{ 4711, 4634},{ 5689, 4762},
+        { 6530, 4841},{ 7256, 4909},{ 7901, 4968},{ 8488, 5021},
+        { 9026, 5066},{ 9523, 5106},{ 9989, 5140},{10433, 5167},
+        {10850, 5194},{11238, 5218},{11616, 5237},{11970, 5252},
+        {12292, 5258},{12598, 5259},{12886, 5260},{13140, 5252}
+      }
+    },
+    {
+      /*Cb  qi=44  INTRA*/
+      {
+        {   31,    3},{  198,  373},{  323,  746},{  406, 1124},
+        {  523, 1452},{  670, 1717},{  825, 1933},{  980, 2113},
+        { 1134, 2274},{ 1286, 2419},{ 1433, 2557},{ 1583, 2697},
+        { 1730, 2829},{ 1853, 2966},{ 1965, 3107},{ 2079, 3254},
+        { 2190, 3390},{ 2292, 3511},{ 2384, 3637},{ 2474, 3777},
+        { 2586, 3890},{ 2684, 3997},{ 2774, 4126},{ 2901, 4310}
+      },
+      /*Cb  qi=44  INTER*/
+      {
+        {  163,   43},{  170,  357},{  176,  677},{  198, 1036},
+        {  247, 1384},{  331, 1695},{  458, 1970},{  620, 2219},
+        {  800, 2452},{  990, 2671},{ 1188, 2873},{ 1393, 3060},
+        { 1611, 3231},{ 1849, 3380},{ 2103, 3515},{ 2363, 3640},
+        { 2627, 3755},{ 2892, 3861},{ 3142, 3969},{ 3387, 4089},
+        { 3645, 4194},{ 3907, 4294},{ 4163, 4378},{ 4403, 4434}
+      }
+    },
+    {
+      /*Cr  qi=44  INTRA*/
+      {
+        {   42,    7},{  199,  395},{  309,  779},{  409, 1157},
+        {  539, 1465},{  678, 1717},{  822, 1931},{  967, 2109},
+        { 1121, 2266},{ 1276, 2417},{ 1429, 2567},{ 1574, 2705},
+        { 1720, 2820},{ 1856, 2938},{ 1977, 3069},{ 2097, 3178},
+        { 2211, 3275},{ 2309, 3382},{ 2398, 3484},{ 2496, 3596},
+        { 2595, 3743},{ 2671, 3877},{ 2758, 4002},{ 2875, 4110}
+      },
+      /*Cr  qi=44  INTER*/
+      {
+        {  147,    6},{  163,  358},{  172,  685},{  194, 1043},
+        {  244, 1387},{  320, 1698},{  425, 1989},{  570, 2256},
+        {  753, 2493},{  961, 2698},{ 1182, 2879},{ 1407, 3046},
+        { 1631, 3211},{ 1853, 3373},{ 2077, 3534},{ 2310, 3685},
+        { 2553, 3819},{ 2813, 3923},{ 3084, 3994},{ 3361, 4046},
+        { 3644, 4065},{ 3923, 4063},{ 4185, 4058},{ 4441, 4046}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=45  INTRA*/
+      {
+        {  236,   61},{  736, 1283},{ 1501, 2022},{ 2342, 2352},
+        { 3126, 2552},{ 3890, 2761},{ 4623, 3009},{ 5301, 3264},
+        { 5920, 3504},{ 6480, 3725},{ 6993, 3920},{ 7444, 4059},
+        { 7868, 4172},{ 8275, 4312},{ 8667, 4470},{ 9062, 4623},
+        { 9431, 4760},{ 9805, 4881},{10147, 4986},{10416, 5067},
+        {10678, 5143},{10958, 5229},{11247, 5318},{11586, 5474}
+      },
+      /*Y'  qi=45  INTER*/
+      {
+        {  204,    7},{  254, 1317},{  882, 2366},{ 1798, 3150},
+        { 2820, 3763},{ 3887, 4229},{ 4965, 4483},{ 5952, 4590},
+        { 6797, 4664},{ 7528, 4728},{ 8178, 4782},{ 8770, 4830},
+        { 9316, 4876},{ 9822, 4914},{10290, 4942},{10728, 4966},
+        {11146, 4987},{11533, 5006},{11903, 5021},{12253, 5028},
+        {12568, 5022},{12870, 5020},{13147, 5017},{13358, 4994}
+      }
+    },
+    {
+      /*Cb  qi=45  INTRA*/
+      {
+        {   33,    3},{  201,  373},{  328,  745},{  419, 1119},
+        {  545, 1441},{  702, 1699},{  869, 1907},{ 1037, 2078},
+        { 1197, 2235},{ 1355, 2378},{ 1509, 2514},{ 1663, 2652},
+        { 1815, 2780},{ 1945, 2913},{ 2063, 3054},{ 2181, 3203},
+        { 2295, 3337},{ 2403, 3456},{ 2496, 3582},{ 2588, 3723},
+        { 2713, 3826},{ 2815, 3929},{ 2904, 4054},{ 3037, 4230}
+      },
+      /*Cb  qi=45  INTER*/
+      {
+        {  165,   38},{  173,  355},{  181,  676},{  203, 1034},
+        {  257, 1378},{  355, 1683},{  497, 1951},{  672, 2195},
+        {  863, 2422},{ 1062, 2636},{ 1269, 2834},{ 1490, 3013},
+        { 1725, 3177},{ 1978, 3320},{ 2251, 3443},{ 2529, 3557},
+        { 2805, 3665},{ 3075, 3767},{ 3336, 3877},{ 3598, 3983},
+        { 3862, 4066},{ 4130, 4159},{ 4399, 4252},{ 4675, 4334}
+      }
+    },
+    {
+      /*Cr  qi=45  INTRA*/
+      {
+        {   43,    8},{  201,  395},{  313,  778},{  420, 1151},
+        {  559, 1454},{  709, 1701},{  865, 1906},{ 1024, 2076},
+        { 1187, 2228},{ 1349, 2378},{ 1507, 2528},{ 1657, 2663},
+        { 1808, 2778},{ 1945, 2898},{ 2069, 3023},{ 2194, 3124},
+        { 2308, 3217},{ 2413, 3324},{ 2509, 3425},{ 2607, 3540},
+        { 2711, 3686},{ 2794, 3810},{ 2883, 3925},{ 3017, 4008}
+      },
+      /*Cr  qi=45  INTER*/
+      {
+        {  149,    8},{  168,  359},{  176,  685},{  199, 1042},
+        {  254, 1381},{  340, 1686},{  460, 1972},{  619, 2234},
+        {  814, 2464},{ 1032, 2664},{ 1266, 2839},{ 1505, 3000},
+        { 1745, 3157},{ 1980, 3318},{ 2214, 3475},{ 2466, 3611},
+        { 2728, 3735},{ 2999, 3829},{ 3284, 3883},{ 3574, 3919},
+        { 3864, 3921},{ 4150, 3911},{ 4408, 3915},{ 4629, 3949}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=46  INTRA*/
+      {
+        {  234,   66},{  742, 1278},{ 1538, 2007},{ 2425, 2326},
+        { 3250, 2507},{ 4031, 2706},{ 4773, 2945},{ 5455, 3190},
+        { 6073, 3423},{ 6638, 3640},{ 7157, 3829},{ 7609, 3965},
+        { 8032, 4080},{ 8438, 4216},{ 8837, 4371},{ 9236, 4522},
+        { 9606, 4654},{ 9985, 4773},{10329, 4878},{10597, 4957},
+        {10865, 5029},{11146, 5110},{11432, 5194},{11752, 5335}
+      },
+      /*Y'  qi=46  INTER*/
+      {
+        {  199,    9},{  270, 1313},{ 1002, 2320},{ 2024, 3067},
+        { 3120, 3660},{ 4247, 4085},{ 5356, 4290},{ 6339, 4383},
+        { 7175, 4460},{ 7906, 4525},{ 8560, 4577},{ 9159, 4626},
+        { 9711, 4671},{10224, 4705},{10707, 4737},{11164, 4767},
+        {11593, 4792},{12000, 4814},{12382, 4832},{12739, 4844},
+        {13074, 4848},{13379, 4846},{13661, 4844},{13914, 4841}
+      }
+    },
+    {
+      /*Cb  qi=46  INTRA*/
+      {
+        {   27,    2},{  202,  373},{  334,  744},{  431, 1108},
+        {  566, 1418},{  729, 1667},{  901, 1869},{ 1075, 2036},
+        { 1239, 2192},{ 1395, 2340},{ 1548, 2481},{ 1707, 2617},
+        { 1863, 2744},{ 1993, 2880},{ 2112, 3021},{ 2230, 3166},
+        { 2344, 3298},{ 2455, 3416},{ 2551, 3539},{ 2641, 3676},
+        { 2760, 3784},{ 2866, 3886},{ 2965, 4005},{ 3115, 4174}
+      },
+      /*Cb  qi=46  INTER*/
+      {
+        {  171,    7},{  176,  356},{  185,  677},{  213, 1030},
+        {  279, 1366},{  398, 1663},{  568, 1921},{  769, 2154},
+        {  982, 2372},{ 1207, 2574},{ 1444, 2758},{ 1694, 2925},
+        { 1963, 3073},{ 2245, 3204},{ 2539, 3322},{ 2835, 3431},
+        { 3128, 3529},{ 3411, 3623},{ 3690, 3731},{ 3966, 3827},
+        { 4241, 3909},{ 4523, 3995},{ 4803, 4082},{ 5080, 4164}
+      }
+    },
+    {
+      /*Cr  qi=46  INTRA*/
+      {
+        {   35,    6},{  200,  393},{  319,  775},{  434, 1137},
+        {  581, 1427},{  737, 1664},{  901, 1862},{ 1066, 2030},
+        { 1235, 2181},{ 1397, 2333},{ 1554, 2486},{ 1705, 2625},
+        { 1858, 2738},{ 1995, 2861},{ 2115, 2991},{ 2238, 3092},
+        { 2354, 3186},{ 2462, 3294},{ 2560, 3392},{ 2662, 3500},
+        { 2773, 3643},{ 2859, 3769},{ 2948, 3883},{ 3085, 3977}
+      },
+      /*Cr  qi=46  INTER*/
+      {
+        {  160,    8},{  168,  359},{  180,  684},{  209, 1037},
+        {  277, 1370},{  382, 1667},{  525, 1942},{  712, 2192},
+        {  935, 2409},{ 1184, 2594},{ 1448, 2756},{ 1712, 2911},
+        { 1971, 3066},{ 2228, 3219},{ 2487, 3368},{ 2758, 3498},
+        { 3045, 3602},{ 3343, 3678},{ 3651, 3720},{ 3952, 3738},
+        { 4248, 3740},{ 4530, 3728},{ 4791, 3728},{ 5043, 3721}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=47  INTRA*/
+      {
+        {  220,   69},{  768, 1271},{ 1601, 1990},{ 2516, 2299},
+        { 3361, 2472},{ 4163, 2661},{ 4926, 2886},{ 5628, 3119},
+        { 6264, 3342},{ 6844, 3546},{ 7378, 3724},{ 7843, 3857},
+        { 8275, 3965},{ 8692, 4095},{ 9104, 4244},{ 9513, 4387},
+        { 9892, 4512},{10280, 4626},{10630, 4723},{10908, 4796},
+        {11191, 4862},{11477, 4938},{11764, 5015},{12113, 5150}
+      },
+      /*Y'  qi=47  INTER*/
+      {
+        {  200,    9},{  275, 1312},{ 1023, 2314},{ 2069, 3048},
+        { 3200, 3622},{ 4364, 4013},{ 5491, 4189},{ 6477, 4272},
+        { 7317, 4342},{ 8051, 4400},{ 8711, 4448},{ 9318, 4494},
+        { 9878, 4533},{10399, 4565},{10882, 4594},{11344, 4621},
+        {11780, 4643},{12185, 4662},{12571, 4674},{12934, 4687},
+        {13269, 4691},{13579, 4692},{13874, 4695},{14155, 4701}
+      }
+    },
+    {
+      /*Cb  qi=47  INTRA*/
+      {
+        {   37,    3},{  207,  374},{  335,  743},{  434, 1106},
+        {  573, 1412},{  740, 1657},{  915, 1855},{ 1091, 2020},
+        { 1256, 2175},{ 1415, 2321},{ 1570, 2460},{ 1729, 2593},
+        { 1888, 2718},{ 2021, 2853},{ 2141, 2991},{ 2263, 3132},
+        { 2380, 3263},{ 2493, 3381},{ 2594, 3498},{ 2691, 3630},
+        { 2807, 3735},{ 2908, 3831},{ 3011, 3940},{ 3173, 4090}
+      },
+      /*Cb  qi=47  INTER*/
+      {
+        {  171,   40},{  179,  357},{  188,  678},{  215, 1029},
+        {  285, 1365},{  410, 1659},{  587, 1915},{  791, 2146},
+        { 1005, 2363},{ 1229, 2563},{ 1471, 2744},{ 1729, 2908},
+        { 2005, 3052},{ 2296, 3181},{ 2596, 3295},{ 2901, 3399},
+        { 3200, 3495},{ 3491, 3587},{ 3784, 3693},{ 4066, 3780},
+        { 4349, 3848},{ 4639, 3928},{ 4922, 4000},{ 5202, 4037}
+      }
+    },
+    {
+      /*Cr  qi=47  INTRA*/
+      {
+        {   48,    8},{  206,  395},{  321,  775},{  438, 1134},
+        {  588, 1420},{  748, 1654},{  914, 1850},{ 1081, 2016},
+        { 1250, 2166},{ 1416, 2315},{ 1576, 2466},{ 1727, 2603},
+        { 1884, 2713},{ 2023, 2833},{ 2143, 2960},{ 2272, 3059},
+        { 2394, 3149},{ 2502, 3253},{ 2601, 3350},{ 2703, 3454},
+        { 2818, 3592},{ 2908, 3719},{ 2997, 3828},{ 3151, 3903}
+      },
+      /*Cr  qi=47  INTER*/
+      {
+        {  159,    8},{  169,  360},{  182,  684},{  211, 1036},
+        {  282, 1367},{  394, 1663},{  544, 1936},{  734, 2185},
+        {  958, 2400},{ 1207, 2583},{ 1472, 2744},{ 1742, 2897},
+        { 2010, 3049},{ 2275, 3199},{ 2542, 3345},{ 2823, 3470},
+        { 3122, 3565},{ 3429, 3632},{ 3740, 3672},{ 4049, 3682},
+        { 4353, 3675},{ 4629, 3678},{ 4871, 3679},{ 5116, 3695}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=48  INTRA*/
+      {
+        {  198,   77},{  796, 1266},{ 1666, 1983},{ 2615, 2290},
+        { 3492, 2446},{ 4314, 2616},{ 5095, 2823},{ 5816, 3036},
+        { 6468, 3241},{ 7061, 3433},{ 7609, 3601},{ 8085, 3724},
+        { 8523, 3823},{ 8950, 3945},{ 9373, 4086},{ 9788, 4223},
+        {10177, 4339},{10574, 4442},{10932, 4528},{11215, 4591},
+        {11491, 4649},{11779, 4718},{12081, 4786},{12431, 4903}
+      },
+      /*Y'  qi=48  INTER*/
+      {
+        {  188,   17},{  276, 1313},{ 1090, 2296},{ 2224, 2999},
+        { 3439, 3536},{ 4663, 3879},{ 5813, 4018},{ 6802, 4091},
+        { 7650, 4156},{ 8397, 4209},{ 9071, 4255},{ 9691, 4297},
+        {10259, 4331},{10790, 4359},{11284, 4386},{11746, 4411},
+        {12184, 4428},{12599, 4444},{12985, 4456},{13337, 4464},
+        {13680, 4467},{14000, 4461},{14282, 4452},{14545, 4435}
+      }
+    },
+    {
+      /*Cb  qi=48  INTRA*/
+      {
+        {   35,    3},{  211,  373},{  345,  741},{  456, 1099},
+        {  610, 1402},{  791, 1640},{  978, 1831},{ 1164, 1992},
+        { 1336, 2145},{ 1502, 2290},{ 1664, 2426},{ 1833, 2553},
+        { 2000, 2670},{ 2148, 2799},{ 2279, 2931},{ 2403, 3067},
+        { 2531, 3192},{ 2649, 3308},{ 2755, 3419},{ 2860, 3542},
+        { 2982, 3645},{ 3084, 3740},{ 3181, 3845},{ 3354, 3966}
+      },
+      /*Cb  qi=48  INTER*/
+      {
+        {  177,   56},{  187,  367},{  194,  680},{  222, 1026},
+        {  296, 1356},{  431, 1644},{  622, 1894},{  843, 2120},
+        { 1075, 2329},{ 1320, 2523},{ 1583, 2698},{ 1867, 2851},
+        { 2169, 2985},{ 2479, 3107},{ 2797, 3218},{ 3116, 3314},
+        { 3429, 3405},{ 3739, 3495},{ 4045, 3576},{ 4338, 3661},
+        { 4629, 3739},{ 4934, 3799},{ 5236, 3853},{ 5497, 3900}
+      }
+    },
+    {
+      /*Cr  qi=48  INTRA*/
+      {
+        {   45,    7},{  210,  392},{  333,  770},{  464, 1125},
+        {  627, 1411},{  798, 1644},{  975, 1834},{ 1152, 1992},
+        { 1333, 2135},{ 1511, 2277},{ 1684, 2421},{ 1845, 2553},
+        { 2004, 2662},{ 2150, 2778},{ 2285, 2898},{ 2422, 2988},
+        { 2547, 3071},{ 2660, 3172},{ 2765, 3270},{ 2873, 3369},
+        { 2988, 3498},{ 3082, 3621},{ 3180, 3725},{ 3302, 3813}
+      },
+      /*Cr  qi=48  INTER*/
+      {
+        {  158,   13},{  174,  367},{  183,  688},{  214, 1035},
+        {  292, 1359},{  413, 1648},{  577, 1916},{  781, 2160},
+        { 1019, 2373},{ 1288, 2550},{ 1578, 2703},{ 1872, 2847},
+        { 2163, 2991},{ 2450, 3133},{ 2738, 3265},{ 3041, 3381},
+        { 3364, 3465},{ 3693, 3512},{ 4019, 3535},{ 4330, 3547},
+        { 4630, 3537},{ 4902, 3535},{ 5158, 3535},{ 5402, 3514}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=49  INTRA*/
+      {
+        {  199,   78},{  799, 1265},{ 1680, 1978},{ 2646, 2277},
+        { 3534, 2424},{ 4361, 2584},{ 5146, 2780},{ 5871, 2985},
+        { 6528, 3183},{ 7126, 3365},{ 7677, 3528},{ 8159, 3647},
+        { 8598, 3744},{ 9026, 3863},{ 9456, 3998},{ 9880, 4130},
+        {10274, 4242},{10674, 4345},{11036, 4430},{11321, 4487},
+        {11601, 4540},{11894, 4606},{12197, 4671},{12539, 4771}
+      },
+      /*Y'  qi=49  INTER*/
+      {
+        {  178,   20},{  286, 1311},{ 1143, 2277},{ 2322, 2960},
+        { 3585, 3471},{ 4845, 3781},{ 6005, 3901},{ 6994, 3969},
+        { 7844, 4029},{ 8595, 4078},{ 9276, 4119},{ 9903, 4159},
+        {10478, 4192},{11015, 4220},{11516, 4244},{11993, 4265},
+        {12437, 4286},{12855, 4304},{13245, 4315},{13605, 4323},
+        {13951, 4327},{14265, 4323},{14553, 4318},{14827, 4314}
+      }
+    },
+    {
+      /*Cb  qi=49  INTRA*/
+      {
+        {   41,    3},{  227,  373},{  367,  741},{  481, 1097},
+        {  638, 1398},{  820, 1635},{ 1008, 1826},{ 1196, 1986},
+        { 1369, 2139},{ 1536, 2283},{ 1699, 2419},{ 1869, 2542},
+        { 2038, 2658},{ 2187, 2786},{ 2321, 2917},{ 2447, 3052},
+        { 2572, 3174},{ 2694, 3284},{ 2799, 3398},{ 2907, 3523},
+        { 3036, 3620},{ 3139, 3710},{ 3237, 3811},{ 3406, 3934}
+      },
+      /*Cb  qi=49  INTER*/
+      {
+        {  178,   60},{  189,  368},{  198,  680},{  226, 1025},
+        {  307, 1352},{  453, 1637},{  656, 1884},{  882, 2107},
+        { 1117, 2313},{ 1373, 2500},{ 1650, 2668},{ 1946, 2817},
+        { 2259, 2946},{ 2580, 3062},{ 2910, 3169},{ 3242, 3264},
+        { 3568, 3350},{ 3883, 3435},{ 4196, 3515},{ 4506, 3585},
+        { 4817, 3651},{ 5134, 3716},{ 5414, 3767},{ 5657, 3799}
+      }
+    },
+    {
+      /*Cr  qi=49  INTRA*/
+      {
+        {   54,    7},{  226,  394},{  354,  771},{  488, 1124},
+        {  654, 1408},{  826, 1639},{ 1006, 1828},{ 1185, 1985},
+        { 1366, 2129},{ 1543, 2269},{ 1718, 2412},{ 1881, 2544},
+        { 2039, 2650},{ 2188, 2762},{ 2327, 2879},{ 2463, 2971},
+        { 2583, 3055},{ 2698, 3156},{ 2807, 3252},{ 2920, 3346},
+        { 3039, 3470},{ 3137, 3591},{ 3234, 3695},{ 3355, 3773}
+      },
+      /*Cr  qi=49  INTER*/
+      {
+        {  170,   13},{  178,  368},{  186,  688},{  219, 1033},
+        {  301, 1355},{  434, 1642},{  609, 1906},{  820, 2147},
+        { 1065, 2353},{ 1343, 2524},{ 1644, 2672},{ 1953, 2813},
+        { 2252, 2953},{ 2547, 3093},{ 2856, 3217},{ 3178, 3318},
+        { 3509, 3394},{ 3841, 3441},{ 4170, 3455},{ 4490, 3460},
+        { 4794, 3463},{ 5069, 3459},{ 5317, 3465},{ 5535, 3515}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=50  INTRA*/
+      {
+        {  189,   84},{  816, 1259},{ 1758, 1962},{ 2799, 2241},
+        { 3735, 2370},{ 4584, 2527},{ 5384, 2716},{ 6117, 2907},
+        { 6781, 3091},{ 7387, 3264},{ 7944, 3416},{ 8430, 3527},
+        { 8873, 3619},{ 9303, 3729},{ 9744, 3856},{10179, 3981},
+        {10578, 4088},{10985, 4183},{11348, 4259},{11640, 4311},
+        {11930, 4363},{12228, 4425},{12541, 4484},{12905, 4581}
+      },
+      /*Y'  qi=50  INTER*/
+      {
+        {  162,   24},{  316, 1305},{ 1302, 2227},{ 2595, 2882},
+        { 3947, 3364},{ 5262, 3617},{ 6426, 3712},{ 7407, 3782},
+        { 8257, 3843},{ 9011, 3889},{ 9698, 3930},{10329, 3966},
+        {10911, 3997},{11456, 4025},{11962, 4048},{12437, 4069},
+        {12885, 4085},{13308, 4100},{13708, 4114},{14077, 4122},
+        {14414, 4126},{14740, 4127},{15029, 4125},{15307, 4117}
+      }
+    },
+    {
+      /*Cb  qi=50  INTRA*/
+      {
+        {   42,    3},{  233,  374},{  376,  739},{  497, 1086},
+        {  665, 1374},{  855, 1601},{ 1051, 1784},{ 1249, 1938},
+        { 1431, 2088},{ 1599, 2235},{ 1764, 2373},{ 1938, 2495},
+        { 2113, 2606},{ 2270, 2726},{ 2410, 2853},{ 2538, 2985},
+        { 2667, 3105},{ 2795, 3211},{ 2899, 3320},{ 3009, 3440},
+        { 3136, 3532},{ 3244, 3620},{ 3354, 3712},{ 3506, 3807}
+      },
+      /*Cb  qi=50  INTER*/
+      {
+        {  177,   58},{  191,  368},{  204,  680},{  245, 1019},
+        {  347, 1338},{  524, 1613},{  760, 1848},{ 1015, 2058},
+        { 1277, 2252},{ 1563, 2429},{ 1875, 2585},{ 2206, 2724},
+        { 2548, 2846},{ 2895, 2954},{ 3242, 3050},{ 3588, 3137},
+        { 3932, 3212},{ 4272, 3279},{ 4590, 3361},{ 4903, 3430},
+        { 5225, 3476},{ 5529, 3526},{ 5816, 3566},{ 6057, 3612}
+      }
+    },
+    {
+      /*Cr  qi=50  INTRA*/
+      {
+        {   54,    7},{  230,  394},{  362,  767},{  505, 1109},
+        {  678, 1382},{  859, 1603},{ 1049, 1782},{ 1240, 1934},
+        { 1429, 2076},{ 1613, 2217},{ 1790, 2359},{ 1955, 2489},
+        { 2114, 2597},{ 2263, 2709},{ 2408, 2821},{ 2554, 2905},
+        { 2680, 2982},{ 2799, 3081},{ 2907, 3178},{ 3015, 3265},
+        { 3145, 3384},{ 3251, 3508},{ 3349, 3609},{ 3474, 3679}
+      },
+      /*Cr  qi=50  INTER*/
+      {
+        {  165,   13},{  181,  369},{  191,  687},{  237, 1027},
+        {  343, 1340},{  505, 1617},{  707, 1871},{  945, 2101},
+        { 1221, 2294},{ 1534, 2454},{ 1867, 2594},{ 2198, 2732},
+        { 2522, 2869},{ 2851, 2999},{ 3179, 3114},{ 3526, 3196},
+        { 3887, 3248},{ 4235, 3272},{ 4564, 3277},{ 4880, 3273},
+        { 5179, 3269},{ 5427, 3277},{ 5666, 3261},{ 5927, 3230}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=51  INTRA*/
+      {
+        {  177,   88},{  843, 1254},{ 1819, 1948},{ 2894, 2216},
+        { 3850, 2334},{ 4717, 2482},{ 5531, 2659},{ 6276, 2837},
+        { 6951, 3012},{ 7570, 3175},{ 8137, 3319},{ 8632, 3423},
+        { 9083, 3513},{ 9518, 3625},{ 9965, 3746},{10404, 3864},
+        {10807, 3967},{11222, 4056},{11593, 4134},{11886, 4187},
+        {12178, 4232},{12481, 4291},{12801, 4351},{13171, 4448}
+      },
+      /*Y'  qi=51  INTER*/
+      {
+        {  154,   27},{  327, 1302},{ 1401, 2196},{ 2781, 2825},
+        { 4202, 3268},{ 5558, 3479},{ 6732, 3559},{ 7722, 3622},
+        { 8584, 3678},{ 9352, 3722},{10049, 3758},{10691, 3791},
+        {11284, 3821},{11839, 3848},{12353, 3870},{12840, 3890},
+        {13299, 3909},{13730, 3923},{14142, 3936},{14503, 3942},
+        {14857, 3948},{15199, 3952},{15475, 3946},{15738, 3942}
+      }
+    },
+    {
+      /*Cb  qi=51  INTRA*/
+      {
+        {   43,    3},{  236,  374},{  382,  737},{  510, 1079},
+        {  686, 1360},{  884, 1581},{ 1087, 1759},{ 1292, 1909},
+        { 1478, 2057},{ 1648, 2206},{ 1815, 2344},{ 1992, 2464},
+        { 2169, 2570},{ 2324, 2689},{ 2463, 2819},{ 2592, 2952},
+        { 2724, 3068},{ 2849, 3176},{ 2955, 3285},{ 3073, 3399},
+        { 3203, 3492},{ 3303, 3586},{ 3409, 3673},{ 3588, 3746}
+      },
+      /*Cb  qi=51  INTER*/
+      {
+        {  176,   16},{  193,  367},{  205,  679},{  250, 1017},
+        {  364, 1331},{  559, 1600},{  814, 1828},{ 1091, 2030},
+        { 1378, 2217},{ 1687, 2387},{ 2026, 2536},{ 2382, 2666},
+        { 2742, 2782},{ 3101, 2886},{ 3459, 2977},{ 3820, 3051},
+        { 4172, 3120},{ 4515, 3184},{ 4859, 3250},{ 5181, 3315},
+        { 5502, 3367},{ 5826, 3408},{ 6125, 3442},{ 6438, 3475}
+      }
+    },
+    {
+      /*Cr  qi=51  INTRA*/
+      {
+        {   54,    7},{  231,  394},{  367,  765},{  519, 1101},
+        {  699, 1367},{  888, 1580},{ 1087, 1754},{ 1284, 1903},
+        { 1478, 2043},{ 1664, 2182},{ 1846, 2321},{ 2014, 2453},
+        { 2169, 2563},{ 2320, 2674},{ 2466, 2787},{ 2604, 2873},
+        { 2730, 2952},{ 2851, 3050},{ 2958, 3147},{ 3067, 3234},
+        { 3199, 3350},{ 3304, 3472},{ 3401, 3564},{ 3535, 3591}
+      },
+      /*Cr  qi=51  INTER*/
+      {
+        {  175,   17},{  181,  370},{  193,  687},{  242, 1024},
+        {  360, 1333},{  537, 1604},{  758, 1852},{ 1019, 2073},
+        { 1323, 2258},{ 1665, 2409},{ 2021, 2544},{ 2367, 2679},
+        { 2709, 2810},{ 3054, 2933},{ 3407, 3031},{ 3767, 3098},
+        { 4129, 3142},{ 4480, 3165},{ 4806, 3172},{ 5117, 3161},
+        { 5410, 3153},{ 5681, 3160},{ 5934, 3153},{ 6166, 3158}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=52  INTRA*/
+      {
+        {  170,   90},{  857, 1253},{ 1862, 1943},{ 2960, 2206},
+        { 3932, 2318},{ 4810, 2459},{ 5634, 2626},{ 6390, 2797},
+        { 7075, 2966},{ 7703, 3123},{ 8282, 3264},{ 8785, 3366},
+        { 9240, 3452},{ 9677, 3560},{10133, 3677},{10583, 3792},
+        {10992, 3892},{11404, 3975},{11771, 4046},{12062, 4095},
+        {12357, 4136},{12672, 4193},{12995, 4247},{13374, 4339}
+      },
+      /*Y'  qi=52  INTER*/
+      {
+        {  146,   29},{  348, 1300},{ 1460, 2181},{ 2882, 2793},
+        { 4359, 3205},{ 5746, 3387},{ 6926, 3456},{ 7921, 3514},
+        { 8794, 3563},{ 9573, 3601},{10281, 3635},{10935, 3667},
+        {11537, 3694},{12100, 3716},{12627, 3737},{13120, 3756},
+        {13580, 3771},{14019, 3784},{14437, 3796},{14807, 3803},
+        {15160, 3807},{15502, 3809},{15791, 3807},{16106, 3809}
+      }
+    },
+    {
+      /*Cb  qi=52  INTRA*/
+      {
+        {   47,    4},{  239,  374},{  384,  737},{  515, 1077},
+        {  693, 1356},{  895, 1575},{ 1101, 1752},{ 1309, 1900},
+        { 1498, 2047},{ 1672, 2194},{ 1843, 2331},{ 2025, 2447},
+        { 2207, 2553},{ 2367, 2670},{ 2511, 2792},{ 2646, 2921},
+        { 2777, 3036},{ 2904, 3140},{ 3010, 3246},{ 3133, 3354},
+        { 3269, 3445},{ 3369, 3533},{ 3475, 3614},{ 3661, 3683}
+      },
+      /*Cb  qi=52  INTER*/
+      {
+        {  175,   12},{  192,  367},{  208,  679},{  257, 1016},
+        {  385, 1327},{  597, 1593},{  862, 1818},{ 1140, 2018},
+        { 1427, 2202},{ 1740, 2370},{ 2086, 2515},{ 2457, 2640},
+        { 2832, 2751},{ 3204, 2850},{ 3580, 2935},{ 3951, 3006},
+        { 4316, 3067},{ 4669, 3128},{ 5013, 3188},{ 5360, 3240},
+        { 5690, 3289},{ 6006, 3323},{ 6309, 3356},{ 6615, 3404}
+      }
+    },
+    {
+      /*Cr  qi=52  INTRA*/
+      {
+        {   60,    8},{  235,  395},{  369,  764},{  523, 1099},
+        {  707, 1364},{  900, 1574},{ 1102, 1745},{ 1301, 1894},
+        { 1501, 2033},{ 1688, 2171},{ 1873, 2307},{ 2051, 2431},
+        { 2213, 2539},{ 2365, 2651},{ 2515, 2762},{ 2659, 2842},
+        { 2788, 2912},{ 2911, 3008},{ 3017, 3105},{ 3128, 3189},
+        { 3262, 3305},{ 3370, 3423},{ 3478, 3509},{ 3608, 3550}
+      },
+      /*Cr  qi=52  INTER*/
+      {
+        {  164,   14},{  180,  368},{  195,  687},{  249, 1022},
+        {  378, 1329},{  573, 1597},{  805, 1842},{ 1066, 2062},
+        { 1371, 2243},{ 1719, 2389},{ 2084, 2521},{ 2445, 2652},
+        { 2804, 2779},{ 3161, 2895},{ 3526, 2986},{ 3904, 3047},
+        { 4278, 3081},{ 4632, 3097},{ 4970, 3102},{ 5282, 3092},
+        { 5572, 3083},{ 5839, 3081},{ 6078, 3076},{ 6334, 3081}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=53  INTRA*/
+      {
+        {  150,   94},{  911, 1240},{ 1970, 1915},{ 3099, 2163},
+        { 4097, 2259},{ 5008, 2377},{ 5869, 2521},{ 6665, 2671},
+        { 7387, 2819},{ 8047, 2956},{ 8650, 3080},{ 9175, 3168},
+        { 9649, 3245},{10108, 3344},{10592, 3448},{11062, 3550},
+        {11490, 3634},{11924, 3705},{12303, 3767},{12603, 3808},
+        {12907, 3841},{13236, 3888},{13570, 3931},{13962, 3987}
+      },
+      /*Y'  qi=53  INTER*/
+      {
+        {  136,   29},{  354, 1297},{ 1530, 2157},{ 3034, 2733},
+        { 4576, 3099},{ 5979, 3248},{ 7154, 3308},{ 8152, 3357},
+        { 9030, 3402},{ 9814, 3436},{10528, 3465},{11188, 3492},
+        {11797, 3515},{12371, 3537},{12907, 3556},{13406, 3571},
+        {13876, 3586},{14327, 3599},{14753, 3610},{15134, 3615},
+        {15499, 3621},{15849, 3624},{16142, 3623},{16375, 3620}
+      }
+    },
+    {
+      /*Cb  qi=53  INTRA*/
+      {
+        {   49,    4},{  243,  374},{  391,  734},{  536, 1071},
+        {  732, 1347},{  948, 1561},{ 1171, 1731},{ 1394, 1872},
+        { 1599, 2010},{ 1784, 2149},{ 1968, 2277},{ 2164, 2383},
+        { 2356, 2478},{ 2527, 2586},{ 2682, 2701},{ 2828, 2820},
+        { 2966, 2927},{ 3096, 3029},{ 3214, 3133},{ 3353, 3220},
+        { 3500, 3296},{ 3617, 3384},{ 3738, 3459},{ 3930, 3511}
+      },
+      /*Cb  qi=53  INTER*/
+      {
+        {  173,   15},{  195,  365},{  210,  678},{  262, 1013},
+        {  395, 1321},{  615, 1584},{  892, 1805},{ 1185, 2000},
+        { 1490, 2178},{ 1823, 2338},{ 2190, 2474},{ 2574, 2594},
+        { 2963, 2698},{ 3350, 2789},{ 3736, 2867},{ 4122, 2931},
+        { 4499, 2988},{ 4870, 3041},{ 5224, 3091},{ 5569, 3134},
+        { 5901, 3174},{ 6208, 3206},{ 6513, 3238},{ 6852, 3284}
+      }
+    },
+    {
+      /*Cr  qi=53  INTRA*/
+      {
+        {   62,    8},{  239,  394},{  380,  761},{  546, 1092},
+        {  747, 1351},{  959, 1553},{ 1180, 1715},{ 1393, 1856},
+        { 1604, 1989},{ 1807, 2117},{ 2008, 2242},{ 2193, 2360},
+        { 2355, 2470},{ 2521, 2576},{ 2687, 2673},{ 2834, 2746},
+        { 2969, 2809},{ 3104, 2899},{ 3220, 2994},{ 3337, 3072},
+        { 3483, 3170},{ 3600, 3280},{ 3710, 3363},{ 3840, 3399}
+      },
+      /*Cr  qi=53  INTER*/
+      {
+        {  166,   14},{  184,  369},{  197,  686},{  254, 1019},
+        {  389, 1323},{  590, 1589},{  832, 1831},{ 1109, 2046},
+        { 1434, 2221},{ 1801, 2361},{ 2183, 2486},{ 2558, 2609},
+        { 2932, 2730},{ 3312, 2833},{ 3695, 2914},{ 4084, 2969},
+        { 4459, 2993},{ 4818, 3001},{ 5156, 3000},{ 5458, 2998},
+        { 5745, 2987},{ 6002, 2978},{ 6251, 2973},{ 6482, 2956}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=54  INTRA*/
+      {
+        {  129,  101},{  972, 1233},{ 2105, 1899},{ 3305, 2128},
+        { 4341, 2205},{ 5272, 2311},{ 6155, 2441},{ 6970, 2579},
+        { 7707, 2717},{ 8381, 2848},{ 8997, 2967},{ 9524, 3052},
+        { 9999, 3126},{10468, 3217},{10958, 3313},{11431, 3412},
+        {11867, 3494},{12311, 3560},{12696, 3616},{13000, 3652},
+        {13314, 3686},{13646, 3733},{13983, 3770},{14389, 3817}
+      },
+      /*Y'  qi=54  INTER*/
+      {
+        {   95,   36},{  412, 1289},{ 1752, 2102},{ 3399, 2637},
+        { 5048, 2946},{ 6495, 3054},{ 7689, 3106},{ 8710, 3152},
+        { 9611, 3191},{10415, 3221},{11144, 3248},{11817, 3272},
+        {12439, 3294},{13021, 3312},{13565, 3329},{14078, 3343},
+        {14561, 3354},{15027, 3365},{15459, 3372},{15848, 3380},
+        {16226, 3386},{16574, 3387},{16878, 3383},{17133, 3368}
+      }
+    },
+    {
+      /*Cb  qi=54  INTRA*/
+      {
+        {   52,    4},{  251,  374},{  403,  732},{  557, 1061},
+        {  765, 1327},{  990, 1535},{ 1220, 1701},{ 1454, 1838},
+        { 1666, 1974},{ 1855, 2113},{ 2042, 2240},{ 2244, 2345},
+        { 2440, 2435},{ 2614, 2538},{ 2777, 2648},{ 2925, 2763},
+        { 3064, 2871},{ 3198, 2969},{ 3317, 3069},{ 3457, 3162},
+        { 3610, 3234},{ 3726, 3314},{ 3846, 3383},{ 4052, 3419}
+      },
+      /*Cb  qi=54  INTER*/
+      {
+        {  180,   18},{  195,  366},{  215,  677},{  287, 1006},
+        {  459, 1305},{  728, 1556},{ 1040, 1766},{ 1361, 1949},
+        { 1702, 2115},{ 2077, 2261},{ 2486, 2387},{ 2911, 2496},
+        { 3335, 2589},{ 3751, 2667},{ 4168, 2730},{ 4578, 2783},
+        { 4975, 2827},{ 5356, 2869},{ 5712, 2913},{ 6069, 2955},
+        { 6414, 2986},{ 6725, 3011},{ 7032, 3037},{ 7371, 3065}
+      }
+    },
+    {
+      /*Cr  qi=54  INTRA*/
+      {
+        {   68,    9},{  246,  394},{  390,  757},{  569, 1079},
+        {  779, 1329},{  999, 1525},{ 1230, 1682},{ 1454, 1820},
+        { 1673, 1950},{ 1883, 2076},{ 2088, 2199},{ 2277, 2316},
+        { 2442, 2422},{ 2610, 2524},{ 2778, 2617},{ 2930, 2685},
+        { 3066, 2746},{ 3201, 2833},{ 3318, 2925},{ 3437, 3004},
+        { 3587, 3094},{ 3708, 3197},{ 3823, 3291},{ 3950, 3342}
+      },
+      /*Cr  qi=54  INTER*/
+      {
+        {  167,   13},{  188,  370},{  203,  685},{  277, 1012},
+        {  451, 1307},{  696, 1562},{  972, 1793},{ 1283, 1995},
+        { 1653, 2154},{ 2068, 2281},{ 2490, 2398},{ 2906, 2513},
+        { 3320, 2620},{ 3730, 2709},{ 4141, 2772},{ 4548, 2806},
+        { 4928, 2823},{ 5279, 2827},{ 5617, 2820},{ 5930, 2810},
+        { 6217, 2798},{ 6475, 2794},{ 6722, 2797},{ 6968, 2809}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=55  INTRA*/
+      {
+        {  114,  103},{ 1030, 1222},{ 2214, 1873},{ 3445, 2091},
+        { 4497, 2158},{ 5448, 2250},{ 6354, 2365},{ 7196, 2488},
+        { 7964, 2612},{ 8662, 2729},{ 9301, 2834},{ 9845, 2904},
+        {10335, 2970},{10825, 3052},{11337, 3138},{11833, 3228},
+        {12288, 3301},{12746, 3357},{13143, 3407},{13462, 3437},
+        {13781, 3463},{14124, 3503},{14483, 3535},{14916, 3572}
+      },
+      /*Y'  qi=55  INTER*/
+      {
+        {   90,   37},{  420, 1287},{ 1844, 2073},{ 3585, 2565},
+        { 5291, 2829},{ 6746, 2915},{ 7941, 2958},{ 8970, 2996},
+        { 9881, 3029},{10698, 3055},{11440, 3077},{12126, 3097},
+        {12758, 3115},{13349, 3132},{13905, 3145},{14431, 3156},
+        {14928, 3167},{15414, 3179},{15863, 3188},{16269, 3194},
+        {16654, 3198},{17018, 3201},{17353, 3201},{17692, 3202}
+      }
+    },
+    {
+      /*Cb  qi=55  INTRA*/
+      {
+        {   51,    4},{  252,  374},{  411,  732},{  580, 1060},
+        {  808, 1322},{ 1056, 1523},{ 1308, 1681},{ 1561, 1811},
+        { 1789, 1941},{ 1990, 2074},{ 2189, 2195},{ 2405, 2293},
+        { 2615, 2379},{ 2804, 2477},{ 2977, 2580},{ 3132, 2689},
+        { 3285, 2788},{ 3431, 2883},{ 3570, 2974},{ 3725, 3048},
+        { 3882, 3116},{ 4014, 3194},{ 4152, 3259},{ 4367, 3289}
+      },
+      /*Cb  qi=55  INTER*/
+      {
+        {  197,   15},{  199,  365},{  220,  676},{  290, 1004},
+        {  472, 1300},{  755, 1547},{ 1087, 1751},{ 1431, 1927},
+        { 1794, 2084},{ 2188, 2223},{ 2613, 2341},{ 3054, 2442},
+        { 3494, 2528},{ 3925, 2601},{ 4358, 2658},{ 4778, 2697},
+        { 5178, 2730},{ 5563, 2770},{ 5939, 2803},{ 6298, 2826},
+        { 6633, 2855},{ 6967, 2885},{ 7278, 2904},{ 7597, 2943}
+      }
+    },
+    {
+      /*Cr  qi=55  INTRA*/
+      {
+        {   66,    8},{  248,  394},{  401,  758},{  596, 1078},
+        {  825, 1324},{ 1066, 1512},{ 1317, 1662},{ 1559, 1794},
+        { 1797, 1918},{ 2020, 2039},{ 2234, 2154},{ 2435, 2264},
+        { 2614, 2367},{ 2791, 2466},{ 2971, 2552},{ 3134, 2616},
+        { 3277, 2670},{ 3429, 2750},{ 3561, 2838},{ 3688, 2911},
+        { 3844, 2990},{ 3976, 3084},{ 4104, 3168},{ 4243, 3212}
+      },
+      /*Cr  qi=55  INTER*/
+      {
+        {  167,   13},{  189,  369},{  205,  684},{  281, 1010},
+        {  463, 1303},{  722, 1554},{ 1016, 1779},{ 1350, 1973},
+        { 1741, 2125},{ 2175, 2244},{ 2617, 2356},{ 3054, 2462},
+        { 3489, 2556},{ 3922, 2633},{ 4344, 2687},{ 4743, 2717},
+        { 5126, 2726},{ 5477, 2724},{ 5810, 2716},{ 6117, 2709},
+        { 6387, 2703},{ 6667, 2699},{ 6928, 2698},{ 7217, 2712}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=56  INTRA*/
+      {
+        {  100,  108},{ 1066, 1219},{ 2311, 1862},{ 3587, 2070},
+        { 4665, 2128},{ 5635, 2212},{ 6559, 2319},{ 7414, 2435},
+        { 8195, 2551},{ 8909, 2664},{ 9556, 2762},{10103, 2827},
+        {10602, 2888},{11106, 2966},{11626, 3048},{12127, 3132},
+        {12585, 3201},{13058, 3252},{13469, 3297},{13783, 3325},
+        {14108, 3349},{14456, 3386},{14813, 3414},{15235, 3445}
+      },
+      /*Y'  qi=56  INTER*/
+      {
+        {   30,   38},{  479, 1282},{ 1966, 2045},{ 3780, 2511},
+        { 5536, 2746},{ 7005, 2817},{ 8211, 2855},{ 9255, 2889},
+        {10178, 2918},{10999, 2940},{11743, 2958},{12424, 2975},
+        {13044, 2990},{13623, 3003},{14166, 3013},{14678, 3023},
+        {15160, 3032},{15623, 3042},{16066, 3049},{16473, 3052},
+        {16854, 3055},{17214, 3056},{17540, 3056},{17843, 3064}
+      }
+    },
+    {
+      /*Cb  qi=56  INTRA*/
+      {
+        {   54,    4},{  257,  374},{  417,  731},{  593, 1054},
+        {  829, 1310},{ 1085, 1506},{ 1345, 1660},{ 1604, 1785},
+        { 1837, 1911},{ 2044, 2041},{ 2247, 2160},{ 2463, 2255},
+        { 2678, 2336},{ 2873, 2428},{ 3053, 2526},{ 3213, 2633},
+        { 3368, 2729},{ 3514, 2821},{ 3652, 2907},{ 3813, 2979},
+        { 3981, 3040},{ 4120, 3110},{ 4257, 3175},{ 4472, 3208}
+      },
+      /*Cb  qi=56  INTER*/
+      {
+        {  188,   14},{  202,  365},{  225,  676},{  317, 1000},
+        {  532, 1290},{  832, 1531},{ 1163, 1732},{ 1510, 1903},
+        { 1888, 2055},{ 2306, 2187},{ 2758, 2298},{ 3229, 2391},
+        { 3691, 2473},{ 4136, 2539},{ 4575, 2587},{ 5002, 2622},
+        { 5406, 2648},{ 5786, 2678},{ 6155, 2712},{ 6518, 2740},
+        { 6856, 2759},{ 7167, 2779},{ 7488, 2802},{ 7779, 2811}
+      }
+    },
+    {
+      /*Cr  qi=56  INTRA*/
+      {
+        {   71,    9},{  253,  394},{  406,  756},{  608, 1071},
+        {  845, 1310},{ 1095, 1493},{ 1355, 1639},{ 1603, 1767},
+        { 1845, 1888},{ 2073, 2004},{ 2290, 2116},{ 2493, 2222},
+        { 2682, 2321},{ 2864, 2416},{ 3044, 2499},{ 3210, 2557},
+        { 3358, 2611},{ 3514, 2688},{ 3650, 2770},{ 3783, 2842},
+        { 3938, 2916},{ 4069, 3004},{ 4208, 3086},{ 4355, 3132}
+      },
+      /*Cr  qi=56  INTER*/
+      {
+        {  176,   13},{  195,  370},{  215,  683},{  307, 1006},
+        {  518, 1292},{  794, 1538},{ 1090, 1761},{ 1430, 1950},
+        { 1840, 2094},{ 2298, 2210},{ 2765, 2314},{ 3228, 2414},
+        { 3685, 2504},{ 4135, 2571},{ 4566, 2614},{ 4967, 2640},
+        { 5345, 2644},{ 5696, 2637},{ 6018, 2631},{ 6322, 2624},
+        { 6608, 2619},{ 6883, 2619},{ 7141, 2621},{ 7428, 2636}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=57  INTRA*/
+      {
+        {   86,  110},{ 1103, 1215},{ 2392, 1848},{ 3703, 2040},
+        { 4797, 2082},{ 5787, 2154},{ 6733, 2245},{ 7613, 2343},
+        { 8419, 2442},{ 9155, 2537},{ 9823, 2622},{10388, 2676},
+        {10904, 2726},{11431, 2793},{11973, 2863},{12495, 2934},
+        {12972, 2996},{13455, 3040},{13882, 3075},{14210, 3097},
+        {14555, 3117},{14926, 3146},{15297, 3166},{15747, 3188}
+      },
+      /*Y'  qi=57  INTER*/
+      {
+        {   17,   44},{  498, 1277},{ 2101, 2010},{ 4024, 2434},
+        { 5848, 2624},{ 7342, 2674},{ 8568, 2702},{ 9629, 2726},
+        {10566, 2747},{11398, 2763},{12148, 2777},{12834, 2790},
+        {13460, 2801},{14048, 2811},{14594, 2820},{15109, 2828},
+        {15596, 2836},{16066, 2841},{16509, 2845},{16929, 2849},
+        {17329, 2851},{17704, 2853},{18061, 2857},{18404, 2860}
+      }
+    },
+    {
+      /*Cb  qi=57  INTRA*/
+      {
+        {   54,    4},{  260,  375},{  427,  730},{  617, 1048},
+        {  870, 1298},{ 1140, 1489},{ 1414, 1637},{ 1693, 1753},
+        { 1943, 1871},{ 2164, 1997},{ 2384, 2110},{ 2618, 2197},
+        { 2844, 2271},{ 3051, 2355},{ 3246, 2446},{ 3425, 2547},
+        { 3595, 2636},{ 3751, 2719},{ 3903, 2796},{ 4081, 2855},
+        { 4263, 2906},{ 4413, 2967},{ 4572, 3027},{ 4789, 3061}
+      },
+      /*Cb  qi=57  INTER*/
+      {
+        {  191,   12},{  203,  367},{  226,  676},{  324,  997},
+        {  553, 1282},{  878, 1516},{ 1240, 1709},{ 1618, 1873},
+        { 2022, 2018},{ 2466, 2143},{ 2948, 2245},{ 3444, 2332},
+        { 3926, 2404},{ 4387, 2460},{ 4832, 2497},{ 5266, 2522},
+        { 5679, 2542},{ 6075, 2561},{ 6466, 2591},{ 6828, 2617},
+        { 7160, 2636},{ 7495, 2659},{ 7824, 2676},{ 8152, 2706}
+      }
+    },
+    {
+      /*Cr  qi=57  INTRA*/
+      {
+        {   71,    9},{  256,  395},{  417,  755},{  633, 1064},
+        {  885, 1297},{ 1149, 1474},{ 1429, 1612},{ 1697, 1735},
+        { 1956, 1849},{ 2201, 1959},{ 2430, 2065},{ 2646, 2165},
+        { 2846, 2258},{ 3041, 2346},{ 3238, 2418},{ 3418, 2468},
+        { 3573, 2518},{ 3737, 2586},{ 3892, 2660},{ 4041, 2725},
+        { 4207, 2793},{ 4363, 2873},{ 4516, 2944},{ 4667, 2986}
+      },
+      /*Cr  qi=57  INTER*/
+      {
+        {  172,   15},{  194,  369},{  217,  682},{  315, 1002},
+        {  540, 1283},{  840, 1523},{ 1167, 1737},{ 1542, 1917},
+        { 1988, 2053},{ 2472, 2163},{ 2962, 2263},{ 3447, 2355},
+        { 3924, 2430},{ 4390, 2485},{ 4825, 2521},{ 5232, 2536},
+        { 5612, 2537},{ 5962, 2529},{ 6287, 2521},{ 6592, 2513},
+        { 6878, 2510},{ 7161, 2509},{ 7436, 2507},{ 7687, 2514}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=58  INTRA*/
+      {
+        {   95,  113},{ 1165, 1212},{ 2480, 1835},{ 3807, 2017},
+        { 4906, 2052},{ 5908, 2115},{ 6876, 2199},{ 7781, 2289},
+        { 8612, 2381},{ 9368, 2469},{10051, 2545},{10629, 2593},
+        {11161, 2639},{11702, 2701},{12256, 2764},{12795, 2829},
+        {13289, 2885},{13789, 2924},{14229, 2957},{14568, 2979},
+        {14920, 2996},{15303, 3022},{15683, 3038},{16122, 3056}
+      },
+      /*Y'  qi=58  INTER*/
+      {
+        {  -18,   46},{  535, 1272},{ 2219, 1981},{ 4234, 2364},
+        { 6111, 2520},{ 7619, 2556},{ 8858, 2576},{ 9934, 2594},
+        {10882, 2610},{11720, 2622},{12477, 2633},{13167, 2643},
+        {13794, 2651},{14385, 2660},{14934, 2667},{15455, 2673},
+        {15959, 2680},{16434, 2684},{16882, 2688},{17302, 2692},
+        {17715, 2696},{18099, 2697},{18453, 2695},{18778, 2694}
+      }
+    },
+    {
+      /*Cb  qi=58  INTRA*/
+      {
+        {   54,    4},{  260,  375},{  428,  729},{  620, 1047},
+        {  874, 1295},{ 1147, 1484},{ 1425, 1630},{ 1708, 1743},
+        { 1963, 1858},{ 2191, 1980},{ 2417, 2088},{ 2658, 2170},
+        { 2892, 2240},{ 3105, 2319},{ 3307, 2403},{ 3493, 2499},
+        { 3668, 2586},{ 3832, 2666},{ 3993, 2738},{ 4180, 2790},
+        { 4370, 2836},{ 4524, 2894},{ 4683, 2947},{ 4899, 2976}
+      },
+      /*Cb  qi=58  INTER*/
+      {
+        {  177,   11},{  204,  363},{  231,  674},{  338,  994},
+        {  589, 1275},{  929, 1507},{ 1296, 1697},{ 1683, 1857},
+        { 2104, 1995},{ 2573, 2111},{ 3085, 2206},{ 3607, 2284},
+        { 4111, 2347},{ 4589, 2391},{ 5048, 2417},{ 5484, 2435},
+        { 5892, 2452},{ 6298, 2473},{ 6691, 2489},{ 7071, 2512},
+        { 7419, 2526},{ 7759, 2534},{ 8104, 2555},{ 8359, 2558}
+      }
+    },
+    {
+      /*Cr  qi=58  INTRA*/
+      {
+        {   70,    9},{  256,  395},{  418,  755},{  636, 1063},
+        {  889, 1295},{ 1156, 1469},{ 1441, 1605},{ 1713, 1724},
+        { 1978, 1834},{ 2231, 1939},{ 2467, 2039},{ 2688, 2135},
+        { 2893, 2225},{ 3096, 2310},{ 3301, 2379},{ 3479, 2426},
+        { 3638, 2470},{ 3814, 2531},{ 3974, 2601},{ 4122, 2666},
+        { 4288, 2730},{ 4456, 2802},{ 4616, 2871},{ 4771, 2908}
+      },
+      /*Cr  qi=58  INTER*/
+      {
+        {  177,   13},{  196,  368},{  219,  682},{  329,  999},
+        {  573, 1277},{  887, 1514},{ 1222, 1725},{ 1609, 1900},
+        { 2074, 2030},{ 2584, 2132},{ 3103, 2224},{ 3617, 2305},
+        { 4112, 2371},{ 4591, 2413},{ 5034, 2436},{ 5444, 2450},
+        { 5823, 2447},{ 6169, 2436},{ 6506, 2430},{ 6818, 2423},
+        { 7099, 2421},{ 7379, 2419},{ 7632, 2415},{ 7887, 2427}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=59  INTRA*/
+      {
+        {   77,  118},{ 1211, 1206},{ 2606, 1813},{ 3987, 1974},
+        { 5104, 1996},{ 6120, 2050},{ 7101, 2124},{ 8017, 2205},
+        { 8864, 2288},{ 9640, 2368},{10337, 2439},{10924, 2485},
+        {11464, 2528},{12016, 2583},{12584, 2641},{13134, 2702},
+        {13634, 2755},{14139, 2791},{14586, 2819},{14935, 2839},
+        {15293, 2855},{15680, 2880},{16067, 2895},{16497, 2916}
+      },
+      /*Y'  qi=59  INTER*/
+      {
+        {  -97,   52},{  615, 1265},{ 2448, 1926},{ 4597, 2262},
+        { 6529, 2387},{ 8051, 2415},{ 9307, 2430},{10397, 2444},
+        {11355, 2456},{12199, 2465},{12962, 2472},{13659, 2479},
+        {14294, 2486},{14890, 2493},{15450, 2499},{15975, 2503},
+        {16478, 2509},{16958, 2513},{17413, 2516},{17838, 2520},
+        {18260, 2521},{18653, 2521},{19009, 2521},{19314, 2518}
+      }
+    },
+    {
+      /*Cb  qi=59  INTRA*/
+      {
+        {   57,    4},{  268,  375},{  442,  727},{  644, 1037},
+        {  911, 1277},{ 1196, 1461},{ 1484, 1603},{ 1777, 1710},
+        { 2040, 1820},{ 2273, 1940},{ 2509, 2045},{ 2755, 2123},
+        { 2992, 2188},{ 3211, 2264},{ 3415, 2346},{ 3607, 2436},
+        { 3787, 2518},{ 3956, 2595},{ 4123, 2666},{ 4314, 2716},
+        { 4506, 2758},{ 4679, 2809},{ 4842, 2859},{ 5040, 2887}
+      },
+      /*Cb  qi=59  INTER*/
+      {
+        {  206,   13},{  214,  364},{  248,  673},{  387,  987},
+        {  670, 1261},{ 1029, 1483},{ 1425, 1663},{ 1854, 1810},
+        { 2319, 1936},{ 2832, 2041},{ 3382, 2125},{ 3931, 2197},
+        { 4457, 2250},{ 4945, 2284},{ 5403, 2306},{ 5846, 2319},
+        { 6267, 2332},{ 6673, 2345},{ 7073, 2364},{ 7440, 2380},
+        { 7801, 2397},{ 8163, 2409},{ 8496, 2415},{ 8729, 2411}
+      }
+    },
+    {
+      /*Cr  qi=59  INTRA*/
+      {
+        {   76,   10},{  261,  397},{  428,  753},{  657, 1053},
+        {  922, 1277},{ 1204, 1445},{ 1501, 1575},{ 1782, 1690},
+        { 2054, 1797},{ 2312, 1898},{ 2553, 1996},{ 2777, 2091},
+        { 2989, 2179},{ 3200, 2259},{ 3409, 2322},{ 3588, 2366},
+        { 3745, 2409},{ 3928, 2465},{ 4100, 2533},{ 4256, 2597},
+        { 4424, 2654},{ 4587, 2720},{ 4753, 2783},{ 4918, 2813}
+      },
+      /*Cr  qi=59  INTER*/
+      {
+        {  179,   12},{  204,  368},{  234,  680},{  374,  993},
+        {  650, 1263},{  983, 1492},{ 1344, 1694},{ 1776, 1856},
+        { 2289, 1973},{ 2846, 2064},{ 3401, 2146},{ 3943, 2218},
+        { 4462, 2272},{ 4941, 2305},{ 5382, 2322},{ 5794, 2329},
+        { 6170, 2328},{ 6513, 2316},{ 6831, 2309},{ 7127, 2307},
+        { 7424, 2308},{ 7726, 2310},{ 7981, 2305},{ 8214, 2307}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=60  INTRA*/
+      {
+        {   79,  120},{ 1292, 1198},{ 2759, 1784},{ 4168, 1930},
+        { 5290, 1944},{ 6327, 1987},{ 7340, 2048},{ 8296, 2114},
+        { 9182, 2180},{ 9993, 2245},{10718, 2303},{11331, 2338},
+        {11896, 2369},{12474, 2412},{13067, 2459},{13645, 2507},
+        {14171, 2553},{14697, 2583},{15169, 2602},{15533, 2614},
+        {15907, 2626},{16321, 2646},{16736, 2658},{17204, 2683}
+      },
+      /*Y'  qi=60  INTER*/
+      {
+        { -152,   60},{  668, 1259},{ 2600, 1890},{ 4845, 2186},
+        { 6826, 2281},{ 8373, 2295},{ 9654, 2299},{10764, 2303},
+        {11734, 2307},{12588, 2310},{13359, 2312},{14068, 2315},
+        {14714, 2318},{15316, 2321},{15883, 2323},{16421, 2327},
+        {16931, 2330},{17412, 2330},{17873, 2331},{18305, 2334},
+        {18723, 2335},{19134, 2335},{19493, 2334},{19833, 2338}
+      }
+    },
+    {
+      /*Cb  qi=60  INTRA*/
+      {
+        {   57,    4},{  274,  375},{  460,  727},{  688, 1035},
+        {  991, 1271},{ 1311, 1448},{ 1629, 1580},{ 1948, 1676},
+        { 2237, 1776},{ 2501, 1883},{ 2768, 1975},{ 3041, 2041},
+        { 3303, 2096},{ 3548, 2163},{ 3782, 2235},{ 4007, 2313},
+        { 4211, 2383},{ 4407, 2450},{ 4595, 2511},{ 4801, 2552},
+        { 5014, 2580},{ 5210, 2615},{ 5386, 2660},{ 5575, 2707}
+      },
+      /*Cb  qi=60  INTER*/
+      {
+        {  205,   11},{  219,  362},{  258,  671},{  422,  982},
+        {  728, 1252},{ 1099, 1470},{ 1504, 1645},{ 1950, 1786},
+        { 2442, 1904},{ 2985, 2001},{ 3565, 2079},{ 4138, 2143},
+        { 4670, 2188},{ 5160, 2212},{ 5624, 2225},{ 6074, 2233},
+        { 6503, 2238},{ 6918, 2248},{ 7343, 2261},{ 7740, 2269},
+        { 8098, 2280},{ 8455, 2291},{ 8792, 2296},{ 9110, 2311}
+      }
+    },
+    {
+      /*Cr  qi=60  INTRA*/
+      {
+        {   76,   10},{  268,  396},{  449,  751},{  710, 1047},
+        { 1009, 1268},{ 1321, 1431},{ 1646, 1553},{ 1956, 1658},
+        { 2258, 1752},{ 2549, 1842},{ 2822, 1930},{ 3076, 2013},
+        { 3314, 2086},{ 3549, 2154},{ 3780, 2203},{ 3977, 2240},
+        { 4152, 2280},{ 4347, 2328},{ 4531, 2388},{ 4702, 2438},
+        { 4886, 2485},{ 5069, 2540},{ 5245, 2595},{ 5431, 2626}
+      },
+      /*Cr  qi=60  INTER*/
+      {
+        {  190,   10},{  216,  366},{  247,  678},{  406,  988},
+        {  706, 1254},{ 1052, 1478},{ 1426, 1674},{ 1880, 1829},
+        { 2423, 1938},{ 3009, 2023},{ 3594, 2096},{ 4157, 2158},
+        { 4685, 2204},{ 5171, 2229},{ 5615, 2239},{ 6019, 2240},
+        { 6395, 2238},{ 6737, 2232},{ 7045, 2224},{ 7359, 2218},
+        { 7648, 2217},{ 7929, 2212},{ 8197, 2210},{ 8324, 2206}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=61  INTRA*/
+      {
+        {  151,  132},{ 1420, 1188},{ 2960, 1744},{ 4401, 1874},
+        { 5526, 1881},{ 6583, 1914},{ 7630, 1960},{ 8628, 2009},
+        { 9560, 2057},{10413, 2103},{11184, 2144},{11827, 2167},
+        {12420, 2187},{13035, 2218},{13663, 2251},{14277, 2288},
+        {14839, 2325},{15391, 2346},{15880, 2356},{16265, 2364},
+        {16665, 2372},{17107, 2386},{17537, 2393},{18014, 2419}
+      },
+      /*Y'  qi=61  INTER*/
+      {
+        { -211,   68},{  714, 1252},{ 2759, 1850},{ 5090, 2104},
+        { 7114, 2170},{ 8687, 2171},{ 9997, 2164},{11137, 2158},
+        {12139, 2154},{13026, 2149},{13826, 2146},{14560, 2144},
+        {15240, 2142},{15879, 2141},{16473, 2140},{17037, 2140},
+        {17568, 2139},{18077, 2137},{18561, 2136},{19019, 2136},
+        {19467, 2137},{19886, 2136},{20271, 2135},{20658, 2137}
+      }
+    },
+    {
+      /*Cb  qi=61  INTRA*/
+      {
+        {   52,    4},{  273,  374},{  469,  726},{  718, 1030},
+        { 1036, 1261},{ 1370, 1431},{ 1709, 1553},{ 2050, 1638},
+        { 2365, 1726},{ 2661, 1820},{ 2953, 1899},{ 3246, 1954},
+        { 3527, 1998},{ 3796, 2053},{ 4049, 2115},{ 4289, 2182},
+        { 4515, 2243},{ 4746, 2297},{ 4956, 2345},{ 5166, 2377},
+        { 5392, 2396},{ 5602, 2426},{ 5797, 2465},{ 6007, 2505}
+      },
+      /*Cb  qi=61  INTER*/
+      {
+        {  195,   12},{  218,  359},{  258,  669},{  431,  979},
+        {  756, 1245},{ 1153, 1457},{ 1585, 1626},{ 2054, 1760},
+        { 2569, 1870},{ 3138, 1959},{ 3738, 2031},{ 4325, 2086},
+        { 4865, 2122},{ 5368, 2139},{ 5848, 2147},{ 6307, 2150},
+        { 6752, 2151},{ 7182, 2157},{ 7616, 2166},{ 8027, 2168},
+        { 8408, 2174},{ 8789, 2185},{ 9148, 2186},{ 9552, 2191}
+      }
+    },
+    {
+      /*Cr  qi=61  INTRA*/
+      {
+        {   71,    9},{  269,  395},{  463,  749},{  743, 1041},
+        { 1054, 1256},{ 1380, 1412},{ 1726, 1525},{ 2058, 1619},
+        { 2385, 1704},{ 2698, 1783},{ 2999, 1858},{ 3282, 1927},
+        { 3538, 1990},{ 3789, 2046},{ 4033, 2083},{ 4247, 2112},
+        { 4437, 2144},{ 4649, 2186},{ 4857, 2233},{ 5038, 2275},
+        { 5231, 2319},{ 5444, 2360},{ 5643, 2396},{ 5856, 2402}
+      },
+      /*Cr  qi=61  INTER*/
+      {
+        {  182,   11},{  213,  364},{  247,  677},{  415,  985},
+        {  735, 1247},{ 1107, 1466},{ 1508, 1655},{ 1991, 1801},
+        { 2558, 1903},{ 3165, 1981},{ 3770, 2047},{ 4348, 2099},
+        { 4885, 2131},{ 5382, 2148},{ 5832, 2159},{ 6244, 2163},
+        { 6618, 2156},{ 6956, 2149},{ 7279, 2145},{ 7598, 2142},
+        { 7900, 2139},{ 8193, 2136},{ 8471, 2136},{ 8674, 2148}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=62  INTRA*/
+      {
+        {  212,  140},{ 1522, 1182},{ 3130, 1716},{ 4593, 1835},
+        { 5717, 1837},{ 6787, 1865},{ 7859, 1904},{ 8888, 1946},
+        { 9847, 1987},{10727, 2026},{11526, 2060},{12190, 2079},
+        {12807, 2094},{13442, 2118},{14095, 2146},{14735, 2176},
+        {15318, 2208},{15889, 2228},{16397, 2238},{16802, 2242},
+        {17221, 2248},{17683, 2261},{18137, 2267},{18658, 2281}
+      },
+      /*Y'  qi=62  INTER*/
+      {
+        { -316,   78},{  799, 1240},{ 2994, 1795},{ 5432, 2010},
+        { 7508, 2055},{ 9112, 2049},{10456, 2037},{11634, 2027},
+        {12673, 2019},{13595, 2013},{14436, 2007},{15205, 2003},
+        {15915, 2000},{16587, 1999},{17214, 1996},{17813, 1995},
+        {18382, 1994},{18929, 1992},{19448, 1990},{19927, 1989},
+        {20389, 1988},{20829, 1987},{21237, 1987},{21680, 1987}
+      }
+    },
+    {
+      /*Cb  qi=62  INTRA*/
+      {
+        {   49,    4},{  277,  374},{  486,  724},{  756, 1024},
+        { 1095, 1249},{ 1451, 1413},{ 1813, 1529},{ 2175, 1607},
+        { 2508, 1688},{ 2826, 1774},{ 3137, 1846},{ 3445, 1896},
+        { 3737, 1936},{ 4017, 1986},{ 4290, 2041},{ 4552, 2099},
+        { 4789, 2154},{ 5024, 2202},{ 5243, 2246},{ 5471, 2275},
+        { 5706, 2292},{ 5914, 2317},{ 6119, 2348},{ 6348, 2368}
+      },
+      /*Cb  qi=62  INTER*/
+      {
+        {  192,    9},{  221,  357},{  266,  667},{  454,  974},
+        {  819, 1231},{ 1256, 1434},{ 1720, 1594},{ 2219, 1720},
+        { 2763, 1820},{ 3362, 1901},{ 3994, 1963},{ 4605, 2010},
+        { 5163, 2039},{ 5673, 2054},{ 6161, 2059},{ 6635, 2056},
+        { 7087, 2055},{ 7538, 2057},{ 7986, 2059},{ 8400, 2061},
+        { 8816, 2062},{ 9215, 2070},{ 9567, 2075},{ 9845, 2067}
+      }
+    },
+    {
+      /*Cr  qi=62  INTRA*/
+      {
+        {   72,   10},{  274,  397},{  482,  747},{  784, 1033},
+        { 1113, 1244},{ 1462, 1394},{ 1831, 1499},{ 2184, 1587},
+        { 2527, 1665},{ 2858, 1738},{ 3175, 1808},{ 3472, 1871},
+        { 3747, 1927},{ 4020, 1977},{ 4271, 2010},{ 4490, 2036},
+        { 4689, 2063},{ 4905, 2099},{ 5122, 2141},{ 5315, 2182},
+        { 5514, 2222},{ 5732, 2258},{ 5948, 2294},{ 6134, 2309}
+      },
+      /*Cr  qi=62  INTER*/
+      {
+        {  191,   12},{  219,  363},{  254,  675},{  441,  979},
+        {  796, 1233},{ 1207, 1444},{ 1646, 1623},{ 2161, 1758},
+        { 2759, 1852},{ 3402, 1920},{ 4039, 1976},{ 4641, 2017},
+        { 5193, 2043},{ 5697, 2059},{ 6155, 2066},{ 6571, 2067},
+        { 6944, 2065},{ 7280, 2061},{ 7617, 2056},{ 7921, 2051},
+        { 8215, 2050},{ 8528, 2050},{ 8834, 2045},{ 9092, 2042}
+      }
+    }
+  },
+  {
+    {
+      /*Y'  qi=63  INTRA*/
+      {
+        {  189,  144},{ 1625, 1169},{ 3329, 1679},{ 4820, 1783},
+        { 5949, 1778},{ 7038, 1796},{ 8150, 1821},{ 9231, 1847},
+        {10239, 1873},{11165, 1896},{12008, 1915},{12714, 1922},
+        {13364, 1928},{14032, 1942},{14719, 1959},{15400, 1979},
+        {16023, 1998},{16624, 2011},{17158, 2017},{17589, 2018},
+        {18034, 2018},{18533, 2025},{19024, 2028},{19594, 2037}
+      },
+      /*Y'  qi=63  INTER*/
+      {
+        { -370,   83},{  845, 1235},{ 3132, 1766},{ 5639, 1953},
+        { 7759, 1979},{ 9395, 1961},{10771, 1939},{11982, 1920},
+        {13057, 1905},{14013, 1892},{14885, 1881},{15690, 1873},
+        {16431, 1865},{17127, 1858},{17777, 1853},{18396, 1847},
+        {18986, 1843},{19560, 1839},{20099, 1834},{20609, 1831},
+        {21083, 1830},{21530, 1828},{21962, 1828},{22387, 1829}
+      }
+    },
+    {
+      /*Cb  qi=63  INTRA*/
+      {
+        {   50,    4},{  279,  374},{  496,  723},{  795, 1017},
+        { 1170, 1235},{ 1557, 1392},{ 1947, 1497},{ 2340, 1564},
+        { 2714, 1630},{ 3071, 1700},{ 3421, 1757},{ 3757, 1795},
+        { 4077, 1822},{ 4389, 1859},{ 4691, 1901},{ 4987, 1944},
+        { 5261, 1984},{ 5523, 2020},{ 5767, 2058},{ 6010, 2077},
+        { 6255, 2086},{ 6494, 2102},{ 6730, 2121},{ 6950, 2148}
+      },
+      /*Cb  qi=63  INTER*/
+      {
+        {  193,   11},{  220,  356},{  263,  667},{  459,  972},
+        {  846, 1226},{ 1313, 1425},{ 1801, 1580},{ 2314, 1700},
+        { 2871, 1796},{ 3485, 1872},{ 4132, 1928},{ 4757, 1969},
+        { 5322, 1993},{ 5843, 2004},{ 6342, 2005},{ 6830, 2000},
+        { 7302, 1994},{ 7775, 1991},{ 8227, 1989},{ 8660, 1985},
+        { 9087, 1983},{ 9484, 1984},{ 9870, 1980},{10254, 1985}
+      }
+    },
+    {
+      /*Cr  qi=63  INTRA*/
+      {
+        {   70,    9},{  277,  395},{  498,  743},{  826, 1023},
+        { 1189, 1227},{ 1569, 1371},{ 1968, 1468},{ 2351, 1545},
+        { 2726, 1608},{ 3094, 1666},{ 3449, 1719},{ 3783, 1767},
+        { 4093, 1812},{ 4389, 1849},{ 4658, 1872},{ 4895, 1890},
+        { 5120, 1910},{ 5354, 1937},{ 5585, 1972},{ 5805, 2002},
+        { 6034, 2035},{ 6276, 2064},{ 6515, 2084},{ 6707, 2081}
+      },
+      /*Cr  qi=63  INTER*/
+      {
+        {  187,   12},{  215,  363},{  252,  675},{  448,  977},
+        {  828, 1227},{ 1272, 1432},{ 1734, 1606},{ 2265, 1736},
+        { 2877, 1825},{ 3533, 1890},{ 4183, 1940},{ 4798, 1975},
+        { 5362, 1996},{ 5876, 2007},{ 6343, 2013},{ 6757, 2013},
+        { 7133, 2009},{ 7483, 2005},{ 7809, 2000},{ 8132, 1997},
+        { 8440, 1994},{ 8752, 1990},{ 9050, 1987},{ 9270, 1989}
+      }
+    }
+  }
+};
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/quant_lookup.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/quant_lookup.h
new file mode 100644
index 0000000..02828e0
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/quant_lookup.h
@@ -0,0 +1,54 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: quant_lookup.h 14233 2007-11-26 17:06:55Z xiphmont $
+
+ ********************************************************************/
+
+#include "codec_internal.h"
+
+#define MIN16 ((1<<16)-1)
+#define SHIFT16 (1<<16)
+
+#define MIN_LEGAL_QUANT_ENTRY 8
+#define MIN_DEQUANT_VAL       2
+#define IDCT_SCALE_FACTOR     2 /* Shift left bits to improve IDCT precision */
+#define OLD_SCHEME            1
+
+
+/******************************
+ * lookup table for DCT coefficient zig-zag ordering
+ * ****************************/
+
+static const ogg_uint32_t zigzag_index[64] = {
+   0,  1,  5,  6, 14, 15, 27, 28,
+   2,  4,  7, 13, 16, 26, 29, 42,
+   3,  8, 12, 17, 25, 30, 41, 43,
+   9, 11, 18, 24, 31, 40, 44, 53,
+  10, 19, 23, 32, 39, 45, 52, 54,
+  20, 22, 33, 38, 46, 51, 55, 60,
+  21, 34, 37, 47, 50, 56, 59, 61,
+  35, 36, 48, 49, 57, 58, 62, 63
+};
+
+static const ogg_uint32_t dezigzag_index[64] = {
+  0,  1,  8,  16,  9,  2,  3, 10,
+  17, 24, 32, 25, 18, 11,  4,  5,
+  12, 19, 26, 33, 40, 48, 41, 34,
+  27, 20, 13,  6,  7, 14, 21, 28,
+  35, 42, 49, 56, 57, 50, 43, 36,
+  29, 22, 15, 23, 30, 37, 44, 51,
+  58, 59, 52, 45, 38, 31, 39, 46,
+  53, 60, 61, 54, 47, 55, 62, 63
+};
+
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/toplevel_lookup.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/toplevel_lookup.h
new file mode 100644
index 0000000..59126bc
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/toplevel_lookup.h
@@ -0,0 +1,134 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: toplevel_lookup.h 14518 2008-02-15 22:45:39Z xiphmont $
+
+ ********************************************************************/
+
+#include "codec_internal.h"
+
+/*The default quantization parameters used by VP3.1.*/
+static const int OC_VP31_RANGE_SIZES[1]={63};
+static const th_quant_base OC_VP31_BASES_INTRA_Y[2]={
+  {
+     16, 11, 10, 16, 24,  40, 51, 61,
+     12, 12, 14, 19, 26,  58, 60, 55,
+     14, 13, 16, 24, 40,  57, 69, 56,
+     14, 17, 22, 29, 51,  87, 80, 62,
+     18, 22, 37, 58, 68, 109,103, 77,
+     24, 35, 55, 64, 81, 104,113, 92,
+     49, 64, 78, 87,103, 121,120,101,
+     72, 92, 95, 98,112, 100,103, 99
+  },
+  {
+     16, 11, 10, 16, 24,  40, 51, 61,
+     12, 12, 14, 19, 26,  58, 60, 55,
+     14, 13, 16, 24, 40,  57, 69, 56,
+     14, 17, 22, 29, 51,  87, 80, 62,
+     18, 22, 37, 58, 68, 109,103, 77,
+     24, 35, 55, 64, 81, 104,113, 92,
+     49, 64, 78, 87,103, 121,120,101,
+     72, 92, 95, 98,112, 100,103, 99
+  }
+};
+static const th_quant_base OC_VP31_BASES_INTRA_C[2]={
+  {
+     17, 18, 24, 47, 99, 99, 99, 99,
+     18, 21, 26, 66, 99, 99, 99, 99,
+     24, 26, 56, 99, 99, 99, 99, 99,
+     47, 66, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99
+  },
+  {
+     17, 18, 24, 47, 99, 99, 99, 99,
+     18, 21, 26, 66, 99, 99, 99, 99,
+     24, 26, 56, 99, 99, 99, 99, 99,
+     47, 66, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99,
+     99, 99, 99, 99, 99, 99, 99, 99
+  }
+};
+static const th_quant_base OC_VP31_BASES_INTER[2]={
+  {
+     16, 16, 16, 20, 24, 28, 32, 40,
+     16, 16, 20, 24, 28, 32, 40, 48,
+     16, 20, 24, 28, 32, 40, 48, 64,
+     20, 24, 28, 32, 40, 48, 64, 64,
+     24, 28, 32, 40, 48, 64, 64, 64,
+     28, 32, 40, 48, 64, 64, 64, 96,
+     32, 40, 48, 64, 64, 64, 96,128,
+     40, 48, 64, 64, 64, 96,128,128
+  },
+  {
+     16, 16, 16, 20, 24, 28, 32, 40,
+     16, 16, 20, 24, 28, 32, 40, 48,
+     16, 20, 24, 28, 32, 40, 48, 64,
+     20, 24, 28, 32, 40, 48, 64, 64,
+     24, 28, 32, 40, 48, 64, 64, 64,
+     28, 32, 40, 48, 64, 64, 64, 96,
+     32, 40, 48, 64, 64, 64, 96,128,
+     40, 48, 64, 64, 64, 96,128,128
+  }
+};
+
+const th_quant_info TH_VP31_QUANT_INFO={
+  {
+    220,200,190,180,170,170,160,160,
+    150,150,140,140,130,130,120,120,
+    110,110,100,100, 90, 90, 90, 80,
+     80, 80, 70, 70, 70, 60, 60, 60,
+     60, 50, 50, 50, 50, 40, 40, 40,
+     40, 40, 30, 30, 30, 30, 30, 30,
+     30, 20, 20, 20, 20, 20, 20, 20,
+     20, 10, 10, 10, 10, 10, 10, 10
+  },
+  {
+    500,450,400,370,340,310,285,265,
+    245,225,210,195,185,180,170,160,
+    150,145,135,130,125,115,110,107,
+    100, 96, 93, 89, 85, 82, 75, 74,
+     70, 68, 64, 60, 57, 56, 52, 50,
+     49, 45, 44, 43, 40, 38, 37, 35,
+     33, 32, 30, 29, 28, 25, 24, 22,
+     21, 19, 18, 17, 15, 13, 12, 10
+  },
+  {
+    30,25,20,20,15,15,14,14,
+    13,13,12,12,11,11,10,10,
+     9, 9, 8, 8, 7, 7, 7, 7,
+     6, 6, 6, 6, 5, 5, 5, 5,
+     4, 4, 4, 4, 3, 3, 3, 3,
+     2, 2, 2, 2, 2, 2, 2, 2,
+     0, 0, 0, 0, 0, 0, 0, 0,
+     0, 0, 0, 0, 0, 0, 0, 0
+  },
+  {
+    {
+      {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTRA_Y},
+      {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTRA_C},
+      {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTRA_C}
+    },
+    {
+      {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTER},
+      {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTER},
+      {1,OC_VP31_RANGE_SIZES,OC_VP31_BASES_INTER}
+    }
+  }
+};
+
+
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/dsp_sse2.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/dsp_sse2.c
new file mode 100644
index 0000000..49dd92c
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/dsp_sse2.c
@@ -0,0 +1,92 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2008                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id$
+
+ ********************************************************************/
+#include <stddef.h>
+#include "x86enc.h"
+
+#if defined(OC_X86_ASM)
+
+static int find_nonzero__sse2(ogg_int16_t *q, int in){
+  int ret,tmp,tmp2;
+
+  __asm__ (
+	   ".p2align 4 \n"
+	   "movd      %[in],%%xmm0\n"
+	   "punpcklwd %%xmm0,%%xmm0\n"
+	   "punpcklwd %%xmm0,%%xmm0\n"
+	   "punpcklwd %%xmm0,%%xmm0\n"
+	   
+	   "movdqu    64(%[quant]),%%xmm1\n"
+	   "pcmpgtw   %%xmm0,%%xmm1\n"
+	   "movdqu    80(%[quant]),%%xmm2\n"
+	   "pcmpgtw   %%xmm0,%%xmm2\n"
+	   "packsswb  %%xmm2,%%xmm1\n"
+
+	   "movdqu    96(%[quant]),%%xmm2\n"
+	   "pcmpgtw   %%xmm0,%%xmm2\n"
+	   "movdqu    112(%[quant]),%%xmm3\n"
+	   "pcmpgtw   %%xmm0,%%xmm3\n"
+	   "packsswb  %%xmm3,%%xmm2\n"
+
+	   "pmovmskb  %%xmm1,%[ret]\n"
+	   "pmovmskb  %%xmm2,%[tmp]\n"
+	   "shl       $16,%[tmp]\n"
+	   "or        %[tmp],%[ret]\n"
+	   "bsr       %[ret],%[ret]\n"
+	   "jz        %=1f\n"
+	   "add       $33,%[ret]\n"
+	   "jmp       %=3f\n"
+
+	   "%=1:\n"
+	   "movdqu    (%[quant]),%%xmm1\n"
+	   "pcmpgtw   %%xmm0,%%xmm1\n"
+	   "movdqu    16(%[quant]),%%xmm2\n"
+	   "pcmpgtw   %%xmm0,%%xmm2\n"
+	   "packsswb  %%xmm2,%%xmm1\n"
+
+	   "movdqu    32(%[quant]),%%xmm2\n"
+	   "pcmpgtw   %%xmm0,%%xmm2\n"
+	   "movdqu    48(%[quant]),%%xmm3\n"
+	   "pcmpgtw   %%xmm0,%%xmm3\n"
+	   "packsswb  %%xmm3,%%xmm2\n"
+
+	   "pmovmskb  %%xmm1,%[ret]\n"
+	   "pmovmskb  %%xmm2,%[tmp]\n"
+	   "shl       $16,%[tmp]\n"
+	   "or        %[tmp],%[ret]\n"
+	   "bsr       %[ret],%[ret]\n"
+	   "jz        %=2f\n"
+	   "inc       %[ret]\n"
+	   "jmp       %=3f\n"
+
+	   "%=2:\n"
+	   "xor       %[ret],%[ret]\n"
+
+	   "%=3:\n"
+
+	   :[ret]"=&r"(ret),[tmp]"=&r"(tmp),[tmp2]"=&r"(tmp2)
+	   :[quant]"r"(q),[in]"r"(in)
+	   );
+
+  return ret;
+}
+
+void dsp_sse2_init(DspFunctions *funcs)
+{
+  funcs->find_nonzero = find_nonzero__sse2;
+}
+
+#endif /* USE_ASM */
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/mmxenc.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/mmxenc.c
new file mode 100644
index 0000000..7db7de8
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/mmxenc.c
@@ -0,0 +1,64 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2008                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: dct_decode_mmx.c 15078 2008-06-27 22:07:19Z xiphmont $
+
+ ********************************************************************/
+#include <string.h>
+#include "x86enc.h"
+#include "../../dec/x86/mmxloop.h"
+
+#if defined(OC_X86_ASM)
+
+/*Apply the loop filter.*/
+void oc_enc_loop_filter_mmx(CP_INSTANCE *cpi,int _flimit){
+  unsigned char OC_ALIGN8  ll[8];
+  unsigned char           *cp;
+  ogg_uint32_t            *bp;
+  int                      pli;
+  cp=cpi->frag_coded;
+  bp=cpi->frag_buffer_index;
+  if(_flimit==0)return;
+  memset(ll,_flimit,sizeof(ll));
+  for(pli=0;pli<3;pli++){
+    ogg_uint32_t *bp_begin;
+    ogg_uint32_t *bp_end;
+    int           stride;
+    int           h;
+    bp_begin=bp;
+    bp_end=bp+cpi->frag_n[pli];
+    stride=cpi->stride[pli];
+    h=cpi->frag_h[pli];
+    while(bp<bp_end){
+      ogg_uint32_t *bp_left;
+      ogg_uint32_t *bp_right;
+      bp_left=bp;
+      bp_right=bp+h;
+      for(;bp<bp_right;bp++,cp++)if(*cp){
+        if(bp>bp_left)OC_LOOP_FILTER_H_MMX(cpi->lastrecon+bp[0],stride,ll);
+        if(bp_left>bp_begin){
+          OC_LOOP_FILTER_V_MMX(cpi->lastrecon+bp[0],stride,ll);
+        }
+        if(bp+1<bp_right&&!cp[1]){
+          OC_LOOP_FILTER_H_MMX(cpi->lastrecon+bp[0]+8,stride,ll);
+        }
+        if(bp+h<bp_end&&!cp[h]){
+          OC_LOOP_FILTER_V_MMX(cpi->lastrecon+bp[h],stride,ll);
+        }
+      }
+    }
+  }
+  __asm__ __volatile__("emms\n\t");
+}
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/mmxencfrag.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/mmxencfrag.c
new file mode 100644
index 0000000..a1b3914
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/mmxencfrag.c
@@ -0,0 +1,901 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: dsp_mmx.c 14579 2008-03-12 06:42:40Z xiphmont $
+
+ ********************************************************************/
+#include <stddef.h>
+#include "x86enc.h"
+
+#if defined(OC_X86_ASM)
+
+unsigned oc_enc_frag_sad_mmxext(const unsigned char *_src,
+ const unsigned char *_ref,int _ystride){
+  ptrdiff_t ystride3;
+  ptrdiff_t ret;
+  __asm__ __volatile__(
+    /*Load the first 4 rows of each block.*/
+    "movq (%[src]),%%mm0\n\t"
+    "movq (%[ref]),%%mm1\n\t"
+    "movq (%[src],%[ystride]),%%mm2\n\t"
+    "movq (%[ref],%[ystride]),%%mm3\n\t"
+    "lea (%[ystride],%[ystride],2),%[ystride3]\n\t"
+    "movq (%[src],%[ystride],2),%%mm4\n\t"
+    "movq (%[ref],%[ystride],2),%%mm5\n\t"
+    "movq (%[src],%[ystride3]),%%mm6\n\t"
+    "movq (%[ref],%[ystride3]),%%mm7\n\t"
+    /*Compute their SADs and add them in %%mm0*/
+    "psadbw %%mm1,%%mm0\n\t"
+    "psadbw %%mm3,%%mm2\n\t"
+    "lea (%[src],%[ystride],4),%[src]\n\t"
+    "paddw %%mm2,%%mm0\n\t"
+    "lea (%[ref],%[ystride],4),%[ref]\n\t"
+    /*Load the next 3 rows as registers become available.*/
+    "movq (%[src]),%%mm2\n\t"
+    "movq (%[ref]),%%mm3\n\t"
+    "psadbw %%mm5,%%mm4\n\t"
+    "psadbw %%mm7,%%mm6\n\t"
+    "paddw %%mm4,%%mm0\n\t"
+    "movq (%[ref],%[ystride]),%%mm5\n\t"
+    "movq (%[src],%[ystride]),%%mm4\n\t"
+    "paddw %%mm6,%%mm0\n\t"
+    "movq (%[ref],%[ystride],2),%%mm7\n\t"
+    "movq (%[src],%[ystride],2),%%mm6\n\t"
+    /*Start adding their SADs to %%mm0*/
+    "psadbw %%mm3,%%mm2\n\t"
+    "psadbw %%mm5,%%mm4\n\t"
+    "paddw %%mm2,%%mm0\n\t"
+    "psadbw %%mm7,%%mm6\n\t"
+    /*Load last row as registers become available.*/
+    "movq (%[src],%[ystride3]),%%mm2\n\t"
+    "movq (%[ref],%[ystride3]),%%mm3\n\t"
+    /*And finish adding up their SADs.*/
+    "paddw %%mm4,%%mm0\n\t"
+    "psadbw %%mm3,%%mm2\n\t"
+    "paddw %%mm6,%%mm0\n\t"
+    "paddw %%mm2,%%mm0\n\t"
+    "movd %%mm0,%[ret]\n\t"
+    :[ret]"=a"(ret),[src]"+%r"(_src),[ref]"+r"(_ref),[ystride3]"=&r"(ystride3)
+    :[ystride]"r"((ptrdiff_t)_ystride)
+  );
+  return (unsigned)ret;
+}
+
+unsigned oc_enc_frag_sad_thresh_mmxext(const unsigned char *_src,
+ const unsigned char *_ref,int _ystride,unsigned _thresh){
+  /*Early termination is for suckers.*/
+  return oc_enc_frag_sad_mmxext(_src,_ref,_ystride);
+}
+
+/*Assumes the first two rows of %[ref1] and %[ref2] are in %%mm0...%%mm3, the
+   first two rows of %[src] are in %%mm4,%%mm5, and {1}x8 is in %%mm7.
+  We pre-load the next two rows of data as registers become available.*/
+#define OC_SAD2_LOOP \
+ "#OC_SAD2_LOOP\n\t" \
+ /*We want to compute (%%mm0+%%mm1>>1) on unsigned bytes without overflow, but \
+    pavgb computes (%%mm0+%%mm1+1>>1). \
+   The latter is exactly 1 too large when the low bit of two corresponding \
+    bytes is only set in one of them. \
+   Therefore we pxor the operands, pand to mask out the low bits, and psubb to \
+    correct the output of pavgb.*/ \
+ "movq %%mm0,%%mm6\n\t" \
+ "lea (%[ref1],%[ystride],2),%[ref1]\n\t" \
+ "pxor %%mm1,%%mm0\n\t" \
+ "pavgb %%mm1,%%mm6\n\t" \
+ "lea (%[ref2],%[ystride],2),%[ref2]\n\t" \
+ "movq %%mm2,%%mm1\n\t" \
+ "pand %%mm7,%%mm0\n\t" \
+ "pavgb %%mm3,%%mm2\n\t" \
+ "pxor %%mm3,%%mm1\n\t" \
+ "movq (%[ref2],%[ystride]),%%mm3\n\t" \
+ "psubb %%mm0,%%mm6\n\t" \
+ "movq (%[ref1]),%%mm0\n\t" \
+ "pand %%mm7,%%mm1\n\t" \
+ "psadbw %%mm6,%%mm4\n\t" \
+ "movd %[ret],%%mm6\n\t" \
+ "psubb %%mm1,%%mm2\n\t" \
+ "movq (%[ref2]),%%mm1\n\t" \
+ "lea (%[src],%[ystride],2),%[src]\n\t" \
+ "psadbw %%mm2,%%mm5\n\t" \
+ "movq (%[ref1],%[ystride]),%%mm2\n\t" \
+ "paddw %%mm4,%%mm5\n\t" \
+ "movq (%[src]),%%mm4\n\t" \
+ "paddw %%mm5,%%mm6\n\t" \
+ "movq (%[src],%[ystride]),%%mm5\n\t" \
+ "movd %%mm6,%[ret]\n\t" \
+
+/*Same as above, but does not pre-load the next two rows.*/
+#define OC_SAD2_TAIL \
+ "#OC_SAD2_TAIL\n\t" \
+ "movq %%mm0,%%mm6\n\t" \
+ "pavgb %%mm1,%%mm0\n\t" \
+ "pxor %%mm1,%%mm6\n\t" \
+ "movq %%mm2,%%mm1\n\t" \
+ "pand %%mm7,%%mm6\n\t" \
+ "pavgb %%mm3,%%mm2\n\t" \
+ "pxor %%mm3,%%mm1\n\t" \
+ "psubb %%mm6,%%mm0\n\t" \
+ "pand %%mm7,%%mm1\n\t" \
+ "psadbw %%mm0,%%mm4\n\t" \
+ "psubb %%mm1,%%mm2\n\t" \
+ "movd %[ret],%%mm6\n\t" \
+ "psadbw %%mm2,%%mm5\n\t" \
+ "paddw %%mm4,%%mm5\n\t" \
+ "paddw %%mm5,%%mm6\n\t" \
+ "movd %%mm6,%[ret]\n\t" \
+
+unsigned oc_enc_frag_sad2_thresh_mmxext(const unsigned char *_src,
+ const unsigned char *_ref1,const unsigned char *_ref2,int _ystride,
+ unsigned _thresh){
+  ptrdiff_t ret;
+  __asm__ __volatile__(
+    "movq (%[ref1]),%%mm0\n\t"
+    "movq (%[ref2]),%%mm1\n\t"
+    "movq (%[ref1],%[ystride]),%%mm2\n\t"
+    "movq (%[ref2],%[ystride]),%%mm3\n\t"
+    "xor %[ret],%[ret]\n\t"
+    "movq (%[src]),%%mm4\n\t"
+    "pxor %%mm7,%%mm7\n\t"
+    "pcmpeqb %%mm6,%%mm6\n\t"
+    "movq (%[src],%[ystride]),%%mm5\n\t"
+    "psubb %%mm6,%%mm7\n\t"
+    OC_SAD2_LOOP
+    OC_SAD2_LOOP
+    OC_SAD2_LOOP
+    OC_SAD2_TAIL
+    :[ret]"=&a"(ret),[src]"+r"(_src),[ref1]"+%r"(_ref1),[ref2]"+r"(_ref2)
+    :[ystride]"r"((ptrdiff_t)_ystride)
+  );
+  return (unsigned)ret;
+}
+
+/*Load an 8x4 array of pixel values from %[src] and %[ref] and compute their
+   16-bit difference in %%mm0...%%mm7.*/
+#define OC_LOAD_SUB_8x4(_off) \
+ "#OC_LOAD_SUB_8x4\n\t" \
+ "movd "_off"(%[src]),%%mm0\n\t" \
+ "movd "_off"(%[ref]),%%mm4\n\t" \
+ "movd "_off"(%[src],%[src_ystride]),%%mm1\n\t" \
+ "lea (%[src],%[src_ystride],2),%[src]\n\t" \
+ "movd "_off"(%[ref],%[ref_ystride]),%%mm5\n\t" \
+ "lea (%[ref],%[ref_ystride],2),%[ref]\n\t" \
+ "movd "_off"(%[src]),%%mm2\n\t" \
+ "movd "_off"(%[ref]),%%mm7\n\t" \
+ "movd "_off"(%[src],%[src_ystride]),%%mm3\n\t" \
+ "movd "_off"(%[ref],%[ref_ystride]),%%mm6\n\t" \
+ "punpcklbw %%mm4,%%mm0\n\t" \
+ "lea (%[src],%[src_ystride],2),%[src]\n\t" \
+ "punpcklbw %%mm4,%%mm4\n\t" \
+ "lea (%[ref],%[ref_ystride],2),%[ref]\n\t" \
+ "psubw %%mm4,%%mm0\n\t" \
+ "movd "_off"(%[src]),%%mm4\n\t" \
+ "movq %%mm0,"_off"*2(%[buf])\n\t" \
+ "movd "_off"(%[ref]),%%mm0\n\t" \
+ "punpcklbw %%mm5,%%mm1\n\t" \
+ "punpcklbw %%mm5,%%mm5\n\t" \
+ "psubw %%mm5,%%mm1\n\t" \
+ "movd "_off"(%[src],%[src_ystride]),%%mm5\n\t" \
+ "punpcklbw %%mm7,%%mm2\n\t" \
+ "punpcklbw %%mm7,%%mm7\n\t" \
+ "psubw %%mm7,%%mm2\n\t" \
+ "movd "_off"(%[ref],%[ref_ystride]),%%mm7\n\t" \
+ "punpcklbw %%mm6,%%mm3\n\t" \
+ "lea (%[src],%[src_ystride],2),%[src]\n\t" \
+ "punpcklbw %%mm6,%%mm6\n\t" \
+ "psubw %%mm6,%%mm3\n\t" \
+ "movd "_off"(%[src]),%%mm6\n\t" \
+ "punpcklbw %%mm0,%%mm4\n\t" \
+ "lea (%[ref],%[ref_ystride],2),%[ref]\n\t" \
+ "punpcklbw %%mm0,%%mm0\n\t" \
+ "lea (%[src],%[src_ystride],2),%[src]\n\t" \
+ "psubw %%mm0,%%mm4\n\t" \
+ "movd "_off"(%[ref]),%%mm0\n\t" \
+ "punpcklbw %%mm7,%%mm5\n\t" \
+ "neg %[src_ystride]\n\t" \
+ "punpcklbw %%mm7,%%mm7\n\t" \
+ "psubw %%mm7,%%mm5\n\t" \
+ "movd "_off"(%[src],%[src_ystride]),%%mm7\n\t" \
+ "punpcklbw %%mm0,%%mm6\n\t" \
+ "lea (%[ref],%[ref_ystride],2),%[ref]\n\t" \
+ "punpcklbw %%mm0,%%mm0\n\t" \
+ "neg %[ref_ystride]\n\t" \
+ "psubw %%mm0,%%mm6\n\t" \
+ "movd "_off"(%[ref],%[ref_ystride]),%%mm0\n\t" \
+ "lea (%[src],%[src_ystride],8),%[src]\n\t" \
+ "punpcklbw %%mm0,%%mm7\n\t" \
+ "neg %[src_ystride]\n\t" \
+ "punpcklbw %%mm0,%%mm0\n\t" \
+ "lea (%[ref],%[ref_ystride],8),%[ref]\n\t" \
+ "psubw %%mm0,%%mm7\n\t" \
+ "neg %[ref_ystride]\n\t" \
+ "movq "_off"*2(%[buf]),%%mm0\n\t" \
+
+/*Load an 8x4 array of pixel values from %[src] into %%mm0...%%mm7.*/
+#define OC_LOAD_8x4(_off) \
+ "#OC_LOAD_8x4\n\t" \
+ "movd "_off"(%[src]),%%mm0\n\t" \
+ "movd "_off"(%[src],%[ystride]),%%mm1\n\t" \
+ "movd "_off"(%[src],%[ystride],2),%%mm2\n\t" \
+ "pxor %%mm7,%%mm7\n\t" \
+ "movd "_off"(%[src],%[ystride3]),%%mm3\n\t" \
+ "punpcklbw %%mm7,%%mm0\n\t" \
+ "movd "_off"(%[src4]),%%mm4\n\t" \
+ "punpcklbw %%mm7,%%mm1\n\t" \
+ "movd "_off"(%[src4],%[ystride]),%%mm5\n\t" \
+ "punpcklbw %%mm7,%%mm2\n\t" \
+ "movd "_off"(%[src4],%[ystride],2),%%mm6\n\t" \
+ "punpcklbw %%mm7,%%mm3\n\t" \
+ "movd "_off"(%[src4],%[ystride3]),%%mm7\n\t" \
+ "punpcklbw %%mm4,%%mm4\n\t" \
+ "punpcklbw %%mm5,%%mm5\n\t" \
+ "psrlw $8,%%mm4\n\t" \
+ "psrlw $8,%%mm5\n\t" \
+ "punpcklbw %%mm6,%%mm6\n\t" \
+ "punpcklbw %%mm7,%%mm7\n\t" \
+ "psrlw $8,%%mm6\n\t" \
+ "psrlw $8,%%mm7\n\t" \
+
+/*Performs the first two stages of an 8-point 1-D Hadamard transform.
+  The transform is performed in place, except that outputs 0-3 are swapped with
+   outputs 4-7.
+  Outputs 2, 3, 6 and 7 from the second stage are negated (which allows us to
+   perform this stage in place with no temporary registers).*/
+#define OC_HADAMARD_AB_8x4 \
+ "#OC_HADAMARD_AB_8x4\n\t" \
+ /*Stage A: \
+   Outputs 0-3 are swapped with 4-7 here.*/ \
+ "paddw %%mm1,%%mm5\n\t" \
+ "paddw %%mm2,%%mm6\n\t" \
+ "paddw %%mm1,%%mm1\n\t" \
+ "paddw %%mm2,%%mm2\n\t" \
+ "psubw %%mm5,%%mm1\n\t" \
+ "psubw %%mm6,%%mm2\n\t" \
+ "paddw %%mm3,%%mm7\n\t" \
+ "paddw %%mm0,%%mm4\n\t" \
+ "paddw %%mm3,%%mm3\n\t" \
+ "paddw %%mm0,%%mm0\n\t" \
+ "psubw %%mm7,%%mm3\n\t" \
+ "psubw %%mm4,%%mm0\n\t" \
+ /*Stage B:*/ \
+ "paddw %%mm2,%%mm0\n\t" \
+ "paddw %%mm3,%%mm1\n\t" \
+ "paddw %%mm6,%%mm4\n\t" \
+ "paddw %%mm7,%%mm5\n\t" \
+ "paddw %%mm2,%%mm2\n\t" \
+ "paddw %%mm3,%%mm3\n\t" \
+ "paddw %%mm6,%%mm6\n\t" \
+ "paddw %%mm7,%%mm7\n\t" \
+ "psubw %%mm0,%%mm2\n\t" \
+ "psubw %%mm1,%%mm3\n\t" \
+ "psubw %%mm4,%%mm6\n\t" \
+ "psubw %%mm5,%%mm7\n\t" \
+
+/*Performs the last stage of an 8-point 1-D Hadamard transform in place.
+  Ouputs 1, 3, 5, and 7 are negated (which allows us to perform this stage in
+   place with no temporary registers).*/
+#define OC_HADAMARD_C_8x4 \
+ "#OC_HADAMARD_C_8x4\n\t" \
+ /*Stage C:*/ \
+ "paddw %%mm1,%%mm0\n\t" \
+ "paddw %%mm3,%%mm2\n\t" \
+ "paddw %%mm5,%%mm4\n\t" \
+ "paddw %%mm7,%%mm6\n\t" \
+ "paddw %%mm1,%%mm1\n\t" \
+ "paddw %%mm3,%%mm3\n\t" \
+ "paddw %%mm5,%%mm5\n\t" \
+ "paddw %%mm7,%%mm7\n\t" \
+ "psubw %%mm0,%%mm1\n\t" \
+ "psubw %%mm2,%%mm3\n\t" \
+ "psubw %%mm4,%%mm5\n\t" \
+ "psubw %%mm6,%%mm7\n\t" \
+
+/*Performs an 8-point 1-D Hadamard transform.
+  The transform is performed in place, except that outputs 0-3 are swapped with
+   outputs 4-7.
+  Outputs 1, 2, 5 and 6 are negated (which allows us to perform the transform
+   in place with no temporary registers).*/
+#define OC_HADAMARD_8x4 \
+ OC_HADAMARD_AB_8x4 \
+ OC_HADAMARD_C_8x4 \
+
+/*Performs the first part of the final stage of the Hadamard transform and
+   summing of absolute values.
+  At the end of this part, %%mm1 will contain the DC coefficient of the
+   transform.*/
+#define OC_HADAMARD_C_ABS_ACCUM_A_8x4(_r6,_r7) \
+ /*We use the fact that \
+     (abs(a+b)+abs(a-b))/2=max(abs(a),abs(b)) \
+    to merge the final butterfly with the abs and the first stage of \
+    accumulation. \
+   Thus we can avoid using pabsw, which is not available until SSSE3. \
+   Emulating pabsw takes 3 instructions, so the straightforward MMXEXT \
+    implementation would be (3+3)*8+7=55 instructions (+4 for spilling \
+    registers). \
+   Even with pabsw, it would be (3+1)*8+7=39 instructions (with no spills). \
+   This implementation is only 26 (+4 for spilling registers).*/ \
+ "#OC_HADAMARD_C_ABS_ACCUM_A_8x4\n\t" \
+ "movq %%mm7,"_r7"(%[buf])\n\t" \
+ "movq %%mm6,"_r6"(%[buf])\n\t" \
+ /*mm7={0x7FFF}x4 \
+   mm0=max(abs(mm0),abs(mm1))-0x7FFF*/ \
+ "pcmpeqb %%mm7,%%mm7\n\t" \
+ "movq %%mm0,%%mm6\n\t" \
+ "psrlw $1,%%mm7\n\t" \
+ "paddw %%mm1,%%mm6\n\t" \
+ "pmaxsw %%mm1,%%mm0\n\t" \
+ "paddsw %%mm7,%%mm6\n\t" \
+ "psubw %%mm6,%%mm0\n\t" \
+ /*mm2=max(abs(mm2),abs(mm3))-0x7FFF \
+   mm4=max(abs(mm4),abs(mm5))-0x7FFF*/ \
+ "movq %%mm2,%%mm6\n\t" \
+ "movq %%mm4,%%mm1\n\t" \
+ "pmaxsw %%mm3,%%mm2\n\t" \
+ "pmaxsw %%mm5,%%mm4\n\t" \
+ "paddw %%mm3,%%mm6\n\t" \
+ "paddw %%mm5,%%mm1\n\t" \
+ "movq "_r7"(%[buf]),%%mm3\n\t" \
+
+/*Performs the second part of the final stage of the Hadamard transform and
+   summing of absolute values.*/
+#define OC_HADAMARD_C_ABS_ACCUM_B_8x4(_r6,_r7) \
+ "#OC_HADAMARD_C_ABS_ACCUM_B_8x4\n\t" \
+ "paddsw %%mm7,%%mm6\n\t" \
+ "movq "_r6"(%[buf]),%%mm5\n\t" \
+ "paddsw %%mm7,%%mm1\n\t" \
+ "psubw %%mm6,%%mm2\n\t" \
+ "psubw %%mm1,%%mm4\n\t" \
+ /*mm7={1}x4 (needed for the horizontal add that follows) \
+   mm0+=mm2+mm4+max(abs(mm3),abs(mm5))-0x7FFF*/ \
+ "movq %%mm3,%%mm6\n\t" \
+ "pmaxsw %%mm5,%%mm3\n\t" \
+ "paddw %%mm2,%%mm0\n\t" \
+ "paddw %%mm5,%%mm6\n\t" \
+ "paddw %%mm4,%%mm0\n\t" \
+ "paddsw %%mm7,%%mm6\n\t" \
+ "paddw %%mm3,%%mm0\n\t" \
+ "psrlw $14,%%mm7\n\t" \
+ "psubw %%mm6,%%mm0\n\t" \
+
+/*Performs the last stage of an 8-point 1-D Hadamard transform, takes the
+   absolute value of each component, and accumulates everything into mm0.
+  This is the only portion of SATD which requires MMXEXT (we could use plain
+   MMX, but it takes 4 instructions and an extra register to work around the
+   lack of a pmaxsw, which is a pretty serious penalty).*/
+#define OC_HADAMARD_C_ABS_ACCUM_8x4(_r6,_r7) \
+ OC_HADAMARD_C_ABS_ACCUM_A_8x4(_r6,_r7) \
+ OC_HADAMARD_C_ABS_ACCUM_B_8x4(_r6,_r7) \
+
+/*Performs an 8-point 1-D Hadamard transform, takes the absolute value of each
+   component, and accumulates everything into mm0.
+  Note that mm0 will have an extra 4 added to each column, and that after
+   removing this value, the remainder will be half the conventional value.*/
+#define OC_HADAMARD_ABS_ACCUM_8x4(_r6,_r7) \
+ OC_HADAMARD_AB_8x4 \
+ OC_HADAMARD_C_ABS_ACCUM_8x4(_r6,_r7)
+
+/*Performs two 4x4 transposes (mostly) in place.
+  On input, {mm0,mm1,mm2,mm3} contains rows {e,f,g,h}, and {mm4,mm5,mm6,mm7}
+   contains rows {a,b,c,d}.
+  On output, {0x40,0x50,0x60,0x70}+_off(%[buf]) contains {e,f,g,h}^T, and
+   {mm4,mm5,mm6,mm7} contains the transposed rows {a,b,c,d}^T.*/
+#define OC_TRANSPOSE_4x4x2(_off) \
+ "#OC_TRANSPOSE_4x4x2\n\t" \
+ /*First 4x4 transpose:*/ \
+ "movq %%mm5,0x10+"_off"(%[buf])\n\t" \
+ /*mm0 = e3 e2 e1 e0 \
+   mm1 = f3 f2 f1 f0 \
+   mm2 = g3 g2 g1 g0 \
+   mm3 = h3 h2 h1 h0*/ \
+ "movq %%mm2,%%mm5\n\t" \
+ "punpcklwd %%mm3,%%mm2\n\t" \
+ "punpckhwd %%mm3,%%mm5\n\t" \
+ "movq %%mm0,%%mm3\n\t" \
+ "punpcklwd %%mm1,%%mm0\n\t" \
+ "punpckhwd %%mm1,%%mm3\n\t" \
+ /*mm0 = f1 e1 f0 e0 \
+   mm3 = f3 e3 f2 e2 \
+   mm2 = h1 g1 h0 g0 \
+   mm5 = h3 g3 h2 g2*/ \
+ "movq %%mm0,%%mm1\n\t" \
+ "punpckldq %%mm2,%%mm0\n\t" \
+ "punpckhdq %%mm2,%%mm1\n\t" \
+ "movq %%mm3,%%mm2\n\t" \
+ "punpckhdq %%mm5,%%mm3\n\t" \
+ "movq %%mm0,0x40+"_off"(%[buf])\n\t" \
+ "punpckldq %%mm5,%%mm2\n\t" \
+ /*mm0 = h0 g0 f0 e0 \
+   mm1 = h1 g1 f1 e1 \
+   mm2 = h2 g2 f2 e2 \
+   mm3 = h3 g3 f3 e3*/ \
+ "movq 0x10+"_off"(%[buf]),%%mm5\n\t" \
+ /*Second 4x4 transpose:*/ \
+ /*mm4 = a3 a2 a1 a0 \
+   mm5 = b3 b2 b1 b0 \
+   mm6 = c3 c2 c1 c0 \
+   mm7 = d3 d2 d1 d0*/ \
+ "movq %%mm6,%%mm0\n\t" \
+ "punpcklwd %%mm7,%%mm6\n\t" \
+ "movq %%mm1,0x50+"_off"(%[buf])\n\t" \
+ "punpckhwd %%mm7,%%mm0\n\t" \
+ "movq %%mm4,%%mm7\n\t" \
+ "punpcklwd %%mm5,%%mm4\n\t" \
+ "movq %%mm2,0x60+"_off"(%[buf])\n\t" \
+ "punpckhwd %%mm5,%%mm7\n\t" \
+ /*mm4 = b1 a1 b0 a0 \
+   mm7 = b3 a3 b2 a2 \
+   mm6 = d1 c1 d0 c0 \
+   mm0 = d3 c3 d2 c2*/ \
+ "movq %%mm4,%%mm5\n\t" \
+ "punpckldq %%mm6,%%mm4\n\t" \
+ "movq %%mm3,0x70+"_off"(%[buf])\n\t" \
+ "punpckhdq %%mm6,%%mm5\n\t" \
+ "movq %%mm7,%%mm6\n\t" \
+ "punpckhdq %%mm0,%%mm7\n\t" \
+ "punpckldq %%mm0,%%mm6\n\t" \
+ /*mm4 = d0 c0 b0 a0 \
+   mm5 = d1 c1 b1 a1 \
+   mm6 = d2 c2 b2 a2 \
+   mm7 = d3 c3 b3 a3*/ \
+
+static unsigned oc_int_frag_satd_thresh_mmxext(const unsigned char *_src,
+ int _src_ystride,const unsigned char *_ref,int _ref_ystride,
+ unsigned _thresh){
+  ogg_int16_t  buf[64]OC_ALIGN8;
+  ogg_int16_t *bufp;
+  unsigned     ret;
+  unsigned     ret2;
+  bufp=buf;
+  __asm__ __volatile__(
+    OC_LOAD_SUB_8x4("0x00")
+    OC_HADAMARD_8x4
+    OC_TRANSPOSE_4x4x2("0x00")
+    /*Finish swapping out this 8x4 block to make room for the next one.
+      mm0...mm3 have been swapped out already.*/
+    "movq %%mm4,0x00(%[buf])\n\t"
+    "movq %%mm5,0x10(%[buf])\n\t"
+    "movq %%mm6,0x20(%[buf])\n\t"
+    "movq %%mm7,0x30(%[buf])\n\t"
+    OC_LOAD_SUB_8x4("0x04")
+    OC_HADAMARD_8x4
+    OC_TRANSPOSE_4x4x2("0x08")
+    /*Here the first 4x4 block of output from the last transpose is the second
+       4x4 block of input for the next transform.
+      We have cleverly arranged that it already be in the appropriate place, so
+       we only have to do half the loads.*/
+    "movq 0x10(%[buf]),%%mm1\n\t"
+    "movq 0x20(%[buf]),%%mm2\n\t"
+    "movq 0x30(%[buf]),%%mm3\n\t"
+    "movq 0x00(%[buf]),%%mm0\n\t"
+    OC_HADAMARD_ABS_ACCUM_8x4("0x28","0x38")
+    /*Up to this point, everything fit in 16 bits (8 input + 1 for the
+       difference + 2*3 for the two 8-point 1-D Hadamards - 1 for the abs - 1
+       for the factor of two we dropped + 3 for the vertical accumulation).
+      Now we finally have to promote things to dwords.
+      We break this part out of OC_HADAMARD_ABS_ACCUM_8x4 to hide the long
+       latency of pmaddwd by starting the next series of loads now.*/
+    "mov %[thresh],%[ret2]\n\t"
+    "pmaddwd %%mm7,%%mm0\n\t"
+    "movq 0x50(%[buf]),%%mm1\n\t"
+    "movq 0x58(%[buf]),%%mm5\n\t"
+    "movq %%mm0,%%mm4\n\t"
+    "movq 0x60(%[buf]),%%mm2\n\t"
+    "punpckhdq %%mm0,%%mm0\n\t"
+    "movq 0x68(%[buf]),%%mm6\n\t"
+    "paddd %%mm0,%%mm4\n\t"
+    "movq 0x70(%[buf]),%%mm3\n\t"
+    "movd %%mm4,%[ret]\n\t"
+    "movq 0x78(%[buf]),%%mm7\n\t"
+    /*The sums produced by OC_HADAMARD_ABS_ACCUM_8x4 each have an extra 4
+       added to them, and a factor of two removed; correct the final sum here.*/
+    "lea -32(%[ret],%[ret]),%[ret]\n\t"
+    "movq 0x40(%[buf]),%%mm0\n\t"
+    "cmp %[ret2],%[ret]\n\t"
+    "movq 0x48(%[buf]),%%mm4\n\t"
+    "jae 1f\n\t"
+    OC_HADAMARD_ABS_ACCUM_8x4("0x68","0x78")
+    "pmaddwd %%mm7,%%mm0\n\t"
+    /*There isn't much to stick in here to hide the latency this time, but the
+       alternative to pmaddwd is movq->punpcklwd->punpckhwd->paddd, whose
+       latency is even worse.*/
+    "sub $32,%[ret]\n\t"
+    "movq %%mm0,%%mm4\n\t"
+    "punpckhdq %%mm0,%%mm0\n\t"
+    "paddd %%mm0,%%mm4\n\t"
+    "movd %%mm4,%[ret2]\n\t"
+    "lea (%[ret],%[ret2],2),%[ret]\n\t"
+    ".p2align 4,,15\n\t"
+    "1:\n\t"
+    /*Although it looks like we're using 7 registers here, gcc can alias %[ret]
+       and %[ret2] with some of the inputs, since for once we don't write to
+       them until after we're done using everything but %[buf] (which is also
+       listed as an output to ensure gcc _doesn't_ alias them against it).*/
+    /*Note that _src_ystride and _ref_ystride must be given non-overlapping
+       constraints, otherewise if gcc can prove they're equal it will allocate
+       them to the same register (which is bad); _src and _ref face a similar
+       problem, though those are never actually the same.*/
+    :[ret]"=a"(ret),[ret2]"=r"(ret2),[buf]"+r"(bufp)
+    :[src]"r"(_src),[src_ystride]"c"((ptrdiff_t)_src_ystride),
+     [ref]"r"(_ref),[ref_ystride]"d"((ptrdiff_t)_ref_ystride),
+     [thresh]"m"(_thresh)
+    /*We have to use neg, so we actually clobber the condition codes for once
+       (not to mention cmp, sub, and add).*/
+    :"cc"
+  );
+  return ret;
+}
+
+unsigned oc_enc_frag_satd_thresh_mmxext(const unsigned char *_src,
+ const unsigned char *_ref,int _ystride,unsigned _thresh){
+  return oc_int_frag_satd_thresh_mmxext(_src,_ystride,_ref,_ystride,_thresh);
+}
+
+/*Our internal implementation of frag_copy2 takes an extra stride parameter so
+   we can share code with oc_enc_frag_satd2_thresh_mmxext().*/
+static void oc_int_frag_copy2_mmxext(unsigned char *_dst,int _dst_ystride,
+ const unsigned char *_src1,const unsigned char *_src2,int _src_ystride){
+  __asm__ __volatile__(
+    /*Load the first 3 rows.*/
+    "movq (%[src1]),%%mm0\n\t"
+    "movq (%[src2]),%%mm1\n\t"
+    "movq (%[src1],%[src_ystride]),%%mm2\n\t"
+    "lea (%[src1],%[src_ystride],2),%[src1]\n\t"
+    "movq (%[src2],%[src_ystride]),%%mm3\n\t"
+    "lea (%[src2],%[src_ystride],2),%[src2]\n\t"
+    "pxor %%mm7,%%mm7\n\t"
+    "movq (%[src1]),%%mm4\n\t"
+    "pcmpeqb %%mm6,%%mm6\n\t"
+    "movq (%[src2]),%%mm5\n\t"
+    /*mm7={1}x8.*/
+    "psubb %%mm6,%%mm7\n\t"
+    /*Start averaging %%mm0 and %%mm1 into %%mm6.*/
+    "movq %%mm0,%%mm6\n\t"
+    "pxor %%mm1,%%mm0\n\t"
+    "pavgb %%mm1,%%mm6\n\t"
+    /*%%mm1 is free, start averaging %%mm3 into %%mm2 using %%mm1.*/
+    "movq %%mm2,%%mm1\n\t"
+    "pand %%mm7,%%mm0\n\t"
+    "pavgb %%mm3,%%mm2\n\t"
+    "pxor %%mm3,%%mm1\n\t"
+    /*%%mm3 is free.*/
+    "psubb %%mm0,%%mm6\n\t"
+    /*%%mm0 is free, start loading the next row.*/
+    "movq (%[src1],%[src_ystride]),%%mm0\n\t"
+    /*Start averaging %%mm5 and %%mm4 using %%mm3.*/
+    "movq %%mm4,%%mm3\n\t"
+    /*%%mm6 (row 0) is done; write it out.*/
+    "movq %%mm6,(%[dst])\n\t"
+    "pand %%mm7,%%mm1\n\t"
+    "pavgb %%mm5,%%mm4\n\t"
+    "psubb %%mm1,%%mm2\n\t"
+    /*%%mm1 is free, continue loading the next row.*/
+    "movq (%[src2],%[src_ystride]),%%mm1\n\t"
+    "pxor %%mm5,%%mm3\n\t"
+    "lea (%[src1],%[src_ystride],2),%[src1]\n\t"
+    /*%%mm2 (row 1) is done; write it out.*/
+    "movq %%mm2,(%[dst],%[dst_ystride])\n\t"
+    "pand %%mm7,%%mm3\n\t"
+    /*Start loading the next row.*/
+    "movq (%[src1]),%%mm2\n\t"
+    "lea (%[dst],%[dst_ystride],2),%[dst]\n\t"
+    "psubb %%mm3,%%mm4\n\t"
+    "lea (%[src2],%[src_ystride],2),%[src2]\n\t"
+    /*%%mm4 (row 2) is done; write it out.*/
+    "movq %%mm4,(%[dst])\n\t"
+    /*Continue loading the next row.*/
+    "movq (%[src2]),%%mm3\n\t"
+    /*Start averaging %%mm0 and %%mm1 into %%mm6.*/
+    "movq %%mm0,%%mm6\n\t"
+    "pxor %%mm1,%%mm0\n\t"
+    /*Start loading the next row.*/
+    "movq (%[src1],%[src_ystride]),%%mm4\n\t"
+    "pavgb %%mm1,%%mm6\n\t"
+    /*%%mm1 is free; start averaging %%mm3 into %%mm2 using %%mm1.*/
+    "movq %%mm2,%%mm1\n\t"
+    "pand %%mm7,%%mm0\n\t"
+    /*Continue loading the next row.*/
+    "movq (%[src2],%[src_ystride]),%%mm5\n\t"
+    "pavgb %%mm3,%%mm2\n\t"
+    "lea (%[src1],%[src_ystride],2),%[src1]\n\t"
+    "pxor %%mm3,%%mm1\n\t"
+    /*%%mm3 is free.*/
+    "psubb %%mm0,%%mm6\n\t"
+    /*%%mm0 is free, start loading the next row.*/
+    "movq (%[src1]),%%mm0\n\t"
+    /*Start averaging %%mm5 into %%mm4 using %%mm3.*/
+    "movq %%mm4,%%mm3\n\t"
+    /*%%mm6 (row 3) is done; write it out.*/
+    "movq %%mm6,(%[dst],%[dst_ystride])\n\t"
+    "pand %%mm7,%%mm1\n\t"
+    "lea (%[src2],%[src_ystride],2),%[src2]\n\t"
+    "pavgb %%mm5,%%mm4\n\t"
+    "lea (%[dst],%[dst_ystride],2),%[dst]\n\t"
+    "psubb %%mm1,%%mm2\n\t"
+    /*%%mm1 is free; continue loading the next row.*/
+    "movq (%[src2]),%%mm1\n\t"
+    "pxor %%mm5,%%mm3\n\t"
+    /*%%mm2 (row 4) is done; write it out.*/
+    "movq %%mm2,(%[dst])\n\t"
+    "pand %%mm7,%%mm3\n\t"
+    /*Start loading the next row.*/
+    "movq (%[src1],%[src_ystride]),%%mm2\n\t"
+    "psubb %%mm3,%%mm4\n\t"
+    /*Start averaging %%mm0 and %%mm1 into %%mm6.*/
+    "movq %%mm0,%%mm6\n\t"
+    /*Continue loading the next row.*/
+    "movq (%[src2],%[src_ystride]),%%mm3\n\t"
+    /*%%mm4 (row 5) is done; write it out.*/
+    "movq %%mm4,(%[dst],%[dst_ystride])\n\t"
+    "pxor %%mm1,%%mm0\n\t"
+    "pavgb %%mm1,%%mm6\n\t"
+    /*%%mm4 is free; start averaging %%mm3 into %%mm2 using %%mm4.*/
+    "movq %%mm2,%%mm4\n\t"
+    "pand %%mm7,%%mm0\n\t"
+    "pavgb %%mm3,%%mm2\n\t"
+    "pxor %%mm3,%%mm4\n\t"
+    "lea (%[dst],%[dst_ystride],2),%[dst]\n\t"
+    "psubb %%mm0,%%mm6\n\t"
+    "pand %%mm7,%%mm4\n\t"
+    /*%%mm6 (row 6) is done, write it out.*/
+    "movq %%mm6,(%[dst])\n\t"
+    "psubb %%mm4,%%mm2\n\t"
+    /*%%mm2 (row 7) is done, write it out.*/
+    "movq %%mm2,(%[dst],%[dst_ystride])\n\t"
+    :[dst]"+r"(_dst),[src1]"+%r"(_src1),[src2]"+r"(_src2)
+    :[dst_ystride]"r"((ptrdiff_t)_dst_ystride),
+     [src_ystride]"r"((ptrdiff_t)_src_ystride)
+    :"memory"
+  );
+}
+
+unsigned oc_enc_frag_satd2_thresh_mmxext(const unsigned char *_src,
+ const unsigned char *_ref1,const unsigned char *_ref2,int _ystride,
+ unsigned _thresh){
+  unsigned char ref[64]OC_ALIGN8;
+  oc_int_frag_copy2_mmxext(ref,8,_ref1,_ref2,_ystride);
+  return oc_int_frag_satd_thresh_mmxext(_src,_ystride,ref,8,_thresh);
+}
+
+unsigned oc_enc_frag_intra_satd_mmxext(const unsigned char *_src,
+ int _ystride){
+  ogg_int16_t  buf[64]OC_ALIGN8;
+  ogg_int16_t *bufp;
+  unsigned     ret;
+  unsigned     ret2;
+  bufp=buf;
+  __asm__ __volatile__(
+    OC_LOAD_8x4("0x00")
+    OC_HADAMARD_8x4
+    OC_TRANSPOSE_4x4x2("0x00")
+    /*Finish swapping out this 8x4 block to make room for the next one.
+      mm0...mm3 have been swapped out already.*/
+    "movq %%mm4,0x00(%[buf])\n\t"
+    "movq %%mm5,0x10(%[buf])\n\t"
+    "movq %%mm6,0x20(%[buf])\n\t"
+    "movq %%mm7,0x30(%[buf])\n\t"
+    OC_LOAD_8x4("0x04")
+    OC_HADAMARD_8x4
+    OC_TRANSPOSE_4x4x2("0x08")
+    /*Here the first 4x4 block of output from the last transpose is the second
+       4x4 block of input for the next transform.
+      We have cleverly arranged that it already be in the appropriate place, so
+       we only have to do half the loads.*/
+    "movq 0x10(%[buf]),%%mm1\n\t"
+    "movq 0x20(%[buf]),%%mm2\n\t"
+    "movq 0x30(%[buf]),%%mm3\n\t"
+    "movq 0x00(%[buf]),%%mm0\n\t"
+    /*We split out the stages here so we can save the DC coefficient in the
+       middle.*/
+    OC_HADAMARD_AB_8x4
+    OC_HADAMARD_C_ABS_ACCUM_A_8x4("0x28","0x38")
+    "movd %%mm1,%[ret]\n\t"
+    OC_HADAMARD_C_ABS_ACCUM_B_8x4("0x28","0x38")
+    /*Up to this point, everything fit in 16 bits (8 input + 1 for the
+       difference + 2*3 for the two 8-point 1-D Hadamards - 1 for the abs - 1
+       for the factor of two we dropped + 3 for the vertical accumulation).
+      Now we finally have to promote things to dwords.
+      We break this part out of OC_HADAMARD_ABS_ACCUM_8x4 to hide the long
+       latency of pmaddwd by starting the next series of loads now.*/
+    "pmaddwd %%mm7,%%mm0\n\t"
+    "movq 0x50(%[buf]),%%mm1\n\t"
+    "movq 0x58(%[buf]),%%mm5\n\t"
+    "movq 0x60(%[buf]),%%mm2\n\t"
+    "movq %%mm0,%%mm4\n\t"
+    "movq 0x68(%[buf]),%%mm6\n\t"
+    "punpckhdq %%mm0,%%mm0\n\t"
+    "movq 0x70(%[buf]),%%mm3\n\t"
+    "paddd %%mm0,%%mm4\n\t"
+    "movq 0x78(%[buf]),%%mm7\n\t"
+    "movd %%mm4,%[ret2]\n\t"
+    "movq 0x40(%[buf]),%%mm0\n\t"
+    "movq 0x48(%[buf]),%%mm4\n\t"
+    OC_HADAMARD_ABS_ACCUM_8x4("0x68","0x78")
+    "pmaddwd %%mm7,%%mm0\n\t"
+    /*We assume that the DC coefficient is always positive (which is true,
+       because the input to the INTRA transform was not a difference).*/
+    "movzx %w[ret],%[ret]\n\t"
+    "add %[ret2],%[ret2]\n\t"
+    "sub %[ret],%[ret2]\n\t"
+    "movq %%mm0,%%mm4\n\t"
+    "punpckhdq %%mm0,%%mm0\n\t"
+    "paddd %%mm0,%%mm4\n\t"
+    "movd %%mm4,%[ret]\n\t"
+    "lea -64(%[ret2],%[ret],2),%[ret]\n\t"
+    /*Although it looks like we're using 7 registers here, gcc can alias %[ret]
+       and %[ret2] with some of the inputs, since for once we don't write to
+       them until after we're done using everything but %[buf] (which is also
+       listed as an output to ensure gcc _doesn't_ alias them against it).*/
+    :[ret]"=a"(ret),[ret2]"=r"(ret2),[buf]"+r"(bufp)
+    :[src]"r"(_src),[src4]"r"(_src+4*_ystride),
+     [ystride]"r"((ptrdiff_t)_ystride),[ystride3]"r"((ptrdiff_t)3*_ystride)
+    /*We have to use sub, so we actually clobber the condition codes for once
+       (not to mention add).*/
+    :"cc"
+  );
+  return ret;
+}
+
+void oc_enc_frag_sub_mmx(ogg_int16_t _residue[64],
+ const unsigned char *_src,const unsigned char *_ref,int _ystride){
+  int i;
+  __asm__ __volatile__("pxor %%mm7,%%mm7\n\t"::);
+  for(i=4;i-->0;){
+    __asm__ __volatile__(
+      /*mm0=[src]*/
+      "movq (%[src]),%%mm0\n\t"
+      /*mm1=[ref]*/
+      "movq (%[ref]),%%mm1\n\t"
+      /*mm4=[src+ystride]*/
+      "movq (%[src],%[ystride]),%%mm4\n\t"
+      /*mm5=[ref+ystride]*/
+      "movq (%[ref],%[ystride]),%%mm5\n\t"
+      /*Compute [src]-[ref].*/
+      "movq %%mm0,%%mm2\n\t"
+      "punpcklbw %%mm7,%%mm0\n\t"
+      "movq %%mm1,%%mm3\n\t"
+      "punpckhbw %%mm7,%%mm2\n\t"
+      "punpcklbw %%mm7,%%mm1\n\t"
+      "punpckhbw %%mm7,%%mm3\n\t"
+      "psubw %%mm1,%%mm0\n\t"
+      "psubw %%mm3,%%mm2\n\t"
+      /*Compute [src+ystride]-[ref+ystride].*/
+      "movq %%mm4,%%mm1\n\t"
+      "punpcklbw %%mm7,%%mm4\n\t"
+      "movq %%mm5,%%mm3\n\t"
+      "punpckhbw %%mm7,%%mm1\n\t"
+      "lea (%[src],%[ystride],2),%[src]\n\t"
+      "punpcklbw %%mm7,%%mm5\n\t"
+      "lea (%[ref],%[ystride],2),%[ref]\n\t"
+      "punpckhbw %%mm7,%%mm3\n\t"
+      "psubw %%mm5,%%mm4\n\t"
+      "psubw %%mm3,%%mm1\n\t"
+      /*Write the answer out.*/
+      "movq %%mm0,0x00(%[residue])\n\t"
+      "movq %%mm2,0x08(%[residue])\n\t"
+      "movq %%mm4,0x10(%[residue])\n\t"
+      "movq %%mm1,0x18(%[residue])\n\t"
+      "lea 0x20(%[residue]),%[residue]\n\t"
+      :[residue]"+r"(_residue),[src]"+r"(_src),[ref]"+r"(_ref)
+      :[ystride]"r"((ptrdiff_t)_ystride)
+      :"memory"
+    );
+  }
+}
+
+void oc_enc_frag_sub_128_mmx(ogg_int16_t _residue[64],
+ const unsigned char *_src,int _ystride){
+  ptrdiff_t ystride3;
+  __asm__ __volatile__(
+    /*mm0=[src]*/
+    "movq (%[src]),%%mm0\n\t"
+    /*mm1=[src+ystride]*/
+    "movq (%[src],%[ystride]),%%mm1\n\t"
+    /*mm6={-1}x4*/
+    "pcmpeqw %%mm6,%%mm6\n\t"
+    /*mm2=[src+2*ystride]*/
+    "movq (%[src],%[ystride],2),%%mm2\n\t"
+    /*[ystride3]=3*[ystride]*/
+    "lea (%[ystride],%[ystride],2),%[ystride3]\n\t"
+    /*mm6={1}x4*/
+    "psllw $15,%%mm6\n\t"
+    /*mm3=[src+3*ystride]*/
+    "movq (%[src],%[ystride3]),%%mm3\n\t"
+    /*mm6={128}x4*/
+    "psrlw $8,%%mm6\n\t"
+    /*mm7=0*/
+    "pxor %%mm7,%%mm7\n\t"
+    /*[src]=[src]+4*[ystride]*/
+    "lea (%[src],%[ystride],4),%[src]\n\t"
+    /*Compute [src]-128 and [src+ystride]-128*/
+    "movq %%mm0,%%mm4\n\t"
+    "punpcklbw %%mm7,%%mm0\n\t"
+    "movq %%mm1,%%mm5\n\t"
+    "punpckhbw %%mm7,%%mm4\n\t"
+    "psubw %%mm6,%%mm0\n\t"
+    "punpcklbw %%mm7,%%mm1\n\t"
+    "psubw %%mm6,%%mm4\n\t"
+    "punpckhbw %%mm7,%%mm5\n\t"
+    "psubw %%mm6,%%mm1\n\t"
+    "psubw %%mm6,%%mm5\n\t"
+    /*Write the answer out.*/
+    "movq %%mm0,0x00(%[residue])\n\t"
+    "movq %%mm4,0x08(%[residue])\n\t"
+    "movq %%mm1,0x10(%[residue])\n\t"
+    "movq %%mm5,0x18(%[residue])\n\t"
+    /*mm0=[src+4*ystride]*/
+    "movq (%[src]),%%mm0\n\t"
+    /*mm1=[src+5*ystride]*/
+    "movq (%[src],%[ystride]),%%mm1\n\t"
+    /*Compute [src+2*ystride]-128 and [src+3*ystride]-128*/
+    "movq %%mm2,%%mm4\n\t"
+    "punpcklbw %%mm7,%%mm2\n\t"
+    "movq %%mm3,%%mm5\n\t"
+    "punpckhbw %%mm7,%%mm4\n\t"
+    "psubw %%mm6,%%mm2\n\t"
+    "punpcklbw %%mm7,%%mm3\n\t"
+    "psubw %%mm6,%%mm4\n\t"
+    "punpckhbw %%mm7,%%mm5\n\t"
+    "psubw %%mm6,%%mm3\n\t"
+    "psubw %%mm6,%%mm5\n\t"
+    /*Write the answer out.*/
+    "movq %%mm2,0x20(%[residue])\n\t"
+    "movq %%mm4,0x28(%[residue])\n\t"
+    "movq %%mm3,0x30(%[residue])\n\t"
+    "movq %%mm5,0x38(%[residue])\n\t"
+    /*mm2=[src+6*ystride]*/
+    "movq (%[src],%[ystride],2),%%mm2\n\t"
+    /*mm3=[src+7*ystride]*/
+    "movq (%[src],%[ystride3]),%%mm3\n\t"
+    /*Compute [src+4*ystride]-128 and [src+5*ystride]-128*/
+    "movq %%mm0,%%mm4\n\t"
+    "punpcklbw %%mm7,%%mm0\n\t"
+    "movq %%mm1,%%mm5\n\t"
+    "punpckhbw %%mm7,%%mm4\n\t"
+    "psubw %%mm6,%%mm0\n\t"
+    "punpcklbw %%mm7,%%mm1\n\t"
+    "psubw %%mm6,%%mm4\n\t"
+    "punpckhbw %%mm7,%%mm5\n\t"
+    "psubw %%mm6,%%mm1\n\t"
+    "psubw %%mm6,%%mm5\n\t"
+    /*Write the answer out.*/
+    "movq %%mm0,0x40(%[residue])\n\t"
+    "movq %%mm4,0x48(%[residue])\n\t"
+    "movq %%mm1,0x50(%[residue])\n\t"
+    "movq %%mm5,0x58(%[residue])\n\t"
+    /*Compute [src+6*ystride]-128 and [src+7*ystride]-128*/
+    "movq %%mm2,%%mm4\n\t"
+    "punpcklbw %%mm7,%%mm2\n\t"
+    "movq %%mm3,%%mm5\n\t"
+    "punpckhbw %%mm7,%%mm4\n\t"
+    "psubw %%mm6,%%mm2\n\t"
+    "punpcklbw %%mm7,%%mm3\n\t"
+    "psubw %%mm6,%%mm4\n\t"
+    "punpckhbw %%mm7,%%mm5\n\t"
+    "psubw %%mm6,%%mm3\n\t"
+    "psubw %%mm6,%%mm5\n\t"
+    /*Write the answer out.*/
+    "movq %%mm2,0x60(%[residue])\n\t"
+    "movq %%mm4,0x68(%[residue])\n\t"
+    "movq %%mm3,0x70(%[residue])\n\t"
+    "movq %%mm5,0x78(%[residue])\n\t"
+    :[src]"+r"(_src),[ystride3]"=&r"(ystride3)
+    :[residue]"r"(_residue),[ystride]"r"((ptrdiff_t)_ystride)
+    :"memory"
+  );
+}
+
+void oc_enc_frag_copy2_mmxext(unsigned char *_dst,
+ const unsigned char *_src1,const unsigned char *_src2,int _ystride){
+  oc_int_frag_copy2_mmxext(_dst,_ystride,_src1,_src2,_ystride);
+}
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/mmxfdct.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/mmxfdct.c
new file mode 100644
index 0000000..0db5170
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/mmxfdct.c
@@ -0,0 +1,660 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 1999-2006                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************/
+/*MMX fDCT implementation for x86_32*/
+/*$Id: fdct_ses2.c 14579 2008-03-12 06:42:40Z xiphmont $*/
+#include "x86enc.h"
+
+#if defined(OC_X86_ASM)
+
+# define OC_FDCT_STAGE1_8x4 \
+ "#OC_FDCT_STAGE1_8x4\n\t" \
+ /*Stage 1:*/ \
+ /*mm0=t7'=t0-t7*/ \
+ "psubw %%mm7,%%mm0\n\t" \
+ "paddw %%mm7,%%mm7\n\t" \
+ /*mm1=t6'=t1-t6*/ \
+ "psubw %%mm6,%%mm1\n\t" \
+ "paddw %%mm6,%%mm6\n\t" \
+ /*mm2=t5'=t2-t5*/ \
+ "psubw %%mm5,%%mm2\n\t" \
+ "paddw %%mm5,%%mm5\n\t" \
+ /*mm3=t4'=t3-t4*/ \
+ "psubw %%mm4,%%mm3\n\t" \
+ "paddw %%mm4,%%mm4\n\t" \
+ /*mm7=t0'=t0+t7*/ \
+ "paddw %%mm0,%%mm7\n\t" \
+ /*mm6=t1'=t1+t6*/ \
+ "paddw %%mm1,%%mm6\n\t" \
+ /*mm5=t2'=t2+t5*/ \
+ "paddw %%mm2,%%mm5\n\t" \
+ /*mm4=t3'=t3+t4*/ \
+ "paddw %%mm3,%%mm4\n\t" \
+
+# define OC_FDCT8x4(_r0,_r1,_r2,_r3,_r4,_r5,_r6,_r7) \
+ "#OC_FDCT8x4\n\t" \
+ /*Stage 2:*/ \
+ /*mm7=t3''=t0'-t3'*/ \
+ "psubw %%mm4,%%mm7\n\t" \
+ "paddw %%mm4,%%mm4\n\t" \
+ /*mm6=t2''=t1'-t2'*/ \
+ "psubw %%mm5,%%mm6\n\t" \
+ "movq %%mm7,"_r6"(%[y])\n\t" \
+ "paddw %%mm5,%%mm5\n\t" \
+ /*mm1=t5''=t6'-t5'*/ \
+ "psubw %%mm2,%%mm1\n\t" \
+ "movq %%mm6,"_r2"(%[y])\n\t" \
+ /*mm4=t0''=t0'+t3'*/ \
+ "paddw %%mm7,%%mm4\n\t" \
+ "paddw %%mm2,%%mm2\n\t" \
+ /*mm5=t1''=t1'+t2'*/ \
+ "movq %%mm4,"_r0"(%[y])\n\t" \
+ "paddw %%mm6,%%mm5\n\t" \
+ /*mm2=t6''=t6'+t5'*/ \
+ "paddw %%mm1,%%mm2\n\t" \
+ "movq %%mm5,"_r4"(%[y])\n\t" \
+ /*mm0=t7', mm1=t5'', mm2=t6'', mm3=t4'.*/ \
+ /*mm4, mm5, mm6, mm7 are free.*/ \
+ /*Stage 3:*/ \
+ /*mm6={2}x4, mm7={27146,0xB500>>1}x2*/ \
+ "mov $0x5A806A0A,%[a]\n\t" \
+ "pcmpeqb %%mm6,%%mm6\n\t" \
+ "movd %[a],%%mm7\n\t" \
+ "psrlw $15,%%mm6\n\t" \
+ "punpckldq %%mm7,%%mm7\n\t" \
+ "paddw %%mm6,%%mm6\n\t" \
+ /*mm0=0, m2={-1}x4 \
+   mm5:mm4=t5''*27146+0xB500*/ \
+ "movq %%mm1,%%mm4\n\t" \
+ "movq %%mm1,%%mm5\n\t" \
+ "punpcklwd %%mm6,%%mm4\n\t" \
+ "movq %%mm2,"_r3"(%[y])\n\t" \
+ "pmaddwd %%mm7,%%mm4\n\t" \
+ "movq %%mm0,"_r7"(%[y])\n\t" \
+ "punpckhwd %%mm6,%%mm5\n\t" \
+ "pxor %%mm0,%%mm0\n\t" \
+ "pmaddwd %%mm7,%%mm5\n\t" \
+ "pcmpeqb %%mm2,%%mm2\n\t" \
+ /*mm2=t6'', mm1=t5''+(t5''!=0) \
+   mm4=(t5''*27146+0xB500>>16)*/ \
+ "pcmpeqw %%mm1,%%mm0\n\t" \
+ "psrad $16,%%mm4\n\t" \
+ "psubw %%mm2,%%mm0\n\t" \
+ "movq "_r3"(%[y]),%%mm2\n\t" \
+ "psrad $16,%%mm5\n\t" \
+ "paddw %%mm0,%%mm1\n\t" \
+ "packssdw %%mm5,%%mm4\n\t" \
+ /*mm4=s=(t5''*27146+0xB500>>16)+t5''+(t5''!=0)>>1*/ \
+ "paddw %%mm1,%%mm4\n\t" \
+ "movq "_r7"(%[y]),%%mm0\n\t" \
+ "psraw $1,%%mm4\n\t" \
+ "movq %%mm3,%%mm1\n\t" \
+ /*mm3=t4''=t4'+s*/ \
+ "paddw %%mm4,%%mm3\n\t" \
+ /*mm1=t5'''=t4'-s*/ \
+ "psubw %%mm4,%%mm1\n\t" \
+ /*mm1=0, mm3={-1}x4 \
+   mm5:mm4=t6''*27146+0xB500*/ \
+ "movq %%mm2,%%mm4\n\t" \
+ "movq %%mm2,%%mm5\n\t" \
+ "punpcklwd %%mm6,%%mm4\n\t" \
+ "movq %%mm1,"_r5"(%[y])\n\t" \
+ "pmaddwd %%mm7,%%mm4\n\t" \
+ "movq %%mm3,"_r1"(%[y])\n\t" \
+ "punpckhwd %%mm6,%%mm5\n\t" \
+ "pxor %%mm1,%%mm1\n\t" \
+ "pmaddwd %%mm7,%%mm5\n\t" \
+ "pcmpeqb %%mm3,%%mm3\n\t" \
+ /*mm2=t6''+(t6''!=0), mm4=(t6''*27146+0xB500>>16)*/ \
+ "psrad $16,%%mm4\n\t" \
+ "pcmpeqw %%mm2,%%mm1\n\t" \
+ "psrad $16,%%mm5\n\t" \
+ "psubw %%mm3,%%mm1\n\t" \
+ "packssdw %%mm5,%%mm4\n\t" \
+ "paddw %%mm1,%%mm2\n\t" \
+ /*mm1=t1'' \
+   mm4=s=(t6''*27146+0xB500>>16)+t6''+(t6''!=0)>>1*/ \
+ "paddw %%mm2,%%mm4\n\t" \
+ "movq "_r4"(%[y]),%%mm1\n\t" \
+ "psraw $1,%%mm4\n\t" \
+ "movq %%mm0,%%mm2\n\t" \
+ /*mm7={54491-0x7FFF,0x7FFF}x2 \
+   mm0=t7''=t7'+s*/ \
+ "paddw %%mm4,%%mm0\n\t" \
+ /*mm2=t6'''=t7'-s*/ \
+ "psubw %%mm4,%%mm2\n\t" \
+ /*Stage 4:*/ \
+ /*mm0=0, mm2=t0'' \
+   mm5:mm4=t1''*27146+0xB500*/ \
+ "movq %%mm1,%%mm4\n\t" \
+ "movq %%mm1,%%mm5\n\t" \
+ "punpcklwd %%mm6,%%mm4\n\t" \
+ "movq %%mm2,"_r3"(%[y])\n\t" \
+ "pmaddwd %%mm7,%%mm4\n\t" \
+ "movq "_r0"(%[y]),%%mm2\n\t" \
+ "punpckhwd %%mm6,%%mm5\n\t" \
+ "movq %%mm0,"_r7"(%[y])\n\t" \
+ "pmaddwd %%mm7,%%mm5\n\t" \
+ "pxor %%mm0,%%mm0\n\t" \
+ /*mm7={27146,0x4000>>1}x2 \
+   mm0=s=(t1''*27146+0xB500>>16)+t1''+(t1''!=0)*/ \
+ "psrad $16,%%mm4\n\t" \
+ "mov $0x20006A0A,%[a]\n\t" \
+ "pcmpeqw %%mm1,%%mm0\n\t" \
+ "movd %[a],%%mm7\n\t" \
+ "psrad $16,%%mm5\n\t" \
+ "psubw %%mm3,%%mm0\n\t" \
+ "packssdw %%mm5,%%mm4\n\t" \
+ "paddw %%mm1,%%mm0\n\t" \
+ "punpckldq %%mm7,%%mm7\n\t" \
+ "paddw %%mm4,%%mm0\n\t" \
+ /*mm6={0x00000E3D}x2 \
+   mm1=-(t0''==0), mm5:mm4=t0''*27146+0x4000*/ \
+ "movq %%mm2,%%mm4\n\t" \
+ "movq %%mm2,%%mm5\n\t" \
+ "punpcklwd %%mm6,%%mm4\n\t" \
+ "mov $0x0E3D,%[a]\n\t" \
+ "pmaddwd %%mm7,%%mm4\n\t" \
+ "punpckhwd %%mm6,%%mm5\n\t" \
+ "movd %[a],%%mm6\n\t" \
+ "pmaddwd %%mm7,%%mm5\n\t" \
+ "pxor %%mm1,%%mm1\n\t" \
+ "punpckldq %%mm6,%%mm6\n\t" \
+ "pcmpeqw %%mm2,%%mm1\n\t" \
+ /*mm4=r=(t0''*27146+0x4000>>16)+t0''+(t0''!=0)*/ \
+ "psrad $16,%%mm4\n\t" \
+ "psubw %%mm3,%%mm1\n\t" \
+ "psrad $16,%%mm5\n\t" \
+ "paddw %%mm1,%%mm2\n\t" \
+ "packssdw %%mm5,%%mm4\n\t" \
+ "movq "_r5"(%[y]),%%mm1\n\t" \
+ "paddw %%mm2,%%mm4\n\t" \
+ /*mm2=t6'', mm0=_y[0]=u=r+s>>1*/ \
+ "mov $0x7FFF54DC,%[a]\n\t" \
+ "paddw %%mm4,%%mm0\n\t" \
+ "movq "_r3"(%[y]),%%mm2\n\t" \
+ "movd %[a],%%mm7\n\t" \
+ "psraw $1,%%mm0\n\t" \
+ /*mm7={54491-0x7FFF,0x7FFF}x2 \
+   mm4=_y[4]=v=r-u*/ \
+ "psubw %%mm0,%%mm4\n\t" \
+ "punpckldq %%mm7,%%mm7\n\t" \
+ "movq %%mm4,"_r4"(%[y])\n\t" \
+ /*mm0=0, mm7={36410}x4 \
+   mm1=(t5'''!=0), mm5:mm4=54491*t5'''+0x0E3D*/ \
+ "movq %%mm1,%%mm4\n\t" \
+ "movq %%mm1,%%mm5\n\t" \
+ "punpcklwd %%mm1,%%mm4\n\t" \
+ "mov $0x8E3A8E3A,%[a]\n\t" \
+ "pmaddwd %%mm7,%%mm4\n\t" \
+ "movq %%mm0,"_r0"(%[y])\n\t" \
+ "punpckhwd %%mm1,%%mm5\n\t" \
+ "pxor %%mm0,%%mm0\n\t" \
+ "pmaddwd %%mm7,%%mm5\n\t" \
+ "pcmpeqw %%mm0,%%mm1\n\t" \
+ "movd %[a],%%mm7\n\t" \
+ "psubw %%mm3,%%mm1\n\t" \
+ "punpckldq %%mm7,%%mm7\n\t" \
+ "paddd %%mm6,%%mm4\n\t" \
+ "paddd %%mm6,%%mm5\n\t" \
+ /*mm0=0 \
+   mm3:mm1=36410*t6'''+((t5'''!=0)<<16)*/ \
+ "movq %%mm2,%%mm6\n\t" \
+ "movq %%mm2,%%mm3\n\t" \
+ "pmulhw %%mm7,%%mm6\n\t" \
+ "paddw %%mm2,%%mm1\n\t" \
+ "pmullw %%mm7,%%mm3\n\t" \
+ "pxor %%mm0,%%mm0\n\t" \
+ "paddw %%mm1,%%mm6\n\t" \
+ "movq %%mm3,%%mm1\n\t" \
+ "punpckhwd %%mm6,%%mm3\n\t" \
+ "punpcklwd %%mm6,%%mm1\n\t" \
+ /*mm3={-1}x4, mm6={1}x4 \
+   mm4=_y[5]=u=(54491*t5'''+36410*t6'''+0x0E3D>>16)+(t5'''!=0)*/ \
+ "paddd %%mm3,%%mm5\n\t" \
+ "paddd %%mm1,%%mm4\n\t" \
+ "psrad $16,%%mm5\n\t" \
+ "pxor %%mm6,%%mm6\n\t" \
+ "psrad $16,%%mm4\n\t" \
+ "pcmpeqb %%mm3,%%mm3\n\t" \
+ "packssdw %%mm5,%%mm4\n\t" \
+ "psubw %%mm3,%%mm6\n\t" \
+ /*mm1=t7'', mm7={26568,0x3400}x2 \
+   mm2=s=t6'''-(36410*u>>16)*/ \
+ "movq %%mm4,%%mm1\n\t" \
+ "mov $0x340067C8,%[a]\n\t" \
+ "pmulhw %%mm7,%%mm4\n\t" \
+ "movd %[a],%%mm7\n\t" \
+ "movq %%mm1,"_r5"(%[y])\n\t" \
+ "punpckldq %%mm7,%%mm7\n\t" \
+ "paddw %%mm1,%%mm4\n\t" \
+ "movq "_r7"(%[y]),%%mm1\n\t" \
+ "psubw %%mm4,%%mm2\n\t" \
+ /*mm6={0x00007B1B}x2 \
+   mm0=(s!=0), mm5:mm4=s*26568+0x3400*/ \
+ "movq %%mm2,%%mm4\n\t" \
+ "movq %%mm2,%%mm5\n\t" \
+ "punpcklwd %%mm6,%%mm4\n\t" \
+ "pcmpeqw %%mm2,%%mm0\n\t" \
+ "pmaddwd %%mm7,%%mm4\n\t" \
+ "mov $0x7B1B,%[a]\n\t" \
+ "punpckhwd %%mm6,%%mm5\n\t" \
+ "movd %[a],%%mm6\n\t" \
+ "pmaddwd %%mm7,%%mm5\n\t" \
+ "psubw %%mm3,%%mm0\n\t" \
+ "punpckldq %%mm6,%%mm6\n\t" \
+ /*mm7={64277-0x7FFF,0x7FFF}x2 \
+   mm2=_y[3]=v=(s*26568+0x3400>>17)+s+(s!=0)*/ \
+ "psrad $17,%%mm4\n\t" \
+ "paddw %%mm0,%%mm2\n\t" \
+ "psrad $17,%%mm5\n\t" \
+ "mov $0x7FFF7B16,%[a]\n\t" \
+ "packssdw %%mm5,%%mm4\n\t" \
+ "movd %[a],%%mm7\n\t" \
+ "paddw %%mm4,%%mm2\n\t" \
+ "punpckldq %%mm7,%%mm7\n\t" \
+ /*mm0=0, mm7={12785}x4 \
+   mm1=(t7''!=0), mm2=t4'', mm5:mm4=64277*t7''+0x7B1B*/ \
+ "movq %%mm1,%%mm4\n\t" \
+ "movq %%mm1,%%mm5\n\t" \
+ "movq %%mm2,"_r3"(%[y])\n\t" \
+ "punpcklwd %%mm1,%%mm4\n\t" \
+ "movq "_r1"(%[y]),%%mm2\n\t" \
+ "pmaddwd %%mm7,%%mm4\n\t" \
+ "mov $0x31F131F1,%[a]\n\t" \
+ "punpckhwd %%mm1,%%mm5\n\t" \
+ "pxor %%mm0,%%mm0\n\t" \
+ "pmaddwd %%mm7,%%mm5\n\t" \
+ "pcmpeqw %%mm0,%%mm1\n\t" \
+ "movd %[a],%%mm7\n\t" \
+ "psubw %%mm3,%%mm1\n\t" \
+ "punpckldq %%mm7,%%mm7\n\t" \
+ "paddd %%mm6,%%mm4\n\t" \
+ "paddd %%mm6,%%mm5\n\t" \
+ /*mm3:mm1=12785*t4'''+((t7''!=0)<<16)*/ \
+ "movq %%mm2,%%mm6\n\t" \
+ "movq %%mm2,%%mm3\n\t" \
+ "pmulhw %%mm7,%%mm6\n\t" \
+ "pmullw %%mm7,%%mm3\n\t" \
+ "paddw %%mm1,%%mm6\n\t" \
+ "movq %%mm3,%%mm1\n\t" \
+ "punpckhwd %%mm6,%%mm3\n\t" \
+ "punpcklwd %%mm6,%%mm1\n\t" \
+ /*mm3={-1}x4, mm6={1}x4 \
+   mm4=_y[1]=u=(12785*t4'''+64277*t7''+0x7B1B>>16)+(t7''!=0)*/ \
+ "paddd %%mm3,%%mm5\n\t" \
+ "paddd %%mm1,%%mm4\n\t" \
+ "psrad $16,%%mm5\n\t" \
+ "pxor %%mm6,%%mm6\n\t" \
+ "psrad $16,%%mm4\n\t" \
+ "pcmpeqb %%mm3,%%mm3\n\t" \
+ "packssdw %%mm5,%%mm4\n\t" \
+ "psubw %%mm3,%%mm6\n\t" \
+ /*mm1=t3'', mm7={20539,0x3000}x2 \
+   mm4=s=(12785*u>>16)-t4''*/ \
+ "movq %%mm4,"_r1"(%[y])\n\t" \
+ "pmulhw %%mm7,%%mm4\n\t" \
+ "mov $0x3000503B,%[a]\n\t" \
+ "movq "_r6"(%[y]),%%mm1\n\t" \
+ "movd %[a],%%mm7\n\t" \
+ "psubw %%mm2,%%mm4\n\t" \
+ "punpckldq %%mm7,%%mm7\n\t" \
+ /*mm6={0x00006CB7}x2 \
+   mm0=(s!=0), mm5:mm4=s*20539+0x3000*/ \
+ "movq %%mm4,%%mm5\n\t" \
+ "movq %%mm4,%%mm2\n\t" \
+ "punpcklwd %%mm6,%%mm4\n\t" \
+ "pcmpeqw %%mm2,%%mm0\n\t" \
+ "pmaddwd %%mm7,%%mm4\n\t" \
+ "mov $0x6CB7,%[a]\n\t" \
+ "punpckhwd %%mm6,%%mm5\n\t" \
+ "movd %[a],%%mm6\n\t" \
+ "pmaddwd %%mm7,%%mm5\n\t" \
+ "psubw %%mm3,%%mm0\n\t" \
+ "punpckldq %%mm6,%%mm6\n\t" \
+ /*mm7={60547-0x7FFF,0x7FFF}x2 \
+   mm2=_y[7]=v=(s*20539+0x3000>>20)+s+(s!=0)*/ \
+ "psrad $20,%%mm4\n\t" \
+ "paddw %%mm0,%%mm2\n\t" \
+ "psrad $20,%%mm5\n\t" \
+ "mov $0x7FFF6C84,%[a]\n\t" \
+ "packssdw %%mm5,%%mm4\n\t" \
+ "movd %[a],%%mm7\n\t" \
+ "paddw %%mm4,%%mm2\n\t" \
+ "punpckldq %%mm7,%%mm7\n\t" \
+ /*mm0=0, mm7={25080}x4 \
+   mm2=t2'', mm5:mm4=60547*t3''+0x6CB7*/ \
+ "movq %%mm1,%%mm4\n\t" \
+ "movq %%mm1,%%mm5\n\t" \
+ "movq %%mm2,"_r7"(%[y])\n\t" \
+ "punpcklwd %%mm1,%%mm4\n\t" \
+ "movq "_r2"(%[y]),%%mm2\n\t" \
+ "pmaddwd %%mm7,%%mm4\n\t" \
+ "mov $0x61F861F8,%[a]\n\t" \
+ "punpckhwd %%mm1,%%mm5\n\t" \
+ "pxor %%mm0,%%mm0\n\t" \
+ "pmaddwd %%mm7,%%mm5\n\t" \
+ "movd %[a],%%mm7\n\t" \
+ "pcmpeqw %%mm0,%%mm1\n\t" \
+ "psubw %%mm3,%%mm1\n\t" \
+ "punpckldq %%mm7,%%mm7\n\t" \
+ "paddd %%mm6,%%mm4\n\t" \
+ "paddd %%mm6,%%mm5\n\t" \
+ /*mm3:mm1=25080*t2''+((t3''!=0)<<16)*/ \
+ "movq %%mm2,%%mm6\n\t" \
+ "movq %%mm2,%%mm3\n\t" \
+ "pmulhw %%mm7,%%mm6\n\t" \
+ "pmullw %%mm7,%%mm3\n\t" \
+ "paddw %%mm1,%%mm6\n\t" \
+ "movq %%mm3,%%mm1\n\t" \
+ "punpckhwd %%mm6,%%mm3\n\t" \
+ "punpcklwd %%mm6,%%mm1\n\t" \
+ /*mm1={-1}x4 \
+   mm4=u=(25080*t2''+60547*t3''+0x6CB7>>16)+(t3''!=0)*/ \
+ "paddd %%mm3,%%mm5\n\t" \
+ "paddd %%mm1,%%mm4\n\t" \
+ "psrad $16,%%mm5\n\t" \
+ "mov $0x28005460,%[a]\n\t" \
+ "psrad $16,%%mm4\n\t" \
+ "pcmpeqb %%mm1,%%mm1\n\t" \
+ "packssdw %%mm5,%%mm4\n\t" \
+ /*mm5={1}x4, mm6=_y[2]=u, mm7={21600,0x2800}x2 \
+   mm4=s=(25080*u>>16)-t2''*/ \
+ "movq %%mm4,%%mm6\n\t" \
+ "pmulhw %%mm7,%%mm4\n\t" \
+ "pxor %%mm5,%%mm5\n\t" \
+ "movd %[a],%%mm7\n\t" \
+ "psubw %%mm1,%%mm5\n\t" \
+ "punpckldq %%mm7,%%mm7\n\t" \
+ "psubw %%mm2,%%mm4\n\t" \
+ /*mm2=s+(s!=0) \
+   mm4:mm3=s*21600+0x2800*/ \
+ "movq %%mm4,%%mm3\n\t" \
+ "movq %%mm4,%%mm2\n\t" \
+ "punpckhwd %%mm5,%%mm4\n\t" \
+ "pcmpeqw %%mm2,%%mm0\n\t" \
+ "pmaddwd %%mm7,%%mm4\n\t" \
+ "psubw %%mm1,%%mm0\n\t" \
+ "punpcklwd %%mm5,%%mm3\n\t" \
+ "paddw %%mm0,%%mm2\n\t" \
+ "pmaddwd %%mm7,%%mm3\n\t" \
+ /*mm0=_y[4], mm1=_y[7], mm4=_y[0], mm5=_y[5] \
+   mm3=_y[6]=v=(s*21600+0x2800>>18)+s+(s!=0)*/ \
+ "movq "_r4"(%[y]),%%mm0\n\t" \
+ "psrad $18,%%mm4\n\t" \
+ "movq "_r5"(%[y]),%%mm5\n\t" \
+ "psrad $18,%%mm3\n\t" \
+ "movq "_r7"(%[y]),%%mm1\n\t" \
+ "packssdw %%mm4,%%mm3\n\t" \
+ "movq "_r0"(%[y]),%%mm4\n\t" \
+ "paddw %%mm2,%%mm3\n\t" \
+
+/*On input, mm4=_y[0], mm6=_y[2], mm0=_y[4], mm5=_y[5], mm3=_y[6], mm1=_y[7].
+  On output, {_y[4],mm1,mm2,mm3} contains the transpose of _y[4...7] and
+   {mm4,mm5,mm6,mm7} contains the transpose of _y[0...3].*/
+# define OC_TRANSPOSE8x4(_r0,_r1,_r2,_r3,_r4,_r5,_r6,_r7) \
+ "#OC_TRANSPOSE8x4\n\t" \
+ /*First 4x4 transpose:*/ \
+ /*mm0 = e3 e2 e1 e0 \
+   mm5 = f3 f2 f1 f0 \
+   mm3 = g3 g2 g1 g0 \
+   mm1 = h3 h2 h1 h0*/ \
+ "movq %%mm0,%%mm2\n\t" \
+ "punpcklwd %%mm5,%%mm0\n\t" \
+ "punpckhwd %%mm5,%%mm2\n\t" \
+ "movq %%mm3,%%mm5\n\t" \
+ "punpcklwd %%mm1,%%mm3\n\t" \
+ "punpckhwd %%mm1,%%mm5\n\t" \
+ /*mm0 = f1 e1 f0 e0 \
+   mm2 = f3 e3 f2 e2 \
+   mm3 = h1 g1 h0 g0 \
+   mm5 = h3 g3 h2 g2*/ \
+ "movq %%mm0,%%mm1\n\t" \
+ "punpckldq %%mm3,%%mm0\n\t" \
+ "movq %%mm0,"_r4"(%[y])\n\t" \
+ "punpckhdq %%mm3,%%mm1\n\t" \
+ "movq "_r1"(%[y]),%%mm0\n\t" \
+ "movq %%mm2,%%mm3\n\t" \
+ "punpckldq %%mm5,%%mm2\n\t" \
+ "punpckhdq %%mm5,%%mm3\n\t" \
+ "movq "_r3"(%[y]),%%mm5\n\t" \
+ /*_y[4] = h0 g0 f0 e0 \
+    mm1  = h1 g1 f1 e1 \
+    mm2  = h2 g2 f2 e2 \
+    mm3  = h3 g3 f3 e3*/ \
+ /*Second 4x4 transpose:*/ \
+ /*mm4 = a3 a2 a1 a0 \
+   mm0 = b3 b2 b1 b0 \
+   mm6 = c3 c2 c1 c0 \
+   mm5 = d3 d2 d1 d0*/ \
+ "movq %%mm4,%%mm7\n\t" \
+ "punpcklwd %%mm0,%%mm4\n\t" \
+ "punpckhwd %%mm0,%%mm7\n\t" \
+ "movq %%mm6,%%mm0\n\t" \
+ "punpcklwd %%mm5,%%mm6\n\t" \
+ "punpckhwd %%mm5,%%mm0\n\t" \
+ /*mm4 = b1 a1 b0 a0 \
+   mm7 = b3 a3 b2 a2 \
+   mm6 = d1 c1 d0 c0 \
+   mm0 = d3 c3 d2 c2*/ \
+ "movq %%mm4,%%mm5\n\t" \
+ "punpckldq %%mm6,%%mm4\n\t" \
+ "punpckhdq %%mm6,%%mm5\n\t" \
+ "movq %%mm7,%%mm6\n\t" \
+ "punpckhdq %%mm0,%%mm7\n\t" \
+ "punpckldq %%mm0,%%mm6\n\t" \
+ /*mm4 = d0 c0 b0 a0 \
+   mm5 = d1 c1 b1 a1 \
+   mm6 = d2 c2 b2 a2 \
+   mm7 = d3 c3 b3 a3*/ \
+
+/*MMX implementation of the fDCT.*/
+void oc_enc_fdct8x8_mmx(ogg_int16_t _y[64],const ogg_int16_t _x[64]){
+  ptrdiff_t a;
+  __asm__ __volatile__(
+    /*Add two extra bits of working precision to improve accuracy; any more and
+       we could overflow.*/
+    /*We also add biases to correct for some systematic error that remains in
+       the full fDCT->iDCT round trip.*/
+    "movq 0x00(%[x]),%%mm0\n\t"
+    "movq 0x10(%[x]),%%mm1\n\t"
+    "movq 0x20(%[x]),%%mm2\n\t"
+    "movq 0x30(%[x]),%%mm3\n\t"
+    "pcmpeqb %%mm4,%%mm4\n\t"
+    "pxor %%mm7,%%mm7\n\t"
+    "movq %%mm0,%%mm5\n\t"
+    "psllw $2,%%mm0\n\t"
+    "pcmpeqw %%mm7,%%mm5\n\t"
+    "movq 0x70(%[x]),%%mm7\n\t"
+    "psllw $2,%%mm1\n\t"
+    "psubw %%mm4,%%mm5\n\t"
+    "psllw $2,%%mm2\n\t"
+    "mov $1,%[a]\n\t"
+    "pslld $16,%%mm5\n\t"
+    "movd %[a],%%mm6\n\t"
+    "psllq $16,%%mm5\n\t"
+    "mov $0x10001,%[a]\n\t"
+    "psllw $2,%%mm3\n\t"
+    "movd %[a],%%mm4\n\t"
+    "punpckhwd %%mm6,%%mm5\n\t"
+    "psubw %%mm6,%%mm1\n\t"
+    "movq 0x60(%[x]),%%mm6\n\t"
+    "paddw %%mm5,%%mm0\n\t"
+    "movq 0x50(%[x]),%%mm5\n\t"
+    "paddw %%mm4,%%mm0\n\t"
+    "movq 0x40(%[x]),%%mm4\n\t"
+    /*We inline stage1 of the transform here so we can get better instruction
+       scheduling with the shifts.*/
+    /*mm0=t7'=t0-t7*/
+    "psllw $2,%%mm7\n\t"
+    "psubw %%mm7,%%mm0\n\t"
+    "psllw $2,%%mm6\n\t"
+    "paddw %%mm7,%%mm7\n\t"
+    /*mm1=t6'=t1-t6*/
+    "psllw $2,%%mm5\n\t"
+    "psubw %%mm6,%%mm1\n\t"
+    "psllw $2,%%mm4\n\t"
+    "paddw %%mm6,%%mm6\n\t"
+    /*mm2=t5'=t2-t5*/
+    "psubw %%mm5,%%mm2\n\t"
+    "paddw %%mm5,%%mm5\n\t"
+    /*mm3=t4'=t3-t4*/
+    "psubw %%mm4,%%mm3\n\t"
+    "paddw %%mm4,%%mm4\n\t"
+    /*mm7=t0'=t0+t7*/
+    "paddw %%mm0,%%mm7\n\t"
+    /*mm6=t1'=t1+t6*/
+    "paddw %%mm1,%%mm6\n\t"
+    /*mm5=t2'=t2+t5*/
+    "paddw %%mm2,%%mm5\n\t"
+    /*mm4=t3'=t3+t4*/
+    "paddw %%mm3,%%mm4\n\t"
+    OC_FDCT8x4("0x00","0x10","0x20","0x30","0x40","0x50","0x60","0x70")
+    OC_TRANSPOSE8x4("0x00","0x10","0x20","0x30","0x40","0x50","0x60","0x70")
+    /*Swap out this 8x4 block for the next one.*/
+    "movq 0x08(%[x]),%%mm0\n\t"
+    "movq %%mm7,0x30(%[y])\n\t"
+    "movq 0x78(%[x]),%%mm7\n\t"
+    "movq %%mm1,0x50(%[y])\n\t"
+    "movq 0x18(%[x]),%%mm1\n\t"
+    "movq %%mm6,0x20(%[y])\n\t"
+    "movq 0x68(%[x]),%%mm6\n\t"
+    "movq %%mm2,0x60(%[y])\n\t"
+    "movq 0x28(%[x]),%%mm2\n\t"
+    "movq %%mm5,0x10(%[y])\n\t"
+    "movq 0x58(%[x]),%%mm5\n\t"
+    "movq %%mm3,0x70(%[y])\n\t"
+    "movq 0x38(%[x]),%%mm3\n\t"
+    /*And increase its working precision, too.*/
+    "psllw $2,%%mm0\n\t"
+    "movq %%mm4,0x00(%[y])\n\t"
+    "psllw $2,%%mm7\n\t"
+    "movq 0x48(%[x]),%%mm4\n\t"
+    /*We inline stage1 of the transform here so we can get better instruction
+       scheduling with the shifts.*/
+    /*mm0=t7'=t0-t7*/
+    "psubw %%mm7,%%mm0\n\t"
+    "psllw $2,%%mm1\n\t"
+    "paddw %%mm7,%%mm7\n\t"
+    "psllw $2,%%mm6\n\t"
+    /*mm1=t6'=t1-t6*/
+    "psubw %%mm6,%%mm1\n\t"
+    "psllw $2,%%mm2\n\t"
+    "paddw %%mm6,%%mm6\n\t"
+    "psllw $2,%%mm5\n\t"
+    /*mm2=t5'=t2-t5*/
+    "psubw %%mm5,%%mm2\n\t"
+    "psllw $2,%%mm3\n\t"
+    "paddw %%mm5,%%mm5\n\t"
+    "psllw $2,%%mm4\n\t"
+    /*mm3=t4'=t3-t4*/
+    "psubw %%mm4,%%mm3\n\t"
+    "paddw %%mm4,%%mm4\n\t"
+    /*mm7=t0'=t0+t7*/
+    "paddw %%mm0,%%mm7\n\t"
+    /*mm6=t1'=t1+t6*/
+    "paddw %%mm1,%%mm6\n\t"
+    /*mm5=t2'=t2+t5*/
+    "paddw %%mm2,%%mm5\n\t"
+    /*mm4=t3'=t3+t4*/
+    "paddw %%mm3,%%mm4\n\t"
+    OC_FDCT8x4("0x08","0x18","0x28","0x38","0x48","0x58","0x68","0x78")
+    OC_TRANSPOSE8x4("0x08","0x18","0x28","0x38","0x48","0x58","0x68","0x78")
+    /*Here the first 4x4 block of output from the last transpose is the second
+       4x4 block of input for the next transform.
+      We have cleverly arranged that it already be in the appropriate place,
+       so we only have to do half the stores and loads.*/
+    "movq 0x00(%[y]),%%mm0\n\t"
+    "movq %%mm1,0x58(%[y])\n\t"
+    "movq 0x10(%[y]),%%mm1\n\t"
+    "movq %%mm2,0x68(%[y])\n\t"
+    "movq 0x20(%[y]),%%mm2\n\t"
+    "movq %%mm3,0x78(%[y])\n\t"
+    "movq 0x30(%[y]),%%mm3\n\t"
+    OC_FDCT_STAGE1_8x4
+    OC_FDCT8x4("0x00","0x10","0x20","0x30","0x08","0x18","0x28","0x38")
+    OC_TRANSPOSE8x4("0x00","0x10","0x20","0x30","0x08","0x18","0x28","0x38")
+    /*mm0={-2}x4*/
+    "pcmpeqw %%mm0,%%mm0\n\t"
+    "paddw %%mm0,%%mm0\n\t"
+    /*Round the results.*/
+    "psubw %%mm0,%%mm1\n\t"
+    "psubw %%mm0,%%mm2\n\t"
+    "psraw $2,%%mm1\n\t"
+    "psubw %%mm0,%%mm3\n\t"
+    "movq %%mm1,0x18(%[y])\n\t"
+    "psraw $2,%%mm2\n\t"
+    "psubw %%mm0,%%mm4\n\t"
+    "movq 0x08(%[y]),%%mm1\n\t"
+    "psraw $2,%%mm3\n\t"
+    "psubw %%mm0,%%mm5\n\t"
+    "psraw $2,%%mm4\n\t"
+    "psubw %%mm0,%%mm6\n\t"
+    "psraw $2,%%mm5\n\t"
+    "psubw %%mm0,%%mm7\n\t"
+    "psraw $2,%%mm6\n\t"
+    "psubw %%mm0,%%mm1\n\t"
+    "psraw $2,%%mm7\n\t"
+    "movq 0x40(%[y]),%%mm0\n\t"
+    "psraw $2,%%mm1\n\t"
+    "movq %%mm7,0x30(%[y])\n\t"
+    "movq 0x78(%[y]),%%mm7\n\t"
+    "movq %%mm1,0x08(%[y])\n\t"
+    "movq 0x50(%[y]),%%mm1\n\t"
+    "movq %%mm6,0x20(%[y])\n\t"
+    "movq 0x68(%[y]),%%mm6\n\t"
+    "movq %%mm2,0x28(%[y])\n\t"
+    "movq 0x60(%[y]),%%mm2\n\t"
+    "movq %%mm5,0x10(%[y])\n\t"
+    "movq 0x58(%[y]),%%mm5\n\t"
+    "movq %%mm3,0x38(%[y])\n\t"
+    "movq 0x70(%[y]),%%mm3\n\t"
+    "movq %%mm4,0x00(%[y])\n\t"
+    "movq 0x48(%[y]),%%mm4\n\t"
+    OC_FDCT_STAGE1_8x4
+    OC_FDCT8x4("0x40","0x50","0x60","0x70","0x48","0x58","0x68","0x78")
+    OC_TRANSPOSE8x4("0x40","0x50","0x60","0x70","0x48","0x58","0x68","0x78")
+    /*mm0={-2}x4*/
+    "pcmpeqw %%mm0,%%mm0\n\t"
+    "paddw %%mm0,%%mm0\n\t"
+    /*Round the results.*/
+    "psubw %%mm0,%%mm1\n\t"
+    "psubw %%mm0,%%mm2\n\t"
+    "psraw $2,%%mm1\n\t"
+    "psubw %%mm0,%%mm3\n\t"
+    "movq %%mm1,0x58(%[y])\n\t"
+    "psraw $2,%%mm2\n\t"
+    "psubw %%mm0,%%mm4\n\t"
+    "movq 0x48(%[y]),%%mm1\n\t"
+    "psraw $2,%%mm3\n\t"
+    "psubw %%mm0,%%mm5\n\t"
+    "movq %%mm2,0x68(%[y])\n\t"
+    "psraw $2,%%mm4\n\t"
+    "psubw %%mm0,%%mm6\n\t"
+    "movq %%mm3,0x78(%[y])\n\t"
+    "psraw $2,%%mm5\n\t"
+    "psubw %%mm0,%%mm7\n\t"
+    "movq %%mm4,0x40(%[y])\n\t"
+    "psraw $2,%%mm6\n\t"
+    "psubw %%mm0,%%mm1\n\t"
+    "movq %%mm5,0x50(%[y])\n\t"
+    "psraw $2,%%mm7\n\t"
+    "movq %%mm6,0x60(%[y])\n\t"
+    "psraw $2,%%mm1\n\t"
+    "movq %%mm7,0x70(%[y])\n\t"
+    "movq %%mm1,0x48(%[y])\n\t"
+    :[a]"=&r"(a)
+    :[y]"r"(_y),[x]"r"(_x)
+    :"memory"
+  );
+}
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/sse2fdct.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/sse2fdct.c
new file mode 100644
index 0000000..f451dc2
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/sse2fdct.c
@@ -0,0 +1,518 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 1999-2006                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************/
+/*SSE2 fDCT implementation for x86_64.*/
+/*$Id: fdct_ses2.c 14579 2008-03-12 06:42:40Z xiphmont $*/
+#include <stddef.h>
+#include "x86enc.h"
+
+#if defined(OC_X86_64_ASM)
+
+# define OC_FDCT8x8 \
+ /*Note: xmm15={0}x8 and xmm14={-1}x8.*/ \
+ "#OC_FDCT8x8\n\t" \
+ /*Stage 1:*/ \
+ "movdqa %%xmm0,%%xmm11\n\t" \
+ "movdqa %%xmm1,%%xmm10\n\t" \
+ "movdqa %%xmm2,%%xmm9\n\t" \
+ "movdqa %%xmm3,%%xmm8\n\t" \
+ /*xmm11=t7'=t0-t7*/ \
+ "psubw %%xmm7,%%xmm11\n\t" \
+ /*xmm10=t6'=t1-t6*/ \
+ "psubw %%xmm6,%%xmm10\n\t" \
+ /*xmm9=t5'=t2-t5*/ \
+ "psubw %%xmm5,%%xmm9\n\t" \
+ /*xmm8=t4'=t3-t4*/ \
+ "psubw %%xmm4,%%xmm8\n\t" \
+ /*xmm0=t0'=t0+t7*/ \
+ "paddw %%xmm7,%%xmm0\n\t" \
+ /*xmm1=t1'=t1+t6*/ \
+ "paddw %%xmm6,%%xmm1\n\t" \
+ /*xmm5=t2'=t2+t5*/ \
+ "paddw %%xmm2,%%xmm5\n\t" \
+ /*xmm4=t3'=t3+t4*/ \
+ "paddw %%xmm3,%%xmm4\n\t" \
+ /*xmm2,3,6,7 are now free.*/ \
+ /*Stage 2:*/ \
+ "movdqa %%xmm0,%%xmm3\n\t" \
+ "mov $0x5A806A0A,%[a]\n\t" \
+ "movdqa %%xmm1,%%xmm2\n\t" \
+ "movd %[a],%%xmm13\n\t" \
+ "movdqa %%xmm10,%%xmm6\n\t" \
+ "pshufd $00,%%xmm13,%%xmm13\n\t" \
+ /*xmm2=t2''=t1'-t2'*/ \
+ "psubw %%xmm5,%%xmm2\n\t" \
+ "pxor %%xmm12,%%xmm12\n\t" \
+ /*xmm3=t3''=t0'-t3'*/ \
+ "psubw %%xmm4,%%xmm3\n\t" \
+ "psubw %%xmm14,%%xmm12\n\t" \
+ /*xmm10=t5''=t6'-t5'*/ \
+ "psubw %%xmm9,%%xmm10\n\t" \
+ "paddw %%xmm12,%%xmm12\n\t" \
+ /*xmm4=t0''=t0'+t3'*/ \
+ "paddw %%xmm0,%%xmm4\n\t" \
+ /*xmm1=t1''=t1'+t2'*/ \
+ "paddw %%xmm5,%%xmm1\n\t" \
+ /*xmm6=t6''=t6'+t5'*/ \
+ "paddw %%xmm9,%%xmm6\n\t" \
+ /*xmm0,xmm5,xmm9 are now free.*/ \
+ /*Stage 3:*/ \
+ /*xmm10:xmm5=t5''*27146+0xB500 \
+   xmm0=t5''*/ \
+ "movdqa %%xmm10,%%xmm5\n\t" \
+ "movdqa %%xmm10,%%xmm0\n\t" \
+ "punpckhwd %%xmm12,%%xmm10\n\t" \
+ "pmaddwd %%xmm13,%%xmm10\n\t" \
+ "punpcklwd %%xmm12,%%xmm5\n\t" \
+ "pmaddwd %%xmm13,%%xmm5\n\t" \
+ /*xmm5=(t5''*27146+0xB500>>16)+t5''*/ \
+ "psrad $16,%%xmm10\n\t" \
+ "psrad $16,%%xmm5\n\t" \
+ "packssdw %%xmm10,%%xmm5\n\t" \
+ "paddw %%xmm0,%%xmm5\n\t" \
+ /*xmm0=s=(t5''*27146+0xB500>>16)+t5''+(t5''!=0)>>1*/ \
+ "pcmpeqw %%xmm15,%%xmm0\n\t" \
+ "psubw %%xmm14,%%xmm0\n\t" \
+ "paddw %%xmm5,%%xmm0\n\t" \
+ "movdqa %%xmm8,%%xmm5\n\t" \
+ "psraw $1,%%xmm0\n\t" \
+ /*xmm5=t5'''=t4'-s*/ \
+ "psubw %%xmm0,%%xmm5\n\t" \
+ /*xmm8=t4''=t4'+s*/ \
+ "paddw %%xmm0,%%xmm8\n\t" \
+ /*xmm0,xmm7,xmm9,xmm10 are free.*/ \
+ /*xmm7:xmm9=t6''*27146+0xB500*/ \
+ "movdqa %%xmm6,%%xmm7\n\t" \
+ "movdqa %%xmm6,%%xmm9\n\t" \
+ "punpckhwd %%xmm12,%%xmm7\n\t" \
+ "pmaddwd %%xmm13,%%xmm7\n\t" \
+ "punpcklwd %%xmm12,%%xmm9\n\t" \
+ "pmaddwd %%xmm13,%%xmm9\n\t" \
+ /*xmm9=(t6''*27146+0xB500>>16)+t6''*/ \
+ "psrad $16,%%xmm7\n\t" \
+ "psrad $16,%%xmm9\n\t" \
+ "packssdw %%xmm7,%%xmm9\n\t" \
+ "paddw %%xmm6,%%xmm9\n\t" \
+ /*xmm9=s=(t6''*27146+0xB500>>16)+t6''+(t6''!=0)>>1*/ \
+ "pcmpeqw %%xmm15,%%xmm6\n\t" \
+ "psubw %%xmm14,%%xmm6\n\t" \
+ "paddw %%xmm6,%%xmm9\n\t" \
+ "movdqa %%xmm11,%%xmm7\n\t" \
+ "psraw $1,%%xmm9\n\t" \
+ /*xmm7=t6'''=t7'-s*/ \
+ "psubw %%xmm9,%%xmm7\n\t" \
+ /*xmm9=t7''=t7'+s*/ \
+ "paddw %%xmm11,%%xmm9\n\t" \
+ /*xmm0,xmm6,xmm10,xmm11 are free.*/ \
+ /*Stage 4:*/ \
+ /*xmm10:xmm0=t1''*27146+0xB500*/ \
+ "movdqa %%xmm1,%%xmm0\n\t" \
+ "movdqa %%xmm1,%%xmm10\n\t" \
+ "punpcklwd %%xmm12,%%xmm0\n\t" \
+ "pmaddwd %%xmm13,%%xmm0\n\t" \
+ "punpckhwd %%xmm12,%%xmm10\n\t" \
+ "pmaddwd %%xmm13,%%xmm10\n\t" \
+ /*xmm0=(t1''*27146+0xB500>>16)+t1''*/ \
+ "psrad $16,%%xmm0\n\t" \
+ "psrad $16,%%xmm10\n\t" \
+ "mov $0x20006A0A,%[a]\n\t" \
+ "packssdw %%xmm10,%%xmm0\n\t" \
+ "movd %[a],%%xmm13\n\t" \
+ "paddw %%xmm1,%%xmm0\n\t" \
+ /*xmm0=s=(t1''*27146+0xB500>>16)+t1''+(t1''!=0)*/ \
+ "pcmpeqw %%xmm15,%%xmm1\n\t" \
+ "pshufd $00,%%xmm13,%%xmm13\n\t" \
+ "psubw %%xmm14,%%xmm1\n\t" \
+ "paddw %%xmm1,%%xmm0\n\t" \
+ /*xmm10:xmm4=t0''*27146+0x4000*/ \
+ "movdqa %%xmm4,%%xmm1\n\t" \
+ "movdqa %%xmm4,%%xmm10\n\t" \
+ "punpcklwd %%xmm12,%%xmm4\n\t" \
+ "pmaddwd %%xmm13,%%xmm4\n\t" \
+ "punpckhwd %%xmm12,%%xmm10\n\t" \
+ "pmaddwd %%xmm13,%%xmm10\n\t" \
+ /*xmm4=(t0''*27146+0x4000>>16)+t0''*/ \
+ "psrad $16,%%xmm4\n\t" \
+ "psrad $16,%%xmm10\n\t" \
+ "mov $0x6CB7,%[a]\n\t" \
+ "packssdw %%xmm10,%%xmm4\n\t" \
+ "movd %[a],%%xmm12\n\t" \
+ "paddw %%xmm1,%%xmm4\n\t" \
+ /*xmm4=r=(t0''*27146+0x4000>>16)+t0''+(t0''!=0)*/ \
+ "pcmpeqw %%xmm15,%%xmm1\n\t" \
+ "pshufd $00,%%xmm12,%%xmm12\n\t" \
+ "psubw %%xmm14,%%xmm1\n\t" \
+ "mov $0x7FFF6C84,%[a]\n\t" \
+ "paddw %%xmm1,%%xmm4\n\t" \
+ /*xmm0=_y[0]=u=r+s>>1*/ \
+ "paddw %%xmm4,%%xmm0\n\t" \
+ "movd %[a],%%xmm13\n\t" \
+ "psraw $1,%%xmm0\n\t" \
+ /*xmm4=_y[4]=v=r-u*/ \
+ "pshufd $00,%%xmm13,%%xmm13\n\t" \
+ "psubw %%xmm0,%%xmm4\n\t" \
+ /*xmm1,xmm6,xmm10,xmm11 are free.*/ \
+ /*xmm6:xmm10=60547*t3''+0x6CB7*/ \
+ "movdqa %%xmm3,%%xmm10\n\t" \
+ "movdqa %%xmm3,%%xmm6\n\t" \
+ "punpcklwd %%xmm3,%%xmm10\n\t" \
+ "pmaddwd %%xmm13,%%xmm10\n\t" \
+ "mov $0x61F861F8,%[a]\n\t" \
+ "punpckhwd %%xmm3,%%xmm6\n\t" \
+ "pmaddwd %%xmm13,%%xmm6\n\t" \
+ "movd %[a],%%xmm13\n\t" \
+ "paddd %%xmm12,%%xmm10\n\t" \
+ "pshufd $00,%%xmm13,%%xmm13\n\t" \
+ "paddd %%xmm12,%%xmm6\n\t" \
+ /*xmm1:xmm2=25080*t2'' \
+   xmm12=t2''*/ \
+ "movdqa %%xmm2,%%xmm11\n\t" \
+ "movdqa %%xmm2,%%xmm12\n\t" \
+ "pmullw %%xmm13,%%xmm2\n\t" \
+ "pmulhw %%xmm13,%%xmm11\n\t" \
+ "movdqa %%xmm2,%%xmm1\n\t" \
+ "punpcklwd %%xmm11,%%xmm2\n\t" \
+ "punpckhwd %%xmm11,%%xmm1\n\t" \
+ /*xmm10=u=(25080*t2''+60547*t3''+0x6CB7>>16)+(t3''!=0)*/ \
+ "paddd %%xmm2,%%xmm10\n\t" \
+ "paddd %%xmm1,%%xmm6\n\t" \
+ "psrad $16,%%xmm10\n\t" \
+ "pcmpeqw %%xmm15,%%xmm3\n\t" \
+ "psrad $16,%%xmm6\n\t" \
+ "psubw %%xmm14,%%xmm3\n\t" \
+ "packssdw %%xmm6,%%xmm10\n\t" \
+ "paddw %%xmm3,%%xmm10\n\t" \
+ /*xmm2=_y[2]=u \
+   xmm10=s=(25080*u>>16)-t2''*/ \
+ "movdqa %%xmm10,%%xmm2\n\t" \
+ "pmulhw %%xmm13,%%xmm10\n\t" \
+ "psubw %%xmm12,%%xmm10\n\t" \
+ /*xmm1:xmm6=s*21600+0x2800*/ \
+ "pxor %%xmm12,%%xmm12\n\t" \
+ "psubw %%xmm14,%%xmm12\n\t" \
+ "mov $0x28005460,%[a]\n\t" \
+ "movd %[a],%%xmm13\n\t" \
+ "pshufd $00,%%xmm13,%%xmm13\n\t" \
+ "movdqa %%xmm10,%%xmm6\n\t" \
+ "movdqa %%xmm10,%%xmm1\n\t" \
+ "punpcklwd %%xmm12,%%xmm6\n\t" \
+ "pmaddwd %%xmm13,%%xmm6\n\t" \
+ "mov $0x0E3D,%[a]\n\t" \
+ "punpckhwd %%xmm12,%%xmm1\n\t" \
+ "pmaddwd %%xmm13,%%xmm1\n\t" \
+ /*xmm6=(s*21600+0x2800>>18)+s*/ \
+ "psrad $18,%%xmm6\n\t" \
+ "psrad $18,%%xmm1\n\t" \
+ "movd %[a],%%xmm12\n\t" \
+ "packssdw %%xmm1,%%xmm6\n\t" \
+ "pshufd $00,%%xmm12,%%xmm12\n\t" \
+ "paddw %%xmm10,%%xmm6\n\t" \
+ /*xmm6=_y[6]=v=(s*21600+0x2800>>18)+s+(s!=0)*/ \
+ "mov $0x7FFF54DC,%[a]\n\t" \
+ "pcmpeqw %%xmm15,%%xmm10\n\t" \
+ "movd %[a],%%xmm13\n\t" \
+ "psubw %%xmm14,%%xmm10\n\t" \
+ "pshufd $00,%%xmm13,%%xmm13\n\t" \
+ "paddw %%xmm10,%%xmm6\n\t " \
+ /*xmm1,xmm3,xmm10,xmm11 are free.*/ \
+ /*xmm11:xmm10=54491*t5'''+0x0E3D*/ \
+ "movdqa %%xmm5,%%xmm10\n\t" \
+ "movdqa %%xmm5,%%xmm11\n\t" \
+ "punpcklwd %%xmm5,%%xmm10\n\t" \
+ "pmaddwd %%xmm13,%%xmm10\n\t" \
+ "mov $0x8E3A8E3A,%[a]\n\t" \
+ "punpckhwd %%xmm5,%%xmm11\n\t" \
+ "pmaddwd %%xmm13,%%xmm11\n\t" \
+ "movd %[a],%%xmm13\n\t" \
+ "paddd %%xmm12,%%xmm10\n\t" \
+ "pshufd $00,%%xmm13,%%xmm13\n\t" \
+ "paddd %%xmm12,%%xmm11\n\t" \
+ /*xmm7:xmm12=36410*t6''' \
+   xmm1=t6'''*/ \
+ "movdqa %%xmm7,%%xmm3\n\t" \
+ "movdqa %%xmm7,%%xmm1\n\t" \
+ "pmulhw %%xmm13,%%xmm3\n\t" \
+ "pmullw %%xmm13,%%xmm7\n\t" \
+ "paddw %%xmm1,%%xmm3\n\t" \
+ "movdqa %%xmm7,%%xmm12\n\t" \
+ "punpckhwd %%xmm3,%%xmm7\n\t" \
+ "punpcklwd %%xmm3,%%xmm12\n\t" \
+ /*xmm10=u=(54491*t5'''+36410*t6'''+0x0E3D>>16)+(t5'''!=0)*/ \
+ "paddd %%xmm12,%%xmm10\n\t" \
+ "paddd %%xmm7,%%xmm11\n\t" \
+ "psrad $16,%%xmm10\n\t" \
+ "pcmpeqw %%xmm15,%%xmm5\n\t" \
+ "psrad $16,%%xmm11\n\t" \
+ "psubw %%xmm14,%%xmm5\n\t" \
+ "packssdw %%xmm11,%%xmm10\n\t" \
+ "pxor %%xmm12,%%xmm12\n\t" \
+ "paddw %%xmm5,%%xmm10\n\t" \
+ /*xmm5=_y[5]=u \
+   xmm1=s=t6'''-(36410*u>>16)*/ \
+ "psubw %%xmm14,%%xmm12\n\t" \
+ "movdqa %%xmm10,%%xmm5\n\t" \
+ "mov $0x340067C8,%[a]\n\t" \
+ "pmulhw %%xmm13,%%xmm10\n\t" \
+ "movd %[a],%%xmm13\n\t" \
+ "paddw %%xmm5,%%xmm10\n\t" \
+ "pshufd $00,%%xmm13,%%xmm13\n\t" \
+ "psubw %%xmm10,%%xmm1\n\t" \
+ /*xmm11:xmm3=s*26568+0x3400*/ \
+ "movdqa %%xmm1,%%xmm3\n\t" \
+ "movdqa %%xmm1,%%xmm11\n\t" \
+ "punpcklwd %%xmm12,%%xmm3\n\t" \
+ "pmaddwd %%xmm13,%%xmm3\n\t" \
+ "mov $0x7B1B,%[a]\n\t" \
+ "punpckhwd %%xmm12,%%xmm11\n\t" \
+ "pmaddwd %%xmm13,%%xmm11\n\t" \
+ /*xmm3=(s*26568+0x3400>>17)+s*/ \
+ "psrad $17,%%xmm3\n\t" \
+ "psrad $17,%%xmm11\n\t" \
+ "movd %[a],%%xmm12\n\t" \
+ "packssdw %%xmm11,%%xmm3\n\t" \
+ "pshufd $00,%%xmm12,%%xmm12\n\t" \
+ "paddw %%xmm1,%%xmm3\n\t" \
+ /*xmm3=_y[3]=v=(s*26568+0x3400>>17)+s+(s!=0)*/ \
+ "mov $0x7FFF7B16,%[a]\n\t" \
+ "pcmpeqw %%xmm15,%%xmm1\n\t" \
+ "movd %[a],%%xmm13\n\t" \
+ "psubw %%xmm14,%%xmm1\n\t" \
+ "pshufd $00,%%xmm13,%%xmm13\n\t" \
+ "paddw %%xmm1,%%xmm3\n\t " \
+ /*xmm1,xmm7,xmm10,xmm11 are free.*/ \
+ /*xmm11:xmm10=64277*t7''+0x7B1B*/ \
+ "movdqa %%xmm9,%%xmm10\n\t" \
+ "movdqa %%xmm9,%%xmm11\n\t" \
+ "punpcklwd %%xmm9,%%xmm10\n\t" \
+ "pmaddwd %%xmm13,%%xmm10\n\t" \
+ "mov $0x31F131F1,%[a]\n\t" \
+ "punpckhwd %%xmm9,%%xmm11\n\t" \
+ "pmaddwd %%xmm13,%%xmm11\n\t" \
+ "movd %[a],%%xmm13\n\t" \
+ "paddd %%xmm12,%%xmm10\n\t" \
+ "pshufd $00,%%xmm13,%%xmm13\n\t" \
+ "paddd %%xmm12,%%xmm11\n\t" \
+ /*xmm12:xmm7=12785*t4''*/ \
+ "movdqa %%xmm8,%%xmm7\n\t" \
+ "movdqa %%xmm8,%%xmm1\n\t" \
+ "pmullw %%xmm13,%%xmm7\n\t" \
+ "pmulhw %%xmm13,%%xmm1\n\t" \
+ "movdqa %%xmm7,%%xmm12\n\t" \
+ "punpcklwd %%xmm1,%%xmm7\n\t" \
+ "punpckhwd %%xmm1,%%xmm12\n\t" \
+ /*xmm10=u=(12785*t4''+64277*t7''+0x7B1B>>16)+(t7''!=0)*/ \
+ "paddd %%xmm7,%%xmm10\n\t" \
+ "paddd %%xmm12,%%xmm11\n\t" \
+ "psrad $16,%%xmm10\n\t" \
+ "pcmpeqw %%xmm15,%%xmm9\n\t" \
+ "psrad $16,%%xmm11\n\t" \
+ "psubw %%xmm14,%%xmm9\n\t" \
+ "packssdw %%xmm11,%%xmm10\n\t" \
+ "pxor %%xmm12,%%xmm12\n\t" \
+ "paddw %%xmm9,%%xmm10\n\t" \
+ /*xmm1=_y[1]=u \
+   xmm10=s=(12785*u>>16)-t4''*/ \
+ "psubw %%xmm14,%%xmm12\n\t" \
+ "movdqa %%xmm10,%%xmm1\n\t" \
+ "mov $0x3000503B,%[a]\n\t" \
+ "pmulhw %%xmm13,%%xmm10\n\t" \
+ "movd %[a],%%xmm13\n\t" \
+ "psubw %%xmm8,%%xmm10\n\t" \
+ "pshufd $00,%%xmm13,%%xmm13\n\t" \
+ /*xmm8:xmm7=s*20539+0x3000*/ \
+ "movdqa %%xmm10,%%xmm7\n\t" \
+ "movdqa %%xmm10,%%xmm8\n\t" \
+ "punpcklwd %%xmm12,%%xmm7\n\t" \
+ "pmaddwd %%xmm13,%%xmm7\n\t" \
+ "punpckhwd %%xmm12,%%xmm8\n\t" \
+ "pmaddwd %%xmm13,%%xmm8\n\t" \
+ /*xmm7=(s*20539+0x3000>>20)+s*/ \
+ "psrad $20,%%xmm7\n\t" \
+ "psrad $20,%%xmm8\n\t" \
+ "packssdw %%xmm8,%%xmm7\n\t" \
+ "paddw %%xmm10,%%xmm7\n\t" \
+ /*xmm7=_y[7]=v=(s*20539+0x3000>>20)+s+(s!=0)*/ \
+ "pcmpeqw %%xmm15,%%xmm10\n\t" \
+ "psubw %%xmm14,%%xmm10\n\t" \
+ "paddw %%xmm10,%%xmm7\n\t " \
+
+# define OC_TRANSPOSE8x8 \
+ "#OC_TRANSPOSE8x8\n\t" \
+ "movdqa %%xmm4,%%xmm8\n\t" \
+ /*xmm4 = f3 e3 f2 e2 f1 e1 f0 e0*/ \
+ "punpcklwd %%xmm5,%%xmm4\n\t" \
+ /*xmm8 = f7 e7 f6 e6 f5 e5 f4 e4*/ \
+ "punpckhwd %%xmm5,%%xmm8\n\t" \
+ /*xmm5 is free.*/ \
+ "movdqa %%xmm0,%%xmm5\n\t" \
+ /*xmm0 = b3 a3 b2 a2 b1 a1 b0 a0*/ \
+ "punpcklwd %%xmm1,%%xmm0\n\t" \
+ /*xmm5 = b7 a7 b6 a6 b5 a5 b4 a4*/ \
+ "punpckhwd %%xmm1,%%xmm5\n\t" \
+ /*xmm1 is free.*/ \
+ "movdqa %%xmm6,%%xmm1\n\t" \
+ /*xmm6 = h3 g3 h2 g2 h1 g1 h0 g0*/ \
+ "punpcklwd %%xmm7,%%xmm6\n\t" \
+ /*xmm1 = h7 g7 h6 g6 h5 g5 h4 g4*/ \
+ "punpckhwd %%xmm7,%%xmm1\n\t" \
+ /*xmm7 is free.*/ \
+ "movdqa %%xmm2,%%xmm7\n\t" \
+ /*xmm7 = d3 c3 d2 c2 d1 c1 d0 c0*/ \
+ "punpcklwd %%xmm3,%%xmm7\n\t" \
+ /*xmm2 = d7 c7 d6 c6 d5 c5 d4 c4*/ \
+ "punpckhwd %%xmm3,%%xmm2\n\t" \
+ /*xmm3 is free.*/ \
+ "movdqa %%xmm0,%%xmm3\n\t" \
+ /*xmm0 = d1 c1 b1 a1 d0 c0 b0 a0*/ \
+ "punpckldq %%xmm7,%%xmm0\n\t" \
+ /*xmm3 = d3 c3 b3 a3 d2 c2 b2 a2*/ \
+ "punpckhdq %%xmm7,%%xmm3\n\t" \
+ /*xmm7 is free.*/ \
+ "movdqa %%xmm5,%%xmm7\n\t" \
+ /*xmm5 = d5 c5 b5 a5 d4 c4 b4 a4*/ \
+ "punpckldq %%xmm2,%%xmm5\n\t" \
+ /*xmm7 = d7 c7 b7 a7 d6 c6 b6 a6*/ \
+ "punpckhdq %%xmm2,%%xmm7\n\t" \
+ /*xmm2 is free.*/ \
+ "movdqa %%xmm4,%%xmm2\n\t" \
+ /*xmm2 = h1 g1 f1 e1 h0 g0 f0 e0*/ \
+ "punpckldq %%xmm6,%%xmm2\n\t" \
+ /*xmm4 = h3 g3 f3 e3 h2 g2 f2 e2*/ \
+ "punpckhdq %%xmm6,%%xmm4\n\t" \
+ /*xmm6 is free.*/ \
+ "movdqa %%xmm8,%%xmm6\n\t" \
+ /*xmm6 = h5 g5 f5 e5 h4 g4 f4 e4*/ \
+ "punpckldq %%xmm1,%%xmm6\n\t" \
+ /*xmm8 = h7 g7 f7 e7 h6 g6 f6 e6*/ \
+ "punpckhdq %%xmm1,%%xmm8\n\t" \
+ /*xmm1 is free.*/ \
+ "movdqa %%xmm0,%%xmm1\n\t" \
+ /*xmm0 = h0 g0 f0 e0 d0 c0 b0 a0*/ \
+ "punpcklqdq %%xmm2,%%xmm0\n\t" \
+ /*xmm1 = h1 g1 f1 e1 d1 c1 b1 a1*/ \
+ "punpckhqdq %%xmm2,%%xmm1\n\t" \
+ /*xmm2 is free.*/ \
+ "movdqa %%xmm3,%%xmm2\n\t" \
+ /*xmm2 = h2 g2 f2 e2 d2 c2 b2 a2*/ \
+ "punpcklqdq %%xmm4,%%xmm2\n\t" \
+ /*xmm3 = h3 g3 f3 e3 d3 c3 b3 a3*/ \
+ "punpckhqdq %%xmm4,%%xmm3\n\t" \
+ /*xmm4 is free.*/ \
+ "movdqa %%xmm5,%%xmm4\n\t" \
+ /*xmm4 = h4 g4 f4 e4 d4 c4 b4 a4*/ \
+ "punpcklqdq %%xmm6,%%xmm4\n\t" \
+ /*xmm5 = h5 g5 f5 e5 d5 c5 b5 a5*/ \
+ "punpckhqdq %%xmm6,%%xmm5\n\t" \
+ /*xmm6 is free.*/ \
+ "movdqa %%xmm7,%%xmm6\n\t" \
+ /*xmm6 = h6 g6 f6 e6 d6 c6 b6 a6*/ \
+ "punpcklqdq %%xmm8,%%xmm6\n\t" \
+ /*xmm7 = h7 g7 f7 e7 d7 c7 b7 a7*/ \
+ "punpckhqdq %%xmm8,%%xmm7\n\t" \
+ /*xmm8 is free.*/ \
+
+/*SSE2 implementation of the fDCT for x86-64 only.
+  Because of the 8 extra XMM registers on x86-64, this version can operate
+   without any temporary stack access at all.*/
+void oc_enc_fdct8x8_x86_64sse2(ogg_int16_t _y[64],const ogg_int16_t _x[64]){
+  ptrdiff_t a;
+  __asm__ __volatile__(
+    /*Load the input.*/
+    "movdqa 0x00(%[x]),%%xmm0\n\t"
+    "movdqa 0x10(%[x]),%%xmm1\n\t"
+    "movdqa 0x20(%[x]),%%xmm2\n\t"
+    "movdqa 0x30(%[x]),%%xmm3\n\t"
+    "movdqa 0x40(%[x]),%%xmm4\n\t"
+    "movdqa 0x50(%[x]),%%xmm5\n\t"
+    "movdqa 0x60(%[x]),%%xmm6\n\t"
+    "movdqa 0x70(%[x]),%%xmm7\n\t"
+    /*Add two extra bits of working precision to improve accuracy; any more and
+       we could overflow.*/
+    /*We also add a few biases to correct for some systematic error that
+       remains in the full fDCT->iDCT round trip.*/
+    /*xmm15={0}x8*/
+    "pxor %%xmm15,%%xmm15\n\t"
+    /*xmm14={-1}x8*/
+    "pcmpeqb %%xmm14,%%xmm14\n\t"
+    "psllw $2,%%xmm0\n\t"
+    /*xmm8=xmm0*/
+    "movdqa %%xmm0,%%xmm8\n\t"
+    "psllw $2,%%xmm1\n\t"
+    /*xmm8={_x[7...0]==0}*/
+    "pcmpeqw %%xmm15,%%xmm8\n\t"
+    "psllw $2,%%xmm2\n\t"
+    /*xmm8={_x[7...0]!=0}*/
+    "psubw %%xmm14,%%xmm8\n\t"
+    "psllw $2,%%xmm3\n\t"
+    /*%[a]=1*/
+    "mov $1,%[a]\n\t"
+    /*xmm8={_x[6]!=0,0,_x[4]!=0,0,_x[2]!=0,0,_x[0]!=0,0}*/
+    "pslld $16,%%xmm8\n\t"
+    "psllw $2,%%xmm4\n\t"
+    /*xmm9={0,0,0,0,0,0,0,1}*/
+    "movd %[a],%%xmm9\n\t"
+    /*xmm8={0,0,_x[2]!=0,0,_x[0]!=0,0}*/
+    "pshufhw $0x00,%%xmm8,%%xmm8\n\t"
+    "psllw $2,%%xmm5\n\t"
+    /*%[a]={1}x2*/
+    "mov $0x10001,%[a]\n\t"
+    /*xmm8={0,0,0,0,0,0,0,_x[0]!=0}*/
+    "pshuflw $0x01,%%xmm8,%%xmm8\n\t"
+    "psllw $2,%%xmm6\n\t"
+    /*xmm10={0,0,0,0,0,0,1,1}*/
+    "movd %[a],%%xmm10\n\t"
+    /*xmm0=_x[7...0]+{0,0,0,0,0,0,0,_x[0]!=0}*/
+    "paddw %%xmm8,%%xmm0\n\t"
+    "psllw $2,%%xmm7\n\t"
+    /*xmm0=_x[7...0]+{0,0,0,0,0,0,1,(_x[0]!=0)+1}*/
+    "paddw %%xmm10,%%xmm0\n\t"
+    /*xmm1=_x[15...8]-{0,0,0,0,0,0,0,1}*/
+    "psubw %%xmm9,%%xmm1\n\t"
+    /*Transform columns.*/
+    OC_FDCT8x8
+    /*Transform rows.*/
+    OC_TRANSPOSE8x8
+    OC_FDCT8x8
+    /*TODO: zig-zag ordering?*/
+    OC_TRANSPOSE8x8
+    /*xmm14={-2,-2,-2,-2,-2,-2,-2,-2}*/
+    "paddw %%xmm14,%%xmm14\n\t"
+    "psubw %%xmm14,%%xmm0\n\t"
+    "psubw %%xmm14,%%xmm1\n\t"
+    "psraw $2,%%xmm0\n\t"
+    "psubw %%xmm14,%%xmm2\n\t"
+    "psraw $2,%%xmm1\n\t"
+    "psubw %%xmm14,%%xmm3\n\t"
+    "psraw $2,%%xmm2\n\t"
+    "psubw %%xmm14,%%xmm4\n\t"
+    "psraw $2,%%xmm3\n\t"
+    "psubw %%xmm14,%%xmm5\n\t"
+    "psraw $2,%%xmm4\n\t"
+    "psubw %%xmm14,%%xmm6\n\t"
+    "psraw $2,%%xmm5\n\t"
+    "psubw %%xmm14,%%xmm7\n\t"
+    "psraw $2,%%xmm6\n\t"
+    "psraw $2,%%xmm7\n\t"
+    /*Store the result.*/
+    "movdqa %%xmm0,0x00(%[y])\n\t"
+    "movdqa %%xmm1,0x10(%[y])\n\t"
+    "movdqa %%xmm2,0x20(%[y])\n\t"
+    "movdqa %%xmm3,0x30(%[y])\n\t"
+    "movdqa %%xmm4,0x40(%[y])\n\t"
+    "movdqa %%xmm5,0x50(%[y])\n\t"
+    "movdqa %%xmm6,0x60(%[y])\n\t"
+    "movdqa %%xmm7,0x70(%[y])\n\t"
+    :[a]"=&r"(a)
+    :[y]"r"(_y),[x]"r"(_x)
+    :"memory"
+  );
+}
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/x86enc.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/x86enc.c
new file mode 100644
index 0000000..b2f5487
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/x86enc.c
@@ -0,0 +1,53 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: x86state.c 15675 2009-02-06 09:43:27Z tterribe $
+
+ ********************************************************************/
+#include "x86enc.h"
+
+#if defined(OC_X86_ASM)
+
+#include "../../cpu.c"
+
+void oc_enc_vtable_init_x86(CP_INSTANCE *_cpi){
+  ogg_uint32_t cpu_flags;
+  cpu_flags=oc_cpu_flags_get();
+  oc_enc_vtable_init_c(_cpi);
+  if(cpu_flags&OC_CPU_X86_MMX){
+    _cpi->opt_vtable.frag_sub=oc_enc_frag_sub_mmx;
+    _cpi->opt_vtable.frag_sub_128=oc_enc_frag_sub_128_mmx;
+    _cpi->opt_vtable.frag_copy=oc_frag_copy_mmx;
+    _cpi->opt_vtable.frag_recon_intra=oc_frag_recon_intra_mmx;
+    _cpi->opt_vtable.frag_recon_inter=oc_frag_recon_inter_mmx;
+    _cpi->opt_vtable.fdct8x8=oc_enc_fdct8x8_mmx;
+    _cpi->opt_vtable.dequant_idct8x8=oc_dequant_idct8x8_mmx;
+    _cpi->opt_vtable.enc_loop_filter=oc_enc_loop_filter_mmx;
+    _cpi->opt_vtable.restore_fpu=oc_restore_fpu_mmx;
+  }
+  if(cpu_flags&OC_CPU_X86_MMXEXT){
+    _cpi->opt_vtable.frag_sad=oc_enc_frag_sad_mmxext;
+    _cpi->opt_vtable.frag_sad_thresh=oc_enc_frag_sad_thresh_mmxext;
+    _cpi->opt_vtable.frag_sad2_thresh=oc_enc_frag_sad2_thresh_mmxext;
+    _cpi->opt_vtable.frag_satd_thresh=oc_enc_frag_satd_thresh_mmxext;
+    _cpi->opt_vtable.frag_satd2_thresh=oc_enc_frag_satd2_thresh_mmxext;
+    _cpi->opt_vtable.frag_intra_satd=oc_enc_frag_intra_satd_mmxext;
+    _cpi->opt_vtable.frag_copy2=oc_enc_frag_copy2_mmxext;
+  }
+  if(cpu_flags&OC_CPU_X86_SSE2){
+# if defined(OC_X86_64_ASM)
+    _cpi->opt_vtable.fdct8x8=oc_enc_fdct8x8_x86_64sse2;
+# endif
+  }
+}
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/x86enc.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/x86enc.h
new file mode 100644
index 0000000..c466555
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86/x86enc.h
@@ -0,0 +1,48 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2009                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: x86int.h 15675 2009-02-06 09:43:27Z tterribe $
+
+ ********************************************************************/
+
+#if !defined(_x86_x86enc_H)
+# define _x86_x86enc_H (1)
+# include "../codec_internal.h"
+# include "../../dec/x86/x86int.h"
+
+void oc_enc_vtable_init_x86(CP_INSTANCE *_cpi);
+
+unsigned oc_enc_frag_sad_mmxext(const unsigned char *_src,
+ const unsigned char *_ref,int _ystride);
+unsigned oc_enc_frag_sad_thresh_mmxext(const unsigned char *_src,
+ const unsigned char *_ref,int _ystride,unsigned _thresh);
+unsigned oc_enc_frag_sad2_thresh_mmxext(const unsigned char *_src,
+ const unsigned char *_ref1,const unsigned char *_ref2,int _ystride,
+ unsigned _thresh);
+unsigned oc_enc_frag_satd_thresh_mmxext(const unsigned char *_src,
+ const unsigned char *_ref,int _ystride,unsigned _thresh);
+unsigned oc_enc_frag_satd2_thresh_mmxext(const unsigned char *_src,
+ const unsigned char *_ref1,const unsigned char *_ref2,int _ystride,
+ unsigned _thresh);
+unsigned oc_enc_frag_intra_satd_mmxext(const unsigned char *_src,int _ystride);
+void oc_enc_frag_sub_mmx(ogg_int16_t _diff[64],
+ const unsigned char *_x,const unsigned char *_y,int _stride);
+void oc_enc_frag_sub_128_mmx(ogg_int16_t _diff[64],
+ const unsigned char *_x,int _stride);
+void oc_enc_frag_copy2_mmxext(unsigned char *_dst,
+ const unsigned char *_src1,const unsigned char *_src2,int _ystride);
+void oc_enc_fdct8x8_mmx(ogg_int16_t _y[64],const ogg_int16_t _x[64]);
+void oc_enc_fdct8x8_x86_64sse2(ogg_int16_t _y[64],const ogg_int16_t _x[64]);
+void oc_enc_loop_filter_mmx(CP_INSTANCE *_cpi,int _flimit);
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86_32_vs/dsp_mmx.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86_32_vs/dsp_mmx.c
new file mode 100644
index 0000000..4cec7ed
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86_32_vs/dsp_mmx.c
@@ -0,0 +1,1603 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: mcomp.c,v 1.8 2003/12/03 08:59:41 arc Exp $
+
+ ********************************************************************/
+
+#include <stdlib.h>
+
+#include "codec_internal.h"
+#include "dsp.h"
+
+#if 0
+//These are to let me selectively enable the C versions, these are needed
+#define DSP_OP_AVG(a,b) ((((int)(a)) + ((int)(b)))/2)
+#define DSP_OP_DIFF(a,b) (((int)(a)) - ((int)(b)))
+#define DSP_OP_ABS_DIFF(a,b) abs((((int)(a)) - ((int)(b))))
+#endif
+
+
+static const ogg_int64_t V128 = 0x0080008000800080;
+
+static void sub8x8__mmx (unsigned char *FiltPtr, unsigned char *ReconPtr,
+			 ogg_int16_t *DctInputPtr, ogg_uint32_t PixelsPerLine)
+{
+
+    //Make non-zero to use the C-version
+#if 0
+  int i;
+
+  /* For each block row */
+  for (i=8; i; i--) {
+    DctInputPtr[0] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[0], ReconPtr[0]);
+    DctInputPtr[1] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[1], ReconPtr[1]);
+    DctInputPtr[2] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[2], ReconPtr[2]);
+    DctInputPtr[3] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[3], ReconPtr[3]);
+    DctInputPtr[4] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[4], ReconPtr[4]);
+    DctInputPtr[5] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[5], ReconPtr[5]);
+    DctInputPtr[6] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[6], ReconPtr[6]);
+    DctInputPtr[7] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[7], ReconPtr[7]);
+
+    /* Start next row */
+    FiltPtr += PixelsPerLine;
+    ReconPtr += PixelsPerLine;
+    DctInputPtr += 8;
+  }
+#else
+    __asm {
+        align 16
+
+        pxor		mm7, mm7	
+
+        mov     eax, FiltPtr
+        mov     ebx, ReconPtr
+        mov     edx, DctInputPtr
+
+     /* You can't use rept in inline masm and macro parsing seems screwed with inline asm*/		
+     
+     /* ITERATION 1 */
+        movq		mm0, [eax]		/* mm0 = FiltPtr */
+        movq		mm1, [ebx]		/* mm1 = ReconPtr */
+        movq		mm2, mm0		/* dup to prepare for up conversion */
+        movq		mm3, mm1		/* dup to prepare for up conversion */
+        /* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		/* mm0 = INT16(FiltPtr) */
+        punpcklbw		mm1, mm7		/* mm1 = INT16(ReconPtr) */
+        punpckhbw		mm2, mm7		/* mm2 = INT16(FiltPtr) */
+        punpckhbw		mm3, mm7		/* mm3 = INT16(ReconPtr) */
+        /* start calculation */
+        psubw		mm0, mm1		/* mm0 = FiltPtr - ReconPtr */
+        psubw		mm2, mm3		/* mm2 = FiltPtr - ReconPtr */
+        movq		[edx], mm0		/* write answer out */
+        movq		[8 + edx], mm2		/* write answer out */
+        /* Increment pointers */
+        add		edx, 16		
+        add		eax, PixelsPerLine		
+        add		ebx, PixelsPerLine
+
+
+     /* ITERATION 2 */
+        movq		mm0, [eax]		/* mm0 = FiltPtr */
+        movq		mm1, [ebx]		/* mm1 = ReconPtr */
+        movq		mm2, mm0		/* dup to prepare for up conversion */
+        movq		mm3, mm1		/* dup to prepare for up conversion */
+        /* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		/* mm0 = INT16(FiltPtr) */
+        punpcklbw		mm1, mm7		/* mm1 = INT16(ReconPtr) */
+        punpckhbw		mm2, mm7		/* mm2 = INT16(FiltPtr) */
+        punpckhbw		mm3, mm7		/* mm3 = INT16(ReconPtr) */
+        /* start calculation */
+        psubw		mm0, mm1		/* mm0 = FiltPtr - ReconPtr */
+        psubw		mm2, mm3		/* mm2 = FiltPtr - ReconPtr */
+        movq		[edx], mm0		/* write answer out */
+        movq		[8 + edx], mm2		/* write answer out */
+        /* Increment pointers */
+        add		edx, 16		
+        add		eax, PixelsPerLine		
+        add		ebx, PixelsPerLine
+
+
+     /* ITERATION 3 */
+        movq		mm0, [eax]		/* mm0 = FiltPtr */
+        movq		mm1, [ebx]		/* mm1 = ReconPtr */
+        movq		mm2, mm0		/* dup to prepare for up conversion */
+        movq		mm3, mm1		/* dup to prepare for up conversion */
+        /* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		/* mm0 = INT16(FiltPtr) */
+        punpcklbw		mm1, mm7		/* mm1 = INT16(ReconPtr) */
+        punpckhbw		mm2, mm7		/* mm2 = INT16(FiltPtr) */
+        punpckhbw		mm3, mm7		/* mm3 = INT16(ReconPtr) */
+        /* start calculation */
+        psubw		mm0, mm1		/* mm0 = FiltPtr - ReconPtr */
+        psubw		mm2, mm3		/* mm2 = FiltPtr - ReconPtr */
+        movq		[edx], mm0		/* write answer out */
+        movq		[8 + edx], mm2		/* write answer out */
+        /* Increment pointers */
+        add		edx, 16		
+        add		eax, PixelsPerLine		
+        add		ebx, PixelsPerLine
+
+
+     /* ITERATION 4 */
+        movq		mm0, [eax]		/* mm0 = FiltPtr */
+        movq		mm1, [ebx]		/* mm1 = ReconPtr */
+        movq		mm2, mm0		/* dup to prepare for up conversion */
+        movq		mm3, mm1		/* dup to prepare for up conversion */
+        /* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		/* mm0 = INT16(FiltPtr) */
+        punpcklbw		mm1, mm7		/* mm1 = INT16(ReconPtr) */
+        punpckhbw		mm2, mm7		/* mm2 = INT16(FiltPtr) */
+        punpckhbw		mm3, mm7		/* mm3 = INT16(ReconPtr) */
+        /* start calculation */
+        psubw		mm0, mm1		/* mm0 = FiltPtr - ReconPtr */
+        psubw		mm2, mm3		/* mm2 = FiltPtr - ReconPtr */
+        movq		[edx], mm0		/* write answer out */
+        movq		[8 + edx], mm2		/* write answer out */
+        /* Increment pointers */
+        add		edx, 16		
+        add		eax, PixelsPerLine		
+        add		ebx, PixelsPerLine
+
+
+     /* ITERATION 5 */
+        movq		mm0, [eax]		/* mm0 = FiltPtr */
+        movq		mm1, [ebx]		/* mm1 = ReconPtr */
+        movq		mm2, mm0		/* dup to prepare for up conversion */
+        movq		mm3, mm1		/* dup to prepare for up conversion */
+        /* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		/* mm0 = INT16(FiltPtr) */
+        punpcklbw		mm1, mm7		/* mm1 = INT16(ReconPtr) */
+        punpckhbw		mm2, mm7		/* mm2 = INT16(FiltPtr) */
+        punpckhbw		mm3, mm7		/* mm3 = INT16(ReconPtr) */
+        /* start calculation */
+        psubw		mm0, mm1		/* mm0 = FiltPtr - ReconPtr */
+        psubw		mm2, mm3		/* mm2 = FiltPtr - ReconPtr */
+        movq		[edx], mm0		/* write answer out */
+        movq		[8 + edx], mm2		/* write answer out */
+        /* Increment pointers */
+        add		edx, 16		
+        add		eax, PixelsPerLine		
+        add		ebx, PixelsPerLine
+
+
+     /* ITERATION 6 */
+        movq		mm0, [eax]		/* mm0 = FiltPtr */
+        movq		mm1, [ebx]		/* mm1 = ReconPtr */
+        movq		mm2, mm0		/* dup to prepare for up conversion */
+        movq		mm3, mm1		/* dup to prepare for up conversion */
+        /* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		/* mm0 = INT16(FiltPtr) */
+        punpcklbw		mm1, mm7		/* mm1 = INT16(ReconPtr) */
+        punpckhbw		mm2, mm7		/* mm2 = INT16(FiltPtr) */
+        punpckhbw		mm3, mm7		/* mm3 = INT16(ReconPtr) */
+        /* start calculation */
+        psubw		mm0, mm1		/* mm0 = FiltPtr - ReconPtr */
+        psubw		mm2, mm3		/* mm2 = FiltPtr - ReconPtr */
+        movq		[edx], mm0		/* write answer out */
+        movq		[8 + edx], mm2		/* write answer out */
+        /* Increment pointers */
+        add		edx, 16		
+        add		eax, PixelsPerLine		
+        add		ebx, PixelsPerLine
+
+
+     /* ITERATION 7 */
+        movq		mm0, [eax]		/* mm0 = FiltPtr */
+        movq		mm1, [ebx]		/* mm1 = ReconPtr */
+        movq		mm2, mm0		/* dup to prepare for up conversion */
+        movq		mm3, mm1		/* dup to prepare for up conversion */
+        /* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		/* mm0 = INT16(FiltPtr) */
+        punpcklbw		mm1, mm7		/* mm1 = INT16(ReconPtr) */
+        punpckhbw		mm2, mm7		/* mm2 = INT16(FiltPtr) */
+        punpckhbw		mm3, mm7		/* mm3 = INT16(ReconPtr) */
+        /* start calculation */
+        psubw		mm0, mm1		/* mm0 = FiltPtr - ReconPtr */
+        psubw		mm2, mm3		/* mm2 = FiltPtr - ReconPtr */
+        movq		[edx], mm0		/* write answer out */
+        movq		[8 + edx], mm2		/* write answer out */
+        /* Increment pointers */
+        add		edx, 16		
+        add		eax, PixelsPerLine		
+        add		ebx, PixelsPerLine
+
+
+     /* ITERATION 8 */
+        movq		mm0, [eax]		/* mm0 = FiltPtr */
+        movq		mm1, [ebx]		/* mm1 = ReconPtr */
+        movq		mm2, mm0		/* dup to prepare for up conversion */
+        movq		mm3, mm1		/* dup to prepare for up conversion */
+        /* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		/* mm0 = INT16(FiltPtr) */
+        punpcklbw		mm1, mm7		/* mm1 = INT16(ReconPtr) */
+        punpckhbw		mm2, mm7		/* mm2 = INT16(FiltPtr) */
+        punpckhbw		mm3, mm7		/* mm3 = INT16(ReconPtr) */
+        /* start calculation */
+        psubw		mm0, mm1		/* mm0 = FiltPtr - ReconPtr */
+        psubw		mm2, mm3		/* mm2 = FiltPtr - ReconPtr */
+        movq		[edx], mm0		/* write answer out */
+        movq		[8 + edx], mm2		/* write answer out */
+        /* Increment pointers */
+        add		edx, 16		
+        add		eax, PixelsPerLine		
+        add		ebx, PixelsPerLine
+
+
+
+     
+
+    };
+ 
+#endif
+}
+
+static void sub8x8_128__mmx (unsigned char *FiltPtr, ogg_int16_t *DctInputPtr,
+			     ogg_uint32_t PixelsPerLine) 
+{
+
+#if 0
+  int i;
+  /* For each block row */
+  for (i=8; i; i--) {
+    /* INTRA mode so code raw image data */
+    /* We convert the data to 8 bit signed (by subtracting 128) as
+       this reduces the internal precision requirments in the DCT
+       transform. */
+    DctInputPtr[0] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[0], 128);
+    DctInputPtr[1] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[1], 128);
+    DctInputPtr[2] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[2], 128);
+    DctInputPtr[3] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[3], 128);
+    DctInputPtr[4] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[4], 128);
+    DctInputPtr[5] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[5], 128);
+    DctInputPtr[6] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[6], 128);
+    DctInputPtr[7] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[7], 128);
+
+    /* Start next row */
+    FiltPtr += PixelsPerLine;
+    DctInputPtr += 8;
+  }
+
+#else
+    __asm {
+        align 16
+
+        pxor		mm7, mm7		
+
+        mov         eax, FiltPtr
+        mov         ebx, DctInputPtr
+
+        movq		mm1, V128
+
+        /*  ITERATION 1 */		
+        movq		mm0, [eax]		/* mm0 = FiltPtr */
+        movq		mm2, mm0		/* dup to prepare for up conversion */
+        /* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		/* mm0 = INT16(FiltPtr) */
+        punpckhbw		mm2, mm7		/* mm2 = INT16(FiltPtr) */
+        /* start calculation */
+        psubw		mm0, mm1		/* mm0 = FiltPtr - 128 */
+        psubw		mm2, mm1		/* mm2 = FiltPtr - 128 */
+        movq		[ebx], mm0		/* write answer out */
+        movq		[8 + ebx], mm2		/* write answer out */
+        /* Increment pointers */
+        add		ebx, 16		
+        add		eax, PixelsPerLine	
+
+
+        /*  ITERATION 2 */		
+        movq		mm0, [eax]		/* mm0 = FiltPtr */
+        movq		mm2, mm0		/* dup to prepare for up conversion */
+        /* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		/* mm0 = INT16(FiltPtr) */
+        punpckhbw		mm2, mm7		/* mm2 = INT16(FiltPtr) */
+        /* start calculation */
+        psubw		mm0, mm1		/* mm0 = FiltPtr - 128 */
+        psubw		mm2, mm1		/* mm2 = FiltPtr - 128 */
+        movq		[ebx], mm0		/* write answer out */
+        movq		[8 + ebx], mm2		/* write answer out */
+        /* Increment pointers */
+        add		ebx, 16		
+        add		eax, PixelsPerLine	
+
+
+        /*  ITERATION 3 */		
+        movq		mm0, [eax]		/* mm0 = FiltPtr */
+        movq		mm2, mm0		/* dup to prepare for up conversion */
+        /* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		/* mm0 = INT16(FiltPtr) */
+        punpckhbw		mm2, mm7		/* mm2 = INT16(FiltPtr) */
+        /* start calculation */
+        psubw		mm0, mm1		/* mm0 = FiltPtr - 128 */
+        psubw		mm2, mm1		/* mm2 = FiltPtr - 128 */
+        movq		[ebx], mm0		/* write answer out */
+        movq		[8 + ebx], mm2		/* write answer out */
+        /* Increment pointers */
+        add		ebx, 16		
+        add		eax, PixelsPerLine	
+
+
+        /*  ITERATION 4 */		
+        movq		mm0, [eax]		/* mm0 = FiltPtr */
+        movq		mm2, mm0		/* dup to prepare for up conversion */
+        /* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		/* mm0 = INT16(FiltPtr) */
+        punpckhbw		mm2, mm7		/* mm2 = INT16(FiltPtr) */
+        /* start calculation */
+        psubw		mm0, mm1		/* mm0 = FiltPtr - 128 */
+        psubw		mm2, mm1		/* mm2 = FiltPtr - 128 */
+        movq		[ebx], mm0		/* write answer out */
+        movq		[8 + ebx], mm2		/* write answer out */
+        /* Increment pointers */
+        add		ebx, 16		
+        add		eax, PixelsPerLine	
+
+
+        /*  ITERATION 5 */		
+        movq		mm0, [eax]		/* mm0 = FiltPtr */
+        movq		mm2, mm0		/* dup to prepare for up conversion */
+        /* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		/* mm0 = INT16(FiltPtr) */
+        punpckhbw		mm2, mm7		/* mm2 = INT16(FiltPtr) */
+        /* start calculation */
+        psubw		mm0, mm1		/* mm0 = FiltPtr - 128 */
+        psubw		mm2, mm1		/* mm2 = FiltPtr - 128 */
+        movq		[ebx], mm0		/* write answer out */
+        movq		[8 + ebx], mm2		/* write answer out */
+        /* Increment pointers */
+        add		ebx, 16		
+        add		eax, PixelsPerLine	
+
+
+        /*  ITERATION 6 */		
+        movq		mm0, [eax]		/* mm0 = FiltPtr */
+        movq		mm2, mm0		/* dup to prepare for up conversion */
+        /* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		/* mm0 = INT16(FiltPtr) */
+        punpckhbw		mm2, mm7		/* mm2 = INT16(FiltPtr) */
+        /* start calculation */
+        psubw		mm0, mm1		/* mm0 = FiltPtr - 128 */
+        psubw		mm2, mm1		/* mm2 = FiltPtr - 128 */
+        movq		[ebx], mm0		/* write answer out */
+        movq		[8 + ebx], mm2		/* write answer out */
+        /* Increment pointers */
+        add		ebx, 16		
+        add		eax, PixelsPerLine	
+
+
+        /*  ITERATION 7 */		
+        movq		mm0, [eax]		/* mm0 = FiltPtr */
+        movq		mm2, mm0		/* dup to prepare for up conversion */
+        /* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		/* mm0 = INT16(FiltPtr) */
+        punpckhbw		mm2, mm7		/* mm2 = INT16(FiltPtr) */
+        /* start calculation */
+        psubw		mm0, mm1		/* mm0 = FiltPtr - 128 */
+        psubw		mm2, mm1		/* mm2 = FiltPtr - 128 */
+        movq		[ebx], mm0		/* write answer out */
+        movq		[8 + ebx], mm2		/* write answer out */
+        /* Increment pointers */
+        add		ebx, 16		
+        add		eax, PixelsPerLine	
+
+
+        /*  ITERATION 8 */		
+        movq		mm0, [eax]		/* mm0 = FiltPtr */
+        movq		mm2, mm0		/* dup to prepare for up conversion */
+        /* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		/* mm0 = INT16(FiltPtr) */
+        punpckhbw		mm2, mm7		/* mm2 = INT16(FiltPtr) */
+        /* start calculation */
+        psubw		mm0, mm1		/* mm0 = FiltPtr - 128 */
+        psubw		mm2, mm1		/* mm2 = FiltPtr - 128 */
+        movq		[ebx], mm0		/* write answer out */
+        movq		[8 + ebx], mm2		/* write answer out */
+        /* Increment pointers */
+        add		ebx, 16		
+        add		eax, PixelsPerLine	
+
+    };
+ 
+#endif
+}
+
+
+
+
+static void sub8x8avg2__mmx (unsigned char *FiltPtr, unsigned char *ReconPtr1,
+			     unsigned char *ReconPtr2, ogg_int16_t *DctInputPtr,
+			     ogg_uint32_t PixelsPerLine)
+{
+
+#if 0
+  int i;
+
+  /* For each block row */
+  for (i=8; i; i--) {
+    DctInputPtr[0] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[0], DSP_OP_AVG (ReconPtr1[0], ReconPtr2[0]));
+    DctInputPtr[1] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[1], DSP_OP_AVG (ReconPtr1[1], ReconPtr2[1]));
+    DctInputPtr[2] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[2], DSP_OP_AVG (ReconPtr1[2], ReconPtr2[2]));
+    DctInputPtr[3] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[3], DSP_OP_AVG (ReconPtr1[3], ReconPtr2[3]));
+    DctInputPtr[4] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[4], DSP_OP_AVG (ReconPtr1[4], ReconPtr2[4]));
+    DctInputPtr[5] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[5], DSP_OP_AVG (ReconPtr1[5], ReconPtr2[5]));
+    DctInputPtr[6] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[6], DSP_OP_AVG (ReconPtr1[6], ReconPtr2[6]));
+    DctInputPtr[7] = (ogg_int16_t) DSP_OP_DIFF (FiltPtr[7], DSP_OP_AVG (ReconPtr1[7], ReconPtr2[7]));
+
+    /* Start next row */
+    FiltPtr += PixelsPerLine;
+    ReconPtr1 += PixelsPerLine;
+    ReconPtr2 += PixelsPerLine;
+    DctInputPtr += 8;
+  }
+#else
+
+    __asm {
+        align 16
+
+            pxor        mm7, mm7
+
+        mov         eax, FiltPtr
+        mov         ebx, ReconPtr1
+        mov         ecx, ReconPtr2
+        mov         edx, DctInputPtr
+
+        /*  ITERATION 1 */	
+        movq		mm0, [eax]		;	/* mm0 = FiltPtr */
+        movq		mm1, [ebx]		;	/* mm1 = ReconPtr1 */
+        movq		mm4, [ecx]		;	/* mm1 = ReconPtr2 */
+        movq		mm2, mm0		;	/* dup to prepare for up conversion */
+        movq		mm3, mm1		;	/* dup to prepare for up conversion */
+        movq		mm5, mm4		;	/* dup to prepare for up conversion */
+	        ;	/* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		;	/* mm0 = INT16(FiltPtr) */
+        punpcklbw		mm1, mm7		;	/* mm1 = INT16(ReconPtr1) */
+        punpcklbw		mm4, mm7		;	/* mm1 = INT16(ReconPtr2) */
+        punpckhbw		mm2, mm7		;	/* mm2 = INT16(FiltPtr) */
+        punpckhbw		mm3, mm7		;	/* mm3 = INT16(ReconPtr1) */
+        punpckhbw		mm5, mm7		;	/* mm3 = INT16(ReconPtr2) */
+	        ;	/* average ReconPtr1 and ReconPtr2 */
+        paddw		mm1, mm4		;	/* mm1 = ReconPtr1 + ReconPtr2 */
+        paddw		mm3, mm5		;	/* mm3 = ReconPtr1 + ReconPtr2 */
+        psrlw		mm1, 1		;	/* mm1 = (ReconPtr1 + ReconPtr2) / 2 */
+        psrlw		mm3, 1		;	/* mm3 = (ReconPtr1 + ReconPtr2) / 2 */
+        psubw		mm0, mm1		;	/* mm0 = FiltPtr - ((ReconPtr1 + ReconPtr2) / 2) */
+        psubw		mm2, mm3		;	/* mm2 = FiltPtr - ((ReconPtr1 + ReconPtr2) / 2) */
+        movq		[edx], mm0		;	/* write answer out */
+        movq		[8 + edx], mm2		;	/* write answer out */
+	        ;	/* Increment pointers */
+        add		edx, 16		;	
+        add		eax, PixelsPerLine		;	
+        add		ebx, PixelsPerLine		;	
+        add		ecx, PixelsPerLine		;	
+	
+
+        /*  ITERATION 2 */	
+        movq		mm0, [eax]		;	/* mm0 = FiltPtr */
+        movq		mm1, [ebx]		;	/* mm1 = ReconPtr1 */
+        movq		mm4, [ecx]		;	/* mm1 = ReconPtr2 */
+        movq		mm2, mm0		;	/* dup to prepare for up conversion */
+        movq		mm3, mm1		;	/* dup to prepare for up conversion */
+        movq		mm5, mm4		;	/* dup to prepare for up conversion */
+	        ;	/* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		;	/* mm0 = INT16(FiltPtr) */
+        punpcklbw		mm1, mm7		;	/* mm1 = INT16(ReconPtr1) */
+        punpcklbw		mm4, mm7		;	/* mm1 = INT16(ReconPtr2) */
+        punpckhbw		mm2, mm7		;	/* mm2 = INT16(FiltPtr) */
+        punpckhbw		mm3, mm7		;	/* mm3 = INT16(ReconPtr1) */
+        punpckhbw		mm5, mm7		;	/* mm3 = INT16(ReconPtr2) */
+	        ;	/* average ReconPtr1 and ReconPtr2 */
+        paddw		mm1, mm4		;	/* mm1 = ReconPtr1 + ReconPtr2 */
+        paddw		mm3, mm5		;	/* mm3 = ReconPtr1 + ReconPtr2 */
+        psrlw		mm1, 1		;	/* mm1 = (ReconPtr1 + ReconPtr2) / 2 */
+        psrlw		mm3, 1		;	/* mm3 = (ReconPtr1 + ReconPtr2) / 2 */
+        psubw		mm0, mm1		;	/* mm0 = FiltPtr - ((ReconPtr1 + ReconPtr2) / 2) */
+        psubw		mm2, mm3		;	/* mm2 = FiltPtr - ((ReconPtr1 + ReconPtr2) / 2) */
+        movq		[edx], mm0		;	/* write answer out */
+        movq		[8 + edx], mm2		;	/* write answer out */
+	        ;	/* Increment pointers */
+        add		edx, 16		;	
+        add		eax, PixelsPerLine		;	
+        add		ebx, PixelsPerLine		;	
+        add		ecx, PixelsPerLine		;	
+
+
+        /*  ITERATION 3 */	
+        movq		mm0, [eax]		;	/* mm0 = FiltPtr */
+        movq		mm1, [ebx]		;	/* mm1 = ReconPtr1 */
+        movq		mm4, [ecx]		;	/* mm1 = ReconPtr2 */
+        movq		mm2, mm0		;	/* dup to prepare for up conversion */
+        movq		mm3, mm1		;	/* dup to prepare for up conversion */
+        movq		mm5, mm4		;	/* dup to prepare for up conversion */
+	        ;	/* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		;	/* mm0 = INT16(FiltPtr) */
+        punpcklbw		mm1, mm7		;	/* mm1 = INT16(ReconPtr1) */
+        punpcklbw		mm4, mm7		;	/* mm1 = INT16(ReconPtr2) */
+        punpckhbw		mm2, mm7		;	/* mm2 = INT16(FiltPtr) */
+        punpckhbw		mm3, mm7		;	/* mm3 = INT16(ReconPtr1) */
+        punpckhbw		mm5, mm7		;	/* mm3 = INT16(ReconPtr2) */
+	        ;	/* average ReconPtr1 and ReconPtr2 */
+        paddw		mm1, mm4		;	/* mm1 = ReconPtr1 + ReconPtr2 */
+        paddw		mm3, mm5		;	/* mm3 = ReconPtr1 + ReconPtr2 */
+        psrlw		mm1, 1		;	/* mm1 = (ReconPtr1 + ReconPtr2) / 2 */
+        psrlw		mm3, 1		;	/* mm3 = (ReconPtr1 + ReconPtr2) / 2 */
+        psubw		mm0, mm1		;	/* mm0 = FiltPtr - ((ReconPtr1 + ReconPtr2) / 2) */
+        psubw		mm2, mm3		;	/* mm2 = FiltPtr - ((ReconPtr1 + ReconPtr2) / 2) */
+        movq		[edx], mm0		;	/* write answer out */
+        movq		[8 + edx], mm2		;	/* write answer out */
+	        ;	/* Increment pointers */
+        add		edx, 16		;	
+        add		eax, PixelsPerLine		;	
+        add		ebx, PixelsPerLine		;	
+        add		ecx, PixelsPerLine		;	
+
+
+        /*  ITERATION 4 */	
+        movq		mm0, [eax]		;	/* mm0 = FiltPtr */
+        movq		mm1, [ebx]		;	/* mm1 = ReconPtr1 */
+        movq		mm4, [ecx]		;	/* mm1 = ReconPtr2 */
+        movq		mm2, mm0		;	/* dup to prepare for up conversion */
+        movq		mm3, mm1		;	/* dup to prepare for up conversion */
+        movq		mm5, mm4		;	/* dup to prepare for up conversion */
+	        ;	/* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		;	/* mm0 = INT16(FiltPtr) */
+        punpcklbw		mm1, mm7		;	/* mm1 = INT16(ReconPtr1) */
+        punpcklbw		mm4, mm7		;	/* mm1 = INT16(ReconPtr2) */
+        punpckhbw		mm2, mm7		;	/* mm2 = INT16(FiltPtr) */
+        punpckhbw		mm3, mm7		;	/* mm3 = INT16(ReconPtr1) */
+        punpckhbw		mm5, mm7		;	/* mm3 = INT16(ReconPtr2) */
+	        ;	/* average ReconPtr1 and ReconPtr2 */
+        paddw		mm1, mm4		;	/* mm1 = ReconPtr1 + ReconPtr2 */
+        paddw		mm3, mm5		;	/* mm3 = ReconPtr1 + ReconPtr2 */
+        psrlw		mm1, 1		;	/* mm1 = (ReconPtr1 + ReconPtr2) / 2 */
+        psrlw		mm3, 1		;	/* mm3 = (ReconPtr1 + ReconPtr2) / 2 */
+        psubw		mm0, mm1		;	/* mm0 = FiltPtr - ((ReconPtr1 + ReconPtr2) / 2) */
+        psubw		mm2, mm3		;	/* mm2 = FiltPtr - ((ReconPtr1 + ReconPtr2) / 2) */
+        movq		[edx], mm0		;	/* write answer out */
+        movq		[8 + edx], mm2		;	/* write answer out */
+	        ;	/* Increment pointers */
+        add		edx, 16		;	
+        add		eax, PixelsPerLine		;	
+        add		ebx, PixelsPerLine		;	
+        add		ecx, PixelsPerLine		;	
+
+
+        /*  ITERATION 5 */	
+        movq		mm0, [eax]		;	/* mm0 = FiltPtr */
+        movq		mm1, [ebx]		;	/* mm1 = ReconPtr1 */
+        movq		mm4, [ecx]		;	/* mm1 = ReconPtr2 */
+        movq		mm2, mm0		;	/* dup to prepare for up conversion */
+        movq		mm3, mm1		;	/* dup to prepare for up conversion */
+        movq		mm5, mm4		;	/* dup to prepare for up conversion */
+	        ;	/* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		;	/* mm0 = INT16(FiltPtr) */
+        punpcklbw		mm1, mm7		;	/* mm1 = INT16(ReconPtr1) */
+        punpcklbw		mm4, mm7		;	/* mm1 = INT16(ReconPtr2) */
+        punpckhbw		mm2, mm7		;	/* mm2 = INT16(FiltPtr) */
+        punpckhbw		mm3, mm7		;	/* mm3 = INT16(ReconPtr1) */
+        punpckhbw		mm5, mm7		;	/* mm3 = INT16(ReconPtr2) */
+	        ;	/* average ReconPtr1 and ReconPtr2 */
+        paddw		mm1, mm4		;	/* mm1 = ReconPtr1 + ReconPtr2 */
+        paddw		mm3, mm5		;	/* mm3 = ReconPtr1 + ReconPtr2 */
+        psrlw		mm1, 1		;	/* mm1 = (ReconPtr1 + ReconPtr2) / 2 */
+        psrlw		mm3, 1		;	/* mm3 = (ReconPtr1 + ReconPtr2) / 2 */
+        psubw		mm0, mm1		;	/* mm0 = FiltPtr - ((ReconPtr1 + ReconPtr2) / 2) */
+        psubw		mm2, mm3		;	/* mm2 = FiltPtr - ((ReconPtr1 + ReconPtr2) / 2) */
+        movq		[edx], mm0		;	/* write answer out */
+        movq		[8 + edx], mm2		;	/* write answer out */
+	        ;	/* Increment pointers */
+        add		edx, 16		;	
+        add		eax, PixelsPerLine		;	
+        add		ebx, PixelsPerLine		;	
+        add		ecx, PixelsPerLine		;	
+
+
+        /*  ITERATION 6 */	
+        movq		mm0, [eax]		;	/* mm0 = FiltPtr */
+        movq		mm1, [ebx]		;	/* mm1 = ReconPtr1 */
+        movq		mm4, [ecx]		;	/* mm1 = ReconPtr2 */
+        movq		mm2, mm0		;	/* dup to prepare for up conversion */
+        movq		mm3, mm1		;	/* dup to prepare for up conversion */
+        movq		mm5, mm4		;	/* dup to prepare for up conversion */
+	        ;	/* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		;	/* mm0 = INT16(FiltPtr) */
+        punpcklbw		mm1, mm7		;	/* mm1 = INT16(ReconPtr1) */
+        punpcklbw		mm4, mm7		;	/* mm1 = INT16(ReconPtr2) */
+        punpckhbw		mm2, mm7		;	/* mm2 = INT16(FiltPtr) */
+        punpckhbw		mm3, mm7		;	/* mm3 = INT16(ReconPtr1) */
+        punpckhbw		mm5, mm7		;	/* mm3 = INT16(ReconPtr2) */
+	        ;	/* average ReconPtr1 and ReconPtr2 */
+        paddw		mm1, mm4		;	/* mm1 = ReconPtr1 + ReconPtr2 */
+        paddw		mm3, mm5		;	/* mm3 = ReconPtr1 + ReconPtr2 */
+        psrlw		mm1, 1		;	/* mm1 = (ReconPtr1 + ReconPtr2) / 2 */
+        psrlw		mm3, 1		;	/* mm3 = (ReconPtr1 + ReconPtr2) / 2 */
+        psubw		mm0, mm1		;	/* mm0 = FiltPtr - ((ReconPtr1 + ReconPtr2) / 2) */
+        psubw		mm2, mm3		;	/* mm2 = FiltPtr - ((ReconPtr1 + ReconPtr2) / 2) */
+        movq		[edx], mm0		;	/* write answer out */
+        movq		[8 + edx], mm2		;	/* write answer out */
+	        ;	/* Increment pointers */
+        add		edx, 16		;	
+        add		eax, PixelsPerLine		;	
+        add		ebx, PixelsPerLine		;	
+        add		ecx, PixelsPerLine		;	
+
+
+        /*  ITERATION 7 */	
+        movq		mm0, [eax]		;	/* mm0 = FiltPtr */
+        movq		mm1, [ebx]		;	/* mm1 = ReconPtr1 */
+        movq		mm4, [ecx]		;	/* mm1 = ReconPtr2 */
+        movq		mm2, mm0		;	/* dup to prepare for up conversion */
+        movq		mm3, mm1		;	/* dup to prepare for up conversion */
+        movq		mm5, mm4		;	/* dup to prepare for up conversion */
+	        ;	/* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		;	/* mm0 = INT16(FiltPtr) */
+        punpcklbw		mm1, mm7		;	/* mm1 = INT16(ReconPtr1) */
+        punpcklbw		mm4, mm7		;	/* mm1 = INT16(ReconPtr2) */
+        punpckhbw		mm2, mm7		;	/* mm2 = INT16(FiltPtr) */
+        punpckhbw		mm3, mm7		;	/* mm3 = INT16(ReconPtr1) */
+        punpckhbw		mm5, mm7		;	/* mm3 = INT16(ReconPtr2) */
+	        ;	/* average ReconPtr1 and ReconPtr2 */
+        paddw		mm1, mm4		;	/* mm1 = ReconPtr1 + ReconPtr2 */
+        paddw		mm3, mm5		;	/* mm3 = ReconPtr1 + ReconPtr2 */
+        psrlw		mm1, 1		;	/* mm1 = (ReconPtr1 + ReconPtr2) / 2 */
+        psrlw		mm3, 1		;	/* mm3 = (ReconPtr1 + ReconPtr2) / 2 */
+        psubw		mm0, mm1		;	/* mm0 = FiltPtr - ((ReconPtr1 + ReconPtr2) / 2) */
+        psubw		mm2, mm3		;	/* mm2 = FiltPtr - ((ReconPtr1 + ReconPtr2) / 2) */
+        movq		[edx], mm0		;	/* write answer out */
+        movq		[8 + edx], mm2		;	/* write answer out */
+	        ;	/* Increment pointers */
+        add		edx, 16		;	
+        add		eax, PixelsPerLine		;	
+        add		ebx, PixelsPerLine		;	
+        add		ecx, PixelsPerLine		;	
+
+
+        /*  ITERATION 8 */	
+        movq		mm0, [eax]		;	/* mm0 = FiltPtr */
+        movq		mm1, [ebx]		;	/* mm1 = ReconPtr1 */
+        movq		mm4, [ecx]		;	/* mm1 = ReconPtr2 */
+        movq		mm2, mm0		;	/* dup to prepare for up conversion */
+        movq		mm3, mm1		;	/* dup to prepare for up conversion */
+        movq		mm5, mm4		;	/* dup to prepare for up conversion */
+	        ;	/* convert from UINT8 to INT16 */
+        punpcklbw		mm0, mm7		;	/* mm0 = INT16(FiltPtr) */
+        punpcklbw		mm1, mm7		;	/* mm1 = INT16(ReconPtr1) */
+        punpcklbw		mm4, mm7		;	/* mm1 = INT16(ReconPtr2) */
+        punpckhbw		mm2, mm7		;	/* mm2 = INT16(FiltPtr) */
+        punpckhbw		mm3, mm7		;	/* mm3 = INT16(ReconPtr1) */
+        punpckhbw		mm5, mm7		;	/* mm3 = INT16(ReconPtr2) */
+	        ;	/* average ReconPtr1 and ReconPtr2 */
+        paddw		mm1, mm4		;	/* mm1 = ReconPtr1 + ReconPtr2 */
+        paddw		mm3, mm5		;	/* mm3 = ReconPtr1 + ReconPtr2 */
+        psrlw		mm1, 1		;	/* mm1 = (ReconPtr1 + ReconPtr2) / 2 */
+        psrlw		mm3, 1		;	/* mm3 = (ReconPtr1 + ReconPtr2) / 2 */
+        psubw		mm0, mm1		;	/* mm0 = FiltPtr - ((ReconPtr1 + ReconPtr2) / 2) */
+        psubw		mm2, mm3		;	/* mm2 = FiltPtr - ((ReconPtr1 + ReconPtr2) / 2) */
+        movq		[edx], mm0		;	/* write answer out */
+        movq		[8 + edx], mm2		;	/* write answer out */
+	        ;	/* Increment pointers */
+        add		edx, 16		;	
+        add		eax, PixelsPerLine		;	
+        add		ebx, PixelsPerLine		;	
+        add		ecx, PixelsPerLine		;	
+
+    };
+
+
+
+
+ 
+#endif
+}
+
+static ogg_uint32_t row_sad8__mmx (unsigned char *Src1, unsigned char *Src2)
+{
+
+#if 0
+  ogg_uint32_t SadValue;
+  ogg_uint32_t SadValue1;
+
+  SadValue    = DSP_OP_ABS_DIFF (Src1[0], Src2[0]) + 
+	        DSP_OP_ABS_DIFF (Src1[1], Src2[1]) +
+	        DSP_OP_ABS_DIFF (Src1[2], Src2[2]) +
+	        DSP_OP_ABS_DIFF (Src1[3], Src2[3]);
+
+  SadValue1   = DSP_OP_ABS_DIFF (Src1[4], Src2[4]) + 
+	        DSP_OP_ABS_DIFF (Src1[5], Src2[5]) +
+	        DSP_OP_ABS_DIFF (Src1[6], Src2[6]) +
+	        DSP_OP_ABS_DIFF (Src1[7], Src2[7]);
+
+  SadValue = ( SadValue > SadValue1 ) ? SadValue : SadValue1;
+
+  return SadValue;
+
+#else
+  ogg_uint32_t MaxSad;
+
+  
+  __asm {
+    align       16
+    mov         ebx, Src1
+    mov         ecx, Src2
+
+
+    pxor		mm6, mm6		;	/* zero out mm6 for unpack */
+    pxor		mm7, mm7		;	/* zero out mm7 for unpack */
+    movq		mm0, [ebx]		;	/* take 8 bytes */
+    movq		mm1, [ecx]		;	
+
+    movq		mm2, mm0		;	
+    psubusb		mm0, mm1		;	/* A - B */
+    psubusb		mm1, mm2		;	/* B - A */
+    por		mm0, mm1		;	/* and or gives abs difference */
+
+    movq		mm1, mm0		;	
+
+    punpcklbw		mm0, mm6		;	/* ; unpack low four bytes to higher precision */
+    punpckhbw		mm1, mm7		;	/* ; unpack high four bytes to higher precision */
+
+    movq		mm2, mm0		;	
+    movq		mm3, mm1		;	
+    psrlq		mm2, 32		;	/* fold and add */
+    psrlq		mm3, 32		;	
+    paddw		mm0, mm2		;	
+    paddw		mm1, mm3		;	
+    movq		mm2, mm0		;	
+    movq		mm3, mm1		;	
+    psrlq		mm2, 16		;	
+    psrlq		mm3, 16		;	
+    paddw		mm0, mm2		;	
+    paddw		mm1, mm3		;	
+
+    psubusw		mm1, mm0		;	
+    paddw		mm1, mm0		;	/* mm1 = max(mm1, mm0) */
+    movd		eax, mm1		;
+
+    and         eax, 0xffff
+    mov         MaxSad, eax
+  };
+   return MaxSad;
+  
+  
+  
+ 
+
+#endif
+}
+
+
+
+
+static ogg_uint32_t col_sad8x8__mmx (unsigned char *Src1, unsigned char *Src2,
+		                    ogg_uint32_t stride)
+{
+
+#if 0
+  ogg_uint32_t SadValue[8] = {0,0,0,0,0,0,0,0};
+  ogg_uint32_t SadValue2[8] = {0,0,0,0,0,0,0,0};
+  ogg_uint32_t MaxSad = 0;
+  ogg_uint32_t i;
+
+  for ( i = 0; i < 4; i++ ){
+    SadValue[0] += abs(Src1[0] - Src2[0]);
+    SadValue[1] += abs(Src1[1] - Src2[1]);
+    SadValue[2] += abs(Src1[2] - Src2[2]);
+    SadValue[3] += abs(Src1[3] - Src2[3]);
+    SadValue[4] += abs(Src1[4] - Src2[4]);
+    SadValue[5] += abs(Src1[5] - Src2[5]);
+    SadValue[6] += abs(Src1[6] - Src2[6]);
+    SadValue[7] += abs(Src1[7] - Src2[7]);
+    
+    Src1 += stride;
+    Src2 += stride;
+  }
+
+  for ( i = 0; i < 4; i++ ){
+    SadValue2[0] += abs(Src1[0] - Src2[0]);
+    SadValue2[1] += abs(Src1[1] - Src2[1]);
+    SadValue2[2] += abs(Src1[2] - Src2[2]);
+    SadValue2[3] += abs(Src1[3] - Src2[3]);
+    SadValue2[4] += abs(Src1[4] - Src2[4]);
+    SadValue2[5] += abs(Src1[5] - Src2[5]);
+    SadValue2[6] += abs(Src1[6] - Src2[6]);
+    SadValue2[7] += abs(Src1[7] - Src2[7]);
+    
+    Src1 += stride;
+    Src2 += stride;
+  }
+    
+  for ( i = 0; i < 8; i++ ){
+    if ( SadValue[i] > MaxSad )
+      MaxSad = SadValue[i];
+    if ( SadValue2[i] > MaxSad )
+      MaxSad = SadValue2[i];
+  }
+    
+  return MaxSad;
+#else
+  ogg_uint32_t MaxSad;
+
+
+    __asm {
+        align       16
+        mov         ebx, Src1
+        mov         ecx, Src2
+
+        pxor		mm3, mm3		;	/* zero out mm3 for unpack */
+        pxor		mm4, mm4		;	/* mm4 low sum */
+        pxor		mm5, mm5		;	/* mm5 high sum */
+        pxor		mm6, mm6		;	/* mm6 low sum */
+        pxor		mm7, mm7		;	/* mm7 high sum */
+        mov		edi, 4		;	/* 4 rows */
+        label_1:				;	
+        movq		mm0, [ebx]		;	/* take 8 bytes */
+        movq		mm1, [ecx]		;	/* take 8 bytes */
+
+        movq		mm2, mm0		;	
+        psubusb		mm0, mm1		;	/* A - B */
+        psubusb		mm1, mm2		;	/* B - A */
+        por		mm0, mm1		;	/* and or gives abs difference */
+        movq		mm1, mm0		;	
+
+        punpcklbw		mm0, mm3		;	/* unpack to higher precision for accumulation */
+        paddw		mm4, mm0		;	/* accumulate difference... */
+        punpckhbw		mm1, mm3		;	/* unpack high four bytes to higher precision */
+        paddw		mm5, mm1		;	/* accumulate difference... */
+        add		ebx, stride		;	/* Inc pointer into the new data */
+        add		ecx, stride		;	/* Inc pointer into the new data */
+
+        dec		edi		;	
+        jnz		label_1		;	
+
+        mov		edi, 4		;	/* 4 rows */
+        label_2:				;	
+        movq		mm0, [ebx]		;	/* take 8 bytes */
+        movq		mm1, [ecx]		;	/* take 8 bytes */
+
+        movq		mm2, mm0		;	
+        psubusb		mm0, mm1		;	/* A - B */
+        psubusb		mm1, mm2		;	/* B - A */
+        por		mm0, mm1		;	/* and or gives abs difference */
+        movq		mm1, mm0		;	
+
+        punpcklbw		mm0, mm3		;	/* unpack to higher precision for accumulation */
+        paddw		mm6, mm0		;	/* accumulate difference... */
+        punpckhbw		mm1, mm3		;	/* unpack high four bytes to higher precision */
+        paddw		mm7, mm1		;	/* accumulate difference... */
+        add		ebx, stride		;	/* Inc pointer into the new data */
+        add		ecx, stride		;	/* Inc pointer into the new data */
+
+        dec		edi		;	
+        jnz		label_2		;	
+
+        psubusw		mm7, mm6		;	
+        paddw		mm7, mm6		;	/* mm7 = max(mm7, mm6) */
+        psubusw		mm5, mm4		;	
+        paddw		mm5, mm4		;	/* mm5 = max(mm5, mm4) */
+        psubusw		mm7, mm5		;	
+        paddw		mm7, mm5		;	/* mm7 = max(mm5, mm7) */
+        movq		mm6, mm7		;	
+        psrlq		mm6, 32		;	
+        psubusw		mm7, mm6		;	
+        paddw		mm7, mm6		;	/* mm7 = max(mm5, mm7) */
+        movq		mm6, mm7		;	
+        psrlq		mm6, 16		;	
+        psubusw		mm7, mm6		;	
+        paddw		mm7, mm6		;	/* mm7 = max(mm5, mm7) */
+        movd		eax, mm7		;	
+        and		    eax, 0xffff		;
+
+        mov         MaxSad, eax
+    };
+
+    return MaxSad;
+
+
+#endif
+}
+
+static ogg_uint32_t sad8x8__mmx (unsigned char *ptr1, ogg_uint32_t stride1,
+		       	    unsigned char *ptr2, ogg_uint32_t stride2)
+{
+
+#if 0
+  ogg_uint32_t  i;
+  ogg_uint32_t  sad = 0;
+
+  for (i=8; i; i--) {
+    sad += DSP_OP_ABS_DIFF(ptr1[0], ptr2[0]);
+    sad += DSP_OP_ABS_DIFF(ptr1[1], ptr2[1]);
+    sad += DSP_OP_ABS_DIFF(ptr1[2], ptr2[2]);
+    sad += DSP_OP_ABS_DIFF(ptr1[3], ptr2[3]);
+    sad += DSP_OP_ABS_DIFF(ptr1[4], ptr2[4]);
+    sad += DSP_OP_ABS_DIFF(ptr1[5], ptr2[5]);
+    sad += DSP_OP_ABS_DIFF(ptr1[6], ptr2[6]);
+    sad += DSP_OP_ABS_DIFF(ptr1[7], ptr2[7]);
+
+    /* Step to next row of block. */
+    ptr1 += stride1;
+    ptr2 += stride2;
+  }
+
+  return sad;
+#else
+  ogg_uint32_t  DiffVal;
+
+  __asm {
+    align  16
+
+    mov         ebx, ptr1
+    mov         edx, ptr2
+
+    pxor		mm6, mm6		;	/* zero out mm6 for unpack */
+    pxor		mm7, mm7		;	/* mm7 contains the result */
+    
+    ; /* ITERATION 1 */
+    movq		mm0, [ebx]		;	/* take 8 bytes */
+    movq		mm1, [edx]		;	
+    movq		mm2, mm0		;	
+
+    psubusb		mm0, mm1		;	/* A - B */
+    psubusb		mm1, mm2		;	/* B - A */
+    por		mm0, mm1		;	/* and or gives abs difference */
+    movq		mm1, mm0		;	
+
+    punpcklbw		mm0, mm6		;	/* unpack to higher precision for accumulation */
+    paddw		mm7, mm0		;	/* accumulate difference... */
+    punpckhbw		mm1, mm6		;	/* unpack high four bytes to higher precision */
+    add		ebx, stride1		;	/* Inc pointer into the new data */
+    paddw		mm7, mm1		;	/* accumulate difference... */
+    add		edx, stride2		;	/* Inc pointer into ref data */
+
+    ; /* ITERATION 2 */
+    movq		mm0, [ebx]		;	/* take 8 bytes */
+    movq		mm1, [edx]		;	
+    movq		mm2, mm0		;	
+
+    psubusb		mm0, mm1		;	/* A - B */
+    psubusb		mm1, mm2		;	/* B - A */
+    por		mm0, mm1		;	/* and or gives abs difference */
+    movq		mm1, mm0		;	
+
+    punpcklbw		mm0, mm6		;	/* unpack to higher precision for accumulation */
+    paddw		mm7, mm0		;	/* accumulate difference... */
+    punpckhbw		mm1, mm6		;	/* unpack high four bytes to higher precision */
+    add		ebx, stride1		;	/* Inc pointer into the new data */
+    paddw		mm7, mm1		;	/* accumulate difference... */
+    add		edx, stride2		;	/* Inc pointer into ref data */
+
+
+    ; /* ITERATION 3 */
+    movq		mm0, [ebx]		;	/* take 8 bytes */
+    movq		mm1, [edx]		;	
+    movq		mm2, mm0		;	
+
+    psubusb		mm0, mm1		;	/* A - B */
+    psubusb		mm1, mm2		;	/* B - A */
+    por		mm0, mm1		;	/* and or gives abs difference */
+    movq		mm1, mm0		;	
+
+    punpcklbw		mm0, mm6		;	/* unpack to higher precision for accumulation */
+    paddw		mm7, mm0		;	/* accumulate difference... */
+    punpckhbw		mm1, mm6		;	/* unpack high four bytes to higher precision */
+    add		ebx, stride1		;	/* Inc pointer into the new data */
+    paddw		mm7, mm1		;	/* accumulate difference... */
+    add		edx, stride2		;	/* Inc pointer into ref data */
+
+    ; /* ITERATION 4 */
+    movq		mm0, [ebx]		;	/* take 8 bytes */
+    movq		mm1, [edx]		;	
+    movq		mm2, mm0		;	
+
+    psubusb		mm0, mm1		;	/* A - B */
+    psubusb		mm1, mm2		;	/* B - A */
+    por		mm0, mm1		;	/* and or gives abs difference */
+    movq		mm1, mm0		;	
+
+    punpcklbw		mm0, mm6		;	/* unpack to higher precision for accumulation */
+    paddw		mm7, mm0		;	/* accumulate difference... */
+    punpckhbw		mm1, mm6		;	/* unpack high four bytes to higher precision */
+    add		ebx, stride1		;	/* Inc pointer into the new data */
+    paddw		mm7, mm1		;	/* accumulate difference... */
+    add		edx, stride2		;	/* Inc pointer into ref data */
+
+
+    ; /* ITERATION 5 */
+    movq		mm0, [ebx]		;	/* take 8 bytes */
+    movq		mm1, [edx]		;	
+    movq		mm2, mm0		;	
+
+    psubusb		mm0, mm1		;	/* A - B */
+    psubusb		mm1, mm2		;	/* B - A */
+    por		mm0, mm1		;	/* and or gives abs difference */
+    movq		mm1, mm0		;	
+
+    punpcklbw		mm0, mm6		;	/* unpack to higher precision for accumulation */
+    paddw		mm7, mm0		;	/* accumulate difference... */
+    punpckhbw		mm1, mm6		;	/* unpack high four bytes to higher precision */
+    add		ebx, stride1		;	/* Inc pointer into the new data */
+    paddw		mm7, mm1		;	/* accumulate difference... */
+    add		edx, stride2		;	/* Inc pointer into ref data */
+
+
+    ; /* ITERATION 6 */
+    movq		mm0, [ebx]		;	/* take 8 bytes */
+    movq		mm1, [edx]		;	
+    movq		mm2, mm0		;	
+
+    psubusb		mm0, mm1		;	/* A - B */
+    psubusb		mm1, mm2		;	/* B - A */
+    por		mm0, mm1		;	/* and or gives abs difference */
+    movq		mm1, mm0		;	
+
+    punpcklbw		mm0, mm6		;	/* unpack to higher precision for accumulation */
+    paddw		mm7, mm0		;	/* accumulate difference... */
+    punpckhbw		mm1, mm6		;	/* unpack high four bytes to higher precision */
+    add		ebx, stride1		;	/* Inc pointer into the new data */
+    paddw		mm7, mm1		;	/* accumulate difference... */
+    add		edx, stride2		;	/* Inc pointer into ref data */
+
+
+    ; /* ITERATION 7 */
+    movq		mm0, [ebx]		;	/* take 8 bytes */
+    movq		mm1, [edx]		;	
+    movq		mm2, mm0		;	
+
+    psubusb		mm0, mm1		;	/* A - B */
+    psubusb		mm1, mm2		;	/* B - A */
+    por		mm0, mm1		;	/* and or gives abs difference */
+    movq		mm1, mm0		;	
+
+    punpcklbw		mm0, mm6		;	/* unpack to higher precision for accumulation */
+    paddw		mm7, mm0		;	/* accumulate difference... */
+    punpckhbw		mm1, mm6		;	/* unpack high four bytes to higher precision */
+    add		ebx, stride1		;	/* Inc pointer into the new data */
+    paddw		mm7, mm1		;	/* accumulate difference... */
+    add		edx, stride2		;	/* Inc pointer into ref data */
+
+
+
+    ; /* ITERATION 8 */
+    movq		mm0, [ebx]		;	/* take 8 bytes */
+    movq		mm1, [edx]		;	
+    movq		mm2, mm0		;	
+
+    psubusb		mm0, mm1		;	/* A - B */
+    psubusb		mm1, mm2		;	/* B - A */
+    por		mm0, mm1		;	/* and or gives abs difference */
+    movq		mm1, mm0		;	
+
+    punpcklbw		mm0, mm6		;	/* unpack to higher precision for accumulation */
+    paddw		mm7, mm0		;	/* accumulate difference... */
+    punpckhbw		mm1, mm6		;	/* unpack high four bytes to higher precision */
+    add		ebx, stride1		;	/* Inc pointer into the new data */
+    paddw		mm7, mm1		;	/* accumulate difference... */
+    add		edx, stride2		;	/* Inc pointer into ref data */
+
+
+
+    ; /* ------ */
+
+    movq		mm0, mm7		;	
+    psrlq		mm7, 32		;	
+    paddw		mm7, mm0		;	
+    movq		mm0, mm7		;	
+    psrlq		mm7, 16		;	
+    paddw		mm7, mm0		;	
+    movd		eax, mm7		;	
+    and		    eax, 0xffff		;	
+
+    mov         DiffVal, eax
+  };
+
+  return DiffVal;
+
+ 
+
+#endif
+}
+
+static ogg_uint32_t sad8x8_thres__mmx (unsigned char *ptr1, ogg_uint32_t stride1,
+		       		  unsigned char *ptr2, ogg_uint32_t stride2, 
+			   	  ogg_uint32_t thres)
+{
+#if 0
+  ogg_uint32_t  i;
+  ogg_uint32_t  sad = 0;
+
+  for (i=8; i; i--) {
+    sad += DSP_OP_ABS_DIFF(ptr1[0], ptr2[0]);
+    sad += DSP_OP_ABS_DIFF(ptr1[1], ptr2[1]);
+    sad += DSP_OP_ABS_DIFF(ptr1[2], ptr2[2]);
+    sad += DSP_OP_ABS_DIFF(ptr1[3], ptr2[3]);
+    sad += DSP_OP_ABS_DIFF(ptr1[4], ptr2[4]);
+    sad += DSP_OP_ABS_DIFF(ptr1[5], ptr2[5]);
+    sad += DSP_OP_ABS_DIFF(ptr1[6], ptr2[6]);
+    sad += DSP_OP_ABS_DIFF(ptr1[7], ptr2[7]);
+
+    if (sad > thres )
+      break;
+
+    /* Step to next row of block. */
+    ptr1 += stride1;
+    ptr2 += stride2;
+  }
+
+  return sad;
+#else
+  return sad8x8__mmx (ptr1, stride1, ptr2, stride2);
+#endif
+}
+
+
+static ogg_uint32_t sad8x8_xy2_thres__mmx (unsigned char *SrcData, ogg_uint32_t SrcStride,
+		                      unsigned char *RefDataPtr1,
+			              unsigned char *RefDataPtr2, ogg_uint32_t RefStride,
+			              ogg_uint32_t thres)
+{
+#if 0
+  ogg_uint32_t  i;
+  ogg_uint32_t  sad = 0;
+
+  for (i=8; i; i--) {
+    sad += DSP_OP_ABS_DIFF(SrcData[0], DSP_OP_AVG (RefDataPtr1[0], RefDataPtr2[0]));
+    sad += DSP_OP_ABS_DIFF(SrcData[1], DSP_OP_AVG (RefDataPtr1[1], RefDataPtr2[1]));
+    sad += DSP_OP_ABS_DIFF(SrcData[2], DSP_OP_AVG (RefDataPtr1[2], RefDataPtr2[2]));
+    sad += DSP_OP_ABS_DIFF(SrcData[3], DSP_OP_AVG (RefDataPtr1[3], RefDataPtr2[3]));
+    sad += DSP_OP_ABS_DIFF(SrcData[4], DSP_OP_AVG (RefDataPtr1[4], RefDataPtr2[4]));
+    sad += DSP_OP_ABS_DIFF(SrcData[5], DSP_OP_AVG (RefDataPtr1[5], RefDataPtr2[5]));
+    sad += DSP_OP_ABS_DIFF(SrcData[6], DSP_OP_AVG (RefDataPtr1[6], RefDataPtr2[6]));
+    sad += DSP_OP_ABS_DIFF(SrcData[7], DSP_OP_AVG (RefDataPtr1[7], RefDataPtr2[7]));
+
+    if ( sad > thres )
+      break;
+
+    /* Step to next row of block. */
+    SrcData += SrcStride;
+    RefDataPtr1 += RefStride;
+    RefDataPtr2 += RefStride;
+  }
+
+  return sad;
+#else
+  ogg_uint32_t  DiffVal;
+
+  __asm {
+    align 16
+
+        mov     ebx, SrcData
+        mov     ecx, RefDataPtr1
+        mov     edx, RefDataPtr2
+
+
+    pcmpeqd		mm5, mm5		;	/* fefefefefefefefe in mm5 */
+    paddb		mm5, mm5		;	
+				    ;	
+    pxor		mm6, mm6		;	/* zero out mm6 for unpack */
+    pxor		mm7, mm7		;	/* mm7 contains the result */
+    mov		edi, 8		;	/* 8 rows */
+    loop_start:				;	
+    movq		mm0, [ebx]		;	/* take 8 bytes */
+
+    movq		mm2, [ecx]		;	
+    movq		mm3, [edx]		;	/* take average of mm2 and mm3 */
+    movq		mm1, mm2		;	
+    pand		mm1, mm3		;	
+    pxor		mm3, mm2		;	
+    pand		mm3, mm5		;	
+    psrlq		mm3, 1		;	
+    paddb		mm1, mm3		;	
+
+    movq		mm2, mm0		;	
+
+    psubusb		mm0, mm1		;	/* A - B */
+    psubusb		mm1, mm2		;	/* B - A */
+    por		mm0, mm1		;	/* and or gives abs difference */
+    movq		mm1, mm0		;	
+
+    punpcklbw		mm0, mm6		;	/* unpack to higher precision for accumulation */
+    paddw		mm7, mm0		;	/* accumulate difference... */
+    punpckhbw		mm1, mm6		;	/* unpack high four bytes to higher precision */
+    add		ebx, SrcStride		;	/* Inc pointer into the new data */
+    paddw		mm7, mm1		;	/* accumulate difference... */
+    add		ecx, RefStride		;	/* Inc pointer into ref data */
+    add		edx, RefStride		;	/* Inc pointer into ref data */
+
+    dec		edi		;	
+    jnz		loop_start		;	
+
+    movq		mm0, mm7		;	
+    psrlq		mm7, 32		;	
+    paddw		mm7, mm0		;	
+    movq		mm0, mm7		;	
+    psrlq		mm7, 16		;	
+    paddw		mm7, mm0		;	
+    movd		eax, mm7		;	
+    and		eax, 0xffff		;	
+
+    mov DiffVal, eax
+  };
+
+  return DiffVal;
+
+ 
+
+#endif
+}
+
+static ogg_uint32_t intra8x8_err__mmx (unsigned char *DataPtr, ogg_uint32_t Stride)
+{
+#if 0
+  ogg_uint32_t  i;
+  ogg_uint32_t  XSum=0;
+  ogg_uint32_t  XXSum=0;
+
+  for (i=8; i; i--) {
+     /* Examine alternate pixel locations. */
+     XSum += DataPtr[0];
+     XXSum += DataPtr[0]*DataPtr[0];
+     XSum += DataPtr[1];
+     XXSum += DataPtr[1]*DataPtr[1];
+     XSum += DataPtr[2];
+     XXSum += DataPtr[2]*DataPtr[2];
+     XSum += DataPtr[3];
+     XXSum += DataPtr[3]*DataPtr[3];
+     XSum += DataPtr[4];
+     XXSum += DataPtr[4]*DataPtr[4];
+     XSum += DataPtr[5];
+     XXSum += DataPtr[5]*DataPtr[5];
+     XSum += DataPtr[6];
+     XXSum += DataPtr[6]*DataPtr[6];
+     XSum += DataPtr[7];
+     XXSum += DataPtr[7]*DataPtr[7];
+
+     /* Step to next row of block. */
+     DataPtr += Stride;
+   }
+
+   /* Compute population variance as mis-match metric. */
+   return (( (XXSum<<6) - XSum*XSum ) );
+#else
+  ogg_uint32_t  XSum;
+  ogg_uint32_t  XXSum;
+
+  __asm {
+    align 16
+
+        mov     ecx, DataPtr
+
+    pxor		mm5, mm5		;	
+    pxor		mm6, mm6		;	
+    pxor		mm7, mm7		;	
+    mov		edi, 8		;	
+    loop_start:		
+    movq		mm0, [ecx]		;	/* take 8 bytes */
+    movq		mm2, mm0		;	
+
+    punpcklbw		mm0, mm6		;	
+    punpckhbw		mm2, mm6		;	
+
+    paddw		mm5, mm0		;	
+    paddw		mm5, mm2		;	
+
+    pmaddwd		mm0, mm0		;	
+    pmaddwd		mm2, mm2		;	
+				    ;	
+    paddd		mm7, mm0		;	
+    paddd		mm7, mm2		;	
+
+    add		ecx, Stride		;	/* Inc pointer into src data */
+
+    dec		edi		;	
+    jnz		loop_start		;	
+
+    movq		mm0, mm5		;	
+    psrlq		mm5, 32		;	
+    paddw		mm5, mm0		;	
+    movq		mm0, mm5		;	
+    psrlq		mm5, 16		;	
+    paddw		mm5, mm0		;	
+    movd		edi, mm5		;	
+    movsx		edi, di		;	
+    mov		eax, edi		;	
+
+    movq		mm0, mm7		;	
+    psrlq		mm7, 32		;	
+    paddd		mm7, mm0		;	
+    movd		ebx, mm7		;	
+
+        mov         XSum, eax
+        mov         XXSum, ebx;
+
+  };
+    /* Compute population variance as mis-match metric. */
+    return (( (XXSum<<6) - XSum*XSum ) );
+
+ 
+
+#endif
+}
+
+static ogg_uint32_t inter8x8_err__mmx (unsigned char *SrcData, ogg_uint32_t SrcStride,
+		                 unsigned char *RefDataPtr, ogg_uint32_t RefStride)
+{
+
+#if 0
+  ogg_uint32_t  i;
+  ogg_uint32_t  XSum=0;
+  ogg_uint32_t  XXSum=0;
+  ogg_int32_t   DiffVal;
+
+  for (i=8; i; i--) {
+    DiffVal = DSP_OP_DIFF (SrcData[0], RefDataPtr[0]);
+    XSum += DiffVal;
+    XXSum += DiffVal*DiffVal;
+
+    DiffVal = DSP_OP_DIFF (SrcData[1], RefDataPtr[1]);
+    XSum += DiffVal;
+    XXSum += DiffVal*DiffVal;
+
+    DiffVal = DSP_OP_DIFF (SrcData[2], RefDataPtr[2]);
+    XSum += DiffVal;
+    XXSum += DiffVal*DiffVal;
+
+    DiffVal = DSP_OP_DIFF (SrcData[3], RefDataPtr[3]);
+    XSum += DiffVal;
+    XXSum += DiffVal*DiffVal;
+        
+    DiffVal = DSP_OP_DIFF (SrcData[4], RefDataPtr[4]);
+    XSum += DiffVal;
+    XXSum += DiffVal*DiffVal;
+        
+    DiffVal = DSP_OP_DIFF (SrcData[5], RefDataPtr[5]);
+    XSum += DiffVal;
+    XXSum += DiffVal*DiffVal;
+        
+    DiffVal = DSP_OP_DIFF (SrcData[6], RefDataPtr[6]);
+    XSum += DiffVal;
+    XXSum += DiffVal*DiffVal;
+        
+    DiffVal = DSP_OP_DIFF (SrcData[7], RefDataPtr[7]);
+    XSum += DiffVal;
+    XXSum += DiffVal*DiffVal;
+        
+    /* Step to next row of block. */
+    SrcData += SrcStride;
+    RefDataPtr += RefStride;
+  }
+
+  /* Compute and return population variance as mis-match metric. */
+  return (( (XXSum<<6) - XSum*XSum ));
+#else
+  ogg_uint32_t  XSum;
+  ogg_uint32_t  XXSum;
+
+
+  __asm {
+    align 16
+
+        mov     ecx, SrcData
+        mov     edx, RefDataPtr
+
+    pxor		mm5, mm5		;	
+    pxor		mm6, mm6		;	
+    pxor		mm7, mm7		;	
+    mov		edi, 8		;	
+    loop_start:				;	
+    movq		mm0, [ecx]		;	/* take 8 bytes */
+    movq		mm1, [edx]		;	
+    movq		mm2, mm0		;	
+    movq		mm3, mm1		;	
+
+    punpcklbw		mm0, mm6		;	
+    punpcklbw		mm1, mm6		;	
+    punpckhbw		mm2, mm6		;	
+    punpckhbw		mm3, mm6		;	
+
+    psubsw		mm0, mm1		;	
+    psubsw		mm2, mm3		;	
+
+    paddw		mm5, mm0		;	
+    paddw		mm5, mm2		;	
+
+    pmaddwd		mm0, mm0		;	
+    pmaddwd		mm2, mm2		;	
+				    ;	
+    paddd		mm7, mm0		;	
+    paddd		mm7, mm2		;	
+
+    add		ecx, SrcStride		;	/* Inc pointer into src data */
+    add		edx, RefStride		;	/* Inc pointer into ref data */
+
+    dec		edi		;	
+    jnz		loop_start		;	
+
+    movq		mm0, mm5		;	
+    psrlq		mm5, 32		;	
+    paddw		mm5, mm0		;	
+    movq		mm0, mm5		;	
+    psrlq		mm5, 16		;	
+    paddw		mm5, mm0		;	
+    movd		edi, mm5		;	
+    movsx		edi, di		;	
+    mov		eax, edi		;	
+
+    movq		mm0, mm7		;	
+    psrlq		mm7, 32		;	
+    paddd		mm7, mm0		;	
+    movd		ebx, mm7		;	
+
+        mov     XSum, eax
+        mov     XXSum, ebx
+
+  };
+
+  /* Compute and return population variance as mis-match metric. */
+  return (( (XXSum<<6) - XSum*XSum ));
+
+ 
+#endif
+}
+
+static ogg_uint32_t inter8x8_err_xy2__mmx (unsigned char *SrcData, ogg_uint32_t SrcStride,
+		                     unsigned char *RefDataPtr1,
+				     unsigned char *RefDataPtr2, ogg_uint32_t RefStride)
+{
+#if 0
+  ogg_uint32_t  i;
+  ogg_uint32_t  XSum=0;
+  ogg_uint32_t  XXSum=0;
+  ogg_int32_t   DiffVal;
+
+  for (i=8; i; i--) {
+    DiffVal = DSP_OP_DIFF(SrcData[0], DSP_OP_AVG (RefDataPtr1[0], RefDataPtr2[0]));
+    XSum += DiffVal;
+    XXSum += DiffVal*DiffVal;
+
+    DiffVal = DSP_OP_DIFF(SrcData[1], DSP_OP_AVG (RefDataPtr1[1], RefDataPtr2[1]));
+    XSum += DiffVal;
+    XXSum += DiffVal*DiffVal;
+
+    DiffVal = DSP_OP_DIFF(SrcData[2], DSP_OP_AVG (RefDataPtr1[2], RefDataPtr2[2]));
+    XSum += DiffVal;
+    XXSum += DiffVal*DiffVal;
+
+    DiffVal = DSP_OP_DIFF(SrcData[3], DSP_OP_AVG (RefDataPtr1[3], RefDataPtr2[3]));
+    XSum += DiffVal;
+    XXSum += DiffVal*DiffVal;
+
+    DiffVal = DSP_OP_DIFF(SrcData[4], DSP_OP_AVG (RefDataPtr1[4], RefDataPtr2[4]));
+    XSum += DiffVal;
+    XXSum += DiffVal*DiffVal;
+
+    DiffVal = DSP_OP_DIFF(SrcData[5], DSP_OP_AVG (RefDataPtr1[5], RefDataPtr2[5]));
+    XSum += DiffVal;
+    XXSum += DiffVal*DiffVal;
+
+    DiffVal = DSP_OP_DIFF(SrcData[6], DSP_OP_AVG (RefDataPtr1[6], RefDataPtr2[6]));
+    XSum += DiffVal;
+    XXSum += DiffVal*DiffVal;
+
+    DiffVal = DSP_OP_DIFF(SrcData[7], DSP_OP_AVG (RefDataPtr1[7], RefDataPtr2[7]));
+    XSum += DiffVal;
+    XXSum += DiffVal*DiffVal;
+
+    /* Step to next row of block. */
+    SrcData += SrcStride;
+    RefDataPtr1 += RefStride;
+    RefDataPtr2 += RefStride;
+  }
+
+  /* Compute and return population variance as mis-match metric. */
+  return (( (XXSum<<6) - XSum*XSum ));
+#else
+  ogg_uint32_t XSum;
+  ogg_uint32_t XXSum;
+
+  __asm {
+    align 16
+
+        mov ebx, SrcData
+        mov ecx, RefDataPtr1
+        mov edx, RefDataPtr2
+
+    pcmpeqd		mm4, mm4		;	/* fefefefefefefefe in mm4 */
+    paddb		mm4, mm4		;	
+    pxor		mm5, mm5		;	
+    pxor		mm6, mm6		;	
+    pxor		mm7, mm7		;	
+    mov		edi, 8		;	
+    loop_start:				;	
+    movq		mm0, [ebx]		;	/* take 8 bytes */
+
+    movq		mm2, [ecx]		;	
+    movq		mm3, [edx]		;	/* take average of mm2 and mm3 */
+    movq		mm1, mm2		;	
+    pand		mm1, mm3		;	
+    pxor		mm3, mm2		;	
+    pand		mm3, mm4		;	
+    psrlq		mm3, 1		;	
+    paddb		mm1, mm3		;	
+
+    movq		mm2, mm0		;	
+    movq		mm3, mm1		;	
+
+    punpcklbw		mm0, mm6		;	
+    punpcklbw		mm1, mm6		;	
+    punpckhbw		mm2, mm6		;	
+    punpckhbw		mm3, mm6		;	
+
+    psubsw		mm0, mm1		;	
+    psubsw		mm2, mm3		;	
+
+    paddw		mm5, mm0		;	
+    paddw		mm5, mm2		;	
+
+    pmaddwd		mm0, mm0		;	
+    pmaddwd		mm2, mm2		;	
+				    ;	
+    paddd		mm7, mm0		;	
+    paddd		mm7, mm2		;	
+
+    add		ebx, SrcStride		;	/* Inc pointer into src data */
+    add		ecx, RefStride		;	/* Inc pointer into ref data */
+    add		edx, RefStride		;	/* Inc pointer into ref data */
+
+    dec		edi		;	
+    jnz		loop_start		;	
+
+    movq		mm0, mm5		;	
+    psrlq		mm5, 32		;	
+    paddw		mm5, mm0		;	
+    movq		mm0, mm5		;	
+    psrlq		mm5, 16		;	
+    paddw		mm5, mm0		;	
+    movd		edi, mm5		;	
+    movsx		edi, di		;	
+    mov         XSum, edi   ; /* movl		eax, edi		;	Modified for vc to resuse eax*/
+
+    movq		mm0, mm7		;	
+    psrlq		mm7, 32		;	
+    paddd		mm7, mm0		;	
+    movd        XXSum, mm7 ; /*movd		eax, mm7		; Modified for vc to reuse eax */
+  };
+
+    return (( (XXSum<<6) - XSum*XSum ));
+
+#endif
+}
+
+static void restore_fpu (void)
+{
+
+    __asm {
+        emms
+    }
+
+}
+
+void dsp_mmx_init(DspFunctions *funcs)
+{
+  funcs->restore_fpu = restore_fpu;
+  funcs->sub8x8 = sub8x8__mmx;
+  funcs->sub8x8_128 = sub8x8_128__mmx;
+  funcs->sub8x8avg2 = sub8x8avg2__mmx;
+  funcs->row_sad8 = row_sad8__mmx;
+  funcs->col_sad8x8 = col_sad8x8__mmx;
+  funcs->sad8x8 = sad8x8__mmx;
+  funcs->sad8x8_thres = sad8x8_thres__mmx;
+  funcs->sad8x8_xy2_thres = sad8x8_xy2_thres__mmx;
+  funcs->intra8x8_err = intra8x8_err__mmx;
+  funcs->inter8x8_err = inter8x8_err__mmx;
+  funcs->inter8x8_err_xy2 = inter8x8_err_xy2__mmx;
+}
+
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86_32_vs/fdct_mmx.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86_32_vs/fdct_mmx.c
new file mode 100644
index 0000000..cf47986
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86_32_vs/fdct_mmx.c
@@ -0,0 +1,334 @@
+;//==========================================================================
+;//
+;//  THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
+;//  KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
+;//  IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
+;//  PURPOSE.
+;//
+;//  Copyright (c) 1999 - 2001  On2 Technologies Inc. All Rights Reserved.
+;//
+;//--------------------------------------------------------------------------
+
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+#include "vtkoggtheora/include/theora/theora.h"
+#include "codec_internal.h"
+#include "dsp.h"
+
+
+static const  ogg_int64_t xC1S7 = 0x0fb15fb15fb15fb15;
+static const  ogg_int64_t xC2S6 = 0x0ec83ec83ec83ec83;
+static const  ogg_int64_t xC3S5 = 0x0d4dbd4dbd4dbd4db;
+static const  ogg_int64_t xC4S4 = 0x0b505b505b505b505;
+static const  ogg_int64_t xC5S3 = 0x08e3a8e3a8e3a8e3a;
+static const  ogg_int64_t xC6S2 = 0x061f861f861f861f8;
+static const  ogg_int64_t xC7S1 = 0x031f131f131f131f1;
+
+
+static __inline void Transpose_mmx( ogg_int16_t *InputData1, ogg_int16_t *OutputData1,
+                                 ogg_int16_t *InputData2, ogg_int16_t *OutputData2)
+{
+
+    __asm {
+        align 16
+            mov     eax, InputData1
+            mov     ebx, InputData2
+            mov     ecx, OutputData1
+            mov     edx, OutputData2
+
+
+        movq		mm0, [eax]		;	/* mm0 = a0 a1 a2 a3 */
+        movq		mm4, [ebx]		;	/* mm4 = e4 e5 e6 e7 */
+        movq		mm1, [16 + eax]		;	/* mm1 = b0 b1 b2 b3 */
+        movq		mm5, [16 + ebx]		;	/* mm5 = f4 f5 f6 f7 */
+        movq		mm2, [32 + eax]		;	/* mm2 = c0 c1 c2 c3 */
+        movq		mm6, [32 + ebx]		;	/* mm6 = g4 g5 g6 g7 */
+        movq		mm3, [48 + eax]		;	/* mm3 = d0 d1 d2 d3 */
+        movq		[16 + ecx], mm1		;	/* save  b0 b1 b2 b3 */
+        movq		mm7, [48 + ebx]		;	/* mm7 = h0 h1 h2 h3 */
+	        ;	/* Transpose 2x8 block */
+        movq		mm1, mm4		;	/* mm1 = e3 e2 e1 e0 */
+        punpcklwd		mm4, mm5		;	/* mm4 = f1 e1 f0 e0 */
+        movq		[ecx], mm0		;	/* save a3 a2 a1 a0  */
+        punpckhwd		mm1, mm5		;	/* mm1 = f3 e3 f2 e2 */
+        movq		mm0, mm6		;	/* mm0 = g3 g2 g1 g0 */
+        punpcklwd		mm6, mm7		;	/* mm6 = h1 g1 h0 g0 */
+        movq		mm5, mm4		;	/* mm5 = f1 e1 f0 e0 */
+        punpckldq		mm4, mm6		;	/* mm4 = h0 g0 f0 e0 = MM4 */
+        punpckhdq		mm5, mm6		;	/* mm5 = h1 g1 f1 e1 = MM5 */
+        movq		mm6, mm1		;	/* mm6 = f3 e3 f2 e2 */
+        movq		[edx], mm4		;	
+        punpckhwd		mm0, mm7		;	/* mm0 = h3 g3 h2 g2 */
+        movq		[16 + edx], mm5		;	
+        punpckhdq		mm6, mm0		;	/* mm6 = h3 g3 f3 e3 = MM7 */
+        movq		mm4, [ecx]		;	/* mm4 = a3 a2 a1 a0 */
+        punpckldq		mm1, mm0		;	/* mm1 = h2 g2 f2 e2 = MM6 */
+        movq		mm5, [16 + ecx]		;	/* mm5 = b3 b2 b1 b0 */
+        movq		mm0, mm4		;	/* mm0 = a3 a2 a1 a0 */
+        movq		[48 + edx], mm6		;	
+        punpcklwd		mm0, mm5		;	/* mm0 = b1 a1 b0 a0 */
+        movq		[32 + edx], mm1		;	
+        punpckhwd		mm4, mm5		;	/* mm4 = b3 a3 b2 a2 */
+        movq		mm5, mm2		;	/* mm5 = c3 c2 c1 c0 */
+        punpcklwd		mm2, mm3		;	/* mm2 = d1 c1 d0 c0 */
+        movq		mm1, mm0		;	/* mm1 = b1 a1 b0 a0 */
+        punpckldq		mm0, mm2		;	/* mm0 = d0 c0 b0 a0 = MM0 */
+        punpckhdq		mm1, mm2		;	/* mm1 = d1 c1 b1 a1 = MM1 */
+        movq		mm2, mm4		;	/* mm2 = b3 a3 b2 a2 */
+        movq		[ecx], mm0		;	
+        punpckhwd		mm5, mm3		;	/* mm5 = d3 c3 d2 c2 */
+        movq		[16 + ecx], mm1		;	
+        punpckhdq		mm4, mm5		;	/* mm4 = d3 c3 b3 a3 = MM3 */
+        punpckldq		mm2, mm5		;	/* mm2 = d2 c2 b2 a2 = MM2 */
+        movq		[48 + ecx], mm4		;	
+        movq		[32 + ecx], mm2		;	
+
+    };
+
+
+}
+
+static __inline void Fdct_mmx( ogg_int16_t *InputData1, ogg_int16_t *InputData2, ogg_int16_t *temp)
+{
+
+    __asm {
+        align 16
+
+
+                mov     eax, InputData1
+                mov     ebx, InputData2
+                mov     ecx, temp
+        movq		mm0, [eax]		;	
+        movq		mm1, [16 + eax]		;	
+        movq		mm2, [48 + eax]		;	
+        movq		mm3, [16 + ebx]		;	
+        movq		mm4, mm0		;	
+        movq		mm5, mm1		;	
+        movq		mm6, mm2		;	
+        movq		mm7, mm3		;	
+				        ;	
+        paddsw		mm0, [48 + ebx]		;	/* mm0 = ip0 + ip7 = is07 */
+        paddsw		mm1, [32 + eax]		;	/* mm1 = ip1 + ip2 = is12 */
+        paddsw		mm2, [ebx]		;	/* mm2 = ip3 + ip4 = is34 */
+        paddsw		mm3, [32 + ebx]		;	/* mm3 = ip5 + ip6 = is56 */
+        psubsw		mm4, [48 + ebx]		;	/* mm4 = ip0 - ip7 = id07 */
+        psubsw		mm5, [32 + eax]		;	/* mm5 = ip1 - ip2 = id12 */
+				        ;	
+        psubsw		mm0, mm2		;	/* mm0 = is07 - is34 */
+				        ;	
+        paddsw		mm2, mm2		;	
+				        ;	
+        psubsw		mm6, [ebx]		;	/* mm6 = ip3 - ip4 = id34 */
+				        ;	
+        paddsw		mm2, mm0		;	/* mm2 = is07 + is34 = is0734 */
+        psubsw		mm1, mm3		;	/* mm1 = is12 - is56 */
+        movq		[ecx], mm0		;	/* Save is07 - is34 to free mm0; */
+        paddsw		mm3, mm3		;	
+        paddsw		mm3, mm1		;	/* mm3 = is12 + 1s56	= is1256 */
+				        ;	
+        psubsw		mm7, [32 + ebx]		;	/* mm7 = ip5 - ip6 = id56 */
+	        ;	/* ------------------------------------------------------------------- */
+        psubsw		mm5, mm7		;	/* mm5 = id12 - id56 */
+        paddsw		mm7, mm7		;	
+        paddsw		mm7, mm5		;	/* mm7 = id12 + id56 */
+	        ;	/* ------------------------------------------------------------------- */
+        psubsw		mm2, mm3		;	/* mm2 = is0734 - is1256 */
+        paddsw		mm3, mm3		;	
+				        ;	
+        movq		mm0, mm2		;	/* make a copy */
+        paddsw		mm3, mm2		;	/* mm3 = is0734 + is1256 */
+				        ;	
+        pmulhw		mm0, xC4S4		;	/* mm0 = xC4S4 * ( is0734 - is1256 ) - ( is0734 - is1256 ) */
+        paddw		mm0, mm2		;	/* mm0 = xC4S4 * ( is0734 - is1256 ) */
+        psrlw		mm2, 15		;	
+        paddw		mm0, mm2		;	/* Truncate mm0, now it is op[4] */
+				        ;	
+        movq		mm2, mm3		;	
+        movq		[ebx], mm0		;	/* save ip4, now mm0,mm2 are free */
+				        ;	
+        movq		mm0, mm3		;	
+        pmulhw		mm3, xC4S4		;	/* mm3 = xC4S4 * ( is0734 +is1256 ) - ( is0734 +is1256 ) */
+				        ;	
+        psrlw		mm2, 15		;	
+        paddw		mm3, mm0		;	/* mm3 = xC4S4 * ( is0734 +is1256 )	 */
+        paddw		mm3, mm2		;	/* Truncate mm3, now it is op[0] */
+				        ;	
+        movq		[eax], mm3		;	
+	        ;	/* ------------------------------------------------------------------- */
+        movq		mm3, [ecx]		;	/* mm3 = irot_input_y */
+        pmulhw		mm3, xC2S6	;	/* mm3 = xC2S6 * irot_input_y - irot_input_y */
+				        ;	
+        movq		mm2, [ecx]		;	
+        movq		mm0, mm2		;	
+				        ;	
+        psrlw		mm2, 15		;	/* mm3 = xC2S6 * irot_input_y */
+        paddw		mm3, mm0		;	
+				        ;	
+        paddw		mm3, mm2		;	/* Truncated */
+        movq		mm0, mm5		;	
+				        ;	
+        movq		mm2, mm5		;	
+        pmulhw		mm0, xC6S2		;	/* mm0 = xC6S2 * irot_input_x */
+				        ;	
+        psrlw		mm2, 15		;	
+        paddw		mm0, mm2		;	/* Truncated */
+				        ;	
+        paddsw		mm3, mm0		;	/* ip[2] */
+        movq		[32 + eax], mm3		;	/* Save ip2 */
+				        ;	
+        movq		mm0, mm5		;	
+        movq		mm2, mm5		;	
+				        ;	
+        pmulhw		mm5, xC2S6		;	/* mm5 = xC2S6 * irot_input_x - irot_input_x */
+        psrlw		mm2, 15		;	
+				        ;	
+        movq		mm3, [ecx]		;	
+        paddw		mm5, mm0		;	/* mm5 = xC2S6 * irot_input_x */
+				        ;	
+        paddw		mm5, mm2		;	/* Truncated */
+        movq		mm2, mm3		;	
+				        ;	
+        pmulhw		mm3, xC6S2		;	/* mm3 = xC6S2 * irot_input_y */
+        psrlw		mm2, 15		;	
+				        ;	
+        paddw		mm3, mm2		;	/* Truncated */
+        psubsw		mm3, mm5		;	
+				        ;	
+        movq		[32 + ebx], mm3		;	
+	        ;	/* ------------------------------------------------------------------- */
+        movq		mm0, xC4S4		;	
+        movq		mm2, mm1		;	
+        movq		mm3, mm1		;	
+				        ;	
+        pmulhw		mm1, mm0		;	/* mm0 = xC4S4 * ( is12 - is56 ) - ( is12 - is56 ) */
+        psrlw		mm2, 15		;	
+				        ;	
+        paddw		mm1, mm3		;	/* mm0 = xC4S4 * ( is12 - is56 ) */
+        paddw		mm1, mm2		;	/* Truncate mm1, now it is icommon_product1 */
+				        ;	
+        movq		mm2, mm7		;	
+        movq		mm3, mm7		;	
+				        ;	
+        pmulhw		mm7, mm0		;	/* mm7 = xC4S4 * ( id12 + id56 ) - ( id12 + id56 ) */
+        psrlw		mm2, 15		;	
+				        ;	
+        paddw		mm7, mm3		;	/* mm7 = xC4S4 * ( id12 + id56 ) */
+        paddw		mm7, mm2		;	/* Truncate mm7, now it is icommon_product2 */
+	        ;	/* ------------------------------------------------------------------- */
+        pxor		mm0, mm0		;	/* Clear mm0 */
+        psubsw		mm0, mm6		;	/* mm0 = - id34 */
+				        ;	
+        psubsw		mm0, mm7		;	/* mm0 = - ( id34 + idcommon_product2 ) */
+        paddsw		mm6, mm6		;	
+        paddsw		mm6, mm0		;	/* mm6 = id34 - icommon_product2 */
+				        ;	
+        psubsw		mm4, mm1		;	/* mm4 = id07 - icommon_product1 */
+        paddsw		mm1, mm1		;	
+        paddsw		mm1, mm4		;	/* mm1 = id07 + icommon_product1 */
+	        ;	/* ------------------------------------------------------------------- */
+        movq		mm7, xC1S7		;	
+        movq		mm2, mm1		;	
+				        ;	
+        movq		mm3, mm1		;	
+        pmulhw		mm1, mm7		;	/* mm1 = xC1S7 * irot_input_x - irot_input_x */
+				        ;	
+        movq		mm7, xC7S1		;	
+        psrlw		mm2, 15		;	
+				        ;	
+        paddw		mm1, mm3		;	/* mm1 = xC1S7 * irot_input_x */
+        paddw		mm1, mm2		;	/* Trucated */
+				        ;	
+        pmulhw		mm3, mm7		;	/* mm3 = xC7S1 * irot_input_x */
+        paddw		mm3, mm2		;	/* Truncated */
+				        ;	
+        movq		mm5, mm0		;	
+        movq		mm2, mm0		;	
+				        ;	
+        movq		mm7, xC1S7		;	
+        pmulhw		mm0, mm7		;	/* mm0 = xC1S7 * irot_input_y - irot_input_y */
+				        ;	
+        movq		mm7, xC7S1		;	
+        psrlw		mm2, 15		;	
+				        ;	
+        paddw		mm0, mm5		;	/* mm0 = xC1S7 * irot_input_y */
+        paddw		mm0, mm2		;	/* Truncated */
+				        ;	
+        pmulhw		mm5, mm7		;	/* mm5 = xC7S1 * irot_input_y */
+        paddw		mm5, mm2		;	/* Truncated */
+				        ;	
+        psubsw		mm1, mm5		;	/* mm1 = xC1S7 * irot_input_x - xC7S1 * irot_input_y = ip1 */
+        paddsw		mm3, mm0		;	/* mm3 = xC7S1 * irot_input_x - xC1S7 * irot_input_y = ip7 */
+				        ;	
+        movq		[16 + eax], mm1		;	
+        movq		[48 + ebx], mm3		;	
+	        ;	/* ------------------------------------------------------------------- */
+        movq		mm0, xC3S5		;	
+        movq		mm1, xC5S3		;	
+				        ;	
+        movq		mm5, mm6		;	
+        movq		mm7, mm6		;	
+				        ;	
+        movq		mm2, mm4		;	
+        movq		mm3, mm4		;	
+				        ;	
+        pmulhw		mm4, mm0		;	/* mm4 = xC3S5 * irot_input_x - irot_input_x */
+        pmulhw		mm6, mm1		;	/* mm6 = xC5S3 * irot_input_y - irot_input_y */
+				        ;	
+        psrlw		mm2, 15		;	
+        psrlw		mm5, 15		;	
+				        ;	
+        paddw		mm4, mm3		;	/* mm4 = xC3S5 * irot_input_x */
+        paddw		mm6, mm7		;	/* mm6 = xC5S3 * irot_input_y */
+				        ;	
+        paddw		mm4, mm2		;	/* Truncated */
+        paddw		mm6, mm5		;	/* Truncated */
+				        ;	
+        psubsw		mm4, mm6		;	/* ip3 */
+        movq		[48 + eax], mm4		;	
+				        ;	
+        movq		mm4, mm3		;	
+        movq		mm6, mm7		;	
+				        ;	
+        pmulhw		mm3, mm1		;	/* mm3 = xC5S3 * irot_input_x - irot_input_x */
+        pmulhw		mm7, mm0		;	/* mm7 = xC3S5 * irot_input_y - irot_input_y */
+				        ;	
+        paddw		mm4, mm2		;	
+        paddw		mm6, mm5		;	
+				        ;	
+        paddw		mm3, mm4		;	/* mm3 = xC5S3 * irot_input_x */
+        paddw		mm7, mm6		;	/* mm7 = xC3S5 * irot_input_y */
+				        ;	
+        paddw		mm3, mm7		;	/* ip5 */
+        movq		[16 + ebx], mm3		;	
+
+};
+
+}
+
+
+static void fdct_short__mmx ( ogg_int16_t *InputData, ogg_int16_t *OutputData)
+{
+
+  static ogg_int16_t tmp[32];
+  ogg_int16_t* align_tmp = (ogg_int16_t*)((unsigned char*)tmp + (16 - ((int)tmp)&15));
+
+
+  Transpose_mmx(InputData, OutputData, InputData + 4, OutputData + 4);
+  Fdct_mmx(OutputData, OutputData + 4, align_tmp);
+
+  Transpose_mmx(InputData + 32, OutputData + 32, InputData + 36, OutputData + 36);
+  Fdct_mmx(OutputData+32, OutputData + 36, align_tmp);
+
+  Transpose_mmx(OutputData, OutputData, OutputData + 32, OutputData + 32);
+  Fdct_mmx(OutputData, OutputData + 32, align_tmp);
+
+  Transpose_mmx(OutputData + 4, OutputData + 4, OutputData + 36, OutputData + 36);
+  Fdct_mmx(OutputData + 4, OutputData + 36, align_tmp);
+
+  __asm     emms
+
+}
+
+void dsp_mmx_fdct_init(DspFunctions *funcs)
+{
+  funcs->fdct_short = fdct_short__mmx;
+}
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86_32_vs/recon_mmx.c b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86_32_vs/recon_mmx.c
new file mode 100644
index 0000000..9bddf5a
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/enc/x86_32_vs/recon_mmx.c
@@ -0,0 +1,103 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation http://www.xiph.org/                  *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+  last mod: $Id: reconstruct.c,v 1.6 2003/12/03 08:59:41 arc Exp $
+
+ ********************************************************************/
+
+#include "codec_internal.h"
+
+
+static const unsigned __int64 V128 = 0x8080808080808080;
+
+static void copy8x8__mmx (unsigned char *src,
+	                unsigned char *dest,
+	                unsigned int stride)
+{
+
+    //Is this even the fastest way to do this?
+    __asm {
+        align 16        
+
+        mov         eax, src
+        mov         ebx, dest
+        mov         ecx, stride
+
+        lea		    edi, [ecx + ecx * 2]
+        movq		mm0, [eax]
+        movq		mm1, [eax + ecx]
+        movq		mm2, [eax + ecx * 2]
+        movq		mm3, [eax + edi]
+        lea		    eax, [eax + ecx * 4]
+        movq		[ebx], mm0
+        movq		[ebx + ecx], mm1
+        movq		[ebx + ecx * 2], mm2
+        movq		[ebx + edi], mm3
+        lea		    ebx, [ebx + ecx * 4]
+        movq		mm0, [eax]
+        movq		mm1, [eax + ecx]
+        movq		mm2, [eax + ecx * 2]
+        movq		mm3, [eax + edi]
+        movq		[ebx], mm0
+        movq		[ebx + ecx], mm1
+        movq		[ebx + ecx * 2], mm2
+        movq		[ebx + edi], mm3
+
+    };
+
+}
+
+static void recon8x8__mmx (unsigned char *ReconPtr, 
+			   ogg_int16_t *ChangePtr, ogg_uint32_t LineStep)
+{
+
+    __asm {
+
+        align 16
+
+        mov         eax, ReconPtr
+        mov         ebx, ChangePtr
+        mov         ecx, LineStep
+    
+        pxor		mm0, mm0
+        lea		    edi, [128 + ebx]
+
+    loop_start:
+        movq		mm2, [eax]
+
+        movq		mm4, [ebx]
+        movq		mm3, mm2
+        movq		mm5, [8 + ebx]
+
+        punpcklbw	mm2, mm0
+        paddsw		mm2, mm4
+        punpckhbw	mm3, mm0
+        paddsw		mm3, mm5
+        packuswb	mm2, mm3
+        lea		    ebx, [16 + ebx]
+        cmp		    ebx, edi
+
+        movq		[eax], mm2
+
+        lea		    eax, [eax + ecx]
+        jc		    loop_start
+
+    };
+}
+
+void dsp_mmx_recon_init(DspFunctions *funcs)
+{
+  funcs->copy8x8 = copy8x8__mmx;
+  funcs->recon8x8 = recon8x8__mmx;
+}
+
diff --git a/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/internal.h b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/internal.h
new file mode 100644
index 0000000..d048efa
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/libtheora-1.1alpha2/lib/internal.h
@@ -0,0 +1,529 @@
+/********************************************************************
+ *                                                                  *
+ * THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *
+ *                                                                  *
+ * THE Theora SOURCE CODE IS COPYRIGHT (C) 2002-2007                *
+ * by the Xiph.Org Foundation and contributors http://www.xiph.org/ *
+ *                                                                  *
+ ********************************************************************
+
+  function:
+    last mod: $Id: internal.h 16038 2009-05-26 22:43:19Z giles $
+
+ ********************************************************************/
+
+#if !defined(_internal_H)
+# define _internal_H (1)
+# include <stdlib.h>
+# if defined(HAVE_CONFIG_H)
+#  include <config.h>
+# endif
+/* KITWARE_OGGTHEORA_CHANGE make sure we include the right headers */
+# include "vtkoggtheora/include/theora/codec.h"
+# include "vtkoggtheora/include/theora/theora.h"
+
+# if defined(_MSC_VER)
+/*Thank you Microsoft, I know the order of operations.*/
+#  pragma warning(disable:4554)
+/*Disable missing EMMS warnings.*/
+#  pragma warning(disable:4799)
+# endif
+/*You, too, gcc.*/
+# if defined(__GNUC_PREREQ)
+#  if __GNUC_PREREQ(4,2)
+#   pragma GCC diagnostic ignored "-Wparentheses"
+#  endif
+# endif
+
+# include "dec/ocintrin.h"
+# include "dec/huffman.h"
+# include "dec/quant.h"
+
+/*Some assembly constructs require aligned operands.*/
+# if defined(OC_X86_ASM)
+#  if defined(__GNUC__)
+#   define OC_ALIGN8 __attribute__((aligned(8)))
+#   define OC_ALIGN16 __attribute__((aligned(16)))
+#  endif
+# endif
+# if !defined(OC_ALIGN8)
+#  define OC_ALIGN8
+# endif
+# if !defined(OC_ALIGN16)
+#  define OC_ALIGN16
+# endif
+
+
+
+typedef struct oc_sb_flags              oc_sb_flags;
+typedef struct oc_border_info           oc_border_info;
+typedef struct oc_fragment              oc_fragment;
+typedef struct oc_fragment_plane        oc_fragment_plane;
+typedef struct oc_base_opt_vtable       oc_base_opt_vtable;
+typedef struct oc_state_dispatch_vtable oc_state_dispatch_vtable;
+typedef struct oc_theora_state          oc_theora_state;
+
+
+
+/*This library's version.*/
+# define OC_VENDOR_STRING "Xiph.Org libThusnelda I 20090526"
+
+/*Theora bitstream version.*/
+# define TH_VERSION_MAJOR (3)
+# define TH_VERSION_MINOR (2)
+# define TH_VERSION_SUB   (1)
+# define TH_VERSION_CHECK(_info,_maj,_min,_sub) \
+ ((_info)->version_major>(_maj)||(_info)->version_major==(_maj)&& \
+ ((_info)->version_minor>(_min)||(_info)->version_minor==(_min)&& \
+ (_info)->version_subminor>=(_sub)))
+
+/*A keyframe.*/
+#define OC_INTRA_FRAME (0)
+/*A predicted frame.*/
+#define OC_INTER_FRAME (1)
+/*A frame of unknown type (frame type decision has not yet been made).*/
+#define OC_UNKWN_FRAME (-1)
+
+/*The amount of padding to add to the reconstructed frame buffers on all
+   sides.
+  This is used to allow unrestricted motion vectors without special casing.
+  This must be a multiple of 2.*/
+#define OC_UMV_PADDING (16)
+
+/*Frame classification indices.*/
+/*The previous golden frame.*/
+#define OC_FRAME_GOLD (0)
+/*The previous frame.*/
+#define OC_FRAME_PREV (1)
+/*The current frame.*/
+#define OC_FRAME_SELF (2)
+
+/*The input or output buffer.*/
+#define OC_FRAME_IO   (3)
+
+/*Macroblock modes.*/
+/*Macro block is invalid: It is never coded.*/
+#define OC_MODE_INVALID        (-1)
+/*Encoded difference from the same macro block in the previous frame.*/
+#define OC_MODE_INTER_NOMV     (0)
+/*Encoded with no motion compensated prediction.*/
+#define OC_MODE_INTRA          (1)
+/*Encoded difference from the previous frame offset by the given motion 
+  vector.*/
+#define OC_MODE_INTER_MV       (2)
+/*Encoded difference from the previous frame offset by the last coded motion 
+  vector.*/
+#define OC_MODE_INTER_MV_LAST  (3)
+/*Encoded difference from the previous frame offset by the second to last 
+  coded motion vector.*/
+#define OC_MODE_INTER_MV_LAST2 (4)
+/*Encoded difference from the same macro block in the previous golden 
+  frame.*/
+#define OC_MODE_GOLDEN_NOMV    (5)
+/*Encoded difference from the previous golden frame offset by the given motion 
+  vector.*/
+#define OC_MODE_GOLDEN_MV      (6)
+/*Encoded difference from the previous frame offset by the individual motion 
+  vectors given for each block.*/
+#define OC_MODE_INTER_MV_FOUR  (7)
+/*The number of (coded) modes.*/
+#define OC_NMODES              (8)
+
+/*Macro block is not coded.*/
+#define OC_MODE_NOT_CODED      (8)
+
+/*Predictor bit flags.*/
+/*Left.*/
+#define OC_PL  (1)
+/*Upper-left.*/
+#define OC_PUL (2)
+/*Up.*/
+#define OC_PU  (4)
+/*Upper-right.*/
+#define OC_PUR (8)
+
+/*Constants for the packet state machine common between encoder and decoder.*/
+
+/*Next packet to emit/read: Codec info header.*/
+#define OC_PACKET_INFO_HDR    (-3)
+/*Next packet to emit/read: Comment header.*/
+#define OC_PACKET_COMMENT_HDR (-2)
+/*Next packet to emit/read: Codec setup header.*/
+#define OC_PACKET_SETUP_HDR   (-1)
+/*No more packets to emit/read.*/
+#define OC_PACKET_DONE        (INT_MAX)
+
+
+
+/*Super blocks are 32x32 segments of pixels in a single color plane indexed
+   in image order.
+  Internally, super blocks are broken up into four quadrants, each of which
+   contains a 2x2 pattern of blocks, each of which is an 8x8 block of pixels.
+  Quadrants, and the blocks within them, are indexed in a special order called
+   a "Hilbert curve" within the super block.
+
+  In order to differentiate between the Hilbert-curve indexing strategy and
+   the regular image order indexing strategy, blocks indexed in image order
+   are called "fragments".
+  Fragments are indexed in image order, left to right, then bottom to top,
+   from Y' plane to Cb plane to Cr plane.
+
+  The co-located fragments in all image planes corresponding to the location
+   of a single quadrant of a luma plane super block form a macro block.
+  Thus there is only a single set of macro blocks for all planes, each of which
+   contains between 6 and 12 fragments, depending on the pixel format.
+  Therefore macro block information is kept in a separate set of arrays from
+   super blocks to avoid unused space in the other planes.
+  The lists are indexed in super block order.
+  That is, the macro block corresponding to the macro block mbi in (luma plane)
+   super block sbi is at index (sbi<<2|mbi).
+  Thus the number of macro blocks in each dimension is always twice the number
+   of super blocks, even when only an odd number fall inside the coded frame.
+  These "extra" macro blocks are just an artifact of our internal data layout,
+   and not part of the coded stream; they are flagged with a negative MB mode.*/
+
+
+
+/*A single quadrant of the map from a super block to fragment numbers.*/
+typedef ptrdiff_t       oc_sb_map_quad[4];
+/*A map from a super block to fragment numbers.*/
+typedef oc_sb_map_quad  oc_sb_map[4];
+/*A single plane of the map from a macro block to fragment numbers.*/
+typedef ptrdiff_t       oc_mb_map_plane[4];
+/*A map from a macro block to fragment numbers.*/
+typedef oc_mb_map_plane oc_mb_map[3];
+/*A motion vector.*/
+typedef signed char     oc_mv[2];
+
+
+
+/*Super block information.*/
+struct oc_sb_flags{
+  unsigned char coded_fully:1;
+  unsigned char coded_partially:1;
+  unsigned char quad_valid:4;
+};
+
+
+
+/*Information about a fragment which intersects the border of the displayable
+   region.
+  This marks which pixels belong to the displayable region, and is used to
+   ensure that pixels outside of this region are never referenced.
+  This allows applications to pass in buffers that are really the size of the
+   displayable region without causing a segfault.*/
+struct oc_border_info{
+  /*A bit mask marking which pixels are in the displayable region.
+    Pixel (x,y) corresponds to bit (y<<3|x).*/
+  ogg_int64_t mask;
+  /*The number of pixels in the displayable region.
+    This is always positive, and always less than 64.*/
+  int         npixels;
+};
+
+
+
+/*Fragment information.*/
+struct oc_fragment{
+  /*A flag indicating whether or not this fragment is coded.*/
+  unsigned   coded:1;
+  /*A flag indicating that this entire fragment lies outside the displayable
+     region of the frame.
+    Note the contrast with an invalid macro block, which is outside the coded
+     frame, not just the displayable one.
+    There are no fragments outside the coded frame by construction.*/
+  unsigned   invalid:1;
+  /*The quality index used for this fragment's AC coefficients.*/
+  unsigned   qi:6;
+  /*The mode of the macroblock this fragment belongs to.*/
+  unsigned   mb_mode:3;
+  /*The index of the associated border information for fragments which lie
+     partially outside the displayable region.
+    For fragments completely inside or outside this region, this is -1.
+    Note that the C standard requires an explicit signed keyword for bitfield
+     types, since some compilers may treat them as unsigned without it.*/
+  signed int borderi:5;
+  /*The prediction-corrected DC component.
+    Note that the C standard requires an explicit signed keyword for bitfield
+     types, since some compilers may treat them as unsigned without it.*/
+  signed int dc:16;
+};
+
+
+
+/*A description of each fragment plane.*/
+struct oc_fragment_plane{
+  /*The number of fragments in the horizontal direction.*/
+  int       nhfrags;
+  /*The number of fragments in the vertical direction.*/
+  int       nvfrags;
+  /*The offset of the first fragment in the plane.*/
+  ptrdiff_t froffset;
+  /*The total number of fragments in the plane.*/
+  ptrdiff_t nfrags;
+  /*The number of super blocks in the horizontal direction.*/
+  unsigned  nhsbs;
+  /*The number of super blocks in the vertical direction.*/
+  unsigned  nvsbs;
+  /*The offset of the first super block in the plane.*/
+  unsigned  sboffset;
+  /*The total number of super blocks in the plane.*/
+  unsigned  nsbs;
+};
+
+
+
+/*The shared (encoder and decoder) functions that have accelerated variants.*/
+struct oc_base_opt_vtable{
+  void (*frag_copy)(unsigned char *_dst,
+   const unsigned char *_src,int _ystride);
+  void (*frag_recon_intra)(unsigned char *_dst,int _ystride,
+   const ogg_int16_t _residue[64]);
+  void (*frag_recon_inter)(unsigned char *_dst,
+   const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]);
+  void (*frag_recon_inter2)(unsigned char *_dst,const unsigned char *_src1,
+   const unsigned char *_src2,int _ystride,const ogg_int16_t _residue[64]);
+  void (*dequant_idct8x8)(ogg_int16_t _y[64],const ogg_int16_t _x[64],
+   int _last_zzi,int _ncoefs,ogg_uint16_t _dc_quant,
+   const ogg_uint16_t _ac_quant[64]);
+  void (*state_frag_recon)(const oc_theora_state *_state,ptrdiff_t _fragi,
+   int _pli,ogg_int16_t _dct_coeffs[64],int _last_zzi,int _ncoefs,
+   ogg_uint16_t _dc_quant,const ogg_uint16_t _ac_quant[64]);
+  void (*state_frag_copy_list)(const oc_theora_state *_state,
+   const ptrdiff_t *_fragis,ptrdiff_t _nfragis,
+   int _dst_frame,int _src_frame,int _pli);
+  void (*state_loop_filter_frag_rows)(const oc_theora_state *_state,
+   int _bv[256],int _refi,int _pli,int _fragy0,int _fragy_end);  
+  void (*restore_fpu)(void);
+};
+
+
+
+/*Common state information between the encoder and decoder.*/
+struct oc_theora_state{
+  /*The stream information.*/
+  th_info             info;
+  /*Table for shared accelerated functions.*/
+  oc_base_opt_vtable  opt_vtable;
+  /*CPU flags to detect the presence of extended instruction sets.*/
+  ogg_uint32_t        cpu_flags;
+  /*The fragment plane descriptions.*/
+  oc_fragment_plane   fplanes[3];
+  /*The list of fragments, indexed in image order.*/
+  oc_fragment        *frags;
+  /*The the offset into the reference frame buffer to the upper-left pixel of
+     each fragment.*/
+  ptrdiff_t          *frag_buf_offs;
+  /*The motion vector for each fragment.*/
+  oc_mv              *frag_mvs;
+  /*The total number of fragments in a single frame.*/
+  ptrdiff_t           nfrags;
+  /*The list of super block maps, indexed in image order.*/
+  oc_sb_map          *sb_maps;
+  /*The list of super block flags, indexed in image order.*/
+  oc_sb_flags        *sb_flags;
+  /*The total number of super blocks in a single frame.*/
+  unsigned            nsbs;
+  /*The number of macro blocks in the X direction.*/
+  unsigned            nhmbs;
+  /*The number of macro blocks in the Y direction.*/
+  unsigned            nvmbs;
+  /*The total number of macro blocks.*/
+  size_t              nmbs;
+  /*The fragments from each color plane that belong to each macro block.
+    Fragments are stored in image order (left to right then top to bottom).
+    When chroma components are decimated, the extra fragments have an index of
+     -1.*/
+  oc_mb_map          *mb_maps;
+  /*The list of macro block modes.
+    A negative number indicates the macro block lies entirely outside the
+     coded frame.*/
+  signed char        *mb_modes;
+  /*The list of coded fragments, in coded order.*/
+  ptrdiff_t          *coded_fragis;
+  /*The number of coded fragments in each plane.*/
+  ptrdiff_t           ncoded_fragis[3];
+  /*The list of uncoded fragments.
+    This just past the end of the list, which is in reverse order, and
+     uses the same block of allocated storage as the coded_fragis list.*/
+  ptrdiff_t          *uncoded_fragis;
+  /*The number of uncoded fragments in each plane.*/
+  ptrdiff_t           nuncoded_fragis[3];
+  /*The list of coded macro blocks in the Y plane, in coded order.*/
+  unsigned           *coded_mbis;
+  /*The number of coded macro blocks in the Y plane.*/
+  size_t              ncoded_mbis;
+  /*The number of unique border patterns.*/
+  int                 nborders;
+  /*The unique border patterns for all border fragments.
+    The borderi field of fragments which straddle the border indexes this
+     list.*/
+  oc_border_info      borders[16];
+  /*The index of the buffers being used for each OC_FRAME_* reference frame.*/
+  int                 ref_frame_idx[3];
+  /*The actual buffers used for the previously decoded frames.*/
+  th_ycbcr_buffer     ref_frame_bufs[3];
+  /*The storage for the reference frame buffers.*/
+  unsigned char      *ref_frame_data[3];
+  /*The frame number of the last keyframe.*/
+  ogg_int64_t         keyframe_num;
+  /*The frame number of the current frame.*/
+  ogg_int64_t         curframe_num;
+  /*The granpos of the current frame.*/
+  ogg_int64_t         granpos;
+  /*The type of the current frame.*/
+  int                 frame_type;
+  /*The quality indices of the current frame.*/
+  unsigned char       qis[3];
+  /*The number of quality indices used in the current frame.*/
+  unsigned char       nqis;
+  /*The dequantization tables.
+    Note that these are stored in zig-zag order.*/
+  oc_quant_table     *dequant_tables[2][3];
+  oc_quant_tables     dequant_table_data[2][3]OC_ALIGN16;
+  /*Loop filter strength parameters.*/
+  unsigned char       loop_filter_limits[64];
+};
+
+
+
+/*The function type used to fill in the chroma plane motion vectors for a
+   macro block when 4 different motion vectors are specified in the luma
+   plane.
+  _cbmvs: The chroma block-level motion vectors to fill in.
+  _lmbmv: The luma macro-block level motion vector to fill in for use in
+           prediction.
+  _lbmvs: The luma block-level motion vectors.*/
+typedef void (*oc_set_chroma_mvs_func)(oc_mv _cbmvs[4],const oc_mv _lbmvs[4]);
+
+
+
+/*A map from the index in the zig zag scan to the coefficient number in a
+   block.*/
+extern const unsigned char OC_FZIG_ZAG[64];
+/*A map from the coefficient number in a block to its index in the zig zag
+   scan.*/
+extern const unsigned char OC_IZIG_ZAG[64];
+/*The predictor frame to use for each macro block mode.*/
+extern const unsigned char OC_FRAME_FOR_MODE[OC_NMODES];
+/*A map from physical macro block ordering to bitstream macro block
+   ordering within a super block.*/
+extern const unsigned char OC_MB_MAP[2][2];
+/*A list of the indices in the oc_mb_map array that can be valid for each of
+   the various chroma decimation types.*/
+extern const unsigned char OC_MB_MAP_IDXS[TH_PF_NFORMATS][12];
+/*The number of indices in the oc_mb_map array that can be valid for each of
+   the various chroma decimation types.*/
+extern const unsigned char OC_MB_MAP_NIDXS[TH_PF_NFORMATS];
+/*A table of functions used to fill in the Cb,Cr plane motion vectors for a
+   macro block when 4 different motion vectors are specified in the luma
+   plane.*/
+extern const oc_set_chroma_mvs_func OC_SET_CHROMA_MVS_TABLE[TH_PF_NFORMATS];
+
+
+
+int oc_ilog(unsigned _v);
+void **oc_malloc_2d(size_t _height,size_t _width,size_t _sz);
+void **oc_calloc_2d(size_t _height,size_t _width,size_t _sz);
+void oc_free_2d(void *_ptr);
+
+void oc_ycbcr_buffer_flip(th_ycbcr_buffer _dst,
+ const th_ycbcr_buffer _src);
+
+ptrdiff_t oc_dct_token_skip(int _token,int _extra_bits);
+
+int oc_frag_pred_dc(const oc_fragment *_frag,
+ const oc_fragment_plane *_fplane,int _x,int _y,int _pred_last[3]);
+
+int oc_state_init(oc_theora_state *_state,const th_info *_info);
+void oc_state_clear(oc_theora_state *_state);
+void oc_state_vtable_init_c(oc_theora_state *_state);
+void oc_state_borders_fill_rows(oc_theora_state *_state,int _refi,int _pli,
+ int _y0,int _yend);
+void oc_state_borders_fill_caps(oc_theora_state *_state,int _refi,int _pli);
+void oc_state_borders_fill(oc_theora_state *_state,int _refi);
+void oc_state_fill_buffer_ptrs(oc_theora_state *_state,int _buf_idx,
+ th_ycbcr_buffer _img);
+int oc_state_mbi_for_pos(oc_theora_state *_state,int _mbx,int _mby);
+int oc_state_get_mv_offsets(const oc_theora_state *_state,int *_offsets,
+ int _dx,int _dy,int _ystride,int _pli);
+
+int oc_state_loop_filter_init(oc_theora_state *_state,int *_bv);
+void oc_state_loop_filter(oc_theora_state *_state,int _frame);
+#if defined(OC_DUMP_IMAGES)
+int oc_state_dump_frame(const oc_theora_state *_state,int _frame,
+ const char *_suf);
+#endif
+
+/*Shared accelerated functions.*/
+void oc_frag_copy(const oc_theora_state *_state,unsigned char *_dst,
+ const unsigned char *_src,int _ystride);
+void oc_frag_recon_intra(const oc_theora_state *_state,
+ unsigned char *_dst,int _dst_ystride,const ogg_int16_t _residue[64]);
+void oc_frag_recon_inter(const oc_theora_state *_state,unsigned char *_dst,
+ const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]);
+void oc_frag_recon_inter2(const oc_theora_state *_state,
+ unsigned char *_dst,const unsigned char *_src1,const unsigned char *_src2,
+ int _ystride,const ogg_int16_t _residue[64]);
+void oc_dequant_idct8x8(const oc_theora_state *_state,ogg_int16_t _y[64],
+ const ogg_int16_t _x[64],int _last_zzi,int _ncoefs,
+ ogg_uint16_t _dc_quant,const ogg_uint16_t _ac_quant[64]);
+void oc_state_frag_recon(const oc_theora_state *_state,ptrdiff_t _fragi,
+ int _pli,ogg_int16_t _dct_coeffs[64],int _last_zzi,int _ncoefs,
+ ogg_uint16_t _dc_quant,const ogg_uint16_t _ac_quant[64]);
+void oc_state_frag_copy_list(const oc_theora_state *_state,
+ const ptrdiff_t *_fragis,ptrdiff_t _nfragis,
+ int _dst_frame,int _src_frame,int _pli);
+void oc_state_loop_filter_frag_rows(const oc_theora_state *_state,
+ int _bv[256],int _refi,int _pli,int _fragy0,int _fragy_end);
+void oc_restore_fpu(const oc_theora_state *_state);
+
+/*Default pure-C implementations.*/
+void oc_frag_copy_c(unsigned char *_dst,
+ const unsigned char *_src,int _src_ystride);
+void oc_frag_recon_intra_c(unsigned char *_dst,int _dst_ystride,
+ const ogg_int16_t _residue[64]);
+void oc_frag_recon_inter_c(unsigned char *_dst,
+ const unsigned char *_src,int _ystride,const ogg_int16_t _residue[64]);
+void oc_frag_recon_inter2_c(unsigned char *_dst,const unsigned char *_src1,
+ const unsigned char *_src2,int _ystride,const ogg_int16_t _residue[64]);
+void oc_dequant_idct8x8_c(ogg_int16_t _y[64],const ogg_int16_t _x[64],
+ int _last_zzi,int _ncoefs,ogg_uint16_t _dc_quant,
+ const ogg_uint16_t _ac_quant[64]);
+void oc_state_frag_recon_c(const oc_theora_state *_state,ptrdiff_t _fragi,
+ int _pli,ogg_int16_t _dct_coeffs[64],int _last_zzi,int _ncoefs,
+ ogg_uint16_t _dc_quant,const ogg_uint16_t _ac_quant[64]);
+void oc_state_frag_copy_list_c(const oc_theora_state *_state,
+ const ptrdiff_t *_fragis,ptrdiff_t _nfragis,
+ int _dst_frame,int _src_frame,int _pli);
+void oc_state_loop_filter_frag_rows_c(const oc_theora_state *_state,
+ int _bv[256],int _refi,int _pli,int _fragy0,int _fragy_end);
+void oc_restore_fpu_c(void);
+
+/*We need a way to call a few encoder functions without introducing a link-time
+   dependency into the decoder, while still allowing the old alpha API which
+   does not distinguish between encoder and decoder objects to be used.
+  We do this by placing a function table at the start of the encoder object
+   which can dispatch into the encoder library.
+  We do a similar thing for the decoder in case we ever decide to split off a
+   common base library.*/
+typedef void (*oc_state_clear_func)(theora_state *_th);
+typedef int (*oc_state_control_func)(theora_state *th,int _req,
+ void *_buf,size_t _buf_sz);
+typedef ogg_int64_t (*oc_state_granule_frame_func)(theora_state *_th,
+ ogg_int64_t _granulepos);
+typedef double (*oc_state_granule_time_func)(theora_state *_th,
+ ogg_int64_t _granulepos);
+
+
+struct oc_state_dispatch_vtable{
+  oc_state_clear_func         clear;
+  oc_state_control_func       control;
+  oc_state_granule_frame_func granule_frame;
+  oc_state_granule_time_func  granule_time;
+};
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/vtk_oggtheora_mangle.h b/VTK/Utilities/vtkoggtheora/vtk_oggtheora_mangle.h
new file mode 100644
index 0000000..5e3380d
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/vtk_oggtheora_mangle.h
@@ -0,0 +1,405 @@
+#ifndef vtk_oggtheora_mangle_h
+#define vtk_oggtheora_mangle_h
+
+/*
+
+This header file mangles all symbols exported from the oggtheora library.
+It is included in all files while building the oggtheora library.  Due to
+namespace pollution, no oggtheora headers should be included in .h files in
+VTK.
+
+The following command was used to obtain the symbol list:
+
+nm libvtkoggtheora.so |grep " [TRD] "
+
+This is the way to recreate the whole list:
+
+nm libvtkoggtheora.so |egrep -i "^[[:digit:]]{8} [TRD] " | awk '{ gsub(/^_/,"",$3);  print "#define "$3" vtk_zlib_"$3 }'
+
+REMOVE the "_init" "_fini", "_.*dyld.*", "_.*dylib.*"  and "_xC.*" entries.
+
+*/
+
+#define AnalysePlane vtk_oggtheora_AnalysePlane
+#define BodyNeighbourScore vtk_oggtheora_BodyNeighbourScore
+#define ClearDownQFragData vtk_oggtheora_ClearDownQFragData
+#define ClearFragmentInfo vtk_oggtheora_ClearFragmentInfo
+#define ClearFrameInfo vtk_oggtheora_ClearFrameInfo
+#define ClearHuffmanSet vtk_oggtheora_ClearHuffmanSet
+#define ClearHuffmanTrees vtk_oggtheora_ClearHuffmanTrees
+#define ClearPBInstance vtk_oggtheora_ClearPBInstance
+#define ClearPPInstance vtk_oggtheora_ClearPPInstance
+#define ClearTmpBuffers vtk_oggtheora_ClearTmpBuffers
+#define CompressKeyFrame vtk_oggtheora_CompressKeyFrame
+#define ConfigurePP vtk_oggtheora_ConfigurePP
+#define CopyBackExtraFrags vtk_oggtheora_CopyBackExtraFrags
+#define CopyHuffTree vtk_oggtheora_CopyHuffTree
+#define CreateBlockMapping vtk_oggtheora_CreateBlockMapping
+#define CreateCodeArray vtk_oggtheora_CreateCodeArray
+#define DPCMTokenizeBlock vtk_oggtheora_DPCMTokenizeBlock
+#define DeblockFrame vtk_oggtheora_DeblockFrame
+#define DeblockPlane vtk_oggtheora_DeblockPlane
+#define DeringBlockStrong vtk_oggtheora_DeringBlockStrong
+#define DeringBlockWeak vtk_oggtheora_DeringBlockWeak
+#define DeringFrame vtk_oggtheora_DeringFrame
+#define DestroyHuffTree vtk_oggtheora_DestroyHuffTree
+#define DiffDevisor vtk_oggtheora_DiffDevisor
+#define EClearFragmentInfo vtk_oggtheora_EClearFragmentInfo
+#define EClearFrameInfo vtk_oggtheora_EClearFrameInfo
+#define EncodeData vtk_oggtheora_EncodeData
+#define ExpandBlock vtk_oggtheora_ExpandBlock
+#define ExpandKFBlock vtk_oggtheora_ExpandKFBlock
+#define ExpandToken vtk_oggtheora_ExpandToken
+#define GetBMVExhaustiveSearch vtk_oggtheora_GetBMVExhaustiveSearch
+#define GetEstimatedBpb vtk_oggtheora_GetEstimatedBpb
+#define GetFOURMVExhaustiveSearch vtk_oggtheora_GetFOURMVExhaustiveSearch
+#define GetMBInterError vtk_oggtheora_GetMBInterError
+#define GetMBIntraError vtk_oggtheora_GetMBIntraError
+#define GetMBMVExhaustiveSearch vtk_oggtheora_GetMBMVExhaustiveSearch
+#define GetMBMVInterError vtk_oggtheora_GetMBMVInterError
+#define IDct1 vtk_oggtheora_IDct1
+#define IDct10__c vtk_oggtheora_IDct10__c
+#define IDct10__mmx vtk_oggtheora_IDct10__mmx
+#define IDct3__mmx vtk_oggtheora_IDct3__mmx
+#define IDctSlow__c vtk_oggtheora_IDctSlow__c
+#define IDctSlow__mmx vtk_oggtheora_IDctSlow__mmx
+#define InitFragmentInfo vtk_oggtheora_InitFragmentInfo
+#define InitFrameDetails vtk_oggtheora_InitFrameDetails
+#define InitFrameInfo vtk_oggtheora_InitFrameInfo
+#define InitHuffmanSet vtk_oggtheora_InitHuffmanSet
+#define InitHuffmanTrees vtk_oggtheora_InitHuffmanTrees
+#define InitMotionCompensation vtk_oggtheora_InitMotionCompensation
+#define InitPBInstance vtk_oggtheora_InitPBInstance
+#define InitPPInstance vtk_oggtheora_InitPPInstance
+#define InitQTables vtk_oggtheora_InitQTables
+#define InitScanMapArrays vtk_oggtheora_InitScanMapArrays
+#define InitTmpBuffers vtk_oggtheora_InitTmpBuffers
+#define InitializeFragCoordinates vtk_oggtheora_InitializeFragCoordinates
+#define LineLengthScores vtk_oggtheora_LineLengthScores
+#define LoopFilter__c vtk_oggtheora_LoopFilter__c
+#define ModeUsesMC vtk_oggtheora_ModeUsesMC
+#define PClearFrameInfo vtk_oggtheora_PClearFrameInfo
+#define PInitFrameInfo vtk_oggtheora_PInitFrameInfo
+#define PackAndWriteDFArray vtk_oggtheora_PackAndWriteDFArray
+#define PackToken vtk_oggtheora_PackToken
+#define PickIntra vtk_oggtheora_PickIntra
+#define PickModes vtk_oggtheora_PickModes
+#define PixelLineSearch vtk_oggtheora_PixelLineSearch
+#define PostProcess vtk_oggtheora_PostProcess
+#define PrimaryEdgeScoreRow vtk_oggtheora_PrimaryEdgeScoreRow
+#define QuadCodeComponent vtk_oggtheora_QuadCodeComponent
+#define ReadHuffTree vtk_oggtheora_ReadHuffTree
+#define ReadHuffmanTrees vtk_oggtheora_ReadHuffmanTrees
+#define ReconRefFrames vtk_oggtheora_ReconRefFrames
+#define RegulateQ vtk_oggtheora_RegulateQ
+#define RowChangedLocalsScan vtk_oggtheora_RowChangedLocalsScan
+#define ScanYUVInit vtk_oggtheora_ScanYUVInit
+#define SetMBMotionVectorsAndMode vtk_oggtheora_SetMBMotionVectorsAndMode
+#define TokenizeDctValue vtk_oggtheora_TokenizeDctValue
+#define TransformQuantizeBlock vtk_oggtheora_TransformQuantizeBlock
+#define UpRegulateDataStream vtk_oggtheora_UpRegulateDataStream
+#define UpRegulateMB vtk_oggtheora_UpRegulateMB
+#define UpdateFragQIndex vtk_oggtheora_UpdateFragQIndex
+#define UpdateFrame vtk_oggtheora_UpdateFrame
+#define UpdateQ vtk_oggtheora_UpdateQ
+#define UpdateQC vtk_oggtheora_UpdateQC
+#define UpdateUMVBorder vtk_oggtheora_UpdateUMVBorder
+#define WriteFrameHeader vtk_oggtheora_WriteFrameHeader
+#define WriteHuffTree vtk_oggtheora_WriteHuffTree
+#define WriteHuffmanTrees vtk_oggtheora_WriteHuffmanTrees
+#define WriteQTables vtk_oggtheora_WriteQTables
+#define YUVAnalyseFrame vtk_oggtheora_YUVAnalyseFrame
+#define col_sad8x8__c vtk_oggtheora_col_sad8x8__c
+#define col_sad8x8__mmx vtk_oggtheora_col_sad8x8__mmx
+#define col_sad8x8__mmxext vtk_oggtheora_col_sad8x8__mmxext
+#define copy8x8__c vtk_oggtheora_copy8x8__c
+#define copy8x8__mmx vtk_oggtheora_copy8x8__mmx
+#define dsp_dct_decode_init vtk_oggtheora_dsp_dct_decode_init
+#define dsp_dct_init vtk_oggtheora_dsp_dct_init
+#define dsp_idct_init vtk_oggtheora_dsp_idct_init
+#define dsp_init vtk_oggtheora_dsp_init
+#define dsp_mmx_dct_decode_init vtk_oggtheora_dsp_mmx_dct_decode_init
+#define dsp_mmx_fdct_init vtk_oggtheora_dsp_mmx_fdct_init
+#define dsp_mmx_idct_init vtk_oggtheora_dsp_mmx_idct_init
+#define dsp_mmx_init vtk_oggtheora_dsp_mmx_init
+#define dsp_mmx_recon_init vtk_oggtheora_dsp_mmx_recon_init
+#define dsp_mmxext_init vtk_oggtheora_dsp_mmxext_init
+#define dsp_recon_init vtk_oggtheora_dsp_recon_init
+#define dsp_static_init vtk_oggtheora_dsp_static_init
+#define fdct_short__c vtk_oggtheora_fdct_short__c
+#define fdct_short__mmx vtk_oggtheora_fdct_short__mmx
+#define idct8 vtk_oggtheora_idct8
+#define idct8_4 vtk_oggtheora_idct8_4
+#define idctconstants vtk_oggtheora_idctconstants
+#define inter8x8_err__c vtk_oggtheora_inter8x8_err__c
+#define inter8x8_err__mmx vtk_oggtheora_inter8x8_err__mmx
+#define inter8x8_err_xy2__c vtk_oggtheora_inter8x8_err_xy2__c
+#define inter8x8_err_xy2__mmx vtk_oggtheora_inter8x8_err_xy2__mmx
+#define inter8x8_err_xy2__mmxext vtk_oggtheora_inter8x8_err_xy2__mmxext
+#define intra8x8_err__c vtk_oggtheora_intra8x8_err__c
+#define intra8x8_err__mmx vtk_oggtheora_intra8x8_err__mmx
+#define loop_filter_mmx vtk_oggtheora_loop_filter_mmx
+#define nop vtk_oggtheora_nop
+#define oc_calloc_2d vtk_oggtheora_oc_calloc_2d
+#define oc_clc_mode_unpack vtk_oggtheora_oc_clc_mode_unpack
+#define oc_clc_mv_comp_unpack vtk_oggtheora_oc_clc_mv_comp_unpack
+#define oc_dct_token_skip vtk_oggtheora_oc_dct_token_skip
+#define oc_dec_dering_frag_rows vtk_oggtheora_oc_dec_dering_frag_rows
+#define oc_dequant_tables_init vtk_oggtheora_oc_dequant_tables_init
+#define oc_dering_block vtk_oggtheora_oc_dering_block
+#define oc_filter_hedge vtk_oggtheora_oc_filter_hedge
+#define oc_filter_vedge vtk_oggtheora_oc_filter_vedge
+#define oc_frag_pred_dc vtk_oggtheora_oc_frag_pred_dc
+#define oc_frag_recon_inter vtk_oggtheora_oc_frag_recon_inter
+#define oc_frag_recon_inter2 vtk_oggtheora_oc_frag_recon_inter2
+#define oc_frag_recon_inter2_c vtk_oggtheora_oc_frag_recon_inter2_c
+#define oc_frag_recon_inter2_mmx vtk_oggtheora_oc_frag_recon_inter2_mmx
+#define oc_frag_recon_inter_c vtk_oggtheora_oc_frag_recon_inter_c
+#define oc_frag_recon_inter_mmx vtk_oggtheora_oc_frag_recon_inter_mmx
+#define oc_frag_recon_intra vtk_oggtheora_oc_frag_recon_intra
+#define oc_frag_recon_intra_c vtk_oggtheora_oc_frag_recon_intra_c
+#define oc_frag_recon_intra_mmx vtk_oggtheora_oc_frag_recon_intra_mmx
+#define oc_free_2d vtk_oggtheora_oc_free_2d
+#define oc_huff_node_fill vtk_oggtheora_oc_huff_node_fill
+#define oc_huff_token_decode vtk_oggtheora_oc_huff_token_decode
+#define oc_huff_tree_collapse vtk_oggtheora_oc_huff_tree_collapse
+#define oc_huff_tree_copy vtk_oggtheora_oc_huff_tree_copy
+#define oc_huff_tree_free vtk_oggtheora_oc_huff_tree_free
+#define oc_huff_tree_mindepth vtk_oggtheora_oc_huff_tree_mindepth
+#define oc_huff_tree_occupancy vtk_oggtheora_oc_huff_tree_occupancy
+#define oc_huff_tree_unpack vtk_oggtheora_oc_huff_tree_unpack
+#define oc_huff_trees_clear vtk_oggtheora_oc_huff_trees_clear
+#define oc_huff_trees_copy vtk_oggtheora_oc_huff_trees_copy
+#define oc_huff_trees_unpack vtk_oggtheora_oc_huff_trees_unpack
+#define oc_idct8x8_10_c vtk_oggtheora_oc_idct8x8_10_c
+#define oc_idct8x8_10_mmx vtk_oggtheora_oc_idct8x8_10_mmx
+#define oc_idct8x8_c vtk_oggtheora_oc_idct8x8_c
+#define oc_idct8x8_mmx vtk_oggtheora_oc_idct8x8_mmx
+#define oc_ilog vtk_oggtheora_oc_ilog
+#define oc_malloc_2d vtk_oggtheora_oc_malloc_2d
+#define oc_mb_fill_cmapping00 vtk_oggtheora_oc_mb_fill_cmapping00
+#define oc_mb_fill_cmapping01 vtk_oggtheora_oc_mb_fill_cmapping01
+#define oc_mb_fill_cmapping10 vtk_oggtheora_oc_mb_fill_cmapping10
+#define oc_mb_fill_cmapping11 vtk_oggtheora_oc_mb_fill_cmapping11
+#define oc_quant_params_clear vtk_oggtheora_oc_quant_params_clear
+#define oc_quant_params_unpack vtk_oggtheora_oc_quant_params_unpack
+#define oc_restore_fpu vtk_oggtheora_oc_restore_fpu
+#define oc_restore_fpu_c vtk_oggtheora_oc_restore_fpu_c
+#define oc_restore_fpu_mmx vtk_oggtheora_oc_restore_fpu_mmx
+#define oc_sb_run_unpack vtk_oggtheora_oc_sb_run_unpack
+#define oc_set_chroma_mvs00 vtk_oggtheora_oc_set_chroma_mvs00
+#define oc_set_chroma_mvs01 vtk_oggtheora_oc_set_chroma_mvs01
+#define oc_set_chroma_mvs10 vtk_oggtheora_oc_set_chroma_mvs10
+#define oc_set_chroma_mvs11 vtk_oggtheora_oc_set_chroma_mvs11
+#define oc_state_borders_fill vtk_oggtheora_oc_state_borders_fill
+#define oc_state_borders_fill_caps vtk_oggtheora_oc_state_borders_fill_caps
+#define oc_state_borders_fill_rows vtk_oggtheora_oc_state_borders_fill_rows
+#define oc_state_clear vtk_oggtheora_oc_state_clear
+#define oc_state_fill_buffer_ptrs vtk_oggtheora_oc_state_fill_buffer_ptrs
+#define oc_state_frag_copy vtk_oggtheora_oc_state_frag_copy
+#define oc_state_frag_copy_c vtk_oggtheora_oc_state_frag_copy_c
+#define oc_state_frag_copy_mmx vtk_oggtheora_oc_state_frag_copy_mmx
+#define oc_state_frag_recon vtk_oggtheora_oc_state_frag_recon
+#define oc_state_frag_recon_c vtk_oggtheora_oc_state_frag_recon_c
+#define oc_state_frag_recon_mmx vtk_oggtheora_oc_state_frag_recon_mmx
+#define oc_state_get_mv_offsets vtk_oggtheora_oc_state_get_mv_offsets
+#define oc_state_init vtk_oggtheora_oc_state_init
+#define oc_state_loop_filter_frag_rows vtk_oggtheora_oc_state_loop_filter_frag_rows
+#define oc_state_loop_filter_frag_rows_c vtk_oggtheora_oc_state_loop_filter_frag_rows_c
+#define oc_state_loop_filter_frag_rows_mmx vtk_oggtheora_oc_state_loop_filter_frag_rows_mmx
+#define oc_state_loop_filter_init vtk_oggtheora_oc_state_loop_filter_init
+#define oc_state_mbi_for_pos vtk_oggtheora_oc_state_mbi_for_pos
+#define oc_state_vtable_init vtk_oggtheora_oc_state_vtable_init
+#define oc_state_vtable_init_c vtk_oggtheora_oc_state_vtable_init_c
+#define oc_state_vtable_init_x86 vtk_oggtheora_oc_state_vtable_init_x86
+#define oc_theora_info2th_info vtk_oggtheora_oc_theora_info2th_info
+#define oc_token_dec1val_cat2 vtk_oggtheora_oc_token_dec1val_cat2
+#define oc_token_dec1val_cati vtk_oggtheora_oc_token_dec1val_cati
+#define oc_token_dec1val_const vtk_oggtheora_oc_token_dec1val_const
+#define oc_token_dec1val_zrl vtk_oggtheora_oc_token_dec1val_zrl
+#define oc_token_expand_cat2 vtk_oggtheora_oc_token_expand_cat2
+#define oc_token_expand_cati vtk_oggtheora_oc_token_expand_cati
+#define oc_token_expand_const vtk_oggtheora_oc_token_expand_const
+#define oc_token_expand_run vtk_oggtheora_oc_token_expand_run
+#define oc_token_expand_run_cat1a vtk_oggtheora_oc_token_expand_run_cat1a
+#define oc_token_expand_zrl vtk_oggtheora_oc_token_expand_zrl
+#define oc_token_skip_eob vtk_oggtheora_oc_token_skip_eob
+#define oc_token_skip_eob6 vtk_oggtheora_oc_token_skip_eob6
+#define oc_token_skip_run vtk_oggtheora_oc_token_skip_run
+#define oc_token_skip_run_cat1a vtk_oggtheora_oc_token_skip_run_cat1a
+#define oc_token_skip_val vtk_oggtheora_oc_token_skip_val
+#define oc_token_skip_zrl vtk_oggtheora_oc_token_skip_zrl
+#define oc_vlc_mode_unpack vtk_oggtheora_oc_vlc_mode_unpack
+#define oc_vlc_mv_comp_unpack vtk_oggtheora_oc_vlc_mv_comp_unpack
+#define oc_ycbcr_buffer_flip vtk_oggtheora_oc_ycbcr_buffer_flip
+#define ogg_packet_clear vtk_oggtheora_ogg_packet_clear
+#define ogg_page_bos vtk_oggtheora_ogg_page_bos
+#define ogg_page_checksum_set vtk_oggtheora_ogg_page_checksum_set
+#define ogg_page_continued vtk_oggtheora_ogg_page_continued
+#define ogg_page_eos vtk_oggtheora_ogg_page_eos
+#define ogg_page_granulepos vtk_oggtheora_ogg_page_granulepos
+#define ogg_page_packets vtk_oggtheora_ogg_page_packets
+#define ogg_page_pageno vtk_oggtheora_ogg_page_pageno
+#define ogg_page_serialno vtk_oggtheora_ogg_page_serialno
+#define ogg_page_version vtk_oggtheora_ogg_page_version
+#define ogg_stream_check vtk_oggtheora_ogg_stream_check
+#define ogg_stream_clear vtk_oggtheora_ogg_stream_clear
+#define ogg_stream_destroy vtk_oggtheora_ogg_stream_destroy
+#define ogg_stream_eos vtk_oggtheora_ogg_stream_eos
+#define ogg_stream_flush vtk_oggtheora_ogg_stream_flush
+#define ogg_stream_init vtk_oggtheora_ogg_stream_init
+#define ogg_stream_iovecin vtk_oggtheora_ogg_stream_iovecin
+#define ogg_stream_packetin vtk_oggtheora_ogg_stream_packetin
+#define ogg_stream_packetout vtk_oggtheora_ogg_stream_packetout
+#define ogg_stream_packetpeek vtk_oggtheora_ogg_stream_packetpeek
+#define ogg_stream_pagein vtk_oggtheora_ogg_stream_pagein
+#define ogg_stream_pageout vtk_oggtheora_ogg_stream_pageout
+#define ogg_stream_reset vtk_oggtheora_ogg_stream_reset
+#define ogg_stream_reset_serialno vtk_oggtheora_ogg_stream_reset_serialno
+#define ogg_sync_buffer vtk_oggtheora_ogg_sync_buffer
+#define ogg_sync_check vtk_oggtheora_ogg_sync_check
+#define ogg_sync_clear vtk_oggtheora_ogg_sync_clear
+#define ogg_sync_destroy vtk_oggtheora_ogg_sync_destroy
+#define ogg_sync_init vtk_oggtheora_ogg_sync_init
+#define ogg_sync_pageout vtk_oggtheora_ogg_sync_pageout
+#define ogg_sync_pageseek vtk_oggtheora_ogg_sync_pageseek
+#define ogg_sync_reset vtk_oggtheora_ogg_sync_reset
+#define ogg_sync_wrote vtk_oggtheora_ogg_sync_wrote
+#define oggpackB_adv vtk_oggtheora_oggpackB_adv
+#define oggpackB_adv1 vtk_oggtheora_oggpackB_adv1
+#define oggpackB_bits vtk_oggtheora_oggpackB_bits
+#define oggpackB_bytes vtk_oggtheora_oggpackB_bytes
+#define oggpackB_get_buffer vtk_oggtheora_oggpackB_get_buffer
+#define oggpackB_look vtk_oggtheora_oggpackB_look
+#define oggpackB_look1 vtk_oggtheora_oggpackB_look1
+#define oggpackB_read vtk_oggtheora_oggpackB_read
+#define oggpackB_read1 vtk_oggtheora_oggpackB_read1
+#define oggpackB_readinit vtk_oggtheora_oggpackB_readinit
+#define oggpackB_reset vtk_oggtheora_oggpackB_reset
+#define oggpackB_write vtk_oggtheora_oggpackB_write
+#define oggpackB_writealign vtk_oggtheora_oggpackB_writealign
+#define oggpackB_writecheck vtk_oggtheora_oggpackB_writecheck
+#define oggpackB_writeclear vtk_oggtheora_oggpackB_writeclear
+#define oggpackB_writecopy vtk_oggtheora_oggpackB_writecopy
+#define oggpackB_writeinit vtk_oggtheora_oggpackB_writeinit
+#define oggpackB_writetrunc vtk_oggtheora_oggpackB_writetrunc
+#define oggpack_adv vtk_oggtheora_oggpack_adv
+#define oggpack_adv1 vtk_oggtheora_oggpack_adv1
+#define oggpack_bits vtk_oggtheora_oggpack_bits
+#define oggpack_bytes vtk_oggtheora_oggpack_bytes
+#define oggpack_get_buffer vtk_oggtheora_oggpack_get_buffer
+#define oggpack_look vtk_oggtheora_oggpack_look
+#define oggpack_look1 vtk_oggtheora_oggpack_look1
+#define oggpack_read vtk_oggtheora_oggpack_read
+#define oggpack_read1 vtk_oggtheora_oggpack_read1
+#define oggpack_readinit vtk_oggtheora_oggpack_readinit
+#define oggpack_reset vtk_oggtheora_oggpack_reset
+#define oggpack_write vtk_oggtheora_oggpack_write
+#define oggpack_writealign vtk_oggtheora_oggpack_writealign
+#define oggpack_writecheck vtk_oggtheora_oggpack_writecheck
+#define oggpack_writeclear vtk_oggtheora_oggpack_writeclear
+#define oggpack_writecopy vtk_oggtheora_oggpack_writecopy
+#define oggpack_writecopy_helper vtk_oggtheora_oggpack_writecopy_helper
+#define oggpack_writeinit vtk_oggtheora_oggpack_writeinit
+#define oggpack_writetrunc vtk_oggtheora_oggpack_writetrunc
+#define quantize vtk_oggtheora_quantize
+#define recon_inter8x8__c vtk_oggtheora_recon_inter8x8__c
+#define recon_inter8x8__mmx vtk_oggtheora_recon_inter8x8__mmx
+#define recon_inter8x8_half__c vtk_oggtheora_recon_inter8x8_half__c
+#define recon_inter8x8_half__mmx vtk_oggtheora_recon_inter8x8_half__mmx
+#define recon_intra8x8__c vtk_oggtheora_recon_intra8x8__c
+#define recon_intra8x8__mmx vtk_oggtheora_recon_intra8x8__mmx
+#define restore_fpu vtk_oggtheora_restore_fpu
+#define row_sad8__c vtk_oggtheora_row_sad8__c
+#define row_sad8__mmx vtk_oggtheora_row_sad8__mmx
+#define row_sad8__mmxext vtk_oggtheora_row_sad8__mmxext
+#define sad8x8__c vtk_oggtheora_sad8x8__c
+#define sad8x8__mmx vtk_oggtheora_sad8x8__mmx
+#define sad8x8__mmxext vtk_oggtheora_sad8x8__mmxext
+#define sad8x8_thres__c vtk_oggtheora_sad8x8_thres__c
+#define sad8x8_thres__mmx vtk_oggtheora_sad8x8_thres__mmx
+#define sad8x8_thres__mmxext vtk_oggtheora_sad8x8_thres__mmxext
+#define sad8x8_xy2_thres__c vtk_oggtheora_sad8x8_xy2_thres__c
+#define sad8x8_xy2_thres__mmx vtk_oggtheora_sad8x8_xy2_thres__mmx
+#define sad8x8_xy2_thres__mmxext vtk_oggtheora_sad8x8_xy2_thres__mmxext
+#define select_quantiser vtk_oggtheora_select_quantiser
+#define sub8x8_128__c vtk_oggtheora_sub8x8_128__c
+#define sub8x8_128__mmx vtk_oggtheora_sub8x8_128__mmx
+#define sub8x8__c vtk_oggtheora_sub8x8__c
+#define sub8x8__mmx vtk_oggtheora_sub8x8__mmx
+#define sub8x8avg2__c vtk_oggtheora_sub8x8avg2__c
+#define sub8x8avg2__mmx vtk_oggtheora_sub8x8avg2__mmx
+#define th_comment_add vtk_oggtheora_th_comment_add
+#define th_comment_add_tag vtk_oggtheora_th_comment_add_tag
+#define th_comment_clear vtk_oggtheora_th_comment_clear
+#define th_comment_init vtk_oggtheora_th_comment_init
+#define th_comment_query vtk_oggtheora_th_comment_query
+#define th_comment_query_count vtk_oggtheora_th_comment_query_count
+#define th_dec_api_clear vtk_oggtheora_th_dec_api_clear
+#define th_decode_alloc vtk_oggtheora_th_decode_alloc
+#define th_decode_ctl vtk_oggtheora_th_decode_ctl
+#define th_decode_free vtk_oggtheora_th_decode_free
+#define th_decode_headerin vtk_oggtheora_th_decode_headerin
+#define th_decode_packetin vtk_oggtheora_th_decode_packetin
+#define th_decode_ycbcr_out vtk_oggtheora_th_decode_ycbcr_out
+#define th_encode_alloc vtk_oggtheora_th_encode_alloc
+#define th_encode_copy_pad_plane vtk_oggtheora_th_encode_copy_pad_plane
+#define th_encode_ctl vtk_oggtheora_th_encode_ctl
+#define th_encode_flushheader vtk_oggtheora_th_encode_flushheader
+#define th_encode_free vtk_oggtheora_th_encode_free
+#define th_encode_packetout vtk_oggtheora_th_encode_packetout
+#define th_encode_ycbcr_in vtk_oggtheora_th_encode_ycbcr_in
+#define th_granule_frame vtk_oggtheora_th_granule_frame
+#define th_granule_time vtk_oggtheora_th_granule_time
+#define th_info_clear vtk_oggtheora_th_info_clear
+#define th_info_init vtk_oggtheora_th_info_init
+#define th_packet_isheader vtk_oggtheora_th_packet_isheader
+#define th_packet_iskeyframe vtk_oggtheora_th_packet_iskeyframe
+#define th_setup_free vtk_oggtheora_th_setup_free
+#define th_version_number vtk_oggtheora_th_version_number
+#define th_version_string vtk_oggtheora_th_version_string
+#define theora_clear vtk_oggtheora_theora_clear
+#define theora_comment_add vtk_oggtheora_theora_comment_add
+#define theora_comment_add_tag vtk_oggtheora_theora_comment_add_tag
+#define theora_comment_clear vtk_oggtheora_theora_comment_clear
+#define theora_comment_init vtk_oggtheora_theora_comment_init
+#define theora_comment_query vtk_oggtheora_theora_comment_query
+#define theora_comment_query_count vtk_oggtheora_theora_comment_query_count
+#define theora_control vtk_oggtheora_theora_control
+#define theora_decode_YUVout vtk_oggtheora_theora_decode_YUVout
+#define theora_decode_clear vtk_oggtheora_theora_decode_clear
+#define theora_decode_control vtk_oggtheora_theora_decode_control
+#define theora_decode_granule_frame vtk_oggtheora_theora_decode_granule_frame
+#define theora_decode_granule_time vtk_oggtheora_theora_decode_granule_time
+#define theora_decode_header vtk_oggtheora_theora_decode_header
+#define theora_decode_init vtk_oggtheora_theora_decode_init
+#define theora_decode_packetin vtk_oggtheora_theora_decode_packetin
+#define theora_encode_YUVin vtk_oggtheora_theora_encode_YUVin
+#define theora_encode_clear vtk_oggtheora_theora_encode_clear
+#define theora_encode_comment vtk_oggtheora_theora_encode_comment
+#define theora_encode_control vtk_oggtheora_theora_encode_control
+#define theora_encode_granule_frame vtk_oggtheora_theora_encode_granule_frame
+#define theora_encode_granule_time vtk_oggtheora_theora_encode_granule_time
+#define theora_encode_header vtk_oggtheora_theora_encode_header
+#define theora_encode_init vtk_oggtheora_theora_encode_init
+#define theora_encode_packetout vtk_oggtheora_theora_encode_packetout
+#define theora_encode_tables vtk_oggtheora_theora_encode_tables
+#define theora_granule_frame vtk_oggtheora_theora_granule_frame
+#define theora_granule_shift vtk_oggtheora_theora_granule_shift
+#define theora_granule_time vtk_oggtheora_theora_granule_time
+#define theora_info_clear vtk_oggtheora_theora_info_clear
+#define theora_info_init vtk_oggtheora_theora_info_init
+#define theora_packet_isheader vtk_oggtheora_theora_packet_isheader
+#define theora_packet_iskeyframe vtk_oggtheora_theora_packet_iskeyframe
+#define theora_version_number vtk_oggtheora_theora_version_number
+#define theora_version_string vtk_oggtheora_theora_version_string
+#define theorapackB_adv1 vtk_oggtheora_theorapackB_adv1
+#define theorapackB_bits vtk_oggtheora_theorapackB_bits
+#define theorapackB_bytes vtk_oggtheora_theorapackB_bytes
+#define theorapackB_get_buffer vtk_oggtheora_theorapackB_get_buffer
+#define theorapackB_look1 vtk_oggtheora_theorapackB_look1
+#define theorapackB_read vtk_oggtheora_theorapackB_read
+#define theorapackB_read1 vtk_oggtheora_theorapackB_read1
+#define theorapackB_readinit vtk_oggtheora_theorapackB_readinit
+
+#endif
diff --git a/VTK/Utilities/vtkoggtheora/vtkoggtheora.def b/VTK/Utilities/vtkoggtheora/vtkoggtheora.def
new file mode 100644
index 0000000..b8b831f
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/vtkoggtheora.def
@@ -0,0 +1,16 @@
+LIBRARY vtkoggtheora
+EXPORTS
+  vtk_oggtheora_ogg_stream_clear
+  vtk_oggtheora_ogg_stream_flush
+  vtk_oggtheora_ogg_stream_packetin
+  vtk_oggtheora_ogg_stream_pageout
+  vtk_oggtheora_ogg_stream_init
+  vtk_oggtheora_th_encode_free
+  vtk_oggtheora_th_info_clear
+  vtk_oggtheora_th_info_init
+  vtk_oggtheora_th_encode_alloc
+  vtk_oggtheora_th_comment_init
+  vtk_oggtheora_th_encode_flushheader
+  vtk_oggtheora_th_comment_clear
+  vtk_oggtheora_th_encode_ycbcr_in
+  vtk_oggtheora_th_encode_packetout
diff --git a/VTK/Utilities/vtkoggtheora/vtkoggtheora.exp b/VTK/Utilities/vtkoggtheora/vtkoggtheora.exp
new file mode 100644
index 0000000..ee954f7
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/vtkoggtheora.exp
@@ -0,0 +1,14 @@
+_vtk_oggtheora_ogg_stream_clear
+_vtk_oggtheora_ogg_stream_flush
+_vtk_oggtheora_ogg_stream_packetin
+_vtk_oggtheora_ogg_stream_pageout
+_vtk_oggtheora_ogg_stream_init
+_vtk_oggtheora_th_encode_free
+_vtk_oggtheora_th_info_clear
+_vtk_oggtheora_th_info_init
+_vtk_oggtheora_th_encode_alloc
+_vtk_oggtheora_th_comment_init
+_vtk_oggtheora_th_encode_flushheader
+_vtk_oggtheora_th_comment_clear
+_vtk_oggtheora_th_encode_ycbcr_in
+_vtk_oggtheora_th_encode_packetout
diff --git a/VTK/Utilities/vtkoggtheora/vtkoggtheora.rc b/VTK/Utilities/vtkoggtheora/vtkoggtheora.rc
new file mode 100644
index 0000000..1c002ac
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/vtkoggtheora.rc
@@ -0,0 +1,32 @@
+#include <windows.h>
+
+#define IDR_VERSION1  1
+IDR_VERSION1	VERSIONINFO	MOVEABLE IMPURE LOADONCALL DISCARDABLE
+  FILEVERSION	 1,0,0,0
+  PRODUCTVERSION 1,0,0,0
+  FILEFLAGSMASK	VS_FFI_FILEFLAGSMASK
+  FILEFLAGS	0
+  FILEOS	VOS_DOS_WINDOWS32
+  FILETYPE	VFT_DLL
+  FILESUBTYPE	0	// not used
+BEGIN
+  BLOCK "StringFileInfo"
+  BEGIN
+    BLOCK "040904E4"
+    //language ID = U.S. English, char set = Windows, Multilingual
+
+    BEGIN
+      VALUE "FileDescription", "Ogg/Theora video container/codec library\0"
+      VALUE "FileVersion",	"1.0.0\0"
+      VALUE "InternalName",	"oggtheora\0"
+      VALUE "OriginalFilename",	"oggtheora.dll\0"
+      VALUE "ProductName",	"OggTheora.DLL\0"
+      VALUE "Comments","Custom build for VTK/ParaView\0"
+      VALUE "LegalCopyright", "(C) 2002-2008 Xiph.Org Foundation and contributors.\0"
+    END
+  END
+  BLOCK "VarFileInfo"
+  BEGIN
+    VALUE "Translation", 0x0409, 1252
+  END
+END
diff --git a/VTK/Utilities/vtkoggtheora/vtkoggtheora.vscript b/VTK/Utilities/vtkoggtheora/vtkoggtheora.vscript
new file mode 100644
index 0000000..286ea07
--- /dev/null
+++ b/VTK/Utilities/vtkoggtheora/vtkoggtheora.vscript
@@ -0,0 +1,19 @@
+VER_1.0alpha2 {
+  global:
+    vtk_oggtheora_ogg_stream_clear;
+    vtk_oggtheora_ogg_stream_flush;
+    vtk_oggtheora_ogg_stream_packetin;
+    vtk_oggtheora_ogg_stream_pageout;
+    vtk_oggtheora_ogg_stream_init;
+    vtk_oggtheora_th_encode_free;
+    vtk_oggtheora_th_info_clear;
+    vtk_oggtheora_th_info_init;
+    vtk_oggtheora_th_encode_alloc;
+    vtk_oggtheora_th_comment_init;
+    vtk_oggtheora_th_encode_flushheader;
+    vtk_oggtheora_th_comment_clear;
+    vtk_oggtheora_th_encode_ycbcr_in;
+    vtk_oggtheora_th_encode_packetout;
+  local:
+    *;
+};
diff --git a/VTK/vtkIncludeDirectories.cmake b/VTK/vtkIncludeDirectories.cmake
index 3318f9e..c9f63a1 100644
--- a/VTK/vtkIncludeDirectories.cmake
+++ b/VTK/vtkIncludeDirectories.cmake
@@ -190,6 +190,7 @@ VTK_THIRD_PARTY_INCLUDE(NetCDF vtknetcdf)
 VTK_THIRD_PARTY_INCLUDE(Exodus2 vtkexodus2/include)
 VTK_THIRD_PARTY_INCLUDE(MATERIALLIBRARY MaterialLibrary)
 VTK_THIRD_PARTY_INCLUDE(VERDICT verdict)
+VTK_THIRD_PARTY_INCLUDE(OGGTHEORA vtkoggtheora/include)
 
 # Include UTF-8 support
 SET(VTK_INCLUDE_DIRS_SOURCE_TREE ${VTK_INCLUDE_DIRS_SOURCE_TREE}
diff --git a/VTK/vtkToolkits.h.in b/VTK/vtkToolkits.h.in
index 06b910d..d3d00d9 100644
--- a/VTK/vtkToolkits.h.in
+++ b/VTK/vtkToolkits.h.in
@@ -120,6 +120,7 @@
 #cmakedefine VTK_USE_SYSTEM_FREETYPE
 #cmakedefine VTK_USE_SYSTEM_LIBXML2
 #cmakedefine VTK_USE_SYSTEM_LIBPROJ4
+#cmakedefine VTK_USE_SYSTEM_OGGTHEORA
 
 /* Whether VTK is using vfw32 and if it supports video capture */
 #cmakedefine VTK_USE_VIDEO_FOR_WINDOWS
-- 
1.6.3.3

