changeset 571:4c19cddce21b

Merged multicoreware/xhevc into default
author Deepthi Devaki Akkoorath <deepthidevaki@multicorewareinc.com>
date Wed, 17 Apr 2013 14:11:17 +0530
parents e93b9f1e9f10 (current diff) 7c3b537734e1 (diff)
children 1fe37c453312
files build/RegressionTester.bat source/Lib/config.cpp source/Lib/config.h source/encoder/macroblock.cpp
diffstat 38 files changed, 4142 insertions(+-), 3226 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/BuildEncoderApplications.bat	Wed Apr 17 14:11:17 2013 +0530
@@ -0,0 +1,60 @@
+@echo off
+
+cd "%builddir%"
+mkdir enabled
+cd enabled
+set solution="x265.sln"
+
+echo SET(ENABLE_TESTS ON CACHE BOOL "Enable Unit Tests" FORCE ^) >> enablecache.txt
+echo SET(HIGH_BIT_DEPTH ON CACHE BOOL "Use 16bit pixels internally" FORCE ^) >> enablecache.txt
+echo SET(ENABLE_PRIMITIVES ON CACHE BOOL "Enable use of optimized encoder primitives" FORCE ^) >> enablecache.txt
+
+cmake -G %makefile%  -C enablecache.txt ..\..\..\source 
+
+if exist %solution% (
+    call %vcvars%
+    MSBuild /property:Configuration="Release" x265.sln >> BuildLog.txt
+
+    if %errorlevel% equ 1 (
+        echo Build with primitive enabled unsuccessfull for %makefile% refer the build log  >> "%LOG%"
+        exit 1
+    )
+    echo Build with primitives enabled successfull for %makefile% >> "%LOG%"
+
+    if exist Release\x265-cli.exe (
+        echo build Application with primitive enable successfull for %makefile% >> "%LOG%"			
+    ) else (
+       echo build Application with primitive enable unsuccessfull for %makefile%  refer the Build log >> "%LOG%"
+    )     
+) else (
+    echo Primitive Enable solution is not created for %makefile% >> "%LOG%"
+)
+
+cd "%builddir%"
+mkdir disable
+cd disable
+
+echo SET(ENABLE_TESTS ON CACHE BOOL "Enable Unit Tests" FORCE^) >> disablecache.txt
+echo SET(ENABLE_PRIMITIVES OFF CACHE BOOL "Enable use of optimized encoder primitives" FORCE^) >> disablecache.txt
+echo SET(ENABLE_PRIMITIVES_VEC OFF CACHE BOOL "Enable use of optimized encoder primitives" FORCE^) >> disablecache.txt
+
+cmake -G %makefile% -C disablecache.txt ..\..\..\source 
+
+if exist %solution% (
+    call %vcvars%
+    MSBuild /property:Configuration="Release" x265.sln >> BuildLog.txt
+
+    if %errorlevel% equ 1 (
+        echo Build with primitive disable unsuccessfull for %makefile% refer the build log  >> "%LOG%"
+        exit 1
+    )
+    echo Build with primitives disable successfull for %makefile% >> "%LOG%"
+
+    if exist Release\x265-cli.exe (
+        echo build Application with primitive disable successfull for %makefile% >> "%LOG%"			
+    ) else (
+        echo build Application with primitive disable unsuccessfull for %makefile%  refer the Build log >> "%LOG%"
+    )     
+) else (
+    echo Primitive Disable solution is not created for %makefile% >> "%LOG%"
+)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/build/CreateRegressionPackage.bat	Wed Apr 17 14:11:17 2013 +0530
@@ -0,0 +1,83 @@
+@echo off
+
+for /f "tokens=1,2,3 delims==" %%a in (config.txt) do (
+if %%a==workingdir set workingdir=%%b
+if %%a==testdir set testdir=%%b
+if %%a==repository set repository=%%b
+)
+
+set HG=hg
+set currentworkingdir="%workingdir%"RegressionTest
+set Buildbat="BuildEncoderApplications.bat"
+
+if exist "%currentworkingdir%" rd /s /q %currentworkingdir%
+
+mkdir "%currentworkingdir%"
+cd "%currentworkingdir%"
+
+set LOG="%currentworkingdir%"\RegressionTester.log
+
+if %errorlevel% equ 1 (echo Working directory not created >> "%LOG%"
+	exit 1
+)
+echo Working directory created >> "%LOG%"
+
+"%HG%" init
+"%HG%" pull "%repository%"
+"%HG%" update
+
+if %errorlevel% equ 1 (echo Pull unsuccessfull >> "%LOG%"
+exit 1
+)
+echo Pull successfull >> "%LOG%"
+
+set builddir=""
+set makefile=""
+set vcvars=""
+
+::Build the solution and applications for VS 11
+
+if  not "%VS110COMNTOOLS%" == "" ( 
+	
+	echo Regression Test	-	VS 11 Compiler found >> "%LOG%"
+	set builddir="%currentworkingdir%"\build\vc11-x86_64
+	set makefile="Visual Studio 11 Win64"
+	set vcvars="%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat"
+	call "%workingdir%BuildEncoderApplications.bat"
+
+	set builddir="%currentworkingdir%"\build\vc11-x86   
+	set makefile="Visual Studio 11"
+	call "%workingdir%BuildEncoderApplications.bat"     
+)
+
+::Build the solution and applications for VS 10
+
+if  not "%VS100COMNTOOLS%" == "" ( 
+	echo Regression Test	-	VS 10 Compiler found >> "%LOG%"
+	set builddir="%currentworkingdir%"\build\vc10-x86_64
+	set makefile="Visual Studio 10 Win64"
+	set vcvars="%VS100COMNTOOLS%\..\..\VC\vcvarsall.bat"
+	call "%workingdir%BuildEncoderApplications.bat"
+
+	set builddir="%currentworkingdir%"\build\vc10-x86        
+	set makefile="Visual Studio 10"
+	call "%workingdir%BuildEncoderApplications.bat"
+)
+
+::Build the solution and applications foe VS 09
+
+if  not "%%VS90COMNTOOLS%" == "" ( 
+	echo Regression Test	-	VS 09 Compiler found >> "%LOG%"
+	set builddir="%currentworkingdir%"\build\vc9-x86_64
+	set makefile="Visual Studio 9 2008"
+	set vcvars="%%VS90COMNTOOLS%%\..\..\VC\vcvarsall.bat"
+	call "%workingdir%BuildEncoderApplications.bat"
+
+	set builddir="%currentworkingdir%"\build\vc9-x86        
+	set makefile="Visual Studio 10"
+	call "%workingdir%BuildEncoderApplications.bat"
+)
+
+
+:: To do list 
+:: Running the test bench and Encoder Application for all the build version
--- a/build/RegressionTester.bat	Wed Apr 17 14:09:10 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,99 +0,0 @@
-@echo off
-
-for /f "tokens=1,2,3,4,5 delims==" %%a in (config.txt) do (
-if %%a==workingdir set workingdir=%%b
-if %%a==testdir set testdir=%%b
-if %%a==repository set repository=%%b
-if %%a==password set password=%%b
-if %%a==logpath set logpath=%%b
-)
-
-set HG=hg
-set LOG="%logpath%"
-
-echo %workingdir%
-echo %testdir%
-echo %repository%
-echo %password%
-
-if exist "%workingdir%" rd /s /q %workingdir%
-
-mkdir "%workingdir%"
-cd "%workingdir%"
-
-if %errorlevel% equ 1 (echo Working directory not created >> "%LOG%"
-exit 1
-)
-echo Working directory created >> "%LOG%"
-
-"%HG%" init
-"%HG%" pull "%repository%"
-"%HG%" update
-
-if %errorlevel% equ 1 (echo Pull unsuccessfull >> "%LOG%"
-exit 1
-)
-echo Pull successfull >> "%LOG%"
-
-
-if  not "%VS110COMNTOOLS%" == "" ( 
-cd build\vc11-x86_64
-
-mkdir Enabled
-cd Enabled
-
-if not exist x265.sln (
-
-echo SET(ENABLE_TESTS ON CACHE BOOL "Enable Unit Tests" FORCE ^) >> enablecache.txt
-echo SET(HIGH_BIT_DEPTH ON CACHE BOOL "Use 16bit pixels internally" FORCE ^) >> enablecache.txt
-echo SET(ENABLE_PRIMITIVES_VEC ON CACHE BOOL "Enable use of optimized encoder primitives" FORCE ^) >> enablecache.txt
-
-cmake -G "Visual Studio 11 Win64" -C enablecache.txt ..\..\..\source
-
-if exist x265.sln (
-  call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat"
-  MSBuild /property:Configuration="Release" x265.sln >> BuildLog.txt
-
-
-if %errorlevel% equ 1 (echo Build for primitives enabled unsuccessfull >> "%LOG%"
-exit 1
-)
-echo Build for primitives enabled successfull >> "%LOG%"
-
-if exist Release\x265-cli.exe (
-  echo Encoder client build successfully >> "%LOG%"
-) else ( echo Encoder client not build successfully >> "%LOG%" )
-)
-)
-
-cd ../
-mkdir Disabled
-cd Disabled
-if not exist x265.sln (
-
-echo SET(ENABLE_TESTS ON CACHE BOOL "Enable Unit Tests" FORCE^) >> disablecache.txt
-echo SET(HIGH_BIT_DEPTH OFF CACHE BOOL "Use 16bit pixels internally" FORCE^) >> disablecache.txt
-echo SET(ENABLE_PRIMITIVES_VEC OFF CACHE BOOL "Enable use of optimized encoder primitives" FORCE^) >> disablecache.txt
-
-cmake -G "Visual Studio 11 Win64" -C disablecache.txt ..\..\..\source
-)
-
-if exist x265.sln (
-  call "%VS110COMNTOOLS%\..\..\VC\vcvarsall.bat"
-  MSBuild /property:Configuration="Release" x265.sln >> BuilLog.txt
-
-if %errorlevel% equ 1 (echo Build for primitives disabled unsuccessfull >> "%LOG%"
-exit 1
-)
-echo Build for primitives disabled successfull >> "%LOG%"
-
-if exist Release\x265-cli.exe (
-	echo Encoder client build successfully >> "%LOG%"
-	del \q BuildLog.txt
- ) else (
-           echo Encoder client not build successfully >> "%LOG%" )
-)
-)
-cd
-pause
-
--- a/build/config.txt	Wed Apr 17 14:09:10 2013 +0530
+++ b/build/config.txt	Wed Apr 17 14:11:17 2013 +0530
@@ -1,6 +1,4 @@
-workingdir=RegressionTesting
+workingdir=E:\\
 testdir=TestEncoder
 repository=https://ggopu@bitbucket.org/multicoreware/xhevc
-password=
-configfile=initialcache.txt
-logpath=E:\\hevc_log.txt
\ No newline at end of file
+
--- a/source/CMakeLists.txt	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/CMakeLists.txt	Wed Apr 17 14:11:17 2013 +0530
@@ -51,13 +51,12 @@ if(ENABLE_PRIMITIVES)
     endif(ENABLE_PRIMITIVES_VEC)
 
     find_package(Yasm)
-    # http://www.cmake.org/Bug/print_bug_page.php?bug_id=8170
-    if(YASM_FOUND AND GCC)
+    if(YASM_FOUND)
         option(ENABLE_PRIMITIVES_ASM "Enable use of assembly coded primitives" ON)
         if(ENABLE_PRIMITIVES_ASM)
             add_definitions(-DENABLE_ASM_PRIMITIVES=1)
         endif(ENABLE_PRIMITIVES_ASM)
-    endif(YASM_FOUND AND GCC)
+    endif(YASM_FOUND)
 endif(ENABLE_PRIMITIVES)
 
 option(ENABLE_PPA "Enable PPA profiling instrumentation" OFF)
@@ -85,9 +84,10 @@ if(ENABLE_CLI)
     endif(GCC)
     set_source_files_properties(x265main.cpp PROPERTIES COMPILE_FLAGS -DX265_VERSION=${X265_VERSION})
 
-    add_executable(x265-cli x265main.cpp ${EXTRAS})
+    add_subdirectory(input)
+    add_executable(x265-cli x265main.cpp x265cfg.cpp x265cfg.h ${EXTRAS})
 
-    target_link_libraries(x265-cli HM x265)
+    target_link_libraries(x265-cli HM x265 InputFiles)
     if(ENABLE_PPA)
         target_link_libraries(x265-cli PPA)
         if(UNIX)
--- a/source/Lib/CMakeLists.txt	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/Lib/CMakeLists.txt	Wed Apr 17 14:11:17 2013 +0530
@@ -26,5 +26,4 @@ source_group(TLibCommon  FILES ${LIBCOMM
 source_group(TLibEncoder FILES ${LIBENCODER})
 
 add_library(HM ${LIBCOMMON} ${LIBENCODER} ${APPCOMMON} ${LIBVIDEOIO} ${MD5}
-            encoder.cpp encoder.h
-            config.cpp config.h)
+            encoder.cpp encoder.h)
--- a/source/Lib/TLibCommon/TComTrQuant.cpp	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/Lib/TLibCommon/TComTrQuant.cpp	Wed Apr 17 14:11:17 2013 +0530
@@ -863,8 +863,13 @@ void xTrMxN(Int bitDepth, Short *block, 
     }
     else if (iWidth == 16 && iHeight == 16)
     {
+#ifdef ENABLE_PRIMITIVES
+        x265::primitives.partial_butterfly[x265::BUTTERFLY_16](block, tmp, shift_1st, iHeight);
+        x265::primitives.partial_butterfly[x265::BUTTERFLY_16](tmp, coeff, shift_2nd, iWidth);
+#else
         partialButterfly16(block, tmp, shift_1st, iHeight);
         partialButterfly16(tmp, coeff, shift_2nd, iWidth);
+#endif
     }
     else if (iWidth == 32 && iHeight == 32)
     {
--- a/source/Lib/TLibVideoIO/TVideoIOY4m.cpp	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/Lib/TLibVideoIO/TVideoIOY4m.cpp	Wed Apr 17 14:11:17 2013 +0530
@@ -195,15 +195,15 @@ Void TVideoIOY4m::open(Char*        pchF
     else
     {
         y4m_handler = (y4m_hnd_t*)handler;
-        y4m_handler->bitDepthShiftY = internalBitDepthY - fileBitDepthY;
-        y4m_handler->bitDepthShiftC = internalBitDepthC - fileBitDepthC;
-        y4m_handler->fileBitDepthY = fileBitDepthY;
-        y4m_handler->fileBitDepthC = fileBitDepthC;
-        y4m_handler->aiPad[0] = aiPad[0];
-        y4m_handler->aiPad[1] = aiPad[1];
         y4m_handler->m_cHandle.seekg(y4m_handler->headerLength);
     }
 
+    y4m_handler->bitDepthShiftY = internalBitDepthY - fileBitDepthY;
+    y4m_handler->bitDepthShiftC = internalBitDepthC - fileBitDepthC;
+    y4m_handler->fileBitDepthY = fileBitDepthY;
+    y4m_handler->fileBitDepthC = fileBitDepthC;
+    y4m_handler->aiPad[0] = aiPad[0];
+    y4m_handler->aiPad[1] = aiPad[1];
     handler =  (hnd_t*)y4m_handler;
 }
 
--- a/source/Lib/config.cpp	Wed Apr 17 14:09:10 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1937 +0,0 @@
-/* The copyright in this software is being made available under the BSD
- * License, included below. This software may be subject to other third party
- * and contributor rights, including patent rights, and no such rights are
- * granted under this license.
- *
- * Copyright (c) 2010-2013, ITU/ISO/IEC
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
- *    be used to endorse or promote products derived from this software without
- *    specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** \file     TAppEncCfg.cpp
-    \brief    Handle encoder configuration parameters
-*/
-
-#include <stdlib.h>
-#include <cassert>
-#include <cstring>
-#include <string>
-#include <math.h>
-#include "TLibCommon/TComRom.h"
-#include "config.h"
-
-static istream &operator >>(istream &, Level::Name &);
-static istream &operator >>(istream &, Level::Tier &);
-static istream &operator >>(istream &, Profile::Name &);
-
-#include "TAppCommon/program_options_lite.h"
-#include "TLibEncoder/TEncRateCtrl.h"
-
-#ifdef WIN32
-#define strdup _strdup
-#endif
-
-using namespace std;
-namespace po = df::program_options_lite;
-
-//! \ingroup TAppEncoder
-//! \{
-
-// ====================================================================================================================
-// Constructor / destructor / initialization / destroy
-// ====================================================================================================================
-
-TAppEncCfg::TAppEncCfg()
-    : m_pchInputFile()
-    , m_pchBitstreamFile()
-    , m_pchReconFile()
-    , m_pchdQPFile()
-    , m_pColumnWidth()
-    , m_pRowHeight()
-    , m_scalingListFile()
-{
-    m_aidQP = NULL;
-#if J0149_TONE_MAPPING_SEI
-    m_startOfCodedInterval = NULL;
-    m_codedPivotValue = NULL;
-    m_targetPivotValue = NULL;
-#endif
-}
-
-TAppEncCfg::~TAppEncCfg()
-{
-    if (m_aidQP)
-    {
-        delete[] m_aidQP;
-    }
-
-#if J0149_TONE_MAPPING_SEI
-    if (m_startOfCodedInterval)
-    {
-        delete[] m_startOfCodedInterval;
-        m_startOfCodedInterval = NULL;
-    }
-
-    if (m_codedPivotValue)
-    {
-        delete[] m_codedPivotValue;
-        m_codedPivotValue = NULL;
-    }
-
-    if (m_targetPivotValue)
-    {
-        delete[] m_targetPivotValue;
-        m_targetPivotValue = NULL;
-    }
-
-#endif // if J0149_TONE_MAPPING_SEI
-    free(m_pchInputFile);
-    free(m_pchBitstreamFile);
-    free(m_pchReconFile);
-    free(m_pchdQPFile);
-    free(m_pColumnWidth);
-    free(m_pRowHeight);
-    free(m_scalingListFile);
-}
-
-Void TAppEncCfg::create()
-{}
-
-Void TAppEncCfg::destroy()
-{}
-
-std::istringstream &operator >>(std::istringstream &in, GOPEntry &entry)     //input
-{
-    in >> entry.m_sliceType;
-    in >> entry.m_POC;
-    in >> entry.m_QPOffset;
-    in >> entry.m_QPFactor;
-    in >> entry.m_tcOffsetDiv2;
-    in >> entry.m_betaOffsetDiv2;
-    in >> entry.m_temporalId;
-    in >> entry.m_numRefPicsActive;
-    in >> entry.m_numRefPics;
-    for (Int i = 0; i < entry.m_numRefPics; i++)
-    {
-        in >> entry.m_referencePics[i];
-    }
-
-    in >> entry.m_interRPSPrediction;
-#if AUTO_INTER_RPS
-    if (entry.m_interRPSPrediction == 1)
-    {
-        in >> entry.m_deltaRPS;
-        in >> entry.m_numRefIdc;
-        for (Int i = 0; i < entry.m_numRefIdc; i++)
-        {
-            in >> entry.m_refIdc[i];
-        }
-    }
-    else if (entry.m_interRPSPrediction == 2)
-    {
-        in >> entry.m_deltaRPS;
-    }
-
-#else // if AUTO_INTER_RPS
-    if (entry.m_interRPSPrediction)
-    {
-        in >> entry.m_deltaRPS;
-        in >> entry.m_numRefIdc;
-        for (Int i = 0; i < entry.m_numRefIdc; i++)
-        {
-            in >> entry.m_refIdc[i];
-        }
-    }
-
-#endif // if AUTO_INTER_RPS
-    return in;
-}
-
-static const struct MapStrToProfile
-{
-    const Char *str;
-    Profile::Name value;
-} strToProfile[] =
-{
-    { "none", Profile::NONE },
-    { "main", Profile::MAIN },
-    { "main10", Profile::MAIN10 },
-    { "main-still-picture", Profile::MAINSTILLPICTURE },
-};
-
-static const struct MapStrToTier
-{
-    const Char *str;
-    Level::Tier value;
-} strToTier[] =
-{
-    { "main", Level::MAIN },
-    { "high", Level::HIGH },
-};
-
-static const struct MapStrToLevel
-{
-    const Char *str;
-    Level::Name value;
-} strToLevel[] =
-{
-    { "none", Level::NONE },
-    { "1",   Level::LEVEL1 },
-    { "2",   Level::LEVEL2 },
-    { "2.1", Level::LEVEL2_1 },
-    { "3",   Level::LEVEL3 },
-    { "3.1", Level::LEVEL3_1 },
-    { "4",   Level::LEVEL4 },
-    { "4.1", Level::LEVEL4_1 },
-    { "5",   Level::LEVEL5 },
-    { "5.1", Level::LEVEL5_1 },
-    { "5.2", Level::LEVEL5_2 },
-    { "6",   Level::LEVEL6 },
-    { "6.1", Level::LEVEL6_1 },
-    { "6.2", Level::LEVEL6_2 },
-};
-
-template<typename T, typename P>
-static istream &readStrToEnum(P map[], unsigned long mapLen, istream &in, T &val)
-{
-    string str;
-
-    in >> str;
-
-    for (Int i = 0; i < mapLen; i++)
-    {
-        if (str == map[i].str)
-        {
-            val = map[i].value;
-            goto found;
-        }
-    }
-
-    /* not found */
-    in.setstate(ios::failbit);
-found:
-    return in;
-}
-
-static istream &operator >>(istream &in, Profile::Name &profile)
-{
-    return readStrToEnum(strToProfile, sizeof(strToProfile) / sizeof(*strToProfile), in, profile);
-}
-
-static istream &operator >>(istream &in, Level::Tier &tier)
-{
-    return readStrToEnum(strToTier, sizeof(strToTier) / sizeof(*strToTier), in, tier);
-}
-
-static istream &operator >>(istream &in, Level::Name &level)
-{
-    return readStrToEnum(strToLevel, sizeof(strToLevel) / sizeof(*strToLevel), in, level);
-}
-
-#if SIGNAL_BITRATE_PICRATE_IN_VPS
-Void readBoolString(const string inpString, const Int numEntries, Bool* &memberArray, const char *elementName);
-Void readIntString(const string inpString, const Int numEntries, Int* &memberArray, const char *elementName);
-#endif
-// ====================================================================================================================
-// Public member functions
-// ====================================================================================================================
-
-/** \param  argc        number of arguments
-    \param  argv        array of arguments
-    \retval             true when success
- */
-Bool TAppEncCfg::parseCfg(Int argc, Char *argv[])
-
-{
-    Bool do_help = false;
-
-    string cfg_InputFile;
-    string cfg_BitstreamFile;
-    string cfg_ReconFile;
-    string cfg_dQPFile;
-    string cfg_ColumnWidth;
-    string cfg_RowHeight;
-    string cfg_ScalingListFile;
-
-#if J0149_TONE_MAPPING_SEI
-    string cfg_startOfCodedInterval;
-    string cfg_codedPivotValue;
-    string cfg_targetPivotValue;
-#endif
-#if SIGNAL_BITRATE_PICRATE_IN_VPS
-    string cfg_bitRateInfoPresentFlag;
-    string cfg_picRateInfoPresentFlag;
-    string cfg_avgBitRate;
-    string cfg_maxBitRate;
-    string cfg_avgPicRate;
-    string cfg_constantPicRateIdc;
-#endif
-    po::Options opts;
-    opts.addOptions()
-        ("help", do_help, false, "this help text")
-        ("c", po::parseConfigFile, "configuration file name")
-
-    // File, I/O and source parameters
-        ("InputFile,i",           cfg_InputFile,     string(""), "Original YUV input file name")
-        ("BitstreamFile,b",       cfg_BitstreamFile, string(""), "Bitstream output file name")
-        ("ReconFile,o",           cfg_ReconFile,     string(""), "Reconstructed YUV output file name")
-        ("SourceWidth,-wdt",      m_iSourceWidth,        0, "Source picture width")
-        ("SourceHeight,-hgt",     m_iSourceHeight,       0, "Source picture height")
-        ("InputBitDepth",         m_inputBitDepthY,    8, "Bit-depth of input file")
-        ("OutputBitDepth",        m_outputBitDepthY,   0, "Bit-depth of output file (default:InternalBitDepth)")
-        ("InternalBitDepth",      m_internalBitDepthY, 0, "Bit-depth the codec operates at. (default:InputBitDepth)"
-        "If different to InputBitDepth, source data will be converted")
-        ("InputBitDepthC",        m_inputBitDepthC,    0,
-        "As per InputBitDepth but for chroma component. (default:InputBitDepth)")
-        ("OutputBitDepthC",       m_outputBitDepthC,   0,
-        "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
-        ("InternalBitDepthC",     m_internalBitDepthC, 0,
-        "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth)")
-        ("ConformanceMode",       m_conformanceMode,     0,
-        "Window conformance mode (0: no window, 1:automatic padding, 2:padding, 3:conformance")
-        ("HorizontalPadding,-pdx", m_aiPad[0],            0, "Horizontal source padding for conformance window mode 2")
-        ("VerticalPadding,-pdy",  m_aiPad[1],            0, "Vertical source padding for conformance window mode 2")
-        ("ConfLeft",              m_confLeft,            0, "Left offset for window conformance mode 3")
-        ("ConfRight",             m_confRight,           0, "Right offset for window conformance mode 3")
-        ("ConfTop",               m_confTop,             0, "Top offset for window conformance mode 3")
-        ("ConfBottom",            m_confBottom,          0, "Bottom offset for window conformance mode 3")
-        ("FrameRate,-fr",         m_iFrameRate,          0, "Frame rate")
-        ("FrameSkip,-fs",         m_FrameSkip,          0u, "Number of frames to skip at start of input YUV")
-        ("FramesToBeEncoded,f",   m_framesToBeEncoded,   0, "Number of frames to be encoded (default=all)")
-
-    // Profile and level
-        ("Profile", m_profile,   Profile::NONE, "Profile to be used when encoding (Incomplete)")
-        ("Level",   m_level,     Level::NONE,   "Level limit to be used, eg 5.1 (Incomplete)")
-        ("Tier",    m_levelTier, Level::MAIN,   "Tier to use for interpretation of --Level")
-
-#if L0046_CONSTRAINT_FLAGS
-    ("ProgressiveSource", m_progressiveSourceFlag, false, "Indicate that source is progressive")
-        ("InterlacedSource",  m_interlacedSourceFlag,  false, "Indicate that source is interlaced")
-        ("NonPackedSource",   m_nonPackedConstraintFlag, false, "Indicate that source does not contain frame packing")
-        ("FrameOnly",         m_frameOnlyConstraintFlag, false, "Indicate that the bitstream contains only frames")
-#endif
-
-    // Unit definition parameters
-    ("MaxCUWidth",              m_uiMaxCUWidth,             64u)
-        ("MaxCUHeight",             m_uiMaxCUHeight,            64u)
-    // todo: remove defaults from MaxCUSize
-        ("MaxCUSize,s",             m_uiMaxCUWidth,             64u, "Maximum CU size")
-        ("MaxCUSize,s",             m_uiMaxCUHeight,            64u, "Maximum CU size")
-        ("MaxPartitionDepth,h",     m_uiMaxCUDepth,              4u, "CU depth")
-
-        ("QuadtreeTULog2MaxSize",   m_uiQuadtreeTULog2MaxSize,   6u, "Maximum TU size in logarithm base 2")
-        ("QuadtreeTULog2MinSize",   m_uiQuadtreeTULog2MinSize,   2u, "Minimum TU size in logarithm base 2")
-
-        ("QuadtreeTUMaxDepthIntra", m_uiQuadtreeTUMaxDepthIntra, 1u, "Depth of TU tree for intra CUs")
-        ("QuadtreeTUMaxDepthInter", m_uiQuadtreeTUMaxDepthInter, 2u, "Depth of TU tree for inter CUs")
-
-    // Coding structure paramters
-        ("IntraPeriod,-ip",         m_iIntraPeriod,              -1, "Intra period in frames, (-1: only first frame)")
-        ("DecodingRefreshType,-dr", m_iDecodingRefreshType,       0, "Intra refresh type (0:none 1:CRA 2:IDR)")
-        ("GOPSize,g",               m_iGOPSize,                   1, "GOP size of temporal structure")
-        ("ListCombination,-lc",     m_bUseLComb,               true,
-        "Combined reference list for uni-prediction estimation in B-slices")
-    // motion options
-        ("FastSearch",              m_iFastSearch,                1, "0:Full search  1:Diamond  2:PMVFAST")
-        ("SearchRange,-sr",         m_iSearchRange,              96, "Motion search range")
-        ("BipredSearchRange",       m_bipredSearchRange,          4, "Motion search range for bipred refinement")
-        ("HadamardME",              m_bUseHADME,               true, "Hadamard ME for fractional-pel")
-        ("ASR",                     m_bUseASR,                false, "Adaptive motion search range")
-
-    // Mode decision parameters
-        ("LambdaModifier0,-LM0", m_adLambdaModifier[0], (Double)1.0, "Lambda modifier for temporal layer 0")
-        ("LambdaModifier1,-LM1", m_adLambdaModifier[1], (Double)1.0, "Lambda modifier for temporal layer 1")
-        ("LambdaModifier2,-LM2", m_adLambdaModifier[2], (Double)1.0, "Lambda modifier for temporal layer 2")
-        ("LambdaModifier3,-LM3", m_adLambdaModifier[3], (Double)1.0, "Lambda modifier for temporal layer 3")
-        ("LambdaModifier4,-LM4", m_adLambdaModifier[4], (Double)1.0, "Lambda modifier for temporal layer 4")
-        ("LambdaModifier5,-LM5", m_adLambdaModifier[5], (Double)1.0, "Lambda modifier for temporal layer 5")
-        ("LambdaModifier6,-LM6", m_adLambdaModifier[6], (Double)1.0, "Lambda modifier for temporal layer 6")
-        ("LambdaModifier7,-LM7", m_adLambdaModifier[7], (Double)1.0, "Lambda modifier for temporal layer 7")
-
-    /* Quantization parameters */
-        ("QP,q",          m_fQP,             30.0, "Qp value, if value is float, QP is switched once during encoding")
-        ("DeltaQpRD,-dqr", m_uiDeltaQpRD,       0u, "max dQp offset for slice")
-        ("MaxDeltaQP,d",  m_iMaxDeltaQP,        0, "max dQp offset for block")
-        ("MaxCuDQPDepth,-dqd",  m_iMaxCuDQPDepth,        0, "max depth for a minimum CuDQP")
-
-        ("CbQpOffset,-cbqpofs",  m_cbQpOffset,        0, "Chroma Cb QP Offset")
-        ("CrQpOffset,-crqpofs",  m_crQpOffset,        0, "Chroma Cr QP Offset")
-
-#if ADAPTIVE_QP_SELECTION
-    ("AdaptiveQpSelection,-aqps",   m_bUseAdaptQpSelect,           false, "AdaptiveQpSelection")
-#endif
-
-    ("AdaptiveQP,-aq",                m_bUseAdaptiveQP,           false, "QP adaptation based on a psycho-visual model")
-        ("MaxQPAdaptationRange,-aqr",     m_iQPAdaptationRange,           6, "QP adaptation range")
-        ("dQPFile,m",                     cfg_dQPFile,           string(""), "dQP file name")
-        ("RDOQ",                          m_useRDOQ,                  true)
-        ("RDOQTS",                        m_useRDOQTS,                true)
-#if L0232_RD_PENALTY
-    ("RDpenalty",                     m_rdPenalty,                0,
-     "RD-penalty for 32x32 TU for intra in non-intra slices. 0:disbaled  1:RD-penalty  2:maximum RD-penalty")
-#endif
-    // Entropy coding parameters
-    ("SBACRD",                         m_bUseSBACRD,                      true, "SBAC based RD estimation")
-
-    // Deblocking filter parameters
-        ("LoopFilterDisable",              m_bLoopFilterDisable,             false)
-        ("LoopFilterOffsetInPPS",          m_loopFilterOffsetInPPS,          false)
-        ("LoopFilterBetaOffset_div2",      m_loopFilterBetaOffsetDiv2,           0)
-        ("LoopFilterTcOffset_div2",        m_loopFilterTcOffsetDiv2,             0)
-        ("DeblockingFilterControlPresent", m_DeblockingFilterControlPresent, false)
-#if L0386_DB_METRIC
-    ("DeblockingFilterMetric",         m_DeblockingFilterMetric,         false)
-#endif
-
-    // Coding tools
-    ("AMP",                      m_enableAMP,                 true,  "Enable asymmetric motion partitions")
-        ("TransformSkip",            m_useTransformSkip,          false, "Intra transform skipping")
-        ("TransformSkipFast",        m_useTransformSkipFast,      false, "Fast intra transform skipping")
-        ("SAO",                      m_bUseSAO,                   true,  "Enable Sample Adaptive Offset")
-        ("MaxNumOffsetsPerPic",      m_maxNumOffsetsPerPic,       2048,  "Max number of SAO offset per picture (Default: 2048)")
-        ("SAOLcuBoundary",           m_saoLcuBoundary,            false,
-        "0: right/bottom LCU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas")
-        ("SAOLcuBasedOptimization",  m_saoLcuBasedOptimization,   true,
-        "0: SAO picture-based optimization, 1: SAO LCU-based optimization ")
-        ("SliceMode",                m_sliceMode,                0,
-        "0: Disable all Recon slice limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice")
-        ("SliceArgument",            m_sliceArgument,            0,     "Depending on SliceMode being:"
-        "\t1: max number of CTUs per slice"
-        "\t2: max number of bytes per slice"
-        "\t3: max number of tiles per slice")
-        ("SliceSegmentMode",         m_sliceSegmentMode,       0,
-        "0: Disable all slice segment limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice")
-        ("SliceSegmentArgument",     m_sliceSegmentArgument,   0,     "Depending on SliceSegmentMode being:"
-        "\t1: max number of CTUs per slice segment"
-        "\t2: max number of bytes per slice segment"
-        "\t3: max number of tiles per slice segment")
-        ("LFCrossSliceBoundaryFlag", m_bLFCrossSliceBoundaryFlag, true)
-
-        ("ConstrainedIntraPred",     m_bUseConstrainedIntraPred,  false, "Constrained Intra Prediction")
-
-        ("PCMEnabledFlag",           m_usePCM,                    false)
-        ("PCMLog2MaxSize",           m_pcmLog2MaxSize,            5u)
-        ("PCMLog2MinSize",           m_uiPCMLog2MinSize,          3u)
-        ("PCMInputBitDepthFlag",     m_bPCMInputBitDepthFlag,     true)
-        ("PCMFilterDisableFlag",     m_bPCMFilterDisableFlag,    false)
-
-        ("LosslessCuEnabled",        m_useLossless, false)
-
-        ("WeightedPredP,-wpP",          m_useWeightedPred,               false,      "Use weighted prediction in P slices")
-        ("WeightedPredB,-wpB",          m_useWeightedBiPred,             false,
-        "Use weighted (bidirectional) prediction in B slices")
-        ("Log2ParallelMergeLevel",      m_log2ParallelMergeLevel,     2u,          "Parallel merge estimation region")
-        ("UniformSpacingIdc",           m_iUniformSpacingIdr,            0,
-        "Indicates if the column and row boundaries are distributed uniformly")
-        ("NumTileColumnsMinus1",        m_iNumColumnsMinus1,             0,          "Number of columns in a picture minus 1")
-        ("ColumnWidthArray",            cfg_ColumnWidth,                 string(""),
-        "Array containing ColumnWidth values in units of LCU")
-        ("NumTileRowsMinus1",           m_iNumRowsMinus1,                0,          "Number of rows in a picture minus 1")
-        ("RowHeightArray",              cfg_RowHeight,                   string(""),
-        "Array containing RowHeight values in units of LCU")
-        ("LFCrossTileBoundaryFlag",      m_bLFCrossTileBoundaryFlag,             true,
-        "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering")
-        ("WaveFrontSynchro",            m_iWaveFrontSynchro,             0,
-        "0: no synchro; 1 synchro with TR; 2 TRR etc")
-        ("ScalingList",                 m_useScalingListId,              0,
-        "0: no scaling list, 1: default scaling lists, 2: scaling lists specified in ScalingListFile")
-        ("ScalingListFile",             cfg_ScalingListFile,             string(""), "Scaling list file name")
-        ("SignHideFlag,-SBH",                m_signHideFlag, 1)
-        ("MaxNumMergeCand",             m_maxNumMergeCand,             5u,         "Maximum number of merge candidates")
-
-    /* Misc. */
-        ("SEIDecodedPictureHash",       m_decodedPictureHashSEIEnabled, 0,
-        "Control generation of decode picture hash SEI messages\n"
-        "\t3: checksum\n"
-        "\t2: CRC\n"
-        "\t1: use MD5\n"
-        "\t0: disable")
-        ("SEIpictureDigest",            m_decodedPictureHashSEIEnabled, 0, "deprecated alias for SEIDecodedPictureHash")
-        ("TMVPMode", m_TMVPModeId, 1,
-        "TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices (default) 2: TMVP enable for certain slices only")
-        ("FEN", m_bUseFastEnc, false, "fast encoder setting")
-        ("ECU", m_bUseEarlyCU, false, "Early CU setting")
-        ("FDM", m_useFastDecisionForMerge, true, "Fast decision for Merge RD Cost")
-        ("CFM", m_bUseCbfFastMode, false, "Cbf fast mode setting")
-        ("ESD", m_useEarlySkipDetection, false, "Early SKIP detection setting")
-#if RATE_CONTROL_LAMBDA_DOMAIN
-    ("RateControl",         m_RCEnableRateControl,   false, "Rate control: enable rate control")
-        ("TargetBitrate",       m_RCTargetBitrate,           0, "Rate control: target bitrate")
-        ("KeepHierarchicalBit", m_RCKeepHierarchicalBit, false,
-        "Rate control: keep hierarchical bit allocation in rate control algorithm")
-        ("LCULevelRateControl", m_RCLCULevelRC,           true, "Rate control: true: LCU level RC; false: picture level RC")
-        ("RCLCUSeparateModel",  m_RCUseLCUSeparateModel,  true, "Rate control: use LCU level separate R-lambda model")
-        ("InitialQP",           m_RCInitialQP,               0, "Rate control: initial QP")
-        ("RCForceIntraQP",      m_RCForceIntraQP,        false, "Rate control: force intra QP to be equal to initial QP")
-#else
-    ("RateCtrl,-rc", m_enableRateCtrl, false, "Rate control on/off")
-        ("TargetBitrate,-tbr", m_targetBitrate, 0, "Input target bitrate")
-        ("NumLCUInUnit,-nu", m_numLCUInUnit, 0, "Number of LCUs in an Unit")
-#endif // if RATE_CONTROL_LAMBDA_DOMAIN
-
-    ("TransquantBypassEnableFlag", m_TransquantBypassEnableFlag, false, "transquant_bypass_enable_flag indicator in PPS")
-        ("CUTransquantBypassFlagValue", m_CUTransquantBypassFlagValue, false,
-        "Fixed cu_transquant_bypass_flag value, when transquant_bypass_enable_flag is enabled")
-        ("RecalculateQPAccordingToLambda", m_recalculateQPAccordingToLambda, false,
-        "Recalculate QP values according to lambda values. Do not suggest to be enabled in all intra case")
-        ("StrongIntraSmoothing,-sis",      m_useStrongIntraSmoothing,           true,
-        "Enable strong intra smoothing for 32x32 blocks")
-        ("SEIActiveParameterSets",         m_activeParameterSetsSEIEnabled,          0,
-        "Enable generation of active parameter sets SEI messages")
-        ("VuiParametersPresent,-vui",      m_vuiParametersPresentFlag,           false, "Enable generation of vui_parameters()")
-        ("AspectRatioInfoPresent",         m_aspectRatioInfoPresentFlag,         false,
-        "Signals whether aspect_ratio_idc is present")
-        ("AspectRatioIdc",                 m_aspectRatioIdc,                         0, "aspect_ratio_idc")
-        ("SarWidth",                       m_sarWidth,                               0,
-        "horizontal size of the sample aspect ratio")
-        ("SarHeight",                      m_sarHeight,                              0,
-        "vertical size of the sample aspect ratio")
-        ("OverscanInfoPresent",            m_overscanInfoPresentFlag,            false,
-        "Indicates whether conformant decoded pictures are suitable for display using overscan\n")
-        ("OverscanAppropriate",            m_overscanAppropriateFlag,            false,
-        "Indicates whether conformant decoded pictures are suitable for display using overscan\n")
-        ("VideoSignalTypePresent",         m_videoSignalTypePresentFlag,         false,
-        "Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present")
-        ("VideoFormat",                    m_videoFormat,                            5, "Indicates representation of pictures")
-        ("VideoFullRange",                 m_videoFullRangeFlag,                 false,
-        "Indicates the black level and range of luma and chroma signals")
-        ("ColourDescriptionPresent",       m_colourDescriptionPresentFlag,       false,
-        "Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present")
-        ("ColourPrimaries",                m_colourPrimaries,                        2,
-        "Indicates chromaticity coordinates of the source primaries")
-        ("TransferCharateristics",         m_transferCharacteristics,                2,
-        "Indicates the opto-electronic transfer characteristics of the source")
-        ("MatrixCoefficients",             m_matrixCoefficients,                     2,
-        "Describes the matrix coefficients used in deriving luma and chroma from RGB primaries")
-        ("ChromaLocInfoPresent",           m_chromaLocInfoPresentFlag,           false,
-        "Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present")
-        ("ChromaSampleLocTypeTopField",    m_chromaSampleLocTypeTopField,            0,
-        "Specifies the location of chroma samples for top field")
-        ("ChromaSampleLocTypeBottomField", m_chromaSampleLocTypeBottomField,         0,
-        "Specifies the location of chroma samples for bottom field")
-        ("NeutralChromaIndication",        m_neutralChromaIndicationFlag,        false,
-        "Indicates that the value of all decoded chroma samples is equal to 1<<(BitDepthCr-1)")
-        ("DefaultDisplayWindowFlag",       m_defaultDisplayWindowFlag,           false,
-        "Indicates the presence of the Default Window parameters")
-        ("DefDispWinLeftOffset",           m_defDispWinLeftOffset,                   0,
-        "Specifies the left offset of the default display window from the conformance window")
-        ("DefDispWinRightOffset",          m_defDispWinRightOffset,                  0,
-        "Specifies the right offset of the default display window from the conformance window")
-        ("DefDispWinTopOffset",            m_defDispWinTopOffset,                    0,
-        "Specifies the top offset of the default display window from the conformance window")
-        ("DefDispWinBottomOffset",         m_defDispWinBottomOffset,                 0,
-        "Specifies the bottom offset of the default display window from the conformance window")
-        ("FrameFieldInfoPresentFlag",      m_frameFieldInfoPresentFlag,               false,
-        "Indicates that pic_struct and field coding related values are present in picture timing SEI messages")
-        ("PocProportionalToTimingFlag",   m_pocProportionalToTimingFlag,         false,
-        "Indicates that the POC value is proportional to the output time w.r.t. first picture in CVS")
-        ("NumTicksPocDiffOneMinus1",      m_numTicksPocDiffOneMinus1,                0,
-        "Number of ticks minus 1 that for a POC difference of one")
-        ("BitstreamRestriction",           m_bitstreamRestrictionFlag,           false,
-        "Signals whether bitstream restriction parameters are present")
-        ("TilesFixedStructure",            m_tilesFixedStructureFlag,            false,
-        "Indicates that each active picture parameter set has the same values of the syntax elements related to tiles")
-        ("MotionVectorsOverPicBoundaries", m_motionVectorsOverPicBoundariesFlag, false,
-        "Indicates that no samples outside the picture boundaries are used for inter prediction")
-        ("MaxBytesPerPicDenom",            m_maxBytesPerPicDenom,                    2,
-        "Indicates a number of bytes not exceeded by the sum of the sizes of the VCL NAL units associated with any coded picture")
-        ("MaxBitsPerMinCuDenom",           m_maxBitsPerMinCuDenom,                   1,
-        "Indicates an upper bound for the number of bits of coding_unit() data")
-        ("Log2MaxMvLengthHorizontal",      m_log2MaxMvLengthHorizontal,             15,
-        "Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units")
-        ("Log2MaxMvLengthVertical",        m_log2MaxMvLengthVertical,               15,
-        "Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units")
-        ("SEIRecoveryPoint",               m_recoveryPointSEIEnabled,                0,
-        "Control generation of recovery point SEI messages")
-        ("SEIBufferingPeriod",             m_bufferingPeriodSEIEnabled,              0,
-        "Control generation of buffering period SEI messages")
-        ("SEIPictureTiming",               m_pictureTimingSEIEnabled,                0,
-        "Control generation of picture timing SEI messages")
-#if J0149_TONE_MAPPING_SEI
-    ("SEIToneMappingInfo",                       m_toneMappingInfoSEIEnabled,    false,
-     "Control generation of Tone Mapping SEI messages")
-        ("SEIToneMapId",                             m_toneMapId,                        0,
-        "Specifies Id of Tone Mapping SEI message for a given session")
-        ("SEIToneMapCancelFlag",                     m_toneMapCancelFlag,            false,
-        "Indicates that Tone Mapping SEI message cancels the persistance or follows")
-        ("SEIToneMapPersistenceFlag",                m_toneMapPersistenceFlag,        true,
-        "Specifies the persistence of the Tone Mapping SEI message")
-        ("SEIToneMapCodedDataBitDepth",              m_toneMapCodedDataBitDepth,         8,
-        "Specifies Coded Data BitDepth of Tone Mapping SEI messages")
-        ("SEIToneMapTargetBitDepth",                 m_toneMapTargetBitDepth,            8,
-        "Specifies Output BitDepth of Tome mapping function")
-        ("SEIToneMapModelId",                        m_toneMapModelId,                   0,
-        "Specifies Model utilized for mapping coded data into target_bit_depth range\n"
-        "\t0:  linear mapping with clipping\n"
-        "\t1:  sigmoidal mapping\n"
-        "\t2:  user-defined table mapping\n"
-        "\t3:  piece-wise linear mapping\n"
-        "\t4:  luminance dynamic range information ")
-        ("SEIToneMapMinValue",                              m_toneMapMinValue,                          0,
-        "Specifies the minimum value in mode 0")
-        ("SEIToneMapMaxValue",                              m_toneMapMaxValue,                       1023,
-        "Specifies the maxmum value in mode 0")
-        ("SEIToneMapSigmoidMidpoint",                       m_sigmoidMidpoint,                        512,
-        "Specifies the centre point in mode 1")
-        ("SEIToneMapSigmoidWidth",                          m_sigmoidWidth,                           960,
-        "Specifies the distance between 5% and 95% values of the target_bit_depth in mode 1")
-        ("SEIToneMapStartOfCodedInterval",                  cfg_startOfCodedInterval,          string(""),
-        "Array of user-defined mapping table")
-        ("SEIToneMapNumPivots",                             m_numPivots,                                0,
-        "Specifies the number of pivot points in mode 3")
-        ("SEIToneMapCodedPivotValue",                       cfg_codedPivotValue,               string(""), "Array of pivot point")
-        ("SEIToneMapTargetPivotValue",                      cfg_targetPivotValue,              string(""), "Array of pivot point")
-        ("SEIToneMapCameraIsoSpeedIdc",                     m_cameraIsoSpeedIdc,                        0,
-        "Indicates the camera ISO speed for daylight illumination")
-        ("SEIToneMapCameraIsoSpeedValue",                   m_cameraIsoSpeedValue,                    400,
-        "Specifies the camera ISO speed for daylight illumination of Extended_ISO")
-        ("SEIToneMapExposureCompensationValueSignFlag",     m_exposureCompensationValueSignFlag,        0,
-        "Specifies the sign of ExposureCompensationValue")
-        ("SEIToneMapExposureCompensationValueNumerator",    m_exposureCompensationValueNumerator,       0,
-        "Specifies the numerator of ExposureCompensationValue")
-        ("SEIToneMapExposureCompensationValueDenomIdc",     m_exposureCompensationValueDenomIdc,        2,
-        "Specifies the denominator of ExposureCompensationValue")
-        ("SEIToneMapRefScreenLuminanceWhite",               m_refScreenLuminanceWhite,                350,
-        "Specifies reference screen brightness setting in units of candela per square metre")
-        ("SEIToneMapExtendedRangeWhiteLevel",               m_extendedRangeWhiteLevel,                800,
-        "Indicates the luminance dynamic range")
-        ("SEIToneMapNominalBlackLevelLumaCodeValue",        m_nominalBlackLevelLumaCodeValue,          16,
-        "Specifies luma sample value of the nominal black level assigned decoded pictures")
-        ("SEIToneMapNominalWhiteLevelLumaCodeValue",        m_nominalWhiteLevelLumaCodeValue,         235,
-        "Specifies luma sample value of the nominal white level assigned decoded pictures")
-        ("SEIToneMapExtendedWhiteLevelLumaCodeValue",       m_extendedWhiteLevelLumaCodeValue,        300,
-        "Specifies luma sample value of the extended dynamic range assigned decoded pictures")
-#endif // if J0149_TONE_MAPPING_SEI
-    ("SEIFramePacking",                m_framePackingSEIEnabled,                 0,
-     "Control generation of frame packing SEI messages")
-        ("SEIFramePackingType",            m_framePackingSEIType,                    0, "Define frame packing arrangement\n"
-        "\t0: checkerboard - pixels alternatively represent either frames\n"
-        "\t1: column alternation - frames are interlaced by column\n"
-        "\t2: row alternation - frames are interlaced by row\n"
-        "\t3: side by side - frames are displayed horizontally\n"
-        "\t4: top bottom - frames are displayed vertically\n"
-        "\t5: frame alternation - one frame is alternated with the other")
-        ("SEIFramePackingId",              m_framePackingSEIId,                      0,
-        "Id of frame packing SEI message for a given session")
-        ("SEIFramePackingQuincunx",        m_framePackingSEIQuincunx,                0,
-        "Indicate the presence of a Quincunx type video frame")
-        ("SEIFramePackingInterpretation",  m_framePackingSEIInterpretation,          0,
-        "Indicate the interpretation of the frame pair\n"
-        "\t0: unspecified\n"
-        "\t1: stereo pair, frame0 represents left view\n"
-        "\t2: stereo pair, frame0 represents right view")
-        ("SEIDisplayOrientation",          m_displayOrientationSEIAngle,             0,
-        "Control generation of display orientation SEI messages\n"
-        "\tN: 0 < N < (2^16 - 1) enable display orientation SEI message with anticlockwise_rotation = N and display_orientation_repetition_period = 1\n"
-        "\t0: disable")
-        ("SEITemporalLevel0Index",         m_temporalLevel0IndexSEIEnabled,          0,
-        "Control generation of temporal level 0 index SEI messages")
-        ("SEIGradualDecodingRefreshInfo",  m_gradualDecodingRefreshInfoEnabled,      0,
-        "Control generation of gradual decoding refresh information SEI message")
-        ("SEIDecodingUnitInfo",             m_decodingUnitInfoSEIEnabled,                       0,
-        "Control generation of decoding unit information SEI message.")
-#if L0208_SOP_DESCRIPTION_SEI
-    ("SEISOPDescription",              m_SOPDescriptionSEIEnabled,              0,
-     "Control generation of SOP description SEI messages")
-#endif
-#if K0180_SCALABLE_NESTING_SEI
-    ("SEIScalableNesting",             m_scalableNestingSEIEnabled,              0,
-     "Control generation of scalable nesting SEI messages")
-#endif
-#if SIGNAL_BITRATE_PICRATE_IN_VPS
-    ("BitRatePicRateMaxTLayers",   m_bitRatePicRateMaxTLayers,           0,
-     "Maximum number of sub-layers signalled; can be inferred otherwise; here for easy parsing of config. file")
-        ("BitRateInfoPresent",         cfg_bitRateInfoPresentFlag,          string(""),
-        "Control signalling of bit rate information of avg. bit rate and max. bit rate in VPS\n"
-        "\t0: Do not sent bit rate info\n"
-        "\tN (N > 0): Send bit rate info for N sub-layers. N should equal maxTempLayers.")
-        ("PicRateInfoPresent",         cfg_picRateInfoPresentFlag,          string(""),
-        "Control signalling of picture rate information of avg. bit rate and max. bit rate in VPS\n"
-        "\t0: Do not sent picture rate info\n"
-        "\tN (N > 0): Send picture rate info for N sub-layers. N should equal maxTempLayers.")
-        ("AvgBitRate",                   cfg_avgBitRate,                    string(""),
-        "List of avg. bit rates for the different sub-layers; include non-negative number even if corresponding flag is 0")
-        ("MaxBitRate",                   cfg_maxBitRate,                    string(""),
-        "List of max. bit rates for the different sub-layers; include non-negative number even if corresponding flag is 0")
-        ("AvgPicRate",                   cfg_avgPicRate,                    string(""),
-        "List of avg. picture rates for the different sub-layers; include non-negative number even if corresponding flag is 0")
-        ("ConstantPicRateIdc",           cfg_constantPicRateIdc,            string(""),
-        "List of constant picture rate IDCs; include non-negative number even if corresponding flag is 0")
-#endif // if SIGNAL_BITRATE_PICRATE_IN_VPS
-    ;
-
-    for (Int i = 1; i < MAX_GOP + 1; i++)
-    {
-        std::ostringstream cOSS;
-        cOSS << "Frame" << i;
-        opts.addOptions() (cOSS.str(), m_GOPList[i - 1], GOPEntry());
-    }
-
-    po::setDefaults(opts);
-    const list<const Char *>& argv_unhandled = po::scanArgv(opts, argc, (const Char**)argv);
-
-    for (list<const Char *>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
-    {
-        fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it);
-    }
-
-    if (argc == 1 || do_help)
-    {
-        /* argc == 1: no options have been specified */
-        po::doHelp(cout, opts);
-        return false;
-    }
-
-    /*
-     * Set any derived parameters
-     */
-
-    /* convert std::string to c string for compatability */
-    m_pchInputFile = cfg_InputFile.empty() ? NULL : strdup(cfg_InputFile.c_str());
-    m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
-    m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
-    m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
-
-    /* parse the width, height, frame rate from the y4m files if it is not given in the configuration file */
-    char * s = strrchr(m_pchInputFile, '.');
-    handler_input = NULL;
-    handler_recon = NULL;
-
-    if ((!strcmp(s + 1, "y4m")))
-    {
-        m_cTVideoIOInputFile = new TVideoIOY4m();
-        m_cTVideoIOReconFile = new TVideoIOY4m();
-        /* get the video information like width,height,framerate */
-        m_cTVideoIOInputFile->open(m_pchInputFile,
-                                   false,
-                                   m_inputBitDepthY,
-                                   m_inputBitDepthC,
-                                   m_internalBitDepthY,
-                                   m_internalBitDepthC,
-                                   handler_input,
-                                   video_info,
-                                   m_aiPad);
-        m_cTVideoIOInputFile->getVideoInfo(video_info, handler_input);
-        m_iSourceWidth = video_info.width;
-        m_iSourceHeight = video_info.height;
-        m_iFrameRate = video_info.FrameRate;
-    }
-    else if ((!strcmp(s + 1, "yuv")))
-    {
-        m_cTVideoIOInputFile = new TVideoIOYuv();
-        m_cTVideoIOReconFile = new TVideoIOYuv();
-    }
-
-    Char *pColumnWidth = cfg_ColumnWidth.empty() ? NULL : strdup(cfg_ColumnWidth.c_str());
-    Char *pRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str());
-    if (m_iUniformSpacingIdr == 0 && m_iNumColumnsMinus1 > 0)
-    {
-        char *columnWidth;
-        int  i = 0;
-        m_pColumnWidth = new UInt[m_iNumColumnsMinus1];
-        columnWidth = strtok(pColumnWidth, " ,-");
-        while (columnWidth != NULL)
-        {
-            if (i >= m_iNumColumnsMinus1)
-            {
-                printf("The number of columns whose width are defined is larger than the allowed number of columns.\n");
-                exit(EXIT_FAILURE);
-            }
-
-            *(m_pColumnWidth + i) = atoi(columnWidth);
-            columnWidth = strtok(NULL, " ,-");
-            i++;
-        }
-
-        if (i < m_iNumColumnsMinus1)
-        {
-            printf("The width of some columns is not defined.\n");
-            exit(EXIT_FAILURE);
-        }
-    }
-    else
-    {
-        m_pColumnWidth = NULL;
-    }
-
-    if (m_iUniformSpacingIdr == 0 && m_iNumRowsMinus1 > 0)
-    {
-        char *rowHeight;
-        int  i = 0;
-        m_pRowHeight = new UInt[m_iNumRowsMinus1];
-        rowHeight = strtok(pRowHeight, " ,-");
-        while (rowHeight != NULL)
-        {
-            if (i >= m_iNumRowsMinus1)
-            {
-                printf("The number of rows whose height are defined is larger than the allowed number of rows.\n");
-                exit(EXIT_FAILURE);
-            }
-
-            *(m_pRowHeight + i) = atoi(rowHeight);
-            rowHeight = strtok(NULL, " ,-");
-            i++;
-        }
-
-        if (i < m_iNumRowsMinus1)
-        {
-            printf("The height of some rows is not defined.\n");
-            exit(EXIT_FAILURE);
-        }
-    }
-    else
-    {
-        m_pRowHeight = NULL;
-    }
-
-#if SIGNAL_BITRATE_PICRATE_IN_VPS
-    readBoolString(cfg_bitRateInfoPresentFlag,
-                   m_bitRatePicRateMaxTLayers,
-                   m_bitRateInfoPresentFlag,
-                   "bit rate info. present flag");
-    readIntString(cfg_avgBitRate,             m_bitRatePicRateMaxTLayers, m_avgBitRate,             "avg. bit rate");
-    readIntString(cfg_maxBitRate,             m_bitRatePicRateMaxTLayers, m_maxBitRate,             "max. bit rate");
-    readBoolString(cfg_picRateInfoPresentFlag,
-                   m_bitRatePicRateMaxTLayers,
-                   m_picRateInfoPresentFlag,
-                   "bit rate info. present flag");
-    readIntString(cfg_avgPicRate,             m_bitRatePicRateMaxTLayers, m_avgPicRate,             "avg. pic rate");
-    readIntString(cfg_constantPicRateIdc,     m_bitRatePicRateMaxTLayers, m_constantPicRateIdc,     "constant pic rate Idc");
-#endif // if SIGNAL_BITRATE_PICRATE_IN_VPS
-    m_scalingListFile = cfg_ScalingListFile.empty() ? NULL : strdup(cfg_ScalingListFile.c_str());
-
-    /* rules for input, output and internal bitdepths as per help text */
-    if (!m_internalBitDepthY)
-    {
-        m_internalBitDepthY = m_inputBitDepthY;
-    }
-
-    if (!m_internalBitDepthC)
-    {
-        m_internalBitDepthC = m_internalBitDepthY;
-    }
-
-    if (!m_inputBitDepthC)
-    {
-        m_inputBitDepthC = m_inputBitDepthY;
-    }
-
-    if (!m_outputBitDepthY)
-    {
-        m_outputBitDepthY = m_internalBitDepthY;
-    }
-
-    if (!m_outputBitDepthC)
-    {
-        m_outputBitDepthC = m_internalBitDepthC;
-    }
-
-    // TODO:ChromaFmt assumes 4:2:0 below
-    switch (m_conformanceMode)
-    {
-    case 0:
-    {
-        // no conformance or padding
-        m_confLeft = m_confRight = m_confTop = m_confBottom = 0;
-        m_aiPad[1] = m_aiPad[0] = 0;
-        break;
-    }
-    case 1:
-    {
-        // automatic padding to minimum CU size
-        Int minCuSize = m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1);
-        if (m_iSourceWidth % minCuSize)
-        {
-            m_aiPad[0] = m_confRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
-            m_iSourceWidth  += m_confRight;
-        }
-
-        if (m_iSourceHeight % minCuSize)
-        {
-            m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
-            m_iSourceHeight += m_confBottom;
-        }
-
-        if (m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0)
-        {
-            fprintf(stderr, "Error: picture width is not an integer multiple of the specified chroma subsampling\n");
-            exit(EXIT_FAILURE);
-        }
-
-        if (m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0)
-        {
-            fprintf(stderr, "Error: picture height is not an integer multiple of the specified chroma subsampling\n");
-            exit(EXIT_FAILURE);
-        }
-
-        break;
-    }
-    case 2:
-    {
-        //padding
-        m_iSourceWidth  += m_aiPad[0];
-        m_iSourceHeight += m_aiPad[1];
-        m_confRight  = m_aiPad[0];
-        m_confBottom = m_aiPad[1];
-        break;
-    }
-    case 3:
-    {
-        // conformance
-        if ((m_confLeft == 0) && (m_confRight == 0) && (m_confTop == 0) && (m_confBottom == 0))
-        {
-            fprintf(stderr, "Warning: Conformance window enabled, but all conformance window parameters set to zero\n");
-        }
-
-        if ((m_aiPad[1] != 0) || (m_aiPad[0] != 0))
-        {
-            fprintf(stderr, "Warning: Conformance window enabled, padding parameters will be ignored\n");
-        }
-
-        m_aiPad[1] = m_aiPad[0] = 0;
-        break;
-    }
-    }
-
-    // allocate slice-based dQP values
-    m_aidQP = new Int[m_framesToBeEncoded + m_iGOPSize + 1];
-    ::memset(m_aidQP, 0, sizeof(Int) * (m_framesToBeEncoded + m_iGOPSize + 1));
-
-    // handling of floating-point QP values
-    // if QP is not integer, sequence is split into two sections having QP and QP+1
-    m_iQP = (Int)(m_fQP);
-    if (m_iQP < m_fQP)
-    {
-        Int iSwitchPOC = (Int)(m_framesToBeEncoded - (m_fQP - m_iQP) * m_framesToBeEncoded + 0.5);
-
-        iSwitchPOC = (Int)((Double)iSwitchPOC / m_iGOPSize + 0.5) * m_iGOPSize;
-        for (Int i = iSwitchPOC; i < m_framesToBeEncoded + m_iGOPSize + 1; i++)
-        {
-            m_aidQP[i] = 1;
-        }
-    }
-
-    // reading external dQP description from file
-    if (m_pchdQPFile)
-    {
-        FILE *fpt = fopen(m_pchdQPFile, "r");
-        if (fpt)
-        {
-            Int iValue;
-            Int iPOC = 0;
-            while (iPOC < m_framesToBeEncoded)
-            {
-                if (fscanf(fpt, "%d", &iValue) == EOF) break;
-
-                m_aidQP[iPOC] = iValue;
-                iPOC++;
-            }
-
-            fclose(fpt);
-        }
-    }
-
-    m_iWaveFrontSubstreams = m_iWaveFrontSynchro ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1;
-
-#if J0149_TONE_MAPPING_SEI
-    if (m_toneMappingInfoSEIEnabled && !m_toneMapCancelFlag)
-    {
-        Char *pcStartOfCodedInterval = cfg_startOfCodedInterval.empty() ? NULL : strdup(cfg_startOfCodedInterval.c_str());
-        Char *pcCodedPivotValue = cfg_codedPivotValue.empty() ? NULL : strdup(cfg_codedPivotValue.c_str());
-        Char *pcTargetPivotValue = cfg_targetPivotValue.empty() ? NULL : strdup(cfg_targetPivotValue.c_str());
-        if (m_toneMapModelId == 2 && pcStartOfCodedInterval)
-        {
-            char *startOfCodedInterval;
-            UInt num = 1u << m_toneMapTargetBitDepth;
-            m_startOfCodedInterval = new Int[num];
-            ::memset(m_startOfCodedInterval, 0, sizeof(Int) * num);
-            startOfCodedInterval = strtok(pcStartOfCodedInterval, " .");
-            int i = 0;
-            while (startOfCodedInterval && (i < num))
-            {
-                m_startOfCodedInterval[i] = atoi(startOfCodedInterval);
-                startOfCodedInterval = strtok(NULL, " .");
-                i++;
-            }
-        }
-        else
-        {
-            m_startOfCodedInterval = NULL;
-        }
-
-        if ((m_toneMapModelId == 3) && (m_numPivots > 0))
-        {
-            if (pcCodedPivotValue && pcTargetPivotValue)
-            {
-                char *codedPivotValue;
-                char *targetPivotValue;
-                m_codedPivotValue = new Int[m_numPivots];
-                m_targetPivotValue = new Int[m_numPivots];
-                ::memset(m_codedPivotValue, 0, sizeof(Int) * (m_numPivots));
-                ::memset(m_targetPivotValue, 0, sizeof(Int) * (m_numPivots));
-                codedPivotValue = strtok(pcCodedPivotValue, " .");
-                int i = 0;
-                while (codedPivotValue && i < m_numPivots)
-                {
-                    m_codedPivotValue[i] = atoi(codedPivotValue);
-                    codedPivotValue = strtok(NULL, " .");
-                    i++;
-                }
-
-                i = 0;
-                targetPivotValue = strtok(pcTargetPivotValue, " .");
-                while (targetPivotValue && i < m_numPivots)
-                {
-                    m_targetPivotValue[i] = atoi(targetPivotValue);
-                    targetPivotValue = strtok(NULL, " .");
-                    i++;
-                }
-            }
-        }
-        else
-        {
-            m_codedPivotValue = NULL;
-            m_targetPivotValue = NULL;
-        }
-    }
-
-#endif // if J0149_TONE_MAPPING_SEI
-       // check validity of input parameters
-    xCheckParameter();
-
-    // set global varibles
-    xSetGlobal();
-
-    // print-out parameters
-    xPrintParameter();
-
-    return true;
-}
-
-#if SIGNAL_BITRATE_PICRATE_IN_VPS
-Void readBoolString(const string inpString, const Int numEntries, Bool* &memberArray, const char *elementName)
-{
-    Char *inpArray = inpString.empty() ? NULL : strdup(inpString.c_str());
-    Int i = 0;
-
-    if (numEntries)
-    {
-        Char *tempArray = strtok(inpArray, " ,-");
-        memberArray = new Bool[numEntries];
-        while (tempArray != NULL)
-        {
-            if (i >= numEntries)
-            {
-                printf("The number of %s defined is larger than the allowed number\n", elementName);
-                exit(EXIT_FAILURE);
-            }
-
-            assert((atoi(tempArray) == 0) || (atoi(tempArray) == 1));
-            *(memberArray + i) = atoi(tempArray);
-            tempArray = strtok(NULL, " ,-");
-            i++;
-        }
-
-        if (i < numEntries)
-        {
-            printf("Some %s are not defined\n", elementName);
-            exit(EXIT_FAILURE);
-        }
-    }
-    else
-    {
-        memberArray = NULL;
-    }
-}
-
-Void readIntString(const string inpString, const Int numEntries, Int* &memberArray, const char *elementName)
-{
-    Char *inpArray = inpString.empty() ? NULL : strdup(inpString.c_str());
-    Int i = 0;
-
-    if (numEntries)
-    {
-        Char *tempArray = strtok(inpArray, " ,-");
-        memberArray = new Int[numEntries];
-        while (tempArray != NULL)
-        {
-            if (i >= numEntries)
-            {
-                printf("The number of %s defined is larger than the allowed number\n", elementName);
-                exit(EXIT_FAILURE);
-            }
-
-            *(memberArray + i) = atoi(tempArray);
-            tempArray = strtok(NULL, " ,-");
-            i++;
-        }
-
-        if (i < numEntries)
-        {
-            printf("Some %s are not defined\n", elementName);
-            exit(EXIT_FAILURE);
-        }
-    }
-    else
-    {
-        memberArray = NULL;
-    }
-}
-
-#endif // if SIGNAL_BITRATE_PICRATE_IN_VPS
-// ====================================================================================================================
-// Private member functions
-// ====================================================================================================================
-
-Bool confirmPara(Bool bflag, const Char *message);
-
-Void TAppEncCfg::xCheckParameter()
-{
-    if (!m_decodedPictureHashSEIEnabled)
-    {
-        fprintf(stderr, "******************************************************************\n");
-        fprintf(stderr, "** WARNING: --SEIDecodedPictureHash is now disabled by default. **\n");
-        fprintf(stderr, "**          Automatic verification of decoded pictures by a     **\n");
-        fprintf(stderr, "**          decoder requires this option to be enabled.         **\n");
-        fprintf(stderr, "******************************************************************\n");
-    }
-
-    Bool check_failed = false; /* abort if there is a fatal configuration problem */
-#define xConfirmPara(a, b) check_failed |= confirmPara(a, b)
-    // check range of parameters
-    xConfirmPara(m_inputBitDepthY < 8,                                                     "InputBitDepth must be at least 8");
-    xConfirmPara(m_inputBitDepthC < 8,                                                     "InputBitDepthC must be at least 8");
-    xConfirmPara(m_iFrameRate <= 0,                                                          "Frame rate must be more than 1");
-    xConfirmPara(m_framesToBeEncoded <= 0,
-                 "Total Number Of Frames encoded must be more than 0");
-    xConfirmPara(m_iGOPSize < 1,
-                 "GOP Size must be greater or equal to 1");
-    xConfirmPara(m_iGOPSize > 1 &&  m_iGOPSize % 2,
-                 "GOP Size must be a multiple of 2, if GOP Size is greater than 1");
-    xConfirmPara((m_iIntraPeriod > 0 && m_iIntraPeriod < m_iGOPSize) || m_iIntraPeriod == 0,
-                 "Intra period must be more than GOP size, or -1 , not 0");
-    xConfirmPara(m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2,
-                 "Decoding Refresh Type must be equal to 0, 1 or 2");
-    xConfirmPara(m_iQP <  -6 * (m_internalBitDepthY - 8) || m_iQP > 51,
-                 "QP exceeds supported range (-QpBDOffsety to 51)");
-    xConfirmPara(m_loopFilterBetaOffsetDiv2 < -13 || m_loopFilterBetaOffsetDiv2 > 13,
-                 "Loop Filter Beta Offset div. 2 exceeds supported range (-13 to 13)");
-    xConfirmPara(m_loopFilterTcOffsetDiv2 < -13 || m_loopFilterTcOffsetDiv2 > 13,
-                 "Loop Filter Tc Offset div. 2 exceeds supported range (-13 to 13)");
-    xConfirmPara(m_iFastSearch < 0 || m_iFastSearch > 2,
-                 "Fast Search Mode is not supported value (0:Full search  1:Diamond  2:PMVFAST)");
-    xConfirmPara(m_iSearchRange < 0,                                                        "Search Range must be more than 0");
-    xConfirmPara(m_bipredSearchRange < 0,                                                   "Search Range must be more than 0");
-    xConfirmPara(m_iMaxDeltaQP > 7,
-                 "Absolute Delta QP exceeds supported range (0 to 7)");
-    xConfirmPara(m_iMaxCuDQPDepth > m_uiMaxCUDepth - 1,
-                 "Absolute depth for a minimum CuDQP exceeds maximum coding unit depth");
-
-    xConfirmPara(m_cbQpOffset < -12,   "Min. Chroma Cb QP Offset is -12");
-    xConfirmPara(m_cbQpOffset >  12,   "Max. Chroma Cb QP Offset is  12");
-    xConfirmPara(m_crQpOffset < -12,   "Min. Chroma Cr QP Offset is -12");
-    xConfirmPara(m_crQpOffset >  12,   "Max. Chroma Cr QP Offset is  12");
-
-    xConfirmPara(m_iQPAdaptationRange <= 0,
-                 "QP Adaptation Range must be more than 0");
-    if (m_iDecodingRefreshType == 2)
-    {
-        xConfirmPara(m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize,
-                     "Intra period must be larger than GOP size for periodic IDR pictures");
-    }
-
-    xConfirmPara((m_uiMaxCUWidth  >> m_uiMaxCUDepth) < 4,
-                 "Minimum partition width size should be larger than or equal to 8");
-    xConfirmPara((m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4,
-                 "Minimum partition height size should be larger than or equal to 8");
-    xConfirmPara(m_uiMaxCUWidth < 16,
-                 "Maximum partition width size should be larger than or equal to 16");
-    xConfirmPara(m_uiMaxCUHeight < 16,
-                 "Maximum partition height size should be larger than or equal to 16");
-    xConfirmPara((m_iSourceWidth  % (m_uiMaxCUWidth  >> (m_uiMaxCUDepth - 1))) != 0,
-                 "Resulting coded frame width must be a multiple of the minimum CU size");
-    xConfirmPara((m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1))) != 0,
-                 "Resulting coded frame height must be a multiple of the minimum CU size");
-
-    xConfirmPara(m_uiQuadtreeTULog2MinSize < 2,
-                 "QuadtreeTULog2MinSize must be 2 or greater.");
-    xConfirmPara(m_uiQuadtreeTULog2MaxSize > 5,
-                 "QuadtreeTULog2MaxSize must be 5 or smaller.");
-    xConfirmPara((1 << m_uiQuadtreeTULog2MaxSize) > m_uiMaxCUWidth,
-                 "QuadtreeTULog2MaxSize must be log2(maxCUSize) or smaller.");
-
-    xConfirmPara(m_uiQuadtreeTULog2MaxSize < m_uiQuadtreeTULog2MinSize,
-                 "QuadtreeTULog2MaxSize must be greater than or equal to m_uiQuadtreeTULog2MinSize.");
-    xConfirmPara((1 << m_uiQuadtreeTULog2MinSize) > (m_uiMaxCUWidth >> (m_uiMaxCUDepth - 1)),
-                 "QuadtreeTULog2MinSize must not be greater than minimum CU size");                                                                            // HS
-    xConfirmPara((1 << m_uiQuadtreeTULog2MinSize) > (m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1)),
-                 "QuadtreeTULog2MinSize must not be greater than minimum CU size");                                                                             // HS
-    xConfirmPara((1 << m_uiQuadtreeTULog2MinSize) > (m_uiMaxCUWidth  >> m_uiMaxCUDepth),
-                 "Minimum CU width must be greater than minimum transform size.");
-    xConfirmPara((1 << m_uiQuadtreeTULog2MinSize) > (m_uiMaxCUHeight >> m_uiMaxCUDepth),
-                 "Minimum CU height must be greater than minimum transform size.");
-    xConfirmPara(m_uiQuadtreeTUMaxDepthInter < 1,
-                 "QuadtreeTUMaxDepthInter must be greater than or equal to 1");
-    xConfirmPara(
-        m_uiMaxCUWidth < (1 << (m_uiQuadtreeTULog2MinSize + m_uiQuadtreeTUMaxDepthInter - 1)),
-        "QuadtreeTUMaxDepthInter must be less than or equal to the difference between log2(maxCUSize) and QuadtreeTULog2MinSize plus 1");
-    xConfirmPara(m_uiQuadtreeTUMaxDepthIntra < 1,
-                 "QuadtreeTUMaxDepthIntra must be greater than or equal to 1");
-    xConfirmPara(
-        m_uiMaxCUWidth < (1 << (m_uiQuadtreeTULog2MinSize + m_uiQuadtreeTUMaxDepthIntra - 1)),
-        "QuadtreeTUMaxDepthInter must be less than or equal to the difference between log2(maxCUSize) and QuadtreeTULog2MinSize plus 1");
-
-    xConfirmPara(m_maxNumMergeCand < 1,  "MaxNumMergeCand must be 1 or greater.");
-    xConfirmPara(m_maxNumMergeCand > 5,  "MaxNumMergeCand must be 5 or smaller.");
-
-#if ADAPTIVE_QP_SELECTION
-    xConfirmPara(m_bUseAdaptQpSelect == true && m_iQP < 0,
-                 "AdaptiveQpSelection must be disabled when QP < 0.");
-    xConfirmPara(m_bUseAdaptQpSelect == true && (m_cbQpOffset != 0 || m_crQpOffset != 0),
-                 "AdaptiveQpSelection must be disabled when ChromaQpOffset is not equal to 0.");
-#endif
-
-    if (m_usePCM)
-    {
-        xConfirmPara(m_uiPCMLog2MinSize < 3,                                      "PCMLog2MinSize must be 3 or greater.");
-        xConfirmPara(m_uiPCMLog2MinSize > 5,                                      "PCMLog2MinSize must be 5 or smaller.");
-        xConfirmPara(m_pcmLog2MaxSize > 5,                                        "PCMLog2MaxSize must be 5 or smaller.");
-        xConfirmPara(m_pcmLog2MaxSize < m_uiPCMLog2MinSize,
-                     "PCMLog2MaxSize must be equal to or greater than m_uiPCMLog2MinSize.");
-    }
-
-    xConfirmPara(m_sliceMode < 0 || m_sliceMode > 3, "SliceMode exceeds supported range (0 to 3)");
-    if (m_sliceMode != 0)
-    {
-        xConfirmPara(m_sliceArgument < 1,         "SliceArgument should be larger than or equal to 1");
-    }
-
-    xConfirmPara(m_sliceSegmentMode < 0 || m_sliceSegmentMode > 3, "SliceSegmentMode exceeds supported range (0 to 3)");
-    if (m_sliceSegmentMode != 0)
-    {
-        xConfirmPara(m_sliceSegmentArgument < 1,         "SliceSegmentArgument should be larger than or equal to 1");
-    }
-
-    Bool tileFlag = (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0);
-    xConfirmPara(tileFlag && m_iWaveFrontSynchro,            "Tile and Wavefront can not be applied together");
-
-    //TODO:ChromaFmt assumes 4:2:0 below
-    xConfirmPara(m_iSourceWidth  % TComSPS::getWinUnitX(
-                     CHROMA_420) != 0, "Picture width must be an integer multiple of the specified chroma subsampling");
-    xConfirmPara(m_iSourceHeight % TComSPS::getWinUnitY(
-                     CHROMA_420) != 0, "Picture height must be an integer multiple of the specified chroma subsampling");
-
-    xConfirmPara(m_aiPad[0] % TComSPS::getWinUnitX(
-                     CHROMA_420) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling");
-    xConfirmPara(m_aiPad[1] % TComSPS::getWinUnitY(
-                     CHROMA_420) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling");
-
-    xConfirmPara(m_confLeft   % TComSPS::getWinUnitX(
-                     CHROMA_420) != 0,
-                 "Left conformance window offset must be an integer multiple of the specified chroma subsampling");
-    xConfirmPara(m_confRight  % TComSPS::getWinUnitX(
-                     CHROMA_420) != 0,
-                 "Right conformance window offset must be an integer multiple of the specified chroma subsampling");
-    xConfirmPara(m_confTop    % TComSPS::getWinUnitY(
-                     CHROMA_420) != 0,
-                 "Top conformance window offset must be an integer multiple of the specified chroma subsampling");
-    xConfirmPara(m_confBottom % TComSPS::getWinUnitY(
-                     CHROMA_420) != 0,
-                 "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling");
-
-    // max CU width and height should be power of 2
-    UInt ui = m_uiMaxCUWidth;
-    while (ui)
-    {
-        ui >>= 1;
-        if ((ui & 1) == 1)
-            xConfirmPara(ui != 1, "Width should be 2^n");
-    }
-
-    ui = m_uiMaxCUHeight;
-    while (ui)
-    {
-        ui >>= 1;
-        if ((ui & 1) == 1)
-            xConfirmPara(ui != 1, "Height should be 2^n");
-    }
-
-    /* if this is an intra-only sequence, ie IntraPeriod=1, don't verify the GOP structure
-     * This permits the ability to omit a GOP structure specification */
-    if (m_iIntraPeriod == 1 && m_GOPList[0].m_POC == -1)
-    {
-        m_GOPList[0] = GOPEntry();
-        m_GOPList[0].m_QPFactor = 1;
-        m_GOPList[0].m_betaOffsetDiv2 = 0;
-        m_GOPList[0].m_tcOffsetDiv2 = 0;
-        m_GOPList[0].m_POC = 1;
-        m_GOPList[0].m_numRefPicsActive = 4;
-    }
-
-    Bool verifiedGOP = false;
-    Bool errorGOP = false;
-    Int checkGOP = 1;
-    Int numRefs = 1;
-    Int refList[MAX_NUM_REF_PICS + 1];
-    refList[0] = 0;
-    Bool isOK[MAX_GOP];
-    for (Int i = 0; i < MAX_GOP; i++)
-    {
-        isOK[i] = false;
-    }
-
-    Int numOK = 0;
-    xConfirmPara(m_iIntraPeriod >= 0 && (m_iIntraPeriod % m_iGOPSize != 0), "Intra period must be a multiple of GOPSize, or -1");
-
-    for (Int i = 0; i < m_iGOPSize; i++)
-    {
-        if (m_GOPList[i].m_POC == m_iGOPSize)
-        {
-            xConfirmPara(m_GOPList[i].m_temporalId != 0, "The last frame in each GOP must have temporal ID = 0 ");
-        }
-    }
-
-    if ((m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && m_DeblockingFilterControlPresent && (!m_bLoopFilterDisable))
-    {
-        for (Int i = 0; i < m_iGOPSize; i++)
-        {
-            xConfirmPara((m_GOPList[i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) < -6 ||
-                         (m_GOPList[i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) > 6,
-                         "Loop Filter Beta Offset div. 2 for one of the GOP entries exceeds supported range (-6 to 6)");
-            xConfirmPara((m_GOPList[i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) < -6 ||
-                         (m_GOPList[i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) > 6,
-                         "Loop Filter Tc Offset div. 2 for one of the GOP entries exceeds supported range (-6 to 6)");
-        }
-    }
-
-    m_extraRPSs = 0;
-    //start looping through frames in coding order until we can verify that the GOP structure is correct.
-    while (!verifiedGOP && !errorGOP)
-    {
-        Int curGOP = (checkGOP - 1) % m_iGOPSize;
-        Int curPOC = ((checkGOP - 1) / m_iGOPSize) * m_iGOPSize + m_GOPList[curGOP].m_POC;
-        if (m_GOPList[curGOP].m_POC < 0)
-        {
-            printf("\nError: found fewer Reference Picture Sets than GOPSize\n");
-            errorGOP = true;
-        }
-        else
-        {
-            //check that all reference pictures are available, or have a POC < 0 meaning they might be available in the next GOP.
-            Bool beforeI = false;
-            for (Int i = 0; i < m_GOPList[curGOP].m_numRefPics; i++)
-            {
-                Int absPOC = curPOC + m_GOPList[curGOP].m_referencePics[i];
-                if (absPOC < 0)
-                {
-                    beforeI = true;
-                }
-                else
-                {
-                    Bool found = false;
-                    for (Int j = 0; j < numRefs; j++)
-                    {
-                        if (refList[j] == absPOC)
-                        {
-                            found = true;
-                            for (Int k = 0; k < m_iGOPSize; k++)
-                            {
-                                if (absPOC % m_iGOPSize == m_GOPList[k].m_POC % m_iGOPSize)
-                                {
-                                    if (m_GOPList[k].m_temporalId == m_GOPList[curGOP].m_temporalId)
-                                    {
-                                        m_GOPList[k].m_refPic = true;
-                                    }
-
-                                    m_GOPList[curGOP].m_usedByCurrPic[i] = m_GOPList[k].m_temporalId <=
-                                        m_GOPList[curGOP].m_temporalId;
-                                }
-                            }
-                        }
-                    }
-
-                    if (!found)
-                    {
-                        printf("\nError: ref pic %d is not available for GOP frame %d\n",
-                               m_GOPList[curGOP].m_referencePics[i],
-                               curGOP + 1);
-                        errorGOP = true;
-                    }
-                }
-            }
-
-            if (!beforeI && !errorGOP)
-            {
-                //all ref frames were present
-                if (!isOK[curGOP])
-                {
-                    numOK++;
-                    isOK[curGOP] = true;
-                    if (numOK == m_iGOPSize)
-                    {
-                        verifiedGOP = true;
-                    }
-                }
-            }
-            else
-            {
-                //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0)
-                m_GOPList[m_iGOPSize + m_extraRPSs] = m_GOPList[curGOP];
-                Int newRefs = 0;
-                for (Int i = 0; i < m_GOPList[curGOP].m_numRefPics; i++)
-                {
-                    Int absPOC = curPOC + m_GOPList[curGOP].m_referencePics[i];
-                    if (absPOC >= 0)
-                    {
-                        m_GOPList[m_iGOPSize + m_extraRPSs].m_referencePics[newRefs] = m_GOPList[curGOP].m_referencePics[i];
-                        m_GOPList[m_iGOPSize + m_extraRPSs].m_usedByCurrPic[newRefs] = m_GOPList[curGOP].m_usedByCurrPic[i];
-                        newRefs++;
-                    }
-                }
-
-                Int numPrefRefs = m_GOPList[curGOP].m_numRefPicsActive;
-
-                for (Int offset = -1; offset > -checkGOP; offset--)
-                {
-                    //step backwards in coding order and include any extra available pictures we might find useful to replace the ones with POC < 0.
-                    Int offGOP = (checkGOP - 1 + offset) % m_iGOPSize;
-                    Int offPOC = ((checkGOP - 1 + offset) / m_iGOPSize) * m_iGOPSize + m_GOPList[offGOP].m_POC;
-                    if (offPOC >= 0 && m_GOPList[offGOP].m_temporalId <= m_GOPList[curGOP].m_temporalId)
-                    {
-                        Bool newRef = false;
-                        for (Int i = 0; i < numRefs; i++)
-                        {
-                            if (refList[i] == offPOC)
-                            {
-                                newRef = true;
-                            }
-                        }
-
-                        for (Int i = 0; i < newRefs; i++)
-                        {
-                            if (m_GOPList[m_iGOPSize + m_extraRPSs].m_referencePics[i] == offPOC - curPOC)
-                            {
-                                newRef = false;
-                            }
-                        }
-
-                        if (newRef)
-                        {
-                            Int insertPoint = newRefs;
-                            //this picture can be added, find appropriate place in list and insert it.
-                            if (m_GOPList[offGOP].m_temporalId == m_GOPList[curGOP].m_temporalId)
-                            {
-                                m_GOPList[offGOP].m_refPic = true;
-                            }
-
-                            for (Int j = 0; j < newRefs; j++)
-                            {
-                                if (m_GOPList[m_iGOPSize + m_extraRPSs].m_referencePics[j] < offPOC - curPOC ||
-                                    m_GOPList[m_iGOPSize + m_extraRPSs].m_referencePics[j] > 0)
-                                {
-                                    insertPoint = j;
-                                    break;
-                                }
-                            }
-
-                            Int prev = offPOC - curPOC;
-                            Int prevUsed = m_GOPList[offGOP].m_temporalId <= m_GOPList[curGOP].m_temporalId;
-                            for (Int j = insertPoint; j < newRefs + 1; j++)
-                            {
-                                Int newPrev = m_GOPList[m_iGOPSize + m_extraRPSs].m_referencePics[j];
-                                Int newUsed = m_GOPList[m_iGOPSize + m_extraRPSs].m_usedByCurrPic[j];
-                                m_GOPList[m_iGOPSize + m_extraRPSs].m_referencePics[j] = prev;
-                                m_GOPList[m_iGOPSize + m_extraRPSs].m_usedByCurrPic[j] = prevUsed;
-                                prevUsed = newUsed;
-                                prev = newPrev;
-                            }
-
-                            newRefs++;
-                        }
-                    }
-
-                    if (newRefs >= numPrefRefs)
-                    {
-                        break;
-                    }
-                }
-
-                m_GOPList[m_iGOPSize + m_extraRPSs].m_numRefPics = newRefs;
-                m_GOPList[m_iGOPSize + m_extraRPSs].m_POC = curPOC;
-                if (m_extraRPSs == 0)
-                {
-                    m_GOPList[m_iGOPSize + m_extraRPSs].m_interRPSPrediction = 0;
-                    m_GOPList[m_iGOPSize + m_extraRPSs].m_numRefIdc = 0;
-                }
-                else
-                {
-                    Int rIdx =  m_iGOPSize + m_extraRPSs - 1;
-                    Int refPOC = m_GOPList[rIdx].m_POC;
-                    Int refPics = m_GOPList[rIdx].m_numRefPics;
-                    Int newIdc = 0;
-                    for (Int i = 0; i <= refPics; i++)
-                    {
-                        Int deltaPOC = ((i != refPics) ? m_GOPList[rIdx].m_referencePics[i] : 0); // check if the reference abs POC is >= 0
-                        Int absPOCref = refPOC + deltaPOC;
-                        Int refIdc = 0;
-                        for (Int j = 0; j < m_GOPList[m_iGOPSize + m_extraRPSs].m_numRefPics; j++)
-                        {
-                            if ((absPOCref - curPOC) == m_GOPList[m_iGOPSize + m_extraRPSs].m_referencePics[j])
-                            {
-                                if (m_GOPList[m_iGOPSize + m_extraRPSs].m_usedByCurrPic[j])
-                                {
-                                    refIdc = 1;
-                                }
-                                else
-                                {
-                                    refIdc = 2;
-                                }
-                            }
-                        }
-
-                        m_GOPList[m_iGOPSize + m_extraRPSs].m_refIdc[newIdc] = refIdc;
-                        newIdc++;
-                    }
-
-                    m_GOPList[m_iGOPSize + m_extraRPSs].m_interRPSPrediction = 1;
-                    m_GOPList[m_iGOPSize + m_extraRPSs].m_numRefIdc = newIdc;
-                    m_GOPList[m_iGOPSize + m_extraRPSs].m_deltaRPS = refPOC - m_GOPList[m_iGOPSize + m_extraRPSs].m_POC;
-                }
-
-                curGOP = m_iGOPSize + m_extraRPSs;
-                m_extraRPSs++;
-            }
-
-            numRefs = 0;
-            for (Int i = 0; i < m_GOPList[curGOP].m_numRefPics; i++)
-            {
-                Int absPOC = curPOC + m_GOPList[curGOP].m_referencePics[i];
-                if (absPOC >= 0)
-                {
-                    refList[numRefs] = absPOC;
-                    numRefs++;
-                }
-            }
-
-            refList[numRefs] = curPOC;
-            numRefs++;
-        }
-
-        checkGOP++;
-    }
-
-    xConfirmPara(errorGOP, "Invalid GOP structure given");
-    m_maxTempLayer = 1;
-    for (Int i = 0; i < m_iGOPSize; i++)
-    {
-        if (m_GOPList[i].m_temporalId >= m_maxTempLayer)
-        {
-            m_maxTempLayer = m_GOPList[i].m_temporalId + 1;
-        }
-
-        xConfirmPara(m_GOPList[i].m_sliceType != 'B' && m_GOPList[i].m_sliceType != 'P', "Slice type must be equal to B or P");
-    }
-
-    for (Int i = 0; i < MAX_TLAYER; i++)
-    {
-        m_numReorderPics[i] = 0;
-        m_maxDecPicBuffering[i] = 0;
-    }
-
-    for (Int i = 0; i < m_iGOPSize; i++)
-    {
-        if (m_GOPList[i].m_numRefPics > m_maxDecPicBuffering[m_GOPList[i].m_temporalId])
-        {
-            m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics;
-        }
-
-        Int highestDecodingNumberWithLowerPOC = 0;
-        for (Int j = 0; j < m_iGOPSize; j++)
-        {
-            if (m_GOPList[j].m_POC <= m_GOPList[i].m_POC)
-            {
-                highestDecodingNumberWithLowerPOC = j;
-            }
-        }
-
-        Int numReorder = 0;
-        for (Int j = 0; j < highestDecodingNumberWithLowerPOC; j++)
-        {
-            if (m_GOPList[j].m_temporalId <= m_GOPList[i].m_temporalId &&
-                m_GOPList[j].m_POC > m_GOPList[i].m_POC)
-            {
-                numReorder++;
-            }
-        }
-
-        if (numReorder > m_numReorderPics[m_GOPList[i].m_temporalId])
-        {
-            m_numReorderPics[m_GOPList[i].m_temporalId] = numReorder;
-        }
-    }
-
-    for (Int i = 0; i < MAX_TLAYER - 1; i++)
-    {
-        // a lower layer can not have higher value of m_numReorderPics than a higher layer
-        if (m_numReorderPics[i + 1] < m_numReorderPics[i])
-        {
-            m_numReorderPics[i + 1] = m_numReorderPics[i];
-        }
-
-        // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
-        if (m_numReorderPics[i] > m_maxDecPicBuffering[i])
-        {
-            m_maxDecPicBuffering[i] = m_numReorderPics[i];
-        }
-
-        // a lower layer can not have higher value of m_uiMaxDecPicBuffering than a higher layer
-        if (m_maxDecPicBuffering[i + 1] < m_maxDecPicBuffering[i])
-        {
-            m_maxDecPicBuffering[i + 1] = m_maxDecPicBuffering[i];
-        }
-    }
-
-    // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
-    if (m_numReorderPics[MAX_TLAYER - 1] > m_maxDecPicBuffering[MAX_TLAYER - 1])
-    {
-        m_maxDecPicBuffering[MAX_TLAYER - 1] = m_numReorderPics[MAX_TLAYER - 1];
-    }
-
-    if (m_vuiParametersPresentFlag && m_bitstreamRestrictionFlag)
-    {
-        Int PicSizeInSamplesY =  m_iSourceWidth * m_iSourceHeight;
-        if (tileFlag)
-        {
-            Int maxTileWidth = 0;
-            Int maxTileHeight = 0;
-            Int widthInCU =
-                (m_iSourceWidth % m_uiMaxCUWidth) ? m_iSourceWidth / m_uiMaxCUWidth + 1 : m_iSourceWidth / m_uiMaxCUWidth;
-            Int heightInCU =
-                (m_iSourceHeight % m_uiMaxCUHeight) ? m_iSourceHeight / m_uiMaxCUHeight + 1 : m_iSourceHeight / m_uiMaxCUHeight;
-            if (m_iUniformSpacingIdr)
-            {
-                maxTileWidth = m_uiMaxCUWidth * ((widthInCU + m_iNumColumnsMinus1) / (m_iNumColumnsMinus1 + 1));
-                maxTileHeight = m_uiMaxCUHeight * ((heightInCU + m_iNumRowsMinus1) / (m_iNumRowsMinus1 + 1));
-                // if only the last tile-row is one treeblock higher than the others
-                // the maxTileHeight becomes smaller if the last row of treeblocks has lower height than the others
-                if (!((heightInCU - 1) % (m_iNumRowsMinus1 + 1)))
-                {
-                    maxTileHeight = maxTileHeight - m_uiMaxCUHeight + (m_iSourceHeight % m_uiMaxCUHeight);
-                }
-
-                // if only the last tile-column is one treeblock wider than the others
-                // the maxTileWidth becomes smaller if the last column of treeblocks has lower width than the others
-                if (!((widthInCU - 1) % (m_iNumColumnsMinus1 + 1)))
-                {
-                    maxTileWidth = maxTileWidth - m_uiMaxCUWidth + (m_iSourceWidth % m_uiMaxCUWidth);
-                }
-            }
-            else // not uniform spacing
-            {
-                if (m_iNumColumnsMinus1 < 1)
-                {
-                    maxTileWidth = m_iSourceWidth;
-                }
-                else
-                {
-                    Int accColumnWidth = 0;
-                    for (Int col = 0; col < (m_iNumColumnsMinus1); col++)
-                    {
-                        maxTileWidth = m_pColumnWidth[col] > maxTileWidth ? m_pColumnWidth[col] : maxTileWidth;
-                        accColumnWidth += m_pColumnWidth[col];
-                    }
-
-                    maxTileWidth =
-                        (widthInCU -
-                         accColumnWidth) > maxTileWidth ? m_uiMaxCUWidth *
-                        (widthInCU - accColumnWidth) : m_uiMaxCUWidth * maxTileWidth;
-                }
-
-                if (m_iNumRowsMinus1 < 1)
-                {
-                    maxTileHeight = m_iSourceHeight;
-                }
-                else
-                {
-                    Int accRowHeight = 0;
-                    for (Int row = 0; row < (m_iNumRowsMinus1); row++)
-                    {
-                        maxTileHeight = m_pRowHeight[row] > maxTileHeight ? m_pRowHeight[row] : maxTileHeight;
-                        accRowHeight += m_pRowHeight[row];
-                    }
-
-                    maxTileHeight =
-                        (heightInCU -
-                         accRowHeight) > maxTileHeight ? m_uiMaxCUHeight *
-                        (heightInCU - accRowHeight) : m_uiMaxCUHeight * maxTileHeight;
-                }
-            }
-
-            Int maxSizeInSamplesY = maxTileWidth * maxTileHeight;
-            m_minSpatialSegmentationIdc = 4 * PicSizeInSamplesY / maxSizeInSamplesY - 4;
-        }
-        else if (m_iWaveFrontSynchro)
-        {
-            m_minSpatialSegmentationIdc = 4 * PicSizeInSamplesY / ((2 * m_iSourceHeight + m_iSourceWidth) * m_uiMaxCUHeight) - 4;
-        }
-        else if (m_sliceMode == 1)
-        {
-            m_minSpatialSegmentationIdc = 4 * PicSizeInSamplesY / (m_sliceArgument * m_uiMaxCUWidth * m_uiMaxCUHeight) - 4;
-        }
-        else
-        {
-            m_minSpatialSegmentationIdc = 0;
-        }
-    }
-
-    xConfirmPara(m_bUseLComb == false && m_numReorderPics[MAX_TLAYER - 1] != 0,
-                 "ListCombination can only be 0 in low delay coding (more precisely when L0 and L1 are identical)");                                                                // Note however this is not the full necessary condition as ref_pic_list_combination_flag can only be 0 if L0 == L1.
-    xConfirmPara(m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative");
-    xConfirmPara(m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive");
-    xConfirmPara(m_iWaveFrontSubstreams > 1 && !m_iWaveFrontSynchro,
-                 "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1");
-
-    xConfirmPara(m_decodedPictureHashSEIEnabled < 0 || m_decodedPictureHashSEIEnabled > 3, "this hash type is not correct!\n");
-
-#if J0149_TONE_MAPPING_SEI
-    if (m_toneMappingInfoSEIEnabled)
-    {
-        xConfirmPara(m_toneMapCodedDataBitDepth < 8 || m_toneMapCodedDataBitDepth > 14,
-                     "SEIToneMapCodedDataBitDepth must be in rage 8 to 14");
-        xConfirmPara(m_toneMapTargetBitDepth < 1 || (m_toneMapTargetBitDepth > 16 && m_toneMapTargetBitDepth < 255),
-                     "SEIToneMapTargetBitDepth must be in rage 1 to 16 or equal to 255");
-        xConfirmPara(m_toneMapModelId < 0 || m_toneMapModelId > 4, "SEIToneMapModelId must be in rage 0 to 4");
-        xConfirmPara(m_cameraIsoSpeedValue == 0, "SEIToneMapCameraIsoSpeedValue shall not be equal to 0");
-        xConfirmPara(m_extendedRangeWhiteLevel < 100, "SEIToneMapExtendedRangeWhiteLevel should be greater than or equal to 100");
-        xConfirmPara(m_nominalBlackLevelLumaCodeValue >= m_nominalWhiteLevelLumaCodeValue,
-                     "SEIToneMapNominalWhiteLevelLumaCodeValue shall be greater than SEIToneMapNominalBlackLevelLumaCodeValue");
-        xConfirmPara(
-            m_extendedWhiteLevelLumaCodeValue < m_nominalWhiteLevelLumaCodeValue,
-            "SEIToneMapExtendedWhiteLevelLumaCodeValue shall be greater than or equal to SEIToneMapNominalWhiteLevelLumaCodeValue");
-    }
-
-#endif // if J0149_TONE_MAPPING_SEI
-
-#if RATE_CONTROL_LAMBDA_DOMAIN
-    if (m_RCEnableRateControl)
-    {
-        if (m_RCForceIntraQP)
-        {
-            if (m_RCInitialQP == 0)
-            {
-                printf("\nInitial QP for rate control is not specified. Reset not to use force intra QP!");
-                m_RCForceIntraQP = false;
-            }
-        }
-
-        xConfirmPara(m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n");
-    }
-
-#else // if RATE_CONTROL_LAMBDA_DOMAIN
-    if (m_enableRateCtrl)
-    {
-        Int numLCUInWidth  = (m_iSourceWidth  / m_uiMaxCUWidth) + ((m_iSourceWidth  %  m_uiMaxCUWidth) ? 1 : 0);
-        Int numLCUInHeight = (m_iSourceHeight / m_uiMaxCUHeight) + ((m_iSourceHeight %  m_uiMaxCUHeight) ? 1 : 0);
-        Int numLCUInPic    =  numLCUInWidth * numLCUInHeight;
-
-        xConfirmPara((numLCUInPic % m_numLCUInUnit) != 0,
-                     "total number of LCUs in a frame should be completely divided by NumLCUInUnit");
-
-        m_iMaxDeltaQP       = MAX_DELTA_QP;
-        m_iMaxCuDQPDepth    = MAX_CUDQP_DEPTH;
-    }
-
-#endif // if RATE_CONTROL_LAMBDA_DOMAIN
-
-    xConfirmPara(!m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagValue,
-                 "CUTransquantBypassFlagValue cannot be 1 when TransquantBypassEnableFlag is 0");
-
-    xConfirmPara(m_log2ParallelMergeLevel < 2, "Log2ParallelMergeLevel should be larger than or equal to 2");
-#if L0444_FPA_TYPE
-    if (m_framePackingSEIEnabled)
-    {
-        xConfirmPara(m_framePackingSEIType < 3 || m_framePackingSEIType > 5, "SEIFramePackingType must be in rage 3 to 5");
-    }
-
-#endif
-
-#undef xConfirmPara
-    if (check_failed)
-    {
-        exit(EXIT_FAILURE);
-    }
-}
-
-/** \todo use of global variables should be removed later
- */
-Void TAppEncCfg::xSetGlobal()
-{
-    // set max CU width & height
-    g_uiMaxCUWidth  = m_uiMaxCUWidth;
-    g_uiMaxCUHeight = m_uiMaxCUHeight;
-
-    // compute actual CU depth with respect to config depth and max transform size
-    g_uiAddCUDepth  = 0;
-    while ((m_uiMaxCUWidth >> m_uiMaxCUDepth) > (1 << (m_uiQuadtreeTULog2MinSize + g_uiAddCUDepth)))
-    {
-        g_uiAddCUDepth++;
-    }
-
-    m_uiMaxCUDepth += g_uiAddCUDepth;
-    g_uiAddCUDepth++;
-    g_uiMaxCUDepth = m_uiMaxCUDepth;
-
-    // set internal bit-depth and constants
-    g_bitDepthY = m_internalBitDepthY;
-    g_bitDepthC = m_internalBitDepthC;
-
-    g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_inputBitDepthY : m_internalBitDepthY;
-    g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_inputBitDepthC : m_internalBitDepthC;
-}
-
-Void TAppEncCfg::xPrintParameter()
-{
-    printf("\n");
-    printf("Input          File          : %s\n", m_pchInputFile);
-    printf("Bitstream      File          : %s\n", m_pchBitstreamFile);
-    printf("Reconstruction File          : %s\n", m_pchReconFile);
-    printf("Real     Format              : %dx%d %dHz\n",
-           m_iSourceWidth - m_confLeft - m_confRight,
-           m_iSourceHeight - m_confTop - m_confBottom,
-           m_iFrameRate);
-    printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate);
-    printf("Frame index                  : %u - %d (%d frames)\n",
-           m_FrameSkip,
-           m_FrameSkip + m_framesToBeEncoded - 1,
-           m_framesToBeEncoded);
-    printf("CU size / depth              : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth);
-    printf("RQT trans. size (min / max)  : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize);
-    printf("Max RQT depth inter          : %d\n", m_uiQuadtreeTUMaxDepthInter);
-    printf("Max RQT depth intra          : %d\n", m_uiQuadtreeTUMaxDepthIntra);
-    printf("Min PCM size                 : %d\n", 1 << m_uiPCMLog2MinSize);
-    printf("Motion search range          : %d\n", m_iSearchRange);
-    printf("Intra period                 : %d\n", m_iIntraPeriod);
-    printf("Decoding refresh type        : %d\n", m_iDecodingRefreshType);
-    printf("QP                           : %5.2f\n", m_fQP);
-    printf("Max dQP signaling depth      : %d\n", m_iMaxCuDQPDepth);
-
-    printf("Cb QP Offset                 : %d\n", m_cbQpOffset);
-    printf("Cr QP Offset                 : %d\n", m_crQpOffset);
-
-    printf("QP adaptation                : %d (range=%d)\n", m_bUseAdaptiveQP, (m_bUseAdaptiveQP ? m_iQPAdaptationRange : 0));
-    printf("GOP size                     : %d\n", m_iGOPSize);
-    printf("Internal bit depth           : (Y:%d, C:%d)\n", m_internalBitDepthY, m_internalBitDepthC);
-    printf("PCM sample bit depth         : (Y:%d, C:%d)\n", g_uiPCMBitDepthLuma, g_uiPCMBitDepthChroma);
-#if RATE_CONTROL_LAMBDA_DOMAIN
-    printf("RateControl                  : %d\n", m_RCEnableRateControl);
-    if (m_RCEnableRateControl)
-    {
-        printf("TargetBitrate                : %d\n", m_RCTargetBitrate);
-        printf("KeepHierarchicalBit          : %d\n", m_RCKeepHierarchicalBit);
-        printf("LCULevelRC                   : %d\n", m_RCLCULevelRC);
-        printf("UseLCUSeparateModel          : %d\n", m_RCUseLCUSeparateModel);
-        printf("InitialQP                    : %d\n", m_RCInitialQP);
-        printf("ForceIntraQP                 : %d\n", m_RCForceIntraQP);
-    }
-
-#else // if RATE_CONTROL_LAMBDA_DOMAIN
-    printf("RateControl                  : %d\n", m_enableRateCtrl);
-    if (m_enableRateCtrl)
-    {
-        printf("TargetBitrate                : %d\n", m_targetBitrate);
-        printf("NumLCUInUnit                 : %d\n", m_numLCUInUnit);
-    }
-
-#endif // if RATE_CONTROL_LAMBDA_DOMAIN
-    printf("Max Num Merge Candidates     : %d\n", m_maxNumMergeCand);
-    printf("\n");
-
-    printf("TOOL CFG: ");
-    printf("IBD:%d ", g_bitDepthY > m_inputBitDepthY || g_bitDepthC > m_inputBitDepthC);
-    printf("HAD:%d ", m_bUseHADME);
-    printf("SRD:%d ", m_bUseSBACRD);
-    printf("RDQ:%d ", m_useRDOQ);
-    printf("RDQTS:%d ", m_useRDOQTS);
-#if L0232_RD_PENALTY
-    printf("RDpenalty:%d ", m_rdPenalty);
-#endif
-    printf("SQP:%d ", m_uiDeltaQpRD);
-    printf("ASR:%d ", m_bUseASR);
-    printf("LComb:%d ", m_bUseLComb);
-    printf("FEN:%d ", m_bUseFastEnc);
-    printf("ECU:%d ", m_bUseEarlyCU);
-    printf("FDM:%d ", m_useFastDecisionForMerge);
-    printf("CFM:%d ", m_bUseCbfFastMode);
-    printf("ESD:%d ", m_useEarlySkipDetection);
-    printf("RQT:%d ", 1);
-    printf("TransformSkip:%d ",     m_useTransformSkip);
-    printf("TransformSkipFast:%d ", m_useTransformSkipFast);
-    printf("Slice: M=%d ", m_sliceMode);
-    if (m_sliceMode != 0)
-    {
-        printf("A=%d ", m_sliceArgument);
-    }
-
-    printf("SliceSegment: M=%d ", m_sliceSegmentMode);
-    if (m_sliceSegmentMode != 0)
-    {
-        printf("A=%d ", m_sliceSegmentArgument);
-    }
-
-    printf("CIP:%d ", m_bUseConstrainedIntraPred);
-    printf("SAO:%d ", (m_bUseSAO) ? (1) : (0));
-    printf("PCM:%d ", (m_usePCM && (1 << m_uiPCMLog2MinSize) <= m_uiMaxCUWidth) ? 1 : 0);
-    printf("SAOLcuBasedOptimization:%d ", (m_saoLcuBasedOptimization) ? (1) : (0));
-
-    printf("LosslessCuEnabled:%d ", (m_useLossless) ? 1 : 0);
-    printf("WPP:%d ", (Int)m_useWeightedPred);
-    printf("WPB:%d ", (Int)m_useWeightedBiPred);
-    printf("PME:%d ", m_log2ParallelMergeLevel);
-    printf(" WaveFrontSynchro:%d WaveFrontSubstreams:%d",
-           m_iWaveFrontSynchro, m_iWaveFrontSubstreams);
-    printf(" ScalingList:%d ", m_useScalingListId);
-    printf("TMVPMode:%d ", m_TMVPModeId);
-#if ADAPTIVE_QP_SELECTION
-    printf("AQpS:%d", m_bUseAdaptQpSelect);
-#endif
-
-    printf(" SignBitHidingFlag:%d ", m_signHideFlag);
-    printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0);
-    printf("\n\n");
-
-    fflush(stdout);
-}
-
-Bool confirmPara(Bool bflag, const Char *message)
-{
-    if (!bflag)
-        return false;
-
-    printf("Error: %s\n", message);
-    return true;
-}
-
-//! \}
--- a/source/Lib/config.h	Wed Apr 17 14:09:10 2013 +0530
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,354 +0,0 @@
-/* The copyright in this software is being made available under the BSD
- * License, included below. This software may be subject to other third party
- * and contributor rights, including patent rights, and no such rights are
- * granted under this license.
- *
- * Copyright (c) 2010-2013, ITU/ISO/IEC
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- *
- *  * Redistributions of source code must retain the above copyright notice,
- *    this list of conditions and the following disclaimer.
- *  * Redistributions in binary form must reproduce the above copyright notice,
- *    this list of conditions and the following disclaimer in the documentation
- *    and/or other materials provided with the distribution.
- *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
- *    be used to endorse or promote products derived from this software without
- *    specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-/** \file     TAppEncCfg.h
-    \brief    Handle encoder configuration parameters (header)
-*/
-
-#ifndef __TAPPENCCFG__
-#define __TAPPENCCFG__
-
-#include "TLibCommon/CommonDef.h"
-
-#include "TLibEncoder/TEncCfg.h"
-#include "TLibVideoIO/TVideoIO.h"
-#include "TLibVideoIO/TVideoIOYuv.h"
-#include "TLibVideoIO/TVideoIOY4m.h"
-#include <sstream>
-//! \ingroup TAppEncoder
-//! \{
-
-// ====================================================================================================================
-// Class definition
-// ====================================================================================================================
-
-/// encoder configuration class
-class TAppEncCfg
-{
-protected:
-
-    // file I/O
-    Char     *m_pchInputFile;                                   ///< source file name
-    Char     *m_pchBitstreamFile;                               ///< output bitstream file
-    Char     *m_pchReconFile;                                   ///< output reconstruction file
-    Double    m_adLambdaModifier[MAX_TLAYER];                 ///< Lambda modifier array for each temporal layer
-    // source specification
-    Int       m_iFrameRate;                                     ///< source frame-rates (Hz)
-    UInt      m_FrameSkip;                                      ///< number of skipped frames from the beginning
-    Int       m_iSourceWidth;                                   ///< source width in pixel
-    Int       m_iSourceHeight;                                  ///< source height in pixel
-    Int       m_conformanceMode;
-    Int       m_confLeft;
-    Int       m_confRight;
-    Int       m_confTop;
-    Int       m_confBottom;
-    Int       m_framesToBeEncoded;                              ///< number of encoded frames
-    Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
-    //Input source file handlers
-    TVideoIO*     m_cTVideoIOInputFile;     ///< input  file
-    TVideoIO*     m_cTVideoIOReconFile;       ///< output reconstruction file
-    hnd_t*      handler_input;
-    hnd_t*      handler_recon;
-    video_info_t  video_info;
-
-    // profile/level
-    Profile::Name m_profile;
-    Level::Tier   m_levelTier;
-    Level::Name   m_level;
-#if L0046_CONSTRAINT_FLAGS
-    Bool m_progressiveSourceFlag;
-    Bool m_interlacedSourceFlag;
-    Bool m_nonPackedConstraintFlag;
-    Bool m_frameOnlyConstraintFlag;
-#endif
-
-    // coding structure
-    Int       m_iIntraPeriod;                                   ///< period of I-slice (random access period)
-    Int       m_iDecodingRefreshType;                           ///< random access type
-    Int       m_iGOPSize;                                       ///< GOP size of hierarchical structure
-    Int       m_extraRPSs;                                      ///< extra RPSs added to handle CRA
-    GOPEntry  m_GOPList[MAX_GOP];                               ///< the coding structure entries from the config file
-    Int       m_numReorderPics[MAX_TLAYER];                     ///< total number of reorder pictures
-    Int       m_maxDecPicBuffering[MAX_TLAYER];                 ///< total number of reference pictures needed for decoding
-    Bool      m_bUseLComb;                                      ///< flag for using combined reference list for uni-prediction in B-slices (JCTVC-D421)
-    Bool      m_useTransformSkip;                               ///< flag for enabling intra transform skipping
-    Bool      m_useTransformSkipFast;                           ///< flag for enabling fast intra transform skipping
-    Bool      m_enableAMP;
-    // coding quality
-    Double    m_fQP;                                            ///< QP value of key-picture (floating point)
-    Int       m_iQP;                                            ///< QP value of key-picture (integer)
-    Char     *m_pchdQPFile;                                     ///< QP offset for each slice (initialized from external file)
-    Int      *m_aidQP;                                          ///< array of slice QP values
-    Int       m_iMaxDeltaQP;                                    ///< max. |delta QP|
-    UInt      m_uiDeltaQpRD;                                    ///< dQP range for multi-pass slice QP optimization
-    Int       m_iMaxCuDQPDepth;                                 ///< Max. depth for a minimum CuDQPSize (0:default)
-
-    Int       m_cbQpOffset;                                     ///< Chroma Cb QP Offset (0:default)
-    Int       m_crQpOffset;                                     ///< Chroma Cr QP Offset (0:default)
-
-#if ADAPTIVE_QP_SELECTION
-    Bool      m_bUseAdaptQpSelect;
-#endif
-
-    Bool      m_bUseAdaptiveQP;                                 ///< Flag for enabling QP adaptation based on a psycho-visual model
-    Int       m_iQPAdaptationRange;                             ///< dQP range by QP adaptation
-
-    Int       m_maxTempLayer;                                  ///< Max temporal layer
-
-    // coding unit (CU) definition
-    UInt      m_uiMaxCUWidth;                                   ///< max. CU width in pixel
-    UInt      m_uiMaxCUHeight;                                  ///< max. CU height in pixel
-    UInt      m_uiMaxCUDepth;                                   ///< max. CU depth
-
-    // transfom unit (TU) definition
-    UInt      m_uiQuadtreeTULog2MaxSize;
-    UInt      m_uiQuadtreeTULog2MinSize;
-
-    UInt      m_uiQuadtreeTUMaxDepthInter;
-    UInt      m_uiQuadtreeTUMaxDepthIntra;
-
-    // coding tools (bit-depth)
-    Int       m_inputBitDepthY;                               ///< bit-depth of input file (luma component)
-    Int       m_inputBitDepthC;                               ///< bit-depth of input file (chroma component)
-    Int       m_outputBitDepthY;                              ///< bit-depth of output file (luma component)
-    Int       m_outputBitDepthC;                              ///< bit-depth of output file (chroma component)
-    Int       m_internalBitDepthY;                            ///< bit-depth codec operates at in luma (input/output files will be converted)
-    Int       m_internalBitDepthC;                            ///< bit-depth codec operates at in chroma (input/output files will be converted)
-
-    // coding tools (PCM bit-depth)
-    Bool      m_bPCMInputBitDepthFlag;                          ///< 0: PCM bit-depth is internal bit-depth. 1: PCM bit-depth is input bit-depth.
-
-    // coding tool (lossless)
-    Bool      m_useLossless;                                    ///< flag for using lossless coding
-    Bool      m_bUseSAO;
-    Int       m_maxNumOffsetsPerPic;                            ///< SAO maximun number of offset per picture
-    Bool      m_saoLcuBoundary;                                 ///< SAO parameter estimation using non-deblocked pixels for LCU bottom and right boundary areas
-    Bool      m_saoLcuBasedOptimization;                        ///< SAO LCU-based optimization
-    // coding tools (loop filter)
-    Bool      m_bLoopFilterDisable;                             ///< flag for using deblocking filter
-    Bool      m_loopFilterOffsetInPPS;                         ///< offset for deblocking filter in 0 = slice header, 1 = PPS
-    Int       m_loopFilterBetaOffsetDiv2;                     ///< beta offset for deblocking filter
-    Int       m_loopFilterTcOffsetDiv2;                       ///< tc offset for deblocking filter
-    Bool      m_DeblockingFilterControlPresent;                 ///< deblocking filter control present flag in PPS
-#if L0386_DB_METRIC
-    Bool      m_DeblockingFilterMetric;                         ///< blockiness metric in encoder
-#endif
-
-    // coding tools (PCM)
-    Bool      m_usePCM;                                         ///< flag for using IPCM
-    UInt      m_pcmLog2MaxSize;                                 ///< log2 of maximum PCM block size
-    UInt      m_uiPCMLog2MinSize;                               ///< log2 of minimum PCM block size
-    Bool      m_bPCMFilterDisableFlag;                          ///< PCM filter disable flag
-
-    // coding tools (encoder-only parameters)
-    Bool      m_bUseSBACRD;                                     ///< flag for using RD optimization based on SBAC
-    Bool      m_bUseASR;                                        ///< flag for using adaptive motion search range
-    Bool      m_bUseHADME;                                      ///< flag for using HAD in sub-pel ME
-    Bool      m_useRDOQ;                                       ///< flag for using RD optimized quantization
-    Bool      m_useRDOQTS;                                     ///< flag for using RD optimized quantization for transform skip
-#if L0232_RD_PENALTY
-    Int      m_rdPenalty;                                      ///< RD-penalty for 32x32 TU for intra in non-intra slices (0: no RD-penalty, 1: RD-penalty, 2: maximum RD-penalty)
-#endif
-    Int       m_iFastSearch;                                    ///< ME mode, 0 = full, 1 = diamond, 2 = PMVFAST
-    Int       m_iSearchRange;                                   ///< ME search range
-    Int       m_bipredSearchRange;                              ///< ME search range for bipred refinement
-    Bool      m_bUseFastEnc;                                    ///< flag for using fast encoder setting
-    Bool      m_bUseEarlyCU;                                    ///< flag for using Early CU setting
-    Bool      m_useFastDecisionForMerge;                        ///< flag for using Fast Decision Merge RD-Cost
-    Bool      m_bUseCbfFastMode;                              ///< flag for using Cbf Fast PU Mode Decision
-    Bool      m_useEarlySkipDetection;                         ///< flag for using Early SKIP Detection
-    Int       m_sliceMode;                                     ///< 0: no slice limits, 1 : max number of CTBs per slice, 2: max number of bytes per slice,
-    ///< 3: max number of tiles per slice
-    Int       m_sliceArgument;                                 ///< argument according to selected slice mode
-    Int       m_sliceSegmentMode;                              ///< 0: no slice segment limits, 1 : max number of CTBs per slice segment, 2: max number of bytes per slice segment,
-    ///< 3: max number of tiles per slice segment
-    Int       m_sliceSegmentArgument;                          ///< argument according to selected slice segment mode
-
-    Bool      m_bLFCrossSliceBoundaryFlag;  ///< 1: filter across slice boundaries 0: do not filter across slice boundaries
-    Bool      m_bLFCrossTileBoundaryFlag;   ///< 1: filter across tile boundaries  0: do not filter across tile boundaries
-    Int       m_iUniformSpacingIdr;
-    Int       m_iNumColumnsMinus1;
-    Char     *m_pchColumnWidth;
-    Int       m_iNumRowsMinus1;
-    Char     *m_pchRowHeight;
-    UInt     *m_pColumnWidth;
-    UInt     *m_pRowHeight;
-    Int       m_iWaveFrontSynchro; //< 0: no WPP. >= 1: WPP is enabled, the "Top right" from which inheritance occurs is this LCU offset in the line above the current.
-    Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
-
-    Bool      m_bUseConstrainedIntraPred;                       ///< flag for using constrained intra prediction
-
-    Int       m_decodedPictureHashSEIEnabled;                    ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
-    Int       m_recoveryPointSEIEnabled;
-    Int       m_bufferingPeriodSEIEnabled;
-    Int       m_pictureTimingSEIEnabled;
-#if J0149_TONE_MAPPING_SEI
-    Bool      m_toneMappingInfoSEIEnabled;
-    Int       m_toneMapId;
-    Bool      m_toneMapCancelFlag;
-    Bool      m_toneMapPersistenceFlag;
-    Int       m_toneMapCodedDataBitDepth;
-    Int       m_toneMapTargetBitDepth;
-    Int       m_toneMapModelId;
-    Int       m_toneMapMinValue;
-    Int       m_toneMapMaxValue;
-    Int       m_sigmoidMidpoint;
-    Int       m_sigmoidWidth;
-    Int       m_numPivots;
-    Int       m_cameraIsoSpeedIdc;
-    Int       m_cameraIsoSpeedValue;
-    Int       m_exposureCompensationValueSignFlag;
-    Int       m_exposureCompensationValueNumerator;
-    Int       m_exposureCompensationValueDenomIdc;
-    Int       m_refScreenLuminanceWhite;
-    Int       m_extendedRangeWhiteLevel;
-    Int       m_nominalBlackLevelLumaCodeValue;
-    Int       m_nominalWhiteLevelLumaCodeValue;
-    Int       m_extendedWhiteLevelLumaCodeValue;
-    Int      *m_startOfCodedInterval;
-    Int      *m_codedPivotValue;
-    Int      *m_targetPivotValue;
-#endif // if J0149_TONE_MAPPING_SEI
-    Int       m_framePackingSEIEnabled;
-    Int       m_framePackingSEIType;
-    Int       m_framePackingSEIId;
-    Int       m_framePackingSEIQuincunx;
-    Int       m_framePackingSEIInterpretation;
-    Int       m_displayOrientationSEIAngle;
-    Int       m_temporalLevel0IndexSEIEnabled;
-    Int       m_gradualDecodingRefreshInfoEnabled;
-    Int       m_decodingUnitInfoSEIEnabled;
-#if L0208_SOP_DESCRIPTION_SEI
-    Int       m_SOPDescriptionSEIEnabled;
-#endif
-#if K0180_SCALABLE_NESTING_SEI
-    Int       m_scalableNestingSEIEnabled;
-#endif
-    // weighted prediction
-    Bool      m_useWeightedPred;                    ///< Use of weighted prediction in P slices
-    Bool      m_useWeightedBiPred;                  ///< Use of bi-directional weighted prediction in B slices
-
-    UInt      m_log2ParallelMergeLevel;                         ///< Parallel merge estimation region
-    UInt      m_maxNumMergeCand;                                ///< Max number of merge candidates
-
-    Int       m_TMVPModeId;
-    Int       m_signHideFlag;
-#if RATE_CONTROL_LAMBDA_DOMAIN
-    Bool      m_RCEnableRateControl;                ///< enable rate control or not
-    Int       m_RCTargetBitrate;                    ///< target bitrate when rate control is enabled
-    Bool      m_RCKeepHierarchicalBit;              ///< whether keeping hierarchical bit allocation structure or not
-    Bool      m_RCLCULevelRC;                       ///< true: LCU level rate control; false: picture level rate control
-    Bool      m_RCUseLCUSeparateModel;              ///< use separate R-lambda model at LCU level
-    Int       m_RCInitialQP;                        ///< inital QP for rate control
-    Bool      m_RCForceIntraQP;                     ///< force all intra picture to use initial QP or not
-#else
-    Bool      m_enableRateCtrl;                                   ///< Flag for using rate control algorithm
-    Int       m_targetBitrate;                                 ///< target bitrate
-    Int       m_numLCUInUnit;                                  ///< Total number of LCUs in a frame should be completely divided by the NumLCUInUnit
-#endif // if RATE_CONTROL_LAMBDA_DOMAIN
-    Int       m_useScalingListId;                               ///< using quantization matrix
-    Char     *m_scalingListFile;                                ///< quantization matrix file name
-
-    Bool      m_TransquantBypassEnableFlag;                     ///< transquant_bypass_enable_flag setting in PPS.
-    Bool      m_CUTransquantBypassFlagValue;                    ///< if transquant_bypass_enable_flag, the fixed value to use for the per-CU cu_transquant_bypass_flag.
-
-    Bool      m_recalculateQPAccordingToLambda;                 ///< recalculate QP value according to the lambda value
-    Bool      m_useStrongIntraSmoothing;                        ///< enable strong intra smoothing for 32x32 blocks where the reference samples are flat
-    Int       m_activeParameterSetsSEIEnabled;
-
-    Bool      m_vuiParametersPresentFlag;                       ///< enable generation of VUI parameters
-    Bool      m_aspectRatioInfoPresentFlag;                     ///< Signals whether aspect_ratio_idc is present
-    Int       m_aspectRatioIdc;                                 ///< aspect_ratio_idc
-    Int       m_sarWidth;                                       ///< horizontal size of the sample aspect ratio
-    Int       m_sarHeight;                                      ///< vertical size of the sample aspect ratio
-    Bool      m_overscanInfoPresentFlag;                        ///< Signals whether overscan_appropriate_flag is present
-    Bool      m_overscanAppropriateFlag;                        ///< Indicates whether conformant decoded pictures are suitable for display using overscan
-    Bool      m_videoSignalTypePresentFlag;                     ///< Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present
-    Int       m_videoFormat;                                    ///< Indicates representation of pictures
-    Bool      m_videoFullRangeFlag;                             ///< Indicates the black level and range of luma and chroma signals
-    Bool      m_colourDescriptionPresentFlag;                   ///< Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present
-    Int       m_colourPrimaries;                                ///< Indicates chromaticity coordinates of the source primaries
-    Int       m_transferCharacteristics;                        ///< Indicates the opto-electronic transfer characteristics of the source
-    Int       m_matrixCoefficients;                             ///< Describes the matrix coefficients used in deriving luma and chroma from RGB primaries
-    Bool      m_chromaLocInfoPresentFlag;                       ///< Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present
-    Int       m_chromaSampleLocTypeTopField;                    ///< Specifies the location of chroma samples for top field
-    Int       m_chromaSampleLocTypeBottomField;                 ///< Specifies the location of chroma samples for bottom field
-    Bool      m_neutralChromaIndicationFlag;                    ///< Indicates that the value of all decoded chroma samples is equal to 1<<(BitDepthCr-1)
-    Bool      m_defaultDisplayWindowFlag;                       ///< Indicates the presence of the default window parameters
-    Int       m_defDispWinLeftOffset;                           ///< Specifies the left offset from the conformance window of the default window
-    Int       m_defDispWinRightOffset;                          ///< Specifies the right offset from the conformance window of the default window
-    Int       m_defDispWinTopOffset;                            ///< Specifies the top offset from the conformance window of the default window
-    Int       m_defDispWinBottomOffset;                         ///< Specifies the bottom offset from the conformance window of the default window
-    Bool      m_frameFieldInfoPresentFlag;                      ///< Indicates that pic_struct values are present in picture timing SEI messages
-    Bool      m_pocProportionalToTimingFlag;                    ///< Indicates that the POC value is proportional to the output time w.r.t. first picture in CVS
-    Int       m_numTicksPocDiffOneMinus1;                       ///< Number of ticks minus 1 that for a POC difference of one
-    Bool      m_bitstreamRestrictionFlag;                       ///< Signals whether bitstream restriction parameters are present
-    Bool      m_tilesFixedStructureFlag;                        ///< Indicates that each active picture parameter set has the same values of the syntax elements related to tiles
-    Bool      m_motionVectorsOverPicBoundariesFlag;             ///< Indicates that no samples outside the picture boundaries are used for inter prediction
-    Int       m_minSpatialSegmentationIdc;                      ///< Indicates the maximum size of the spatial segments in the pictures in the coded video sequence
-    Int       m_maxBytesPerPicDenom;                            ///< Indicates a number of bytes not exceeded by the sum of the sizes of the VCL NAL units associated with any coded picture
-    Int       m_maxBitsPerMinCuDenom;                           ///< Indicates an upper bound for the number of bits of coding_unit() data
-    Int       m_log2MaxMvLengthHorizontal;                      ///< Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units
-    Int       m_log2MaxMvLengthVertical;                        ///< Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units
-
-    // internal member functions
-    Void  xSetGlobal();                                         ///< set global variables
-    Void  xCheckParameter();                                    ///< check validity of configuration values
-    Void  xPrintParameter();                                    ///< print configuration values
-    Void  xPrintUsage();                                        ///< print usage
-#if SIGNAL_BITRATE_PICRATE_IN_VPS
-    Int       m_bitRatePicRateMaxTLayers;                       ///< Indicates max. number of sub-layers for which bit rate is signalled.
-    Bool     *m_bitRateInfoPresentFlag;                         ///< Indicates whether bit rate information is signalled
-    Bool     *m_picRateInfoPresentFlag;                         ///< Indicates whether pic rate information is signalled
-    Int      *m_avgBitRate;                                     ///< Indicates avg. bit rate information for various sub-layers
-    Int      *m_maxBitRate;                                     ///< Indicates max. bit rate information for various sub-layers
-    Int      *m_avgPicRate;                                     ///< Indicates avg. picture rate information for various sub-layers
-    Int      *m_constantPicRateIdc;                                ///< Indicates constant picture rate idc for various sub-layers
-#endif
-#
-
-public:
-
-    TAppEncCfg();
-    virtual ~TAppEncCfg();
-
-public:
-
-    Void  create();                                             ///< create option handling class
-    Void  destroy();                                            ///< destroy option handling class
-    Bool  parseCfg(Int argc, Char * argv[]);                     ///< parse configuration file to fill member variables
-}; // END CLASS DEFINITION TAppEncCfg
-
-//! \}
-
-#endif // __TAPPENCCFG__
--- a/source/Lib/encoder.h	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/Lib/encoder.h	Wed Apr 17 14:11:17 2013 +0530
@@ -44,7 +44,7 @@
 #include "TLibEncoder/TEncTop.h"
 #include "TLibVideoIO/TVideoIOYuv.h"
 #include "TLibCommon/AccessUnit.h"
-#include "config.h"
+#include "x265cfg.h"
 
 //! \ingroup TAppEncoder
 //! \{
--- a/source/encoder/CMakeLists.txt	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/encoder/CMakeLists.txt	Wed Apr 17 14:11:17 2013 +0530
@@ -14,11 +14,11 @@ add_library(x265 ../../COPYING
 if(ENABLE_PRIMITIVES)
     if(ENABLE_PRIMITIVES_VEC)
         add_subdirectory(vec)
-        target_link_libraries(x265 VectorPrimitives)
+        target_link_libraries(x265 PrimitivesVec)
     endif(ENABLE_PRIMITIVES_VEC)
 
     if(ENABLE_PRIMITIVES_ASM)
         add_subdirectory(x86)
-        target_link_libraries(x265 AsmPrimitives)
+        target_link_libraries(x265 PrimitivesASM)
     endif(ENABLE_PRIMITIVES_ASM)
 endif(ENABLE_PRIMITIVES)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source/encoder/butterfly.h	Wed Apr 17 14:11:17 2013 +0530
@@ -0,0 +1,152 @@
+/*****************************************************************************
+ * Copyright (C) 2013 x265 project
+ *
+ * Authors: Praveen Kumar Tiwari <praveen@multicorewareinc.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@multicorewareinc.com.
+ *****************************************************************************/
+
+#ifndef BUTTERFLY_H
+#define BUTTERFLY_H
+
+const short g_aiT4[4][4] =
+{
+    { 64, 64, 64, 64 },
+    { 83, 36, -36, -83 },
+    { 64, -64, -64, 64 },
+    { 36, -83, 83, -36 }
+};
+
+const short g_aiT8[8][8] =
+{
+    { 64, 64, 64, 64, 64, 64, 64, 64 },
+    { 89, 75, 50, 18, -18, -50, -75, -89 },
+    { 83, 36, -36, -83, -83, -36, 36, 83 },
+    { 75, -18, -89, -50, 50, 89, 18, -75 },
+    { 64, -64, -64, 64, 64, -64, -64, 64 },
+    { 50, -89, 18, 75, -75, -18, 89, -50 },
+    { 36, -83, 83, -36, -36, 83, -83, 36 },
+    { 18, -50, 75, -89, 89, -75, 50, -18 }
+};
+
+const short g_aiT16[16][16] =
+{
+    { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64 },
+    { 90, 87, 80, 70, 57, 43, 25,  9, -9, -25, -43, -57, -70, -80, -87, -90 },
+    { 89, 75, 50, 18, -18, -50, -75, -89, -89, -75, -50, -18, 18, 50, 75, 89 },
+    { 87, 57,  9, -43, -80, -90, -70, -25, 25, 70, 90, 80, 43, -9, -57, -87 },
+    { 83, 36, -36, -83, -83, -36, 36, 83, 83, 36, -36, -83, -83, -36, 36, 83 },
+    { 80,  9, -70, -87, -25, 57, 90, 43, -43, -90, -57, 25, 87, 70, -9, -80 },
+    { 75, -18, -89, -50, 50, 89, 18, -75, -75, 18, 89, 50, -50, -89, -18, 75 },
+    { 70, -43, -87,  9, 90, 25, -80, -57, 57, 80, -25, -90, -9, 87, 43, -70 },
+    { 64, -64, -64, 64, 64, -64, -64, 64, 64, -64, -64, 64, 64, -64, -64, 64 },
+    { 57, -80, -25, 90, -9, -87, 43, 70, -70, -43, 87,  9, -90, 25, 80, -57 },
+    { 50, -89, 18, 75, -75, -18, 89, -50, -50, 89, -18, -75, 75, 18, -89, 50 },
+    { 43, -90, 57, 25, -87, 70,  9, -80, 80, -9, -70, 87, -25, -57, 90, -43 },
+    { 36, -83, 83, -36, -36, 83, -83, 36, 36, -83, 83, -36, -36, 83, -83, 36 },
+    { 25, -70, 90, -80, 43,  9, -57, 87, -87, 57, -9, -43, 80, -90, 70, -25 },
+    { 18, -50, 75, -89, 89, -75, 50, -18, -18, 50, -75, 89, -89, 75, -50, 18 },
+    {  9, -25, 43, -57, 70, -80, 87, -90, 90, -87, 80, -70, 57, -43, 25, -9 }
+};
+
+const short g_aiT32[32][32] =
+{
+    { 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
+      64 },
+    { 90, 90, 88, 85, 82, 78, 73, 67, 61, 54, 46, 38, 31, 22, 13,  4, -4, -13, -22, -31, -38, -46, -54, -61, -67, -73, -78, -82,
+      -85, -88, -90, -90 },
+    { 90, 87, 80, 70, 57, 43, 25,  9, -9, -25, -43, -57, -70, -80, -87, -90, -90, -87, -80, -70, -57, -43, -25, -9,  9, 25, 43,
+      57, 70, 80, 87, 90 },
+    { 90, 82, 67, 46, 22, -4, -31, -54, -73, -85, -90, -88, -78, -61, -38, -13, 13, 38, 61, 78, 88, 90, 85, 73, 54, 31,  4, -22,
+      -46, -67, -82, -90 },
+    { 89, 75, 50, 18, -18, -50, -75, -89, -89, -75, -50, -18, 18, 50, 75, 89, 89, 75, 50, 18, -18, -50, -75, -89, -89, -75, -50,
+      -18, 18, 50, 75, 89 },
+    { 88, 67, 31, -13, -54, -82, -90, -78, -46, -4, 38, 73, 90, 85, 61, 22, -22, -61, -85, -90, -73, -38,  4, 46, 78, 90, 82, 54,
+      13, -31, -67, -88 },
+    { 87, 57,  9, -43, -80, -90, -70, -25, 25, 70, 90, 80, 43, -9, -57, -87, -87, -57, -9, 43, 80, 90, 70, 25, -25, -70, -90, -80,
+      -43,  9, 57, 87 },
+    { 85, 46, -13, -67, -90, -73, -22, 38, 82, 88, 54, -4, -61, -90, -78, -31, 31, 78, 90, 61,  4, -54, -88, -82, -38, 22, 73, 90,
+      67, 13, -46, -85 },
+    { 83, 36, -36, -83, -83, -36, 36, 83, 83, 36, -36, -83, -83, -36, 36, 83, 83, 36, -36, -83, -83, -36, 36, 83, 83, 36, -36,
+      -83, -83, -36, 36, 83 },
+    { 82, 22, -54, -90, -61, 13, 78, 85, 31, -46, -90, -67,  4, 73, 88, 38, -38, -88, -73, -4, 67, 90, 46, -31, -85, -78, -13, 61,
+      90, 54, -22, -82 },
+    { 80,  9, -70, -87, -25, 57, 90, 43, -43, -90, -57, 25, 87, 70, -9, -80, -80, -9, 70, 87, 25, -57, -90, -43, 43, 90, 57, -25,
+      -87, -70,  9, 80 },
+    { 78, -4, -82, -73, 13, 85, 67, -22, -88, -61, 31, 90, 54, -38, -90, -46, 46, 90, 38, -54, -90, -31, 61, 88, 22, -67, -85,
+      -13, 73, 82,  4, -78 },
+    { 75, -18, -89, -50, 50, 89, 18, -75, -75, 18, 89, 50, -50, -89, -18, 75, 75, -18, -89, -50, 50, 89, 18, -75, -75, 18, 89, 50,
+      -50, -89, -18, 75 },
+    { 73, -31, -90, -22, 78, 67, -38, -90, -13, 82, 61, -46, -88, -4, 85, 54, -54, -85,  4, 88, 46, -61, -82, 13, 90, 38, -67,
+      -78, 22, 90, 31, -73 },
+    { 70, -43, -87,  9, 90, 25, -80, -57, 57, 80, -25, -90, -9, 87, 43, -70, -70, 43, 87, -9, -90, -25, 80, 57, -57, -80, 25, 90,
+      9, -87, -43, 70 },
+    { 67, -54, -78, 38, 85, -22, -90,  4, 90, 13, -88, -31, 82, 46, -73, -61, 61, 73, -46, -82, 31, 88, -13, -90, -4, 90, 22, -85,
+      -38, 78, 54, -67 },
+    { 64, -64, -64, 64, 64, -64, -64, 64, 64, -64, -64, 64, 64, -64, -64, 64, 64, -64, -64, 64, 64, -64, -64, 64, 64, -64, -64,
+      64, 64, -64, -64, 64 },
+    { 61, -73, -46, 82, 31, -88, -13, 90, -4, -90, 22, 85, -38, -78, 54, 67, -67, -54, 78, 38, -85, -22, 90,  4, -90, 13, 88, -31,
+      -82, 46, 73, -61 },
+    { 57, -80, -25, 90, -9, -87, 43, 70, -70, -43, 87,  9, -90, 25, 80, -57, -57, 80, 25, -90,  9, 87, -43, -70, 70, 43, -87, -9,
+      90, -25, -80, 57 },
+    { 54, -85, -4, 88, -46, -61, 82, 13, -90, 38, 67, -78, -22, 90, -31, -73, 73, 31, -90, 22, 78, -67, -38, 90, -13, -82, 61, 46,
+      -88,  4, 85, -54 },
+    { 50, -89, 18, 75, -75, -18, 89, -50, -50, 89, -18, -75, 75, 18, -89, 50, 50, -89, 18, 75, -75, -18, 89, -50, -50, 89, -18,
+      -75, 75, 18, -89, 50 },
+    { 46, -90, 38, 54, -90, 31, 61, -88, 22, 67, -85, 13, 73, -82,  4, 78, -78, -4, 82, -73, -13, 85, -67, -22, 88, -61, -31, 90,
+      -54, -38, 90, -46 },
+    { 43, -90, 57, 25, -87, 70,  9, -80, 80, -9, -70, 87, -25, -57, 90, -43, -43, 90, -57, -25, 87, -70, -9, 80, -80,  9, 70, -87,
+      25, 57, -90, 43 },
+    { 38, -88, 73, -4, -67, 90, -46, -31, 85, -78, 13, 61, -90, 54, 22, -82, 82, -22, -54, 90, -61, -13, 78, -85, 31, 46, -90, 67,
+      4, -73, 88, -38 },
+    { 36, -83, 83, -36, -36, 83, -83, 36, 36, -83, 83, -36, -36, 83, -83, 36, 36, -83, 83, -36, -36, 83, -83, 36, 36, -83, 83,
+      -36, -36, 83, -83, 36 },
+    { 31, -78, 90, -61,  4, 54, -88, 82, -38, -22, 73, -90, 67, -13, -46, 85, -85, 46, 13, -67, 90, -73, 22, 38, -82, 88, -54, -4,
+      61, -90, 78, -31 },
+    { 25, -70, 90, -80, 43,  9, -57, 87, -87, 57, -9, -43, 80, -90, 70, -25, -25, 70, -90, 80, -43, -9, 57, -87, 87, -57,  9, 43,
+      -80, 90, -70, 25 },
+    { 22, -61, 85, -90, 73, -38, -4, 46, -78, 90, -82, 54, -13, -31, 67, -88, 88, -67, 31, 13, -54, 82, -90, 78, -46,  4, 38, -73,
+      90, -85, 61, -22 },
+    { 18, -50, 75, -89, 89, -75, 50, -18, -18, 50, -75, 89, -89, 75, -50, 18, 18, -50, 75, -89, 89, -75, 50, -18, -18, 50, -75,
+      89, -89, 75, -50, 18 },
+    { 13, -38, 61, -78, 88, -90, 85, -73, 54, -31,  4, 22, -46, 67, -82, 90, -90, 82, -67, 46, -22, -4, 31, -54, 73, -85, 90, -88,
+      78, -61, 38, -13 },
+    {  9, -25, 43, -57, 70, -80, 87, -90, 90, -87, 80, -70, 57, -43, 25, -9, -9, 25, -43, 57, -70, 80, -87, 90, -90, 87, -80, 70,
+       -57, 43, -25,  9 },
+    {  4, -13, 22, -31, 38, -46, 54, -61, 67, -73, 78, -82, 85, -88, 90, -90, 90, -90, 88, -85, 82, -78, 73, -67, 61, -54, 46,
+       -38, 31, -22, 13, -4 }
+};
+
+const unsigned char g_aucChromaScale[58] =
+{
+    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
+    17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 29, 30, 31, 32,
+    33, 33, 34, 34, 35, 35, 36, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44,
+    45, 46, 47, 48, 49, 50, 51
+};
+
+// Mode-Dependent DCT/DST
+const short g_as_DST_MAT_4[4][4] =
+{
+    { 29,   55,    74,   84 },
+    { 74,   74,    0,  -74 },
+    { 84,  -29,   -74,   55 },
+    { 55,  -84,    74,  -29 },
+};
+
+#endif // ifndef BUTTERFLY_H
--- a/source/encoder/macroblock.cpp	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/encoder/macroblock.cpp	Wed Apr 17 14:11:17 2013 +0530
@@ -26,6 +26,7 @@
 
 #include "primitives.h"
 #include "Lib/TLibCommon/CommonDef.h"
+#include "butterfly.h"
 #include <algorithm>
 
 /* Used for filter */
@@ -49,22 +50,22 @@ void CDECL inversedst(short *tmp, short 
         c[2] = tmp[i] - tmp[12 + i];
         c[3] = 74 * tmp[4 + i];
 
-        block[4 * i + 0] = (short) Clip3(-32768, 32767, (29 * c[0] + 55 * c[1]     + c[3]               + rnd_factor) >> shift);
-        block[4 * i + 1] = (short) Clip3(-32768, 32767, (55 * c[2] - 29 * c[1]     + c[3]               + rnd_factor) >> shift);
-        block[4 * i + 2] = (short) Clip3(-32768, 32767, (74 * (tmp[i] - tmp[8 + i]  + tmp[12 + i])      + rnd_factor) >> shift);
-        block[4 * i + 3] = (short) Clip3(-32768, 32767, (55 * c[0] + 29 * c[2]     - c[3]               + rnd_factor) >> shift);
+        block[4 * i + 0] = (short)Clip3(-32768, 32767, (29 * c[0] + 55 * c[1]     + c[3]               + rnd_factor) >> shift);
+        block[4 * i + 1] = (short)Clip3(-32768, 32767, (55 * c[2] - 29 * c[1]     + c[3]               + rnd_factor) >> shift);
+        block[4 * i + 2] = (short)Clip3(-32768, 32767, (74 * (tmp[i] - tmp[8 + i]  + tmp[12 + i])      + rnd_factor) >> shift);
+        block[4 * i + 3] = (short)Clip3(-32768, 32767, (55 * c[0] + 29 * c[2]     - c[3]               + rnd_factor) >> shift);
     }
 }
 
 template<int N, bool isFirst, bool isLast>
 void CDECL filter_8_nonvertical(const short *coeff,
-                                pixel *src,
-                                int    srcStride,
-                                pixel *dst,
-                                int    dstStride,
-                                int    block_width,
-                                int    block_height,
-                                int    bitDepth)
+                                pixel *      src,
+                                int          srcStride,
+                                pixel *      dst,
+                                int          dstStride,
+                                int          block_width,
+                                int          block_height,
+                                int          bitDepth)
 {
     int row, col;
     short c[8];
@@ -117,7 +118,7 @@ void CDECL filter_8_nonvertical(const sh
     {
         for (col = 0; col < block_width; col++)
         {
-            int sum;
+            short sum;
             sum  = src[col + 0] * c[0];
             sum += src[col + 1] * c[1];
             if (N >= 4)
@@ -156,6 +157,59 @@ void CDECL filter_8_nonvertical(const sh
 #pragma warning(default: 4127) // conditional expression is constant
 #endif
 }
+
+void CDECL partialButterfly16(short *src, short *dst, int shift, int line)
+{
+    int j, k;
+    int E[8], O[8];
+    int EE[4], EO[4];
+    int EEE[2], EEO[2];
+    int add = 1 << (shift - 1);
+
+    for (j = 0; j < line; j++)
+    {
+        /* E and O */
+        for (k = 0; k < 8; k++)
+        {
+            E[k] = src[k] + src[15 - k];
+            O[k] = src[k] - src[15 - k];
+        }
+
+        /* EE and EO */
+        for (k = 0; k < 4; k++)
+        {
+            EE[k] = E[k] + E[7 - k];
+            EO[k] = E[k] - E[7 - k];
+        }
+
+        /* EEE and EEO */
+        EEE[0] = EE[0] + EE[3];
+        EEO[0] = EE[0] - EE[3];
+        EEE[1] = EE[1] + EE[2];
+        EEO[1] = EE[1] - EE[2];
+
+        dst[0] = (short)((g_aiT16[0][0] * EEE[0] + g_aiT16[0][1] * EEE[1] + add) >> shift);
+        dst[8 * line] = (short)((g_aiT16[8][0] * EEE[0] + g_aiT16[8][1] * EEE[1] + add) >> shift);
+        dst[4 * line] = (short)((g_aiT16[4][0] * EEO[0] + g_aiT16[4][1] * EEO[1] + add) >> shift);
+        dst[12 * line] = (short)((g_aiT16[12][0] * EEO[0] + g_aiT16[12][1] * EEO[1] + add) >> shift);
+
+        for (k = 2; k < 16; k += 4)
+        {
+            dst[k * line] = (short)((g_aiT16[k][0] * EO[0] + g_aiT16[k][1] * EO[1] + g_aiT16[k][2] * EO[2] +
+                                     g_aiT16[k][3] * EO[3] + add) >> shift);
+        }
+
+        for (k = 1; k < 16; k += 2)
+        {
+            dst[k * line] =  (short)((g_aiT16[k][0] * O[0] + g_aiT16[k][1] * O[1] + g_aiT16[k][2] * O[2] + g_aiT16[k][3] * O[3] +
+                                      g_aiT16[k][4] * O[4] + g_aiT16[k][5] * O[5] + g_aiT16[k][6] * O[6] + g_aiT16[k][7] * O[7] +
+                                      add) >> shift);
+        }
+
+        src += 16;
+        dst++;
+    }
+}
 }
 
 namespace x265 {
@@ -174,5 +228,7 @@ void Setup_C_MacroblockPrimitives(Encode
     p.filter[FILTER_H_8_0_1] = filter_8_nonvertical<8, 0, 1>;
     p.filter[FILTER_H_8_1_0] = filter_8_nonvertical<8, 1, 0>;
     p.filter[FILTER_H_8_1_1] = filter_8_nonvertical<8, 1, 1>;
+
+    p.partial_butterfly[BUTTERFLY_16] = partialButterfly16;
 }
 }
--- a/source/encoder/primitives.h	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/encoder/primitives.h	Wed Apr 17 14:11:17 2013 +0530
@@ -112,6 +112,19 @@ enum FilterConf
     NUM_FILTER
 };
 
+enum Butterflies
+{
+    BUTTERFLY_4,
+    BUTTERFLY_INVERSE_4,
+    BUTTERFLY_8,
+    BUTTERFLY_INVERSE_8,
+    BUTTERFLY_16,
+    BUTTERFLY_INVERSE_16,
+    BUTTERFLY_32,
+    BUTTERFLY_INVERSE_32,
+    NUM_BUTTERFLIES
+};
+
 // Returns a Partitions enum if the size matches a supported performance primitive,
 // else returns -1 (in which case you should use the slow path)
 int PartitionFromSizes(int Width, int Height);
@@ -120,6 +133,7 @@ typedef int (CDECL * pixelcmp)(pixel *fe
 typedef void (CDECL * mbdst)(short *block, short *coeff, int shift);
 typedef void (CDECL * IPFilter)(const short *coeff, pixel *src, int srcStride, pixel *dst, int dstStride, int block_width,
                                 int block_height, int bitDepth);
+typedef void (CDECL * butterfly)(short *src, short *dst, int shift, int line);
 
 /* Define a structure containing function pointers to optimized encoder
  * primitives.  Each pointer can reference either an assembly routine,
@@ -133,6 +147,7 @@ struct EncoderPrimitives
     pixelcmp sa8d_16x16;
     IPFilter filter[NUM_FILTER];
     mbdst inversedst;
+    butterfly partial_butterfly[NUM_BUTTERFLIES];
 };
 
 /* This copy of the table is what gets used by all by the encoder.
--- a/source/encoder/vec/CMakeLists.txt	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/encoder/vec/CMakeLists.txt	Wed Apr 17 14:11:17 2013 +0530
@@ -20,5 +20,5 @@ endif(GCC)
 file(GLOB VECTORCLASS ../../VectorClass/*.h ../../VectorClass/special/*.h)
 source_group(VectorClass FILES ${VECTORCLASS})
 
-add_library(VectorPrimitives vec-primitives.cpp ${PRIMITIVES} ${VECTORCLASS}
+add_library(PrimitivesVec vec-primitives.cpp ${PRIMITIVES} ${VECTORCLASS}
             vecprimitives.inc pixel.inc macroblock.inc)
--- a/source/encoder/vec/macroblock.inc	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/encoder/vec/macroblock.inc	Wed Apr 17 14:11:17 2013 +0530
@@ -122,6 +122,130 @@ void CDECL filter_Horizontal_8(const sho
     }
 }
 
+void CDECL partialButterfly16(short *src, short *dst, int shift, int line)
+{
+    int j;
+    int add = 1 << (shift - 1);
+
+    Vec4i g_aiT_zero_row(64, 64, 0, 0);
+    Vec4i g_aiT_four_row(83, 36, 0, 0);
+    Vec4i g_aiT_eight_row(64, -64, 0, 0);
+    Vec4i g_aiT_twelve_row(36, -83, 0, 0);
+
+    Vec4i g_aiT_two_row(89, 75, 50, 18);
+    Vec4i g_aiT_six_row(75, -18, -89, -50);
+    Vec4i g_aiT_ten_row(50, -89, 18, 75);
+    Vec4i g_aiT_fourteen_row(18, -50, 75, -89);
+
+    Vec8i g_aiT_one_row(90, 87, 80, 70, 57, 43, 25,  9);
+    Vec8i g_aiT_three_row(87, 57,  9, -43, -80, -90, -70, -25);
+    Vec8i g_aiT_five_row(80,  9, -70, -87, -25, 57, 90, 43);
+    Vec8i g_aiT_seven_row(70, -43, -87,  9, 90, 25, -80, -57);
+    Vec8i g_aiT_nine_row(57, -80, -25, 90, -9, -87, 43, 70);
+    Vec8i g_aiT_eleven_row(43, -90, 57, 25, -87, 70,  9, -80);
+    Vec8i g_aiT_thirteen_row(25, -70, 90, -80, 43,  9, -57, 87);
+    Vec8i g_aiT_fifteen_row(9, -25, 43, -57, 70, -80, 87, -90);
+
+    for (j = 0; j < line; j++)
+    {
+        Vec16s tmp1;
+        tmp1.load(src);
+        Vec8i src_first_half = extend_low(tmp1);
+        Vec8i src_second_half_tmp = extend_high(tmp1);
+        Vec8i src_second_half = permute8i<15, 14, 13, 12, 11, 10, 9, 8>(src_second_half_tmp);
+
+        Vec8i E = src_first_half + src_second_half;
+        Vec8i O = src_first_half - src_second_half;
+
+        Vec4i E_first_half;
+        E_first_half = E.get_low();
+        Vec4i E_second_half_tmp = E.get_high();
+        Vec4i E_second_half = permute4i<7, 6, 5, 4>(E_second_half_tmp);
+
+        Vec4i EE = E_first_half + E_second_half;
+        Vec4i EO = E_first_half - E_second_half;
+
+        Vec4i EE_first_half = permute4i<0, 1, -1, -1>(EE);
+        Vec4i EE_second_half = permute4i<3, 2, -1, -1>(EE);
+
+        Vec4i EEE = EE_first_half + EE_second_half;
+        Vec4i EEO = EE_first_half - EE_second_half;
+
+        Vec4i dst_tmp0 = g_aiT_zero_row * EEE;
+        Vec4i dst_tmp4 = g_aiT_four_row * EEO;
+        Vec4i dst_tmp8 = g_aiT_eight_row * EEE;
+        Vec4i dst_tmp12 = g_aiT_twelve_row * EEO;
+
+        int dst_zero = horizontal_add(dst_tmp0);
+        int dst_four = horizontal_add(dst_tmp4);
+        int dst_eight = horizontal_add(dst_tmp8);
+        int dst_twelve = horizontal_add(dst_tmp12);
+
+        Vec4i dst_0_8_4_12(dst_zero, dst_eight, dst_four, dst_twelve);
+
+        Vec4i dst_result = dst_0_8_4_12 + add;
+        Vec4i dst_shift_result = dst_result >> shift;
+
+        dst[0] = dst_shift_result[0];
+        dst[8 * line] = dst_shift_result[1];
+        dst[4 * line] = dst_shift_result[2];
+        dst[12 * line] = dst_shift_result[3];
+
+        Vec4i dst_tmp2 = g_aiT_two_row * EO;
+        Vec4i dst_tmp6 = g_aiT_six_row * EO;
+        Vec4i dst_tmp10 = g_aiT_ten_row * EO;
+        Vec4i dst_tmp14 = g_aiT_fourteen_row * EO;
+
+        int dst_two = horizontal_add(dst_tmp2);
+        int dst_six = horizontal_add(dst_tmp6);
+        int dst_ten = horizontal_add(dst_tmp10);
+        int dst_fourteen = horizontal_add(dst_tmp14);
+
+        Vec4i dst_2_6_10_14(dst_two, dst_six, dst_ten, dst_fourteen);
+        dst_2_6_10_14 = dst_2_6_10_14 + add;
+        dst_2_6_10_14 = dst_2_6_10_14 >> shift;
+
+        dst[2 * line] = dst_2_6_10_14[0];
+        dst[6 * line] = dst_2_6_10_14[1];
+        dst[10 * line] = dst_2_6_10_14[2];
+        dst[14 * line] = dst_2_6_10_14[3];
+
+        Vec8i dst_tmp1 = g_aiT_one_row * O;
+        Vec8i dst_tmp3 = g_aiT_three_row * O;
+        Vec8i dst_tmp5 = g_aiT_five_row * O;
+        Vec8i dst_tmp7 = g_aiT_seven_row * O;
+        Vec8i dst_tmp9 = g_aiT_nine_row * O;
+        Vec8i dst_tmp11 = g_aiT_eleven_row * O;
+        Vec8i dst_tmp13 = g_aiT_thirteen_row * O;
+        Vec8i dst_tmp15 = g_aiT_fifteen_row * O;
+
+        int dst_one = horizontal_add(dst_tmp1);
+        int dst_three = horizontal_add(dst_tmp3);
+        int dst_five = horizontal_add(dst_tmp5);
+        int dst_seven = horizontal_add(dst_tmp7);
+        int dst_nine = horizontal_add(dst_tmp9);
+        int dst_eleven = horizontal_add(dst_tmp11);
+        int dst_thirteen = horizontal_add(dst_tmp13);
+        int dst_fifteen = horizontal_add(dst_tmp15);
+
+        Vec8i dst_1_2_5_7_9_11_13_15(dst_one, dst_three, dst_five, dst_seven, dst_nine, dst_eleven, dst_thirteen, dst_fifteen);
+        dst_1_2_5_7_9_11_13_15 = dst_1_2_5_7_9_11_13_15 + add;
+        dst_1_2_5_7_9_11_13_15 = dst_1_2_5_7_9_11_13_15 >> shift;
+
+        dst[1 * line] = dst_1_2_5_7_9_11_13_15[0];
+        dst[3 * line] = dst_1_2_5_7_9_11_13_15[1];
+        dst[5 * line] = dst_1_2_5_7_9_11_13_15[2];
+        dst[7 * line] = dst_1_2_5_7_9_11_13_15[3];
+        dst[9 * line] = dst_1_2_5_7_9_11_13_15[4];
+        dst[11 * line] = dst_1_2_5_7_9_11_13_15[5];
+        dst[13 * line] = dst_1_2_5_7_9_11_13_15[6];
+        dst[15 * line] = dst_1_2_5_7_9_11_13_15[7];
+
+        src += 16;
+        dst++;
+    }
+}
+
 void Setup_Vec_MacroblockPrimitives(EncoderPrimitives &p)
 {
     p.inversedst = inversedst;
@@ -132,7 +256,10 @@ void Setup_Vec_MacroblockPrimitives(Enco
       p.filter[FILTER_H_4_1_1] = filter_Horizontal_4< 1, 1>;*/
 
     p.filter[FILTER_H_8_0_0] = filter_Horizontal_8<0, 0>;
-    p.filter[FILTER_H_8_0_1] = filter_Horizontal_8<0, 1>;
+    p.filter[FILTER_H_8_0_1] = filter_Horizontal_8<0, 1>;
     p.filter[FILTER_H_8_1_0] = filter_Horizontal_8<1, 0>;
     p.filter[FILTER_H_8_1_1] = filter_Horizontal_8<1, 1>;
+
+    p.partial_butterfly[BUTTERFLY_16] = partialButterfly16;
 }
+
--- a/source/encoder/x86/CMakeLists.txt	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/encoder/x86/CMakeLists.txt	Wed Apr 17 14:11:17 2013 +0530
@@ -4,9 +4,35 @@ else()
     add_definitions(-DHAVE_ALIGNED_STACK=0)
 endif()
 
-if (NOT X64)
-    set(EXTRAS pixel-32.asm)
+if(MSVC)
+    # this is horrible. ugly, and hacky, and it reproduces logic found
+    # in the yasm CMake modules, but this is required because of this cmake bug
+    # http://www.cmake.org/Bug/print_bug_page.php?bug_id=8170
+    set(ASMS pixel-a)
+    if (X64)
+        set(FLAGS -f win64 -m amd64 -DARCH_X86_64=1 -DHAVE_ALIGNED_STACK=0)
+    else()
+        set(FLAGS -f win32 -DARCH_X86_64=0 -DHAVE_ALIGNED_STACK=0)
+        set(ASMS ${ASMS} pixel-32)
+    endif()
+    if (HIGH_BIT_DEPTH)
+        set(FLAGS ${FLAGS} -DHIGH_BIT_DEPTH=1 -DBIT_DEPTH=10)
+    else()
+        set(FLAGS ${FLAGS} -DHIGH_BIT_DEPTH=0 -DBIT_DEPTH=8)
+    endif()
+    foreach(ASM ${ASMS})
+        set(OBJS ${OBJS} ${ASM}.o)
+        add_custom_command(
+            OUTPUT ${ASM}.o
+            COMMAND ${YASM_EXECUTABLE} ARGS ${FLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${ASM}.asm -o ${ASM}.o
+            DEPENDS ${ASM}.asm)
+    endforeach()
+    add_library(PrimitivesASM asm-primitives.cpp ${OBJS})
+else()
+    enable_language(ASM_YASM)
+    set(ASMS pixel-a.asm)
+    if (NOT X64)
+        set(ASMS ${ASMS} pixel-32.asm)
+    endif()
+    add_library(PrimitivesASM asm-primitives.cpp ${ASMS})
 endif()
-
-enable_language(ASM_YASM)
-add_library(AsmPrimitives asm-primitives.cpp ${EXTRAS} pixel-a.asm)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source/input/CMakeLists.txt	Wed Apr 17 14:11:17 2013 +0530
@@ -0,0 +1,4 @@
+add_library(InputFiles 
+    input.cpp input.h
+    y4m.cpp y4m.h
+    yuv.cpp yuv.h)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source/input/input.cpp	Wed Apr 17 14:11:17 2013 +0530
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * Copyright (C) 2013 x265 project
+ *
+ * Authors: Steve Borho <steve@borho.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@multicorewareinc.com.
+ *****************************************************************************/
+
+#include "input.h"
+#include "yuv.h"
+#include "y4m.h"
+#include <string.h>
+
+using namespace x265;
+
+Input* Input::Open(const char *filename)
+{
+    const char * s = strrchr(filename, '.');
+    if (s && !strcmp(s, ".y4m"))
+        return new Y4MInput(filename);
+    else
+        return new YUVInput(filename);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source/input/input.h	Wed Apr 17 14:11:17 2013 +0530
@@ -0,0 +1,82 @@
+/*****************************************************************************
+ * Copyright (C) 2013 x265 project
+ *
+ * Authors: Steve Borho <steve@borho.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@multicorewareinc.com.
+ *****************************************************************************/
+
+#ifndef _INPUT_H_
+#define _INPUT_H_
+
+#include <stdint.h>
+#include <TLibCommon/TypeDef.h>
+
+namespace x265 {
+
+struct Picture
+{
+    void *planes[3];
+
+    int   stride[3];
+
+    int   bitDepth;
+
+    ChromaFormat csp;
+};
+
+class Input
+{
+protected:
+
+    virtual ~Input()  {}
+
+public:
+
+    Input()           {}
+
+    static Input* Open(const char *filename);
+
+    virtual void setDimensions(int width, int height) = 0;
+
+    virtual void setRate(int numerator, int denominator) = 0;
+
+    virtual void setBitDepth(int bitDepth) = 0;
+
+    virtual float getRate() const = 0;
+
+    virtual int getWidth() const = 0;
+
+    virtual int getHeight() const = 0;
+
+    virtual void release() = 0;
+
+    virtual void skipFrames(int numFrames) = 0;
+
+    virtual bool readPicture(Picture& pic) = 0;
+
+    virtual bool isEof() const = 0;
+
+    virtual bool isFail() const = 0;
+
+    virtual int  guessFrameCount() const = 0;
+};
+
+}
+
+#endif // _INPUT_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source/input/y4m.cpp	Wed Apr 17 14:11:17 2013 +0530
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * Copyright (C) 2013 x265 project
+ *
+ * Authors: Steve Borho <steve@borho.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@multicorewareinc.com.
+ *****************************************************************************/
+
+#include "y4m.h"
+#include <stdio.h>
+
+using namespace x265;
+
+Y4MInput::Y4MInput(const char *filename)
+{
+    fp = fopen(filename, "rb");
+
+    if (fp)
+        parseHeader();
+}
+
+Y4MInput::~Y4MInput()
+{
+    if (fp) fclose(fp); 
+}
+
+void Y4MInput::parseHeader()
+{
+}
+
+int  Y4MInput::guessFrameCount() const
+{
+    return 0;
+}
+
+void Y4MInput::skipFrames(int numFrames)
+{
+
+}
+
+bool Y4MInput::readPicture(Picture& pic)
+{
+    return false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source/input/y4m.h	Wed Apr 17 14:11:17 2013 +0530
@@ -0,0 +1,83 @@
+/*****************************************************************************
+ * Copyright (C) 2013 x265 project
+ *
+ * Authors: Steve Borho <steve@borho.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@multicorewareinc.com.
+ *****************************************************************************/
+
+#ifndef _Y4M_H_
+#define _Y4M_H_
+
+#include "input.h"
+#include <stdio.h>
+
+namespace x265 {
+
+class Y4MInput : public Input
+{
+protected:
+
+    int rateNum;
+
+    int rateDenom;
+
+    int width;
+
+    int height;
+
+    FILE *fp;
+
+    bool eof;
+
+    void parseHeader();
+
+public:
+
+    Y4MInput(const char *filename);
+
+    virtual ~Y4MInput();
+
+    void setDimensions(int w, int h)              { /* ignore, warn */ }
+
+    void setRate(int numerator, int denominator)  { /* ignore, warn */ }
+
+    void setBitDepth(int bitDepth)                { /* ignore, warn */ }
+
+    float getRate() const                         { return ((float) rateNum)/rateDenom; }
+
+    int getWidth() const                          { return width; }
+
+    int getHeight() const                         { return height; }
+
+    bool isEof() const                            { return eof; }
+
+    bool isFail() const                           { return !!fp; }
+
+    void release()                                { delete this; }
+
+    int  guessFrameCount() const;
+
+    void skipFrames(int numFrames);
+
+    bool readPicture(Picture&);
+};
+
+}
+
+#endif // _Y4M_H_
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source/input/yuv.cpp	Wed Apr 17 14:11:17 2013 +0530
@@ -0,0 +1,56 @@
+/*****************************************************************************
+ * Copyright (C) 2013 x265 project
+ *
+ * Authors: Steve Borho <steve@borho.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@multicorewareinc.com.
+ *****************************************************************************/
+
+#include <fcntl.h>
+#include <assert.h>
+#include <sys/stat.h>
+
+#include "input.h"
+#include "yuv.h"
+
+using namespace x265;
+
+YUVInput::YUVInput(const char *filename)
+{
+    fp = fopen(filename, "rb");
+}
+
+YUVInput::~YUVInput()
+{
+    if (fp) fclose(fp); 
+}
+
+int  YUVInput::guessFrameCount() const
+{
+    return 0;
+}
+
+void YUVInput::skipFrames(int numFrames)
+{
+
+}
+
+bool YUVInput::readPicture(Picture& pic)
+{
+    return false;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source/input/yuv.h	Wed Apr 17 14:11:17 2013 +0530
@@ -0,0 +1,83 @@
+/*****************************************************************************
+ * Copyright (C) 2013 x265 project
+ *
+ * Authors: Steve Borho <steve@borho.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@multicorewareinc.com.
+ *****************************************************************************/
+
+#ifndef _YUV_H_
+#define _YUV_H_
+
+#include "input.h"
+#include <stdio.h>
+
+namespace x265 {
+
+class YUVInput : public Input
+{
+protected:
+
+    int rateNum;
+
+    int rateDenom;
+
+    int width;
+
+    int height;
+
+    int depth;
+
+    FILE *fp;
+
+    bool eof;
+
+public:
+
+    YUVInput(const char *filename);
+
+    virtual ~YUVInput();
+
+    void setDimensions(int w, int h)              { width = w; height = h; }
+
+    void setRate(int numerator, int denominator)  { rateNum = numerator; rateDenom = denominator; }
+
+    void setBitDepth(int bitDepth)                { depth = bitDepth; }
+
+    float getRate() const                         { return ((float) rateNum)/rateDenom; }
+
+    int getWidth() const                          { return width; }
+
+    int getHeight() const                         { return height; }
+
+    bool isEof() const                            { return eof; }
+
+    bool isFail() const                           { return !!fp; }
+
+    void release()                                { if (fp) fclose(fp); delete this; }
+
+    int  guessFrameCount() const;
+
+    void skipFrames(int numFrames);
+
+    bool readPicture(Picture&);
+};
+
+}
+
+#endif // _YUV_H_
--- a/source/test/CMakeLists.txt	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/test/CMakeLists.txt	Wed Apr 17 14:11:17 2013 +0530
@@ -8,8 +8,11 @@ if(ENABLE_PPA)
     endif(UNIX)
 endif(ENABLE_PPA)
 
-add_executable(PoolTest testpool.cpp)
-target_link_libraries(PoolTest x265 HM ${PLATFORM_LIBS})
+option(ENABLE_TEST_THREADPOOL "Enable thread pool unit test" OFF)
+if(ENABLE_TEST_THREADPOOL)
+    add_executable(PoolTest testpool.cpp)
+    target_link_libraries(PoolTest x265 HM ${PLATFORM_LIBS})
+endif()
 
 if(MSVC)
     # these should be cleaned up so the test bench compiles clean for
--- a/source/test/filterharness.cpp	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/test/filterharness.cpp	Wed Apr 17 14:11:17 2013 +0530
@@ -1,185 +1,185 @@
-/*****************************************************************************
- * Copyright (C) 2013 x265 project
- *
- * Authors: Steve Borho <steve@borho.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
- *
- * This program is also available under a commercial proprietary license.
- * For more information, contact us at licensing@multicorewareinc.com.
- *****************************************************************************/
-
-#include "filterharness.h"
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-
-using namespace x265;
-
-const short m_lumaFilter[4][8] =
-{
-    { 0, 0,   0, 64,  0,   0, 0,  0 },
-    { -1, 4, -10, 58, 17,  -5, 1,  0 },
-    { -1, 4, -11, 40, 40, -11, 4, -1 },
-    { 0, 1,  -5, 17, 58, -10, 4, -1 }
-};
-
-const char *FilterConf_names[] =
-{
-    // Naming convention used is - isVertical_N_isFirst_isLast
-    "Hor_N=4_isFirst=0_isLast=0",
-    "Hor_N=4_isFirst=0_isLast=1",
-    "Hor_N=4_isFirst=1_isLast=0",
-    "Hor_N=4_isFirst=1_isLast=1",
-
-    "Hor_N=8_isFirst=0_isLast=0",
-    "Hor_N=8_isFirst=0_isLast=1",
-    "Hor_N=8_isFirst=1_isLast=0",
-    "Hor_N=8_isFirst=1_isLast=1",
-
-    "Ver_N=4_isFirst=0_isLast=0",
-    "Ver_N=4_isFirst=0_isLast=1",
-    "Ver_N=4_isFirst=1_isLast=0",
-    "Ver_N=4_isFirst=1_isLast=1",
-
-    "Ver_N=8_isFirst=0_isLast=0",
-    "Ver_N=8_isFirst=0_isLast=1",
-    "Ver_N=8_isFirst=1_isLast=0",
-    "Ver_N=8_isFirst=1_isLast=1"
-};
-
-FilterHarness::FilterHarness()
-{
-    ipf_t_size = 200 * 200;
-    pixel_buff = (pixel*)malloc(ipf_t_size * sizeof(pixel));     // Assuming max_height = max_width = max_srcStride = max_dstStride = 100
-    IPF_vec_output = (short*)malloc(ipf_t_size * sizeof(short)); // Output Buffer1
-    IPF_C_output = (short*)malloc(ipf_t_size * sizeof(short));   // Output Buffer2
-
-    if (!pixel_buff || !IPF_vec_output || !IPF_C_output)
-    {
-        fprintf(stderr, "init_IPFilter_buffers: malloc failed, unable to initiate tests!\n");
-        exit(-1);
-    }
-
-    for (int i = 0; i < ipf_t_size; i++)                         // Initialize input buffer
-    {
-        int isPositive = rand() & 1;                             // To randomly generate Positive and Negative values
-        isPositive = (isPositive) ? 1 : -1;
-        pixel_buff[i] = isPositive * (rand() & PIXEL_MAX);
-    }
-}
-
-FilterHarness::~FilterHarness()
-{
-    free(IPF_vec_output);
-    free(IPF_C_output);
-    free(pixel_buff);
-}
-
-bool FilterHarness::check_IPFilter_primitive(IPFilter ref, IPFilter opt)
-{
-    int rand_height = rand() & 100;                 // Randomly generated Height
-    int rand_width = rand() & 100;                  // Randomly generated Width
-    short rand_val, rand_srcStride, rand_dstStride;
-
-    for (int i = 0; i <= 100; i++)
-    {
-        memset(IPF_vec_output, 0, ipf_t_size);      // Initialize output buffer to zero
-        memset(IPF_C_output, 0, ipf_t_size);        // Initialize output buffer to zero
-
-        rand_val = rand() & 24;                     // Random offset in the filter
-        rand_srcStride = rand() & 100;              // Randomly generated srcStride
-        rand_dstStride = rand() & 100;              // Randomly generated dstStride
-
-        opt((short*)(m_lumaFilter + rand_val),
-            pixel_buff,
-            rand_srcStride,
-            (pixel*)IPF_vec_output,
-            rand_dstStride,
-            rand_height,
-            rand_width,
-            BIT_DEPTH);
-        ref((short*)(m_lumaFilter + rand_val),
-            pixel_buff,
-            rand_srcStride,
-            (pixel*)IPF_C_output,
-            rand_dstStride,
-            rand_height,
-            rand_width,
-            BIT_DEPTH);
-
-        if (memcmp(IPF_vec_output, IPF_C_output, ipf_t_size))
-            return false;
-    }
-
-    return true;
-}
-
-bool FilterHarness::testCorrectness( const EncoderPrimitives& ref, const EncoderPrimitives& opt )
-{
-    for (int value = 4; value < 8; value++)
-    {
-        if (opt.filter[value])
-        {
-            if (!check_IPFilter_primitive(ref.filter[value], opt.filter[value]))
-            {
-                printf("\nfilter[%s] failed\n", FilterConf_names[value]);
-                return false;
-            }
-        }
-    }
-
-    return true;
-}
-
-#define FILTER_ITERATIONS   100000
-
-void FilterHarness::measureSpeed( const EncoderPrimitives& ref, const EncoderPrimitives& opt )
-{
-    Timer *t = Timer::CreateTimer();
-
-    /* Add logic here for testing performance of your new primitive*/
-    int rand_height = rand() % 100;             // Randomly generated Height
-    int rand_width = rand() % 100;              // Randomly generated Width
-    short rand_val, rand_srcStride, rand_dstStride;
-
-    rand_val = rand() % 24;                     // Random offset in the filter
-    rand_srcStride = rand() % 100;              // Randomly generated srcStride
-    rand_dstStride = rand() % 100;              // Randomly generated dstStride
-
-    for (int value = 4; value < 8; value++)
-    {
-        memset(IPF_vec_output, 0, ipf_t_size);  // Initialize output buffer to zero
-        memset(IPF_C_output, 0, ipf_t_size);    // Initialize output buffer to zero
-        if (opt.filter[value])
-        {
-            t->Start();
-            for (int j = 0; j < FILTER_ITERATIONS; j++)
-                opt.filter[value]((short*)(m_lumaFilter + rand_val), pixel_buff, rand_srcStride, (pixel*)IPF_vec_output,
-                                      rand_dstStride, rand_height, rand_width, BIT_DEPTH);
-            t->Stop();
-            printf("\nfilter[%s]\tVec: (%1.2f ms) ", FilterConf_names[value], t->ElapsedMS());
-
-            t->Start();
-            for (int j = 0; j < FILTER_ITERATIONS; j++)
-                ref.filter[value]((short*)(m_lumaFilter + rand_val), pixel_buff, rand_srcStride, (pixel*)IPF_vec_output,
-                                    rand_dstStride, rand_height, rand_width, BIT_DEPTH);
-            t->Stop();
-            printf("\tC: (%1.2f ms) ", t->ElapsedMS());
-        }
-    }
-
-    t->Release();
-}
+/*****************************************************************************
+ * Copyright (C) 2013 x265 project
+ *
+ * Authors: Steve Borho <steve@borho.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@multicorewareinc.com.
+ *****************************************************************************/
+
+#include "filterharness.h"
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+using namespace x265;
+
+const short m_lumaFilter[4][8] =
+{
+    { 0, 0,   0, 64,  0,   0, 0,  0 },
+    { -1, 4, -10, 58, 17,  -5, 1,  0 },
+    { -1, 4, -11, 40, 40, -11, 4, -1 },
+    { 0, 1,  -5, 17, 58, -10, 4, -1 }
+};
+
+const char *FilterConf_names[] =
+{
+    // Naming convention used is - isVertical_N_isFirst_isLast
+    "Hor_N=4_isFirst=0_isLast=0",
+    "Hor_N=4_isFirst=0_isLast=1",
+    "Hor_N=4_isFirst=1_isLast=0",
+    "Hor_N=4_isFirst=1_isLast=1",
+
+    "Hor_N=8_isFirst=0_isLast=0",
+    "Hor_N=8_isFirst=0_isLast=1",
+    "Hor_N=8_isFirst=1_isLast=0",
+    "Hor_N=8_isFirst=1_isLast=1",
+
+    "Ver_N=4_isFirst=0_isLast=0",
+    "Ver_N=4_isFirst=0_isLast=1",
+    "Ver_N=4_isFirst=1_isLast=0",
+    "Ver_N=4_isFirst=1_isLast=1",
+
+    "Ver_N=8_isFirst=0_isLast=0",
+    "Ver_N=8_isFirst=0_isLast=1",
+    "Ver_N=8_isFirst=1_isLast=0",
+    "Ver_N=8_isFirst=1_isLast=1"
+};
+
+FilterHarness::FilterHarness()
+{
+    ipf_t_size = 200 * 200;
+    pixel_buff = (pixel*)malloc(ipf_t_size * sizeof(pixel));     // Assuming max_height = max_width = max_srcStride = max_dstStride = 100
+    IPF_vec_output = (short*)malloc(ipf_t_size * sizeof(short)); // Output Buffer1
+    IPF_C_output = (short*)malloc(ipf_t_size * sizeof(short));   // Output Buffer2
+
+    if (!pixel_buff || !IPF_vec_output || !IPF_C_output)
+    {
+        fprintf(stderr, "init_IPFilter_buffers: malloc failed, unable to initiate tests!\n");
+        exit(-1);
+    }
+
+    for (int i = 0; i < ipf_t_size; i++)                         // Initialize input buffer
+    {
+        int isPositive = rand() & 1;                             // To randomly generate Positive and Negative values
+        isPositive = (isPositive) ? 1 : -1;
+        pixel_buff[i] = isPositive * (rand() & PIXEL_MAX);
+    }
+}
+
+FilterHarness::~FilterHarness()
+{
+    free(IPF_vec_output);
+    free(IPF_C_output);
+    free(pixel_buff);
+}
+
+bool FilterHarness::check_IPFilter_primitive(IPFilter ref, IPFilter opt)
+{
+    int rand_height = rand() & 100;                 // Randomly generated Height
+    int rand_width = rand() & 100;                  // Randomly generated Width
+    short rand_val, rand_srcStride, rand_dstStride;
+
+    for (int i = 0; i <= 100; i++)
+    {
+        memset(IPF_vec_output, 0, ipf_t_size);      // Initialize output buffer to zero
+        memset(IPF_C_output, 0, ipf_t_size);        // Initialize output buffer to zero
+
+        rand_val = rand() & 24;                     // Random offset in the filter
+        rand_srcStride = rand() & 100;              // Randomly generated srcStride
+        rand_dstStride = rand() & 100;              // Randomly generated dstStride
+
+        opt((short*)(m_lumaFilter + rand_val),
+            pixel_buff,
+            rand_srcStride,
+            (pixel*)IPF_vec_output,
+            rand_dstStride,
+            rand_height,
+            rand_width,
+            BIT_DEPTH);
+        ref((short*)(m_lumaFilter + rand_val),
+            pixel_buff,
+            rand_srcStride,
+            (pixel*)IPF_C_output,
+            rand_dstStride,
+            rand_height,
+            rand_width,
+            BIT_DEPTH);
+
+        if (memcmp(IPF_vec_output, IPF_C_output, ipf_t_size))
+            return false;
+    }
+
+    return true;
+}
+
+bool FilterHarness::testCorrectness( const EncoderPrimitives& ref, const EncoderPrimitives& opt )
+{
+    for (int value = 4; value < 8; value++)
+    {
+        if (opt.filter[value])
+        {
+            if (!check_IPFilter_primitive(ref.filter[value], opt.filter[value]))
+            {
+                printf("\nfilter[%s] failed\n", FilterConf_names[value]);
+                return false;
+            }
+        }
+    }
+
+    return true;
+}
+
+#define FILTER_ITERATIONS   100000
+
+void FilterHarness::measureSpeed( const EncoderPrimitives& ref, const EncoderPrimitives& opt )
+{
+    Timer *t = Timer::CreateTimer();
+
+    /* Add logic here for testing performance of your new primitive*/
+    int rand_height = rand() % 100;             // Randomly generated Height
+    int rand_width = rand() % 100;              // Randomly generated Width
+    short rand_val, rand_srcStride, rand_dstStride;
+
+    rand_val = rand() % 24;                     // Random offset in the filter
+    rand_srcStride = rand() % 100;              // Randomly generated srcStride
+    rand_dstStride = rand() % 100;              // Randomly generated dstStride
+
+    for (int value = 4; value < 8; value++)
+    {
+        memset(IPF_vec_output, 0, ipf_t_size);  // Initialize output buffer to zero
+        memset(IPF_C_output, 0, ipf_t_size);    // Initialize output buffer to zero
+        if (opt.filter[value])
+        {
+            t->Start();
+            for (int j = 0; j < FILTER_ITERATIONS; j++)
+                opt.filter[value]((short*)(m_lumaFilter + rand_val), pixel_buff, rand_srcStride, (pixel*)IPF_vec_output,
+                                      rand_dstStride, rand_height, rand_width, BIT_DEPTH);
+            t->Stop();
+            printf("\nfilter[%s]\tVec: (%1.2f ms) ", FilterConf_names[value], t->ElapsedMS());
+
+            t->Start();
+            for (int j = 0; j < FILTER_ITERATIONS; j++)
+                ref.filter[value]((short*)(m_lumaFilter + rand_val), pixel_buff, rand_srcStride, (pixel*)IPF_vec_output,
+                                    rand_dstStride, rand_height, rand_width, BIT_DEPTH);
+            t->Stop();
+            printf("\tC: (%1.2f ms) ", t->ElapsedMS());
+        }
+    }
+
+    t->Release();
+}
--- a/source/test/filterharness.h	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/test/filterharness.h	Wed Apr 17 14:11:17 2013 +0530
@@ -1,53 +1,53 @@
-/*****************************************************************************
- * Copyright (C) 2013 x265 project
- *
- * Authors: Steve Borho <steve@borho.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
- *
- * This program is also available under a commercial proprietary license.
- * For more information, contact us at licensing@multicorewareinc.com.
- *****************************************************************************/
-
-#ifndef _FILTERHARNESS_H_1
-#define _FILTERHARNESS_H_1 1
-
-#include "testharness.h"
-#include "primitives.h"
-
-class FilterHarness : public TestHarness
-{
-protected:
-
-    pixel *pixel_buff;
-
-    short *IPF_vec_output, *IPF_C_output;
-
-    int ipf_t_size;
-
-    bool check_IPFilter_primitive(x265::IPFilter ref, x265::IPFilter opt);
-
-public:
-
-    FilterHarness();
-
-    virtual ~FilterHarness();
-
-    bool testCorrectness(const x265::EncoderPrimitives& ref, const x265::EncoderPrimitives& opt);
-
-    void measureSpeed(const x265::EncoderPrimitives& ref, const x265::EncoderPrimitives& opt);
-};
-
-#endif
+/*****************************************************************************
+ * Copyright (C) 2013 x265 project
+ *
+ * Authors: Steve Borho <steve@borho.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@multicorewareinc.com.
+ *****************************************************************************/
+
+#ifndef _FILTERHARNESS_H_1
+#define _FILTERHARNESS_H_1 1
+
+#include "testharness.h"
+#include "primitives.h"
+
+class FilterHarness : public TestHarness
+{
+protected:
+
+    pixel *pixel_buff;
+
+    short *IPF_vec_output, *IPF_C_output;
+
+    int ipf_t_size;
+
+    bool check_IPFilter_primitive(x265::IPFilter ref, x265::IPFilter opt);
+
+public:
+
+    FilterHarness();
+
+    virtual ~FilterHarness();
+
+    bool testCorrectness(const x265::EncoderPrimitives& ref, const x265::EncoderPrimitives& opt);
+
+    void measureSpeed(const x265::EncoderPrimitives& ref, const x265::EncoderPrimitives& opt);
+};
+
+#endif
--- a/source/test/mbdstharness.cpp	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/test/mbdstharness.cpp	Wed Apr 17 14:11:17 2013 +0530
@@ -1,113 +1,204 @@
-/*****************************************************************************
- * Copyright (C) 2013 x265 project
- *
- * Authors: Steve Borho <steve@borho.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
- *
- * This program is also available under a commercial proprietary license.
- * For more information, contact us at licensing@multicorewareinc.com.
- *****************************************************************************/
-
-#include "mbdstharness.h"
-#include <stdlib.h>
-#include <string.h>
-#include <stdio.h>
-
-using namespace x265;
-
-MBDstHarness::MBDstHarness()
-{
-    mb_t_size = 32;
-
-    mbuf1 = (short*)malloc(0x1e00 * sizeof(pixel));
-    mbuf2 = (short*)malloc(mb_t_size);
-    mbuf3 = (short*)malloc(mb_t_size);
-    if (!mbuf1 || !mbuf2 || !mbuf3)
-    {
-        fprintf(stderr, "malloc failed, unable to initiate tests!\n");
-        exit(1);
-    }
-
-    for (int i = 0; i < 64*100; i++)
-        mbuf1[i] = rand() & PIXEL_MAX;
-    memset(mbuf2, 0, mb_t_size);
-    memset(mbuf3, 0, mb_t_size);
-}
-
-MBDstHarness::~MBDstHarness()
-{
-    free(mbuf1);
-    free(mbuf2);
-    free(mbuf3);
-}
-
-bool MBDstHarness::check_mbdst_primitive(mbdst ref, mbdst opt)
-{
-    int j = 0;
-
-    for (int i = 0; i <= 100; i++)
-    {
-        opt(mbuf1 + j, mbuf2, 16);
-        ref(mbuf1 + j, mbuf3, 16);
-
-        if (memcmp(mbuf2, mbuf3, mb_t_size))
-            return false;
-
-        j += 16;
-        memset(mbuf2, 0, mb_t_size);
-        memset(mbuf3, 0, mb_t_size);
-    }
-
-    return true;
-}
-
-bool MBDstHarness::testCorrectness( const EncoderPrimitives& ref, const EncoderPrimitives& opt )
-{
-    if (opt.inversedst)
-    {
-        if (!check_mbdst_primitive(ref.inversedst, opt.inversedst))
-        {
-            printf("Inversedst: Failed!\n");
-            return false;
-        }
-    }
-
-    return true;
-}
-
-#define MBDST_ITERATIONS 4000000
-
-void MBDstHarness::measureSpeed( const EncoderPrimitives& ref, const EncoderPrimitives& opt )
-{
-    Timer *t = Timer::CreateTimer();
-
-    if (opt.inversedst)
-    {
-        t->Start();
-        for (int j = 0; j < MBDST_ITERATIONS; j++)
-            opt.inversedst(mbuf1, mbuf2, 16);
-        t->Stop();
-        printf("\nInverseDST\tVec: (%1.2f ms) ", t->ElapsedMS());
-
-        t->Start();
-        for (int j = 0; j < MBDST_ITERATIONS; j++)
-            ref.inversedst(mbuf1, mbuf2, 16);
-        t->Stop();
-        printf("\tC: (%1.2f ms) ", t->ElapsedMS());
-    }
-
-    t->Release();
-}
+/*****************************************************************************
+ * Copyright (C) 2013 x265 project
+ *
+ * Authors: Steve Borho <steve@borho.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@multicorewareinc.com.
+ *****************************************************************************/
+
+#include "mbdstharness.h"
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+
+using namespace x265;
+
+const char *ButterflyConf_names[] =
+{
+"4",
+"Inverse4",
+"8",
+"Inverse8",
+"16",
+"Inverse16",
+"32",
+"Inverse32"
+};
+
+enum Butterflies
+{
+    butterfly_4,
+    butterfly_inverse_4,
+    butterfly_8,
+    butterfly_inverse_8,
+    butterfly_16,
+    butterfly_inverse_16,
+    butterfly_32,
+    butterfly_inverse_32,
+    num_butterflies
+};
+
+MBDstHarness::MBDstHarness()
+{
+    mb_t_size = 6400;
+
+    mbuf1 = (short*)malloc(0x1e00 * sizeof(short));
+    mbuf2 = (short*)malloc(mb_t_size);
+    mbuf3 = (short*)malloc(mb_t_size);
+    if (!mbuf1 || !mbuf2 || !mbuf3)
+    {
+        fprintf(stderr, "malloc failed, unable to initiate tests!\n");
+        exit(1);
+    }
+
+    for (int i = 0; i < 64 * 100; i++)
+    {
+        mbuf1[i] = rand() & PIXEL_MAX;
+    }
+
+    memset(mbuf2, 0, mb_t_size);
+    memset(mbuf3, 0, mb_t_size);
+}
+
+MBDstHarness::~MBDstHarness()
+{
+    free(mbuf1);
+    free(mbuf2);
+    free(mbuf3);
+}
+
+bool MBDstHarness::check_mbdst_primitive(mbdst ref, mbdst opt)
+{
+    int j = 0;
+    int mem_cmp_size = 32;
+
+    for (int i = 0; i <= 100; i++)
+    {
+        opt(mbuf1 + j, mbuf2, 16);
+        ref(mbuf1 + j, mbuf3, 16);
+
+        if (memcmp(mbuf2, mbuf3, mem_cmp_size))
+            return false;
+
+        j += 16;
+        memset(mbuf2, 0, mem_cmp_size);
+        memset(mbuf3, 0, mem_cmp_size);
+    }
+
+    return true;
+}
+
+bool MBDstHarness::check_butterfly16_primitive(butterfly ref, butterfly opt)
+{
+    int j = 0;
+    int mem_cmp_size = 320; // 2*16*10 -> sizeof(short)*number of elements*number of lines
+
+    for (int i = 0; i <= 100; i++)
+    {
+        opt(mbuf1 + j, mbuf2, 3, 10);
+        ref(mbuf1 + j, mbuf3, 3, 10);
+
+        if (memcmp(mbuf2, mbuf3, mem_cmp_size))
+            return false;
+
+        j += 16;
+        memset(mbuf2, 0, mem_cmp_size);
+        memset(mbuf3, 0, mem_cmp_size);
+    }
+
+    return true;
+}
+
+bool MBDstHarness::testCorrectness(const EncoderPrimitives& ref, const EncoderPrimitives& opt)
+{
+    if (opt.inversedst)
+    {
+        if (!check_mbdst_primitive(ref.inversedst, opt.inversedst))
+        {
+            printf("Inversedst: Failed!\n");
+            return false;
+        }
+    }
+
+    if (opt.partial_butterfly[butterfly_16])
+    {
+        if (!check_butterfly16_primitive(ref.partial_butterfly[butterfly_16], opt.partial_butterfly[butterfly_16]))
+        {
+            printf("\npartialButterfly%s failed\n", ButterflyConf_names[butterfly_16]);
+            return false;
+        }
+    }
+
+    return true;
+}
+
+#define MBDST_ITERATIONS 4000000
+
+void MBDstHarness::measureSpeed(const EncoderPrimitives& ref, const EncoderPrimitives& opt)
+{
+    Timer *t = Timer::CreateTimer();
+
+    if (opt.inversedst)
+    {
+        t->Start();
+        for (int j = 0; j < MBDST_ITERATIONS; j++)
+        {
+            opt.inversedst(mbuf1, mbuf2, 16);
+        }
+
+        t->Stop();
+        printf("\nInverseDST\tVec: (%1.2f ms) ", t->ElapsedMS());
+
+        t->Start();
+        for (int j = 0; j < MBDST_ITERATIONS; j++)
+        {
+            ref.inversedst(mbuf1, mbuf2, 16);
+        }
+
+        t->Stop();
+        printf("\tC: (%1.2f ms) ", t->ElapsedMS());
+    }
+
+    for (int value = 0; value < 8; value++)
+    {
+        memset(mbuf2, 0, mb_t_size); // Initialize output buffer to zero
+        memset(mbuf3, 0, mb_t_size); // Initialize output buffer to zero
+        if (opt.partial_butterfly[value])
+        {
+            t->Start();
+            for (int j = 0; j < MBDST_ITERATIONS; j++)
+            {
+                opt.partial_butterfly[value](mbuf1, mbuf2, 3, 10);
+            }
+
+            t->Stop();
+            printf("\npartialButterfly%s\tVec: (%1.2f ms) ", ButterflyConf_names[value], t->ElapsedMS());
+
+            t->Start();
+            for (int j = 0; j < MBDST_ITERATIONS; j++)
+            {
+                ref.partial_butterfly[value](mbuf1, mbuf2, 3, 10);
+            }
+
+            t->Stop();
+            printf("\tC: (%1.2f ms) ", t->ElapsedMS());
+        }
+    }
+
+    t->Release();
+}
--- a/source/test/mbdstharness.h	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/test/mbdstharness.h	Wed Apr 17 14:11:17 2013 +0530
@@ -1,50 +1,52 @@
-/*****************************************************************************
- * Copyright (C) 2013 x265 project
- *
- * Authors: Steve Borho <steve@borho.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
- *
- * This program is also available under a commercial proprietary license.
- * For more information, contact us at licensing@multicorewareinc.com.
- *****************************************************************************/
-
-#ifndef _MBDSTHARNESS_H_1
-#define _MBDSTHARNESS_H_1 1
-
-#include "testharness.h"
-#include "primitives.h"
-
-class MBDstHarness : public TestHarness
-{
-protected:
-
-    short *mbuf1, *mbuf2, *mbuf3;
-
-    int mb_t_size;
-
-    bool check_mbdst_primitive(x265::mbdst ref, x265::mbdst opt);
-
-public:
-    MBDstHarness();
-
-    virtual ~MBDstHarness();
-
-    bool testCorrectness(const x265::EncoderPrimitives& ref, const x265::EncoderPrimitives& opt);
-
-    void measureSpeed(const x265::EncoderPrimitives& ref, const x265::EncoderPrimitives& opt);
-};
-
-#endif
+/*****************************************************************************
+ * Copyright (C) 2013 x265 project
+ *
+ * Authors: Steve Borho <steve@borho.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@multicorewareinc.com.
+ *****************************************************************************/
+
+#ifndef _MBDSTHARNESS_H_1
+#define _MBDSTHARNESS_H_1 1
+
+#include "testharness.h"
+#include "primitives.h"
+
+class MBDstHarness : public TestHarness
+{
+protected:
+
+    short *mbuf1, *mbuf2, *mbuf3;
+
+    int mb_t_size;
+
+    bool check_mbdst_primitive(x265::mbdst ref, x265::mbdst opt);
+    bool check_butterfly16_primitive(x265::butterfly ref, x265::butterfly opt);
+
+public:
+
+    MBDstHarness();
+
+    virtual ~MBDstHarness();
+
+    bool testCorrectness(const x265::EncoderPrimitives& ref, const x265::EncoderPrimitives& opt);
+
+    void measureSpeed(const x265::EncoderPrimitives& ref, const x265::EncoderPrimitives& opt);
+};
+
+#endif // ifndef _MBDSTHARNESS_H_1
--- a/source/test/pixelharness.cpp	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/test/pixelharness.cpp	Wed Apr 17 14:11:17 2013 +0530
@@ -1,205 +1,221 @@
-/*****************************************************************************
- * Copyright (C) 2013 x265 project
- *
- * Authors: Steve Borho <steve@borho.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
- *
- * This program is also available under a commercial proprietary license.
- * For more information, contact us at licensing@multicorewareinc.com.
- *****************************************************************************/
-
-#include "pixelharness.h"
-#include "primitives.h"
-#include <stdlib.h>
-#include <stdio.h>
-
-using namespace x265;
-
-// Initialize the Func Names for all the Pixel Comp
-static const char *FuncNames[NUM_PARTITIONS] =
-{
-    "4x4", "8x4", "4x8", "8x8", "4x16", "16x4", "8x16", "16x8", "16x16",
-    "4x32", "32x4", "8x32", "32x8", "16x32", "32x16", "32x32", "4x64",
-    "64x4", "8x64", "64x8", "16x64", "64x16", "32x64", "64x32", "64x64"
-};
-
-#if HIGH_BIT_DEPTH
-#define BIT_DEPTH 10
-#else
-#define BIT_DEPTH 8
-#endif
-
-#define PIXEL_MAX ((1 << BIT_DEPTH) - 1)
-
-#define PIXELCMP_ITERATIONS 2000000
-
-#define INCR 16
-#define STRIDE 16
-
-PixelHarness::PixelHarness()
-{
-    pbuf1 = (pixel*)malloc(0x1e00 * sizeof(pixel));
-    pbuf2 = (pixel*)malloc(0x1e00 * sizeof(pixel));
-    if (!pbuf1 || !pbuf2)
-    {
-        fprintf(stderr, "malloc failed, unable to initiate tests!\n");
-        exit(1);
-    }
-
-    for (int i = 0; i < 0x1e00; i++)
-    {
-        //Generate the Random Buffer for Testing
-        pbuf1[i] = rand() & PIXEL_MAX;
-        pbuf2[i] = rand() & PIXEL_MAX;
-    }
-}
-
-PixelHarness::~PixelHarness()
-{
-    free(pbuf1);
-    free(pbuf2);
-}
-
-bool PixelHarness::check_pixel_primitive(pixelcmp ref, pixelcmp opt)
-{
-    int j = 0;
-
-    for (int i = 0; i <= 100; i++)
-    {
-        int vres = opt(pbuf1, STRIDE, pbuf2 + j, STRIDE);
-        int cres = ref(pbuf1, STRIDE, pbuf2 + j, STRIDE);
-        if (vres != cres)
-            return false;
-
-        j += INCR;
-    }
-
-    return true;
-}
-
-bool PixelHarness::testCorrectness( const EncoderPrimitives& ref, const EncoderPrimitives& opt )
-{
-   for (uint16_t curpar = 0; curpar < NUM_PARTITIONS; curpar++)
-   {
-        if (opt.satd[curpar])
-        {
-            if (!check_pixel_primitive(ref.satd[curpar], opt.satd[curpar]))
-            {
-                printf("satd[%s]: failed!\n", FuncNames[curpar]);
-                return false;
-            }
-        }
-
-        if (opt.sad[curpar])
-        {
-            if (!check_pixel_primitive(ref.sad[curpar], opt.sad[curpar]))
-            {
-                printf("sad[%s]: failed!\n", FuncNames[curpar]);
-                return false;
-            }
-        }
-    }
-
-    if (opt.sa8d_8x8)
-    {
-        if (!check_pixel_primitive(ref.sa8d_8x8, opt.sa8d_8x8))
-        {
-            printf("sa8d_8x8: failed!\n");
-            return false;
-        }
-    }
-
-    if (opt.sa8d_16x16)
-    {
-        if (!check_pixel_primitive(ref.sa8d_16x16, opt.sa8d_16x16))
-        {
-            printf("sa8d_16x16: failed!\n");
-            return false;
-        }
-    }
-
-    return true;
-}
-
-void PixelHarness::measureSpeed(const EncoderPrimitives& ref, const EncoderPrimitives& opt)
-{
-    Timer *t = Timer::CreateTimer();
-
-    for (int curpar = 0; curpar < NUM_PARTITIONS; curpar++)
-    {
-        if (opt.satd[curpar])
-        {
-            t->Start();
-            for (int j = 0; j < PIXELCMP_ITERATIONS; j++)
-                opt.satd[curpar](pbuf1, STRIDE, pbuf2, STRIDE);
-            t->Stop();
-            printf("\nsatd[%s]\tVec: (%1.2f ms) ", FuncNames[curpar], t->ElapsedMS());
-
-            t->Start();
-            for (int j = 0; j < PIXELCMP_ITERATIONS; j++)
-                ref.satd[curpar](pbuf1, STRIDE, pbuf2, STRIDE);
-            t->Stop();
-            printf("\tC: (%1.2f ms) ", t->ElapsedMS());
-        }
-
-        if (opt.sad[curpar])
-        {
-            t->Start();
-            for (int j = 0; j < PIXELCMP_ITERATIONS; j++)
-                opt.sad[curpar](pbuf1, STRIDE, pbuf2, STRIDE);
-            t->Stop();
-            printf("\nsad[%s]\tVec: (%1.2f ms) ", FuncNames[curpar], t->ElapsedMS());
-
-            t->Start();
-            for (int j = 0; j < PIXELCMP_ITERATIONS; j++)
-                ref.sad[curpar](pbuf1, STRIDE, pbuf2, STRIDE);
-            t->Stop();
-            printf("\tC: (%1.2f ms) ", t->ElapsedMS());
-        }
-    }
-
-    if (opt.sa8d_8x8)
-    {
-        t->Start();
-        for (int j = 0; j < PIXELCMP_ITERATIONS; j++)
-            opt.sa8d_8x8(pbuf1, STRIDE, pbuf2, STRIDE);
-        t->Stop();
-        printf("\nsa8d_8x8\tVec: (%1.2f ms) ", t->ElapsedMS());
-
-        t->Start();
-        for (int j = 0; j < PIXELCMP_ITERATIONS; j++)
-            ref.sa8d_8x8(pbuf1, STRIDE, pbuf2, STRIDE);
-        t->Stop();
-        printf("\tC: (%1.2f ms) ", t->ElapsedMS());
-    }
-
-    if (opt.sa8d_16x16)
-    {
-        t->Start();
-        for (int j = 0; j < PIXELCMP_ITERATIONS; j++)
-            opt.sa8d_16x16(pbuf1, STRIDE, pbuf2, STRIDE);
-        t->Stop();
-        printf("\nsa8d_16x16\tVec: (%1.2f ms) ", t->ElapsedMS());
-
-        t->Start();
-        for (int j = 0; j < PIXELCMP_ITERATIONS; j++)
-            ref.sa8d_16x16(pbuf1, STRIDE, pbuf2, STRIDE);
-        t->Stop();
-        printf("\tC: (%1.2f ms) ", t->ElapsedMS());
-    }
-
-    t->Release();
-}
+/*****************************************************************************
+ * Copyright (C) 2013 x265 project
+ *
+ * Authors: Steve Borho <steve@borho.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@multicorewareinc.com.
+ *****************************************************************************/
+
+#include "pixelharness.h"
+#include "primitives.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <malloc.h>
+
+#ifdef __MINGW32__ 
+#define _aligned_malloc __mingw_aligned_malloc 
+#define _aligned_free  __mingw_aligned_free 
+#endif
+
+using namespace x265;
+
+// Initialize the Func Names for all the Pixel Comp
+static const char *FuncNames[NUM_PARTITIONS] =
+{
+    "4x4", "8x4", "4x8", "8x8", "4x16", "16x4", "8x16", "16x8", "16x16",
+    "4x32", "32x4", "8x32", "32x8", "16x32", "32x16", "32x32", "4x64",
+    "64x4", "8x64", "64x8", "16x64", "64x16", "32x64", "64x32", "64x64"
+};
+
+#if HIGH_BIT_DEPTH
+#define BIT_DEPTH 10
+#else
+#define BIT_DEPTH 8
+#endif
+
+#define PIXEL_MAX ((1 << BIT_DEPTH) - 1)
+
+PixelHarness::PixelHarness()
+{
+#if _WIN32
+    pbuf1 = (pixel*)_aligned_malloc(0x1e00 * sizeof(pixel), 32);
+    pbuf2 = (pixel*)_aligned_malloc(0x1e00 * sizeof(pixel), 32);
+#else
+    posix_memalign((void**)&pbuf1, 32, 0x1e00 * sizeof(pixel));
+    posix_memalign((void**)&pbuf2, 32, 0x1e00 * sizeof(pixel));
+#endif
+    if (!pbuf1 || !pbuf2)
+    {
+        fprintf(stderr, "malloc failed, unable to initiate tests!\n");
+        exit(1);
+    }
+
+    for (int i = 0; i < 0x1e00; i++)
+    {
+        //Generate the Random Buffer for Testing
+        pbuf1[i] = rand() & PIXEL_MAX;
+        pbuf2[i] = rand() & PIXEL_MAX;
+    }
+}
+
+PixelHarness::~PixelHarness()
+{
+#if _WIN32
+    _aligned_free(pbuf1);
+    _aligned_free(pbuf2);
+#else
+    free(pbuf1);
+    free(pbuf2);
+#endif
+}
+
+#define INCR 16
+#define STRIDE 16
+
+bool PixelHarness::check_pixel_primitive(pixelcmp ref, pixelcmp opt)
+{
+    int j = 0;
+
+    for (int i = 0; i <= 100; i++)
+    {
+        int vres = opt(pbuf1, STRIDE, pbuf2 + j, STRIDE);
+        int cres = ref(pbuf1, STRIDE, pbuf2 + j, STRIDE);
+        if (vres != cres)
+            return false;
+
+        j += INCR;
+    }
+
+    return true;
+}
+
+bool PixelHarness::testCorrectness( const EncoderPrimitives& ref, const EncoderPrimitives& opt )
+{
+   for (uint16_t curpar = 0; curpar < NUM_PARTITIONS; curpar++)
+   {
+        if (opt.satd[curpar])
+        {
+            if (!check_pixel_primitive(ref.satd[curpar], opt.satd[curpar]))
+            {
+                printf("satd[%s]: failed!\n", FuncNames[curpar]);
+                return false;
+            }
+        }
+
+        if (opt.sad[curpar])
+        {
+            if (!check_pixel_primitive(ref.sad[curpar], opt.sad[curpar]))
+            {
+                printf("sad[%s]: failed!\n", FuncNames[curpar]);
+                return false;
+            }
+        }
+    }
+
+    if (opt.sa8d_8x8)
+    {
+        if (!check_pixel_primitive(ref.sa8d_8x8, opt.sa8d_8x8))
+        {
+            printf("sa8d_8x8: failed!\n");
+            return false;
+        }
+    }
+
+    if (opt.sa8d_16x16)
+    {
+        if (!check_pixel_primitive(ref.sa8d_16x16, opt.sa8d_16x16))
+        {
+            printf("sa8d_16x16: failed!\n");
+            return false;
+        }
+    }
+
+    return true;
+}
+
+#define PIXELCMP_ITERATIONS 2000000
+
+void PixelHarness::measureSpeed(const EncoderPrimitives& ref, const EncoderPrimitives& opt)
+{
+    Timer *t = Timer::CreateTimer();
+
+    for (int curpar = 0; curpar < NUM_PARTITIONS; curpar++)
+    {
+        if (opt.satd[curpar])
+        {
+            t->Start();
+            for (int j = 0; j < PIXELCMP_ITERATIONS; j++)
+                opt.satd[curpar](pbuf1, STRIDE, pbuf2, STRIDE);
+            t->Stop();
+            printf("\nsatd[%s]\tVec: (%1.2f ms) ", FuncNames[curpar], t->ElapsedMS());
+
+            t->Start();
+            for (int j = 0; j < PIXELCMP_ITERATIONS; j++)
+                ref.satd[curpar](pbuf1, STRIDE, pbuf2, STRIDE);
+            t->Stop();
+            printf("\tC: (%1.2f ms) ", t->ElapsedMS());
+        }
+
+        if (opt.sad[curpar])
+        {
+            t->Start();
+            for (int j = 0; j < PIXELCMP_ITERATIONS; j++)
+                opt.sad[curpar](pbuf1, STRIDE, pbuf2, STRIDE);
+            t->Stop();
+            printf("\nsad[%s]\tVec: (%1.2f ms) ", FuncNames[curpar], t->ElapsedMS());
+
+            t->Start();
+            for (int j = 0; j < PIXELCMP_ITERATIONS; j++)
+                ref.sad[curpar](pbuf1, STRIDE, pbuf2, STRIDE);
+            t->Stop();
+            printf("\tC: (%1.2f ms) ", t->ElapsedMS());
+        }
+    }
+
+    if (opt.sa8d_8x8)
+    {
+        t->Start();
+        for (int j = 0; j < PIXELCMP_ITERATIONS; j++)
+            opt.sa8d_8x8(pbuf1, STRIDE, pbuf2, STRIDE);
+        t->Stop();
+        printf("\nsa8d_8x8\tVec: (%1.2f ms) ", t->ElapsedMS());
+
+        t->Start();
+        for (int j = 0; j < PIXELCMP_ITERATIONS; j++)
+            ref.sa8d_8x8(pbuf1, STRIDE, pbuf2, STRIDE);
+        t->Stop();
+        printf("\tC: (%1.2f ms) ", t->ElapsedMS());
+    }
+
+    if (opt.sa8d_16x16)
+    {
+        t->Start();
+        for (int j = 0; j < PIXELCMP_ITERATIONS; j++)
+            opt.sa8d_16x16(pbuf1, STRIDE, pbuf2, STRIDE);
+        t->Stop();
+        printf("\nsa8d_16x16\tVec: (%1.2f ms) ", t->ElapsedMS());
+
+        t->Start();
+        for (int j = 0; j < PIXELCMP_ITERATIONS; j++)
+            ref.sa8d_16x16(pbuf1, STRIDE, pbuf2, STRIDE);
+        t->Stop();
+        printf("\tC: (%1.2f ms) ", t->ElapsedMS());
+    }
+
+    t->Release();
+}
--- a/source/test/pixelharness.h	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/test/pixelharness.h	Wed Apr 17 14:11:17 2013 +0530
@@ -1,48 +1,48 @@
-/*****************************************************************************
- * Copyright (C) 2013 x265 project
- *
- * Authors: Steve Borho <steve@borho.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
- *
- * This program is also available under a commercial proprietary license.
- * For more information, contact us at licensing@multicorewareinc.com.
- *****************************************************************************/
-
-#ifndef _PIXELHARNESS_H_1
-#define _PIXELHARNESS_H_1 1
-
-#include "testharness.h"
-#include "primitives.h"
-
-class PixelHarness : public TestHarness
-{
-protected:
-
-    pixel *pbuf1, *pbuf2;
-
-    bool check_pixel_primitive(x265::pixelcmp ref, x265::pixelcmp opt);
-
-public:
-    PixelHarness();
-
-    virtual ~PixelHarness();
-
-    bool testCorrectness(const x265::EncoderPrimitives& ref, const x265::EncoderPrimitives& opt);
-
-    void measureSpeed(const x265::EncoderPrimitives& ref, const x265::EncoderPrimitives& opt );
-};
-
-#endif
+/*****************************************************************************
+ * Copyright (C) 2013 x265 project
+ *
+ * Authors: Steve Borho <steve@borho.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@multicorewareinc.com.
+ *****************************************************************************/
+
+#ifndef _PIXELHARNESS_H_1
+#define _PIXELHARNESS_H_1 1
+
+#include "testharness.h"
+#include "primitives.h"
+
+class PixelHarness : public TestHarness
+{
+protected:
+
+    pixel *pbuf1, *pbuf2;
+
+    bool check_pixel_primitive(x265::pixelcmp ref, x265::pixelcmp opt);
+
+public:
+    PixelHarness();
+
+    virtual ~PixelHarness();
+
+    bool testCorrectness(const x265::EncoderPrimitives& ref, const x265::EncoderPrimitives& opt);
+
+    void measureSpeed(const x265::EncoderPrimitives& ref, const x265::EncoderPrimitives& opt );
+};
+
+#endif
--- a/source/test/testbench.cpp	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/test/testbench.cpp	Wed Apr 17 14:11:17 2013 +0530
@@ -56,7 +56,8 @@ int main(int argc, char *argv[])
     MBDstHarness  HMBDist;
 
     // To disable classes of tests, simply comment them out in this list
-    TestHarness *harness[] = {
+    TestHarness *harness[] =
+    {
         &HPixel,
         &HFilter,
         &HMBDist
@@ -72,7 +73,7 @@ int main(int argc, char *argv[])
         memset(&vecprim, 0, sizeof(vecprim));
         Setup_Vector_Primitives(vecprim, i);
         printf("Testing vector class primitives: CPUID %d\n", i);
-        for (int h = 0; h < sizeof(harness)/sizeof(TestHarness*); h++)
+        for (int h = 0; h < sizeof(harness) / sizeof(TestHarness*); h++)
         {
             if (!harness[h]->testCorrectness(cprim, vecprim))
             {
@@ -80,14 +81,15 @@ int main(int argc, char *argv[])
                 return -1;
             }
         }
-#endif
+
+#endif // if ENABLE_VECTOR_PRIMITIVES
 
 #if ENABLE_ASM_PRIMITIVES
         EncoderPrimitives asmprim;
         memset(&asmprim, 0, sizeof(asmprim));
         Setup_Assembly_Primitives(asmprim, i);
         printf("Testing assembly primitives: CPUID %d\n", i);
-        for (int h = 0; h < sizeof(harness)/sizeof(TestHarness*); h++)
+        for (int h = 0; h < sizeof(harness) / sizeof(TestHarness*); h++)
         {
             if (!harness[h]->testCorrectness(cprim, vecprim))
             {
@@ -95,11 +97,12 @@ int main(int argc, char *argv[])
                 return -1;
             }
         }
+
 #endif // if ENABLE_ASM_PRIMITIVES
     }
+
     fprintf(stderr, "\nx265: All tests passed Yeah :)\n");
 
-
     /******************* Cycle count for all primitives **********************/
 
     EncoderPrimitives optprim;
@@ -111,8 +114,10 @@ int main(int argc, char *argv[])
     Setup_Assembly_Primitives(optprim, cpuid);
 #endif
 
-    for (int h = 0; h < sizeof(harness)/sizeof(TestHarness*); h++)
+    for (int h = 0; h < sizeof(harness) / sizeof(TestHarness*); h++)
+    {
         harness[h]->measureSpeed(cprim, optprim);
+    }
 
     printf("\n");
 
--- a/source/test/testharness.h	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/test/testharness.h	Wed Apr 17 14:11:17 2013 +0530
@@ -1,66 +1,66 @@
-/*****************************************************************************
- * Copyright (C) 2013 x265 project
- *
- * Authors: Steve Borho <steve@borho.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
- *
- * This program is also available under a commercial proprietary license.
- * For more information, contact us at licensing@multicorewareinc.com.
- *****************************************************************************/
-
-#ifndef _TESTHARNESS_H_
-#define _TESTHARNESS_H_ 1
-
-#include "primitives.h"
-
-#if HIGH_BIT_DEPTH
-#define BIT_DEPTH 10
-#else
-#define BIT_DEPTH 8
-#endif
-#define PIXEL_MAX ((1 << BIT_DEPTH) - 1)
-
-class TestHarness
-{
-public:
-    TestHarness() {}
-
-    virtual ~TestHarness() {}
-
-    virtual bool testCorrectness(const x265::EncoderPrimitives& ref, const x265::EncoderPrimitives& opt) = 0;
-
-    virtual void measureSpeed(const x265::EncoderPrimitives& ref, const x265::EncoderPrimitives& opt) = 0;
-};
-
-class Timer
-{
-public:
-    Timer() {}
-
-    virtual ~Timer() {}
-
-    static Timer *CreateTimer();
-
-    virtual void Start() = 0;
-
-    virtual void Stop() = 0;
-
-    virtual float ElapsedMS() = 0;
-
-    virtual void Release() = 0;
-};
-
-#endif
+/*****************************************************************************
+ * Copyright (C) 2013 x265 project
+ *
+ * Authors: Steve Borho <steve@borho.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
+ *
+ * This program is also available under a commercial proprietary license.
+ * For more information, contact us at licensing@multicorewareinc.com.
+ *****************************************************************************/
+
+#ifndef _TESTHARNESS_H_
+#define _TESTHARNESS_H_ 1
+
+#include "primitives.h"
+
+#if HIGH_BIT_DEPTH
+#define BIT_DEPTH 10
+#else
+#define BIT_DEPTH 8
+#endif
+#define PIXEL_MAX ((1 << BIT_DEPTH) - 1)
+
+class TestHarness
+{
+public:
+    TestHarness() {}
+
+    virtual ~TestHarness() {}
+
+    virtual bool testCorrectness(const x265::EncoderPrimitives& ref, const x265::EncoderPrimitives& opt) = 0;
+
+    virtual void measureSpeed(const x265::EncoderPrimitives& ref, const x265::EncoderPrimitives& opt) = 0;
+};
+
+class Timer
+{
+public:
+    Timer() {}
+
+    virtual ~Timer() {}
+
+    static Timer *CreateTimer();
+
+    virtual void Start() = 0;
+
+    virtual void Stop() = 0;
+
+    virtual float ElapsedMS() = 0;
+
+    virtual void Release() = 0;
+};
+
+#endif
--- a/source/test/testpool.cpp	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/test/testpool.cpp	Wed Apr 17 14:11:17 2013 +0530
@@ -167,7 +167,8 @@ void MD5Frame::ProcessRow(int rownum)
         {
             ScopedLock below(this->row[rownum + 1].lock);
 
-            if (this->row[rownum + 1].active == false)
+            if (this->row[rownum + 1].active == false &&
+                this->row[rownum + 1].curCol + 2 <= curRow.curCol)
             {
                 // set active indicator so row is only enqueued once
                 // row stays marked active until blocked or done
--- a/source/test/timer.cpp	Wed Apr 17 14:09:10 2013 +0530
+++ b/source/test/timer.cpp	Wed Apr 17 14:11:17 2013 +0530
@@ -23,58 +23,40 @@
 
 #include "testharness.h"
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
+#if _WIN32
+
+#include <Windows.h>
+
+class TimerImpl : public Timer
+{
+protected:
+
+    LARGE_INTEGER freq;
+
+    LARGE_INTEGER start, finish;
+
+public:
+
+    TimerImpl()         { QueryPerformanceFrequency(&freq); }
+
+    void Start()        { QueryPerformanceCounter(&start); }
+
+    void Stop()         { QueryPerformanceCounter(&finish); }
+
+    float ElapsedMS()
+    {
+        return ((float)(finish.QuadPart - start.QuadPart) / freq.QuadPart) * 1000.0f;
+    }
+
+    void Release()      { delete this; }
+};
+
+#else
+
 #include <sys/types.h>
 #include <sys/timeb.h>
-
-// Code snippet from http://www.winehq.org/pipermail/wine-devel/2003-June/018082.html begins
-// this part is windows implementation of Gettimeoffday() function
-
-#ifndef _TIMEVAL_H
-#ifdef _WIN32
-
-#define WIN32_LEAN_AND_MEAN
-#include <winsock2.h>
-
-#if defined(_MSC_VER)
-#define EPOCHFILETIME (116444736000000000i64)
-#else
-#define EPOCHFILETIME (116444736000000000LL)
-#endif
-
-int gettimeofday(struct timeval *tv, struct timezone *tz)
-{
-    FILETIME        ft;
-    LARGE_INTEGER   li;
-    __int64         t;
-
-    if (tv)
-    {
-        GetSystemTimeAsFileTime(&ft);
-        li.LowPart  = ft.dwLowDateTime;
-        li.HighPart = ft.dwHighDateTime;
-        t  = li.QuadPart;       /* In 100-nanosecond intervals */
-        t -= EPOCHFILETIME;     /* Offset to the Epoch time */
-        t /= 10;                /* In microseconds */
-        tv->tv_sec  = (long)(t / 1000000);
-        tv->tv_usec = (long)(t % 1000000);
-    }
-
-    return 0;
-}
-
-#else  /* _WIN32 */
-
 #include <sys/time.h>
 
-#endif /* _WIN32 */
-#endif /* _TIMEVAL_H */
-
-// Code snippet from http://www.winehq.org/pipermail/wine-devel/2003-June/018082.html ends
-
-
 class TimerImpl : public Timer
 {
 protected:
@@ -83,33 +65,22 @@ protected:
 
 public:
 
-    void Start();
+    void Start()        { gettimeofday(&start, 0); }
 
-    void Stop();
+    void Stop()         { gettimeofday(&finish, 0); }
 
-    float ElapsedMS();
+    float ElapsedMS()
+    {
+        return (finish.tv_sec - start.tv_sec) * 1000 +
+        (float)(finish.tv_usec - start.tv_usec) / 1000;
+    }
 
     void Release()      { delete this; }
 };
 
+#endif /* _WIN32 */
+
 Timer *Timer::CreateTimer()
 {
     return new TimerImpl();
 }
-
-void TimerImpl::Start()
-{
-    gettimeofday(&start, NULL);
-}
-
-void TimerImpl::Stop()
-{
-    gettimeofday(&finish, NULL);
-}
-
-float TimerImpl::ElapsedMS()
-{
-    float msec = (finish.tv_sec - start.tv_sec) * 1000;
-    msec += (float)(finish.tv_usec - start.tv_usec) / 1000;
-    return msec;
-}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source/x265cfg.cpp	Wed Apr 17 14:11:17 2013 +0530
@@ -0,0 +1,1937 @@
+/* The copyright in this software is being made available under the BSD
+ * License, included below. This software may be subject to other third party
+ * and contributor rights, including patent rights, and no such rights are
+ * granted under this license.
+ *
+ * Copyright (c) 2010-2013, ITU/ISO/IEC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  * Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
+ *    be used to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** \file     TAppEncCfg.cpp
+    \brief    Handle encoder configuration parameters
+*/
+
+#include <stdlib.h>
+#include <cassert>
+#include <cstring>
+#include <string>
+#include <math.h>
+#include "TLibCommon/TComRom.h"
+#include "x265cfg.h"
+
+static istream &operator >>(istream &, Level::Name &);
+static istream &operator >>(istream &, Level::Tier &);
+static istream &operator >>(istream &, Profile::Name &);
+
+#include "TAppCommon/program_options_lite.h"
+#include "TLibEncoder/TEncRateCtrl.h"
+
+#ifdef WIN32
+#define strdup _strdup
+#endif
+
+using namespace std;
+namespace po = df::program_options_lite;
+
+//! \ingroup TAppEncoder
+//! \{
+
+// ====================================================================================================================
+// Constructor / destructor / initialization / destroy
+// ====================================================================================================================
+
+TAppEncCfg::TAppEncCfg()
+    : m_pchInputFile()
+    , m_pchBitstreamFile()
+    , m_pchReconFile()
+    , m_pchdQPFile()
+    , m_pColumnWidth()
+    , m_pRowHeight()
+    , m_scalingListFile()
+{
+    m_aidQP = NULL;
+#if J0149_TONE_MAPPING_SEI
+    m_startOfCodedInterval = NULL;
+    m_codedPivotValue = NULL;
+    m_targetPivotValue = NULL;
+#endif
+}
+
+TAppEncCfg::~TAppEncCfg()
+{
+    if (m_aidQP)
+    {
+        delete[] m_aidQP;
+    }
+
+#if J0149_TONE_MAPPING_SEI
+    if (m_startOfCodedInterval)
+    {
+        delete[] m_startOfCodedInterval;
+        m_startOfCodedInterval = NULL;
+    }
+
+    if (m_codedPivotValue)
+    {
+        delete[] m_codedPivotValue;
+        m_codedPivotValue = NULL;
+    }
+
+    if (m_targetPivotValue)
+    {
+        delete[] m_targetPivotValue;
+        m_targetPivotValue = NULL;
+    }
+
+#endif // if J0149_TONE_MAPPING_SEI
+    free(m_pchInputFile);
+    free(m_pchBitstreamFile);
+    free(m_pchReconFile);
+    free(m_pchdQPFile);
+    free(m_pColumnWidth);
+    free(m_pRowHeight);
+    free(m_scalingListFile);
+}
+
+Void TAppEncCfg::create()
+{}
+
+Void TAppEncCfg::destroy()
+{}
+
+std::istringstream &operator >>(std::istringstream &in, GOPEntry &entry)     //input
+{
+    in >> entry.m_sliceType;
+    in >> entry.m_POC;
+    in >> entry.m_QPOffset;
+    in >> entry.m_QPFactor;
+    in >> entry.m_tcOffsetDiv2;
+    in >> entry.m_betaOffsetDiv2;
+    in >> entry.m_temporalId;
+    in >> entry.m_numRefPicsActive;
+    in >> entry.m_numRefPics;
+    for (Int i = 0; i < entry.m_numRefPics; i++)
+    {
+        in >> entry.m_referencePics[i];
+    }
+
+    in >> entry.m_interRPSPrediction;
+#if AUTO_INTER_RPS
+    if (entry.m_interRPSPrediction == 1)
+    {
+        in >> entry.m_deltaRPS;
+        in >> entry.m_numRefIdc;
+        for (Int i = 0; i < entry.m_numRefIdc; i++)
+        {
+            in >> entry.m_refIdc[i];
+        }
+    }
+    else if (entry.m_interRPSPrediction == 2)
+    {
+        in >> entry.m_deltaRPS;
+    }
+
+#else // if AUTO_INTER_RPS
+    if (entry.m_interRPSPrediction)
+    {
+        in >> entry.m_deltaRPS;
+        in >> entry.m_numRefIdc;
+        for (Int i = 0; i < entry.m_numRefIdc; i++)
+        {
+            in >> entry.m_refIdc[i];
+        }
+    }
+
+#endif // if AUTO_INTER_RPS
+    return in;
+}
+
+static const struct MapStrToProfile
+{
+    const Char *str;
+    Profile::Name value;
+} strToProfile[] =
+{
+    { "none", Profile::NONE },
+    { "main", Profile::MAIN },
+    { "main10", Profile::MAIN10 },
+    { "main-still-picture", Profile::MAINSTILLPICTURE },
+};
+
+static const struct MapStrToTier
+{
+    const Char *str;
+    Level::Tier value;
+} strToTier[] =
+{
+    { "main", Level::MAIN },
+    { "high", Level::HIGH },
+};
+
+static const struct MapStrToLevel
+{
+    const Char *str;
+    Level::Name value;
+} strToLevel[] =
+{
+    { "none", Level::NONE },
+    { "1",   Level::LEVEL1 },
+    { "2",   Level::LEVEL2 },
+    { "2.1", Level::LEVEL2_1 },
+    { "3",   Level::LEVEL3 },
+    { "3.1", Level::LEVEL3_1 },
+    { "4",   Level::LEVEL4 },
+    { "4.1", Level::LEVEL4_1 },
+    { "5",   Level::LEVEL5 },
+    { "5.1", Level::LEVEL5_1 },
+    { "5.2", Level::LEVEL5_2 },
+    { "6",   Level::LEVEL6 },
+    { "6.1", Level::LEVEL6_1 },
+    { "6.2", Level::LEVEL6_2 },
+};
+
+template<typename T, typename P>
+static istream &readStrToEnum(P map[], unsigned long mapLen, istream &in, T &val)
+{
+    string str;
+
+    in >> str;
+
+    for (Int i = 0; i < mapLen; i++)
+    {
+        if (str == map[i].str)
+        {
+            val = map[i].value;
+            goto found;
+        }
+    }
+
+    /* not found */
+    in.setstate(ios::failbit);
+found:
+    return in;
+}
+
+static istream &operator >>(istream &in, Profile::Name &profile)
+{
+    return readStrToEnum(strToProfile, sizeof(strToProfile) / sizeof(*strToProfile), in, profile);
+}
+
+static istream &operator >>(istream &in, Level::Tier &tier)
+{
+    return readStrToEnum(strToTier, sizeof(strToTier) / sizeof(*strToTier), in, tier);
+}
+
+static istream &operator >>(istream &in, Level::Name &level)
+{
+    return readStrToEnum(strToLevel, sizeof(strToLevel) / sizeof(*strToLevel), in, level);
+}
+
+#if SIGNAL_BITRATE_PICRATE_IN_VPS
+Void readBoolString(const string inpString, const Int numEntries, Bool* &memberArray, const char *elementName);
+Void readIntString(const string inpString, const Int numEntries, Int* &memberArray, const char *elementName);
+#endif
+// ====================================================================================================================
+// Public member functions
+// ====================================================================================================================
+
+/** \param  argc        number of arguments
+    \param  argv        array of arguments
+    \retval             true when success
+ */
+Bool TAppEncCfg::parseCfg(Int argc, Char *argv[])
+
+{
+    Bool do_help = false;
+
+    string cfg_InputFile;
+    string cfg_BitstreamFile;
+    string cfg_ReconFile;
+    string cfg_dQPFile;
+    string cfg_ColumnWidth;
+    string cfg_RowHeight;
+    string cfg_ScalingListFile;
+
+#if J0149_TONE_MAPPING_SEI
+    string cfg_startOfCodedInterval;
+    string cfg_codedPivotValue;
+    string cfg_targetPivotValue;
+#endif
+#if SIGNAL_BITRATE_PICRATE_IN_VPS
+    string cfg_bitRateInfoPresentFlag;
+    string cfg_picRateInfoPresentFlag;
+    string cfg_avgBitRate;
+    string cfg_maxBitRate;
+    string cfg_avgPicRate;
+    string cfg_constantPicRateIdc;
+#endif
+    po::Options opts;
+    opts.addOptions()
+        ("help", do_help, false, "this help text")
+        ("c", po::parseConfigFile, "configuration file name")
+
+    // File, I/O and source parameters
+        ("InputFile,i",           cfg_InputFile,     string(""), "Original YUV input file name")
+        ("BitstreamFile,b",       cfg_BitstreamFile, string(""), "Bitstream output file name")
+        ("ReconFile,o",           cfg_ReconFile,     string(""), "Reconstructed YUV output file name")
+        ("SourceWidth,-wdt",      m_iSourceWidth,        0, "Source picture width")
+        ("SourceHeight,-hgt",     m_iSourceHeight,       0, "Source picture height")
+        ("InputBitDepth",         m_inputBitDepthY,    8, "Bit-depth of input file")
+        ("OutputBitDepth",        m_outputBitDepthY,   0, "Bit-depth of output file (default:InternalBitDepth)")
+        ("InternalBitDepth",      m_internalBitDepthY, 0, "Bit-depth the codec operates at. (default:InputBitDepth)"
+        "If different to InputBitDepth, source data will be converted")
+        ("InputBitDepthC",        m_inputBitDepthC,    0,
+        "As per InputBitDepth but for chroma component. (default:InputBitDepth)")
+        ("OutputBitDepthC",       m_outputBitDepthC,   0,
+        "As per OutputBitDepth but for chroma component. (default:InternalBitDepthC)")
+        ("InternalBitDepthC",     m_internalBitDepthC, 0,
+        "As per InternalBitDepth but for chroma component. (default:IntrenalBitDepth)")
+        ("ConformanceMode",       m_conformanceMode,     0,
+        "Window conformance mode (0: no window, 1:automatic padding, 2:padding, 3:conformance")
+        ("HorizontalPadding,-pdx", m_aiPad[0],            0, "Horizontal source padding for conformance window mode 2")
+        ("VerticalPadding,-pdy",  m_aiPad[1],            0, "Vertical source padding for conformance window mode 2")
+        ("ConfLeft",              m_confLeft,            0, "Left offset for window conformance mode 3")
+        ("ConfRight",             m_confRight,           0, "Right offset for window conformance mode 3")
+        ("ConfTop",               m_confTop,             0, "Top offset for window conformance mode 3")
+        ("ConfBottom",            m_confBottom,          0, "Bottom offset for window conformance mode 3")
+        ("FrameRate,-fr",         m_iFrameRate,          0, "Frame rate")
+        ("FrameSkip,-fs",         m_FrameSkip,          0u, "Number of frames to skip at start of input YUV")
+        ("FramesToBeEncoded,f",   m_framesToBeEncoded,   0, "Number of frames to be encoded (default=all)")
+
+    // Profile and level
+        ("Profile", m_profile,   Profile::NONE, "Profile to be used when encoding (Incomplete)")
+        ("Level",   m_level,     Level::NONE,   "Level limit to be used, eg 5.1 (Incomplete)")
+        ("Tier",    m_levelTier, Level::MAIN,   "Tier to use for interpretation of --Level")
+
+#if L0046_CONSTRAINT_FLAGS
+    ("ProgressiveSource", m_progressiveSourceFlag, false, "Indicate that source is progressive")
+        ("InterlacedSource",  m_interlacedSourceFlag,  false, "Indicate that source is interlaced")
+        ("NonPackedSource",   m_nonPackedConstraintFlag, false, "Indicate that source does not contain frame packing")
+        ("FrameOnly",         m_frameOnlyConstraintFlag, false, "Indicate that the bitstream contains only frames")
+#endif
+
+    // Unit definition parameters
+    ("MaxCUWidth",              m_uiMaxCUWidth,             64u)
+        ("MaxCUHeight",             m_uiMaxCUHeight,            64u)
+    // todo: remove defaults from MaxCUSize
+        ("MaxCUSize,s",             m_uiMaxCUWidth,             64u, "Maximum CU size")
+        ("MaxCUSize,s",             m_uiMaxCUHeight,            64u, "Maximum CU size")
+        ("MaxPartitionDepth,h",     m_uiMaxCUDepth,              4u, "CU depth")
+
+        ("QuadtreeTULog2MaxSize",   m_uiQuadtreeTULog2MaxSize,   6u, "Maximum TU size in logarithm base 2")
+        ("QuadtreeTULog2MinSize",   m_uiQuadtreeTULog2MinSize,   2u, "Minimum TU size in logarithm base 2")
+
+        ("QuadtreeTUMaxDepthIntra", m_uiQuadtreeTUMaxDepthIntra, 1u, "Depth of TU tree for intra CUs")
+        ("QuadtreeTUMaxDepthInter", m_uiQuadtreeTUMaxDepthInter, 2u, "Depth of TU tree for inter CUs")
+
+    // Coding structure paramters
+        ("IntraPeriod,-ip",         m_iIntraPeriod,              -1, "Intra period in frames, (-1: only first frame)")
+        ("DecodingRefreshType,-dr", m_iDecodingRefreshType,       0, "Intra refresh type (0:none 1:CRA 2:IDR)")
+        ("GOPSize,g",               m_iGOPSize,                   1, "GOP size of temporal structure")
+        ("ListCombination,-lc",     m_bUseLComb,               true,
+        "Combined reference list for uni-prediction estimation in B-slices")
+    // motion options
+        ("FastSearch",              m_iFastSearch,                1, "0:Full search  1:Diamond  2:PMVFAST")
+        ("SearchRange,-sr",         m_iSearchRange,              96, "Motion search range")
+        ("BipredSearchRange",       m_bipredSearchRange,          4, "Motion search range for bipred refinement")
+        ("HadamardME",              m_bUseHADME,               true, "Hadamard ME for fractional-pel")
+        ("ASR",                     m_bUseASR,                false, "Adaptive motion search range")
+
+    // Mode decision parameters
+        ("LambdaModifier0,-LM0", m_adLambdaModifier[0], (Double)1.0, "Lambda modifier for temporal layer 0")
+        ("LambdaModifier1,-LM1", m_adLambdaModifier[1], (Double)1.0, "Lambda modifier for temporal layer 1")
+        ("LambdaModifier2,-LM2", m_adLambdaModifier[2], (Double)1.0, "Lambda modifier for temporal layer 2")
+        ("LambdaModifier3,-LM3", m_adLambdaModifier[3], (Double)1.0, "Lambda modifier for temporal layer 3")
+        ("LambdaModifier4,-LM4", m_adLambdaModifier[4], (Double)1.0, "Lambda modifier for temporal layer 4")
+        ("LambdaModifier5,-LM5", m_adLambdaModifier[5], (Double)1.0, "Lambda modifier for temporal layer 5")
+        ("LambdaModifier6,-LM6", m_adLambdaModifier[6], (Double)1.0, "Lambda modifier for temporal layer 6")
+        ("LambdaModifier7,-LM7", m_adLambdaModifier[7], (Double)1.0, "Lambda modifier for temporal layer 7")
+
+    /* Quantization parameters */
+        ("QP,q",          m_fQP,             30.0, "Qp value, if value is float, QP is switched once during encoding")
+        ("DeltaQpRD,-dqr", m_uiDeltaQpRD,       0u, "max dQp offset for slice")
+        ("MaxDeltaQP,d",  m_iMaxDeltaQP,        0, "max dQp offset for block")
+        ("MaxCuDQPDepth,-dqd",  m_iMaxCuDQPDepth,        0, "max depth for a minimum CuDQP")
+
+        ("CbQpOffset,-cbqpofs",  m_cbQpOffset,        0, "Chroma Cb QP Offset")
+        ("CrQpOffset,-crqpofs",  m_crQpOffset,        0, "Chroma Cr QP Offset")
+
+#if ADAPTIVE_QP_SELECTION
+    ("AdaptiveQpSelection,-aqps",   m_bUseAdaptQpSelect,           false, "AdaptiveQpSelection")
+#endif
+
+    ("AdaptiveQP,-aq",                m_bUseAdaptiveQP,           false, "QP adaptation based on a psycho-visual model")
+        ("MaxQPAdaptationRange,-aqr",     m_iQPAdaptationRange,           6, "QP adaptation range")
+        ("dQPFile,m",                     cfg_dQPFile,           string(""), "dQP file name")
+        ("RDOQ",                          m_useRDOQ,                  true)
+        ("RDOQTS",                        m_useRDOQTS,                true)
+#if L0232_RD_PENALTY
+    ("RDpenalty",                     m_rdPenalty,                0,
+     "RD-penalty for 32x32 TU for intra in non-intra slices. 0:disbaled  1:RD-penalty  2:maximum RD-penalty")
+#endif
+    // Entropy coding parameters
+    ("SBACRD",                         m_bUseSBACRD,                      true, "SBAC based RD estimation")
+
+    // Deblocking filter parameters
+        ("LoopFilterDisable",              m_bLoopFilterDisable,             false)
+        ("LoopFilterOffsetInPPS",          m_loopFilterOffsetInPPS,          false)
+        ("LoopFilterBetaOffset_div2",      m_loopFilterBetaOffsetDiv2,           0)
+        ("LoopFilterTcOffset_div2",        m_loopFilterTcOffsetDiv2,             0)
+        ("DeblockingFilterControlPresent", m_DeblockingFilterControlPresent, false)
+#if L0386_DB_METRIC
+    ("DeblockingFilterMetric",         m_DeblockingFilterMetric,         false)
+#endif
+
+    // Coding tools
+    ("AMP",                      m_enableAMP,                 true,  "Enable asymmetric motion partitions")
+        ("TransformSkip",            m_useTransformSkip,          false, "Intra transform skipping")
+        ("TransformSkipFast",        m_useTransformSkipFast,      false, "Fast intra transform skipping")
+        ("SAO",                      m_bUseSAO,                   true,  "Enable Sample Adaptive Offset")
+        ("MaxNumOffsetsPerPic",      m_maxNumOffsetsPerPic,       2048,  "Max number of SAO offset per picture (Default: 2048)")
+        ("SAOLcuBoundary",           m_saoLcuBoundary,            false,
+        "0: right/bottom LCU boundary areas skipped from SAO parameter estimation, 1: non-deblocked pixels are used for those areas")
+        ("SAOLcuBasedOptimization",  m_saoLcuBasedOptimization,   true,
+        "0: SAO picture-based optimization, 1: SAO LCU-based optimization ")
+        ("SliceMode",                m_sliceMode,                0,
+        "0: Disable all Recon slice limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice")
+        ("SliceArgument",            m_sliceArgument,            0,     "Depending on SliceMode being:"
+        "\t1: max number of CTUs per slice"
+        "\t2: max number of bytes per slice"
+        "\t3: max number of tiles per slice")
+        ("SliceSegmentMode",         m_sliceSegmentMode,       0,
+        "0: Disable all slice segment limits, 1: Enforce max # of LCUs, 2: Enforce max # of bytes, 3:specify tiles per dependent slice")
+        ("SliceSegmentArgument",     m_sliceSegmentArgument,   0,     "Depending on SliceSegmentMode being:"
+        "\t1: max number of CTUs per slice segment"
+        "\t2: max number of bytes per slice segment"
+        "\t3: max number of tiles per slice segment")
+        ("LFCrossSliceBoundaryFlag", m_bLFCrossSliceBoundaryFlag, true)
+
+        ("ConstrainedIntraPred",     m_bUseConstrainedIntraPred,  false, "Constrained Intra Prediction")
+
+        ("PCMEnabledFlag",           m_usePCM,                    false)
+        ("PCMLog2MaxSize",           m_pcmLog2MaxSize,            5u)
+        ("PCMLog2MinSize",           m_uiPCMLog2MinSize,          3u)
+        ("PCMInputBitDepthFlag",     m_bPCMInputBitDepthFlag,     true)
+        ("PCMFilterDisableFlag",     m_bPCMFilterDisableFlag,    false)
+
+        ("LosslessCuEnabled",        m_useLossless, false)
+
+        ("WeightedPredP,-wpP",          m_useWeightedPred,               false,      "Use weighted prediction in P slices")
+        ("WeightedPredB,-wpB",          m_useWeightedBiPred,             false,
+        "Use weighted (bidirectional) prediction in B slices")
+        ("Log2ParallelMergeLevel",      m_log2ParallelMergeLevel,     2u,          "Parallel merge estimation region")
+        ("UniformSpacingIdc",           m_iUniformSpacingIdr,            0,
+        "Indicates if the column and row boundaries are distributed uniformly")
+        ("NumTileColumnsMinus1",        m_iNumColumnsMinus1,             0,          "Number of columns in a picture minus 1")
+        ("ColumnWidthArray",            cfg_ColumnWidth,                 string(""),
+        "Array containing ColumnWidth values in units of LCU")
+        ("NumTileRowsMinus1",           m_iNumRowsMinus1,                0,          "Number of rows in a picture minus 1")
+        ("RowHeightArray",              cfg_RowHeight,                   string(""),
+        "Array containing RowHeight values in units of LCU")
+        ("LFCrossTileBoundaryFlag",      m_bLFCrossTileBoundaryFlag,             true,
+        "1: cross-tile-boundary loop filtering. 0:non-cross-tile-boundary loop filtering")
+        ("WaveFrontSynchro",            m_iWaveFrontSynchro,             0,
+        "0: no synchro; 1 synchro with TR; 2 TRR etc")
+        ("ScalingList",                 m_useScalingListId,              0,
+        "0: no scaling list, 1: default scaling lists, 2: scaling lists specified in ScalingListFile")
+        ("ScalingListFile",             cfg_ScalingListFile,             string(""), "Scaling list file name")
+        ("SignHideFlag,-SBH",                m_signHideFlag, 1)
+        ("MaxNumMergeCand",             m_maxNumMergeCand,             5u,         "Maximum number of merge candidates")
+
+    /* Misc. */
+        ("SEIDecodedPictureHash",       m_decodedPictureHashSEIEnabled, 0,
+        "Control generation of decode picture hash SEI messages\n"
+        "\t3: checksum\n"
+        "\t2: CRC\n"
+        "\t1: use MD5\n"
+        "\t0: disable")
+        ("SEIpictureDigest",            m_decodedPictureHashSEIEnabled, 0, "deprecated alias for SEIDecodedPictureHash")
+        ("TMVPMode", m_TMVPModeId, 1,
+        "TMVP mode 0: TMVP disable for all slices. 1: TMVP enable for all slices (default) 2: TMVP enable for certain slices only")
+        ("FEN", m_bUseFastEnc, false, "fast encoder setting")
+        ("ECU", m_bUseEarlyCU, false, "Early CU setting")
+        ("FDM", m_useFastDecisionForMerge, true, "Fast decision for Merge RD Cost")
+        ("CFM", m_bUseCbfFastMode, false, "Cbf fast mode setting")
+        ("ESD", m_useEarlySkipDetection, false, "Early SKIP detection setting")
+#if RATE_CONTROL_LAMBDA_DOMAIN
+    ("RateControl",         m_RCEnableRateControl,   false, "Rate control: enable rate control")
+        ("TargetBitrate",       m_RCTargetBitrate,           0, "Rate control: target bitrate")
+        ("KeepHierarchicalBit", m_RCKeepHierarchicalBit, false,
+        "Rate control: keep hierarchical bit allocation in rate control algorithm")
+        ("LCULevelRateControl", m_RCLCULevelRC,           true, "Rate control: true: LCU level RC; false: picture level RC")
+        ("RCLCUSeparateModel",  m_RCUseLCUSeparateModel,  true, "Rate control: use LCU level separate R-lambda model")
+        ("InitialQP",           m_RCInitialQP,               0, "Rate control: initial QP")
+        ("RCForceIntraQP",      m_RCForceIntraQP,        false, "Rate control: force intra QP to be equal to initial QP")
+#else
+    ("RateCtrl,-rc", m_enableRateCtrl, false, "Rate control on/off")
+        ("TargetBitrate,-tbr", m_targetBitrate, 0, "Input target bitrate")
+        ("NumLCUInUnit,-nu", m_numLCUInUnit, 0, "Number of LCUs in an Unit")
+#endif // if RATE_CONTROL_LAMBDA_DOMAIN
+
+    ("TransquantBypassEnableFlag", m_TransquantBypassEnableFlag, false, "transquant_bypass_enable_flag indicator in PPS")
+        ("CUTransquantBypassFlagValue", m_CUTransquantBypassFlagValue, false,
+        "Fixed cu_transquant_bypass_flag value, when transquant_bypass_enable_flag is enabled")
+        ("RecalculateQPAccordingToLambda", m_recalculateQPAccordingToLambda, false,
+        "Recalculate QP values according to lambda values. Do not suggest to be enabled in all intra case")
+        ("StrongIntraSmoothing,-sis",      m_useStrongIntraSmoothing,           true,
+        "Enable strong intra smoothing for 32x32 blocks")
+        ("SEIActiveParameterSets",         m_activeParameterSetsSEIEnabled,          0,
+        "Enable generation of active parameter sets SEI messages")
+        ("VuiParametersPresent,-vui",      m_vuiParametersPresentFlag,           false, "Enable generation of vui_parameters()")
+        ("AspectRatioInfoPresent",         m_aspectRatioInfoPresentFlag,         false,
+        "Signals whether aspect_ratio_idc is present")
+        ("AspectRatioIdc",                 m_aspectRatioIdc,                         0, "aspect_ratio_idc")
+        ("SarWidth",                       m_sarWidth,                               0,
+        "horizontal size of the sample aspect ratio")
+        ("SarHeight",                      m_sarHeight,                              0,
+        "vertical size of the sample aspect ratio")
+        ("OverscanInfoPresent",            m_overscanInfoPresentFlag,            false,
+        "Indicates whether conformant decoded pictures are suitable for display using overscan\n")
+        ("OverscanAppropriate",            m_overscanAppropriateFlag,            false,
+        "Indicates whether conformant decoded pictures are suitable for display using overscan\n")
+        ("VideoSignalTypePresent",         m_videoSignalTypePresentFlag,         false,
+        "Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present")
+        ("VideoFormat",                    m_videoFormat,                            5, "Indicates representation of pictures")
+        ("VideoFullRange",                 m_videoFullRangeFlag,                 false,
+        "Indicates the black level and range of luma and chroma signals")
+        ("ColourDescriptionPresent",       m_colourDescriptionPresentFlag,       false,
+        "Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present")
+        ("ColourPrimaries",                m_colourPrimaries,                        2,
+        "Indicates chromaticity coordinates of the source primaries")
+        ("TransferCharateristics",         m_transferCharacteristics,                2,
+        "Indicates the opto-electronic transfer characteristics of the source")
+        ("MatrixCoefficients",             m_matrixCoefficients,                     2,
+        "Describes the matrix coefficients used in deriving luma and chroma from RGB primaries")
+        ("ChromaLocInfoPresent",           m_chromaLocInfoPresentFlag,           false,
+        "Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present")
+        ("ChromaSampleLocTypeTopField",    m_chromaSampleLocTypeTopField,            0,
+        "Specifies the location of chroma samples for top field")
+        ("ChromaSampleLocTypeBottomField", m_chromaSampleLocTypeBottomField,         0,
+        "Specifies the location of chroma samples for bottom field")
+        ("NeutralChromaIndication",        m_neutralChromaIndicationFlag,        false,
+        "Indicates that the value of all decoded chroma samples is equal to 1<<(BitDepthCr-1)")
+        ("DefaultDisplayWindowFlag",       m_defaultDisplayWindowFlag,           false,
+        "Indicates the presence of the Default Window parameters")
+        ("DefDispWinLeftOffset",           m_defDispWinLeftOffset,                   0,
+        "Specifies the left offset of the default display window from the conformance window")
+        ("DefDispWinRightOffset",          m_defDispWinRightOffset,                  0,
+        "Specifies the right offset of the default display window from the conformance window")
+        ("DefDispWinTopOffset",            m_defDispWinTopOffset,                    0,
+        "Specifies the top offset of the default display window from the conformance window")
+        ("DefDispWinBottomOffset",         m_defDispWinBottomOffset,                 0,
+        "Specifies the bottom offset of the default display window from the conformance window")
+        ("FrameFieldInfoPresentFlag",      m_frameFieldInfoPresentFlag,               false,
+        "Indicates that pic_struct and field coding related values are present in picture timing SEI messages")
+        ("PocProportionalToTimingFlag",   m_pocProportionalToTimingFlag,         false,
+        "Indicates that the POC value is proportional to the output time w.r.t. first picture in CVS")
+        ("NumTicksPocDiffOneMinus1",      m_numTicksPocDiffOneMinus1,                0,
+        "Number of ticks minus 1 that for a POC difference of one")
+        ("BitstreamRestriction",           m_bitstreamRestrictionFlag,           false,
+        "Signals whether bitstream restriction parameters are present")
+        ("TilesFixedStructure",            m_tilesFixedStructureFlag,            false,
+        "Indicates that each active picture parameter set has the same values of the syntax elements related to tiles")
+        ("MotionVectorsOverPicBoundaries", m_motionVectorsOverPicBoundariesFlag, false,
+        "Indicates that no samples outside the picture boundaries are used for inter prediction")
+        ("MaxBytesPerPicDenom",            m_maxBytesPerPicDenom,                    2,
+        "Indicates a number of bytes not exceeded by the sum of the sizes of the VCL NAL units associated with any coded picture")
+        ("MaxBitsPerMinCuDenom",           m_maxBitsPerMinCuDenom,                   1,
+        "Indicates an upper bound for the number of bits of coding_unit() data")
+        ("Log2MaxMvLengthHorizontal",      m_log2MaxMvLengthHorizontal,             15,
+        "Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units")
+        ("Log2MaxMvLengthVertical",        m_log2MaxMvLengthVertical,               15,
+        "Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units")
+        ("SEIRecoveryPoint",               m_recoveryPointSEIEnabled,                0,
+        "Control generation of recovery point SEI messages")
+        ("SEIBufferingPeriod",             m_bufferingPeriodSEIEnabled,              0,
+        "Control generation of buffering period SEI messages")
+        ("SEIPictureTiming",               m_pictureTimingSEIEnabled,                0,
+        "Control generation of picture timing SEI messages")
+#if J0149_TONE_MAPPING_SEI
+    ("SEIToneMappingInfo",                       m_toneMappingInfoSEIEnabled,    false,
+     "Control generation of Tone Mapping SEI messages")
+        ("SEIToneMapId",                             m_toneMapId,                        0,
+        "Specifies Id of Tone Mapping SEI message for a given session")
+        ("SEIToneMapCancelFlag",                     m_toneMapCancelFlag,            false,
+        "Indicates that Tone Mapping SEI message cancels the persistance or follows")
+        ("SEIToneMapPersistenceFlag",                m_toneMapPersistenceFlag,        true,
+        "Specifies the persistence of the Tone Mapping SEI message")
+        ("SEIToneMapCodedDataBitDepth",              m_toneMapCodedDataBitDepth,         8,
+        "Specifies Coded Data BitDepth of Tone Mapping SEI messages")
+        ("SEIToneMapTargetBitDepth",                 m_toneMapTargetBitDepth,            8,
+        "Specifies Output BitDepth of Tome mapping function")
+        ("SEIToneMapModelId",                        m_toneMapModelId,                   0,
+        "Specifies Model utilized for mapping coded data into target_bit_depth range\n"
+        "\t0:  linear mapping with clipping\n"
+        "\t1:  sigmoidal mapping\n"
+        "\t2:  user-defined table mapping\n"
+        "\t3:  piece-wise linear mapping\n"
+        "\t4:  luminance dynamic range information ")
+        ("SEIToneMapMinValue",                              m_toneMapMinValue,                          0,
+        "Specifies the minimum value in mode 0")
+        ("SEIToneMapMaxValue",                              m_toneMapMaxValue,                       1023,
+        "Specifies the maxmum value in mode 0")
+        ("SEIToneMapSigmoidMidpoint",                       m_sigmoidMidpoint,                        512,
+        "Specifies the centre point in mode 1")
+        ("SEIToneMapSigmoidWidth",                          m_sigmoidWidth,                           960,
+        "Specifies the distance between 5% and 95% values of the target_bit_depth in mode 1")
+        ("SEIToneMapStartOfCodedInterval",                  cfg_startOfCodedInterval,          string(""),
+        "Array of user-defined mapping table")
+        ("SEIToneMapNumPivots",                             m_numPivots,                                0,
+        "Specifies the number of pivot points in mode 3")
+        ("SEIToneMapCodedPivotValue",                       cfg_codedPivotValue,               string(""), "Array of pivot point")
+        ("SEIToneMapTargetPivotValue",                      cfg_targetPivotValue,              string(""), "Array of pivot point")
+        ("SEIToneMapCameraIsoSpeedIdc",                     m_cameraIsoSpeedIdc,                        0,
+        "Indicates the camera ISO speed for daylight illumination")
+        ("SEIToneMapCameraIsoSpeedValue",                   m_cameraIsoSpeedValue,                    400,
+        "Specifies the camera ISO speed for daylight illumination of Extended_ISO")
+        ("SEIToneMapExposureCompensationValueSignFlag",     m_exposureCompensationValueSignFlag,        0,
+        "Specifies the sign of ExposureCompensationValue")
+        ("SEIToneMapExposureCompensationValueNumerator",    m_exposureCompensationValueNumerator,       0,
+        "Specifies the numerator of ExposureCompensationValue")
+        ("SEIToneMapExposureCompensationValueDenomIdc",     m_exposureCompensationValueDenomIdc,        2,
+        "Specifies the denominator of ExposureCompensationValue")
+        ("SEIToneMapRefScreenLuminanceWhite",               m_refScreenLuminanceWhite,                350,
+        "Specifies reference screen brightness setting in units of candela per square metre")
+        ("SEIToneMapExtendedRangeWhiteLevel",               m_extendedRangeWhiteLevel,                800,
+        "Indicates the luminance dynamic range")
+        ("SEIToneMapNominalBlackLevelLumaCodeValue",        m_nominalBlackLevelLumaCodeValue,          16,
+        "Specifies luma sample value of the nominal black level assigned decoded pictures")
+        ("SEIToneMapNominalWhiteLevelLumaCodeValue",        m_nominalWhiteLevelLumaCodeValue,         235,
+        "Specifies luma sample value of the nominal white level assigned decoded pictures")
+        ("SEIToneMapExtendedWhiteLevelLumaCodeValue",       m_extendedWhiteLevelLumaCodeValue,        300,
+        "Specifies luma sample value of the extended dynamic range assigned decoded pictures")
+#endif // if J0149_TONE_MAPPING_SEI
+    ("SEIFramePacking",                m_framePackingSEIEnabled,                 0,
+     "Control generation of frame packing SEI messages")
+        ("SEIFramePackingType",            m_framePackingSEIType,                    0, "Define frame packing arrangement\n"
+        "\t0: checkerboard - pixels alternatively represent either frames\n"
+        "\t1: column alternation - frames are interlaced by column\n"
+        "\t2: row alternation - frames are interlaced by row\n"
+        "\t3: side by side - frames are displayed horizontally\n"
+        "\t4: top bottom - frames are displayed vertically\n"
+        "\t5: frame alternation - one frame is alternated with the other")
+        ("SEIFramePackingId",              m_framePackingSEIId,                      0,
+        "Id of frame packing SEI message for a given session")
+        ("SEIFramePackingQuincunx",        m_framePackingSEIQuincunx,                0,
+        "Indicate the presence of a Quincunx type video frame")
+        ("SEIFramePackingInterpretation",  m_framePackingSEIInterpretation,          0,
+        "Indicate the interpretation of the frame pair\n"
+        "\t0: unspecified\n"
+        "\t1: stereo pair, frame0 represents left view\n"
+        "\t2: stereo pair, frame0 represents right view")
+        ("SEIDisplayOrientation",          m_displayOrientationSEIAngle,             0,
+        "Control generation of display orientation SEI messages\n"
+        "\tN: 0 < N < (2^16 - 1) enable display orientation SEI message with anticlockwise_rotation = N and display_orientation_repetition_period = 1\n"
+        "\t0: disable")
+        ("SEITemporalLevel0Index",         m_temporalLevel0IndexSEIEnabled,          0,
+        "Control generation of temporal level 0 index SEI messages")
+        ("SEIGradualDecodingRefreshInfo",  m_gradualDecodingRefreshInfoEnabled,      0,
+        "Control generation of gradual decoding refresh information SEI message")
+        ("SEIDecodingUnitInfo",             m_decodingUnitInfoSEIEnabled,                       0,
+        "Control generation of decoding unit information SEI message.")
+#if L0208_SOP_DESCRIPTION_SEI
+    ("SEISOPDescription",              m_SOPDescriptionSEIEnabled,              0,
+     "Control generation of SOP description SEI messages")
+#endif
+#if K0180_SCALABLE_NESTING_SEI
+    ("SEIScalableNesting",             m_scalableNestingSEIEnabled,              0,
+     "Control generation of scalable nesting SEI messages")
+#endif
+#if SIGNAL_BITRATE_PICRATE_IN_VPS
+    ("BitRatePicRateMaxTLayers",   m_bitRatePicRateMaxTLayers,           0,
+     "Maximum number of sub-layers signalled; can be inferred otherwise; here for easy parsing of config. file")
+        ("BitRateInfoPresent",         cfg_bitRateInfoPresentFlag,          string(""),
+        "Control signalling of bit rate information of avg. bit rate and max. bit rate in VPS\n"
+        "\t0: Do not sent bit rate info\n"
+        "\tN (N > 0): Send bit rate info for N sub-layers. N should equal maxTempLayers.")
+        ("PicRateInfoPresent",         cfg_picRateInfoPresentFlag,          string(""),
+        "Control signalling of picture rate information of avg. bit rate and max. bit rate in VPS\n"
+        "\t0: Do not sent picture rate info\n"
+        "\tN (N > 0): Send picture rate info for N sub-layers. N should equal maxTempLayers.")
+        ("AvgBitRate",                   cfg_avgBitRate,                    string(""),
+        "List of avg. bit rates for the different sub-layers; include non-negative number even if corresponding flag is 0")
+        ("MaxBitRate",                   cfg_maxBitRate,                    string(""),
+        "List of max. bit rates for the different sub-layers; include non-negative number even if corresponding flag is 0")
+        ("AvgPicRate",                   cfg_avgPicRate,                    string(""),
+        "List of avg. picture rates for the different sub-layers; include non-negative number even if corresponding flag is 0")
+        ("ConstantPicRateIdc",           cfg_constantPicRateIdc,            string(""),
+        "List of constant picture rate IDCs; include non-negative number even if corresponding flag is 0")
+#endif // if SIGNAL_BITRATE_PICRATE_IN_VPS
+    ;
+
+    for (Int i = 1; i < MAX_GOP + 1; i++)
+    {
+        std::ostringstream cOSS;
+        cOSS << "Frame" << i;
+        opts.addOptions() (cOSS.str(), m_GOPList[i - 1], GOPEntry());
+    }
+
+    po::setDefaults(opts);
+    const list<const Char *>& argv_unhandled = po::scanArgv(opts, argc, (const Char**)argv);
+
+    for (list<const Char *>::const_iterator it = argv_unhandled.begin(); it != argv_unhandled.end(); it++)
+    {
+        fprintf(stderr, "Unhandled argument ignored: `%s'\n", *it);
+    }
+
+    if (argc == 1 || do_help)
+    {
+        /* argc == 1: no options have been specified */
+        po::doHelp(cout, opts);
+        return false;
+    }
+
+    /*
+     * Set any derived parameters
+     */
+
+    /* convert std::string to c string for compatability */
+    m_pchInputFile = cfg_InputFile.empty() ? NULL : strdup(cfg_InputFile.c_str());
+    m_pchBitstreamFile = cfg_BitstreamFile.empty() ? NULL : strdup(cfg_BitstreamFile.c_str());
+    m_pchReconFile = cfg_ReconFile.empty() ? NULL : strdup(cfg_ReconFile.c_str());
+    m_pchdQPFile = cfg_dQPFile.empty() ? NULL : strdup(cfg_dQPFile.c_str());
+
+    /* parse the width, height, frame rate from the y4m files if it is not given in the configuration file */
+    char * s = strrchr(m_pchInputFile, '.');
+    handler_input = NULL;
+    handler_recon = NULL;
+
+    if ((!strcmp(s + 1, "y4m")))
+    {
+        m_cTVideoIOInputFile = new TVideoIOY4m();
+        m_cTVideoIOReconFile = new TVideoIOY4m();
+        /* get the video information like width,height,framerate */
+        m_cTVideoIOInputFile->open(m_pchInputFile,
+                                   false,
+                                   m_inputBitDepthY,
+                                   m_inputBitDepthC,
+                                   m_internalBitDepthY,
+                                   m_internalBitDepthC,
+                                   handler_input,
+                                   video_info,
+                                   m_aiPad);
+        m_cTVideoIOInputFile->getVideoInfo(video_info, handler_input);
+        m_iSourceWidth = video_info.width;
+        m_iSourceHeight = video_info.height;
+        m_iFrameRate = video_info.FrameRate;
+    }
+    else if ((!strcmp(s + 1, "yuv")))
+    {
+        m_cTVideoIOInputFile = new TVideoIOYuv();
+        m_cTVideoIOReconFile = new TVideoIOYuv();
+    }
+
+    Char *pColumnWidth = cfg_ColumnWidth.empty() ? NULL : strdup(cfg_ColumnWidth.c_str());
+    Char *pRowHeight = cfg_RowHeight.empty() ? NULL : strdup(cfg_RowHeight.c_str());
+    if (m_iUniformSpacingIdr == 0 && m_iNumColumnsMinus1 > 0)
+    {
+        char *columnWidth;
+        int  i = 0;
+        m_pColumnWidth = new UInt[m_iNumColumnsMinus1];
+        columnWidth = strtok(pColumnWidth, " ,-");
+        while (columnWidth != NULL)
+        {
+            if (i >= m_iNumColumnsMinus1)
+            {
+                printf("The number of columns whose width are defined is larger than the allowed number of columns.\n");
+                exit(EXIT_FAILURE);
+            }
+
+            *(m_pColumnWidth + i) = atoi(columnWidth);
+            columnWidth = strtok(NULL, " ,-");
+            i++;
+        }
+
+        if (i < m_iNumColumnsMinus1)
+        {
+            printf("The width of some columns is not defined.\n");
+            exit(EXIT_FAILURE);
+        }
+    }
+    else
+    {
+        m_pColumnWidth = NULL;
+    }
+
+    if (m_iUniformSpacingIdr == 0 && m_iNumRowsMinus1 > 0)
+    {
+        char *rowHeight;
+        int  i = 0;
+        m_pRowHeight = new UInt[m_iNumRowsMinus1];
+        rowHeight = strtok(pRowHeight, " ,-");
+        while (rowHeight != NULL)
+        {
+            if (i >= m_iNumRowsMinus1)
+            {
+                printf("The number of rows whose height are defined is larger than the allowed number of rows.\n");
+                exit(EXIT_FAILURE);
+            }
+
+            *(m_pRowHeight + i) = atoi(rowHeight);
+            rowHeight = strtok(NULL, " ,-");
+            i++;
+        }
+
+        if (i < m_iNumRowsMinus1)
+        {
+            printf("The height of some rows is not defined.\n");
+            exit(EXIT_FAILURE);
+        }
+    }
+    else
+    {
+        m_pRowHeight = NULL;
+    }
+
+#if SIGNAL_BITRATE_PICRATE_IN_VPS
+    readBoolString(cfg_bitRateInfoPresentFlag,
+                   m_bitRatePicRateMaxTLayers,
+                   m_bitRateInfoPresentFlag,
+                   "bit rate info. present flag");
+    readIntString(cfg_avgBitRate,             m_bitRatePicRateMaxTLayers, m_avgBitRate,             "avg. bit rate");
+    readIntString(cfg_maxBitRate,             m_bitRatePicRateMaxTLayers, m_maxBitRate,             "max. bit rate");
+    readBoolString(cfg_picRateInfoPresentFlag,
+                   m_bitRatePicRateMaxTLayers,
+                   m_picRateInfoPresentFlag,
+                   "bit rate info. present flag");
+    readIntString(cfg_avgPicRate,             m_bitRatePicRateMaxTLayers, m_avgPicRate,             "avg. pic rate");
+    readIntString(cfg_constantPicRateIdc,     m_bitRatePicRateMaxTLayers, m_constantPicRateIdc,     "constant pic rate Idc");
+#endif // if SIGNAL_BITRATE_PICRATE_IN_VPS
+    m_scalingListFile = cfg_ScalingListFile.empty() ? NULL : strdup(cfg_ScalingListFile.c_str());
+
+    /* rules for input, output and internal bitdepths as per help text */
+    if (!m_internalBitDepthY)
+    {
+        m_internalBitDepthY = m_inputBitDepthY;
+    }
+
+    if (!m_internalBitDepthC)
+    {
+        m_internalBitDepthC = m_internalBitDepthY;
+    }
+
+    if (!m_inputBitDepthC)
+    {
+        m_inputBitDepthC = m_inputBitDepthY;
+    }
+
+    if (!m_outputBitDepthY)
+    {
+        m_outputBitDepthY = m_internalBitDepthY;
+    }
+
+    if (!m_outputBitDepthC)
+    {
+        m_outputBitDepthC = m_internalBitDepthC;
+    }
+
+    // TODO:ChromaFmt assumes 4:2:0 below
+    switch (m_conformanceMode)
+    {
+    case 0:
+    {
+        // no conformance or padding
+        m_confLeft = m_confRight = m_confTop = m_confBottom = 0;
+        m_aiPad[1] = m_aiPad[0] = 0;
+        break;
+    }
+    case 1:
+    {
+        // automatic padding to minimum CU size
+        Int minCuSize = m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1);
+        if (m_iSourceWidth % minCuSize)
+        {
+            m_aiPad[0] = m_confRight  = ((m_iSourceWidth / minCuSize) + 1) * minCuSize - m_iSourceWidth;
+            m_iSourceWidth  += m_confRight;
+        }
+
+        if (m_iSourceHeight % minCuSize)
+        {
+            m_aiPad[1] = m_confBottom = ((m_iSourceHeight / minCuSize) + 1) * minCuSize - m_iSourceHeight;
+            m_iSourceHeight += m_confBottom;
+        }
+
+        if (m_aiPad[0] % TComSPS::getWinUnitX(CHROMA_420) != 0)
+        {
+            fprintf(stderr, "Error: picture width is not an integer multiple of the specified chroma subsampling\n");
+            exit(EXIT_FAILURE);
+        }
+
+        if (m_aiPad[1] % TComSPS::getWinUnitY(CHROMA_420) != 0)
+        {
+            fprintf(stderr, "Error: picture height is not an integer multiple of the specified chroma subsampling\n");
+            exit(EXIT_FAILURE);
+        }
+
+        break;
+    }
+    case 2:
+    {
+        //padding
+        m_iSourceWidth  += m_aiPad[0];
+        m_iSourceHeight += m_aiPad[1];
+        m_confRight  = m_aiPad[0];
+        m_confBottom = m_aiPad[1];
+        break;
+    }
+    case 3:
+    {
+        // conformance
+        if ((m_confLeft == 0) && (m_confRight == 0) && (m_confTop == 0) && (m_confBottom == 0))
+        {
+            fprintf(stderr, "Warning: Conformance window enabled, but all conformance window parameters set to zero\n");
+        }
+
+        if ((m_aiPad[1] != 0) || (m_aiPad[0] != 0))
+        {
+            fprintf(stderr, "Warning: Conformance window enabled, padding parameters will be ignored\n");
+        }
+
+        m_aiPad[1] = m_aiPad[0] = 0;
+        break;
+    }
+    }
+
+    // allocate slice-based dQP values
+    m_aidQP = new Int[m_framesToBeEncoded + m_iGOPSize + 1];
+    ::memset(m_aidQP, 0, sizeof(Int) * (m_framesToBeEncoded + m_iGOPSize + 1));
+
+    // handling of floating-point QP values
+    // if QP is not integer, sequence is split into two sections having QP and QP+1
+    m_iQP = (Int)(m_fQP);
+    if (m_iQP < m_fQP)
+    {
+        Int iSwitchPOC = (Int)(m_framesToBeEncoded - (m_fQP - m_iQP) * m_framesToBeEncoded + 0.5);
+
+        iSwitchPOC = (Int)((Double)iSwitchPOC / m_iGOPSize + 0.5) * m_iGOPSize;
+        for (Int i = iSwitchPOC; i < m_framesToBeEncoded + m_iGOPSize + 1; i++)
+        {
+            m_aidQP[i] = 1;
+        }
+    }
+
+    // reading external dQP description from file
+    if (m_pchdQPFile)
+    {
+        FILE *fpt = fopen(m_pchdQPFile, "r");
+        if (fpt)
+        {
+            Int iValue;
+            Int iPOC = 0;
+            while (iPOC < m_framesToBeEncoded)
+            {
+                if (fscanf(fpt, "%d", &iValue) == EOF) break;
+
+                m_aidQP[iPOC] = iValue;
+                iPOC++;
+            }
+
+            fclose(fpt);
+        }
+    }
+
+    m_iWaveFrontSubstreams = m_iWaveFrontSynchro ? (m_iSourceHeight + m_uiMaxCUHeight - 1) / m_uiMaxCUHeight : 1;
+
+#if J0149_TONE_MAPPING_SEI
+    if (m_toneMappingInfoSEIEnabled && !m_toneMapCancelFlag)
+    {
+        Char *pcStartOfCodedInterval = cfg_startOfCodedInterval.empty() ? NULL : strdup(cfg_startOfCodedInterval.c_str());
+        Char *pcCodedPivotValue = cfg_codedPivotValue.empty() ? NULL : strdup(cfg_codedPivotValue.c_str());
+        Char *pcTargetPivotValue = cfg_targetPivotValue.empty() ? NULL : strdup(cfg_targetPivotValue.c_str());
+        if (m_toneMapModelId == 2 && pcStartOfCodedInterval)
+        {
+            char *startOfCodedInterval;
+            UInt num = 1u << m_toneMapTargetBitDepth;
+            m_startOfCodedInterval = new Int[num];
+            ::memset(m_startOfCodedInterval, 0, sizeof(Int) * num);
+            startOfCodedInterval = strtok(pcStartOfCodedInterval, " .");
+            int i = 0;
+            while (startOfCodedInterval && (i < num))
+            {
+                m_startOfCodedInterval[i] = atoi(startOfCodedInterval);
+                startOfCodedInterval = strtok(NULL, " .");
+                i++;
+            }
+        }
+        else
+        {
+            m_startOfCodedInterval = NULL;
+        }
+
+        if ((m_toneMapModelId == 3) && (m_numPivots > 0))
+        {
+            if (pcCodedPivotValue && pcTargetPivotValue)
+            {
+                char *codedPivotValue;
+                char *targetPivotValue;
+                m_codedPivotValue = new Int[m_numPivots];
+                m_targetPivotValue = new Int[m_numPivots];
+                ::memset(m_codedPivotValue, 0, sizeof(Int) * (m_numPivots));
+                ::memset(m_targetPivotValue, 0, sizeof(Int) * (m_numPivots));
+                codedPivotValue = strtok(pcCodedPivotValue, " .");
+                int i = 0;
+                while (codedPivotValue && i < m_numPivots)
+                {
+                    m_codedPivotValue[i] = atoi(codedPivotValue);
+                    codedPivotValue = strtok(NULL, " .");
+                    i++;
+                }
+
+                i = 0;
+                targetPivotValue = strtok(pcTargetPivotValue, " .");
+                while (targetPivotValue && i < m_numPivots)
+                {
+                    m_targetPivotValue[i] = atoi(targetPivotValue);
+                    targetPivotValue = strtok(NULL, " .");
+                    i++;
+                }
+            }
+        }
+        else
+        {
+            m_codedPivotValue = NULL;
+            m_targetPivotValue = NULL;
+        }
+    }
+
+#endif // if J0149_TONE_MAPPING_SEI
+       // check validity of input parameters
+    xCheckParameter();
+
+    // set global varibles
+    xSetGlobal();
+
+    // print-out parameters
+    xPrintParameter();
+
+    return true;
+}
+
+#if SIGNAL_BITRATE_PICRATE_IN_VPS
+Void readBoolString(const string inpString, const Int numEntries, Bool* &memberArray, const char *elementName)
+{
+    Char *inpArray = inpString.empty() ? NULL : strdup(inpString.c_str());
+    Int i = 0;
+
+    if (numEntries)
+    {
+        Char *tempArray = strtok(inpArray, " ,-");
+        memberArray = new Bool[numEntries];
+        while (tempArray != NULL)
+        {
+            if (i >= numEntries)
+            {
+                printf("The number of %s defined is larger than the allowed number\n", elementName);
+                exit(EXIT_FAILURE);
+            }
+
+            assert((atoi(tempArray) == 0) || (atoi(tempArray) == 1));
+            *(memberArray + i) = atoi(tempArray);
+            tempArray = strtok(NULL, " ,-");
+            i++;
+        }
+
+        if (i < numEntries)
+        {
+            printf("Some %s are not defined\n", elementName);
+            exit(EXIT_FAILURE);
+        }
+    }
+    else
+    {
+        memberArray = NULL;
+    }
+}
+
+Void readIntString(const string inpString, const Int numEntries, Int* &memberArray, const char *elementName)
+{
+    Char *inpArray = inpString.empty() ? NULL : strdup(inpString.c_str());
+    Int i = 0;
+
+    if (numEntries)
+    {
+        Char *tempArray = strtok(inpArray, " ,-");
+        memberArray = new Int[numEntries];
+        while (tempArray != NULL)
+        {
+            if (i >= numEntries)
+            {
+                printf("The number of %s defined is larger than the allowed number\n", elementName);
+                exit(EXIT_FAILURE);
+            }
+
+            *(memberArray + i) = atoi(tempArray);
+            tempArray = strtok(NULL, " ,-");
+            i++;
+        }
+
+        if (i < numEntries)
+        {
+            printf("Some %s are not defined\n", elementName);
+            exit(EXIT_FAILURE);
+        }
+    }
+    else
+    {
+        memberArray = NULL;
+    }
+}
+
+#endif // if SIGNAL_BITRATE_PICRATE_IN_VPS
+// ====================================================================================================================
+// Private member functions
+// ====================================================================================================================
+
+Bool confirmPara(Bool bflag, const Char *message);
+
+Void TAppEncCfg::xCheckParameter()
+{
+    if (!m_decodedPictureHashSEIEnabled)
+    {
+        fprintf(stderr, "******************************************************************\n");
+        fprintf(stderr, "** WARNING: --SEIDecodedPictureHash is now disabled by default. **\n");
+        fprintf(stderr, "**          Automatic verification of decoded pictures by a     **\n");
+        fprintf(stderr, "**          decoder requires this option to be enabled.         **\n");
+        fprintf(stderr, "******************************************************************\n");
+    }
+
+    Bool check_failed = false; /* abort if there is a fatal configuration problem */
+#define xConfirmPara(a, b) check_failed |= confirmPara(a, b)
+    // check range of parameters
+    xConfirmPara(m_inputBitDepthY < 8,                                                     "InputBitDepth must be at least 8");
+    xConfirmPara(m_inputBitDepthC < 8,                                                     "InputBitDepthC must be at least 8");
+    xConfirmPara(m_iFrameRate <= 0,                                                          "Frame rate must be more than 1");
+    xConfirmPara(m_framesToBeEncoded <= 0,
+                 "Total Number Of Frames encoded must be more than 0");
+    xConfirmPara(m_iGOPSize < 1,
+                 "GOP Size must be greater or equal to 1");
+    xConfirmPara(m_iGOPSize > 1 &&  m_iGOPSize % 2,
+                 "GOP Size must be a multiple of 2, if GOP Size is greater than 1");
+    xConfirmPara((m_iIntraPeriod > 0 && m_iIntraPeriod < m_iGOPSize) || m_iIntraPeriod == 0,
+                 "Intra period must be more than GOP size, or -1 , not 0");
+    xConfirmPara(m_iDecodingRefreshType < 0 || m_iDecodingRefreshType > 2,
+                 "Decoding Refresh Type must be equal to 0, 1 or 2");
+    xConfirmPara(m_iQP <  -6 * (m_internalBitDepthY - 8) || m_iQP > 51,
+                 "QP exceeds supported range (-QpBDOffsety to 51)");
+    xConfirmPara(m_loopFilterBetaOffsetDiv2 < -13 || m_loopFilterBetaOffsetDiv2 > 13,
+                 "Loop Filter Beta Offset div. 2 exceeds supported range (-13 to 13)");
+    xConfirmPara(m_loopFilterTcOffsetDiv2 < -13 || m_loopFilterTcOffsetDiv2 > 13,
+                 "Loop Filter Tc Offset div. 2 exceeds supported range (-13 to 13)");
+    xConfirmPara(m_iFastSearch < 0 || m_iFastSearch > 2,
+                 "Fast Search Mode is not supported value (0:Full search  1:Diamond  2:PMVFAST)");
+    xConfirmPara(m_iSearchRange < 0,                                                        "Search Range must be more than 0");
+    xConfirmPara(m_bipredSearchRange < 0,                                                   "Search Range must be more than 0");
+    xConfirmPara(m_iMaxDeltaQP > 7,
+                 "Absolute Delta QP exceeds supported range (0 to 7)");
+    xConfirmPara(m_iMaxCuDQPDepth > m_uiMaxCUDepth - 1,
+                 "Absolute depth for a minimum CuDQP exceeds maximum coding unit depth");
+
+    xConfirmPara(m_cbQpOffset < -12,   "Min. Chroma Cb QP Offset is -12");
+    xConfirmPara(m_cbQpOffset >  12,   "Max. Chroma Cb QP Offset is  12");
+    xConfirmPara(m_crQpOffset < -12,   "Min. Chroma Cr QP Offset is -12");
+    xConfirmPara(m_crQpOffset >  12,   "Max. Chroma Cr QP Offset is  12");
+
+    xConfirmPara(m_iQPAdaptationRange <= 0,
+                 "QP Adaptation Range must be more than 0");
+    if (m_iDecodingRefreshType == 2)
+    {
+        xConfirmPara(m_iIntraPeriod > 0 && m_iIntraPeriod <= m_iGOPSize,
+                     "Intra period must be larger than GOP size for periodic IDR pictures");
+    }
+
+    xConfirmPara((m_uiMaxCUWidth  >> m_uiMaxCUDepth) < 4,
+                 "Minimum partition width size should be larger than or equal to 8");
+    xConfirmPara((m_uiMaxCUHeight >> m_uiMaxCUDepth) < 4,
+                 "Minimum partition height size should be larger than or equal to 8");
+    xConfirmPara(m_uiMaxCUWidth < 16,
+                 "Maximum partition width size should be larger than or equal to 16");
+    xConfirmPara(m_uiMaxCUHeight < 16,
+                 "Maximum partition height size should be larger than or equal to 16");
+    xConfirmPara((m_iSourceWidth  % (m_uiMaxCUWidth  >> (m_uiMaxCUDepth - 1))) != 0,
+                 "Resulting coded frame width must be a multiple of the minimum CU size");
+    xConfirmPara((m_iSourceHeight % (m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1))) != 0,
+                 "Resulting coded frame height must be a multiple of the minimum CU size");
+
+    xConfirmPara(m_uiQuadtreeTULog2MinSize < 2,
+                 "QuadtreeTULog2MinSize must be 2 or greater.");
+    xConfirmPara(m_uiQuadtreeTULog2MaxSize > 5,
+                 "QuadtreeTULog2MaxSize must be 5 or smaller.");
+    xConfirmPara((1 << m_uiQuadtreeTULog2MaxSize) > m_uiMaxCUWidth,
+                 "QuadtreeTULog2MaxSize must be log2(maxCUSize) or smaller.");
+
+    xConfirmPara(m_uiQuadtreeTULog2MaxSize < m_uiQuadtreeTULog2MinSize,
+                 "QuadtreeTULog2MaxSize must be greater than or equal to m_uiQuadtreeTULog2MinSize.");
+    xConfirmPara((1 << m_uiQuadtreeTULog2MinSize) > (m_uiMaxCUWidth >> (m_uiMaxCUDepth - 1)),
+                 "QuadtreeTULog2MinSize must not be greater than minimum CU size");                                                                            // HS
+    xConfirmPara((1 << m_uiQuadtreeTULog2MinSize) > (m_uiMaxCUHeight >> (m_uiMaxCUDepth - 1)),
+                 "QuadtreeTULog2MinSize must not be greater than minimum CU size");                                                                             // HS
+    xConfirmPara((1 << m_uiQuadtreeTULog2MinSize) > (m_uiMaxCUWidth  >> m_uiMaxCUDepth),
+                 "Minimum CU width must be greater than minimum transform size.");
+    xConfirmPara((1 << m_uiQuadtreeTULog2MinSize) > (m_uiMaxCUHeight >> m_uiMaxCUDepth),
+                 "Minimum CU height must be greater than minimum transform size.");
+    xConfirmPara(m_uiQuadtreeTUMaxDepthInter < 1,
+                 "QuadtreeTUMaxDepthInter must be greater than or equal to 1");
+    xConfirmPara(
+        m_uiMaxCUWidth < (1 << (m_uiQuadtreeTULog2MinSize + m_uiQuadtreeTUMaxDepthInter - 1)),
+        "QuadtreeTUMaxDepthInter must be less than or equal to the difference between log2(maxCUSize) and QuadtreeTULog2MinSize plus 1");
+    xConfirmPara(m_uiQuadtreeTUMaxDepthIntra < 1,
+                 "QuadtreeTUMaxDepthIntra must be greater than or equal to 1");
+    xConfirmPara(
+        m_uiMaxCUWidth < (1 << (m_uiQuadtreeTULog2MinSize + m_uiQuadtreeTUMaxDepthIntra - 1)),
+        "QuadtreeTUMaxDepthInter must be less than or equal to the difference between log2(maxCUSize) and QuadtreeTULog2MinSize plus 1");
+
+    xConfirmPara(m_maxNumMergeCand < 1,  "MaxNumMergeCand must be 1 or greater.");
+    xConfirmPara(m_maxNumMergeCand > 5,  "MaxNumMergeCand must be 5 or smaller.");
+
+#if ADAPTIVE_QP_SELECTION
+    xConfirmPara(m_bUseAdaptQpSelect == true && m_iQP < 0,
+                 "AdaptiveQpSelection must be disabled when QP < 0.");
+    xConfirmPara(m_bUseAdaptQpSelect == true && (m_cbQpOffset != 0 || m_crQpOffset != 0),
+                 "AdaptiveQpSelection must be disabled when ChromaQpOffset is not equal to 0.");
+#endif
+
+    if (m_usePCM)
+    {
+        xConfirmPara(m_uiPCMLog2MinSize < 3,                                      "PCMLog2MinSize must be 3 or greater.");
+        xConfirmPara(m_uiPCMLog2MinSize > 5,                                      "PCMLog2MinSize must be 5 or smaller.");
+        xConfirmPara(m_pcmLog2MaxSize > 5,                                        "PCMLog2MaxSize must be 5 or smaller.");
+        xConfirmPara(m_pcmLog2MaxSize < m_uiPCMLog2MinSize,
+                     "PCMLog2MaxSize must be equal to or greater than m_uiPCMLog2MinSize.");
+    }
+
+    xConfirmPara(m_sliceMode < 0 || m_sliceMode > 3, "SliceMode exceeds supported range (0 to 3)");
+    if (m_sliceMode != 0)
+    {
+        xConfirmPara(m_sliceArgument < 1,         "SliceArgument should be larger than or equal to 1");
+    }
+
+    xConfirmPara(m_sliceSegmentMode < 0 || m_sliceSegmentMode > 3, "SliceSegmentMode exceeds supported range (0 to 3)");
+    if (m_sliceSegmentMode != 0)
+    {
+        xConfirmPara(m_sliceSegmentArgument < 1,         "SliceSegmentArgument should be larger than or equal to 1");
+    }
+
+    Bool tileFlag = (m_iNumColumnsMinus1 > 0 || m_iNumRowsMinus1 > 0);
+    xConfirmPara(tileFlag && m_iWaveFrontSynchro,            "Tile and Wavefront can not be applied together");
+
+    //TODO:ChromaFmt assumes 4:2:0 below
+    xConfirmPara(m_iSourceWidth  % TComSPS::getWinUnitX(
+                     CHROMA_420) != 0, "Picture width must be an integer multiple of the specified chroma subsampling");
+    xConfirmPara(m_iSourceHeight % TComSPS::getWinUnitY(
+                     CHROMA_420) != 0, "Picture height must be an integer multiple of the specified chroma subsampling");
+
+    xConfirmPara(m_aiPad[0] % TComSPS::getWinUnitX(
+                     CHROMA_420) != 0, "Horizontal padding must be an integer multiple of the specified chroma subsampling");
+    xConfirmPara(m_aiPad[1] % TComSPS::getWinUnitY(
+                     CHROMA_420) != 0, "Vertical padding must be an integer multiple of the specified chroma subsampling");
+
+    xConfirmPara(m_confLeft   % TComSPS::getWinUnitX(
+                     CHROMA_420) != 0,
+                 "Left conformance window offset must be an integer multiple of the specified chroma subsampling");
+    xConfirmPara(m_confRight  % TComSPS::getWinUnitX(
+                     CHROMA_420) != 0,
+                 "Right conformance window offset must be an integer multiple of the specified chroma subsampling");
+    xConfirmPara(m_confTop    % TComSPS::getWinUnitY(
+                     CHROMA_420) != 0,
+                 "Top conformance window offset must be an integer multiple of the specified chroma subsampling");
+    xConfirmPara(m_confBottom % TComSPS::getWinUnitY(
+                     CHROMA_420) != 0,
+                 "Bottom conformance window offset must be an integer multiple of the specified chroma subsampling");
+
+    // max CU width and height should be power of 2
+    UInt ui = m_uiMaxCUWidth;
+    while (ui)
+    {
+        ui >>= 1;
+        if ((ui & 1) == 1)
+            xConfirmPara(ui != 1, "Width should be 2^n");
+    }
+
+    ui = m_uiMaxCUHeight;
+    while (ui)
+    {
+        ui >>= 1;
+        if ((ui & 1) == 1)
+            xConfirmPara(ui != 1, "Height should be 2^n");
+    }
+
+    /* if this is an intra-only sequence, ie IntraPeriod=1, don't verify the GOP structure
+     * This permits the ability to omit a GOP structure specification */
+    if (m_iIntraPeriod == 1 && m_GOPList[0].m_POC == -1)
+    {
+        m_GOPList[0] = GOPEntry();
+        m_GOPList[0].m_QPFactor = 1;
+        m_GOPList[0].m_betaOffsetDiv2 = 0;
+        m_GOPList[0].m_tcOffsetDiv2 = 0;
+        m_GOPList[0].m_POC = 1;
+        m_GOPList[0].m_numRefPicsActive = 4;
+    }
+
+    Bool verifiedGOP = false;
+    Bool errorGOP = false;
+    Int checkGOP = 1;
+    Int numRefs = 1;
+    Int refList[MAX_NUM_REF_PICS + 1];
+    refList[0] = 0;
+    Bool isOK[MAX_GOP];
+    for (Int i = 0; i < MAX_GOP; i++)
+    {
+        isOK[i] = false;
+    }
+
+    Int numOK = 0;
+    xConfirmPara(m_iIntraPeriod >= 0 && (m_iIntraPeriod % m_iGOPSize != 0), "Intra period must be a multiple of GOPSize, or -1");
+
+    for (Int i = 0; i < m_iGOPSize; i++)
+    {
+        if (m_GOPList[i].m_POC == m_iGOPSize)
+        {
+            xConfirmPara(m_GOPList[i].m_temporalId != 0, "The last frame in each GOP must have temporal ID = 0 ");
+        }
+    }
+
+    if ((m_iIntraPeriod != 1) && !m_loopFilterOffsetInPPS && m_DeblockingFilterControlPresent && (!m_bLoopFilterDisable))
+    {
+        for (Int i = 0; i < m_iGOPSize; i++)
+        {
+            xConfirmPara((m_GOPList[i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) < -6 ||
+                         (m_GOPList[i].m_betaOffsetDiv2 + m_loopFilterBetaOffsetDiv2) > 6,
+                         "Loop Filter Beta Offset div. 2 for one of the GOP entries exceeds supported range (-6 to 6)");
+            xConfirmPara((m_GOPList[i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) < -6 ||
+                         (m_GOPList[i].m_tcOffsetDiv2 + m_loopFilterTcOffsetDiv2) > 6,
+                         "Loop Filter Tc Offset div. 2 for one of the GOP entries exceeds supported range (-6 to 6)");
+        }
+    }
+
+    m_extraRPSs = 0;
+    //start looping through frames in coding order until we can verify that the GOP structure is correct.
+    while (!verifiedGOP && !errorGOP)
+    {
+        Int curGOP = (checkGOP - 1) % m_iGOPSize;
+        Int curPOC = ((checkGOP - 1) / m_iGOPSize) * m_iGOPSize + m_GOPList[curGOP].m_POC;
+        if (m_GOPList[curGOP].m_POC < 0)
+        {
+            printf("\nError: found fewer Reference Picture Sets than GOPSize\n");
+            errorGOP = true;
+        }
+        else
+        {
+            //check that all reference pictures are available, or have a POC < 0 meaning they might be available in the next GOP.
+            Bool beforeI = false;
+            for (Int i = 0; i < m_GOPList[curGOP].m_numRefPics; i++)
+            {
+                Int absPOC = curPOC + m_GOPList[curGOP].m_referencePics[i];
+                if (absPOC < 0)
+                {
+                    beforeI = true;
+                }
+                else
+                {
+                    Bool found = false;
+                    for (Int j = 0; j < numRefs; j++)
+                    {
+                        if (refList[j] == absPOC)
+                        {
+                            found = true;
+                            for (Int k = 0; k < m_iGOPSize; k++)
+                            {
+                                if (absPOC % m_iGOPSize == m_GOPList[k].m_POC % m_iGOPSize)
+                                {
+                                    if (m_GOPList[k].m_temporalId == m_GOPList[curGOP].m_temporalId)
+                                    {
+                                        m_GOPList[k].m_refPic = true;
+                                    }
+
+                                    m_GOPList[curGOP].m_usedByCurrPic[i] = m_GOPList[k].m_temporalId <=
+                                        m_GOPList[curGOP].m_temporalId;
+                                }
+                            }
+                        }
+                    }
+
+                    if (!found)
+                    {
+                        printf("\nError: ref pic %d is not available for GOP frame %d\n",
+                               m_GOPList[curGOP].m_referencePics[i],
+                               curGOP + 1);
+                        errorGOP = true;
+                    }
+                }
+            }
+
+            if (!beforeI && !errorGOP)
+            {
+                //all ref frames were present
+                if (!isOK[curGOP])
+                {
+                    numOK++;
+                    isOK[curGOP] = true;
+                    if (numOK == m_iGOPSize)
+                    {
+                        verifiedGOP = true;
+                    }
+                }
+            }
+            else
+            {
+                //create a new GOPEntry for this frame containing all the reference pictures that were available (POC > 0)
+                m_GOPList[m_iGOPSize + m_extraRPSs] = m_GOPList[curGOP];
+                Int newRefs = 0;
+                for (Int i = 0; i < m_GOPList[curGOP].m_numRefPics; i++)
+                {
+                    Int absPOC = curPOC + m_GOPList[curGOP].m_referencePics[i];
+                    if (absPOC >= 0)
+                    {
+                        m_GOPList[m_iGOPSize + m_extraRPSs].m_referencePics[newRefs] = m_GOPList[curGOP].m_referencePics[i];
+                        m_GOPList[m_iGOPSize + m_extraRPSs].m_usedByCurrPic[newRefs] = m_GOPList[curGOP].m_usedByCurrPic[i];
+                        newRefs++;
+                    }
+                }
+
+                Int numPrefRefs = m_GOPList[curGOP].m_numRefPicsActive;
+
+                for (Int offset = -1; offset > -checkGOP; offset--)
+                {
+                    //step backwards in coding order and include any extra available pictures we might find useful to replace the ones with POC < 0.
+                    Int offGOP = (checkGOP - 1 + offset) % m_iGOPSize;
+                    Int offPOC = ((checkGOP - 1 + offset) / m_iGOPSize) * m_iGOPSize + m_GOPList[offGOP].m_POC;
+                    if (offPOC >= 0 && m_GOPList[offGOP].m_temporalId <= m_GOPList[curGOP].m_temporalId)
+                    {
+                        Bool newRef = false;
+                        for (Int i = 0; i < numRefs; i++)
+                        {
+                            if (refList[i] == offPOC)
+                            {
+                                newRef = true;
+                            }
+                        }
+
+                        for (Int i = 0; i < newRefs; i++)
+                        {
+                            if (m_GOPList[m_iGOPSize + m_extraRPSs].m_referencePics[i] == offPOC - curPOC)
+                            {
+                                newRef = false;
+                            }
+                        }
+
+                        if (newRef)
+                        {
+                            Int insertPoint = newRefs;
+                            //this picture can be added, find appropriate place in list and insert it.
+                            if (m_GOPList[offGOP].m_temporalId == m_GOPList[curGOP].m_temporalId)
+                            {
+                                m_GOPList[offGOP].m_refPic = true;
+                            }
+
+                            for (Int j = 0; j < newRefs; j++)
+                            {
+                                if (m_GOPList[m_iGOPSize + m_extraRPSs].m_referencePics[j] < offPOC - curPOC ||
+                                    m_GOPList[m_iGOPSize + m_extraRPSs].m_referencePics[j] > 0)
+                                {
+                                    insertPoint = j;
+                                    break;
+                                }
+                            }
+
+                            Int prev = offPOC - curPOC;
+                            Int prevUsed = m_GOPList[offGOP].m_temporalId <= m_GOPList[curGOP].m_temporalId;
+                            for (Int j = insertPoint; j < newRefs + 1; j++)
+                            {
+                                Int newPrev = m_GOPList[m_iGOPSize + m_extraRPSs].m_referencePics[j];
+                                Int newUsed = m_GOPList[m_iGOPSize + m_extraRPSs].m_usedByCurrPic[j];
+                                m_GOPList[m_iGOPSize + m_extraRPSs].m_referencePics[j] = prev;
+                                m_GOPList[m_iGOPSize + m_extraRPSs].m_usedByCurrPic[j] = prevUsed;
+                                prevUsed = newUsed;
+                                prev = newPrev;
+                            }
+
+                            newRefs++;
+                        }
+                    }
+
+                    if (newRefs >= numPrefRefs)
+                    {
+                        break;
+                    }
+                }
+
+                m_GOPList[m_iGOPSize + m_extraRPSs].m_numRefPics = newRefs;
+                m_GOPList[m_iGOPSize + m_extraRPSs].m_POC = curPOC;
+                if (m_extraRPSs == 0)
+                {
+                    m_GOPList[m_iGOPSize + m_extraRPSs].m_interRPSPrediction = 0;
+                    m_GOPList[m_iGOPSize + m_extraRPSs].m_numRefIdc = 0;
+                }
+                else
+                {
+                    Int rIdx =  m_iGOPSize + m_extraRPSs - 1;
+                    Int refPOC = m_GOPList[rIdx].m_POC;
+                    Int refPics = m_GOPList[rIdx].m_numRefPics;
+                    Int newIdc = 0;
+                    for (Int i = 0; i <= refPics; i++)
+                    {
+                        Int deltaPOC = ((i != refPics) ? m_GOPList[rIdx].m_referencePics[i] : 0); // check if the reference abs POC is >= 0
+                        Int absPOCref = refPOC + deltaPOC;
+                        Int refIdc = 0;
+                        for (Int j = 0; j < m_GOPList[m_iGOPSize + m_extraRPSs].m_numRefPics; j++)
+                        {
+                            if ((absPOCref - curPOC) == m_GOPList[m_iGOPSize + m_extraRPSs].m_referencePics[j])
+                            {
+                                if (m_GOPList[m_iGOPSize + m_extraRPSs].m_usedByCurrPic[j])
+                                {
+                                    refIdc = 1;
+                                }
+                                else
+                                {
+                                    refIdc = 2;
+                                }
+                            }
+                        }
+
+                        m_GOPList[m_iGOPSize + m_extraRPSs].m_refIdc[newIdc] = refIdc;
+                        newIdc++;
+                    }
+
+                    m_GOPList[m_iGOPSize + m_extraRPSs].m_interRPSPrediction = 1;
+                    m_GOPList[m_iGOPSize + m_extraRPSs].m_numRefIdc = newIdc;
+                    m_GOPList[m_iGOPSize + m_extraRPSs].m_deltaRPS = refPOC - m_GOPList[m_iGOPSize + m_extraRPSs].m_POC;
+                }
+
+                curGOP = m_iGOPSize + m_extraRPSs;
+                m_extraRPSs++;
+            }
+
+            numRefs = 0;
+            for (Int i = 0; i < m_GOPList[curGOP].m_numRefPics; i++)
+            {
+                Int absPOC = curPOC + m_GOPList[curGOP].m_referencePics[i];
+                if (absPOC >= 0)
+                {
+                    refList[numRefs] = absPOC;
+                    numRefs++;
+                }
+            }
+
+            refList[numRefs] = curPOC;
+            numRefs++;
+        }
+
+        checkGOP++;
+    }
+
+    xConfirmPara(errorGOP, "Invalid GOP structure given");
+    m_maxTempLayer = 1;
+    for (Int i = 0; i < m_iGOPSize; i++)
+    {
+        if (m_GOPList[i].m_temporalId >= m_maxTempLayer)
+        {
+            m_maxTempLayer = m_GOPList[i].m_temporalId + 1;
+        }
+
+        xConfirmPara(m_GOPList[i].m_sliceType != 'B' && m_GOPList[i].m_sliceType != 'P', "Slice type must be equal to B or P");
+    }
+
+    for (Int i = 0; i < MAX_TLAYER; i++)
+    {
+        m_numReorderPics[i] = 0;
+        m_maxDecPicBuffering[i] = 0;
+    }
+
+    for (Int i = 0; i < m_iGOPSize; i++)
+    {
+        if (m_GOPList[i].m_numRefPics > m_maxDecPicBuffering[m_GOPList[i].m_temporalId])
+        {
+            m_maxDecPicBuffering[m_GOPList[i].m_temporalId] = m_GOPList[i].m_numRefPics;
+        }
+
+        Int highestDecodingNumberWithLowerPOC = 0;
+        for (Int j = 0; j < m_iGOPSize; j++)
+        {
+            if (m_GOPList[j].m_POC <= m_GOPList[i].m_POC)
+            {
+                highestDecodingNumberWithLowerPOC = j;
+            }
+        }
+
+        Int numReorder = 0;
+        for (Int j = 0; j < highestDecodingNumberWithLowerPOC; j++)
+        {
+            if (m_GOPList[j].m_temporalId <= m_GOPList[i].m_temporalId &&
+                m_GOPList[j].m_POC > m_GOPList[i].m_POC)
+            {
+                numReorder++;
+            }
+        }
+
+        if (numReorder > m_numReorderPics[m_GOPList[i].m_temporalId])
+        {
+            m_numReorderPics[m_GOPList[i].m_temporalId] = numReorder;
+        }
+    }
+
+    for (Int i = 0; i < MAX_TLAYER - 1; i++)
+    {
+        // a lower layer can not have higher value of m_numReorderPics than a higher layer
+        if (m_numReorderPics[i + 1] < m_numReorderPics[i])
+        {
+            m_numReorderPics[i + 1] = m_numReorderPics[i];
+        }
+
+        // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
+        if (m_numReorderPics[i] > m_maxDecPicBuffering[i])
+        {
+            m_maxDecPicBuffering[i] = m_numReorderPics[i];
+        }
+
+        // a lower layer can not have higher value of m_uiMaxDecPicBuffering than a higher layer
+        if (m_maxDecPicBuffering[i + 1] < m_maxDecPicBuffering[i])
+        {
+            m_maxDecPicBuffering[i + 1] = m_maxDecPicBuffering[i];
+        }
+    }
+
+    // the value of num_reorder_pics[ i ] shall be in the range of 0 to max_dec_pic_buffering[ i ], inclusive
+    if (m_numReorderPics[MAX_TLAYER - 1] > m_maxDecPicBuffering[MAX_TLAYER - 1])
+    {
+        m_maxDecPicBuffering[MAX_TLAYER - 1] = m_numReorderPics[MAX_TLAYER - 1];
+    }
+
+    if (m_vuiParametersPresentFlag && m_bitstreamRestrictionFlag)
+    {
+        Int PicSizeInSamplesY =  m_iSourceWidth * m_iSourceHeight;
+        if (tileFlag)
+        {
+            Int maxTileWidth = 0;
+            Int maxTileHeight = 0;
+            Int widthInCU =
+                (m_iSourceWidth % m_uiMaxCUWidth) ? m_iSourceWidth / m_uiMaxCUWidth + 1 : m_iSourceWidth / m_uiMaxCUWidth;
+            Int heightInCU =
+                (m_iSourceHeight % m_uiMaxCUHeight) ? m_iSourceHeight / m_uiMaxCUHeight + 1 : m_iSourceHeight / m_uiMaxCUHeight;
+            if (m_iUniformSpacingIdr)
+            {
+                maxTileWidth = m_uiMaxCUWidth * ((widthInCU + m_iNumColumnsMinus1) / (m_iNumColumnsMinus1 + 1));
+                maxTileHeight = m_uiMaxCUHeight * ((heightInCU + m_iNumRowsMinus1) / (m_iNumRowsMinus1 + 1));
+                // if only the last tile-row is one treeblock higher than the others
+                // the maxTileHeight becomes smaller if the last row of treeblocks has lower height than the others
+                if (!((heightInCU - 1) % (m_iNumRowsMinus1 + 1)))
+                {
+                    maxTileHeight = maxTileHeight - m_uiMaxCUHeight + (m_iSourceHeight % m_uiMaxCUHeight);
+                }
+
+                // if only the last tile-column is one treeblock wider than the others
+                // the maxTileWidth becomes smaller if the last column of treeblocks has lower width than the others
+                if (!((widthInCU - 1) % (m_iNumColumnsMinus1 + 1)))
+                {
+                    maxTileWidth = maxTileWidth - m_uiMaxCUWidth + (m_iSourceWidth % m_uiMaxCUWidth);
+                }
+            }
+            else // not uniform spacing
+            {
+                if (m_iNumColumnsMinus1 < 1)
+                {
+                    maxTileWidth = m_iSourceWidth;
+                }
+                else
+                {
+                    Int accColumnWidth = 0;
+                    for (Int col = 0; col < (m_iNumColumnsMinus1); col++)
+                    {
+                        maxTileWidth = m_pColumnWidth[col] > maxTileWidth ? m_pColumnWidth[col] : maxTileWidth;
+                        accColumnWidth += m_pColumnWidth[col];
+                    }
+
+                    maxTileWidth =
+                        (widthInCU -
+                         accColumnWidth) > maxTileWidth ? m_uiMaxCUWidth *
+                        (widthInCU - accColumnWidth) : m_uiMaxCUWidth * maxTileWidth;
+                }
+
+                if (m_iNumRowsMinus1 < 1)
+                {
+                    maxTileHeight = m_iSourceHeight;
+                }
+                else
+                {
+                    Int accRowHeight = 0;
+                    for (Int row = 0; row < (m_iNumRowsMinus1); row++)
+                    {
+                        maxTileHeight = m_pRowHeight[row] > maxTileHeight ? m_pRowHeight[row] : maxTileHeight;
+                        accRowHeight += m_pRowHeight[row];
+                    }
+
+                    maxTileHeight =
+                        (heightInCU -
+                         accRowHeight) > maxTileHeight ? m_uiMaxCUHeight *
+                        (heightInCU - accRowHeight) : m_uiMaxCUHeight * maxTileHeight;
+                }
+            }
+
+            Int maxSizeInSamplesY = maxTileWidth * maxTileHeight;
+            m_minSpatialSegmentationIdc = 4 * PicSizeInSamplesY / maxSizeInSamplesY - 4;
+        }
+        else if (m_iWaveFrontSynchro)
+        {
+            m_minSpatialSegmentationIdc = 4 * PicSizeInSamplesY / ((2 * m_iSourceHeight + m_iSourceWidth) * m_uiMaxCUHeight) - 4;
+        }
+        else if (m_sliceMode == 1)
+        {
+            m_minSpatialSegmentationIdc = 4 * PicSizeInSamplesY / (m_sliceArgument * m_uiMaxCUWidth * m_uiMaxCUHeight) - 4;
+        }
+        else
+        {
+            m_minSpatialSegmentationIdc = 0;
+        }
+    }
+
+    xConfirmPara(m_bUseLComb == false && m_numReorderPics[MAX_TLAYER - 1] != 0,
+                 "ListCombination can only be 0 in low delay coding (more precisely when L0 and L1 are identical)");                                                                // Note however this is not the full necessary condition as ref_pic_list_combination_flag can only be 0 if L0 == L1.
+    xConfirmPara(m_iWaveFrontSynchro < 0, "WaveFrontSynchro cannot be negative");
+    xConfirmPara(m_iWaveFrontSubstreams <= 0, "WaveFrontSubstreams must be positive");
+    xConfirmPara(m_iWaveFrontSubstreams > 1 && !m_iWaveFrontSynchro,
+                 "Must have WaveFrontSynchro > 0 in order to have WaveFrontSubstreams > 1");
+
+    xConfirmPara(m_decodedPictureHashSEIEnabled < 0 || m_decodedPictureHashSEIEnabled > 3, "this hash type is not correct!\n");
+
+#if J0149_TONE_MAPPING_SEI
+    if (m_toneMappingInfoSEIEnabled)
+    {
+        xConfirmPara(m_toneMapCodedDataBitDepth < 8 || m_toneMapCodedDataBitDepth > 14,
+                     "SEIToneMapCodedDataBitDepth must be in rage 8 to 14");
+        xConfirmPara(m_toneMapTargetBitDepth < 1 || (m_toneMapTargetBitDepth > 16 && m_toneMapTargetBitDepth < 255),
+                     "SEIToneMapTargetBitDepth must be in rage 1 to 16 or equal to 255");
+        xConfirmPara(m_toneMapModelId < 0 || m_toneMapModelId > 4, "SEIToneMapModelId must be in rage 0 to 4");
+        xConfirmPara(m_cameraIsoSpeedValue == 0, "SEIToneMapCameraIsoSpeedValue shall not be equal to 0");
+        xConfirmPara(m_extendedRangeWhiteLevel < 100, "SEIToneMapExtendedRangeWhiteLevel should be greater than or equal to 100");
+        xConfirmPara(m_nominalBlackLevelLumaCodeValue >= m_nominalWhiteLevelLumaCodeValue,
+                     "SEIToneMapNominalWhiteLevelLumaCodeValue shall be greater than SEIToneMapNominalBlackLevelLumaCodeValue");
+        xConfirmPara(
+            m_extendedWhiteLevelLumaCodeValue < m_nominalWhiteLevelLumaCodeValue,
+            "SEIToneMapExtendedWhiteLevelLumaCodeValue shall be greater than or equal to SEIToneMapNominalWhiteLevelLumaCodeValue");
+    }
+
+#endif // if J0149_TONE_MAPPING_SEI
+
+#if RATE_CONTROL_LAMBDA_DOMAIN
+    if (m_RCEnableRateControl)
+    {
+        if (m_RCForceIntraQP)
+        {
+            if (m_RCInitialQP == 0)
+            {
+                printf("\nInitial QP for rate control is not specified. Reset not to use force intra QP!");
+                m_RCForceIntraQP = false;
+            }
+        }
+
+        xConfirmPara(m_uiDeltaQpRD > 0, "Rate control cannot be used together with slice level multiple-QP optimization!\n");
+    }
+
+#else // if RATE_CONTROL_LAMBDA_DOMAIN
+    if (m_enableRateCtrl)
+    {
+        Int numLCUInWidth  = (m_iSourceWidth  / m_uiMaxCUWidth) + ((m_iSourceWidth  %  m_uiMaxCUWidth) ? 1 : 0);
+        Int numLCUInHeight = (m_iSourceHeight / m_uiMaxCUHeight) + ((m_iSourceHeight %  m_uiMaxCUHeight) ? 1 : 0);
+        Int numLCUInPic    =  numLCUInWidth * numLCUInHeight;
+
+        xConfirmPara((numLCUInPic % m_numLCUInUnit) != 0,
+                     "total number of LCUs in a frame should be completely divided by NumLCUInUnit");
+
+        m_iMaxDeltaQP       = MAX_DELTA_QP;
+        m_iMaxCuDQPDepth    = MAX_CUDQP_DEPTH;
+    }
+
+#endif // if RATE_CONTROL_LAMBDA_DOMAIN
+
+    xConfirmPara(!m_TransquantBypassEnableFlag && m_CUTransquantBypassFlagValue,
+                 "CUTransquantBypassFlagValue cannot be 1 when TransquantBypassEnableFlag is 0");
+
+    xConfirmPara(m_log2ParallelMergeLevel < 2, "Log2ParallelMergeLevel should be larger than or equal to 2");
+#if L0444_FPA_TYPE
+    if (m_framePackingSEIEnabled)
+    {
+        xConfirmPara(m_framePackingSEIType < 3 || m_framePackingSEIType > 5, "SEIFramePackingType must be in rage 3 to 5");
+    }
+
+#endif
+
+#undef xConfirmPara
+    if (check_failed)
+    {
+        exit(EXIT_FAILURE);
+    }
+}
+
+/** \todo use of global variables should be removed later
+ */
+Void TAppEncCfg::xSetGlobal()
+{
+    // set max CU width & height
+    g_uiMaxCUWidth  = m_uiMaxCUWidth;
+    g_uiMaxCUHeight = m_uiMaxCUHeight;
+
+    // compute actual CU depth with respect to config depth and max transform size
+    g_uiAddCUDepth  = 0;
+    while ((m_uiMaxCUWidth >> m_uiMaxCUDepth) > (1 << (m_uiQuadtreeTULog2MinSize + g_uiAddCUDepth)))
+    {
+        g_uiAddCUDepth++;
+    }
+
+    m_uiMaxCUDepth += g_uiAddCUDepth;
+    g_uiAddCUDepth++;
+    g_uiMaxCUDepth = m_uiMaxCUDepth;
+
+    // set internal bit-depth and constants
+    g_bitDepthY = m_internalBitDepthY;
+    g_bitDepthC = m_internalBitDepthC;
+
+    g_uiPCMBitDepthLuma = m_bPCMInputBitDepthFlag ? m_inputBitDepthY : m_internalBitDepthY;
+    g_uiPCMBitDepthChroma = m_bPCMInputBitDepthFlag ? m_inputBitDepthC : m_internalBitDepthC;
+}
+
+Void TAppEncCfg::xPrintParameter()
+{
+    printf("\n");
+    printf("Input          File          : %s\n", m_pchInputFile);
+    printf("Bitstream      File          : %s\n", m_pchBitstreamFile);
+    printf("Reconstruction File          : %s\n", m_pchReconFile);
+    printf("Real     Format              : %dx%d %dHz\n",
+           m_iSourceWidth - m_confLeft - m_confRight,
+           m_iSourceHeight - m_confTop - m_confBottom,
+           m_iFrameRate);
+    printf("Internal Format              : %dx%d %dHz\n", m_iSourceWidth, m_iSourceHeight, m_iFrameRate);
+    printf("Frame index                  : %u - %d (%d frames)\n",
+           m_FrameSkip,
+           m_FrameSkip + m_framesToBeEncoded - 1,
+           m_framesToBeEncoded);
+    printf("CU size / depth              : %d / %d\n", m_uiMaxCUWidth, m_uiMaxCUDepth);
+    printf("RQT trans. size (min / max)  : %d / %d\n", 1 << m_uiQuadtreeTULog2MinSize, 1 << m_uiQuadtreeTULog2MaxSize);
+    printf("Max RQT depth inter          : %d\n", m_uiQuadtreeTUMaxDepthInter);
+    printf("Max RQT depth intra          : %d\n", m_uiQuadtreeTUMaxDepthIntra);
+    printf("Min PCM size                 : %d\n", 1 << m_uiPCMLog2MinSize);
+    printf("Motion search range          : %d\n", m_iSearchRange);
+    printf("Intra period                 : %d\n", m_iIntraPeriod);
+    printf("Decoding refresh type        : %d\n", m_iDecodingRefreshType);
+    printf("QP                           : %5.2f\n", m_fQP);
+    printf("Max dQP signaling depth      : %d\n", m_iMaxCuDQPDepth);
+
+    printf("Cb QP Offset                 : %d\n", m_cbQpOffset);
+    printf("Cr QP Offset                 : %d\n", m_crQpOffset);
+
+    printf("QP adaptation                : %d (range=%d)\n", m_bUseAdaptiveQP, (m_bUseAdaptiveQP ? m_iQPAdaptationRange : 0));
+    printf("GOP size                     : %d\n", m_iGOPSize);
+    printf("Internal bit depth           : (Y:%d, C:%d)\n", m_internalBitDepthY, m_internalBitDepthC);
+    printf("PCM sample bit depth         : (Y:%d, C:%d)\n", g_uiPCMBitDepthLuma, g_uiPCMBitDepthChroma);
+#if RATE_CONTROL_LAMBDA_DOMAIN
+    printf("RateControl                  : %d\n", m_RCEnableRateControl);
+    if (m_RCEnableRateControl)
+    {
+        printf("TargetBitrate                : %d\n", m_RCTargetBitrate);
+        printf("KeepHierarchicalBit          : %d\n", m_RCKeepHierarchicalBit);
+        printf("LCULevelRC                   : %d\n", m_RCLCULevelRC);
+        printf("UseLCUSeparateModel          : %d\n", m_RCUseLCUSeparateModel);
+        printf("InitialQP                    : %d\n", m_RCInitialQP);
+        printf("ForceIntraQP                 : %d\n", m_RCForceIntraQP);
+    }
+
+#else // if RATE_CONTROL_LAMBDA_DOMAIN
+    printf("RateControl                  : %d\n", m_enableRateCtrl);
+    if (m_enableRateCtrl)
+    {
+        printf("TargetBitrate                : %d\n", m_targetBitrate);
+        printf("NumLCUInUnit                 : %d\n", m_numLCUInUnit);
+    }
+
+#endif // if RATE_CONTROL_LAMBDA_DOMAIN
+    printf("Max Num Merge Candidates     : %d\n", m_maxNumMergeCand);
+    printf("\n");
+
+    printf("TOOL CFG: ");
+    printf("IBD:%d ", g_bitDepthY > m_inputBitDepthY || g_bitDepthC > m_inputBitDepthC);
+    printf("HAD:%d ", m_bUseHADME);
+    printf("SRD:%d ", m_bUseSBACRD);
+    printf("RDQ:%d ", m_useRDOQ);
+    printf("RDQTS:%d ", m_useRDOQTS);
+#if L0232_RD_PENALTY
+    printf("RDpenalty:%d ", m_rdPenalty);
+#endif
+    printf("SQP:%d ", m_uiDeltaQpRD);
+    printf("ASR:%d ", m_bUseASR);
+    printf("LComb:%d ", m_bUseLComb);
+    printf("FEN:%d ", m_bUseFastEnc);
+    printf("ECU:%d ", m_bUseEarlyCU);
+    printf("FDM:%d ", m_useFastDecisionForMerge);
+    printf("CFM:%d ", m_bUseCbfFastMode);
+    printf("ESD:%d ", m_useEarlySkipDetection);
+    printf("RQT:%d ", 1);
+    printf("TransformSkip:%d ",     m_useTransformSkip);
+    printf("TransformSkipFast:%d ", m_useTransformSkipFast);
+    printf("Slice: M=%d ", m_sliceMode);
+    if (m_sliceMode != 0)
+    {
+        printf("A=%d ", m_sliceArgument);
+    }
+
+    printf("SliceSegment: M=%d ", m_sliceSegmentMode);
+    if (m_sliceSegmentMode != 0)
+    {
+        printf("A=%d ", m_sliceSegmentArgument);
+    }
+
+    printf("CIP:%d ", m_bUseConstrainedIntraPred);
+    printf("SAO:%d ", (m_bUseSAO) ? (1) : (0));
+    printf("PCM:%d ", (m_usePCM && (1 << m_uiPCMLog2MinSize) <= m_uiMaxCUWidth) ? 1 : 0);
+    printf("SAOLcuBasedOptimization:%d ", (m_saoLcuBasedOptimization) ? (1) : (0));
+
+    printf("LosslessCuEnabled:%d ", (m_useLossless) ? 1 : 0);
+    printf("WPP:%d ", (Int)m_useWeightedPred);
+    printf("WPB:%d ", (Int)m_useWeightedBiPred);
+    printf("PME:%d ", m_log2ParallelMergeLevel);
+    printf(" WaveFrontSynchro:%d WaveFrontSubstreams:%d",
+           m_iWaveFrontSynchro, m_iWaveFrontSubstreams);
+    printf(" ScalingList:%d ", m_useScalingListId);
+    printf("TMVPMode:%d ", m_TMVPModeId);
+#if ADAPTIVE_QP_SELECTION
+    printf("AQpS:%d", m_bUseAdaptQpSelect);
+#endif
+
+    printf(" SignBitHidingFlag:%d ", m_signHideFlag);
+    printf("RecalQP:%d", m_recalculateQPAccordingToLambda ? 1 : 0);
+    printf("\n\n");
+
+    fflush(stdout);
+}
+
+Bool confirmPara(Bool bflag, const Char *message)
+{
+    if (!bflag)
+        return false;
+
+    printf("Error: %s\n", message);
+    return true;
+}
+
+//! \}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/source/x265cfg.h	Wed Apr 17 14:11:17 2013 +0530
@@ -0,0 +1,354 @@
+/* The copyright in this software is being made available under the BSD
+ * License, included below. This software may be subject to other third party
+ * and contributor rights, including patent rights, and no such rights are
+ * granted under this license.
+ *
+ * Copyright (c) 2010-2013, ITU/ISO/IEC
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ *
+ *  * Redistributions of source code must retain the above copyright notice,
+ *    this list of conditions and the following disclaimer.
+ *  * Redistributions in binary form must reproduce the above copyright notice,
+ *    this list of conditions and the following disclaimer in the documentation
+ *    and/or other materials provided with the distribution.
+ *  * Neither the name of the ITU/ISO/IEC nor the names of its contributors may
+ *    be used to endorse or promote products derived from this software without
+ *    specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** \file     TAppEncCfg.h
+    \brief    Handle encoder configuration parameters (header)
+*/
+
+#ifndef __TAPPENCCFG__
+#define __TAPPENCCFG__
+
+#include "TLibCommon/CommonDef.h"
+
+#include "TLibEncoder/TEncCfg.h"
+#include "TLibVideoIO/TVideoIO.h"
+#include "TLibVideoIO/TVideoIOYuv.h"
+#include "TLibVideoIO/TVideoIOY4m.h"
+#include <sstream>
+//! \ingroup TAppEncoder
+//! \{
+
+// ====================================================================================================================
+// Class definition
+// ====================================================================================================================
+
+/// encoder configuration class
+class TAppEncCfg
+{
+protected:
+
+    // file I/O
+    Char     *m_pchInputFile;                                   ///< source file name
+    Char     *m_pchBitstreamFile;                               ///< output bitstream file
+    Char     *m_pchReconFile;                                   ///< output reconstruction file
+    Double    m_adLambdaModifier[MAX_TLAYER];                 ///< Lambda modifier array for each temporal layer
+    // source specification
+    Int       m_iFrameRate;                                     ///< source frame-rates (Hz)
+    UInt      m_FrameSkip;                                      ///< number of skipped frames from the beginning
+    Int       m_iSourceWidth;                                   ///< source width in pixel
+    Int       m_iSourceHeight;                                  ///< source height in pixel
+    Int       m_conformanceMode;
+    Int       m_confLeft;
+    Int       m_confRight;
+    Int       m_confTop;
+    Int       m_confBottom;
+    Int       m_framesToBeEncoded;                              ///< number of encoded frames
+    Int       m_aiPad[2];                                       ///< number of padded pixels for width and height
+    //Input source file handlers
+    TVideoIO*     m_cTVideoIOInputFile;     ///< input  file
+    TVideoIO*     m_cTVideoIOReconFile;       ///< output reconstruction file
+    hnd_t*      handler_input;
+    hnd_t*      handler_recon;
+    video_info_t  video_info;
+
+    // profile/level
+    Profile::Name m_profile;
+    Level::Tier   m_levelTier;
+    Level::Name   m_level;
+#if L0046_CONSTRAINT_FLAGS
+    Bool m_progressiveSourceFlag;
+    Bool m_interlacedSourceFlag;
+    Bool m_nonPackedConstraintFlag;
+    Bool m_frameOnlyConstraintFlag;
+#endif
+
+    // coding structure
+    Int       m_iIntraPeriod;                                   ///< period of I-slice (random access period)
+    Int       m_iDecodingRefreshType;                           ///< random access type
+    Int       m_iGOPSize;                                       ///< GOP size of hierarchical structure
+    Int       m_extraRPSs;                                      ///< extra RPSs added to handle CRA
+    GOPEntry  m_GOPList[MAX_GOP];                               ///< the coding structure entries from the config file
+    Int       m_numReorderPics[MAX_TLAYER];                     ///< total number of reorder pictures
+    Int       m_maxDecPicBuffering[MAX_TLAYER];                 ///< total number of reference pictures needed for decoding
+    Bool      m_bUseLComb;                                      ///< flag for using combined reference list for uni-prediction in B-slices (JCTVC-D421)
+    Bool      m_useTransformSkip;                               ///< flag for enabling intra transform skipping
+    Bool      m_useTransformSkipFast;                           ///< flag for enabling fast intra transform skipping
+    Bool      m_enableAMP;
+    // coding quality
+    Double    m_fQP;                                            ///< QP value of key-picture (floating point)
+    Int       m_iQP;                                            ///< QP value of key-picture (integer)
+    Char     *m_pchdQPFile;                                     ///< QP offset for each slice (initialized from external file)
+    Int      *m_aidQP;                                          ///< array of slice QP values
+    Int       m_iMaxDeltaQP;                                    ///< max. |delta QP|
+    UInt      m_uiDeltaQpRD;                                    ///< dQP range for multi-pass slice QP optimization
+    Int       m_iMaxCuDQPDepth;                                 ///< Max. depth for a minimum CuDQPSize (0:default)
+
+    Int       m_cbQpOffset;                                     ///< Chroma Cb QP Offset (0:default)
+    Int       m_crQpOffset;                                     ///< Chroma Cr QP Offset (0:default)
+
+#if ADAPTIVE_QP_SELECTION
+    Bool      m_bUseAdaptQpSelect;
+#endif
+
+    Bool      m_bUseAdaptiveQP;                                 ///< Flag for enabling QP adaptation based on a psycho-visual model
+    Int       m_iQPAdaptationRange;                             ///< dQP range by QP adaptation
+
+    Int       m_maxTempLayer;                                  ///< Max temporal layer
+
+    // coding unit (CU) definition
+    UInt      m_uiMaxCUWidth;                                   ///< max. CU width in pixel
+    UInt      m_uiMaxCUHeight;                                  ///< max. CU height in pixel
+    UInt      m_uiMaxCUDepth;                                   ///< max. CU depth
+
+    // transfom unit (TU) definition
+    UInt      m_uiQuadtreeTULog2MaxSize;
+    UInt      m_uiQuadtreeTULog2MinSize;
+
+    UInt      m_uiQuadtreeTUMaxDepthInter;
+    UInt      m_uiQuadtreeTUMaxDepthIntra;
+
+    // coding tools (bit-depth)
+    Int       m_inputBitDepthY;                               ///< bit-depth of input file (luma component)
+    Int       m_inputBitDepthC;                               ///< bit-depth of input file (chroma component)
+    Int       m_outputBitDepthY;                              ///< bit-depth of output file (luma component)
+    Int       m_outputBitDepthC;                              ///< bit-depth of output file (chroma component)
+    Int       m_internalBitDepthY;                            ///< bit-depth codec operates at in luma (input/output files will be converted)
+    Int       m_internalBitDepthC;                            ///< bit-depth codec operates at in chroma (input/output files will be converted)
+
+    // coding tools (PCM bit-depth)
+    Bool      m_bPCMInputBitDepthFlag;                          ///< 0: PCM bit-depth is internal bit-depth. 1: PCM bit-depth is input bit-depth.
+
+    // coding tool (lossless)
+    Bool      m_useLossless;                                    ///< flag for using lossless coding
+    Bool      m_bUseSAO;
+    Int       m_maxNumOffsetsPerPic;                            ///< SAO maximun number of offset per picture
+    Bool      m_saoLcuBoundary;                                 ///< SAO parameter estimation using non-deblocked pixels for LCU bottom and right boundary areas
+    Bool      m_saoLcuBasedOptimization;                        ///< SAO LCU-based optimization
+    // coding tools (loop filter)
+    Bool      m_bLoopFilterDisable;                             ///< flag for using deblocking filter
+    Bool      m_loopFilterOffsetInPPS;                         ///< offset for deblocking filter in 0 = slice header, 1 = PPS
+    Int       m_loopFilterBetaOffsetDiv2;                     ///< beta offset for deblocking filter
+    Int       m_loopFilterTcOffsetDiv2;                       ///< tc offset for deblocking filter
+    Bool      m_DeblockingFilterControlPresent;                 ///< deblocking filter control present flag in PPS
+#if L0386_DB_METRIC
+    Bool      m_DeblockingFilterMetric;                         ///< blockiness metric in encoder
+#endif
+
+    // coding tools (PCM)
+    Bool      m_usePCM;                                         ///< flag for using IPCM
+    UInt      m_pcmLog2MaxSize;                                 ///< log2 of maximum PCM block size
+    UInt      m_uiPCMLog2MinSize;                               ///< log2 of minimum PCM block size
+    Bool      m_bPCMFilterDisableFlag;                          ///< PCM filter disable flag
+
+    // coding tools (encoder-only parameters)
+    Bool      m_bUseSBACRD;                                     ///< flag for using RD optimization based on SBAC
+    Bool      m_bUseASR;                                        ///< flag for using adaptive motion search range
+    Bool      m_bUseHADME;                                      ///< flag for using HAD in sub-pel ME
+    Bool      m_useRDOQ;                                       ///< flag for using RD optimized quantization
+    Bool      m_useRDOQTS;                                     ///< flag for using RD optimized quantization for transform skip
+#if L0232_RD_PENALTY
+    Int      m_rdPenalty;                                      ///< RD-penalty for 32x32 TU for intra in non-intra slices (0: no RD-penalty, 1: RD-penalty, 2: maximum RD-penalty)
+#endif
+    Int       m_iFastSearch;                                    ///< ME mode, 0 = full, 1 = diamond, 2 = PMVFAST
+    Int       m_iSearchRange;                                   ///< ME search range
+    Int       m_bipredSearchRange;                              ///< ME search range for bipred refinement
+    Bool      m_bUseFastEnc;                                    ///< flag for using fast encoder setting
+    Bool      m_bUseEarlyCU;                                    ///< flag for using Early CU setting
+    Bool      m_useFastDecisionForMerge;                        ///< flag for using Fast Decision Merge RD-Cost
+    Bool      m_bUseCbfFastMode;                              ///< flag for using Cbf Fast PU Mode Decision
+    Bool      m_useEarlySkipDetection;                         ///< flag for using Early SKIP Detection
+    Int       m_sliceMode;                                     ///< 0: no slice limits, 1 : max number of CTBs per slice, 2: max number of bytes per slice,
+    ///< 3: max number of tiles per slice
+    Int       m_sliceArgument;                                 ///< argument according to selected slice mode
+    Int       m_sliceSegmentMode;                              ///< 0: no slice segment limits, 1 : max number of CTBs per slice segment, 2: max number of bytes per slice segment,
+    ///< 3: max number of tiles per slice segment
+    Int       m_sliceSegmentArgument;                          ///< argument according to selected slice segment mode
+
+    Bool      m_bLFCrossSliceBoundaryFlag;  ///< 1: filter across slice boundaries 0: do not filter across slice boundaries
+    Bool      m_bLFCrossTileBoundaryFlag;   ///< 1: filter across tile boundaries  0: do not filter across tile boundaries
+    Int       m_iUniformSpacingIdr;
+    Int       m_iNumColumnsMinus1;
+    Char     *m_pchColumnWidth;
+    Int       m_iNumRowsMinus1;
+    Char     *m_pchRowHeight;
+    UInt     *m_pColumnWidth;
+    UInt     *m_pRowHeight;
+    Int       m_iWaveFrontSynchro; //< 0: no WPP. >= 1: WPP is enabled, the "Top right" from which inheritance occurs is this LCU offset in the line above the current.
+    Int       m_iWaveFrontSubstreams; //< If iWaveFrontSynchro, this is the number of substreams per frame (dependent tiles) or per tile (independent tiles).
+
+    Bool      m_bUseConstrainedIntraPred;                       ///< flag for using constrained intra prediction
+
+    Int       m_decodedPictureHashSEIEnabled;                    ///< Checksum(3)/CRC(2)/MD5(1)/disable(0) acting on decoded picture hash SEI message
+    Int       m_recoveryPointSEIEnabled;
+    Int       m_bufferingPeriodSEIEnabled;
+    Int       m_pictureTimingSEIEnabled;
+#if J0149_TONE_MAPPING_SEI
+    Bool      m_toneMappingInfoSEIEnabled;
+    Int       m_toneMapId;
+    Bool      m_toneMapCancelFlag;
+    Bool      m_toneMapPersistenceFlag;
+    Int       m_toneMapCodedDataBitDepth;
+    Int       m_toneMapTargetBitDepth;
+    Int       m_toneMapModelId;
+    Int       m_toneMapMinValue;
+    Int       m_toneMapMaxValue;
+    Int       m_sigmoidMidpoint;
+    Int       m_sigmoidWidth;
+    Int       m_numPivots;
+    Int       m_cameraIsoSpeedIdc;
+    Int       m_cameraIsoSpeedValue;
+    Int       m_exposureCompensationValueSignFlag;
+    Int       m_exposureCompensationValueNumerator;
+    Int       m_exposureCompensationValueDenomIdc;
+    Int       m_refScreenLuminanceWhite;
+    Int       m_extendedRangeWhiteLevel;
+    Int       m_nominalBlackLevelLumaCodeValue;
+    Int       m_nominalWhiteLevelLumaCodeValue;
+    Int       m_extendedWhiteLevelLumaCodeValue;
+    Int      *m_startOfCodedInterval;
+    Int      *m_codedPivotValue;
+    Int      *m_targetPivotValue;
+#endif // if J0149_TONE_MAPPING_SEI
+    Int       m_framePackingSEIEnabled;
+    Int       m_framePackingSEIType;
+    Int       m_framePackingSEIId;
+    Int       m_framePackingSEIQuincunx;
+    Int       m_framePackingSEIInterpretation;
+    Int       m_displayOrientationSEIAngle;
+    Int       m_temporalLevel0IndexSEIEnabled;
+    Int       m_gradualDecodingRefreshInfoEnabled;
+    Int       m_decodingUnitInfoSEIEnabled;
+#if L0208_SOP_DESCRIPTION_SEI
+    Int       m_SOPDescriptionSEIEnabled;
+#endif
+#if K0180_SCALABLE_NESTING_SEI
+    Int       m_scalableNestingSEIEnabled;
+#endif
+    // weighted prediction
+    Bool      m_useWeightedPred;                    ///< Use of weighted prediction in P slices
+    Bool      m_useWeightedBiPred;                  ///< Use of bi-directional weighted prediction in B slices
+
+    UInt      m_log2ParallelMergeLevel;                         ///< Parallel merge estimation region
+    UInt      m_maxNumMergeCand;                                ///< Max number of merge candidates
+
+    Int       m_TMVPModeId;
+    Int       m_signHideFlag;
+#if RATE_CONTROL_LAMBDA_DOMAIN
+    Bool      m_RCEnableRateControl;                ///< enable rate control or not
+    Int       m_RCTargetBitrate;                    ///< target bitrate when rate control is enabled
+    Bool      m_RCKeepHierarchicalBit;              ///< whether keeping hierarchical bit allocation structure or not
+    Bool      m_RCLCULevelRC;                       ///< true: LCU level rate control; false: picture level rate control
+    Bool      m_RCUseLCUSeparateModel;              ///< use separate R-lambda model at LCU level
+    Int       m_RCInitialQP;                        ///< inital QP for rate control
+    Bool      m_RCForceIntraQP;                     ///< force all intra picture to use initial QP or not
+#else
+    Bool      m_enableRateCtrl;                                   ///< Flag for using rate control algorithm
+    Int       m_targetBitrate;                                 ///< target bitrate
+    Int       m_numLCUInUnit;                                  ///< Total number of LCUs in a frame should be completely divided by the NumLCUInUnit
+#endif // if RATE_CONTROL_LAMBDA_DOMAIN
+    Int       m_useScalingListId;                               ///< using quantization matrix
+    Char     *m_scalingListFile;                                ///< quantization matrix file name
+
+    Bool      m_TransquantBypassEnableFlag;                     ///< transquant_bypass_enable_flag setting in PPS.
+    Bool      m_CUTransquantBypassFlagValue;                    ///< if transquant_bypass_enable_flag, the fixed value to use for the per-CU cu_transquant_bypass_flag.
+
+    Bool      m_recalculateQPAccordingToLambda;                 ///< recalculate QP value according to the lambda value
+    Bool      m_useStrongIntraSmoothing;                        ///< enable strong intra smoothing for 32x32 blocks where the reference samples are flat
+    Int       m_activeParameterSetsSEIEnabled;
+
+    Bool      m_vuiParametersPresentFlag;                       ///< enable generation of VUI parameters
+    Bool      m_aspectRatioInfoPresentFlag;                     ///< Signals whether aspect_ratio_idc is present
+    Int       m_aspectRatioIdc;                                 ///< aspect_ratio_idc
+    Int       m_sarWidth;                                       ///< horizontal size of the sample aspect ratio
+    Int       m_sarHeight;                                      ///< vertical size of the sample aspect ratio
+    Bool      m_overscanInfoPresentFlag;                        ///< Signals whether overscan_appropriate_flag is present
+    Bool      m_overscanAppropriateFlag;                        ///< Indicates whether conformant decoded pictures are suitable for display using overscan
+    Bool      m_videoSignalTypePresentFlag;                     ///< Signals whether video_format, video_full_range_flag, and colour_description_present_flag are present
+    Int       m_videoFormat;                                    ///< Indicates representation of pictures
+    Bool      m_videoFullRangeFlag;                             ///< Indicates the black level and range of luma and chroma signals
+    Bool      m_colourDescriptionPresentFlag;                   ///< Signals whether colour_primaries, transfer_characteristics and matrix_coefficients are present
+    Int       m_colourPrimaries;                                ///< Indicates chromaticity coordinates of the source primaries
+    Int       m_transferCharacteristics;                        ///< Indicates the opto-electronic transfer characteristics of the source
+    Int       m_matrixCoefficients;                             ///< Describes the matrix coefficients used in deriving luma and chroma from RGB primaries
+    Bool      m_chromaLocInfoPresentFlag;                       ///< Signals whether chroma_sample_loc_type_top_field and chroma_sample_loc_type_bottom_field are present
+    Int       m_chromaSampleLocTypeTopField;                    ///< Specifies the location of chroma samples for top field
+    Int       m_chromaSampleLocTypeBottomField;                 ///< Specifies the location of chroma samples for bottom field
+    Bool      m_neutralChromaIndicationFlag;                    ///< Indicates that the value of all decoded chroma samples is equal to 1<<(BitDepthCr-1)
+    Bool      m_defaultDisplayWindowFlag;                       ///< Indicates the presence of the default window parameters
+    Int       m_defDispWinLeftOffset;                           ///< Specifies the left offset from the conformance window of the default window
+    Int       m_defDispWinRightOffset;                          ///< Specifies the right offset from the conformance window of the default window
+    Int       m_defDispWinTopOffset;                            ///< Specifies the top offset from the conformance window of the default window
+    Int       m_defDispWinBottomOffset;                         ///< Specifies the bottom offset from the conformance window of the default window
+    Bool      m_frameFieldInfoPresentFlag;                      ///< Indicates that pic_struct values are present in picture timing SEI messages
+    Bool      m_pocProportionalToTimingFlag;                    ///< Indicates that the POC value is proportional to the output time w.r.t. first picture in CVS
+    Int       m_numTicksPocDiffOneMinus1;                       ///< Number of ticks minus 1 that for a POC difference of one
+    Bool      m_bitstreamRestrictionFlag;                       ///< Signals whether bitstream restriction parameters are present
+    Bool      m_tilesFixedStructureFlag;                        ///< Indicates that each active picture parameter set has the same values of the syntax elements related to tiles
+    Bool      m_motionVectorsOverPicBoundariesFlag;             ///< Indicates that no samples outside the picture boundaries are used for inter prediction
+    Int       m_minSpatialSegmentationIdc;                      ///< Indicates the maximum size of the spatial segments in the pictures in the coded video sequence
+    Int       m_maxBytesPerPicDenom;                            ///< Indicates a number of bytes not exceeded by the sum of the sizes of the VCL NAL units associated with any coded picture
+    Int       m_maxBitsPerMinCuDenom;                           ///< Indicates an upper bound for the number of bits of coding_unit() data
+    Int       m_log2MaxMvLengthHorizontal;                      ///< Indicate the maximum absolute value of a decoded horizontal MV component in quarter-pel luma units
+    Int       m_log2MaxMvLengthVertical;                        ///< Indicate the maximum absolute value of a decoded vertical MV component in quarter-pel luma units
+
+    // internal member functions
+    Void  xSetGlobal();                                         ///< set global variables
+    Void  xCheckParameter();                                    ///< check validity of configuration values
+    Void  xPrintParameter();                                    ///< print configuration values
+    Void  xPrintUsage();                                        ///< print usage
+#if SIGNAL_BITRATE_PICRATE_IN_VPS
+    Int       m_bitRatePicRateMaxTLayers;                       ///< Indicates max. number of sub-layers for which bit rate is signalled.
+    Bool     *m_bitRateInfoPresentFlag;                         ///< Indicates whether bit rate information is signalled
+    Bool     *m_picRateInfoPresentFlag;                         ///< Indicates whether pic rate information is signalled
+    Int      *m_avgBitRate;                                     ///< Indicates avg. bit rate information for various sub-layers
+    Int      *m_maxBitRate;                                     ///< Indicates max. bit rate information for various sub-layers
+    Int      *m_avgPicRate;                                     ///< Indicates avg. picture rate information for various sub-layers
+    Int      *m_constantPicRateIdc;                                ///< Indicates constant picture rate idc for various sub-layers
+#endif
+#
+
+public:
+
+    TAppEncCfg();
+    virtual ~TAppEncCfg();
+
+public:
+
+    Void  create();                                             ///< create option handling class
+    Void  destroy();                                            ///< destroy option handling class
+    Bool  parseCfg(Int argc, Char * argv[]);                     ///< parse configuration file to fill member variables
+}; // END CLASS DEFINITION TAppEncCfg
+
+//! \}
+
+#endif // __TAPPENCCFG__