Index: /branches/SHM-dev/source/App/TAppDownConvert/DownConvert.h
===================================================================
--- /branches/SHM-dev/source/App/TAppDownConvert/DownConvert.h	(revision 1334)
+++ /branches/SHM-dev/source/App/TAppDownConvert/DownConvert.h	(revision 1335)
@@ -40,5 +40,5 @@
 
 #include <cassert>
-#include "../../Lib/TLibCommon/TypeDef.h"
+#include "../../Lib/TLibCommon/CommonDef.h"
 
 #ifndef  gMax
Index: /branches/SHM-dev/source/Lib/TLibCommon/CommonDef.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/CommonDef.h	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibCommon/CommonDef.h	(revision 1335)
@@ -33,5 +33,5 @@
 
 /** \file     CommonDef.h
-    \brief    Defines constants, macros and tool parameters
+    \brief    Defines version information, constants and small in-line functions
 */
 
@@ -116,24 +116,139 @@
 // ====================================================================================================================
 
-#define MAX_GOP                     64          ///< max. value of hierarchical GOP size
-
-#define MAX_NUM_REF_PICS            16          ///< max. number of pictures used for reference
-#define MAX_NUM_REF                 16          ///< max. number of entries in picture reference list
-
-#define MAX_UINT                    0xFFFFFFFFU ///< max. value of unsigned 32-bit integer
-#define MAX_INT                     2147483647  ///< max. value of signed 32-bit integer
-#define MAX_INT64                   0x7FFFFFFFFFFFFFFFLL  ///< max. value of signed 64-bit integer
-#if RExt__HIGH_BIT_DEPTH_SUPPORT
-#define MAX_INTERMEDIATE_INT        MAX_INT64
-#else
-#define MAX_INTERMEDIATE_INT        MAX_INT
-#endif
-
-#define MAX_DOUBLE                  1.7e+308    ///< max. value of Double-type value
-
-#define MIN_QP                      0
-#define MAX_QP                      51
-
-#define NOT_VALID                   -1
+static const UInt   MAX_UINT =                            0xFFFFFFFFU; ///< max. value of unsigned 32-bit integer
+static const Int    MAX_INT =                              2147483647; ///< max. value of signed 32-bit integer
+static const Double MAX_DOUBLE =                             1.7e+308; ///< max. value of Double-type value
+
+// ====================================================================================================================
+// Coding tool configuration
+// ====================================================================================================================
+// Most of these should not be changed - they resolve the meaning of otherwise magic numbers.
+
+static const Int MAX_GOP =                                         64; ///< max. value of hierarchical GOP size
+static const Int MAX_NUM_REF_PICS =                                16; ///< max. number of pictures used for reference
+static const Int MAX_NUM_REF =                                     16; ///< max. number of entries in picture reference list
+static const Int MAX_QP =                                          51;
+static const Int NOT_VALID =                                       -1;
+
+static const Int AMVP_MAX_NUM_CANDS =                               2; ///< AMVP: advanced motion vector prediction - max number of final candidates
+static const Int AMVP_MAX_NUM_CANDS_MEM =                           3; ///< AMVP: advanced motion vector prediction - max number of candidates
+static const Int AMVP_DECIMATION_FACTOR =                           4;
+static const Int MRG_MAX_NUM_CANDS =                                5; ///< MERGE
+
+
+static const Int MAX_TLAYER =                                       7; ///< Explicit temporal layer QP offset - max number of temporal layer
+
+static const Int ADAPT_SR_SCALE =                                   1; ///< division factor for adaptive search range
+
+static const Int MAX_NUM_PICS_IN_SOP =                           1024;
+
+static const Int MAX_NESTING_NUM_OPS =                           1024;
+static const Int MAX_NESTING_NUM_LAYER =                           64;
+
+static const Int MAX_VPS_NUM_HRD_PARAMETERS =                       1;
+static const Int MAX_VPS_OP_SETS_PLUS1 =                         1024;
+static const Int MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1 =         1;
+
+static const Int MAXIMUM_INTRA_FILTERED_WIDTH =                    16;
+static const Int MAXIMUM_INTRA_FILTERED_HEIGHT =                   16;
+
+static const Int MAX_CPB_CNT =                                     32; ///< Upper bound of (cpb_cnt_minus1 + 1)
+#if SVC_EXTENSION
+static const Int MAX_NUM_LAYER_IDS =                               63;
+#else
+static const Int MAX_NUM_LAYER_IDS =                               64;
+#endif
+
+static const Int COEF_REMAIN_BIN_REDUCTION =                        3; ///< indicates the level at which the VLC transitions from Golomb-Rice to TU+EG(k)
+
+static const Int CU_DQP_TU_CMAX =                                   5; ///< max number bins for truncated unary
+static const Int CU_DQP_EG_k =                                      0; ///< expgolomb order
+
+static const Int SBH_THRESHOLD =                                    4; ///< value of the fixed SBH controlling threshold
+
+static const Int C1FLAG_NUMBER =                                    8; // maximum number of largerThan1 flag coded in one chunk:  16 in HM5
+static const Int C2FLAG_NUMBER =                                    1; // maximum number of largerThan2 flag coded in one chunk:  16 in HM5
+
+static const Int MAX_NUM_VPS =                                     16;
+static const Int MAX_NUM_SPS =                                     16;
+static const Int MAX_NUM_PPS =                                     64;
+
+
+static const Int MLS_GRP_NUM =                                     64; ///< Max number of coefficient groups, max(16, 64)
+static const Int MLS_CG_LOG2_WIDTH =                                2;
+static const Int MLS_CG_LOG2_HEIGHT =                               2;
+static const Int MLS_CG_SIZE =                                      4; ///< Coefficient group size of 4x4; = MLS_CG_LOG2_WIDTH + MLS_CG_LOG2_HEIGHT
+
+#if ADAPTIVE_QP_SELECTION
+static const Int ARL_C_PRECISION =                                  7; ///< G382: 7-bit arithmetic precision
+static const Int LEVEL_RANGE =                                     30; ///< G382: max coefficient level in statistics collection
+#endif
+
+static const Int RVM_VCEGAM10_M =                                   4;
+
+static const Int FAST_UDI_MAX_RDMODE_NUM =                         35; ///< maximum number of RD comparison in fast-UDI estimation loop
+
+static const Int NUM_INTRA_MODE =                                  36;
+static const Int PLANAR_IDX =                                       0;
+static const Int VER_IDX =                                         26; ///< index for intra VERTICAL   mode
+static const Int HOR_IDX =                                         10; ///< index for intra HORIZONTAL mode
+static const Int DC_IDX =                                           1; ///< index for intra DC mode
+static const Int NUM_CHROMA_MODE =                                  5; ///< total number of chroma modes
+static const Int DM_CHROMA_IDX =                                   36; ///< chroma mode index for derived from luma intra mode
+
+static const Int MDCS_ANGLE_LIMIT =                                 4; ///< 0 = Horizontal/vertical only, 1 = Horizontal/vertical +/- 1, 2 = Horizontal/vertical +/- 2 etc...
+static const Int MDCS_MAXIMUM_WIDTH =                               8; ///< (measured in pixels) TUs with width greater than this can only use diagonal scan
+static const Int MDCS_MAXIMUM_HEIGHT =                              8; ///< (measured in pixels) TUs with height greater than this can only use diagonal scan
+
+
+static const Int LOG2_MAX_NUM_COLUMNS_MINUS1 =                      7;
+static const Int LOG2_MAX_NUM_ROWS_MINUS1 =                         7;
+
+static const Int CABAC_INIT_PRESENT_FLAG =                          1;
+
+static const Int LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS =   4;
+static const Int CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS = 8;
+
+static const Int MAX_NUM_LONG_TERM_REF_PICS =                      33;
+static const Int NUM_LONG_TERM_REF_PIC_SPS =                        0;
+
+
+static const Int MAX_QP_OFFSET_LIST_SIZE =                          6; ///< Maximum size of QP offset list is 6 entries
+
+// Cost mode support
+static const Int LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP =      0; ///< QP to use for lossless coding.
+static const Int LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME =4; ///< QP' to use for mixed_lossy_lossless coding.
+
+static const Int RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS =     4;
+static const Int RExt__GOLOMB_RICE_INCREMENT_DIVISOR =              4;
+
+static const Int RExt__PREDICTION_WEIGHTING_ANALYSIS_DC_PRECISION = 0; ///< Additional fixed bit precision used during encoder-side weighting prediction analysis. Currently only used when high_precision_prediction_weighting_flag is set, for backwards compatibility reasons.
+
+static const Int MAX_TIMECODE_SEI_SETS =                            3; ///< Maximum number of time sets
+
+static const Int MAX_CU_DEPTH =                                     6; ///< log2(CTUSize)
+static const Int MAX_CU_SIZE =                                     64; ///< = 1<<(MAX_CU_DEPTH)
+static const Int MIN_PU_SIZE =                                      4;
+static const Int MIN_TU_SIZE =                                      4;
+static const Int MAX_TU_SIZE =                                     32;
+static const Int MAX_NUM_PART_IDXS_IN_CTU_WIDTH = MAX_CU_SIZE/MIN_PU_SIZE; ///< maximum number of partition indices across the width of a CTU (or height of a CTU)
+static const Int SCALING_LIST_REM_NUM =                             6;
+
+static const Int QUANT_SHIFT =                                     14; ///< Q(4) = 2^14
+static const Int IQUANT_SHIFT =                                     6;
+static const Int SCALE_BITS =                                      15; ///< For fractional bit estimates in RDOQ
+
+static const Int SCALING_LIST_NUM = MAX_NUM_COMPONENT * NUMBER_OF_PREDICTION_MODES; ///< list number for quantization matrix
+
+static const Int SCALING_LIST_START_VALUE =                        8 ; ///< start value for dpcm mode
+static const Int MAX_MATRIX_COEF_NUM =                            64 ; ///< max coefficient number for quantization matrix
+static const Int MAX_MATRIX_SIZE_NUM =                             8 ; ///< max size number for quantization matrix
+static const Int SCALING_LIST_BITS =                               8 ; ///< bit depth of scaling list entries
+static const Int LOG2_SCALING_LIST_NEUTRAL_VALUE =                 4 ; ///< log2 of the value that, when used in a scaling list, has no effect on quantisation
+static const Int SCALING_LIST_DC =                                16 ; ///< default DC value
+
+static const Int CONTEXT_STATE_BITS =                              6 ;
+static const Int LAST_SIGNIFICANT_GROUPS =                        10 ;
+
 
 // ====================================================================================================================
@@ -180,113 +295,4 @@
 template <typename ValueType> inline ValueType rightShiftEvenRounding(const ValueType value, const UInt shift) { return (shift == 0) ? value : ((value + (1<<(shift-1))-1 + ((value>>shift)&1)) >> shift) ; }
 #endif
-
-// ====================================================================================================================
-// Coding tool configuration
-// ====================================================================================================================
-
-// AMVP: advanced motion vector prediction
-#define AMVP_MAX_NUM_CANDS          2           ///< max number of final candidates
-#define AMVP_MAX_NUM_CANDS_MEM      3           ///< max number of candidates
-// MERGE
-#define MRG_MAX_NUM_CANDS           5
-
-// Reference memory management
-#define DYN_REF_FREE                0           ///< dynamic free of reference memories
-
-// Explicit temporal layer QP offset
-#define MAX_TLAYER                  7           ///< max number of temporal layer
-
-// Fast estimation of generalized B in low-delay mode
-#define GPB_SIMPLE_UNI              1           ///< Simple mode for uni-direction
-
-// Adaptive search range depending on POC difference
-#define ADAPT_SR_SCALE              1           ///< division factor for adaptive search range
-
-// Early-skip threshold (encoder)
-#define EARLY_SKIP_THRES            1.50        ///< if RD < thres*avg[BestSkipRD]
-
-
-#define MAX_CHROMA_FORMAT_IDC      3
-
-// TODO: Existing names used for the different NAL unit types can be altered to better reflect the names in the spec.
-//       However, the names in the spec are not yet stable at this point. Once the names are stable, a cleanup
-//       effort can be done without use of macros to alter the names used to indicate the different NAL unit types.
-enum NalUnitType
-{
-  NAL_UNIT_CODED_SLICE_TRAIL_N = 0, // 0
-  NAL_UNIT_CODED_SLICE_TRAIL_R,     // 1
-
-  NAL_UNIT_CODED_SLICE_TSA_N,       // 2
-  NAL_UNIT_CODED_SLICE_TSA_R,       // 3
-
-  NAL_UNIT_CODED_SLICE_STSA_N,      // 4
-  NAL_UNIT_CODED_SLICE_STSA_R,      // 5
-
-  NAL_UNIT_CODED_SLICE_RADL_N,      // 6
-  NAL_UNIT_CODED_SLICE_RADL_R,      // 7
-
-  NAL_UNIT_CODED_SLICE_RASL_N,      // 8
-  NAL_UNIT_CODED_SLICE_RASL_R,      // 9
-
-  NAL_UNIT_RESERVED_VCL_N10,
-  NAL_UNIT_RESERVED_VCL_R11,
-  NAL_UNIT_RESERVED_VCL_N12,
-  NAL_UNIT_RESERVED_VCL_R13,
-  NAL_UNIT_RESERVED_VCL_N14,
-  NAL_UNIT_RESERVED_VCL_R15,
-
-  NAL_UNIT_CODED_SLICE_BLA_W_LP,    // 16
-  NAL_UNIT_CODED_SLICE_BLA_W_RADL,  // 17
-  NAL_UNIT_CODED_SLICE_BLA_N_LP,    // 18
-  NAL_UNIT_CODED_SLICE_IDR_W_RADL,  // 19
-  NAL_UNIT_CODED_SLICE_IDR_N_LP,    // 20
-  NAL_UNIT_CODED_SLICE_CRA,         // 21
-  NAL_UNIT_RESERVED_IRAP_VCL22,
-  NAL_UNIT_RESERVED_IRAP_VCL23,
-
-  NAL_UNIT_RESERVED_VCL24,
-  NAL_UNIT_RESERVED_VCL25,
-  NAL_UNIT_RESERVED_VCL26,
-  NAL_UNIT_RESERVED_VCL27,
-  NAL_UNIT_RESERVED_VCL28,
-  NAL_UNIT_RESERVED_VCL29,
-  NAL_UNIT_RESERVED_VCL30,
-  NAL_UNIT_RESERVED_VCL31,
-
-  NAL_UNIT_VPS,                     // 32
-  NAL_UNIT_SPS,                     // 33
-  NAL_UNIT_PPS,                     // 34
-  NAL_UNIT_ACCESS_UNIT_DELIMITER,   // 35
-  NAL_UNIT_EOS,                     // 36
-  NAL_UNIT_EOB,                     // 37
-  NAL_UNIT_FILLER_DATA,             // 38
-  NAL_UNIT_PREFIX_SEI,              // 39
-  NAL_UNIT_SUFFIX_SEI,              // 40
-
-  NAL_UNIT_RESERVED_NVCL41,
-  NAL_UNIT_RESERVED_NVCL42,
-  NAL_UNIT_RESERVED_NVCL43,
-  NAL_UNIT_RESERVED_NVCL44,
-  NAL_UNIT_RESERVED_NVCL45,
-  NAL_UNIT_RESERVED_NVCL46,
-  NAL_UNIT_RESERVED_NVCL47,
-  NAL_UNIT_UNSPECIFIED_48,
-  NAL_UNIT_UNSPECIFIED_49,
-  NAL_UNIT_UNSPECIFIED_50,
-  NAL_UNIT_UNSPECIFIED_51,
-  NAL_UNIT_UNSPECIFIED_52,
-  NAL_UNIT_UNSPECIFIED_53,
-  NAL_UNIT_UNSPECIFIED_54,
-  NAL_UNIT_UNSPECIFIED_55,
-  NAL_UNIT_UNSPECIFIED_56,
-  NAL_UNIT_UNSPECIFIED_57,
-  NAL_UNIT_UNSPECIFIED_58,
-  NAL_UNIT_UNSPECIFIED_59,
-  NAL_UNIT_UNSPECIFIED_60,
-  NAL_UNIT_UNSPECIFIED_61,
-  NAL_UNIT_UNSPECIFIED_62,
-  NAL_UNIT_UNSPECIFIED_63,
-  NAL_UNIT_INVALID,
-};
 
 #if SVC_EXTENSION
Index: /branches/SHM-dev/source/Lib/TLibCommon/Debug.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/Debug.cpp	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibCommon/Debug.cpp	(revision 1335)
@@ -47,5 +47,5 @@
 static const UInt settingValueWidth = 3;
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
 // these strings are used to reorder the debug output so that the encoder and decoder match.
 const Char *debug_reorder_data_inter_token[MAX_NUM_COMPONENT+1]
@@ -153,5 +153,5 @@
 EnvVar DebugOptionList::ForceChromaMode       ("FORCE_CHROMA_MODE", "0", "Force a particular intra direction for chroma (0-5)"                                            );
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
 EnvVar DebugOptionList::DebugString_Structure ("DEBUG_STRUCTURE",   "0", "Produce output on chosen structure                        bit0=intra, bit1=inter");
 EnvVar DebugOptionList::DebugString_Pred      ("DEBUG_PRED",        "0", "Produce output on prediction data.                        bit0=intra, bit1=inter");
@@ -179,6 +179,4 @@
   PRINT_CONSTANT(O0043_BEST_EFFORT_DECODING,                                        settingNameWidth, settingValueWidth);
 
-  PRINT_CONSTANT(RD_TEST_SAO_DISABLE_AT_PICTURE_LEVEL,                              settingNameWidth, settingValueWidth);
-
   //------------------------------------------------
 
@@ -193,10 +191,10 @@
 UInt  g_debugCounter  = 0;
 
-#ifdef DEBUG_ENCODER_SEARCH_BINS
+#if DEBUG_ENCODER_SEARCH_BINS
 const UInt debugEncoderSearchBinTargetLine = 0;
 const UInt debugEncoderSearchBinWindow     = 1000000;
 #endif
 
-#ifdef DEBUG_CABAC_BINS
+#if DEBUG_CABAC_BINS
 const UInt debugCabacBinTargetLine = 0;
 const UInt debugCabacBinWindow     = 1000000;
@@ -458,5 +456,5 @@
 }
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
 Int DebugStringGetPredModeMask(PredMode mode)
 {
Index: /branches/SHM-dev/source/Lib/TLibCommon/Debug.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/Debug.h	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibCommon/Debug.h	(revision 1335)
@@ -47,5 +47,5 @@
 #include <TLibCommon/CommonDef.h>
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
 extern const Char *debug_reorder_data_inter_token[MAX_NUM_COMPONENT+1];
 extern const Char *partSizeToString[NUMBER_OF_PART_SIZES];
@@ -103,5 +103,5 @@
   extern EnvVar ForceChromaMode;
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
   extern EnvVar DebugString_Structure;
   extern EnvVar DebugString_Pred;
@@ -122,10 +122,10 @@
 extern UInt g_debugCounter;
 
-#ifdef DEBUG_ENCODER_SEARCH_BINS
+#if DEBUG_ENCODER_SEARCH_BINS
 extern const UInt debugEncoderSearchBinTargetLine;
 extern const UInt debugEncoderSearchBinWindow;
 #endif
 
-#ifdef DEBUG_CABAC_BINS
+#if DEBUG_CABAC_BINS
 extern const UInt debugCabacBinTargetLine;
 extern const UInt debugCabacBinWindow;
@@ -270,5 +270,5 @@
 // ---------------------------------------------------------------------------------------------- //
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
   Int DebugStringGetPredModeMask(PredMode mode);
   Void DebugInterPredResiReco(std::string &sDebug, TComYuv &pred, TComYuv &resi, TComYuv &reco, Int predmode_mask);
Index: /branches/SHM-dev/source/Lib/TLibCommon/SEI.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/SEI.h	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibCommon/SEI.h	(revision 1335)
@@ -40,5 +40,5 @@
 #include <cstring>
 
-#include "TypeDef.h"
+#include "CommonDef.h"
 #include "libmd5/MD5.h"
 #if SVC_EXTENSION
Index: /branches/SHM-dev/source/Lib/TLibCommon/TCom3DAsymLUT.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TCom3DAsymLUT.cpp	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TCom3DAsymLUT.cpp	(revision 1335)
@@ -42,5 +42,5 @@
 #include <algorithm>
 
-#include "TypeDef.h"
+#include "CommonDef.h"
 #include "TCom3DAsymLUT.h"
 #include "TComPicYuv.h"
Index: /branches/SHM-dev/source/Lib/TLibCommon/TCom3DAsymLUT.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TCom3DAsymLUT.h	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TCom3DAsymLUT.h	(revision 1335)
@@ -40,5 +40,5 @@
 #define __TCOM3DASYMLUT__
 
-#include "TypeDef.h"
+#include "CommonDef.h"
 
 #if CGS_3D_ASYMLUT
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComCodingStatistics.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComCodingStatistics.h	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComCodingStatistics.h	(revision 1335)
@@ -35,5 +35,5 @@
 #define __TCOMCODINGSTATISTICS__
 
-#include "TypeDef.h"
+#include "CommonDef.h"
 #include <stdio.h>
 #include <string>
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComInterpolationFilter.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComInterpolationFilter.h	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComInterpolationFilter.h	(revision 1335)
@@ -40,5 +40,5 @@
 #define __TCOMINTERPOLATIONFILTER__
 
-#include "TypeDef.h"
+#include "CommonDef.h"
 
 //! \ingroup TLibCommon
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComPattern.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComPattern.cpp	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComPattern.cpp	(revision 1335)
@@ -146,5 +146,5 @@
 
   Int   iPicStride = pcCU->getPic()->getStride(compID);
-  Bool  bNeighborFlags[4 * MAX_NUM_SPU_W + 1];
+  Bool  bNeighborFlags[4 * MAX_NUM_PART_IDXS_IN_CTU_WIDTH + 1];
   Int   iNumIntraNeighbor = 0;
 
@@ -164,5 +164,5 @@
   assert(uiROIWidth*uiROIHeight <= m_iYuvExtSize);
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
   std::stringstream ss(stringstream::out);
 #endif
@@ -181,5 +181,5 @@
 
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
     if (DebugOptionList::DebugString_Pred.getInt()&DebugStringGetPredModeMask(MODE_INTRA))
     {
@@ -301,5 +301,5 @@
       *piDestPtr=*piSrcPtr; // far right is not filtered
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
     if (DebugOptionList::DebugString_Pred.getInt()&DebugStringGetPredModeMask(MODE_INTRA))
     {
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComRom.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComRom.cpp	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComRom.cpp	(revision 1335)
@@ -249,8 +249,8 @@
 // ====================================================================================================================
 
-UInt g_auiZscanToRaster [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, };
-UInt g_auiRasterToZscan [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, };
-UInt g_auiRasterToPelX  [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, };
-UInt g_auiRasterToPelY  [ MAX_NUM_SPU_W*MAX_NUM_SPU_W ] = { 0, };
+UInt g_auiZscanToRaster [ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ] = { 0, };
+UInt g_auiRasterToZscan [ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ] = { 0, };
+UInt g_auiRasterToPelX  [ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ] = { 0, };
+UInt g_auiRasterToPelY  [ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ] = { 0, };
 
 const UInt g_auiPUOffset[NUMBER_OF_PART_SIZES] = { 0, 8, 4, 4, 2, 10, 1, 5};
@@ -668,48 +668,35 @@
 Int g_posScalingFactor [MAX_LAYERS][2] = {{0,0}, {0,0}};
 
-std::string NaluToStr( NalUnitType nalu )
-{
-  switch( nalu )
-  {
-  case NAL_UNIT_CODED_SLICE_TRAIL_N:
-    return "TRAIL_N";
-  case NAL_UNIT_CODED_SLICE_TRAIL_R:
-    return "TRAIL_R";
-  
-  case NAL_UNIT_CODED_SLICE_TSA_N:
-    return "  TSA_N";
-  case NAL_UNIT_CODED_SLICE_TSA_R:
-    return "  TSA_R";
-  
-  case NAL_UNIT_CODED_SLICE_STSA_N:
-    return " STSA_N";
-  case NAL_UNIT_CODED_SLICE_STSA_R:
-    return " STSA_R";
-
-  case NAL_UNIT_CODED_SLICE_RADL_N:
-    return " RADL_N";
-  case NAL_UNIT_CODED_SLICE_RADL_R:
-    return " RADL_R";
-  
-  case NAL_UNIT_CODED_SLICE_RASL_N:
-    return " RASL_N";
-  case NAL_UNIT_CODED_SLICE_RASL_R:
-    return " RASL_R";
-
-  case NAL_UNIT_CODED_SLICE_BLA_W_LP:
-  case NAL_UNIT_CODED_SLICE_BLA_W_RADL:
-  case NAL_UNIT_CODED_SLICE_BLA_N_LP:
-    return "    BLA";
-
-  case NAL_UNIT_CODED_SLICE_IDR_W_RADL:
-  case NAL_UNIT_CODED_SLICE_IDR_N_LP:
-    return "    IDR";
-  
-  case NAL_UNIT_CODED_SLICE_CRA:
-    return "    CRA";
-
-  default:
-    return "       ";
-  };
+std::string NaluToStr( NalUnitType type )
+{
+  switch (type)
+  {
+    case NAL_UNIT_CODED_SLICE_TRAIL_R:    return "   TRAIL_R";
+    case NAL_UNIT_CODED_SLICE_TRAIL_N:    return "   TRAIL_N";
+    case NAL_UNIT_CODED_SLICE_TSA_R:      return "     TSA_R";
+    case NAL_UNIT_CODED_SLICE_TSA_N:      return "     TSA_N";
+    case NAL_UNIT_CODED_SLICE_STSA_R:     return "    STSA_R";
+    case NAL_UNIT_CODED_SLICE_STSA_N:     return "    STSA_N";
+    case NAL_UNIT_CODED_SLICE_BLA_W_LP:   return "  BLA_W_LP";
+    case NAL_UNIT_CODED_SLICE_BLA_W_RADL: return "BLA_W_RADL";
+    case NAL_UNIT_CODED_SLICE_BLA_N_LP:   return "  BLA_N_LP";
+    case NAL_UNIT_CODED_SLICE_IDR_W_RADL: return "IDR_W_RADL";
+    case NAL_UNIT_CODED_SLICE_IDR_N_LP:   return "  IDR_N_LP";
+    case NAL_UNIT_CODED_SLICE_CRA:        return "       CRA";
+    case NAL_UNIT_CODED_SLICE_RADL_R:     return "    RADL_R";
+    case NAL_UNIT_CODED_SLICE_RADL_N:     return "    RADL_N";
+    case NAL_UNIT_CODED_SLICE_RASL_R:     return "    RASL_R";
+    case NAL_UNIT_CODED_SLICE_RASL_N:     return "    RASL_N";
+    case NAL_UNIT_VPS:                    return "       VPS";
+    case NAL_UNIT_SPS:                    return "       SPS";
+    case NAL_UNIT_PPS:                    return "       PPS";
+    case NAL_UNIT_ACCESS_UNIT_DELIMITER:  return "       AUD";
+    case NAL_UNIT_EOS:                    return "       EOS";
+    case NAL_UNIT_EOB:                    return "       EOB";
+    case NAL_UNIT_FILLER_DATA:            return "    FILLER";
+    case NAL_UNIT_PREFIX_SEI:             return "       SEI";
+    case NAL_UNIT_SUFFIX_SEI:             return "       SEI";
+    default:                              return "       UNK";
+  }
 }
 #if LAYER_CTB
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComRom.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComRom.h	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComRom.h	(revision 1335)
@@ -48,17 +48,4 @@
 
 // ====================================================================================================================
-// Macros
-// ====================================================================================================================
-
-#define     MAX_CU_DEPTH             6                          // log2(CTUSize)
-#define     MAX_CU_SIZE             (1<<(MAX_CU_DEPTH))         // maximum allowable size of CU, surely 64? (not 1<<7 = 128)
-#define     MIN_PU_SIZE              4
-#define     MIN_TU_SIZE              4
-#define     MAX_TU_SIZE             32
-#define     MAX_NUM_SPU_W           (MAX_CU_SIZE/MIN_PU_SIZE)   // maximum number of SPU in horizontal line
-
-#define     SCALING_LIST_REM_NUM     6
-
-// ====================================================================================================================
 // Initialize / destroy functions
 // ====================================================================================================================
@@ -72,6 +59,6 @@
 
 // flexible conversion from relative to absolute index
-extern       UInt   g_auiZscanToRaster[ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
-extern       UInt   g_auiRasterToZscan[ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
+extern       UInt   g_auiZscanToRaster[ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ];
+extern       UInt   g_auiRasterToZscan[ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ];
 extern       UInt*  g_scanOrder[SCAN_NUMBER_OF_GROUP_TYPES][SCAN_NUMBER_OF_TYPES][ MAX_CU_DEPTH ][ MAX_CU_DEPTH ];
 
@@ -80,23 +67,10 @@
 
 // conversion of partition index to picture pel position
-extern       UInt   g_auiRasterToPelX[ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
-extern       UInt   g_auiRasterToPelY[ MAX_NUM_SPU_W*MAX_NUM_SPU_W ];
+extern       UInt   g_auiRasterToPelX[ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ];
+extern       UInt   g_auiRasterToPelY[ MAX_NUM_PART_IDXS_IN_CTU_WIDTH*MAX_NUM_PART_IDXS_IN_CTU_WIDTH ];
 
 Void         initRasterToPelXY ( UInt uiMaxCUWidth, UInt uiMaxCUHeight, UInt uiMaxDepth );
 
 extern const UInt g_auiPUOffset[NUMBER_OF_PART_SIZES];
-
-#define QUANT_SHIFT                14 // Q(4) = 2^14
-#define IQUANT_SHIFT                6
-#define SCALE_BITS                 15 // Inherited from TMuC, pressumably for fractional bit estimates in RDOQ
-
-#define SQRT2                      11585
-#define SQRT2_SHIFT                13
-#define INVSQRT2                   11585
-#define INVSQRT2_SHIFT             14
-#define ADDITIONAL_MULTIPLIER_BITS 14
-
-#define SHIFT_INV_1ST               7 // Shift after first inverse transform stage
-#define SHIFT_INV_2ND              12 // Shift after second inverse transform stage
 
 extern const Int g_quantScales[SCALING_LIST_REM_NUM];             // Q(QP%6)
@@ -122,10 +96,4 @@
 extern const UChar  g_aucChromaScale[NUM_CHROMA_FORMAT][chromaQPMappingTableSize];
 
-// ====================================================================================================================
-// Entropy Coding
-// ====================================================================================================================
-
-#define CONTEXT_STATE_BITS             6
-#define LAST_SIGNIFICANT_GROUPS       10
 
 // ====================================================================================================================
@@ -158,8 +126,4 @@
 
 extern       Char   g_aucConvertToBit  [ MAX_CU_SIZE+1 ];   // from width to log2(width)-2
-
-#ifndef ENC_DEC_TRACE
-#define ENC_DEC_TRACE 0
-#endif
 
 
@@ -195,14 +159,4 @@
 #endif
 
-
-#define SCALING_LIST_NUM (MAX_NUM_COMPONENT * NUMBER_OF_PREDICTION_MODES) ///< list number for quantization matrix
-
-#define SCALING_LIST_START_VALUE 8                                        ///< start value for dpcm mode
-#define MAX_MATRIX_COEF_NUM 64                                            ///< max coefficient number for quantization matrix
-#define MAX_MATRIX_SIZE_NUM 8                                             ///< max size number for quantization matrix
-#define SCALING_LIST_BITS 8                                               ///< bit depth of scaling list entries
-#define LOG2_SCALING_LIST_NEUTRAL_VALUE 4                                 ///< log2 of the value that, when used in a scaling list, has no effect on quantisation
-#define SCALING_LIST_DC 16                                                ///< default DC value
-
 extern const Char *MatrixType[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM];
 extern const Char *MatrixType_DC[SCALING_LIST_SIZE_NUM][SCALING_LIST_NUM];
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComSlice.h	(revision 1335)
@@ -1429,6 +1429,6 @@
   TComSPSRExt      m_spsRangeExtension;
 
-  static const Int m_winUnitX[MAX_CHROMA_FORMAT_IDC+1];
-  static const Int m_winUnitY[MAX_CHROMA_FORMAT_IDC+1];
+  static const Int m_winUnitX[NUM_CHROMA_FORMAT];
+  static const Int m_winUnitY[NUM_CHROMA_FORMAT];
   TComPTL          m_pcPTL;
 
@@ -1465,6 +1465,6 @@
   Void                   setChromaFormatIdc (ChromaFormat i)                                             { m_chromaFormatIdc = i;                                               }
 
-  static Int             getWinUnitX (Int chromaFormatIdc)                                               { assert (chromaFormatIdc >= 0 && chromaFormatIdc <= MAX_CHROMA_FORMAT_IDC); return m_winUnitX[chromaFormatIdc]; }
-  static Int             getWinUnitY (Int chromaFormatIdc)                                               { assert (chromaFormatIdc >= 0 && chromaFormatIdc <= MAX_CHROMA_FORMAT_IDC); return m_winUnitY[chromaFormatIdc]; }
+  static Int             getWinUnitX (Int chromaFormatIdc)                                               { assert (chromaFormatIdc >= 0 && chromaFormatIdc < NUM_CHROMA_FORMAT); return m_winUnitX[chromaFormatIdc]; }
+  static Int             getWinUnitY (Int chromaFormatIdc)                                               { assert (chromaFormatIdc >= 0 && chromaFormatIdc < NUM_CHROMA_FORMAT); return m_winUnitY[chromaFormatIdc]; }
 
   // structure
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComTrQuant.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComTrQuant.cpp	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComTrQuant.cpp	(revision 1335)
@@ -1516,5 +1516,5 @@
     else
     {
-#ifdef DEBUG_TRANSFORM_AND_QUANTISE
+#if DEBUG_TRANSFORM_AND_QUANTISE
       std::cout << g_debugCounter << ": " << uiWidth << "x" << uiHeight << " channel " << compID << " TU at input to transform\n";
       printBlock(pcResidual, uiWidth, uiHeight, uiStride);
@@ -1537,5 +1537,5 @@
       }
 
-#ifdef DEBUG_TRANSFORM_AND_QUANTISE
+#if DEBUG_TRANSFORM_AND_QUANTISE
       std::cout << g_debugCounter << ": " << uiWidth << "x" << uiHeight << " channel " << compID << " TU between transform and quantiser\n";
       printBlock(m_plTempCoeff, uiWidth, uiHeight, uiWidth);
@@ -1549,5 +1549,5 @@
               uiAbsSum, compID, cQP );
 
-#ifdef DEBUG_TRANSFORM_AND_QUANTISE
+#if DEBUG_TRANSFORM_AND_QUANTISE
       std::cout << g_debugCounter << ": " << uiWidth << "x" << uiHeight << " channel " << compID << " TU at output of quantiser\n";
       printBlock(rpcCoeff, uiWidth, uiHeight, uiWidth);
@@ -1603,5 +1603,5 @@
   }
 
-#if defined DEBUG_STRING
+#if DEBUG_STRING
   if (psDebug)
   {
@@ -1627,5 +1627,5 @@
   else
   {
-#ifdef DEBUG_TRANSFORM_AND_QUANTISE
+#if DEBUG_TRANSFORM_AND_QUANTISE
     std::cout << g_debugCounter << ": " << uiWidth << "x" << uiHeight << " channel " << compID << " TU at input to dequantiser\n";
     printBlock(pcCoeff, uiWidth, uiHeight, uiWidth);
@@ -1634,10 +1634,10 @@
     xDeQuant(rTu, pcCoeff, m_plTempCoeff, compID, cQP);
 
-#ifdef DEBUG_TRANSFORM_AND_QUANTISE
+#if DEBUG_TRANSFORM_AND_QUANTISE
     std::cout << g_debugCounter << ": " << uiWidth << "x" << uiHeight << " channel " << compID << " TU between dequantiser and inverse-transform\n";
     printBlock(m_plTempCoeff, uiWidth, uiHeight, uiWidth);
 #endif
 
-#if defined DEBUG_STRING
+#if DEBUG_STRING
     if (psDebug)
     {
@@ -1652,5 +1652,5 @@
       xITransformSkip( m_plTempCoeff, pcResidual, uiStride, rTu, compID );
 
-#if defined DEBUG_STRING
+#if DEBUG_STRING
       if (psDebug)
       {
@@ -1675,5 +1675,5 @@
       xIT( channelBitDepth, rTu.useDST(compID), m_plTempCoeff, pcResidual, uiStride, uiWidth, uiHeight, pcCU->getSlice()->getSPS()->getMaxLog2TrDynamicRange(toChannelType(compID)) );
 
-#if defined DEBUG_STRING
+#if DEBUG_STRING
       if (psDebug)
       {
@@ -1686,5 +1686,5 @@
     }
 
-#ifdef DEBUG_TRANSFORM_AND_QUANTISE
+#if DEBUG_TRANSFORM_AND_QUANTISE
     std::cout << g_debugCounter << ": " << uiWidth << "x" << uiHeight << " channel " << compID << " TU at output of inverse-transform\n";
     printBlock(pcResidual, uiWidth, uiHeight, uiStride);
@@ -1727,5 +1727,5 @@
     {
       DEBUG_STRING_NEW(sTemp)
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
       std::string *psDebug=((DebugOptionList::DebugString_InvTran.getInt()&(pcCU->isIntra(absPartIdxTU)?1:(pcCU->isInter(absPartIdxTU)?2:4)))!=0) ? &sTemp : 0;
 #endif
@@ -1733,5 +1733,5 @@
       invTransformNxN( rTu, compID, pResi, uiStride, pcCoeff, cQP DEBUG_STRING_PASS_INTO(psDebug) );
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
       if (psDebug != 0)
       {
@@ -2289,5 +2289,5 @@
       const Int64  tmpLevel                = Int64(abs(plSrcCoeff[ uiBlkPos ])) * quantisationCoefficient;
 
-      const Intermediate_Int lLevelDouble  = (Intermediate_Int)min<Int64>(tmpLevel, MAX_INTERMEDIATE_INT - (Intermediate_Int(1) << (iQBits - 1)));
+      const Intermediate_Int lLevelDouble  = (Intermediate_Int)min<Int64>(tmpLevel, std::numeric_limits<Intermediate_Int>::max() - (Intermediate_Int(1) << (iQBits - 1)));
 
 #if ADAPTIVE_QP_SELECTION
@@ -2621,5 +2621,5 @@
         {
           // calculate the cost
-          Int64 minCostInc = MAX_INT64, curCost = MAX_INT64;
+          Int64 minCostInc = std::numeric_limits<Int64>::max(), curCost = std::numeric_limits<Int64>::max();
           Int minPos = -1, finalChange = 0, curChange = 0;
 
@@ -2648,5 +2648,5 @@
                 if(n==firstNZPosInCG && abs(piDstCoeff[uiBlkPos])==1)
                 {
-                  curCost = MAX_INT64;
+                  curCost = std::numeric_limits<Int64>::max();
                 }
                 else
@@ -2666,5 +2666,5 @@
                 if(thissignbit != signbit )
                 {
-                  curCost = MAX_INT64;
+                  curCost = std::numeric_limits<Int64>::max();
                 }
               }
Index: /branches/SHM-dev/source/Lib/TLibCommon/TComUpsampleFilter.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TComUpsampleFilter.cpp	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TComUpsampleFilter.cpp	(revision 1335)
@@ -1,3 +1,3 @@
-#include "TypeDef.h"
+#include "CommonDef.h"
 #if SVC_EXTENSION
 #include "TComUpsampleFilter.h"
Index: /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibCommon/TypeDef.h	(revision 1335)
@@ -33,9 +33,13 @@
 
 /** \file     TypeDef.h
-    \brief    Define basic types, new types and enumerations
+    \brief    Define macros, basic types, new types and enumerations
 */
 
 #ifndef __TYPEDEF__
 #define __TYPEDEF__
+
+#ifndef __COMMONDEF__
+#error Include CommonDef.h not TypeDef.h
+#endif
 
 #include <vector>
@@ -117,4 +121,8 @@
 #define MAX_VPS_NUM_SCALABILITY_TYPES    16
 #define MAX_REF_LAYERS                   7
+#define MAX_VPS_OP_LAYER_SETS_PLUS1          (MAX_LAYERS+1)
+#define MAX_VPS_LAYER_SETS_PLUS1                       1024
+#define MAX_VPS_OUTPUT_LAYER_SETS_PLUS1                1024
+#define MAX_VPS_LAYER_IDX_PLUS1                   MAX_LAYERS
 
 #endif // SVC_EXTENSION
@@ -128,11 +136,92 @@
 // ====================================================================================================================
 
-// #define DEBUG_STRING                 // enable to print out final decision debug info at encoder and decoder
-// #define DEBUG_ENCODER_SEARCH_BINS    // enable to print out each bin as it is coded during encoder search
-// #define DEBUG_CABAC_BINS             // enable to print out each bin as it is coded during final encode and decode
-// #define DEBUG_INTRA_SEARCH_COSTS     // enable to print out the cost for each mode during encoder search
-// #define DEBUG_TRANSFORM_AND_QUANTISE // enable to print out each TU as it passes through the transform-quantise-dequantise-inverseTransform process
-
-#ifdef DEBUG_STRING
+#define DEBUG_STRING                                      0 ///< When enabled, prints out final decision debug info at encoder and decoder
+#define DEBUG_ENCODER_SEARCH_BINS                         0 ///< When enabled, prints out each bin as it is coded during encoder search
+#define DEBUG_CABAC_BINS                                  0 ///< When enabled, prints out each bin as it is coded during final encode and decode
+#define DEBUG_INTRA_SEARCH_COSTS                          0 ///< When enabled, prints out the cost for each mode during encoder search
+#define DEBUG_TRANSFORM_AND_QUANTISE                      0 ///< When enabled, prints out each TU as it passes through the transform-quantise-dequantise-inverseTransform process
+
+#define ENVIRONMENT_VARIABLE_DEBUG_AND_TEST               0 ///< When enabled, allows control of debug modifications via environment variables
+#define PRINT_MACRO_VALUES                                1 ///< When enabled, the encoder prints out a list of the non-environment-variable controlled macros and their values on startup
+
+// TODO: rename this macro to DECODER_DEBUG_BIT_STATISTICS (may currently cause merge issues with other branches)
+// This can be enabled by the makefile
+#ifndef RExt__DECODER_DEBUG_BIT_STATISTICS
+#define RExt__DECODER_DEBUG_BIT_STATISTICS                0 ///< 0 (default) = decoder reports as normal, 1 = decoder produces bit usage statistics (will impact decoder run time by up to ~10%)
+#endif
+
+// This can be enabled by the makefile
+#ifndef ENC_DEC_TRACE
+#define ENC_DEC_TRACE                                     0
+#endif
+
+#define PRINT_RPS_INFO                                    0 ///< Enable/disable the printing of bits used to send the RPS.
+
+// ====================================================================================================================
+// Tool Switches - transitory (these macros are likely to be removed in future revisions)
+// ====================================================================================================================
+
+#define ALLOW_RECOVERY_POINT_AS_RAP                       1
+#define AMP_SAD                                           1 ///< dedicated SAD functions for AMP
+#define BUGFIX_INTRAPERIOD                                1
+#define DECODER_CHECK_SUBSTREAM_AND_SLICE_TRAILING_BYTES  1
+#define DYN_REF_FREE                                      0 ///< Reference memory management - dynamic free of reference memories
+#define RDO_WITHOUT_DQP_BITS                              0 ///< Disable counting dQP bits in RDO-based mode decision
+#define SAO_ENCODE_ALLOW_USE_PREDEBLOCK                   1
+#define T0196_SELECTIVE_RDOQ                              1 ///< selective RDOQ
+#define TILE_SIZE_CHECK                                   1
+#define WRITE_BACK                                        1 ///< Enable/disable the encoder to replace the deltaPOC and Used by current from the config file with the values derived by the refIdc parameter.
+
+// ====================================================================================================================
+// Tool Switches
+// ====================================================================================================================
+
+#define ADAPTIVE_QP_SELECTION                             1 ///< G382: Adaptive reconstruction levels, non-normative part for adaptive QP selection
+
+#define AMP_ENC_SPEEDUP                                   1 ///< encoder only speed-up by AMP mode skipping
+#if AMP_ENC_SPEEDUP
+#define AMP_MRG                                           1 ///< encoder only force merge for AMP partition (no motion search for AMP)
+#endif
+
+#define FAST_BIT_EST                                      1 ///< G763: Table-based bit estimation for CABAC
+
+#define HHI_RQT_INTRA_SPEEDUP                             1 ///< tests one best mode with full rqt
+#define HHI_RQT_INTRA_SPEEDUP_MOD                         0 ///< tests two best modes with full rqt
+
+#if HHI_RQT_INTRA_SPEEDUP_MOD && !HHI_RQT_INTRA_SPEEDUP
+#error
+#endif
+
+#define MATRIX_MULT                                       0 ///< Brute force matrix multiplication instead of partial butterfly
+
+#define O0043_BEST_EFFORT_DECODING                        0 ///< 0 (default) = disable code related to best effort decoding, 1 = enable code relating to best effort decoding [ decode-side only ].
+
+#define RDOQ_CHROMA_LAMBDA                                1 ///< F386: weighting of chroma for RDOQ
+
+// This can be enabled by the makefile
+#ifndef RExt__HIGH_BIT_DEPTH_SUPPORT
+#define RExt__HIGH_BIT_DEPTH_SUPPORT                      0 ///< 0 (default) use data type definitions for 8-10 bit video, 1 = use larger data types to allow for up to 16-bit video (originally developed as part of N0188)
+#endif
+
+
+// ====================================================================================================================
+// Derived macros
+// ====================================================================================================================
+
+#if RExt__HIGH_BIT_DEPTH_SUPPORT
+#define FULL_NBIT                                         1 ///< When enabled, use distortion measure derived from all bits of source data, otherwise discard (bitDepth - 8) least-significant bits of distortion
+#define RExt__HIGH_PRECISION_FORWARD_TRANSFORM            1 ///< 0 use original 6-bit transform matrices for both forward and inverse transform, 1 (default) = use original matrices for inverse transform and high precision matrices for forward transform
+#else
+#define FULL_NBIT                                         0 ///< When enabled, use distortion measure derived from all bits of source data, otherwise discard (bitDepth - 8) least-significant bits of distortion
+#define RExt__HIGH_PRECISION_FORWARD_TRANSFORM            0 ///< 0 (default) use original 6-bit transform matrices for both forward and inverse transform, 1 = use original matrices for inverse transform and high precision matrices for forward transform
+#endif
+
+#if FULL_NBIT
+# define DISTORTION_PRECISION_ADJUSTMENT(x)  0
+#else
+# define DISTORTION_PRECISION_ADJUSTMENT(x) (x)
+#endif
+
+#if DEBUG_STRING
   #define DEBUG_STRING_PASS_INTO(name) , name
   #define DEBUG_STRING_PASS_INTO_OPTIONAL(name, exp) , (exp==0)?0:name
@@ -158,205 +247,7 @@
 #endif
 
-
-// ====================================================================================================================
-// Tool Switches
-// ====================================================================================================================
-#define T0196_SELECTIVE_RDOQ                              1 ///< selective RDOQ
-
-#define ALLOW_RECOVERY_POINT_AS_RAP                       1
-#define BUGFIX_INTRAPERIOD                                1
-
-#define SAO_ENCODE_ALLOW_USE_PREDEBLOCK                   1
-
-#define TILE_SIZE_CHECK                                   1
-
-#define MAX_NUM_PICS_IN_SOP                            1024
-
-#define MAX_NESTING_NUM_OPS                            1024
-#define MAX_NESTING_NUM_LAYER                            64
-
-#if SVC_EXTENSION
-#define MAX_VPS_OP_LAYER_SETS_PLUS1          (MAX_LAYERS+1)
-#define MAX_VPS_LAYER_SETS_PLUS1                       1024
-#define MAX_VPS_OUTPUT_LAYER_SETS_PLUS1                1024
-#define MAX_VPS_LAYER_IDX_PLUS1                   MAX_LAYERS
-#else
-#define MAX_VPS_NUM_HRD_PARAMETERS                        1
-#define MAX_VPS_OP_SETS_PLUS1                          1024
-#define MAX_VPS_NUH_RESERVED_ZERO_LAYER_ID_PLUS1          1
-#endif
-
-#define MAXIMUM_INTRA_FILTERED_WIDTH                     16
-#define MAXIMUM_INTRA_FILTERED_HEIGHT                    16
-
-#define MAX_CPB_CNT                                      32 ///< Upper bound of (cpb_cnt_minus1 + 1)
-
-#if SVC_EXTENSION
-#define MAX_NUM_LAYER_IDS                                63
-#else
-#define MAX_NUM_LAYER_IDS                                64
-#endif
-
-#define COEF_REMAIN_BIN_REDUCTION                         3 ///< indicates the level at which the VLC
-                                                            ///< transitions from Golomb-Rice to TU+EG(k)
-
-#define CU_DQP_TU_CMAX                                    5 ///< max number bins for truncated unary
-#define CU_DQP_EG_k                                       0 ///< expgolomb order
-
-#define SBH_THRESHOLD                                     4  ///< I0156: value of the fixed SBH controlling threshold
-
-#define C1FLAG_NUMBER                                     8 // maximum number of largerThan1 flag coded in one chunk :  16 in HM5
-#define C2FLAG_NUMBER                                     1 // maximum number of largerThan2 flag coded in one chunk:  16 in HM5
-
-#define SAO_ENCODING_CHOICE                               1  ///< I0184: picture early termination
-#if SAO_ENCODING_CHOICE
-#define SAO_ENCODING_RATE                                 0.75
-#define SAO_ENCODING_CHOICE_CHROMA                        1 ///< J0044: picture early termination Luma and Chroma are handled separately
-#if SAO_ENCODING_CHOICE_CHROMA
-#define SAO_ENCODING_RATE_CHROMA                          0.5
-#endif
-#endif
-
-#define MAX_NUM_SAO_OFFSETS                               4
-
-#define MAX_NUM_VPS                                      16
-#define MAX_NUM_SPS                                      16
-#define MAX_NUM_PPS                                      64
-
-#define RDOQ_CHROMA_LAMBDA                                1   ///< F386: weighting of chroma for RDOQ
-
-#define MIN_SCAN_POS_CROSS                                4
-
-#define FAST_BIT_EST                                      1   ///< G763: Table-based bit estimation for CABAC
-
-#define MLS_GRP_NUM                                      64     ///< G644 : Max number of coefficient groups, max(16, 64)
-#define MLS_CG_LOG2_WIDTH                                 2
-#define MLS_CG_LOG2_HEIGHT                                2
-#define MLS_CG_SIZE                                     (MLS_CG_LOG2_WIDTH + MLS_CG_LOG2_HEIGHT)  ///< G644 : Coefficient group size of 4x4
-
-#define ADAPTIVE_QP_SELECTION                             1      ///< G382: Adaptive reconstruction levels, non-normative part for adaptive QP selection
-#if ADAPTIVE_QP_SELECTION
-#define ARL_C_PRECISION                                   7      ///< G382: 7-bit arithmetic precision
-#define LEVEL_RANGE                                      30     ///< G382: max coefficient level in statistics collection
-#endif
-
-#define HHI_RQT_INTRA_SPEEDUP                             1           ///< tests one best mode with full rqt
-#define HHI_RQT_INTRA_SPEEDUP_MOD                         0           ///< tests two best modes with full rqt
-
-#if HHI_RQT_INTRA_SPEEDUP_MOD && !HHI_RQT_INTRA_SPEEDUP
-#error
-#endif
-
-#define AMVP_DECIMATION_FACTOR                            4
-
-#define SCAN_SET_SIZE                                    16
-#define LOG2_SCAN_SET_SIZE                                4
-
-#define FAST_UDI_MAX_RDMODE_NUM                          35          ///< maximum number of RD comparison in fast-UDI estimation loop
-
-#define NUM_INTRA_MODE                                   36
-
-#define WRITE_BACK                                        1           ///< Enable/disable the encoder to replace the deltaPOC and Used by current from the config file with the values derived by the refIdc parameter.
-#define PRINT_RPS_INFO                                    0           ///< Enable/disable the printing of bits used to send the RPS.
-                                                                        // using one nearest frame as reference frame, and the other frames are high quality (POC%4==0) frames (1+X)
-                                                                        // this should be done with encoder only decision
-                                                                        // but because of the absence of reference frame management, the related code was hard coded currently
-
-#define RVM_VCEGAM10_M 4
-
-#define PLANAR_IDX                                        0
-#define VER_IDX                                          26                    // index for intra VERTICAL   mode
-#define HOR_IDX                                          10                    // index for intra HORIZONTAL mode
-#define DC_IDX                                            1                    // index for intra DC mode
-#define NUM_CHROMA_MODE                                   5                    // total number of chroma modes
-#define DM_CHROMA_IDX                                    36                    // chroma mode index for derived from luma intra mode
-#define INVALID_MODE_IDX                                 (NUM_INTRA_MODE+1)    // value used to indicate an invalid intra mode
-#define STOPCHROMASEARCH_MODE_IDX                        (INVALID_MODE_IDX+1)  // value used to signal the end of a chroma mode search
-
-#define MDCS_ANGLE_LIMIT                                  4         ///< (default 4) 0 = Horizontal/vertical only, 1 = Horizontal/vertical +/- 1, 2 = Horizontal/vertical +/- 2 etc...
-#define MDCS_MAXIMUM_WIDTH                                8         ///< (default 8) (measured in pixels) TUs with width greater than this can only use diagonal scan
-#define MDCS_MAXIMUM_HEIGHT                               8         ///< (default 8) (measured in pixels) TUs with height greater than this can only use diagonal scan
-
-#define RDO_WITHOUT_DQP_BITS                              0           ///< Disable counting dQP bits in RDO-based mode decision
-
-#define LOG2_MAX_NUM_COLUMNS_MINUS1                       7
-#define LOG2_MAX_NUM_ROWS_MINUS1                          7
-#define LOG2_MAX_COLUMN_WIDTH                            13
-#define LOG2_MAX_ROW_HEIGHT                              13
-
-#define MATRIX_MULT                                       0 // Brute force matrix multiplication instead of partial butterfly
-
-#define AMP_SAD                                           1 ///< dedicated SAD functions for AMP
-#define AMP_ENC_SPEEDUP                                   1 ///< encoder only speed-up by AMP mode skipping
-#if AMP_ENC_SPEEDUP
-#define AMP_MRG                                           1 ///< encoder only force merge for AMP partition (no motion search for AMP)
-#endif
-
-#define CABAC_INIT_PRESENT_FLAG                           1
-
-#define LUMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS    4
-#define CHROMA_INTERPOLATION_FILTER_SUB_SAMPLE_POSITIONS  8
-
-#define MAX_NUM_LONG_TERM_REF_PICS                       33
-#define NUM_LONG_TERM_REF_PIC_SPS                         0
-
-#define DECODER_CHECK_SUBSTREAM_AND_SLICE_TRAILING_BYTES  1
-
-#define RD_TEST_SAO_DISABLE_AT_PICTURE_LEVEL              0 ///< 1 = tests whether SAO should be disabled at the picture level,  0 (default) = does not apply this additional test
-
-#define O0043_BEST_EFFORT_DECODING                        0 ///< 0 (default) = disable code related to best effort decoding, 1 = enable code relating to best effort decoding [ decode-side only ].
-
-#define MAX_QP_OFFSET_LIST_SIZE                           6 ///< Maximum size of QP offset list is 6 entries
-// Cost mode support
-
-#define LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP       0 ///< QP to use for lossless coding.
-#define LOSSLESS_AND_MIXED_LOSSLESS_RD_COST_TEST_QP_PRIME 4 ///< QP' to use for mixed_lossy_lossless coding.
-
-// Debug support
-
-#define ENVIRONMENT_VARIABLE_DEBUG_AND_TEST               0 ///< When enabled, allows control of debug modifications via environment variables
-
-#define PRINT_MACRO_VALUES                                1 ///< When enabled, the encoder prints out a list of the non-environment-variable controlled macros and their values on startup
-
-// TODO: rename this macro to DECODER_DEBUG_BIT_STATISTICS (may currently cause merge issues with other branches)
-// This can be enabled by the makefile
-#ifndef RExt__DECODER_DEBUG_BIT_STATISTICS
-#define RExt__DECODER_DEBUG_BIT_STATISTICS                                     0 ///< 0 (default) = decoder reports as normal, 1 = decoder produces bit usage statistics (will impact decoder run time by up to ~10%)
-#endif
-
-// This can be enabled by the makefile
-#ifndef RExt__HIGH_BIT_DEPTH_SUPPORT
-#define RExt__HIGH_BIT_DEPTH_SUPPORT                                           0 ///< 0 (default) use data type definitions for 8-10 bit video, 1 = use larger data types to allow for up to 16-bit video (originally developed as part of N0188)
-#endif
-
-#define RExt__GOLOMB_RICE_ADAPTATION_STATISTICS_SETS                           4
-#define RExt__GOLOMB_RICE_INCREMENT_DIVISOR                                    4
-
-#define RExt__PREDICTION_WEIGHTING_ANALYSIS_DC_PRECISION                       0 ///< Additional fixed bit precision used during encoder-side weighting prediction analysis. Currently only used when high_precision_prediction_weighting_flag is set, for backwards compatibility reasons.
-
-#define MAX_TIMECODE_SEI_SETS                                                  3 ///< Maximum number of time sets
-
-//------------------------------------------------
-// Derived macros
-//------------------------------------------------
-
-#if RExt__HIGH_BIT_DEPTH_SUPPORT
-#define FULL_NBIT                                                              1 ///< When enabled, use distortion measure derived from all bits of source data, otherwise discard (bitDepth - 8) least-significant bits of distortion
-#define RExt__HIGH_PRECISION_FORWARD_TRANSFORM                                 1 ///< 0 use original 6-bit transform matrices for both forward and inverse transform, 1 (default) = use original matrices for inverse transform and high precision matrices for forward transform
-#else
-#define FULL_NBIT                                                              0 ///< When enabled, use distortion measure derived from all bits of source data, otherwise discard (bitDepth - 8) least-significant bits of distortion
-#define RExt__HIGH_PRECISION_FORWARD_TRANSFORM                                 0 ///< 0 (default) use original 6-bit transform matrices for both forward and inverse transform, 1 = use original matrices for inverse transform and high precision matrices for forward transform
-#endif
-
-#if FULL_NBIT
-# define DISTORTION_PRECISION_ADJUSTMENT(x)  0
-#else
-# define DISTORTION_PRECISION_ADJUSTMENT(x) (x)
-#endif
-
-
-//------------------------------------------------
+// ====================================================================================================================
 // Error checks
-//------------------------------------------------
+// ====================================================================================================================
 
 #if ((RExt__HIGH_PRECISION_FORWARD_TRANSFORM != 0) && (RExt__HIGH_BIT_DEPTH_SUPPORT == 0))
@@ -405,4 +296,29 @@
 #endif
 
+// ====================================================================================================================
+// Named numerical types
+// ====================================================================================================================
+
+#if RExt__HIGH_BIT_DEPTH_SUPPORT
+typedef       Int             Pel;               ///< pixel type
+typedef       Int64           TCoeff;            ///< transform coefficient
+typedef       Int             TMatrixCoeff;      ///< transform matrix coefficient
+typedef       Short           TFilterCoeff;      ///< filter coefficient
+typedef       Int64           Intermediate_Int;  ///< used as intermediate value in calculations
+typedef       UInt64          Intermediate_UInt; ///< used as intermediate value in calculations
+#else
+typedef       Short           Pel;               ///< pixel type
+typedef       Int             TCoeff;            ///< transform coefficient
+typedef       Short           TMatrixCoeff;      ///< transform matrix coefficient
+typedef       Short           TFilterCoeff;      ///< filter coefficient
+typedef       Int             Intermediate_Int;  ///< used as intermediate value in calculations
+typedef       UInt            Intermediate_UInt; ///< used as intermediate value in calculations
+#endif
+
+#if FULL_NBIT
+typedef       UInt64          Distortion;        ///< distortion measurement
+#else
+typedef       UInt            Distortion;        ///< distortion measurement
+#endif
 
 // ====================================================================================================================
@@ -776,29 +692,88 @@
 };
 
+// TODO: Existing names used for the different NAL unit types can be altered to better reflect the names in the spec.
+//       However, the names in the spec are not yet stable at this point. Once the names are stable, a cleanup
+//       effort can be done without use of macros to alter the names used to indicate the different NAL unit types.
+enum NalUnitType
+{
+  NAL_UNIT_CODED_SLICE_TRAIL_N = 0, // 0
+  NAL_UNIT_CODED_SLICE_TRAIL_R,     // 1
+
+  NAL_UNIT_CODED_SLICE_TSA_N,       // 2
+  NAL_UNIT_CODED_SLICE_TSA_R,       // 3
+
+  NAL_UNIT_CODED_SLICE_STSA_N,      // 4
+  NAL_UNIT_CODED_SLICE_STSA_R,      // 5
+
+  NAL_UNIT_CODED_SLICE_RADL_N,      // 6
+  NAL_UNIT_CODED_SLICE_RADL_R,      // 7
+
+  NAL_UNIT_CODED_SLICE_RASL_N,      // 8
+  NAL_UNIT_CODED_SLICE_RASL_R,      // 9
+
+  NAL_UNIT_RESERVED_VCL_N10,
+  NAL_UNIT_RESERVED_VCL_R11,
+  NAL_UNIT_RESERVED_VCL_N12,
+  NAL_UNIT_RESERVED_VCL_R13,
+  NAL_UNIT_RESERVED_VCL_N14,
+  NAL_UNIT_RESERVED_VCL_R15,
+
+  NAL_UNIT_CODED_SLICE_BLA_W_LP,    // 16
+  NAL_UNIT_CODED_SLICE_BLA_W_RADL,  // 17
+  NAL_UNIT_CODED_SLICE_BLA_N_LP,    // 18
+  NAL_UNIT_CODED_SLICE_IDR_W_RADL,  // 19
+  NAL_UNIT_CODED_SLICE_IDR_N_LP,    // 20
+  NAL_UNIT_CODED_SLICE_CRA,         // 21
+  NAL_UNIT_RESERVED_IRAP_VCL22,
+  NAL_UNIT_RESERVED_IRAP_VCL23,
+
+  NAL_UNIT_RESERVED_VCL24,
+  NAL_UNIT_RESERVED_VCL25,
+  NAL_UNIT_RESERVED_VCL26,
+  NAL_UNIT_RESERVED_VCL27,
+  NAL_UNIT_RESERVED_VCL28,
+  NAL_UNIT_RESERVED_VCL29,
+  NAL_UNIT_RESERVED_VCL30,
+  NAL_UNIT_RESERVED_VCL31,
+
+  NAL_UNIT_VPS,                     // 32
+  NAL_UNIT_SPS,                     // 33
+  NAL_UNIT_PPS,                     // 34
+  NAL_UNIT_ACCESS_UNIT_DELIMITER,   // 35
+  NAL_UNIT_EOS,                     // 36
+  NAL_UNIT_EOB,                     // 37
+  NAL_UNIT_FILLER_DATA,             // 38
+  NAL_UNIT_PREFIX_SEI,              // 39
+  NAL_UNIT_SUFFIX_SEI,              // 40
+
+  NAL_UNIT_RESERVED_NVCL41,
+  NAL_UNIT_RESERVED_NVCL42,
+  NAL_UNIT_RESERVED_NVCL43,
+  NAL_UNIT_RESERVED_NVCL44,
+  NAL_UNIT_RESERVED_NVCL45,
+  NAL_UNIT_RESERVED_NVCL46,
+  NAL_UNIT_RESERVED_NVCL47,
+  NAL_UNIT_UNSPECIFIED_48,
+  NAL_UNIT_UNSPECIFIED_49,
+  NAL_UNIT_UNSPECIFIED_50,
+  NAL_UNIT_UNSPECIFIED_51,
+  NAL_UNIT_UNSPECIFIED_52,
+  NAL_UNIT_UNSPECIFIED_53,
+  NAL_UNIT_UNSPECIFIED_54,
+  NAL_UNIT_UNSPECIFIED_55,
+  NAL_UNIT_UNSPECIFIED_56,
+  NAL_UNIT_UNSPECIFIED_57,
+  NAL_UNIT_UNSPECIFIED_58,
+  NAL_UNIT_UNSPECIFIED_59,
+  NAL_UNIT_UNSPECIFIED_60,
+  NAL_UNIT_UNSPECIFIED_61,
+  NAL_UNIT_UNSPECIFIED_62,
+  NAL_UNIT_UNSPECIFIED_63,
+  NAL_UNIT_INVALID,
+};
+
 // ====================================================================================================================
 // Type definition
 // ====================================================================================================================
-
-#if RExt__HIGH_BIT_DEPTH_SUPPORT
-typedef       Int             Pel;               ///< pixel type
-typedef       Int64           TCoeff;            ///< transform coefficient
-typedef       Int             TMatrixCoeff;      ///< transform matrix coefficient
-typedef       Short           TFilterCoeff;      ///< filter coefficient
-typedef       Int64           Intermediate_Int;  ///< used as intermediate value in calculations
-typedef       UInt64          Intermediate_UInt; ///< used as intermediate value in calculations
-#else
-typedef       Short           Pel;               ///< pixel type
-typedef       Int             TCoeff;            ///< transform coefficient
-typedef       Short           TMatrixCoeff;      ///< transform matrix coefficient
-typedef       Short           TFilterCoeff;      ///< filter coefficient
-typedef       Int             Intermediate_Int;  ///< used as intermediate value in calculations
-typedef       UInt            Intermediate_UInt; ///< used as intermediate value in calculations
-#endif
-
-#if FULL_NBIT
-typedef       UInt64          Distortion;        ///< distortion measurement
-#else
-typedef       UInt            Distortion;        ///< distortion measurement
-#endif
 
 /// parameters for adaptive loop filter
Index: /branches/SHM-dev/source/Lib/TLibDecoder/AnnexBread.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/AnnexBread.h	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/AnnexBread.h	(revision 1335)
@@ -46,5 +46,5 @@
 #include <vector>
 
-#include "TLibCommon/TypeDef.h"
+#include "TLibCommon/CommonDef.h"
 
 //! \ingroup TLibDecoder
Index: /branches/SHM-dev/source/Lib/TLibDecoder/NALread.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/NALread.h	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/NALread.h	(revision 1335)
@@ -42,5 +42,5 @@
 #define __NALREAD__
 
-#include "TLibCommon/TypeDef.h"
+#include "TLibCommon/CommonDef.h"
 #include "TLibCommon/TComBitStream.h"
 #include "TLibCommon/NAL.h"
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecBinCoderCABAC.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecBinCoderCABAC.cpp	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecBinCoderCABAC.cpp	(revision 1335)
@@ -111,5 +111,5 @@
 #endif
 {
-#ifdef DEBUG_CABAC_BINS
+#if DEBUG_CABAC_BINS
   const UInt startingRange = m_uiRange;
 #endif
@@ -161,5 +161,5 @@
   }
 
-#ifdef DEBUG_CABAC_BINS
+#if DEBUG_CABAC_BINS
   if ((g_debugCounter + debugCabacBinWindow) >= debugCabacBinTargetLine)
   {
Index: /branches/SHM-dev/source/Lib/TLibDecoder/TDecCu.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibDecoder/TDecCu.cpp	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibDecoder/TDecCu.cpp	(revision 1335)
@@ -457,5 +457,5 @@
   }
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
   const PredMode predMode=m_ppcCU[uiDepth]->getPredictionMode(0);
   if (DebugOptionList::DebugString_Structure.getInt()&DebugStringGetPredModeMask(predMode))
@@ -482,5 +482,5 @@
   m_pcPrediction->motionCompensation( pcCU, m_ppcYuvReco[uiDepth] );
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
   const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTER);
   if (DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask)
@@ -493,5 +493,5 @@
   xDecodeInterTexture( pcCU, uiDepth );
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
   if (DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask)
   {
@@ -513,5 +513,5 @@
     m_ppcYuvReco[uiDepth]->copyPartToPartYuv( m_ppcYuvReco[uiDepth],0, pcCU->getWidth( 0 ),pcCU->getHeight( 0 ));
   }
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
   if (DebugOptionList::DebugString_Reco.getInt()&debugPredModeMask)
   {
@@ -578,5 +578,5 @@
   const Bool bUseFilteredPredictions=TComPrediction::filteringIntraReferenceSamples(compID, uiChFinalMode, uiWidth, uiHeight, chFmt, pcCU->getSlice()->getSPS()->getSpsRangeExtension().getIntraSmoothingDisabledFlag());
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
   std::ostream &ss(std::cout);
 #endif
@@ -590,5 +590,5 @@
   m_pcPrediction->predIntraAng( compID,   uiChFinalMode, 0 /* Decoder does not have an original image */, 0, piPred, uiStride, rTu, bAboveAvail, bLeftAvail, bUseFilteredPredictions );
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
   ss << sTemp;
 #endif
@@ -602,5 +602,5 @@
 
   DEBUG_STRING_NEW(sDebug);
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
   const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTRA);
   std::string *psDebug=(DebugOptionList::DebugString_InvTran.getInt()&debugPredModeMask) ? &sDebug : 0;
@@ -622,5 +622,5 @@
   }
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
   if (psDebug)
   {
@@ -642,5 +642,5 @@
 
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
   const Bool bDebugPred=((DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID));
   const Bool bDebugResi=((DebugOptionList::DebugString_Resi.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID));
@@ -668,5 +668,5 @@
   for( UInt uiY = 0; uiY < uiHeight; uiY++ )
   {
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
     if (bDebugPred || bDebugResi || bDebugReco)
     {
@@ -690,5 +690,5 @@
     for( UInt uiX = 0; uiX < uiWidth; uiX++ )
     {
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
       if (bDebugResi)
       {
@@ -703,5 +703,5 @@
       pRecIPred[ uiX ] = pReco[ uiX ];
     }
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
     if (bDebugReco)
     {
Index: /branches/SHM-dev/source/Lib/TLibEncoder/NALwrite.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/NALwrite.h	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/NALwrite.h	(revision 1335)
@@ -39,5 +39,5 @@
 #include <ostream>
 
-#include "TLibCommon/TypeDef.h"
+#include "TLibCommon/CommonDef.h"
 #include "TLibCommon/TComBitStream.h"
 #include "TLibCommon/NAL.h"
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncBinCoderCABAC.cpp	(revision 1335)
@@ -196,5 +196,5 @@
   //}
 
-#ifdef DEBUG_CABAC_BINS
+#if DEBUG_CABAC_BINS
   const UInt startingRange = m_uiRange;
 #endif
@@ -228,5 +228,5 @@
   }
 
-#ifdef DEBUG_CABAC_BINS
+#if DEBUG_CABAC_BINS
   if ((g_debugCounter + debugCabacBinWindow) >= debugCabacBinTargetLine)
   {
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncBinCoderCABACCounter.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncBinCoderCABACCounter.cpp	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncBinCoderCABACCounter.cpp	(revision 1335)
@@ -74,5 +74,5 @@
 Void TEncBinCABACCounter::encodeBin( UInt binValue, ContextModel &rcCtxModel )
 {
-#ifdef DEBUG_ENCODER_SEARCH_BINS
+#if DEBUG_ENCODER_SEARCH_BINS
   const UInt64 startingFracBits = m_fracBits;
 #endif
@@ -82,5 +82,5 @@
   rcCtxModel.update( binValue );
 
-#ifdef DEBUG_ENCODER_SEARCH_BINS
+#if DEBUG_ENCODER_SEARCH_BINS
   if ((g_debugCounter + debugEncoderSearchBinWindow) >= debugEncoderSearchBinTargetLine)
   {
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncCu.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncCu.cpp	(revision 1335)
@@ -1376,5 +1376,5 @@
                                                      (uiNoResidual != 0) DEBUG_STRING_PASS_INTO(tmpStr) );
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
           DebugInterPredResiReco(tmpStr, *(m_ppcPredYuvTemp[uhDepth]), *(m_ppcResiYuvBest[uhDepth]), *(m_ppcRecoYuvTemp[uhDepth]), DebugStringGetPredModeMask(rpcTempCU->getPredictionMode(0)));
 #endif
@@ -1486,5 +1486,5 @@
   rpcTempCU->getTotalCost()  = m_pcRdCost->calcRdCost( rpcTempCU->getTotalBits(), rpcTempCU->getTotalDistortion() );
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
   DebugInterPredResiReco(sTest, *(m_ppcPredYuvTemp[uhDepth]), *(m_ppcResiYuvBest[uhDepth]), *(m_ppcRecoYuvTemp[uhDepth]), DebugStringGetPredModeMask(rpcTempCU->getPredictionMode(0)));
 #endif
@@ -1635,5 +1635,5 @@
 
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
     DEBUG_STRING_SWAP(sParent, sTest)
     const PredMode predMode=rpcBestCU->getPredictionMode(0);
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncEntropy.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncEntropy.cpp	(revision 1335)
@@ -37,5 +37,5 @@
 
 #include "TEncEntropy.h"
-#include "TLibCommon/TypeDef.h"
+#include "TLibCommon/CommonDef.h"
 #include "TLibCommon/TComSampleAdaptiveOffset.h"
 #include "TLibCommon/TComTU.h"
Index: /branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/TEncSearch.cpp	(revision 1335)
@@ -36,5 +36,5 @@
  */
 
-#include "TLibCommon/TypeDef.h"
+#include "TLibCommon/CommonDef.h"
 #include "TLibCommon/TComRom.h"
 #include "TLibCommon/TComMotionInfo.h"
@@ -1153,5 +1153,5 @@
         Pel *const     lumaResidualForEstimate              = bUseReconstructedResidualForEstimate ? reconstructedLumaResidual : encoderLumaResidual;
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
   const Int debugPredModeMask=DebugStringGetPredModeMask(MODE_INTRA);
 #endif
@@ -1163,5 +1163,5 @@
   DEBUG_STRING_NEW(sTemp)
 
-#ifndef DEBUG_STRING
+#if !DEBUG_STRING
   if( default0Save1Load2 != 2 )
 #endif
@@ -1190,5 +1190,5 @@
     }
   }
-#ifndef DEBUG_STRING
+#if !DEBUG_STRING
   else
   {
@@ -1273,5 +1273,5 @@
   //--- inverse transform ---
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
   if ( (uiAbsSum > 0) || (DebugOptionList::DebugString_InvTran.getInt()&debugPredModeMask) )
 #else
@@ -1313,5 +1313,5 @@
     }
 
- #ifdef DEBUG_STRING
+ #if DEBUG_STRING
     std::stringstream ss(stringstream::out);
     const Bool bDebugPred=((DebugOptionList::DebugString_Pred.getInt()&debugPredModeMask) && DEBUG_STRING_CHANNEL_CONDITION(compID));
@@ -2331,5 +2331,5 @@
         Double cost      = (Double)uiSad + (Double)iModeBits * sqrtLambdaForFirstPass;
 
-#ifdef DEBUG_INTRA_SEARCH_COSTS
+#if DEBUG_INTRA_SEARCH_COSTS
         std::cout << "1st pass mode " << uiMode << " SAD = " << uiSad << ", mode bits = " << iModeBits << ", cost = " << cost << "\n";
 #endif
@@ -2412,5 +2412,5 @@
 #endif
 
-#ifdef DEBUG_INTRA_SEARCH_COSTS
+#if DEBUG_INTRA_SEARCH_COSTS
       std::cout << "2nd pass [luma,chroma] mode [" << Int(pcCU->getIntraDir(CHANNEL_TYPE_LUMA, uiPartOffset)) << "," << Int(pcCU->getIntraDir(CHANNEL_TYPE_CHROMA, uiPartOffset)) << "] cost = " << dPUCost << "\n";
 #endif
@@ -4550,5 +4550,5 @@
     m_pcRDGoOnSbacCoder->store(m_pppcRDSbacCoder[pcCU->getDepth(0)][CI_TEMP_BEST]);
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
     pcYuvResiBest->clear(); // Clear the residual image, if we didn't code it.
     for(UInt i=0; i<MAX_NUM_COMPONENT+1; i++)
@@ -4598,5 +4598,5 @@
     static const UInt useTS[MAX_NUM_COMPONENT]={0,0,0};
     pcCU->setTransformSkipSubParts ( useTS, 0, pcCU->getDepth(0) );
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
     sDebug.clear();
     for(UInt i=0; i<MAX_NUM_COMPONENT+1; i++)
@@ -4674,5 +4674,5 @@
 
   UInt SplitFlag = ((pcCU->getSlice()->getSPS()->getQuadtreeTUMaxDepthInter() == 1) && pcCU->isInter(uiAbsPartIdx) && ( pcCU->getPartitionSize(uiAbsPartIdx) != SIZE_2Nx2N ));
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
   const Int debugPredModeMask = DebugStringGetPredModeMask(pcCU->getPredictionMode(uiAbsPartIdx));
 #endif
@@ -5002,5 +5002,5 @@
                 }
 
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
                 if (currAbsSum > 0)
                 {
@@ -5167,5 +5167,5 @@
       DEBUG_STRING_NEW(childString)
       xEstimateInterResidualQT( pcResi, dSubdivCost, uiSubdivBits, uiSubdivDist, bCheckFull ? NULL : puiZeroDist,  tuRecurseChild DEBUG_STRING_PASS_INTO(childString));
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
       // split the string by component and append to the relevant output (because decoder decodes in channel order, whereas this search searches by TU-order)
       std::size_t lastPos=0;
@@ -5223,5 +5223,5 @@
       ruiBits += uiSubdivBits;
       ruiDist += uiSubdivDist;
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
       for(UInt ch = 0; ch < numValidComp; ch++)
       {
@@ -5283,5 +5283,5 @@
     ruiBits += uiSingleBits;
     ruiDist += uiSingleDist;
-#ifdef DEBUG_STRING
+#if DEBUG_STRING
     for(UInt ch = 0; ch < numValidComp; ch++)
     {
Index: /branches/SHM-dev/source/Lib/TLibEncoder/WeightPredAnalysis.cpp
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/WeightPredAnalysis.cpp	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/WeightPredAnalysis.cpp	(revision 1335)
@@ -36,5 +36,5 @@
 */
 
-#include "../TLibCommon/TypeDef.h"
+#include "../TLibCommon/CommonDef.h"
 #include "../TLibCommon/TComSlice.h"
 #include "../TLibCommon/TComPic.h"
Index: /branches/SHM-dev/source/Lib/TLibEncoder/WeightPredAnalysis.h
===================================================================
--- /branches/SHM-dev/source/Lib/TLibEncoder/WeightPredAnalysis.h	(revision 1334)
+++ /branches/SHM-dev/source/Lib/TLibEncoder/WeightPredAnalysis.h	(revision 1335)
@@ -38,5 +38,5 @@
 #define __WEIGHTPREDANALYSIS__
 
-#include "../TLibCommon/TypeDef.h"
+#include "../TLibCommon/CommonDef.h"
 #include "../TLibCommon/TComSlice.h"
 #include "TEncCavlc.h"
@@ -46,5 +46,5 @@
 private:
 
-  // member variables  
+  // member variables
   WPScalingParam  m_wp[NUM_REF_PIC_LIST_01][MAX_NUM_REF][MAX_NUM_COMPONENT];
 
